diff options
Diffstat (limited to 'src/widgets/widgets')
94 files changed, 1248 insertions, 951 deletions
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 7fa50f4c0b..400233caa9 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -117,21 +117,21 @@ Q_SIGNALS: void toggled(bool checked); protected: - virtual void paintEvent(QPaintEvent *e) = 0; + void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE = 0; virtual bool hitButton(const QPoint &pos) const; virtual void checkStateSet(); virtual void nextCheckState(); - bool event(QEvent *e); - void keyPressEvent(QKeyEvent *e); - void keyReleaseEvent(QKeyEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void focusInEvent(QFocusEvent *e); - void focusOutEvent(QFocusEvent *e); - void changeEvent(QEvent *e); - void timerEvent(QTimerEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void changeEvent(QEvent *e) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; protected: diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 4cafeafcec..62234cf125 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -54,7 +54,7 @@ #include <private/qapplication_p.h> -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -162,7 +162,7 @@ QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate() shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored), viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0), xoffset(0), yoffset(0), viewportFilter(0) -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN , singleFingerPanEnabled(false) #endif { @@ -308,7 +308,7 @@ void QAbstractScrollAreaPrivate::init() #endif } -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on) { singleFingerPanEnabled = on; @@ -316,7 +316,7 @@ void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on) if (dd) dd->winSetupGestures(); } -#endif // Q_WS_WIN +#endif // Q_DEAD_CODE_FROM_QT4_WIN void QAbstractScrollAreaPrivate::layoutChildren() { @@ -337,7 +337,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() const int hscrollOverlap = hbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, hbar); const int vscrollOverlap = vbar->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarOverlap, &opt, vbar); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC QWidget * const window = q->window(); // Use small scroll bars for tool windows, to match the native size grip. @@ -380,7 +380,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() // If the scroll bars are at the very right and bottom of the window we // move their positions to be aligned with the size grip. -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC // Check if a native sizegrip is present. bool hasMacReverseSizeGrip = false; bool hasMacSizeGrip = false; @@ -433,7 +433,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() if (hasCornerWidget && ((needv && vscrollOverlap == 0) || (needh && hscrollOverlap == 0))) cornerOffset = extPoint; -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC // Also move the scroll bars if they are covered by the native Mac size grip. if (hasMacSizeGrip) cornerOffset = extPoint; @@ -448,7 +448,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() // (transparent) sizegrip in the area where a corner widget would be. if ((needv && needh && hasCornerWidget == false && hscrollOverlap == 0 && vscrollOverlap == 0) || ((needv || needh) -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC && hasMacSizeGrip #endif ) @@ -458,7 +458,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() cornerPaintingRect = QRect(); } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (hasMacReverseSizeGrip) reverseCornerPaintingRect = QRect(controlsRect.bottomRight() + QPoint(1, 1) - extPoint, extSize); else @@ -483,7 +483,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() if (needh) { QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom())); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (hasMacReverseSizeGrip) horizontalScrollBarRect.adjust(vsbExt, 0, 0, 0); #endif @@ -603,7 +603,7 @@ void QAbstractScrollArea::setViewport(QWidget *widget) d->viewport->setParent(this); d->viewport->setFocusProxy(this); d->viewport->installEventFilter(d->viewportFilter.data()); -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC #ifndef QT_NO_GESTURES d->viewport->grabGesture(Qt::PanGesture); #endif @@ -923,7 +923,7 @@ QWidgetList QAbstractScrollArea::scrollBarWidgets(Qt::Alignment alignment) they should not call this function. By default all margins are zero. - + \sa viewportMargins() */ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom) { @@ -943,7 +943,7 @@ void QAbstractScrollArea::setViewportMargins(int left, int top, int right, int b area. By default all margins are zero. - + \sa viewportMargins() */ void QAbstractScrollArea::setViewportMargins(const QMargins &margins) { @@ -951,6 +951,19 @@ void QAbstractScrollArea::setViewportMargins(const QMargins &margins) margins.right(), margins.bottom()); } +/*! + \since 5.5 + Returns the margins around the scrolling area. + By default all the margins are zero. + + \sa setViewportMargins() +*/ +QMargins QAbstractScrollArea::viewportMargins() const +{ + Q_D(const QAbstractScrollArea); + return QMargins(d->left, d->top, d->right, d->bottom); +} + /*! \internal */ bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e) { @@ -1017,7 +1030,7 @@ bool QAbstractScrollArea::event(QEvent *e) QPainter p(this); style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this); } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (d->reverseCornerPaintingRect.isValid()) { option.rect = d->reverseCornerPaintingRect; QPainter p(this); @@ -1096,7 +1109,7 @@ bool QAbstractScrollArea::event(QEvent *e) hBar->setValue(se->contentPos().x()); vBar->setValue(se->contentPos().y()); -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN typedef BOOL (*PtrBeginPanningFeedback)(HWND); typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL); typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL); @@ -1520,13 +1533,13 @@ void QAbstractScrollAreaPrivate::_q_vslide(int y) void QAbstractScrollAreaPrivate::_q_showOrHideScrollBars() { layoutChildren(); -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN // Need to re-subscribe to gestures as the content changes to make sure we // enable/disable panning when needed. QWidgetPrivate *dd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(viewport)); if (dd) dd->winSetupGestures(); -#endif // Q_WS_WIN +#endif // Q_DEAD_CODE_FROM_QT4_WIN } QPoint QAbstractScrollAreaPrivate::contentsOffset() const diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index a3f6c3e2d4..9ce8d286b7 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -49,7 +49,6 @@ class Q_WIDGETS_EXPORT QAbstractScrollArea : public QFrame { Q_OBJECT - Q_ENUMS(SizeAdjustPolicy) Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy) Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy) Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy) @@ -63,6 +62,7 @@ public: AdjustToContentsOnFirstShow, AdjustToContents }; + Q_ENUM(SizeAdjustPolicy) Qt::ScrollBarPolicy verticalScrollBarPolicy() const; void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy); @@ -84,9 +84,9 @@ public: void setViewport(QWidget *widget); QSize maximumViewportSize() const; - QSize minimumSizeHint() const; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; virtual void setupViewport(QWidget *viewport); @@ -97,31 +97,32 @@ protected: QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0); void setViewportMargins(int left, int top, int right, int bottom); void setViewportMargins(const QMargins &margins); + QMargins viewportMargins() const; - bool eventFilter(QObject *, QEvent *); - bool event(QEvent *); + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; virtual bool viewportEvent(QEvent *); - void resizeEvent(QResizeEvent *); - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *); + void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_DRAGANDDROP - void dragEnterEvent(QDragEnterEvent *); - void dragMoveEvent(QDragMoveEvent *); - void dragLeaveEvent(QDragLeaveEvent *); - void dropEvent(QDropEvent *); + void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent *) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent *) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent *) Q_DECL_OVERRIDE; #endif - void keyPressEvent(QKeyEvent *); + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; virtual void scrollContentsBy(int dx, int dy); diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h index aaf93a3352..fbc542ee02 100644 --- a/src/widgets/widgets/qabstractscrollarea_p.h +++ b/src/widgets/widgets/qabstractscrollarea_p.h @@ -75,7 +75,7 @@ public: QWidget *viewport; QWidget *cornerWidget; QRect cornerPaintingRect; -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC QRect reverseCornerPaintingRect; #endif int left, top, right, bottom; // viewport margin @@ -102,7 +102,7 @@ public: { return q_func()->viewportEvent(event); } QScopedPointer<QObject> viewportFilter; -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN bool singleFingerPanEnabled; void setSingleFingerPanEnabled(bool on = true); #endif @@ -114,7 +114,7 @@ class QAbstractScrollAreaFilter : public QObject public: QAbstractScrollAreaFilter(QAbstractScrollAreaPrivate *p) : d(p) { setObjectName(QLatin1String("qt_abstractscrollarea_filter")); } - bool eventFilter(QObject *o, QEvent *e) + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE { return (o == d->viewport ? d->viewportEvent(e) : false); } private: QAbstractScrollAreaPrivate *d; diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index d9dae9d775..f0b59471bc 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -710,7 +710,7 @@ bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::Keyb offset_accumulated = 0; offset_accumulated += stepsToScrollF; -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC // Don't scroll more than one page in any case: stepsToScroll = qBound(-pageStep, int(offset_accumulated), pageStep); #else @@ -728,7 +728,7 @@ bool QAbstractSliderPrivate::scrollByDelta(Qt::Orientation orientation, Qt::Keyb stepsToScroll = -stepsToScroll; int prevValue = value; - position = overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction() + position = bound(overflowSafeAdd(stepsToScroll)); // value will be updated by triggerAction() q->triggerAction(QAbstractSlider::SliderMove); if (prevValue == value) { diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h index 99312a0ef7..3b107d5502 100644 --- a/src/widgets/widgets/qabstractslider.h +++ b/src/widgets/widgets/qabstractslider.h @@ -122,7 +122,7 @@ Q_SIGNALS: void actionTriggered(int action); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50); SliderAction repeatAction() const; @@ -135,12 +135,12 @@ protected: }; virtual void sliderChange(SliderChange change); - void keyPressEvent(QKeyEvent *ev); - void timerEvent(QTimerEvent *); + void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *e); + void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif - void changeEvent(QEvent *e); + void changeEvent(QEvent *e) Q_DECL_OVERRIDE; protected: diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index 8fcb5eadf0..234c06bb10 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -51,8 +51,6 @@ class Q_WIDGETS_EXPORT QAbstractSpinBox : public QWidget { Q_OBJECT - Q_ENUMS(ButtonSymbols) - Q_ENUMS(CorrectionMode) Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping) Q_PROPERTY(bool frame READ hasFrame WRITE setFrame) Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) @@ -74,11 +72,13 @@ public: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag) enum ButtonSymbols { UpDownArrows, PlusMinus, NoButtons }; + Q_ENUM(ButtonSymbols) ButtonSymbols buttonSymbols() const; void setButtonSymbols(ButtonSymbols bs); enum CorrectionMode { CorrectToPreviousValue, CorrectToNearestValue }; + Q_ENUM(CorrectionMode) void setCorrectionMode(CorrectionMode cm); CorrectionMode correctionMode() const; diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index fa3dbc1f32..099727cbd3 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -65,6 +65,11 @@ enum { namespace { +static QString formatNumber(int number, int fieldWidth) +{ + return QString::number(number).rightJustified(fieldWidth, QLatin1Char('0')); +} + class QCalendarDateSectionValidator { public: @@ -86,16 +91,16 @@ public: QLocale m_locale; protected: - QString highlightString(const QString &str, int pos) const; + static QString highlightString(const QString &str, int pos); private: }; -QString QCalendarDateSectionValidator::highlightString(const QString &str, int pos) const +QString QCalendarDateSectionValidator::highlightString(const QString &str, int pos) { if (pos == 0) return QLatin1String("<b>") + str + QLatin1String("</b>"); int startPos = str.length() - pos; - return str.mid(0, startPos) + QLatin1String("<b>") + str.mid(startPos, pos) + QLatin1String("</b>"); + return str.midRef(0, startPos) + QLatin1String("<b>") + str.midRef(startPos, pos) + QLatin1String("</b>"); } @@ -104,11 +109,11 @@ class QCalendarDayValidator : public QCalendarDateSectionValidator public: QCalendarDayValidator(); - virtual Section handleKey(int key); - virtual QDate applyToDate(const QDate &date) const; - virtual void setDate(const QDate &date); - virtual QString text() const; - virtual QString text(const QDate &date, int repeat) const; + virtual Section handleKey(int key) Q_DECL_OVERRIDE; + virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE; + virtual void setDate(const QDate &date) Q_DECL_OVERRIDE; + virtual QString text() const Q_DECL_OVERRIDE; + virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE; private: int m_pos; int m_day; @@ -189,11 +194,7 @@ void QCalendarDayValidator::setDate(const QDate &date) QString QCalendarDayValidator::text() const { - QString str; - if (m_day / 10 == 0) - str += QLatin1Char('0'); - str += QString::number(m_day); - return highlightString(str, m_pos); + return highlightString(formatNumber(m_day, 2), m_pos); } QString QCalendarDayValidator::text(const QDate &date, int repeat) const @@ -201,10 +202,7 @@ QString QCalendarDayValidator::text(const QDate &date, int repeat) const if (repeat <= 1) { return QString::number(date.day()); } else if (repeat == 2) { - QString str; - if (date.day() / 10 == 0) - str += QLatin1Char('0'); - return str + QString::number(date.day()); + return formatNumber(date.day(), 2); } else if (repeat == 3) { return m_locale.dayName(date.dayOfWeek(), QLocale::ShortFormat); } else if (repeat >= 4) { @@ -220,11 +218,11 @@ class QCalendarMonthValidator : public QCalendarDateSectionValidator public: QCalendarMonthValidator(); - virtual Section handleKey(int key); - virtual QDate applyToDate(const QDate &date) const; - virtual void setDate(const QDate &date); - virtual QString text() const; - virtual QString text(const QDate &date, int repeat) const; + virtual Section handleKey(int key) Q_DECL_OVERRIDE; + virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE; + virtual void setDate(const QDate &date) Q_DECL_OVERRIDE; + virtual QString text() const Q_DECL_OVERRIDE; + virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE; private: int m_pos; int m_month; @@ -307,11 +305,7 @@ void QCalendarMonthValidator::setDate(const QDate &date) QString QCalendarMonthValidator::text() const { - QString str; - if (m_month / 10 == 0) - str += QLatin1Char('0'); - str += QString::number(m_month); - return highlightString(str, m_pos); + return highlightString(formatNumber(m_month, 2), m_pos); } QString QCalendarMonthValidator::text(const QDate &date, int repeat) const @@ -319,10 +313,7 @@ QString QCalendarMonthValidator::text(const QDate &date, int repeat) const if (repeat <= 1) { return QString::number(date.month()); } else if (repeat == 2) { - QString str; - if (date.month() / 10 == 0) - str += QLatin1Char('0'); - return str + QString::number(date.month()); + return formatNumber(date.month(), 2); } else if (repeat == 3) { return m_locale.standaloneMonthName(date.month(), QLocale::ShortFormat); } else /*if (repeat >= 4)*/ { @@ -337,11 +328,11 @@ class QCalendarYearValidator : public QCalendarDateSectionValidator public: QCalendarYearValidator(); - virtual Section handleKey(int key); - virtual QDate applyToDate(const QDate &date) const; - virtual void setDate(const QDate &date); - virtual QString text() const; - virtual QString text(const QDate &date, int repeat) const; + virtual Section handleKey(int key) Q_DECL_OVERRIDE; + virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE; + virtual void setDate(const QDate &date) Q_DECL_OVERRIDE; + virtual QString text() const Q_DECL_OVERRIDE; + virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE; private: int pow10(int n); int m_pos; @@ -420,26 +411,13 @@ void QCalendarYearValidator::setDate(const QDate &date) QString QCalendarYearValidator::text() const { - QString str; - int pow = 10; - for (int i = 0; i < 3; i++) { - if (m_year / pow == 0) - str += QLatin1Char('0'); - pow *= 10; - } - str += QString::number(m_year); - return highlightString(str, m_pos); + return highlightString(formatNumber(m_year, 4), m_pos); } QString QCalendarYearValidator::text(const QDate &date, int repeat) const { - if (repeat < 4) { - QString str; - int year = date.year() % 100; - if (year / 10 == 0) - str = QLatin1Char('0'); - return str + QString::number(year); - } + if (repeat < 4) + return formatNumber(date.year() % 100, 2); return QString::number(date.year()); } @@ -476,9 +454,9 @@ private: QStringList m_separators; QList<SectionToken *> m_tokens; - QCalendarDateSectionValidator *m_yearValidator; - QCalendarDateSectionValidator *m_monthValidator; - QCalendarDateSectionValidator *m_dayValidator; + QCalendarYearValidator m_yearValidator; + QCalendarMonthValidator m_monthValidator; + QCalendarDayValidator m_dayValidator; SectionToken *m_currentToken; @@ -489,26 +467,22 @@ private: }; QCalendarDateValidator::QCalendarDateValidator() - : m_currentToken(0), m_lastSectionMove(QCalendarDateSectionValidator::ThisSection) + : m_currentToken(Q_NULLPTR), + m_initialDate(QDate::currentDate()), + m_currentDate(m_initialDate), + m_lastSectionMove(QCalendarDateSectionValidator::ThisSection) { - m_initialDate = m_currentDate = QDate::currentDate(); - m_yearValidator = new QCalendarYearValidator(); - m_monthValidator = new QCalendarMonthValidator(); - m_dayValidator = new QCalendarDayValidator(); } void QCalendarDateValidator::setLocale(const QLocale &locale) { - m_yearValidator->m_locale = locale; - m_monthValidator->m_locale = locale; - m_dayValidator->m_locale = locale; + m_yearValidator.m_locale = locale; + m_monthValidator.m_locale = locale; + m_dayValidator.m_locale = locale; } QCalendarDateValidator::~QCalendarDateValidator() { - delete m_yearValidator; - delete m_monthValidator; - delete m_dayValidator; clear(); } @@ -525,9 +499,9 @@ int QCalendarDateValidator::countRepeat(const QString &str, int index) const void QCalendarDateValidator::setInitialDate(const QDate &date) { - m_yearValidator->setDate(date); - m_monthValidator->setDate(date); - m_dayValidator->setDate(date); + m_yearValidator.setDate(date); + m_monthValidator.setDate(date); + m_dayValidator.setDate(date); m_initialDate = date; m_currentDate = date; m_lastSectionMove = QCalendarDateSectionValidator::ThisSection; @@ -587,13 +561,13 @@ void QCalendarDateValidator::setFormat(const QString &format) SectionToken *token = 0; if (nextChar == QLatin1Char('d')) { offset = qMin(4, countRepeat(format, pos)); - token = new SectionToken(m_dayValidator, offset); + token = new SectionToken(&m_dayValidator, offset); } else if (nextChar == QLatin1Char('M')) { offset = qMin(4, countRepeat(format, pos)); - token = new SectionToken(m_monthValidator, offset); + token = new SectionToken(&m_monthValidator, offset); } else if (nextChar == QLatin1Char('y')) { offset = qMin(4, countRepeat(format, pos)); - token = new SectionToken(m_yearValidator, offset); + token = new SectionToken(&m_yearValidator, offset); } else { separator += nextChar; } @@ -614,9 +588,9 @@ void QCalendarDateValidator::setFormat(const QString &format) void QCalendarDateValidator::applyToDate() { - m_currentDate = m_yearValidator->applyToDate(m_currentDate); - m_currentDate = m_monthValidator->applyToDate(m_currentDate); - m_currentDate = m_dayValidator->applyToDate(m_currentDate); + m_currentDate = m_yearValidator.applyToDate(m_currentDate); + m_currentDate = m_monthValidator.applyToDate(m_currentDate); + m_currentDate = m_dayValidator.applyToDate(m_currentDate); } void QCalendarDateValidator::toNextToken() @@ -683,8 +657,8 @@ public: QDate date() const; void setDate(const QDate &date); - bool eventFilter(QObject *o, QEvent *e); - void timerEvent(QTimerEvent *e); + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; signals: void dateChanged(const QDate &date); @@ -853,32 +827,32 @@ class QCalendarModel : public QAbstractTableModel public: QCalendarModel(QObject *parent = 0); - int rowCount(const QModelIndex &) const + int rowCount(const QModelIndex &) const Q_DECL_OVERRIDE { return RowCount + m_firstRow; } - int columnCount(const QModelIndex &) const + int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE { return ColumnCount + m_firstColumn; } - QVariant data(const QModelIndex &index, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE; - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginInsertRows(parent, row, row + count - 1); endInsertRows(); return true; } - bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) + bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginInsertColumns(parent, column, column + count - 1); endInsertColumns(); return true; } - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginRemoveRows(parent, row, row + count - 1); endRemoveRows(); return true; } - bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) + bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE { beginRemoveColumns(parent, column, column + count - 1); endRemoveColumns(); @@ -939,7 +913,7 @@ public: void internalUpdate() { updateGeometries(); } void setReadOnly(bool enable); - virtual void keyboardSearch(const QString & search) { Q_UNUSED(search) } + virtual void keyboardSearch(const QString & search) Q_DECL_OVERRIDE { Q_UNUSED(search) } signals: void showDate(const QDate &date); @@ -947,16 +921,16 @@ signals: void clicked(const QDate &date); void editingFinished(); protected: - QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); - void mouseDoubleClickEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); + QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; #endif - void keyPressEvent(QKeyEvent *event); - bool event(QEvent *event); + void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; QDate handleMouseEvent(QMouseEvent *event); public: @@ -969,19 +943,19 @@ private: }; QCalendarModel::QCalendarModel(QObject *parent) - : QAbstractTableModel(parent) -{ - m_date = QDate::currentDate(); - m_minimumDate = QDate::fromJulianDay(1); - m_maximumDate = QDate(7999, 12, 31); - m_shownYear = m_date.year(); - m_shownMonth = m_date.month(); - m_firstDay = QLocale().firstDayOfWeek(); - m_horizontalHeaderFormat = QCalendarWidget::ShortDayNames; - m_weekNumbersShown = true; - m_firstColumn = 1; - m_firstRow = 1; - m_view = 0; + : QAbstractTableModel(parent), + m_firstColumn(1), + m_firstRow(1), + m_date(QDate::currentDate()), + m_minimumDate(QDate::fromJulianDay(1)), + m_maximumDate(7999, 12, 31), + m_shownYear(m_date.year()), + m_shownMonth(m_date.month()), + m_firstDay(QLocale().firstDayOfWeek()), + m_horizontalHeaderFormat(QCalendarWidget::ShortDayNames), + m_weekNumbersShown(true), + m_view(Q_NULLPTR) +{ } Qt::DayOfWeek QCalendarModel::dayOfWeekForColumn(int column) const @@ -1555,7 +1529,7 @@ public: : QItemDelegate(parent), calendarWidgetPrivate(w) { } virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const Q_DECL_OVERRIDE; void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const; private: @@ -1571,11 +1545,11 @@ public: : QToolButton(parent) { } protected: - void paintEvent(QPaintEvent *e) + void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE { Q_UNUSED(e) -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC QStyleOptionToolButton opt; initStyleOption(&opt); @@ -1599,7 +1573,7 @@ class QPrevNextCalButton : public QToolButton public: QPrevNextCalButton(QWidget *parent) : QToolButton(parent) {} protected: - void paintEvent(QPaintEvent *) { + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE { QStylePainter painter(this); QStyleOptionToolButton opt; initStyleOption(&opt); diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h index e838098e53..7914b13fba 100644 --- a/src/widgets/widgets/qcalendarwidget.h +++ b/src/widgets/widgets/qcalendarwidget.h @@ -50,9 +50,6 @@ class Q_WIDGETS_EXPORT QCalendarWidget : public QWidget { Q_OBJECT Q_ENUMS(Qt::DayOfWeek) - Q_ENUMS(HorizontalHeaderFormat) - Q_ENUMS(VerticalHeaderFormat) - Q_ENUMS(SelectionMode) Q_PROPERTY(QDate selectedDate READ selectedDate WRITE setSelectedDate) Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate) Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate) @@ -72,22 +69,25 @@ public: ShortDayNames, LongDayNames }; + Q_ENUM(HorizontalHeaderFormat) enum VerticalHeaderFormat { NoVerticalHeader, ISOWeekNumbers }; + Q_ENUM(VerticalHeaderFormat) enum SelectionMode { NoSelection, SingleSelection }; + Q_ENUM(SelectionMode) explicit QCalendarWidget(QWidget *parent = 0); ~QCalendarWidget(); - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; + virtual QSize sizeHint() const Q_DECL_OVERRIDE; + virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE; QDate selectedDate() const; @@ -132,11 +132,11 @@ public: void setDateEditAcceptDelay(int delay); protected: - bool event(QEvent *event); - bool eventFilter(QObject *watched, QEvent *event); - void mousePressEvent(QMouseEvent *event); - void resizeEvent(QResizeEvent * event); - void keyPressEvent(QKeyEvent * event); + bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent * event) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent * event) Q_DECL_OVERRIDE; virtual void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const; void updateCell(const QDate &date); diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h index fe954571aa..6586793db2 100644 --- a/src/widgets/widgets/qcheckbox.h +++ b/src/widgets/widgets/qcheckbox.h @@ -53,8 +53,8 @@ public: explicit QCheckBox(const QString &text, QWidget *parent=0); ~QCheckBox(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setTristate(bool y = true); bool isTristate() const; @@ -66,12 +66,12 @@ Q_SIGNALS: void stateChanged(int); protected: - bool event(QEvent *e); - bool hitButton(const QPoint &pos) const; - void checkStateSet(); - void nextCheckState(); - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + bool hitButton(const QPoint &pos) const Q_DECL_OVERRIDE; + void checkStateSet() Q_DECL_OVERRIDE; + void nextCheckState() Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionButton *option) const; diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 40cf2f0f95..65ec3f7d7b 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -59,7 +59,7 @@ #include <private/qabstractitemmodel_p.h> #include <private/qabstractscrollarea_p.h> #include <qdebug.h> -#if defined(Q_WS_MAC) && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) +#if defined(Q_DEAD_CODE_FROM_QT4_MAC) && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC) #include <private/qcore_mac_p.h> #include <private/qmacstyle_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> @@ -397,7 +397,7 @@ void QComboBoxPrivateContainer::leaveEvent(QEvent *) { // On Mac using the Mac style we want to clear the selection // when the mouse moves outside the popup. -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC QStyleOptionComboBox opt = comboStyleOption(); if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) view->clearSelection(); @@ -1931,6 +1931,9 @@ void QComboBox::setModel(QAbstractItemModel *model) return; } + if (model == d->model) + return; + #ifndef QT_NO_COMPLETER if (d->lineEdit && d->lineEdit->completer() && d->lineEdit->completer() == d->completer) @@ -1983,15 +1986,16 @@ void QComboBox::setModel(QAbstractItemModel *model) this, SLOT(_q_emitHighlighted(QModelIndex)), Qt::UniqueConnection); } + setRootModelIndex(QModelIndex()); + bool currentReset = false; - if (count()) { - for (int pos=0; pos < count(); pos++) { - if (d->model->index(pos, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled) { - setCurrentIndex(pos); - currentReset = true; - break; - } + const int rowCount = count(); + for (int pos=0; pos < rowCount; pos++) { + if (d->model->index(pos, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled) { + setCurrentIndex(pos); + currentReset = true; + break; } } @@ -2021,6 +2025,8 @@ QModelIndex QComboBox::rootModelIndex() const void QComboBox::setRootModelIndex(const QModelIndex &index) { Q_D(QComboBox); + if (d->root == index) + return; d->root = QPersistentModelIndex(index); view()->setRootIndex(index); update(); @@ -2063,9 +2069,7 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) { Q_Q(QComboBox); - QModelIndex normalized; - if (mi.column() != modelColumn) - normalized = model->index(mi.row(), modelColumn, mi.parent()); + QModelIndex normalized = mi.sibling(mi.row(), modelColumn); // no-op if mi.column() == modelColumn if (!normalized.isValid()) normalized = mi; // Fallback to passed index. diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 806653d2d8..9c83d4dd08 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -52,8 +52,6 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget { Q_OBJECT - Q_ENUMS(InsertPolicy) - Q_ENUMS(SizeAdjustPolicy) Q_PROPERTY(bool editable READ isEditable WRITE setEditable) Q_PROPERTY(int count READ count) Q_PROPERTY(QString currentText READ currentText WRITE setCurrentText NOTIFY currentTextChanged USER true) @@ -115,6 +113,7 @@ public: InsertBeforeCurrent, InsertAlphabetically }; + Q_ENUM(InsertPolicy) InsertPolicy insertPolicy() const; void setInsertPolicy(InsertPolicy policy); @@ -125,6 +124,7 @@ public: AdjustToMinimumContentsLength, // ### Qt 6: remove AdjustToMinimumContentsLengthWithIcon }; + Q_ENUM(SizeAdjustPolicy) SizeAdjustPolicy sizeAdjustPolicy() const; void setSizeAdjustPolicy(SizeAdjustPolicy policy); @@ -188,14 +188,14 @@ public: QAbstractItemView *view() const; void setView(QAbstractItemView *itemView); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; virtual void showPopup(); virtual void hidePopup(); - bool event(QEvent *event); - QVariant inputMethodQuery(Qt::InputMethodQuery) const; + bool event(QEvent *event) Q_DECL_OVERRIDE; + QVariant inputMethodQuery(Qt::InputMethodQuery) const Q_DECL_OVERRIDE; public Q_SLOTS: void clear(); @@ -215,22 +215,22 @@ Q_SIGNALS: void currentTextChanged(const QString &); protected: - void focusInEvent(QFocusEvent *e); - void focusOutEvent(QFocusEvent *e); - void changeEvent(QEvent *e); - void resizeEvent(QResizeEvent *e); - void paintEvent(QPaintEvent *e); - void showEvent(QShowEvent *e); - void hideEvent(QHideEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - void keyReleaseEvent(QKeyEvent *e); + void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + void changeEvent(QEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *e); + void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif - void contextMenuEvent(QContextMenuEvent *e); - void inputMethodEvent(QInputMethodEvent *); + void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionComboBox *option) const; diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h index bfef2e300d..582f666e83 100644 --- a/src/widgets/widgets/qcommandlinkbutton.h +++ b/src/widgets/widgets/qcommandlinkbutton.h @@ -58,11 +58,11 @@ public: void setDescription(const QString &description); protected: - QSize sizeHint() const; - int heightForWidth(int) const; - QSize minimumSizeHint() const; - bool event(QEvent *e); - void paintEvent(QPaintEvent *); + QSize sizeHint() const Q_DECL_OVERRIDE; + int heightForWidth(int) const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QCommandLinkButton) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 7b73fd8bdc..21958e91d4 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -31,7 +31,6 @@ ** ****************************************************************************/ -#include <math.h> #include <private/qdatetimeedit_p.h> #include <qabstractspinbox.h> #include <qapplication.h> @@ -1125,7 +1124,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event) select = false; break; } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC else #ifdef QT_KEYPAD_NAVIGATION if (!QApplication::keypadNavigationEnabled()) diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h index 5a1d6dbf3f..2d37bd4351 100644 --- a/src/widgets/widgets/qdatetimeedit.h +++ b/src/widgets/widgets/qdatetimeedit.h @@ -51,7 +51,6 @@ class Q_WIDGETS_EXPORT QDateTimeEdit : public QAbstractSpinBox { Q_OBJECT - Q_ENUMS(Section) Q_FLAGS(Sections) Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged USER true) Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged) @@ -83,6 +82,7 @@ public: TimeSections_Mask = AmPmSection|MSecSection|SecondSection|MinuteSection|HourSection, DateSections_Mask = DaySection|MonthSection|YearSection }; + Q_ENUM(Section) Q_DECLARE_FLAGS(Sections, Section) diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp index 0dd6515f5b..a9de9a7154 100644 --- a/src/widgets/widgets/qdial.cpp +++ b/src/widgets/widgets/qdial.cpp @@ -75,7 +75,7 @@ public: int valueFromPoint(const QPoint &) const; double angle(const QPoint &, const QPoint &) const; void init(); - virtual int bound(int val) const; + virtual int bound(int val) const Q_DECL_OVERRIDE; }; void QDialPrivate::init() diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h index de233b09b7..acaf6c8c9e 100644 --- a/src/widgets/widgets/qdial.h +++ b/src/widgets/widgets/qdial.h @@ -66,23 +66,23 @@ public: qreal notchTarget() const; bool notchesVisible() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setNotchesVisible(bool visible); void setWrapping(bool on); protected: - bool event(QEvent *e); - void resizeEvent(QResizeEvent *re); - void paintEvent(QPaintEvent *pe); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *re) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *pe) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *me); - void mouseReleaseEvent(QMouseEvent *me); - void mouseMoveEvent(QMouseEvent *me); + void mousePressEvent(QMouseEvent *me) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *me) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *me) Q_DECL_OVERRIDE; - void sliderChange(SliderChange change); + void sliderChange(SliderChange change) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionSlider *option) const; diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 1ca02a594b..e3b1668fa7 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -411,7 +411,7 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut qWarning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added"); } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC // Since mnemonics is off by default on Mac, we add a Cmd-D // shortcut here to e.g. make the "Don't Save" button work nativly: if (sbutton == QDialogButtonBox::Discard) diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h index e20a166d29..7bf497e3e5 100644 --- a/src/widgets/widgets/qdialogbuttonbox.h +++ b/src/widgets/widgets/qdialogbuttonbox.h @@ -140,8 +140,8 @@ Q_SIGNALS: void rejected(); protected: - void changeEvent(QEvent *event); - bool event(QEvent *event); + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QDialogButtonBox) diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 702cd8bac9..cbeee236d0 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -1934,7 +1934,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> QDockAreaLayoutItem item(new QDockWidgetItem(widget)); if (flags & StateFlagFloating) { bool drawer = false; -#ifdef Q_WS_MAC // drawer support +#ifdef Q_DEAD_CODE_FROM_QT4_MAC // drawer support extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp drawer = qt_mac_is_macdrawer(widget); @@ -1949,7 +1949,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> int x, y, w, h; stream >> x >> y >> w >> h; -#ifdef Q_WS_MAC // drawer support +#ifdef Q_DEAD_CODE_FROM_QT4_MAC // drawer support if (drawer) { mainWindow->window()->createWinId(); widget->window()->createWinId(); @@ -2057,7 +2057,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const } j++; -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC sepWidget->raise(); #endif QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2); @@ -2979,7 +2979,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) dockWidget->d_func()->setWindowState(true, true, r); } dockWidget->setVisible(!placeHolder->hidden); -#ifdef Q_WS_X11 +#ifdef Q_DEAD_CODE_FROM_QT4_X11 if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag dockWidget->d_func()->setWindowState(true); #endif @@ -3169,7 +3169,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const } j++; -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC sepWidget->raise(); #endif QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2); diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 2bf8a37e7f..a0a51fb609 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -52,7 +52,7 @@ #include "qdockwidget_p.h" #include "qmainwindowlayout_p.h" -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC #include <private/qapplication_p.h> #include <private/qt_mac_p.h> #include <private/qmacstyle_mac_p.h> @@ -109,13 +109,13 @@ class QDockWidgetTitleButton : public QAbstractButton public: QDockWidgetTitleButton(QDockWidget *dockWidget); - QSize sizeHint() const; - inline QSize minimumSizeHint() const + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE { return sizeHint(); } - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); - void paintEvent(QPaintEvent *event); + void enterEvent(QEvent *event) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; }; @@ -207,7 +207,8 @@ static bool isXcb() bool QDockWidgetLayout::nativeWindowDeco(bool floating) const { -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID) + Q_UNUSED(floating) return false; #else return !isXcb() && (floating && item_list[QDockWidgetLayout::TitleBar] == 0); @@ -859,7 +860,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { startDrag(); -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN grabMouseWhileInWindow(); #else q->grabMouse(); @@ -903,7 +904,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) QRect geo = q->geometry(); QRect titleRect = q->frameGeometry(); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if ((features & QDockWidget::DockWidgetVerticalTitleBar)) { titleRect.setTop(geo.top()); titleRect.setBottom(geo.bottom()); @@ -1436,7 +1437,7 @@ bool QDockWidget::event(QEvent *event) if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event))) return true; break; -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN case QEvent::Leave: if (d->state != 0 && d->state->dragging && !d->state->nca) { // This is a workaround for loosing the mouse on Vista. diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index 70ee2a4dcb..fb5c2c375a 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -106,10 +106,10 @@ Q_SIGNALS: void dockLocationChanged(Qt::DockWidgetArea area); protected: - void changeEvent(QEvent *event); - void closeEvent(QCloseEvent *event); - void paintEvent(QPaintEvent *event); - bool event(QEvent *event); + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionDockWidget *option) const; private: diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 7d75b4859c..e8c4720a98 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -128,18 +128,18 @@ class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout public: QDockWidgetLayout(QWidget *parent = 0); ~QDockWidgetLayout(); - void addItem(QLayoutItem *item); - QLayoutItem *itemAt(int index) const; - QLayoutItem *takeAt(int index); - int count() const; + void addItem(QLayoutItem *item) Q_DECL_OVERRIDE; + QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE; + QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE; + int count() const Q_DECL_OVERRIDE; - QSize maximumSize() const; - QSize minimumSize() const; - QSize sizeHint() const; + QSize maximumSize() const Q_DECL_OVERRIDE; + QSize minimumSize() const Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; QSize sizeFromContent(const QSize &content, bool floating) const; - void setGeometry(const QRect &r); + void setGeometry(const QRect &r) Q_DECL_OVERRIDE; enum Role { Content, CloseButton, FloatButton, TitleBar, RoleCount }; QWidget *widgetForRole(Role r) const; @@ -170,9 +170,9 @@ class QDockWidgetItem : public QWidgetItem { public: QDockWidgetItem(QDockWidget *dockWidget); - QSize minimumSize() const; - QSize maximumSize() const; - QSize sizeHint() const; + QSize minimumSize() const Q_DECL_OVERRIDE; + QSize maximumSize() const Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; private: inline QLayoutItem *dockWidgetChildItem() const; diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index 33fa772d83..79e9c0669a 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -64,10 +64,10 @@ public: void run(int time); protected: - void paintEvent(QPaintEvent* e); - void closeEvent(QCloseEvent*); + void paintEvent(QPaintEvent* e) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE; void alphaBlend(); - bool eventFilter(QObject *, QEvent *); + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; protected slots: void render(); @@ -341,8 +341,8 @@ public: void run(int time); protected: - void paintEvent(QPaintEvent*); - void closeEvent(QCloseEvent*); + void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE; private slots: void scroll(); diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h index d84f286bb6..08eb2a570d 100644 --- a/src/widgets/widgets/qfocusframe.h +++ b/src/widgets/widgets/qfocusframe.h @@ -53,10 +53,10 @@ public: QWidget *widget() const; protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; - bool eventFilter(QObject *, QEvent *); - void paintEvent(QPaintEvent *); + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOption *option) const; private: diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 4e3b57bd02..2247608956 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -45,10 +45,6 @@ #include <QDesktopWidget> #include <qdebug.h> -#include <QtGui/private/qguiapplication_p.h> -#include <qpa/qplatformintegration.h> -#include <qpa/qplatformfontdatabase.h> - QT_BEGIN_NAMESPACE static QFontDatabase::WritingSystem writingSystemFromScript(QLocale::Script script) @@ -188,10 +184,10 @@ public: // painting void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const Q_DECL_OVERRIDE; QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const Q_DECL_OVERRIDE; QIcon truetype; QIcon bitmap; @@ -324,10 +320,8 @@ void QFontComboBoxPrivate::_q_updateModel() int offset = 0; QFontInfo fi(currentFont); - QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase(); - for (int i = 0; i < list.size(); ++i) { - if (pfdb->isPrivateFontFamily(list.at(i))) + if (fdb.isPrivateFamily(list.at(i))) continue; if ((filters & scalableMask) && (filters & scalableMask) != scalableMask) { diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h index 95bedc7009..c2e5332c50 100644 --- a/src/widgets/widgets/qfontcombobox.h +++ b/src/widgets/widgets/qfontcombobox.h @@ -72,7 +72,7 @@ public: FontFilters fontFilters() const; QFont currentFont() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setCurrentFont(const QFont &f); @@ -81,7 +81,7 @@ Q_SIGNALS: void currentFontChanged(const QFont &f); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QFontComboBox) diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp index 57cd51396c..b914a80f1d 100644 --- a/src/widgets/widgets/qframe.cpp +++ b/src/widgets/widgets/qframe.cpp @@ -202,6 +202,49 @@ QFrame::QFrame(QFramePrivate &dd, QWidget* parent, Qt::WindowFlags f) d->init(); } +/*! + \since 5.5 + + Initializes \a option with the values from this QFrame. This method is + useful for subclasses when they need a QStyleOptionFrame but don't want to + fill in all the information themselves. + + \sa QStyleOption::initFrom() +*/ +void QFrame::initStyleOption(QStyleOptionFrame *option) const +{ + if (!option) + return; + + Q_D(const QFrame); + option->initFrom(this); + + int frameShape = d->frameStyle & QFrame::Shape_Mask; + int frameShadow = d->frameStyle & QFrame::Shadow_Mask; + option->frameShape = Shape(int(option->frameShape) | frameShape); + option->rect = frameRect(); + switch (frameShape) { + case QFrame::Box: + case QFrame::HLine: + case QFrame::VLine: + case QFrame::StyledPanel: + case QFrame::Panel: + option->lineWidth = d->lineWidth; + option->midLineWidth = d->midLineWidth; + break; + default: + // most frame styles do not handle customized line and midline widths + // (see updateFrameWidth()). + option->lineWidth = d->frameWidth; + break; + } + + if (frameShadow == Sunken) + option->state |= QStyle::State_Sunken; + else if (frameShadow == Raised) + option->state |= QStyle::State_Raised; +} + /*! Destroys the frame. @@ -362,10 +405,7 @@ void QFramePrivate::updateStyledFrameWidths() { Q_Q(const QFrame); QStyleOptionFrame opt; - opt.initFrom(q); - opt.lineWidth = lineWidth; - opt.midLineWidth = midLineWidth; - opt.frameShape = QFrame::Shape(frameStyle & QFrame::Shape_Mask); + q->initStyleOption(&opt); QRect cr = q->style()->subElementRect(QStyle::SE_ShapedFrameContents, &opt, q); leftFrameWidth = cr.left() - opt.rect.left(); @@ -472,34 +512,8 @@ void QFrame::paintEvent(QPaintEvent *) */ void QFrame::drawFrame(QPainter *p) { - Q_D(QFrame); QStyleOptionFrame opt; - opt.init(this); - int frameShape = d->frameStyle & QFrame::Shape_Mask; - int frameShadow = d->frameStyle & QFrame::Shadow_Mask; - opt.frameShape = Shape(int(opt.frameShape) | frameShape); - opt.rect = frameRect(); - switch (frameShape) { - case QFrame::Box: - case QFrame::HLine: - case QFrame::VLine: - case QFrame::StyledPanel: - case QFrame::Panel: - opt.lineWidth = d->lineWidth; - opt.midLineWidth = d->midLineWidth; - break; - default: - // most frame styles do not handle customized line and midline widths - // (see updateFrameWidth()). - opt.lineWidth = d->frameWidth; - break; - } - - if (frameShadow == Sunken) - opt.state |= QStyle::State_Sunken; - else if (frameShadow == Raised) - opt.state |= QStyle::State_Raised; - + initStyleOption(&opt); style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this); } diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h index ff04d70afc..41fd3a92b6 100644 --- a/src/widgets/widgets/qframe.h +++ b/src/widgets/widgets/qframe.h @@ -40,12 +40,12 @@ QT_BEGIN_NAMESPACE class QFramePrivate; +class QStyleOptionFrame; class Q_WIDGETS_EXPORT QFrame : public QWidget { Q_OBJECT - Q_ENUMS(Shape Shadow) Q_PROPERTY(Shape frameShape READ frameShape WRITE setFrameShape) Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow) Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth) @@ -62,7 +62,7 @@ public: int frameWidth() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; enum Shape { NoFrame = 0, // no frame @@ -73,11 +73,13 @@ public: VLine = 0x0005, // vertical line StyledPanel = 0x0006 // rectangular panel depending on the GUI style }; + Q_ENUM(Shape) enum Shadow { Plain = 0x0010, // plain line Raised = 0x0020, // raised shadow effect Sunken = 0x0030 // sunken shadow effect }; + Q_ENUM(Shadow) enum StyleMask { Shadow_Mask = 0x00f0, // mask for the shadow @@ -99,14 +101,15 @@ public: void setFrameRect(const QRect &); protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); - void changeEvent(QEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; void drawFrame(QPainter *); protected: QFrame(QFramePrivate &dd, QWidget* parent = 0, Qt::WindowFlags f = 0); + void initStyleOption(QStyleOptionFrame *option) const; private: Q_DISABLE_COPY(QFrame) diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h index ca5a95e79e..da0f4680d6 100644 --- a/src/widgets/widgets/qgroupbox.h +++ b/src/widgets/widgets/qgroupbox.h @@ -63,7 +63,7 @@ public: Qt::Alignment alignment() const; void setAlignment(int alignment); - QSize minimumSizeHint() const; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; bool isFlat() const; void setFlat(bool flat); @@ -79,15 +79,15 @@ Q_SIGNALS: void toggled(bool); protected: - bool event(QEvent *event); - void childEvent(QChildEvent *event); - void resizeEvent(QResizeEvent *event); - void paintEvent(QPaintEvent *event); - void focusInEvent(QFocusEvent *event); - void changeEvent(QEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE; + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionGroupBox *option) const; diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h index a1e9543187..be56d3bf0f 100644 --- a/src/widgets/widgets/qlabel.h +++ b/src/widgets/widgets/qlabel.h @@ -88,13 +88,13 @@ public: bool hasScaledContents() const; void setScaledContents(bool); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; #ifndef QT_NO_SHORTCUT void setBuddy(QWidget *); QWidget *buddy() const; #endif - int heightForWidth(int) const; + int heightForWidth(int) const Q_DECL_OVERRIDE; bool openExternalLinks() const; void setOpenExternalLinks(bool open); @@ -125,17 +125,17 @@ Q_SIGNALS: void linkHovered(const QString& link); protected: - bool event(QEvent *e); - void keyPressEvent(QKeyEvent *ev); - void paintEvent(QPaintEvent *); - void changeEvent(QEvent *); - void mousePressEvent(QMouseEvent *ev); - void mouseMoveEvent(QMouseEvent *ev); - void mouseReleaseEvent(QMouseEvent *ev); - void contextMenuEvent(QContextMenuEvent *ev); - void focusInEvent(QFocusEvent *ev); - void focusOutEvent(QFocusEvent *ev); - bool focusNextPrevChild(bool next); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; private: diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h index 0c3a4d6cf5..59aad073f1 100644 --- a/src/widgets/widgets/qlcdnumber.h +++ b/src/widgets/widgets/qlcdnumber.h @@ -45,7 +45,6 @@ class QLCDNumberPrivate; class Q_WIDGETS_EXPORT QLCDNumber : public QFrame // LCD number widget { Q_OBJECT - Q_ENUMS(Mode SegmentStyle) Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint) Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount) Q_PROPERTY(Mode mode READ mode WRITE setMode) @@ -61,9 +60,11 @@ public: enum Mode { Hex, Dec, Oct, Bin }; + Q_ENUM(Mode) enum SegmentStyle { Outline, Filled, Flat }; + Q_ENUM(SegmentStyle) bool smallDecimalPoint() const; int digitCount() const; @@ -81,7 +82,7 @@ public: double value() const; int intValue() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void display(const QString &str); @@ -97,8 +98,8 @@ Q_SIGNALS: void overflow(); protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; public: diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index bd8dd783ff..c027155f86 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC extern void qt_mac_secure_keyboard(bool); //qapplication_mac.cpp #endif @@ -434,12 +434,6 @@ bool QLineEdit::hasFrame() const */ /*! - \fn void QLineEdit::addAction(QAction *action) - \overload - \internal -*/ - -/*! \overload Adds the \a action to the list of actions at the \a position. @@ -581,7 +575,7 @@ void QLineEdit::setEchoMode(EchoMode mode) setInputMethodHints(imHints); d->control->setEchoMode(mode); update(); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (hasFocus()) qt_mac_secure_keyboard(mode == Password || mode == NoEcho); #endif @@ -1405,7 +1399,7 @@ bool QLineEdit::event(QEvent * e) { Q_D(QLineEdit); if (e->type() == QEvent::Timer) { - // should be timerEvent, is here for binary compatibility + // ### Qt6: move to timerEvent, is here for binary compatibility int timerId = ((QTimerEvent*)e)->timerId(); if (false) { #ifndef QT_NO_DRAGANDDROP @@ -1806,7 +1800,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e) if((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) d->setCursorVisible(true); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho) qt_mac_secure_keyboard(true); #endif @@ -1854,7 +1848,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) if (hasAcceptableInput() || d->control->fixup()) emit editingFinished(); } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho) qt_mac_secure_keyboard(false); #endif diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 3997ed16fd..c1e873f02a 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -58,7 +58,6 @@ class Q_WIDGETS_EXPORT QLineEdit : public QWidget { Q_OBJECT - Q_ENUMS(ActionPosition EchoMode) Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true) Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength) @@ -83,6 +82,7 @@ public: LeadingPosition, TrailingPosition }; + Q_ENUM(ActionPosition) explicit QLineEdit(QWidget* parent=0); explicit QLineEdit(const QString &, QWidget* parent=0); @@ -105,6 +105,7 @@ public: bool isClearButtonEnabled() const; enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit }; + Q_ENUM(EchoMode) EchoMode echoMode() const; void setEchoMode(EchoMode); @@ -121,8 +122,8 @@ public: QCompleter *completer() const; #endif - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; int cursorPosition() const; void setCursorPosition(int); @@ -166,13 +167,7 @@ public: void getTextMargins(int *left, int *top, int *right, int *bottom) const; QMargins textMargins() const; -#ifdef Q_NO_USING_KEYWORD - inline void addAction(QAction *action) - { QWidget::addAction(action); } -#else using QWidget::addAction; -#endif - void addAction(QAction *action, ActionPosition position); QAction *addAction(const QIcon &icon, ActionPosition position); @@ -204,30 +199,30 @@ Q_SIGNALS: void selectionChanged(); protected: - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent *); - void keyPressEvent(QKeyEvent *); - void focusInEvent(QFocusEvent *); - void focusOutEvent(QFocusEvent *); - void paintEvent(QPaintEvent *); + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_DRAGANDDROP - void dragEnterEvent(QDragEnterEvent *); - void dragMoveEvent(QDragMoveEvent *e); - void dragLeaveEvent(QDragLeaveEvent *e); - void dropEvent(QDropEvent *); + void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent *) Q_DECL_OVERRIDE; #endif - void changeEvent(QEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE; #endif - void inputMethodEvent(QInputMethodEvent *); + void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionFrame *option) const; public: - QVariant inputMethodQuery(Qt::InputMethodQuery) const; - bool event(QEvent *); + QVariant inputMethodQuery(Qt::InputMethodQuery) const Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; protected: QRect cursorRect() const; diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 6426329de6..95fc7551fc 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -81,7 +81,7 @@ public: #endif protected: - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private slots: void updateCursor(); diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index ddecea81bf..439fda9dd4 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -55,7 +55,7 @@ #ifdef Q_OS_OSX #include <qpa/qplatformnativeinterface.h> #endif -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> QT_BEGIN_NAMESPACE @@ -74,7 +74,7 @@ public: #ifdef Q_OS_OSX , useUnifiedToolBar(false) #endif -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC , useHIToolBar(false) , activateUnifiedToolbarAfterFullScreen(false) #endif @@ -89,7 +89,7 @@ public: #ifdef Q_OS_OSX bool useUnifiedToolBar; #endif -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC bool useHIToolBar; bool activateUnifiedToolbarAfterFullScreen; #endif @@ -1079,7 +1079,7 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget d_func()->layout->removeWidget(dockwidget); // in case it was already in here addDockWidget(area, dockwidget, orientation); -#ifdef Q_WS_MAC //drawer support +#ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support QMacCocoaAutoReleasePool pool; extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp if (qt_mac_is_macdrawer(dockwidget)) { @@ -1454,7 +1454,7 @@ bool QMainWindow::event(QEvent *event) if (!d->explicitIconSize) setIconSize(QSize()); break; -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC case QEvent::Show: if (unifiedTitleAndToolBarOnMac()) d->layout->syncUnifiedToolbarVisibility(); @@ -1473,7 +1473,7 @@ bool QMainWindow::event(QEvent *event) } } break; -#endif // Q_WS_MAC +#endif // Q_DEAD_CODE_FROM_QT4_MAC #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) case QEvent::CursorChange: // CursorChange events are triggered as mouse moves to new widgets even @@ -1529,7 +1529,7 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) } #endif -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC Q_D(QMainWindow); if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) return; @@ -1564,7 +1564,7 @@ bool QMainWindow::unifiedTitleAndToolBarOnMac() const #ifdef Q_OS_OSX return d_func()->useUnifiedToolBar; #endif -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint); #endif return false; diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index 4478c47449..a1f7df2f4e 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -53,7 +53,6 @@ class Q_WIDGETS_EXPORT QMainWindow : public QWidget { Q_OBJECT - Q_ENUMS(DockOption) Q_FLAGS(DockOptions) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle) @@ -80,6 +79,7 @@ public: ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks VerticalTabs = 0x10 // implies AllowTabbedDocks }; + Q_ENUM(DockOption) Q_DECLARE_FLAGS(DockOptions, DockOption) explicit QMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); @@ -188,9 +188,9 @@ Q_SIGNALS: protected: #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *event); + void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; #endif - bool event(QEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; private: Q_DECLARE_PRIVATE(QMainWindow) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 827e2ed2ba..65d8141a5f 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -61,7 +61,7 @@ #include <private/qapplication_p.h> #include <private/qlayoutengine_p.h> -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC # include <private/qcore_mac_p.h> # include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -830,11 +830,11 @@ void QMainWindowLayout::removeToolBar(QToolBar *toolbar) QObject::disconnect(parentWidget(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (usesHIToolBar(toolbar)) { removeFromMacToolbar(toolbar); } else -#endif // Q_WS_MAC +#endif // Q_DEAD_CODE_FROM_QT4_MAC { removeWidget(toolbar); } @@ -849,7 +849,7 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area, bool) { validateToolBarArea(area); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if ((area == Qt::TopToolBarArea) && layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) { insertIntoMacToolbar(0, toolbar); @@ -875,11 +875,11 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area, */ void QMainWindowLayout::insertToolBar(QToolBar *before, QToolBar *toolbar) { -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (usesHIToolBar(before)) { insertIntoMacToolbar(before, toolbar); } else -#endif // Q_WS_MAC +#endif // Q_DEAD_CODE_FROM_QT4_MAC { addChildWidget(toolbar); QLayoutItem * item = layoutState.toolBarAreaLayout.insertToolBar(before, toolbar); @@ -908,7 +908,7 @@ Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const case QInternal::BottomDock: return Qt::BottomToolBarArea; default: break; } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (pos == QInternal::DockCount) { if (qtoolbarsInUnifiedToolbarList.contains(toolbar)) return Qt::TopToolBarArea; @@ -931,7 +931,7 @@ void QMainWindowLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar void QMainWindowLayout::toggleToolBarsVisible() { bool updateNonUnifiedParts = true; -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) { // If we hit this case, someone has pressed the "toolbar button" which will // toggle the unified toolbar visibility, because that's what the user wants. @@ -1243,7 +1243,7 @@ class QMainWindowTabBar : public QTabBar public: QMainWindowTabBar(QWidget *parent); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; }; QMainWindowTabBar::QMainWindowTabBar(QWidget *parent) @@ -1261,8 +1261,8 @@ bool QMainWindowTabBar::event(QEvent *e) QSize size = this->size(); QSize hint = sizeHint(); if (shape() == QTabBar::RoundedWest || shape() == QTabBar::RoundedEast) { - size.transpose(); - hint.transpose(); + size = size.transposed(); + hint = hint.transposed(); } if (size.width() < hint.width()) return QTabBar::event(e); @@ -1475,7 +1475,7 @@ QSize QMainWindowLayout::minimumSize() const const QSize sbMin = statusbar ? statusbar->minimumSize() : QSize(0, 0); minSize = QSize(qMax(sbMin.width(), minSize.width()), sbMin.height() + minSize.height()); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC const QSize storedSize = minSize; int minWidth = 0; foreach (QToolBar *toolbar, qtoolbarsInUnifiedToolbarList) { @@ -1676,7 +1676,7 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay #ifndef QT_NO_RUBBERBAND , gapIndicator(new QRubberBand(QRubberBand::Rectangle, mainwindow)) #endif //QT_NO_RUBBERBAND -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC , blockVisiblityCheck(false) #endif { @@ -1709,7 +1709,7 @@ QMainWindowLayout::~QMainWindowLayout() layoutState.deleteAllLayoutItems(); layoutState.deleteCentralWidgetItem(); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC cleanUpMacToolbarItems(); #endif @@ -1956,7 +1956,7 @@ bool QMainWindowLayout::restoreState(QDataStream &stream) // HIToolbar. bool QMainWindowLayout::usesHIToolBar(QToolBar *toolbar) const { -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC Q_UNUSED(toolbar); return false; #else diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index d9e18b03f4..2985a996cf 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -60,7 +60,7 @@ #include "qdockarealayout_p.h" #include "qtoolbararealayout_p.h" -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC // Forward defs to make avoid including Carbon.h (faster compile you know ;). struct OpaqueHIObjectRef; typedef struct OpaqueHIObjectRef* HIObjectRef; @@ -70,7 +70,7 @@ typedef const struct __CFString * CFStringRef; #include <private/qunifiedtoolbarsurface_mac_p.h> -#endif // Q_WS_MAC +#endif // Q_DEAD_CODE_FROM_QT4_MAC QT_BEGIN_NAMESPACE @@ -151,7 +151,7 @@ public: void setDockOptions(QMainWindow::DockOptions opts); bool usesHIToolBar(QToolBar *toolbar) const; - void timerEvent(QTimerEvent *e); + void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; // status bar @@ -249,17 +249,17 @@ public: // QLayout interface - void addItem(QLayoutItem *item); - void setGeometry(const QRect &r); - QLayoutItem *itemAt(int index) const; - QLayoutItem *takeAt(int index); - int count() const; + void addItem(QLayoutItem *item) Q_DECL_OVERRIDE; + void setGeometry(const QRect &r) Q_DECL_OVERRIDE; + QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE; + QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE; + int count() const Q_DECL_OVERRIDE; - QSize sizeHint() const; - QSize minimumSize() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSize() const Q_DECL_OVERRIDE; mutable QSize szHint; mutable QSize minSize; - void invalidate(); + void invalidate() Q_DECL_OVERRIDE; // animations @@ -292,7 +292,7 @@ private: #ifndef QT_NO_TABBAR void updateTabBarShapes(); #endif -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *); static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event, void *data); @@ -325,7 +325,7 @@ public: QUnifiedToolbarSurface *unifiedSurface; void updateUnifiedToolbarOffset(); -#endif // Q_WS_MAC +#endif // Q_DEAD_CODE_FROM_QT4_MAC }; #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG_STREAM) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 3553baf68a..4be85ca3dd 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -154,7 +154,7 @@ #include <QApplication> #include <QStyle> -#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) +#if defined(Q_DEAD_CODE_FROM_QT4_MAC) && !defined(QT_NO_STYLE_MAC) #include <private/qmacstyle_mac_p.h> #endif #include <QChildEvent> @@ -567,9 +567,9 @@ public: QMdiAreaTabBar(QWidget *parent) : QTabBar(parent) {} protected: - void mousePressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *event); + void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; #endif private: @@ -2491,7 +2491,7 @@ bool QMdiArea::event(QEvent *event) { Q_D(QMdiArea); switch (event->type()) { -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN // QWidgetPrivate::hide_helper activates another sub-window when closing a // modal dialog on Windows (see activateWindow() inside the ifdef). case QEvent::WindowUnblocked: @@ -2555,7 +2555,7 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event) QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); // Ingore key events without a Ctrl modifier (except for press/release on the modifier itself). -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (!(keyEvent->modifiers() & Qt::MetaModifier) && keyEvent->key() != Qt::Key_Meta) #else if (!(keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() != Qt::Key_Control) @@ -2574,7 +2574,7 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event) // 3) Ctrl-Shift-Tab (Tab, Tab, ...) -> iterate through all windows in the opposite // direction (activatePreviousSubWindow()) switch (keyEvent->key()) { -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC case Qt::Key_Meta: #else case Qt::Key_Control: diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h index 18d559e21b..19deabddf8 100644 --- a/src/widgets/widgets/qmdiarea.h +++ b/src/widgets/widgets/qmdiarea.h @@ -48,7 +48,6 @@ class QMdiAreaPrivate; class Q_WIDGETS_EXPORT QMdiArea : public QAbstractScrollArea { Q_OBJECT - Q_ENUMS(ViewMode) Q_PROPERTY(QBrush background READ background WRITE setBackground) Q_PROPERTY(WindowOrder activationOrder READ activationOrder WRITE setActivationOrder) Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode) @@ -61,7 +60,6 @@ class Q_WIDGETS_EXPORT QMdiArea : public QAbstractScrollArea Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape) Q_PROPERTY(QTabWidget::TabPosition tabPosition READ tabPosition WRITE setTabPosition) #endif - Q_ENUMS(WindowOrder) public: enum AreaOption { DontMaximizeSubWindowOnActivation = 0x1 @@ -73,17 +71,19 @@ public: StackingOrder, ActivationHistoryOrder }; + Q_ENUM(WindowOrder) enum ViewMode { SubWindowView, TabbedView }; + Q_ENUM(ViewMode) QMdiArea(QWidget *parent = 0); ~QMdiArea(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; QMdiSubWindow *currentSubWindow() const; QMdiSubWindow *activeSubWindow() const; @@ -135,18 +135,18 @@ public Q_SLOTS: void activatePreviousSubWindow(); protected Q_SLOTS: - void setupViewport(QWidget *viewport); + void setupViewport(QWidget *viewport) Q_DECL_OVERRIDE; protected: - bool event(QEvent *event); - bool eventFilter(QObject *object, QEvent *event); - void paintEvent(QPaintEvent *paintEvent); - void childEvent(QChildEvent *childEvent); - void resizeEvent(QResizeEvent *resizeEvent); - void timerEvent(QTimerEvent *timerEvent); - void showEvent(QShowEvent *showEvent); - bool viewportEvent(QEvent *event); - void scrollContentsBy(int dx, int dy); + bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *childEvent) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *timerEvent) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE; + bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE; + void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QMdiArea) diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index ba531adaad..170584a803 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -81,8 +81,8 @@ class RegularTiler : public Rearranger // Rearranges widgets according to a regular tiling pattern // covering the entire domain. // Both positions and sizes may change. - void rearrange(QList<QWidget *> &widgets, const QRect &domain) const; - inline Type type() const { return Rearranger::RegularTiler; } + void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE; + Type type() const Q_DECL_OVERRIDE { return Rearranger::RegularTiler; } }; class SimpleCascader : public Rearranger @@ -90,8 +90,8 @@ class SimpleCascader : public Rearranger // Rearranges widgets according to a simple, regular cascading pattern. // Widgets are resized to minimumSize. // Both positions and sizes may change. - void rearrange(QList<QWidget *> &widgets, const QRect &domain) const; - inline Type type() const { return Rearranger::SimpleCascader; } + void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE; + Type type() const Q_DECL_OVERRIDE { return Rearranger::SimpleCascader; } }; class IconTiler : public Rearranger @@ -99,8 +99,8 @@ class IconTiler : public Rearranger // Rearranges icons (assumed to be the same size) according to a regular // tiling pattern filling up the domain from the bottom. // Only positions may change. - void rearrange(QList<QWidget *> &widgets, const QRect &domain) const; - inline Type type() const { return Rearranger::IconTiler; } + void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE; + Type type() const Q_DECL_OVERRIDE { return Rearranger::IconTiler; } }; class Placer @@ -115,7 +115,7 @@ public: class MinOverlapPlacer : public Placer { - QPoint place(const QSize &size, const QVector<QRect> &rects, const QRect &domain) const; + QPoint place(const QSize &size, const QVector<QRect> &rects, const QRect &domain) const Q_DECL_OVERRIDE; static int accumulatedOverlap(const QRect &source, const QVector<QRect> &rects); static QRect findMinOverlapRect(const QVector<QRect> &source, const QVector<QRect> &rects); static QVector<QRect> getCandidatePlacements(const QSize &size, const QVector<QRect> &rects, const QRect &domain); @@ -199,7 +199,7 @@ public: bool lastWindowAboutToBeDestroyed() const; void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const; QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount); - void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp + void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) Q_DECL_OVERRIDE; // reimp QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder, int removed = -1, int fromIndex = -1) const; void highlightNextSubWindow(int increaseFactor); diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 2340c8fe4b..8b2e6ee808 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -274,7 +274,7 @@ static inline bool isHoverControl(QStyle::SubControl control) return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel; } -#if defined(Q_WS_WIN) +#if defined(Q_DEAD_CODE_FROM_QT4_WIN) static inline QRgb colorref2qrgb(COLORREF col) { return qRgb(GetRValue(col),GetGValue(col),GetBValue(col)); @@ -362,18 +362,18 @@ class ControlLabel : public QWidget public: ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; signals: void _q_clicked(); void _q_doubleClicked(); protected: - bool event(QEvent *event); - void paintEvent(QPaintEvent *paintEvent); - void mousePressEvent(QMouseEvent *mouseEvent); - void mouseDoubleClickEvent(QMouseEvent *mouseEvent); - void mouseReleaseEvent(QMouseEvent *mouseEvent); + bool event(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; private: QPixmap label; @@ -488,7 +488,7 @@ class ControllerWidget : public QWidget Q_OBJECT public: ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible); inline bool hasVisibleControls() const { @@ -503,12 +503,12 @@ signals: void _q_close(); protected: - void paintEvent(QPaintEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void leaveEvent(QEvent *event); - bool event(QEvent *event); + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; private: QStyle::SubControl activeControl; @@ -1921,7 +1921,7 @@ QPalette QMdiSubWindowPrivate::desktopPalette() const QPalette newPalette = q->palette(); bool colorsInitialized = false; -#ifdef Q_WS_WIN // ask system properties on windows +#ifdef Q_DEAD_CODE_FROM_QT4_WIN // ask system properties on windows #ifndef SPI_GETGRADIENTCAPTIONS #define SPI_GETGRADIENTCAPTIONS 0x1008 #endif @@ -1957,7 +1957,7 @@ QPalette QMdiSubWindowPrivate::desktopPalette() const newPalette.color(QPalette::Inactive, QPalette::Highlight)); } } -#endif // Q_WS_WIN +#endif // Q_DEAD_CODE_FROM_QT4_WIN if (!colorsInitialized) { newPalette.setColor(QPalette::Active, QPalette::Highlight, newPalette.color(QPalette::Active, QPalette::Highlight)); diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h index a94ecfb48e..6e4d0514ee 100644 --- a/src/widgets/widgets/qmdisubwindow.h +++ b/src/widgets/widgets/qmdisubwindow.h @@ -63,8 +63,8 @@ public: QMdiSubWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~QMdiSubWindow(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setWidget(QWidget *widget); QWidget *widget() const; @@ -101,28 +101,28 @@ public Q_SLOTS: void showShaded(); protected: - bool eventFilter(QObject *object, QEvent *event); - bool event(QEvent *event); - void showEvent(QShowEvent *showEvent); - void hideEvent(QHideEvent *hideEvent); - void changeEvent(QEvent *changeEvent); - void closeEvent(QCloseEvent *closeEvent); - void leaveEvent(QEvent *leaveEvent); - void resizeEvent(QResizeEvent *resizeEvent); - void timerEvent(QTimerEvent *timerEvent); - void moveEvent(QMoveEvent *moveEvent); - void paintEvent(QPaintEvent *paintEvent); - void mousePressEvent(QMouseEvent *mouseEvent); - void mouseDoubleClickEvent(QMouseEvent *mouseEvent); - void mouseReleaseEvent(QMouseEvent *mouseEvent); - void mouseMoveEvent(QMouseEvent *mouseEvent); - void keyPressEvent(QKeyEvent *keyEvent); + bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *hideEvent) Q_DECL_OVERRIDE; + void changeEvent(QEvent *changeEvent) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent *closeEvent) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *leaveEvent) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *timerEvent) Q_DECL_OVERRIDE; + void moveEvent(QMoveEvent *moveEvent) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *keyEvent) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *contextMenuEvent); + void contextMenuEvent(QContextMenuEvent *contextMenuEvent) Q_DECL_OVERRIDE; #endif - void focusInEvent(QFocusEvent *focusInEvent); - void focusOutEvent(QFocusEvent *focusOutEvent); - void childEvent(QChildEvent *childEvent); + void focusInEvent(QFocusEvent *focusInEvent) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *focusOutEvent) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *childEvent) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QMdiSubWindow) diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 763f6ba039..f5cb94faea 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -260,7 +260,7 @@ public: void setFocusWidget(); bool restoreFocus(); void storeFocusWidget(); - void setWindowFlags(Qt::WindowFlags windowFlags); + void setWindowFlags(Qt::WindowFlags windowFlags) Q_DECL_OVERRIDE; void setVisible(WindowStateAction, bool visible = true); #ifndef QT_NO_ACTION void setEnabled(WindowStateAction, bool enable = true); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 5e5126e1e8..7e446fd087 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -70,6 +70,22 @@ QT_BEGIN_NAMESPACE QMenu *QMenuPrivate::mouseDown = 0; +QPointer<QMenu> QMenuPrivate::previousMouseMenu(Q_NULLPTR); +static void handleEnterLeaveEvents(QPointer<QMenu> *previous_ptr, QMenu *next) +{ + QWidget *previous = previous_ptr->data(); + if (previous != next) { + if (previous) { + QEvent leaveEvent(QEvent::Leave); + QApplication::sendEvent(previous, &leaveEvent); + } + if (next) { + QEvent enterEvent(QEvent::Enter); + QApplication::sendEvent(next, &enterEvent); + } + } + *previous_ptr = next; +} /* QMenu code */ // internal class used for the torn off popup @@ -86,7 +102,7 @@ class QTornOffMenu : public QMenu causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action; causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack(); } - QList<QPointer<QWidget> > calcCausedStack() const { return causedStack; } + QList<QPointer<QWidget> > calcCausedStack() const Q_DECL_OVERRIDE { return causedStack; } QPointer<QMenu> causedMenu; QList<QPointer<QWidget> > causedStack; }; @@ -119,7 +135,7 @@ public: } else if (act->type() == QEvent::ActionRemoved) removeAction(act->action()); } - void actionEvent(QActionEvent *e) + void actionEvent(QActionEvent *e) Q_DECL_OVERRIDE { QMenu::actionEvent(e); setFixedSize(sizeHint()); @@ -148,6 +164,9 @@ void QMenuPrivate::init() } setPlatformMenu(QGuiApplicationPrivate::platformTheme()->createPlatformMenu()); + sloppyState.initialize(q); + delayState.initialize(q); + mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, q); } void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu) @@ -270,7 +289,6 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const maxIconWidth = 0; hasCheckableItems = false; ncols = 1; - sloppyAction = 0; for (int i = 0; i < actions.count(); ++i) { QAction *action = actions.at(i); @@ -482,21 +500,30 @@ void QMenuPrivate::hideMenu(QMenu *menu) aboutToHide = false; blocker.unblock(); #endif // QT_NO_EFFECTS + if (activeMenu == menu) + activeMenu = 0; + menu->d_func()->causedPopup.action = 0; + menu->d_func()->causedPopup.widget = 0; menu->close(); + if (previousMouseMenu.data() == menu) + handleEnterLeaveEvents(&previousMouseMenu, Q_NULLPTR); } void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) { Q_Q(QMenu); - if (action && action->isEnabled()) { - if (!delay) - q->internalDelayedPopup(); - else if (!menuDelayTimer.isActive() && (!action->menu() || !action->menu()->isVisible())) - menuDelayTimer.start(delay, q); - if (activateFirst && action->menu()) - action->menu()->d_func()->setFirstActionActive(); + if (action) { + if (action->isEnabled()) { + if (!delay) + q->internalDelayedPopup(); + else if (action->menu() && !action->menu()->isVisible()) + delayState.start(delay, action); + else if (!action->menu()) + delayState.stop(); + if (activateFirst && action->menu()) + action->menu()->d_func()->setFirstActionActive(); + } } else if (QMenu *menu = activeMenu) { //hide the current item - activeMenu = 0; hideMenu(menu); } } @@ -547,33 +574,32 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason { Q_Q(QMenu); tearoffHighlighted = 0; + + if (action + && (action->isSeparator() + || (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)))) + action = Q_NULLPTR; + // Reselect the currently active action in case mouse moved over other menu items when // moving from sub menu action to sub menu (QTBUG-20094). - if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) { + if (reason != SelectedFromKeyboard) { if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) { if (causedPopup.action && menu->d_func()->activeMenu == q) menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false); } - return; } if (currentAction) q->update(actionRect(currentAction)); - sloppyAction = 0; - if (!sloppyRegion.isEmpty()) - sloppyRegion = QRegion(); QMenu *hideActiveMenu = activeMenu; -#ifndef QT_NO_STATUSTIP QAction *previousAction = currentAction; -#endif currentAction = action; if (action) { if (!action->isSeparator()) { activateAction(action, QAction::Hover); if (popup != -1) { - hideActiveMenu = 0; //will be done "later" // if the menu is visible then activate the required action, // otherwise we just mark the action as currentAction // and activate it when the menu will be popuped. @@ -596,24 +622,122 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } } } - } else { //action is a separator - if (popup != -1) - hideActiveMenu = 0; //will be done "later" } #ifndef QT_NO_STATUSTIP } else if (previousAction) { previousAction->d_func()->showStatusText(topCausedWidget(), QString()); #endif } - if (hideActiveMenu) { - activeMenu = 0; + if (hideActiveMenu && previousAction != currentAction) { + if (popup == -1) { #ifndef QT_NO_EFFECTS - // kill any running effect - qFadeEffect(0); - qScrollEffect(0); + // kill any running effect + qFadeEffect(0); + qScrollEffect(0); #endif - hideMenu(hideActiveMenu); + hideMenu(hideActiveMenu); + } else if (!currentAction || !currentAction->menu()) { + sloppyState.startTimerIfNotRunning(); + } + } +} + +void QMenuSloppyState::reset() +{ + m_enabled = false; + m_first_mouse = true; + m_init_guard = false; + m_uni_dir_discarded_count = 0; + m_time.stop(); + m_reset_action = Q_NULLPTR; + m_origin_action = Q_NULLPTR; + m_action_rect = QRect(); + m_previous_point = QPointF(); + if (m_sub_menu) { + QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = Q_NULLPTR; + m_sub_menu = Q_NULLPTR; + } +} +void QMenuSloppyState::enter() +{ + QMenuPrivate *menuPriv = QMenuPrivate::get(m_menu); + + if (m_discard_state_when_entering_parent && m_sub_menu == menuPriv->activeMenu) { + menuPriv->hideMenu(m_sub_menu); + reset(); + } + if (m_parent) + m_parent->childEnter(); +} + +void QMenuSloppyState::childLeave() +{ + if (m_enabled && !QMenuPrivate::get(m_menu)->hasReceievedEnter) { + startTimer(); + if (m_parent) + m_parent->childLeave(); + } +} + +void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAction, QMenu *subMenu) +{ + m_enabled = true; + m_init_guard = true; + m_time.stop(); + m_action_rect = actionRect; + m_sub_menu = subMenu; + QMenuPrivate::get(subMenu)->sloppyState.m_parent = this; + m_reset_action = resetAction; + m_origin_action = resetAction; +} + +bool QMenuSloppyState::hasParentActiveDelayTimer() const +{ + return m_parent && m_parent->m_menu && QMenuPrivate::get(m_parent->m_menu)->delayState.timer.isActive(); +} + +class ResetOnDestroy +{ +public: + ResetOnDestroy(QMenuSloppyState *sloppyState, bool *guard) + : toReset(sloppyState) + , guard(guard) + { + *guard = false; + } + + ~ResetOnDestroy() + { + if (!*guard) + toReset->reset(); } + + QMenuSloppyState *toReset; + bool *guard; +}; + +void QMenuSloppyState::timeout() +{ + QMenuPrivate *menu_priv = QMenuPrivate::get(m_menu); + if (menu_priv->currentAction == m_reset_action + && menu_priv->hasReceievedEnter + && (menu_priv->currentAction + && menu_priv->currentAction->menu() == menu_priv->activeMenu)) { + return; + } + + ResetOnDestroy resetState(this, &m_init_guard); + + if (hasParentActiveDelayTimer() || !m_menu || !m_menu->isVisible()) + return; + + if (m_sub_menu) + menu_priv->hideMenu(m_sub_menu); + + if (menu_priv->hasReceievedEnter) + menu_priv->setCurrentAction(m_reset_action,0); + else + menu_priv->setCurrentAction(Q_NULLPTR, 0); } //return the top causedPopup.widget that is not a QMenu @@ -964,8 +1088,10 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) tearoffHighlighted = 0; } - if (q->frameGeometry().contains(e->globalPos())) //otherwise if the event is in our rect we want it.. + if (q->frameGeometry().contains(e->globalPos())) { //otherwise if the event is in our rect we want it.. + handleEnterLeaveEvents(&previousMouseMenu, q); return false; + } for(QWidget *caused = causedPopup.widget; caused;) { bool passOnEvent = false; @@ -981,17 +1107,18 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) next_widget = m->d_func()->causedPopup.widget; } if (passOnEvent) { + handleEnterLeaveEvents(&previousMouseMenu,qobject_cast<QMenu *>(caused)); if(e->type() != QEvent::MouseButtonRelease || mouseDown == caused) { QMouseEvent new_e(e->type(), cpos, caused->mapTo(caused->topLevelWidget(), cpos), e->screenPos(), e->button(), e->buttons(), e->modifiers()); QGuiApplicationPrivate::setMouseEventSource(&new_e, e->source()); QApplication::sendEvent(caused, &new_e); return true; + } } - } - if (!next_widget) - break; caused = next_widget; + if (!caused) + handleEnterLeaveEvents(&previousMouseMenu, Q_NULLPTR); } return false; } @@ -2236,6 +2363,8 @@ void QMenu::hideEvent(QHideEvent *) #endif d->mouseDown = 0; d->hasHadMouse = false; + if (d->activeMenu) + d->hideMenu(d->activeMenu); d->causedPopup.widget = 0; d->causedPopup.action = 0; if (d->scroll) @@ -2402,7 +2531,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) #endif d->activateAction(action, QAction::Trigger); } - } else if (d->hasMouseMoved(e->globalPos())) { + } else if ((!action || action->isEnabled()) && d->hasMouseMoved(e->globalPos())) { d->hideUpToMenuBar(); } } @@ -2467,8 +2596,8 @@ QMenu::event(QEvent *e) } } break; case QEvent::ContextMenu: - if(d->menuDelayTimer.isActive()) { - d->menuDelayTimer.stop(); + if (d->delayState.timer.isActive()) { + d->delayState.stop(); internalDelayedPopup(); } break; @@ -2485,6 +2614,7 @@ QMenu::event(QEvent *e) case QEvent::Show: d->mouseDown = 0; d->updateActionRects(); + d->sloppyState.reset(); if (d->currentAction) d->popupAction(d->currentAction, 0, false); break; @@ -2892,34 +3022,34 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) Q_D(QMenu); if (!isVisible() || d->aboutToHide || d->mouseEventTaken(e)) return; + d->motions++; - if (d->motions == 0) // ignore first mouse move event (see enterEvent()) + if (d->motions == 0) return; + d->hasHadMouse = d->hasHadMouse || rect().contains(e->pos()); QAction *action = d->actionAt(e->pos()); - if (!action || action->isSeparator()) { + if ((!action || action->isSeparator()) && !d->sloppyState.enabled()) { if (d->hasHadMouse - && d->sloppyDelayTimer == 0 // Keep things as they are while we're moving to the submenu - && (!d->currentAction || (action && action->isSeparator()) - || !(d->currentAction->menu() && d->currentAction->menu()->isVisible()))) - d->setCurrentAction(0); + || (!d->currentAction || !d->currentAction->menu() || !d->currentAction->menu()->isVisible())) { + d->setCurrentAction(action); + } return; - } else if(e->buttons()) { - d->mouseDown = this; } - if (d->sloppyRegion.contains(e->pos())) { - // If the timer is already running then don't start a new one unless the action is the same - if (d->sloppyAction != action && d->sloppyDelayTimer != 0) { - killTimer(d->sloppyDelayTimer); - d->sloppyDelayTimer = 0; - } - if (d->sloppyDelayTimer == 0) { - d->sloppyAction = action; - d->sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this) * 6); - } - } else if (action != d->currentAction) { - d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)); + + if (e->buttons()) + d->mouseDown = this; + + if (d->activeMenu) + d->activeMenu->d_func()->setCurrentAction(0); + + QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction); + if (sloppyEventResult == QMenuSloppyState::EventShouldBePropogated) { + d->setCurrentAction(action, d->mousePopupDelay); + } else if (sloppyEventResult == QMenuSloppyState::EventDiscardsSloppyState) { + d->sloppyState.reset(); + d->hideMenu(d->activeMenu); } } @@ -2928,7 +3058,11 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) */ void QMenu::enterEvent(QEvent *) { - d_func()->motions = -1; // force us to ignore the generate mouse move in mouseMoveEvent() + Q_D(QMenu); + d->hasReceievedEnter = true; + d->sloppyState.enter(); + d->sloppyState.startTimer(); + d->motions = -1; // force us to ignore the generate mouse move in mouseMoveEvent() } /*! @@ -2937,9 +3071,8 @@ void QMenu::enterEvent(QEvent *) void QMenu::leaveEvent(QEvent *) { Q_D(QMenu); - d->sloppyAction = 0; - if (!d->sloppyRegion.isEmpty()) - d->sloppyRegion = QRegion(); + d->hasReceievedEnter = false; + d->sloppyState.leave(); if (!d->activeMenu && d->currentAction) setActiveAction(0); } @@ -2955,13 +3088,14 @@ QMenu::timerEvent(QTimerEvent *e) d->scrollMenu((QMenuPrivate::QMenuScroller::ScrollDirection)d->scroll->scrollDirection); if (d->scroll->scrollFlags == QMenuPrivate::QMenuScroller::ScrollNone) d->scroll->scrollTimer.stop(); - } else if(d->menuDelayTimer.timerId() == e->timerId()) { - d->menuDelayTimer.stop(); + } else if (d->delayState.timer.timerId() == e->timerId()) { + if (d->currentAction && !d->currentAction->menu()) + return; + d->delayState.stop(); + d->sloppyState.stopTimer(); internalDelayedPopup(); - } else if (d->sloppyDelayTimer == e->timerId()) { - killTimer(d->sloppyDelayTimer); - d->sloppyDelayTimer = 0; - internalSetSloppyAction(); + } else if (d->sloppyState.isTimerId(e->timerId())) { + d->sloppyState.timeout(); } else if(d->searchBufferTimer.timerId() == e->timerId()) { d->searchBuffer.clear(); } @@ -3086,23 +3220,13 @@ void QMenu::actionEvent(QActionEvent *e) /*! \internal */ -void QMenu::internalSetSloppyAction() -{ - if (d_func()->sloppyAction) - d_func()->setCurrentAction(d_func()->sloppyAction, 0); -} - -/*! - \internal -*/ void QMenu::internalDelayedPopup() { Q_D(QMenu); - //hide the current item if (QMenu *menu = d->activeMenu) { - d->activeMenu = 0; - d->hideMenu(menu); + if (d->activeMenu->menuAction() != d->currentAction) + d->hideMenu(menu); } if (!d->currentAction || !d->currentAction->isEnabled() || !d->currentAction->menu() || @@ -3116,46 +3240,15 @@ void QMenu::internalDelayedPopup() int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); const QRect actionRect(d->actionRect(d->currentAction)); - const QSize menuSize(d->activeMenu->sizeHint()); const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); QPoint pos(rightPos); - //calc sloppy focus buffer - if (style()->styleHint(QStyle::SH_Menu_SloppySubMenus, 0, this)) { - QPoint cur = QCursor::pos(); - if (actionRect.contains(mapFromGlobal(cur))) { - QPoint pts[4]; - pts[0] = QPoint(cur.x(), cur.y() - 2); - pts[3] = QPoint(cur.x(), cur.y() + 2); - if (pos.x() >= cur.x()) { - pts[1] = QPoint(geometry().right(), pos.y()); - pts[2] = QPoint(geometry().right(), pos.y() + menuSize.height()); - } else { - pts[1] = QPoint(pos.x() + menuSize.width(), pos.y()); - pts[2] = QPoint(pos.x() + menuSize.width(), pos.y() + menuSize.height()); - } - QPolygon points(4); - for(int i = 0; i < 4; i++) - points.setPoint(i, mapFromGlobal(pts[i])); - d->sloppyRegion = QRegion(points); - } - } - - //do the popup d->activeMenu->popup(pos); + d->sloppyState.setSubMenuPopup(actionRect, d->currentAction, d->activeMenu); } /*! - \fn void QMenu::addAction(QAction *action) - \overload - - Appends the action \a action to the menu's list of actions. - - \sa QMenuBar::addAction(), QWidget::addAction() -*/ - -/*! \fn void QMenu::aboutToHide() \since 4.2 diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 937f6e3316..6bc14c7c78 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -72,11 +72,7 @@ public: explicit QMenu(const QString &title, QWidget *parent = 0); ~QMenu(); -#ifdef Q_NO_USING_KEYWORD - inline void addAction(QAction *action) { QWidget::addAction(action); } -#else using QWidget::addAction; -#endif QAction *addAction(const QString &text); QAction *addAction(const QIcon &icon, const QString &text); QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0); @@ -117,7 +113,7 @@ public: static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at=0, QWidget *parent=0); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; QRect actionGeometry(QAction *) const; QAction *actionAt(const QPoint &) const; @@ -157,22 +153,22 @@ Q_SIGNALS: protected: int columnCount() const; - void changeEvent(QEvent *); - void keyPressEvent(QKeyEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *); + void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif - void enterEvent(QEvent *); - void leaveEvent(QEvent *); - void hideEvent(QHideEvent *); - void paintEvent(QPaintEvent *); - void actionEvent(QActionEvent *); - void timerEvent(QTimerEvent *); - bool event(QEvent *); - bool focusNextPrevChild(bool next); + void enterEvent(QEvent *) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void actionEvent(QActionEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const; #ifdef Q_OS_WINCE @@ -180,7 +176,6 @@ protected: #endif private Q_SLOTS: - void internalSetSloppyAction(); void internalDelayedPopup(); private: diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 4a4518671c..64a728eaba 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -71,20 +71,230 @@ struct QWceMenuAction { }; #endif +template <typename T> +class QSetValueOnDestroy +{ +public: + QSetValueOnDestroy(T &toSet, T value) + : toSet(toSet) + , value(value) + { } + + ~QSetValueOnDestroy() { toSet = value; } +private: + T &toSet; + T value; +}; + +class QMenuSloppyState +{ + Q_DISABLE_COPY(QMenuSloppyState) +public: + QMenuSloppyState() + : m_menu(Q_NULLPTR) + , m_enabled(false) + , m_uni_directional(false) + , m_select_other_actions(false) + , m_first_mouse(true) + , m_init_guard(false) + , m_uni_dir_discarded_count(0) + , m_uni_dir_fail_at_count(0) + , m_timeout(0) + , m_reset_action(Q_NULLPTR) + , m_origin_action(Q_NULLPTR) + , m_parent(Q_NULLPTR) + { } + + ~QMenuSloppyState() { reset(); } + + void initialize(QMenu *menu) + { + m_menu = menu; + m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, 0, menu); + m_uni_dir_fail_at_count = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, 0, menu); + m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, 0 , menu); + m_timeout = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout); + m_discard_state_when_entering_parent = menu->style()->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent); + m_dont_start_time_on_leave = menu->style()->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave); + reset(); + } + + void reset(); + bool enabled() const { return m_enabled; } + + void setResetAction(QAction *action) { m_reset_action = action; } + + enum MouseEventResult { + EventIsProcessed, + EventShouldBePropogated, + EventDiscardsSloppyState + }; + + void startTimer() + { + if (m_enabled) + m_time.start(m_timeout, m_menu); + } + + void startTimerIfNotRunning() + { + if (!m_time.isActive()) + startTimer(); + } + + void stopTimer() + { + m_time.stop(); + } + + void enter(); + + void childEnter() + { + stopTimer(); + if (m_parent) + m_parent->childEnter(); + } + + void leave() + { + if (m_dont_start_time_on_leave) + return; + if (m_parent) + m_parent->childLeave(); + startTimer(); + } + void childLeave(); + + static float slope(const QPointF &p1, const QPointF &p2) + { + const QPointF slope = p2 - p1; + if (slope.x()== 0) + return 9999; + return slope.y()/slope.x(); + } + + bool checkSlope(qreal oldS, qreal newS, bool wantSteeper) + { + if (wantSteeper) + return oldS <= newS; + return newS <= oldS; + } + + MouseEventResult processMouseEvent(const QPointF &mousePos, QAction *resetAction, QAction *currentAction) + { + if (m_parent) + m_parent->stopTimer(); + + if (!m_enabled) + return EventShouldBePropogated; + + if (!m_time.isActive()) + startTimer(); + + if (!m_sub_menu) { + reset(); + return EventShouldBePropogated; + } + + QSetValueOnDestroy<bool> setFirstMouse(m_first_mouse, false); + QSetValueOnDestroy<QPointF> setPreviousPoint(m_previous_point, mousePos); + + if (resetAction && resetAction->isSeparator()) + m_reset_action = Q_NULLPTR; + else { + m_reset_action = resetAction; + } + + if (m_action_rect.contains(mousePos)) { + startTimer(); + return currentAction == m_menu->menuAction() ? EventIsProcessed : EventShouldBePropogated; + } + + if (m_uni_directional && !m_first_mouse && resetAction != m_origin_action) { + bool left_to_right = m_menu->layoutDirection() == Qt::LeftToRight; + QRect sub_menu_rect = m_sub_menu->geometry(); + QPoint sub_menu_top = + left_to_right? sub_menu_rect.topLeft() : sub_menu_rect.topRight(); + QPoint sub_menu_bottom = + left_to_right? sub_menu_rect.bottomLeft() : sub_menu_rect.bottomRight(); + qreal prev_slope_top = slope(m_previous_point, sub_menu_top); + qreal prev_slope_bottom = slope(m_previous_point, sub_menu_bottom); + + qreal current_slope_top = slope(mousePos, sub_menu_top); + qreal current_slope_bottom = slope(mousePos, sub_menu_bottom); + + bool slopeTop = checkSlope(prev_slope_top, current_slope_top, sub_menu_top.y() < mousePos.y()); + bool slopeBottom = checkSlope(prev_slope_bottom, current_slope_bottom, sub_menu_bottom.y() > mousePos.y()); + bool rightDirection = false; + int mouseDir = m_previous_point.y() - mousePos.y(); + if (mouseDir >= 0) { + rightDirection = rightDirection || slopeTop; + } + if (mouseDir <= 0) { + rightDirection = rightDirection || slopeBottom; + } + + if (m_uni_dir_discarded_count >= m_uni_dir_fail_at_count && !rightDirection) { + m_uni_dir_discarded_count = 0; + return EventDiscardsSloppyState; + } + + if (!rightDirection) + m_uni_dir_discarded_count++; + else + m_uni_dir_discarded_count = 0; + + } + + return m_select_other_actions ? EventShouldBePropogated : EventIsProcessed; + } + + void setSubMenuPopup(const QRect &actionRect, QAction *resetAction, QMenu *subMenu); + bool hasParentActiveDelayTimer() const; + void timeout(); + int timeForTimeout() const { return m_timeout; } + + bool isTimerId(int timerId) const { return m_time.timerId() == timerId; } + QMenu *subMenu() const { return m_sub_menu; } + +private: + QMenu *m_menu; + bool m_enabled; + bool m_uni_directional; + bool m_select_other_actions; + bool m_first_mouse; + bool m_init_guard; + bool m_discard_state_when_entering_parent; + bool m_dont_start_time_on_leave; + short m_uni_dir_discarded_count; + short m_uni_dir_fail_at_count; + short m_timeout; + QBasicTimer m_time; + QAction *m_reset_action; + QAction *m_origin_action; + QRectF m_action_rect; + QPointF m_previous_point; + QPointer<QMenu> m_sub_menu; + QMenuSloppyState *m_parent; +}; + class QMenuPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QMenu) public: QMenuPrivate() : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0), collapsibleSeparators(true), toolTipsVisible(false), - activationRecursionGuard(false), hasHadMouse(0), aboutToHide(0), motions(0), + activationRecursionGuard(false), delayedPopupGuard(false), + hasReceievedEnter(false), + hasHadMouse(0), aboutToHide(0), motions(0), currentAction(0), #ifdef QT_KEYPAD_NAVIGATION selectAction(0), cancelAction(0), #endif scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0), - hasCheckableItems(0), sloppyDelayTimer(0), sloppyAction(0), doChildEffects(false), platformMenu(0) + hasCheckableItems(0), doChildEffects(false), platformMenu(0) #if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR) ,wce_menu(0) @@ -127,6 +337,8 @@ public: int getLastVisibleAction() const; bool activationRecursionGuard; + bool delayedPopupGuard; + bool hasReceievedEnter; //selection static QMenu *mouseDown; @@ -134,12 +346,39 @@ public: uint hasHadMouse : 1; uint aboutToHide : 1; int motions; + int mousePopupDelay; QAction *currentAction; #ifdef QT_KEYPAD_NAVIGATION QAction *selectAction; QAction *cancelAction; #endif - QBasicTimer menuDelayTimer; + struct DelayState { + DelayState() + : parent(0) + , action(0) + { } + void initialize(QMenu *parent) + { + this->parent = parent; + } + + void start(int timeout, QAction *toStartAction) + { + if (timer.isActive() && toStartAction == action) + return; + action = toStartAction; + timer.start(timeout,parent); + } + void stop() + { + action = 0; + timer.stop(); + } + + QMenu *parent; + QBasicTimer timer; + QAction *action; + } delayState; enum SelectionReason { SelectedFromKeyboard, SelectedFromElsewhere @@ -198,10 +437,7 @@ public: mutable bool hasCheckableItems; - //sloppy selection - int sloppyDelayTimer; - mutable QAction *sloppyAction; - QRegion sloppyRegion; + QMenuSloppyState sloppyState; //default action QPointer<QAction> defaultAction; @@ -257,6 +493,7 @@ public: QAction* wceCommands(uint command); #endif QPointer<QWidget> noReplayFor; + static QPointer<QMenu> previousMouseMenu; }; #endif // QT_NO_MENU diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 619cb64636..54d403fa21 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -69,8 +69,8 @@ class QMenuBarExtension : public QToolButton public: explicit QMenuBarExtension(QWidget *parent); - QSize sizeHint() const; - void paintEvent(QPaintEvent *); + QSize sizeHint() const Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; }; QMenuBarExtension::QMenuBarExtension(QWidget *parent) @@ -1922,15 +1922,6 @@ QAction *QMenuBar::defaultAction() const \sa triggered(), QAction::hovered() */ -/*! - \fn void QMenuBar::addAction(QAction *action) - \overload - - Appends the action \a action to the menu bar's list of actions. - - \sa QMenu::addAction(), QWidget::addAction(), QWidget::actions() -*/ - // for private slots diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index cd2d2cd7aa..936cb22880 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -57,11 +57,7 @@ public: explicit QMenuBar(QWidget *parent = 0); ~QMenuBar(); -#ifdef Q_NO_USING_KEYWORD - void addAction(QAction *action) { QWidget::addAction(action); } -#else using QWidget::addAction; -#endif QAction *addAction(const QString &text); QAction *addAction(const QString &text, const QObject *receiver, const char* member); diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index e56fd111e5..b7bf4974d0 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -604,6 +604,10 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const { return r; } +QString QPlainTextEditControl::anchorAt(const QPointF &pos) const +{ + return textEdit->anchorAt(pos.toPoint()); +} void QPlainTextEditPrivate::setTopLine(int visualTopLine, int dx) { @@ -800,7 +804,7 @@ void QPlainTextEditPrivate::init(const QString &txt) viewport->setCursor(Qt::IBeamCursor); #endif originalOffsetY = 0; -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN setSingleFingerPanEnabled(true); #endif } diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index 9f67aaa8da..bb9ecc9886 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -59,7 +59,6 @@ class Q_WIDGETS_EXPORT QPlainTextEdit : public QAbstractScrollArea { Q_OBJECT Q_DECLARE_PRIVATE(QPlainTextEdit) - Q_ENUMS(LineWrapMode) Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus) Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle) Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled) @@ -81,6 +80,7 @@ public: NoWrap, WidgetWidth }; + Q_ENUM(LineWrapMode) explicit QPlainTextEdit(QWidget *parent = 0); explicit QPlainTextEdit(const QString &text, QWidget *parent = 0); @@ -176,7 +176,7 @@ public: void print(QPagedPaintDevice *printer) const; int blockCount() const; - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; public Q_SLOTS: @@ -218,43 +218,43 @@ Q_SIGNALS: void modificationChanged(bool); protected: - virtual bool event(QEvent *e); - virtual void timerEvent(QTimerEvent *e); - virtual void keyPressEvent(QKeyEvent *e); - virtual void keyReleaseEvent(QKeyEvent *e); - virtual void resizeEvent(QResizeEvent *e); - virtual void paintEvent(QPaintEvent *e); - virtual void mousePressEvent(QMouseEvent *e); - virtual void mouseMoveEvent(QMouseEvent *e); - virtual void mouseReleaseEvent(QMouseEvent *e); - virtual void mouseDoubleClickEvent(QMouseEvent *e); - virtual bool focusNextPrevChild(bool next); + virtual bool event(QEvent *e) Q_DECL_OVERRIDE; + virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - virtual void contextMenuEvent(QContextMenuEvent *e); + virtual void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_DRAGANDDROP - virtual void dragEnterEvent(QDragEnterEvent *e); - virtual void dragLeaveEvent(QDragLeaveEvent *e); - virtual void dragMoveEvent(QDragMoveEvent *e); - virtual void dropEvent(QDropEvent *e); + virtual void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; + virtual void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; + virtual void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; + virtual void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE; #endif - virtual void focusInEvent(QFocusEvent *e); - virtual void focusOutEvent(QFocusEvent *e); - virtual void showEvent(QShowEvent *); - virtual void changeEvent(QEvent *e); + virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent *e) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent *e); + virtual void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif virtual QMimeData *createMimeDataFromSelection() const; virtual bool canInsertFromMimeData(const QMimeData *source) const; virtual void insertFromMimeData(const QMimeData *source); - virtual void inputMethodEvent(QInputMethodEvent *); + virtual void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; QPlainTextEdit(QPlainTextEditPrivate &dd, QWidget *parent); - virtual void scrollContentsBy(int dx, int dy); + virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; virtual void doSetTextCursor(const QTextCursor &cursor); QTextBlock firstVisibleBlock() const; @@ -287,14 +287,14 @@ public: QPlainTextDocumentLayout(QTextDocument *document); ~QPlainTextDocumentLayout(); - void draw(QPainter *, const PaintContext &); - int hitTest(const QPointF &, Qt::HitTestAccuracy ) const; + void draw(QPainter *, const PaintContext &) Q_DECL_OVERRIDE; + int hitTest(const QPointF &, Qt::HitTestAccuracy ) const Q_DECL_OVERRIDE; - int pageCount() const; - QSizeF documentSize() const; + int pageCount() const Q_DECL_OVERRIDE; + QSizeF documentSize() const Q_DECL_OVERRIDE; - QRectF frameBoundingRect(QTextFrame *) const; - QRectF blockBoundingRect(const QTextBlock &block) const; + QRectF frameBoundingRect(QTextFrame *) const Q_DECL_OVERRIDE; + QRectF blockBoundingRect(const QTextBlock &block) const Q_DECL_OVERRIDE; void ensureBlockLayout(const QTextBlock &block) const; @@ -304,7 +304,7 @@ public: void requestUpdate(); protected: - void documentChanged(int from, int /*charsRemoved*/, int charsAdded); + void documentChanged(int from, int /*charsRemoved*/, int charsAdded) Q_DECL_OVERRIDE; private: diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h index 6ab8b90a0d..30aff5e97c 100644 --- a/src/widgets/widgets/qplaintextedit_p.h +++ b/src/widgets/widgets/qplaintextedit_p.h @@ -72,18 +72,19 @@ public: QPlainTextEditControl(QPlainTextEdit *parent); - QMimeData *createMimeDataFromSelection() const; - bool canInsertFromMimeData(const QMimeData *source) const; - void insertFromMimeData(const QMimeData *source); - int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const; - QRectF blockBoundingRect(const QTextBlock &block) const; + QMimeData *createMimeDataFromSelection() const Q_DECL_OVERRIDE; + bool canInsertFromMimeData(const QMimeData *source) const Q_DECL_OVERRIDE; + void insertFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE; + int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const Q_DECL_OVERRIDE; + QRectF blockBoundingRect(const QTextBlock &block) const Q_DECL_OVERRIDE; + QString anchorAt(const QPointF &pos) const Q_DECL_OVERRIDE; inline QRectF cursorRect(const QTextCursor &cursor) const { QRectF r = QWidgetTextControl::cursorRect(cursor); r.setLeft(qMax(r.left(), (qreal) 0.)); return r; } inline QRectF cursorRect() { return cursorRect(textCursor()); } - void ensureCursorVisible() { + void ensureCursorVisible() Q_DECL_OVERRIDE { textEdit->ensureCursorVisible(); emit microFocusChanged(); } @@ -93,7 +94,7 @@ public: int topBlock; QTextBlock firstVisibleBlock() const; - QVariant loadResource(int type, const QUrl &name) { + QVariant loadResource(int type, const QUrl &name) Q_DECL_OVERRIDE { return textEdit->loadResource(type, name); } diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 58aec8ee9a..89d2243299 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -132,7 +132,7 @@ void QProgressBar::initStyleOption(QStyleOptionProgressBar *option) const if (QStyleOptionProgressBarV2 *optionV2 = qstyleoption_cast<QStyleOptionProgressBarV2 *>(option)) { - optionV2->orientation = d->orientation; // ### Qt 5: use State_Horizontal instead + optionV2->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBarV2 optionV2->invertedAppearance = d->invertedAppearance; optionV2->bottomToTop = (d->textDirection == QProgressBar::BottomToTop); } @@ -426,7 +426,7 @@ QSize QProgressBar::sizeHint() const int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this); QSize size = QSize(qMax(9, cw) * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8); if (opt.orientation == Qt::Vertical) - size.transpose(); + size = size.transposed(); return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this); } diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h index 2cdcbccdb3..7e1a04bd7b 100644 --- a/src/widgets/widgets/qprogressbar.h +++ b/src/widgets/widgets/qprogressbar.h @@ -47,7 +47,6 @@ class QStyleOptionProgressBar; class Q_WIDGETS_EXPORT QProgressBar : public QWidget { Q_OBJECT - Q_ENUMS(Direction) Q_PROPERTY(int minimum READ minimum WRITE setMinimum) Q_PROPERTY(int maximum READ maximum WRITE setMaximum) Q_PROPERTY(QString text READ text) @@ -61,6 +60,7 @@ class Q_WIDGETS_EXPORT QProgressBar : public QWidget public: enum Direction { TopToBottom, BottomToTop }; + Q_ENUM(Direction) explicit QProgressBar(QWidget *parent = 0); ~QProgressBar(); @@ -77,8 +77,8 @@ public: Qt::Alignment alignment() const; void setAlignment(Qt::Alignment alignment); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; Qt::Orientation orientation() const; @@ -103,8 +103,8 @@ Q_SIGNALS: void valueChanged(int value); protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionProgressBar *option) const; private: diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index 84a0afd0b8..ff1c0a1abe 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -50,10 +50,10 @@ #include "qdebug.h" #include "qlayoutitem.h" #include "qdialogbuttonbox.h" -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC #include "private/qmacstyle_mac_p.h" #include "private/qmacstyle_mac_p_p.h" -#endif // Q_WS_MAC +#endif // Q_DEAD_CODE_FROM_QT4_MAC #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" @@ -673,7 +673,7 @@ bool QPushButton::event(QEvent *e) return QAbstractButton::event(e); } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC /*! \reimp */ bool QPushButton::hitButton(const QPoint &pos) const { @@ -702,7 +702,7 @@ bool QPushButtonPrivate::hitButton(const QPoint &pos) q->rect().height() - QMacStylePrivate::PushButtonBottomOffset); return roundedRect.contains(pos); } -#endif // Q_WS_MAC +#endif // Q_DEAD_CODE_FROM_QT4_MAC QT_END_NAMESPACE diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index ebf66f8ef8..9a52a7eb99 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -57,8 +57,8 @@ public: QPushButton(const QIcon& icon, const QString &text, QWidget *parent=0); ~QPushButton(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; bool autoDefault() const; void setAutoDefault(bool); @@ -79,14 +79,14 @@ public Q_SLOTS: #endif protected: - bool event(QEvent *e); -#ifdef Q_WS_MAC + bool event(QEvent *e) Q_DECL_OVERRIDE; +#ifdef Q_DEAD_CODE_FROM_QT4_MAC bool hitButton(const QPoint &pos) const; -#endif // Q_WS_MAC - void paintEvent(QPaintEvent *); - void keyPressEvent(QKeyEvent *); - void focusInEvent(QFocusEvent *); - void focusOutEvent(QFocusEvent *); +#endif // Q_DEAD_CODE_FROM_QT4_MAC + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionButton *option) const; QPushButton(QPushButtonPrivate &dd, QWidget* parent = 0); diff --git a/src/widgets/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h index 0f5e9a9796..ac6e1efbfa 100644 --- a/src/widgets/widgets/qpushbutton_p.h +++ b/src/widgets/widgets/qpushbutton_p.h @@ -64,7 +64,7 @@ public: inline void init() { resetLayoutItemMargins(); } static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC bool hitButton(const QPoint &pos); #endif #ifndef QT_NO_MENU diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h index 0bfb0de4e8..beda0e0d38 100644 --- a/src/widgets/widgets/qradiobutton.h +++ b/src/widgets/widgets/qradiobutton.h @@ -51,14 +51,14 @@ public: explicit QRadioButton(const QString &text, QWidget *parent=0); ~QRadioButton(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; protected: - bool event(QEvent *e); - bool hitButton(const QPoint &) const; - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + bool hitButton(const QPoint &) const Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionButton *button) const; diff --git a/src/widgets/widgets/qrubberband.cpp b/src/widgets/widgets/qrubberband.cpp index 2a425c27db..107fa7c629 100644 --- a/src/widgets/widgets/qrubberband.cpp +++ b/src/widgets/widgets/qrubberband.cpp @@ -41,7 +41,7 @@ #include "qstyle.h" #include "qstyleoption.h" -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC # include <private/qt_mac_p.h> # include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -136,12 +136,12 @@ QRubberBand::QRubberBand(Shape s, QWidget *p) Q_D(QRubberBand); d->shape = s; setAttribute(Qt::WA_TransparentForMouseEvents); -#ifndef Q_WS_WIN +#ifndef Q_DEAD_CODE_FROM_QT4_WIN setAttribute(Qt::WA_NoSystemBackground); -#endif //Q_WS_WIN +#endif //Q_DEAD_CODE_FROM_QT4_WIN setAttribute(Qt::WA_WState_ExplicitShowHide); setVisible(false); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC if (isWindow()) { createWinId(); extern OSWindowRef qt_mac_window_for(const QWidget *); //qwidget_mac.cpp diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h index 7193f69f59..f46d6a8643 100644 --- a/src/widgets/widgets/qrubberband.h +++ b/src/widgets/widgets/qrubberband.h @@ -67,12 +67,12 @@ public: { resize(s.width(), s.height()); } protected: - bool event(QEvent *e); - void paintEvent(QPaintEvent *); - void changeEvent(QEvent *); - void showEvent(QShowEvent *); - void resizeEvent(QResizeEvent *); - void moveEvent(QMoveEvent *); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void moveEvent(QMoveEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionRubberBand *option) const; private: diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h index 568dbc6e4f..3ec9ca14a3 100644 --- a/src/widgets/widgets/qscrollarea.h +++ b/src/widgets/widgets/qscrollarea.h @@ -60,9 +60,9 @@ public: bool widgetResizable() const; void setWidgetResizable(bool resizable); - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; - bool focusNextPrevChild(bool next); + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; Qt::Alignment alignment() const; void setAlignment(Qt::Alignment); @@ -72,10 +72,10 @@ public: protected: QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = 0); - bool event(QEvent *); - bool eventFilter(QObject *, QEvent *); - void resizeEvent(QResizeEvent *); - void scrollContentsBy(int dx, int dy); + bool event(QEvent *) Q_DECL_OVERRIDE; + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; QSize viewportSizeHint() const Q_DECL_OVERRIDE; diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h index 2b67f04850..992bd511c8 100644 --- a/src/widgets/widgets/qscrollbar.h +++ b/src/widgets/widgets/qscrollbar.h @@ -53,21 +53,21 @@ public: explicit QScrollBar(Qt::Orientation, QWidget *parent=0); ~QScrollBar(); - QSize sizeHint() const; - bool event(QEvent *event); + QSize sizeHint() const Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; protected: #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *); + void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void hideEvent(QHideEvent*); - void sliderChange(SliderChange change); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent*) Q_DECL_OVERRIDE; + void sliderChange(SliderChange change) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE; #endif void initStyleOption(QStyleOptionSlider *option) const; diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 184aa37806..ee6a4e3815 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -46,7 +46,7 @@ #include "qdebug.h" #include <QDesktopWidget> -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC #include <private/qt_mac_p.h> #endif @@ -76,7 +76,7 @@ public: Qt::Corner m_corner; bool gotMousePress; QPointer<QWidget> tlw; -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC void updateMacSizer(bool hide) const; #endif Qt::Corner corner() const; @@ -114,7 +114,7 @@ public: updateTopLevelWidget(); if (tlw && showSizeGrip) { Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen; -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC sizeGripNotVisibleState |= Qt::WindowMaximized; #endif // Don't show the size grip if the tlw is maximized or in full screen mode. @@ -136,7 +136,7 @@ QSizeGripPrivate::QSizeGripPrivate() { } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC void QSizeGripPrivate::updateMacSizer(bool hide) const { Q_Q(const QSizeGrip); @@ -219,7 +219,7 @@ void QSizeGripPrivate::init() Q_Q(QSizeGrip); m_corner = q->isLeftToRight() ? Qt::BottomRightCorner : Qt::BottomLeftCorner; -#if !defined(QT_NO_CURSOR) && !defined(Q_WS_MAC) +#if !defined(QT_NO_CURSOR) && !defined(Q_DEAD_CODE_FROM_QT4_MAC) q->setCursor(m_corner == Qt::TopLeftCorner || m_corner == Qt::BottomRightCorner ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor); #endif @@ -432,7 +432,7 @@ void QSizeGrip::moveEvent(QMoveEvent * /*moveEvent*/) return; d->m_corner = d->corner(); -#if !defined(QT_NO_CURSOR) && !defined(Q_WS_MAC) +#if !defined(QT_NO_CURSOR) && !defined(Q_DEAD_CODE_FROM_QT4_MAC) setCursor(d->m_corner == Qt::TopLeftCorner || d->m_corner == Qt::BottomRightCorner ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor); #endif @@ -443,7 +443,7 @@ void QSizeGrip::moveEvent(QMoveEvent * /*moveEvent*/) */ void QSizeGrip::showEvent(QShowEvent *showEvent) { -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC d_func()->updateMacSizer(false); #endif QWidget::showEvent(showEvent); @@ -454,7 +454,7 @@ void QSizeGrip::showEvent(QShowEvent *showEvent) */ void QSizeGrip::hideEvent(QHideEvent *hideEvent) { -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC d_func()->updateMacSizer(true); #endif QWidget::hideEvent(hideEvent); @@ -478,7 +478,7 @@ bool QSizeGrip::eventFilter(QObject *o, QEvent *e) return QWidget::eventFilter(o, e); } Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen; -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC sizeGripNotVisibleState |= Qt::WindowMaximized; #endif // Don't show the size grip if the tlw is maximized or in full screen mode. diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h index 61b397e2bb..7885d0a2b7 100644 --- a/src/widgets/widgets/qsizegrip.h +++ b/src/widgets/widgets/qsizegrip.h @@ -48,19 +48,19 @@ public: explicit QSizeGrip(QWidget *parent); ~QSizeGrip(); - QSize sizeHint() const; - void setVisible(bool); + QSize sizeHint() const Q_DECL_OVERRIDE; + void setVisible(bool) Q_DECL_OVERRIDE; protected: - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *mouseEvent); - void moveEvent(QMoveEvent *moveEvent); - void showEvent(QShowEvent *showEvent); - void hideEvent(QHideEvent *hideEvent); - bool eventFilter(QObject *, QEvent *); - bool event(QEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; + void moveEvent(QMoveEvent *moveEvent) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *hideEvent) Q_DECL_OVERRIDE; + bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; public: diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h index 6d7bf7eee8..6191e7fcab 100644 --- a/src/widgets/widgets/qslider.h +++ b/src/widgets/widgets/qslider.h @@ -47,7 +47,6 @@ class Q_WIDGETS_EXPORT QSlider : public QAbstractSlider { Q_OBJECT - Q_ENUMS(TickPosition) Q_PROPERTY(TickPosition tickPosition READ tickPosition WRITE setTickPosition) Q_PROPERTY(int tickInterval READ tickInterval WRITE setTickInterval) @@ -60,14 +59,15 @@ public: TicksRight = TicksBelow, TicksBothSides = 3 }; + Q_ENUM(TickPosition) explicit QSlider(QWidget *parent = 0); explicit QSlider(Qt::Orientation orientation, QWidget *parent = 0); ~QSlider(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setTickPosition(TickPosition position); TickPosition tickPosition() const; @@ -75,13 +75,13 @@ public: void setTickInterval(int ti); int tickInterval() const; - bool event(QEvent *event); + bool event(QEvent *event) Q_DECL_OVERRIDE; protected: - void paintEvent(QPaintEvent *ev); - void mousePressEvent(QMouseEvent *ev); - void mouseReleaseEvent(QMouseEvent *ev); - void mouseMoveEvent(QMouseEvent *ev); + void paintEvent(QPaintEvent *ev) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionSlider *option) const; diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index e8b22151fa..3e5f690f5b 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -41,7 +41,6 @@ #include <qvalidator.h> #include <qdebug.h> -#include <math.h> #include <float.h> QT_BEGIN_NAMESPACE @@ -58,10 +57,10 @@ class QSpinBoxPrivate : public QAbstractSpinBoxPrivate Q_DECLARE_PUBLIC(QSpinBox) public: QSpinBoxPrivate(); - void emitSignals(EmitPolicy ep, const QVariant &); + void emitSignals(EmitPolicy ep, const QVariant &) Q_DECL_OVERRIDE; - virtual QVariant valueFromText(const QString &n) const; - virtual QString textFromValue(const QVariant &n) const; + virtual QVariant valueFromText(const QString &n) const Q_DECL_OVERRIDE; + virtual QString textFromValue(const QVariant &n) const Q_DECL_OVERRIDE; QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const; @@ -79,10 +78,10 @@ class QDoubleSpinBoxPrivate : public QAbstractSpinBoxPrivate Q_DECLARE_PUBLIC(QDoubleSpinBox) public: QDoubleSpinBoxPrivate(); - void emitSignals(EmitPolicy ep, const QVariant &); + void emitSignals(EmitPolicy ep, const QVariant &) Q_DECL_OVERRIDE; - virtual QVariant valueFromText(const QString &n) const; - virtual QString textFromValue(const QVariant &n) const; + virtual QVariant valueFromText(const QString &n) const Q_DECL_OVERRIDE; + virtual QString textFromValue(const QVariant &n) const Q_DECL_OVERRIDE; QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const; double round(double input) const; diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h index bb8b359831..41db23a434 100644 --- a/src/widgets/widgets/qsplashscreen.h +++ b/src/widgets/widgets/qsplashscreen.h @@ -66,9 +66,9 @@ Q_SIGNALS: void messageChanged(const QString &message); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; virtual void drawContents(QPainter *painter); - void mousePressEvent(QMouseEvent *); + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QSplashScreen) diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h index f82c06c3bc..c08682eef2 100644 --- a/src/widgets/widgets/qsplitter.h +++ b/src/widgets/widgets/qsplitter.h @@ -77,8 +77,8 @@ public: bool opaqueResize() const; void refresh(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; QList<int> sizes() const; void setSizes(const QList<int> &list); @@ -104,12 +104,12 @@ Q_SIGNALS: protected: virtual QSplitterHandle *createHandle(); - void childEvent(QChildEvent *); + void childEvent(QChildEvent *) Q_DECL_OVERRIDE; - bool event(QEvent *); - void resizeEvent(QResizeEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; - void changeEvent(QEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; void moveSplitter(int pos, int index); void setRubberBand(int position); int closestLegalPosition(int, int); @@ -138,15 +138,15 @@ public: bool opaqueResize() const; QSplitter *splitter() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; protected: - void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void resizeEvent(QResizeEvent *); - bool event(QEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; void moveSplitter(int p); int closestLegalPosition(int p); diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h index af048bc749..71191ba133 100644 --- a/src/widgets/widgets/qstackedwidget.h +++ b/src/widgets/widgets/qstackedwidget.h @@ -73,7 +73,7 @@ Q_SIGNALS: void widgetRemoved(int index); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QStackedWidget) diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp index e4a2df15e7..a658a5714e 100644 --- a/src/widgets/widgets/qstatusbar.cpp +++ b/src/widgets/widgets/qstatusbar.cpp @@ -81,7 +81,7 @@ public: int savedStrut; -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC QPoint dragStart; #endif @@ -740,7 +740,7 @@ bool QStatusBar::event(QEvent *e) // On Mac OS X Leopard it is possible to drag the window by clicking // on the tool bar on most applications. -#ifndef Q_WS_MAC +#ifndef Q_DEAD_CODE_FROM_QT4_MAC return QWidget::event(e); #else if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_4) diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index d24680ab2a..56d45b9001 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -73,14 +73,14 @@ Q_SIGNALS: void messageChanged(const QString &text); protected: - void showEvent(QShowEvent *); - void paintEvent(QPaintEvent *); - void resizeEvent(QResizeEvent *); + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; // ### Qt 6: consider making reformat() and hideOrShow() private void reformat(); void hideOrShow(); - bool event(QEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QStatusBar) diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 871bf1eba1..29dd3efeb1 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -57,7 +57,7 @@ #ifndef QT_NO_TABBAR -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> #endif @@ -1802,7 +1802,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event) d->moveTabFinished(d->pressedIndex); d->pressedIndex = d->indexAtPos(event->pos()); -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC d->previousPressedIndex = d->pressedIndex; #endif if (d->validIndex(d->pressedIndex)) { @@ -1885,7 +1885,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event) update(); } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC } else if (!d->documentMode && event->buttons() == Qt::LeftButton && d->previousPressedIndex != -1) { int newPressedIndex = d->indexAtPos(event->pos()); if (d->pressedIndex == -1 && d->previousPressedIndex == newPressedIndex) { @@ -1988,7 +1988,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event) event->ignore(); return; } -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC d->previousPressedIndex = -1; #endif if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) { diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h index bdc9dae07c..70cb02eb72 100644 --- a/src/widgets/widgets/qtabbar.h +++ b/src/widgets/widgets/qtabbar.h @@ -49,7 +49,6 @@ class Q_WIDGETS_EXPORT QTabBar: public QWidget { Q_OBJECT - Q_ENUMS(Shape) Q_PROPERTY(Shape shape READ shape WRITE setShape) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) Q_PROPERTY(int count READ count) @@ -72,6 +71,7 @@ public: enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast, TriangularNorth, TriangularSouth, TriangularWest, TriangularEast }; + Q_ENUM(Shape) enum ButtonPosition { LeftSide, @@ -130,8 +130,8 @@ public: int currentIndex() const; int count() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; void setDrawBase(bool drawTheBase); bool drawBase() const; @@ -183,20 +183,20 @@ protected: virtual void tabRemoved(int index); virtual void tabLayoutChange(); - bool event(QEvent *); - void resizeEvent(QResizeEvent *); - void showEvent(QShowEvent *); - void hideEvent(QHideEvent *); - void paintEvent(QPaintEvent *); - void mousePressEvent (QMouseEvent *); - void mouseMoveEvent (QMouseEvent *); - void mouseReleaseEvent (QMouseEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void mousePressEvent (QMouseEvent *) Q_DECL_OVERRIDE; + void mouseMoveEvent (QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent (QMouseEvent *) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; #endif - void keyPressEvent(QKeyEvent *); - void changeEvent(QEvent *); - void timerEvent(QTimerEvent *event); + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionTab *option, int tabIndex) const; #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index b26ad20f1a..7a36e2e92d 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -71,7 +71,7 @@ public: selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), autoHide(false), changeCurrentOnDrag(false), switchTabCurrentIndex(-1), switchTabTimerId(0), movingTab(0) -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC , previousPressedIndex(-1) #endif {} @@ -119,9 +119,9 @@ public: TabBarAnimation(Tab *t, QTabBarPrivate *_priv) : tab(t), priv(_priv) { setEasingCurve(QEasingCurve::InOutQuad); } - void updateCurrentValue(const QVariant ¤t); + void updateCurrentValue(const QVariant ¤t) Q_DECL_OVERRIDE; - void updateState(State, State newState); + void updateState(State, State newState) Q_DECL_OVERRIDE; private: //these are needed for the callbacks Tab *tab; @@ -202,7 +202,7 @@ public: int switchTabTimerId; QWidget *movingTab; -#ifdef Q_WS_MAC +#ifdef Q_DEAD_CODE_FROM_QT4_MAC int previousPressedIndex; #endif // shared by tabwidget and qtabbar @@ -250,12 +250,12 @@ class CloseButton : public QAbstractButton public: CloseButton(QWidget *parent = 0); - QSize sizeHint() const; - inline QSize minimumSizeHint() const + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE { return sizeHint(); } - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); - void paintEvent(QPaintEvent *event); + void enterEvent(QEvent *event) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; }; diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h index 5d9adc40e5..4913a2197a 100644 --- a/src/widgets/widgets/qtabwidget.h +++ b/src/widgets/widgets/qtabwidget.h @@ -49,7 +49,6 @@ class QStyleOptionTabWidgetFrame; class Q_WIDGETS_EXPORT QTabWidget : public QWidget { Q_OBJECT - Q_ENUMS(TabPosition TabShape) Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition) Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) @@ -100,6 +99,7 @@ public: int count() const; enum TabPosition { North, South, West, East }; + Q_ENUM(TabPosition) TabPosition tabPosition() const; void setTabPosition(TabPosition); @@ -110,13 +110,14 @@ public: void setMovable(bool movable); enum TabShape { Rounded, Triangular }; + Q_ENUM(TabShape) TabShape tabShape() const; void setTabShape(TabShape s); - QSize sizeHint() const; - QSize minimumSizeHint() const; - int heightForWidth(int width) const; - bool hasHeightForWidth() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; + int heightForWidth(int width) const Q_DECL_OVERRIDE; + bool hasHeightForWidth() const Q_DECL_OVERRIDE; void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner); QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const; @@ -154,13 +155,13 @@ protected: virtual void tabInserted(int index); virtual void tabRemoved(int index); - void showEvent(QShowEvent *); - void resizeEvent(QResizeEvent *); - void keyPressEvent(QKeyEvent *); - void paintEvent(QPaintEvent *); + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void setTabBar(QTabBar *); - void changeEvent(QEvent *); - bool event(QEvent *); + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + bool event(QEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionTabWidgetFrame *option) const; diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 1ef2f92804..7a02401dd1 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -129,7 +129,7 @@ public: void setSource(const QUrl &url); // re-imlemented from QTextEditPrivate - virtual QUrl resolveUrl(const QUrl &url) const; + virtual QUrl resolveUrl(const QUrl &url) const Q_DECL_OVERRIDE; inline QUrl resolveUrl(const QString &url) const { return resolveUrl(QUrl(url)); } diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h index d08590cb27..de917d0bf3 100644 --- a/src/widgets/widgets/qtextbrowser.h +++ b/src/widgets/widgets/qtextbrowser.h @@ -65,7 +65,7 @@ public: QStringList searchPaths() const; void setSearchPaths(const QStringList &paths); - virtual QVariant loadResource(int type, const QUrl &name); + virtual QVariant loadResource(int type, const QUrl &name) Q_DECL_OVERRIDE; bool isBackwardAvailable() const; bool isForwardAvailable() const; @@ -98,14 +98,14 @@ Q_SIGNALS: void anchorClicked(const QUrl &); protected: - bool event(QEvent *e); - virtual void keyPressEvent(QKeyEvent *ev); - virtual void mouseMoveEvent(QMouseEvent *ev); - virtual void mousePressEvent(QMouseEvent *ev); - virtual void mouseReleaseEvent(QMouseEvent *ev); - virtual void focusOutEvent(QFocusEvent *ev); - virtual bool focusNextPrevChild(bool next); - virtual void paintEvent(QPaintEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE; + virtual void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; + virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; + virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QTextBrowser) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 7ef864139f..b6b156ad63 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -77,19 +77,19 @@ class QTextEditControl : public QWidgetTextControl public: inline QTextEditControl(QObject *parent) : QWidgetTextControl(parent) {} - virtual QMimeData *createMimeDataFromSelection() const { + virtual QMimeData *createMimeDataFromSelection() const Q_DECL_OVERRIDE { QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); if (!ed) return QWidgetTextControl::createMimeDataFromSelection(); return ed->createMimeDataFromSelection(); } - virtual bool canInsertFromMimeData(const QMimeData *source) const { + virtual bool canInsertFromMimeData(const QMimeData *source) const Q_DECL_OVERRIDE { QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); if (!ed) return QWidgetTextControl::canInsertFromMimeData(source); return ed->canInsertFromMimeData(source); } - virtual void insertFromMimeData(const QMimeData *source) { + virtual void insertFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE { QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); if (!ed) QWidgetTextControl::insertFromMimeData(source); @@ -178,7 +178,7 @@ void QTextEditPrivate::init(const QString &html) #ifndef QT_NO_CURSOR viewport->setCursor(Qt::IBeamCursor); #endif -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN setSingleFingerPanEnabled(true); #endif } diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index dc8deea8b6..30533b7435 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -58,7 +58,6 @@ class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea Q_OBJECT Q_DECLARE_PRIVATE(QTextEdit) Q_FLAGS(AutoFormatting) - Q_ENUMS(LineWrapMode) Q_PROPERTY(AutoFormatting autoFormatting READ autoFormatting WRITE setAutoFormatting) Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus) Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle) @@ -85,6 +84,7 @@ public: FixedPixelWidth, FixedColumnWidth }; + Q_ENUM(LineWrapMode) enum AutoFormattingFlag { AutoNone = 0, @@ -203,7 +203,7 @@ public: void print(QPagedPaintDevice *printer) const; - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; public Q_SLOTS: @@ -257,43 +257,43 @@ Q_SIGNALS: void cursorPositionChanged(); protected: - virtual bool event(QEvent *e); - virtual void timerEvent(QTimerEvent *e); - virtual void keyPressEvent(QKeyEvent *e); - virtual void keyReleaseEvent(QKeyEvent *e); - virtual void resizeEvent(QResizeEvent *e); - virtual void paintEvent(QPaintEvent *e); - virtual void mousePressEvent(QMouseEvent *e); - virtual void mouseMoveEvent(QMouseEvent *e); - virtual void mouseReleaseEvent(QMouseEvent *e); - virtual void mouseDoubleClickEvent(QMouseEvent *e); - virtual bool focusNextPrevChild(bool next); + virtual bool event(QEvent *e) Q_DECL_OVERRIDE; + virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; + virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE; + virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; + virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE; + virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - virtual void contextMenuEvent(QContextMenuEvent *e); + virtual void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_DRAGANDDROP - virtual void dragEnterEvent(QDragEnterEvent *e); - virtual void dragLeaveEvent(QDragLeaveEvent *e); - virtual void dragMoveEvent(QDragMoveEvent *e); - virtual void dropEvent(QDropEvent *e); + virtual void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE; + virtual void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE; + virtual void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE; + virtual void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE; #endif - virtual void focusInEvent(QFocusEvent *e); - virtual void focusOutEvent(QFocusEvent *e); - virtual void showEvent(QShowEvent *); - virtual void changeEvent(QEvent *e); + virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE; + virtual void changeEvent(QEvent *e) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent *e); + virtual void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; #endif virtual QMimeData *createMimeDataFromSelection() const; virtual bool canInsertFromMimeData(const QMimeData *source) const; virtual void insertFromMimeData(const QMimeData *source); - virtual void inputMethodEvent(QInputMethodEvent *); + virtual void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; QTextEdit(QTextEditPrivate &dd, QWidget *parent); - virtual void scrollContentsBy(int dx, int dy); + virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE; virtual void doSetTextCursor(const QTextCursor &cursor); void zoomInF(float range); diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 77119a0d7d..3f5bbf1fc7 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -316,7 +316,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) startDrag(moving); if (!moving && !wasDragging) { -#ifdef Q_WS_WIN +#ifdef Q_DEAD_CODE_FROM_QT4_WIN grabMouseWhileInWindow(); #else q->grabMouse(); @@ -418,15 +418,6 @@ void QToolBarPrivate::plug(const QRect &r) */ /*! - \fn void QToolBar::addAction(QAction *action) - \overload - - Appends the \a action to the toolbar's list of actions. - - \sa QMenu::addAction(), QWidget::addAction() -*/ - -/*! \fn void QToolBar::actionTriggered(QAction *action) This signal is emitted when an action in this toolbar is triggered. diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 6bd1411592..57a69afb74 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -86,13 +86,7 @@ public: void clear(); -#ifdef Q_NO_USING_KEYWORD - inline void addAction(QAction *action) - { QWidget::addAction(action); } -#else using QWidget::addAction; -#endif - QAction *addAction(const QString &text); QAction *addAction(const QIcon &icon, const QString &text); QAction *addAction(const QString &text, const QObject *receiver, const char* member); @@ -135,10 +129,10 @@ Q_SIGNALS: void visibilityChanged(bool visible); protected: - void actionEvent(QActionEvent *event); - void changeEvent(QEvent *event); - void paintEvent(QPaintEvent *event); - bool event(QEvent *event); + void actionEvent(QActionEvent *event) Q_DECL_OVERRIDE; + void changeEvent(QEvent *event) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionToolBar *option) const; diff --git a/src/widgets/widgets/qtoolbarextension_p.h b/src/widgets/widgets/qtoolbarextension_p.h index 07e3301ed7..6625419d87 100644 --- a/src/widgets/widgets/qtoolbarextension_p.h +++ b/src/widgets/widgets/qtoolbarextension_p.h @@ -58,8 +58,8 @@ class Q_AUTOTEST_EXPORT QToolBarExtension : public QToolButton public: explicit QToolBarExtension(QWidget *parent); - void paintEvent(QPaintEvent *); - QSize sizeHint() const; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setOrientation(Qt::Orientation o); diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h index 47857d6802..4cedd2b37a 100644 --- a/src/widgets/widgets/qtoolbarlayout_p.h +++ b/src/widgets/widgets/qtoolbarlayout_p.h @@ -61,7 +61,7 @@ class QToolBarItem : public QWidgetItem { public: QToolBarItem(QWidget *widget); - bool isEmpty() const; + bool isEmpty() const Q_DECL_OVERRIDE; QAction *action; bool customWidget; @@ -75,22 +75,22 @@ public: QToolBarLayout(QWidget *parent = 0); ~QToolBarLayout(); - void addItem(QLayoutItem *item); - QLayoutItem *itemAt(int index) const; - QLayoutItem *takeAt(int index); - int count() const; + void addItem(QLayoutItem *item) Q_DECL_OVERRIDE; + QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE; + QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE; + int count() const Q_DECL_OVERRIDE; - bool isEmpty() const; - void invalidate(); - Qt::Orientations expandingDirections() const; + bool isEmpty() const Q_DECL_OVERRIDE; + void invalidate() Q_DECL_OVERRIDE; + Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE; - void setGeometry(const QRect &r); - QSize minimumSize() const; - QSize sizeHint() const; + void setGeometry(const QRect &r) Q_DECL_OVERRIDE; + QSize minimumSize() const Q_DECL_OVERRIDE; + QSize sizeHint() const Q_DECL_OVERRIDE; void insertAction(int index, QAction *action); int indexOf(QAction *action) const; - int indexOf(QWidget *widget) const { return QLayout::indexOf(widget); } + int indexOf(QWidget *widget) const Q_DECL_OVERRIDE { return QLayout::indexOf(widget); } bool layoutActions(const QSize &size); QSize expandedSize(const QSize &size) const; diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h index 3ac46db482..b3f862cefa 100644 --- a/src/widgets/widgets/qtoolbarseparator_p.h +++ b/src/widgets/widgets/qtoolbarseparator_p.h @@ -64,9 +64,9 @@ public: Qt::Orientation orientation() const; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void initStyleOption(QStyleOption *option) const; public Q_SLOTS: diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp index 518b975b51..53e5e9544c 100644 --- a/src/widgets/widgets/qtoolbox.cpp +++ b/src/widgets/widgets/qtoolbox.cpp @@ -65,12 +65,12 @@ public: inline void setSelected(bool b) { selected = b; update(); } inline void setIndex(int newIndex) { indexInPage = newIndex; } - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; protected: void initStyleOption(QStyleOptionToolBox *opt) const; - void paintEvent(QPaintEvent *); + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: bool selected; @@ -232,7 +232,6 @@ void QToolBoxButton::initStyleOption(QStyleOptionToolBox *option) const void QToolBoxButton::paintEvent(QPaintEvent *) { QPainter paint(this); - QString text = QAbstractButton::text(); QPainter *p = &paint; QStyleOptionToolBoxV2 opt; initStyleOption(&opt); diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h index 1ea276e8ab..40bbce7d44 100644 --- a/src/widgets/widgets/qtoolbox.h +++ b/src/widgets/widgets/qtoolbox.h @@ -89,11 +89,11 @@ Q_SIGNALS: void currentChanged(int index); protected: - bool event(QEvent *e); + bool event(QEvent *e) Q_DECL_OVERRIDE; virtual void itemInserted(int index); virtual void itemRemoved(int index); - void showEvent(QShowEvent *e); - void changeEvent(QEvent *); + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; private: diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 922ea09abd..fdd32c7486 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -48,7 +48,7 @@ class QStyleOptionToolButton; class Q_WIDGETS_EXPORT QToolButton : public QAbstractButton { Q_OBJECT - Q_ENUMS(Qt::ToolButtonStyle Qt::ArrowType ToolButtonPopupMode) + Q_ENUMS(Qt::ToolButtonStyle Qt::ArrowType) #ifndef QT_NO_MENU Q_PROPERTY(ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode) #endif @@ -62,12 +62,13 @@ public: MenuButtonPopup, InstantPopup }; + Q_ENUM(ToolButtonPopupMode) explicit QToolButton(QWidget * parent=0); ~QToolButton(); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; + QSize minimumSizeHint() const Q_DECL_OVERRIDE; Qt::ToolButtonStyle toolButtonStyle() const; @@ -98,19 +99,19 @@ Q_SIGNALS: void triggered(QAction *); protected: - bool event(QEvent *e); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - void paintEvent(QPaintEvent *); - void actionEvent(QActionEvent *); - - void enterEvent(QEvent *); - void leaveEvent(QEvent *); - void timerEvent(QTimerEvent *); - void changeEvent(QEvent *); - - bool hitButton(const QPoint &pos) const; - void nextCheckState(); + bool event(QEvent *e) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; + void actionEvent(QActionEvent *) Q_DECL_OVERRIDE; + + void enterEvent(QEvent *) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE; + void changeEvent(QEvent *) Q_DECL_OVERRIDE; + + bool hitButton(const QPoint &pos) const Q_DECL_OVERRIDE; + void nextCheckState() Q_DECL_OVERRIDE; void initStyleOption(QStyleOptionToolButton *option) const; private: diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 86a830a9f9..6747bdc2a7 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -66,7 +66,7 @@ int QWidgetLineControl::redoTextLayout() const QTextLine l = m_textLayout.createLine(); m_textLayout.endLayout(); -#if defined(Q_WS_MAC) +#if defined(Q_DEAD_CODE_FROM_QT4_MAC) if (m_threadChecks) m_textLayoutThread = QThread::currentThread(); #endif diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 49d9413fc0..382ed1c3c0 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -83,7 +83,7 @@ public: m_selstart(0), m_selend(0), m_passwordEchoEditing(false) , m_passwordEchoTimer(0) , m_passwordMaskDelay(-1) -#if defined(Q_WS_MAC) +#if defined(Q_DEAD_CODE_FROM_QT4_MAC) , m_threadChecks(false) , m_textLayoutThread(0) #endif @@ -372,14 +372,14 @@ public: QTextLayout *textLayout() const { -#if defined(Q_WS_MAC) +#if defined(Q_DEAD_CODE_FROM_QT4_MAC) if (m_threadChecks && QThread::currentThread() != m_textLayoutThread) redoTextLayout(); #endif return &m_textLayout; } -#if defined(Q_WS_MAC) +#if defined(Q_DEAD_CODE_FROM_QT4_MAC) void setThreadChecks(bool threadChecks) { m_threadChecks = threadChecks; @@ -503,7 +503,7 @@ private: } int redoTextLayout() const; -#if defined(Q_WS_MAC) +#if defined(Q_DEAD_CODE_FROM_QT4_MAC) bool m_threadChecks; mutable QThread *m_textLayoutThread; #endif @@ -532,7 +532,7 @@ Q_SIGNALS: void editFocusChange(bool); #endif protected: - virtual void timerEvent(QTimerEvent *event); + virtual void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; private Q_SLOTS: void _q_clipboardChanged(); diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index 13ec0fba7a..f4d26aadb2 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -114,7 +114,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos()))) return false; if (e->button() == Qt::LeftButton) { -#if defined(Q_WS_X11) +#if defined(Q_DEAD_CODE_FROM_QT4_X11) /* Implicit grabs do not stop the X server from changing the cursor in children, which looks *really* bad when @@ -128,7 +128,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) # else widget->grabMouse(); # endif // QT_NO_CURSOR -#endif // Q_WS_X11 +#endif // Q_DEAD_CODE_FROM_QT4_X11 buttonDown = false; emit activate(); bool me = movingEnabled; diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h index 5b165aa7be..5c9bb50bd4 100644 --- a/src/widgets/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/widgets/qwidgetresizehandler_p.h @@ -88,7 +88,7 @@ Q_SIGNALS: void activate(); protected: - bool eventFilter(QObject *o, QEvent *e); + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *e); void keyPressEvent(QKeyEvent *e); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 2e1e87be72..fe147472d1 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1312,8 +1312,10 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) else if (e == QKeySequence::Delete) { QTextCursor localCursor = cursor; localCursor.deleteChar(); - } - else if (e == QKeySequence::DeleteEndOfWord) { + } else if (e == QKeySequence::Backspace) { + QTextCursor localCursor = cursor; + localCursor.deletePreviousChar(); + }else if (e == QKeySequence::DeleteEndOfWord) { if (!cursor.hasSelection()) cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); cursor.removeSelectedText(); diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 949201e8a8..fb16e7e3c4 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -124,7 +124,7 @@ public: QRectF selectionRect(const QTextCursor &cursor) const; QRectF selectionRect() const; - QString anchorAt(const QPointF &pos) const; + virtual QString anchorAt(const QPointF &pos) const; QPointF anchorPosition(const QString &name) const; QString anchorAtCursor() const; @@ -242,9 +242,9 @@ public: bool findNextPrevAnchor(const QTextCursor& from, bool next, QTextCursor& newAnchor); protected: - virtual void timerEvent(QTimerEvent *e); + virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE; - virtual bool event(QEvent *e); + virtual bool event(QEvent *e) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(QWidgetTextControl) @@ -280,9 +280,9 @@ class QTextEditMimeData : public QMimeData public: inline QTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {} - virtual QStringList formats() const; + virtual QStringList formats() const Q_DECL_OVERRIDE; protected: - virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const; + virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const Q_DECL_OVERRIDE; private: void setup() const; |