2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
2024-02-02 13:36:10 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2016-06-30 10:07:18 +00:00
|
|
|
|
Mark all of Qt as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses in this and some other modules is still
extremely high, too high for anyone to tackle in a short amount of
time. Even if they're not concentrated in just a few TUs, we need to
make progress on a global QT_NO_FOREACH default, so grab the nettle
and stick to our strategy:
Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too).
In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the
#undef QT_NO_FOREACH to indicate that these actually test the macro.
Task-number: QTBUG-115839
Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-07 15:59:46 +00:00
|
|
|
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
|
|
|
|
|
2016-06-30 10:07:18 +00:00
|
|
|
#include "itemwindow.h"
|
|
|
|
|
|
|
|
#include <QtGui/QPainter>
|
|
|
|
#include <QtGui/QPaintEvent>
|
|
|
|
|
|
|
|
void TextItem::paint(QPainter &painter)
|
|
|
|
{
|
|
|
|
painter.fillRect(m_rect, m_col);
|
|
|
|
painter.drawRect(m_rect);
|
|
|
|
QTextOption textOption;
|
|
|
|
textOption.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
|
|
painter.drawText(m_rect, m_text, textOption);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ButtonItem::mouseEvent(QMouseEvent *mouseEvent)
|
|
|
|
{
|
|
|
|
if (mouseEvent->type() == QEvent::MouseButtonPress && rect().contains(mouseEvent->pos())) {
|
|
|
|
mouseEvent->accept();
|
|
|
|
emit clicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ButtonItem::keyEvent(QKeyEvent *keyEvent)
|
|
|
|
{
|
|
|
|
if (m_shortcut && keyEvent->type() == QEvent::KeyPress
|
|
|
|
&& (keyEvent->key() + int(keyEvent->modifiers())) == m_shortcut) {
|
|
|
|
keyEvent->accept();
|
|
|
|
emit clicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ItemWindow::paintEvent(QPaintEvent *)
|
|
|
|
{
|
|
|
|
QPainter painter(this);
|
|
|
|
QRect rect(QPoint(0, 0), size());
|
|
|
|
painter.fillRect(rect, m_background);
|
|
|
|
foreach (Item *i, m_items)
|
|
|
|
i->paint(painter);
|
|
|
|
}
|