summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/accessible/complexwidgets.cpp2
-rw-r--r--src/widgets/accessible/itemviews.cpp23
-rw-r--r--src/widgets/accessible/itemviews_p.h14
-rw-r--r--src/widgets/accessible/qaccessiblewidgetfactory_p.h4
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp3
-rw-r--r--src/widgets/dialogs/dialogs.pri1
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp157
-rw-r--r--src/widgets/dialogs/qcolordialog.h11
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h179
-rw-r--r--src/widgets/dialogs/qdialog.cpp11
-rw-r--r--src/widgets/dialogs/qdialog.h4
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp81
-rw-r--r--src/widgets/dialogs/qerrormessage.h2
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp122
-rw-r--r--src/widgets/dialogs/qfiledialog.h46
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp6
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h4
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp224
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.h10
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h10
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp11
-rw-r--r--src/widgets/dialogs/qfontdialog.h10
-rw-r--r--src/widgets/dialogs/qfontdialog_p.h7
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp1
-rw-r--r--src/widgets/dialogs/qinputdialog.h18
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp7
-rw-r--r--src/widgets/dialogs/qmessagebox.h6
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp6
-rw-r--r--src/widgets/dialogs/qprogressdialog.h5
-rw-r--r--src/widgets/dialogs/qsidebar.cpp18
-rw-r--r--src/widgets/dialogs/qwizard.cpp6
-rw-r--r--src/widgets/dialogs/qwizard.h8
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/listview.pngbin9695 -> 9695 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/modelview-combobox.pngbin5022 -> 5022 bytes
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/images/tableview.pngbin10102 -> 10102 bytes
-rw-r--r--src/widgets/doc/qtwidgets.qdocconf2
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp10
-rw-r--r--src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp2
-rw-r--r--src/widgets/doc/snippets/javastyle.cpp25
-rw-r--r--[-rwxr-xr-x]src/widgets/doc/snippets/macmainwindow.mm0
-rw-r--r--src/widgets/doc/snippets/qstyleoption/main.cpp33
-rw-r--r--src/widgets/doc/src/guibooks.qdoc2
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc2
-rw-r--r--src/widgets/doc/src/qtwidgets-examples.qdoc2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/layout.qdoc4
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/styles.qdoc10
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc52
-rw-r--r--src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc8
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp4
-rw-r--r--src/widgets/effects/qgraphicseffect.h14
-rw-r--r--src/widgets/effects/qgraphicseffect_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.h2
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.h6
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h64
-rw-r--r--src/widgets/graphicsview/qgraphicsitem_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.cpp62
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslayout.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp36
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.h2
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.h10
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.h2
-rw-r--r--src/widgets/graphicsview/qgraphicssceneindex.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.cpp5
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.h6
-rw-r--r--src/widgets/graphicsview/qgraphicstransform_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp10
-rw-r--r--src/widgets/graphicsview/qgraphicsview.h6
-rw-r--r--src/widgets/graphicsview/qgraphicsview_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp3
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.h8
-rw-r--r--src/widgets/graphicsview/qsimplex_p.cpp8
-rw-r--r--src/widgets/itemviews/itemviews.pri1
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp12
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.h4
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp26
-rw-r--r--src/widgets/itemviews/qabstractitemview.h6
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h2
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp12
-rw-r--r--src/widgets/itemviews/qcolumnview.h4
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.cpp2
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.h2
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp1
-rw-r--r--src/widgets/itemviews/qdirmodel.h6
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp1
-rw-r--r--src/widgets/itemviews/qheaderview.cpp8
-rw-r--r--src/widgets/itemviews/qheaderview.h4
-rw-r--r--src/widgets/itemviews/qheaderview_p.h1
-rw-r--r--src/widgets/itemviews/qitemdelegate.h2
-rw-r--r--src/widgets/itemviews/qlistview.cpp31
-rw-r--r--src/widgets/itemviews/qlistview.h7
-rw-r--r--src/widgets/itemviews/qlistview_p.h4
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp24
-rw-r--r--src/widgets/itemviews/qlistwidget.h10
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.h2
-rw-r--r--src/widgets/itemviews/qtableview.cpp31
-rw-r--r--src/widgets/itemviews/qtableview.h2
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp39
-rw-r--r--src/widgets/itemviews/qtablewidget.h6
-rw-r--r--src/widgets/itemviews/qtreeview.h4
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp20
-rw-r--r--src/widgets/itemviews/qtreewidget.h6
-rw-r--r--src/widgets/itemviews/qwidgetitemdata_p.h1
-rw-r--r--src/widgets/kernel/qaction.cpp11
-rw-r--r--src/widgets/kernel/qaction.h2
-rw-r--r--src/widgets/kernel/qapplication.cpp50
-rw-r--r--src/widgets/kernel/qapplication.h4
-rw-r--r--src/widgets/kernel/qapplication_p.h2
-rw-r--r--src/widgets/kernel/qboxlayout.h6
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp81
-rw-r--r--src/widgets/kernel/qdesktopwidget.h5
-rw-r--r--src/widgets/kernel/qdesktopwidget.qdoc14
-rw-r--r--src/widgets/kernel/qformlayout.h2
-rw-r--r--src/widgets/kernel/qgesture.h12
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp15
-rw-r--r--src/widgets/kernel/qgridlayout.h10
-rw-r--r--src/widgets/kernel/qlayout.cpp3
-rw-r--r--src/widgets/kernel/qlayoutitem.h2
-rw-r--r--src/widgets/kernel/qmacgesturerecognizer.cpp1
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp95
-rw-r--r--src/widgets/kernel/qopenglwidget.h2
-rw-r--r--src/widgets/kernel/qshortcut.h2
-rw-r--r--src/widgets/kernel/qsizepolicy.cpp9
-rw-r--r--src/widgets/kernel/qsizepolicy.h6
-rw-r--r--src/widgets/kernel/qtooltip.cpp1
-rw-r--r--src/widgets/kernel/qtooltip.h2
-rw-r--r--src/widgets/kernel/qwhatsthis.cpp3
-rw-r--r--src/widgets/kernel/qwhatsthis.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp192
-rw-r--r--src/widgets/kernel/qwidget.h17
-rw-r--r--src/widgets/kernel/qwidget_p.h12
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp283
-rw-r--r--src/widgets/kernel/qwidgetbackingstore_p.h7
-rw-r--r--src/widgets/kernel/qwidgetsvariant.cpp2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp24
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp9
-rw-r--r--src/widgets/statemachine/qkeyeventtransition.cpp2
-rw-r--r--src/widgets/statemachine/qkeyeventtransition.h4
-rw-r--r--src/widgets/statemachine/qmouseeventtransition.h4
-rw-r--r--src/widgets/styles/qandroidstyle.cpp19
-rw-r--r--src/widgets/styles/qcommonstyle.cpp141
-rw-r--r--src/widgets/styles/qcommonstyle.h32
-rw-r--r--src/widgets/styles/qcommonstyle_p.h2
-rw-r--r--src/widgets/styles/qdrawutil.h22
-rw-r--r--src/widgets/styles/qfusionstyle.cpp9
-rw-r--r--src/widgets/styles/qgtk2painter.cpp2
-rw-r--r--src/widgets/styles/qgtkstyle.cpp2
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp4
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm159
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h4
-rw-r--r--src/widgets/styles/qproxystyle.h20
-rw-r--r--src/widgets/styles/qstyle.h34
-rw-r--r--src/widgets/styles/qstylepainter.h2
-rw-r--r--src/widgets/styles/qstyleplugin.h2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp82
-rw-r--r--src/widgets/styles/qwindowscestyle.cpp6
-rw-r--r--src/widgets/styles/qwindowsmobilestyle.cpp18
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp30
-rw-r--r--src/widgets/styles/qwindowsstyle_p_p.h3
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp22
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp30
-rw-r--r--src/widgets/util/qcompleter.cpp31
-rw-r--r--src/widgets/util/qcompleter.h6
-rw-r--r--src/widgets/util/qflickgesture.cpp22
-rw-r--r--src/widgets/util/qscroller.cpp12
-rw-r--r--src/widgets/util/qscroller_mac.mm3
-rw-r--r--src/widgets/util/qscroller_p.h3
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp8
-rw-r--r--src/widgets/util/qsystemtrayicon.h4
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp2
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp35
-rw-r--r--src/widgets/util/qundogroup.h2
-rw-r--r--src/widgets/util/qundostack.h6
-rw-r--r--src/widgets/util/qundoview.h6
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp21
-rw-r--r--src/widgets/widgets/qabstractbutton.h4
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp6
-rw-r--r--src/widgets/widgets/qabstractscrollarea.h4
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h3
-rw-r--r--src/widgets/widgets/qabstractslider.h4
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp11
-rw-r--r--src/widgets/widgets/qabstractspinbox.h4
-rw-r--r--src/widgets/widgets/qbuttongroup.h2
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp5
-rw-r--r--src/widgets/widgets/qcalendarwidget.h2
-rw-r--r--src/widgets/widgets/qcheckbox.h4
-rw-r--r--src/widgets/widgets/qcombobox.cpp22
-rw-r--r--src/widgets/widgets/qcombobox.h2
-rw-r--r--src/widgets/widgets/qcombobox_p.h1
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.h6
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp6
-rw-r--r--src/widgets/widgets/qdatetimeedit.h18
-rw-r--r--src/widgets/widgets/qdatetimeedit_p.h3
-rw-r--r--src/widgets/widgets/qdial.h2
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp2
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.h8
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp161
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h8
-rw-r--r--src/widgets/widgets/qdockwidget.cpp179
-rw-r--r--src/widgets/widgets/qdockwidget.h5
-rw-r--r--src/widgets/widgets/qdockwidget_p.h3
-rw-r--r--src/widgets/widgets/qeffects.cpp2
-rw-r--r--src/widgets/widgets/qfocusframe.cpp4
-rw-r--r--src/widgets/widgets/qfocusframe.h2
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp8
-rw-r--r--src/widgets/widgets/qfontcombobox.h2
-rw-r--r--src/widgets/widgets/qframe.cpp6
-rw-r--r--src/widgets/widgets/qframe.h4
-rw-r--r--src/widgets/widgets/qframe_p.h4
-rw-r--r--src/widgets/widgets/qgroupbox.h4
-rw-r--r--src/widgets/widgets/qkeysequenceedit.h4
-rw-r--r--src/widgets/widgets/qlabel.cpp83
-rw-r--r--src/widgets/widgets/qlabel.h4
-rw-r--r--src/widgets/widgets/qlabel_p.h74
-rw-r--r--src/widgets/widgets/qlcdnumber.h4
-rw-r--r--src/widgets/widgets/qlineedit.cpp20
-rw-r--r--src/widgets/widgets/qlineedit.h4
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp8
-rw-r--r--src/widgets/widgets/qlineedit_p.h4
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.h2
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.h2
-rw-r--r--src/widgets/widgets/qmainwindow.cpp54
-rw-r--r--src/widgets/widgets/qmainwindow.h8
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp675
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h46
-rw-r--r--src/widgets/widgets/qmdiarea.h4
-rw-r--r--src/widgets/widgets/qmdiarea_p.h4
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp9
-rw-r--r--src/widgets/widgets/qmdisubwindow.h2
-rw-r--r--src/widgets/widgets/qmenu.cpp177
-rw-r--r--src/widgets/widgets/qmenu.h80
-rw-r--r--src/widgets/widgets/qmenu_mac.mm1
-rw-r--r--src/widgets/widgets/qmenu_p.h14
-rw-r--r--src/widgets/widgets/qmenubar.cpp18
-rw-r--r--src/widgets/widgets/qmenubar.h2
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp2
-rw-r--r--src/widgets/widgets/qplaintextedit.h8
-rw-r--r--src/widgets/widgets/qprogressbar.cpp22
-rw-r--r--src/widgets/widgets/qprogressbar.h2
-rw-r--r--src/widgets/widgets/qpushbutton.h8
-rw-r--r--src/widgets/widgets/qradiobutton.h4
-rw-r--r--src/widgets/widgets/qrubberband.h2
-rw-r--r--src/widgets/widgets/qscrollarea.h4
-rw-r--r--src/widgets/widgets/qscrollbar.h4
-rw-r--r--src/widgets/widgets/qslider.h4
-rw-r--r--src/widgets/widgets/qspinbox.h4
-rw-r--r--src/widgets/widgets/qsplashscreen.h4
-rw-r--r--src/widgets/widgets/qsplitter.cpp13
-rw-r--r--src/widgets/widgets/qsplitter.h4
-rw-r--r--src/widgets/widgets/qsplitter_p.h1
-rw-r--r--src/widgets/widgets/qstackedwidget.h2
-rw-r--r--src/widgets/widgets/qstatusbar.h2
-rw-r--r--src/widgets/widgets/qtabbar.cpp39
-rw-r--r--src/widgets/widgets/qtabbar.h2
-rw-r--r--src/widgets/widgets/qtabbar_p.h2
-rw-r--r--src/widgets/widgets/qtabwidget.cpp26
-rw-r--r--src/widgets/widgets/qtabwidget.h2
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp1
-rw-r--r--src/widgets/widgets/qtextbrowser.h2
-rw-r--r--src/widgets/widgets/qtextedit.h8
-rw-r--r--src/widgets/widgets/qtoolbar.cpp76
-rw-r--r--src/widgets/widgets/qtoolbar.h50
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp2
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp2
-rw-r--r--src/widgets/widgets/qtoolbox.cpp40
-rw-r--r--src/widgets/widgets/qtoolbox.h2
-rw-r--r--src/widgets/widgets/qtoolbutton.h2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp7
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp21
276 files changed, 3584 insertions, 2047 deletions
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp
index 6e985c86e8..ba87fead3c 100644
--- a/src/widgets/accessible/complexwidgets.cpp
+++ b/src/widgets/accessible/complexwidgets.cpp
@@ -172,7 +172,7 @@ QAccessibleTabBar::QAccessibleTabBar(QWidget *w)
QAccessibleTabBar::~QAccessibleTabBar()
{
- foreach (QAccessible::Id id, m_childInterfaces.values())
+ foreach (QAccessible::Id id, m_childInterfaces)
QAccessible::deleteAccessibleInterface(id);
}
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index 6534d51a45..1b724c9a17 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -94,7 +94,7 @@ bool QAccessibleTable::isValid() const
QAccessibleTable::~QAccessibleTable()
{
- Q_FOREACH (QAccessible::Id id, childToId.values())
+ Q_FOREACH (QAccessible::Id id, childToId)
QAccessible::deleteAccessibleInterface(id);
}
@@ -198,7 +198,9 @@ QList<QAccessibleInterface *> QAccessibleTable::selectedCells() const
QList<QAccessibleInterface*> cells;
if (!view()->selectionModel())
return cells;
- Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedIndexes())
+ const QModelIndexList selectedIndexes = view()->selectionModel()->selectedIndexes();
+ cells.reserve(selectedIndexes.size());
+ Q_FOREACH (const QModelIndex &index, selectedIndexes)
cells.append(child(logicalIndex(index)));
return cells;
}
@@ -208,9 +210,11 @@ QList<int> QAccessibleTable::selectedColumns() const
if (!view()->selectionModel())
return QList<int>();
QList<int> columns;
- Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedColumns()) {
+ const QModelIndexList selectedColumns = view()->selectionModel()->selectedColumns();
+ columns.reserve(selectedColumns.size());
+ Q_FOREACH (const QModelIndex &index, selectedColumns)
columns.append(index.column());
- }
+
return columns;
}
@@ -219,9 +223,11 @@ QList<int> QAccessibleTable::selectedRows() const
if (!view()->selectionModel())
return QList<int>();
QList<int> rows;
- Q_FOREACH (const QModelIndex &index, view()->selectionModel()->selectedRows()) {
+ const QModelIndexList selectedRows = view()->selectionModel()->selectedRows();
+ rows.reserve(selectedRows.size());
+ Q_FOREACH (const QModelIndex &index, selectedRows)
rows.append(index.row());
- }
+
return rows;
}
@@ -526,7 +532,7 @@ void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event)
switch (event->modelChangeType()) {
case QAccessibleTableModelChangeEvent::ModelReset:
- Q_FOREACH (QAccessible::Id id, childToId.values())
+ Q_FOREACH (QAccessible::Id id, childToId)
QAccessible::deleteAccessibleInterface(id);
childToId.clear();
break;
@@ -1010,6 +1016,9 @@ QAccessible::Role QAccessibleTableCell::role() const
QAccessible::State QAccessibleTableCell::state() const
{
QAccessible::State st;
+ if (!view)
+ return st;
+
QRect globalRect = view->rect();
globalRect.translate(view->mapToGlobal(QPoint(0,0)));
if (!globalRect.intersects(rect()))
diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h
index a1b6a6db9f..6a18a1231b 100644
--- a/src/widgets/accessible/itemviews_p.h
+++ b/src/widgets/accessible/itemviews_p.h
@@ -172,13 +172,13 @@ public:
QAccessibleTableCell(QAbstractItemView *view, const QModelIndex &m_index, QAccessible::Role role);
void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
- QObject *object() const Q_DECL_OVERRIDE { return 0; }
+ QObject *object() const Q_DECL_OVERRIDE { return Q_NULLPTR; }
QAccessible::Role role() const Q_DECL_OVERRIDE;
QAccessible::State state() const Q_DECL_OVERRIDE;
QRect rect() const Q_DECL_OVERRIDE;
bool isValid() const Q_DECL_OVERRIDE;
- QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return 0; }
+ QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return Q_NULLPTR; }
int childCount() const Q_DECL_OVERRIDE { return 0; }
int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; }
@@ -224,13 +224,13 @@ public:
// For header cells, pass the header view in addition
QAccessibleTableHeaderCell(QAbstractItemView *view, int index, Qt::Orientation orientation);
- QObject *object() const Q_DECL_OVERRIDE { return 0; }
+ QObject *object() const Q_DECL_OVERRIDE { return Q_NULLPTR; }
QAccessible::Role role() const Q_DECL_OVERRIDE;
QAccessible::State state() const Q_DECL_OVERRIDE;
QRect rect() const Q_DECL_OVERRIDE;
bool isValid() const Q_DECL_OVERRIDE;
- QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return 0; }
+ QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return Q_NULLPTR; }
int childCount() const Q_DECL_OVERRIDE { return 0; }
int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; }
@@ -261,13 +261,13 @@ public:
:view(view_)
{}
- QObject *object() const Q_DECL_OVERRIDE { return 0; }
+ QObject *object() const Q_DECL_OVERRIDE { return Q_NULLPTR; }
QAccessible::Role role() const Q_DECL_OVERRIDE { return QAccessible::Pane; }
QAccessible::State state() const Q_DECL_OVERRIDE { return QAccessible::State(); }
QRect rect() const Q_DECL_OVERRIDE { return QRect(); }
bool isValid() const Q_DECL_OVERRIDE { return true; }
- QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return 0; }
+ QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return Q_NULLPTR; }
int childCount() const Q_DECL_OVERRIDE { return 0; }
int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; }
@@ -278,7 +278,7 @@ public:
return QAccessible::queryAccessibleInterface(view);
}
QAccessibleInterface *child(int) const Q_DECL_OVERRIDE {
- return 0;
+ return Q_NULLPTR;
}
private:
diff --git a/src/widgets/accessible/qaccessiblewidgetfactory_p.h b/src/widgets/accessible/qaccessiblewidgetfactory_p.h
index caa37dcf81..d94f2d1cb2 100644
--- a/src/widgets/accessible/qaccessiblewidgetfactory_p.h
+++ b/src/widgets/accessible/qaccessiblewidgetfactory_p.h
@@ -40,8 +40,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index 604c754ea1..adf908b821 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -826,6 +826,9 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
attrs["text-underline-type"] = QStringLiteral("single"); // if underlineStyleValue is set, there is an underline, and Qt does not support other than single ones
} // else both are "none" which is the default - no need to set them
+ if (block.textDirection() == Qt::RightToLeft)
+ attrs["writing-mode"] = QStringLiteral("rl");
+
QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment();
attrs["text-position"] = QString::fromLatin1((alignment == QTextCharFormat::AlignSubScript) ? "sub" : ((alignment == QTextCharFormat::AlignSuperScript) ? "super" : "baseline" ));
diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri
index a5b4883db8..4f4a9b1517 100644
--- a/src/widgets/dialogs/dialogs.pri
+++ b/src/widgets/dialogs/dialogs.pri
@@ -2,7 +2,6 @@
HEADERS += \
dialogs/qcolordialog.h \
- dialogs/qcolordialog_p.h \
dialogs/qfscompleter_p.h \
dialogs/qdialog.h \
dialogs/qdialog_p.h \
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 5f3161f39f..468bffe49e 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#include "qcolordialog_p.h"
+#include "qcolordialog.h"
#ifndef QT_NO_COLORDIALOG
@@ -49,6 +49,7 @@
#include "qpixmap.h"
#include "qpushbutton.h"
#include "qsettings.h"
+#include "qsharedpointer.h"
#include "qstyle.h"
#include "qstyleoption.h"
#include "qvalidator.h"
@@ -58,13 +59,115 @@
#include "qscreen.h"
#include "qcursor.h"
#include "qtimer.h"
+#include "qwindow.h"
+
+#include "private/qdialog_p.h"
#include <algorithm>
QT_BEGIN_NAMESPACE
+namespace {
+class QColorLuminancePicker;
+class QColorPicker;
+class QColorShower;
+class QWellArray;
+class QColorPickingEventFilter;
+} // unnamed namespace
+
+class QColorDialogPrivate : public QDialogPrivate
+{
+ Q_DECLARE_PUBLIC(QColorDialog)
+
+public:
+ enum SetColorMode {
+ ShowColor = 0x1,
+ SelectColor = 0x2,
+ SetColorAll = ShowColor | SelectColor
+ };
+
+ QColorDialogPrivate() : options(new QColorDialogOptions)
+#ifdef Q_OS_WIN32
+ , updateTimer(0)
+#endif
+ {}
+
+ QPlatformColorDialogHelper *platformColorDialogHelper() const
+ { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); }
+
+ void init(const QColor &initial);
+ void initWidgets();
+ QRgb currentColor() const;
+ QColor currentQColor() const;
+ void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll);
+ void setCurrentRgbColor(QRgb rgb);
+ void setCurrentQColor(const QColor &color);
+ bool selectColor(const QColor &color);
+ QColor grabScreenColor(const QPoint &p);
+
+ int currentAlpha() const;
+ void setCurrentAlpha(int a);
+ void showAlpha(bool b);
+ bool isAlphaVisible() const;
+ void retranslateStrings();
+
+ void _q_addCustom();
+
+ void _q_newHsv(int h, int s, int v);
+ void _q_newColorTypedIn(QRgb rgb);
+ void _q_nextCustom(int, int);
+ void _q_newCustom(int, int);
+ void _q_newStandard(int, int);
+ void _q_pickScreenColor();
+ void _q_updateColorPicking();
+ void updateColorLabelText(const QPoint &);
+ void updateColorPicking(const QPoint &pos);
+ void releaseColorPicking();
+ bool handleColorPickingMouseMove(QMouseEvent *e);
+ bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
+ bool handleColorPickingKeyPress(QKeyEvent *e);
+
+ bool canBeNativeDialog() const Q_DECL_OVERRIDE;
+
+ QWellArray *custom;
+ QWellArray *standard;
+
+ QDialogButtonBox *buttons;
+ QVBoxLayout *leftLay;
+ QColorPicker *cp;
+ QColorLuminancePicker *lp;
+ QColorShower *cs;
+ QLabel *lblBasicColors;
+ QLabel *lblCustomColors;
+ QLabel *lblScreenColorInfo;
+ QPushButton *ok;
+ QPushButton *cancel;
+ QPushButton *addCusBt;
+ QPushButton *screenColorPickerButton;
+ QColor selectedQColor;
+ int nextCust;
+ bool smallDisplay;
+ bool screenColorPicking;
+ QColorPickingEventFilter *colorPickingEventFilter;
+ QRgb beforeScreenColorPicking;
+ QSharedPointer<QColorDialogOptions> options;
+
+ QPointer<QObject> receiverToDisconnectOnClose;
+ QByteArray memberToDisconnectOnClose;
+#ifdef Q_OS_WIN32
+ QTimer *updateTimer;
+ QWindow dummyTransparentWindow;
+#endif
+
+private:
+ virtual void initHelper(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
+ virtual void helperPrepareShow(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
+};
+
//////////// QWellArray BEGIN
+namespace {
+
struct QWellArrayData;
class QWellArray : public QWidget
@@ -446,6 +549,8 @@ private:
QColorDialogPrivate *m_dp;
};
+} // unnamed namespace
+
/*!
Returns the number of custom colors supported by QColorDialog. All
color dialogs share the same custom colors.
@@ -506,6 +611,8 @@ static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v)
c.getHsv(&h, &s, &v);
}
+namespace {
+
class QColorWell : public QWellArray
{
public:
@@ -975,8 +1082,8 @@ private:
QColorDialog *colorDialog;
QGridLayout *gl;
- friend class QColorDialog;
- friend class QColorDialogPrivate;
+ friend class QT_PREPEND_NAMESPACE(QColorDialog);
+ friend class QT_PREPEND_NAMESPACE(QColorDialogPrivate);
};
class QColorShowLabel : public QFrame
@@ -1265,6 +1372,8 @@ QColorShower::QColorShower(QColorDialog *parent)
retranslateStrings();
}
+} // unnamed namespace
+
inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); }
inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); }
inline void QColorDialogPrivate::setCurrentAlpha(int a) { cs->setCurrentAlpha(a); }
@@ -1605,9 +1714,6 @@ void QColorDialogPrivate::init(const QColor &initial)
if (!nativeDialogInUse)
initWidgets();
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
- delegate = 0;
-#endif
#ifdef Q_OS_WIN32
dummyTransparentWindow.resize(1, 1);
dummyTransparentWindow.setFlags(Qt::Tool | Qt::FramelessWindowHint);
@@ -2009,11 +2115,6 @@ QColorDialog::ColorDialogOptions QColorDialog::options() const
\sa color, colorSelected()
*/
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
-// can only have one Cocoa color panel active
-bool QColorDialogPrivate::sharedColorPanelAvailable = true;
-#endif
-
/*!
\fn void QColorDialog::colorSelected(const QColor &color);
@@ -2040,23 +2141,6 @@ void QColorDialog::setVisible(bool visible)
if (visible)
d->selectedQColor = QColor();
-#if defined(Q_DEAD_CODE_FROM_QT4_MAC)
- if (visible) {
- if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable &&
- !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){
- d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options());
- QColorDialogPrivate::sharedColorPanelAvailable = false;
- setAttribute(Qt::WA_DontShowOnScreen);
- }
- setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
- } else {
- if (d->delegate) {
- d->closeCocoaColorPanel();
- setAttribute(Qt::WA_DontShowOnScreen, false);
- }
- }
-#else
-
if (d->nativeDialogInUse) {
d->setNativeDialogVisible(visible);
// Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
@@ -2065,7 +2149,6 @@ void QColorDialog::setVisible(bool visible)
} else {
setAttribute(Qt::WA_DontShowOnScreen, false);
}
-#endif
QDialog::setVisible(visible);
}
@@ -2141,13 +2224,7 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
QColorDialog::~QColorDialog()
{
-#if defined(Q_DEAD_CODE_FROM_QT4_MAC)
- Q_D(QColorDialog);
- if (d->delegate) {
- d->releaseCocoaColorPanelDelegate();
- QColorDialogPrivate::sharedColorPanelAvailable = true;
- }
-#endif
+
}
/*!
@@ -2209,16 +2286,12 @@ bool QColorDialogPrivate::handleColorPickingMouseButtonRelease(QMouseEvent *e)
bool QColorDialogPrivate::handleColorPickingKeyPress(QKeyEvent *e)
{
Q_Q(QColorDialog);
- switch (e->key()) {
- case Qt::Key_Escape:
+ if (e->matches(QKeySequence::Cancel)) {
releaseColorPicking();
q->setCurrentColor(beforeScreenColorPicking);
- break;
- case Qt::Key_Return:
- case Qt::Key_Enter:
+ } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
q->setCurrentColor(grabScreenColor(QCursor::pos()));
releaseColorPicking();
- break;
}
e->accept();
return true;
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
index 16339f56c4..de18e6f9ed 100644
--- a/src/widgets/dialogs/qcolordialog.h
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -61,8 +61,8 @@ public:
Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
- explicit QColorDialog(QWidget *parent = 0);
- explicit QColorDialog(const QColor &initial, QWidget *parent = 0);
+ explicit QColorDialog(QWidget *parent = Q_NULLPTR);
+ explicit QColorDialog(const QColor &initial, QWidget *parent = Q_NULLPTR);
~QColorDialog();
void setCurrentColor(const QColor &color);
@@ -81,12 +81,12 @@ public:
void setVisible(bool visible) Q_DECL_OVERRIDE;
static QColor getColor(const QColor &initial = Qt::white,
- QWidget *parent = 0,
+ QWidget *parent = Q_NULLPTR,
const QString &title = QString(),
- ColorDialogOptions options = 0);
+ ColorDialogOptions options = ColorDialogOptions());
// obsolete
- static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = 0, QWidget *parent = 0);
+ static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = Q_NULLPTR, QWidget *parent = Q_NULLPTR);
static int customCount();
static QColor customColor(int index);
@@ -113,7 +113,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor())
Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking())
- friend class QColorShower;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h
deleted file mode 100644
index 1a881eae70..0000000000
--- a/src/widgets/dialogs/qcolordialog_p.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOLORDIALOG_P_H
-#define QCOLORDIALOG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// to version without notice, or even be removed.
-//
-// We mean it.
-//
-//
-
-#include "private/qdialog_p.h"
-#include "qcolordialog.h"
-#include "qsharedpointer.h"
-#include "qwindow.h"
-
-#ifndef QT_NO_COLORDIALOG
-
-QT_BEGIN_NAMESPACE
-
-class QColorLuminancePicker;
-class QColorPicker;
-class QColorShower;
-class QDialogButtonBox;
-class QLabel;
-class QVBoxLayout;
-class QPushButton;
-class QWellArray;
-class QColorPickingEventFilter;
-class QTimer;
-
-class QColorDialogPrivate : public QDialogPrivate
-{
- Q_DECLARE_PUBLIC(QColorDialog)
-
-public:
- enum SetColorMode {
- ShowColor = 0x1,
- SelectColor = 0x2,
- SetColorAll = ShowColor | SelectColor
- };
-
- QColorDialogPrivate() : options(new QColorDialogOptions)
-#ifdef Q_OS_WIN32
- , updateTimer(0)
-#endif
- {}
-
- QPlatformColorDialogHelper *platformColorDialogHelper() const
- { return static_cast<QPlatformColorDialogHelper *>(platformHelper()); }
-
- void init(const QColor &initial);
- void initWidgets();
- QRgb currentColor() const;
- QColor currentQColor() const;
- void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll);
- void setCurrentRgbColor(QRgb rgb);
- void setCurrentQColor(const QColor &color);
- bool selectColor(const QColor &color);
- QColor grabScreenColor(const QPoint &p);
-
- int currentAlpha() const;
- void setCurrentAlpha(int a);
- void showAlpha(bool b);
- bool isAlphaVisible() const;
- void retranslateStrings();
-
- void _q_addCustom();
-
- void _q_newHsv(int h, int s, int v);
- void _q_newColorTypedIn(QRgb rgb);
- void _q_nextCustom(int, int);
- void _q_newCustom(int, int);
- void _q_newStandard(int, int);
- void _q_pickScreenColor();
- void _q_updateColorPicking();
- void updateColorLabelText(const QPoint &);
- void updateColorPicking(const QPoint &pos);
- void releaseColorPicking();
- bool handleColorPickingMouseMove(QMouseEvent *e);
- bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
- bool handleColorPickingKeyPress(QKeyEvent *e);
-
- bool canBeNativeDialog() const Q_DECL_OVERRIDE;
-
- QWellArray *custom;
- QWellArray *standard;
-
- QDialogButtonBox *buttons;
- QVBoxLayout *leftLay;
- QColorPicker *cp;
- QColorLuminancePicker *lp;
- QColorShower *cs;
- QLabel *lblBasicColors;
- QLabel *lblCustomColors;
- QLabel *lblScreenColorInfo;
- QPushButton *ok;
- QPushButton *cancel;
- QPushButton *addCusBt;
- QPushButton *screenColorPickerButton;
- QColor selectedQColor;
- int nextCust;
- bool smallDisplay;
- bool screenColorPicking;
- QColorPickingEventFilter *colorPickingEventFilter;
- QRgb beforeScreenColorPicking;
- QSharedPointer<QColorDialogOptions> options;
-
- QPointer<QObject> receiverToDisconnectOnClose;
- QByteArray memberToDisconnectOnClose;
-#ifdef Q_OS_WIN32
- QTimer *updateTimer;
- QWindow dummyTransparentWindow;
-#endif
-
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
- void openCocoaColorPanel(const QColor &initial,
- QWidget *parent, const QString &title, QColorDialog::ColorDialogOptions options);
- void closeCocoaColorPanel();
- void releaseCocoaColorPanelDelegate();
- void setCocoaPanelColor(const QColor &color);
-
- inline void done(int result) { q_func()->done(result); }
- inline QColorDialog *colorDialog() { return q_func(); }
-
- void *delegate;
-
- static bool sharedColorPanelAvailable;
-
- void _q_macRunNativeAppModalPanel();
- void mac_nativeDialogModalHelp();
-#endif
-private:
- virtual void initHelper(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
- virtual void helperPrepareShow(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
-};
-
-#endif // QT_NO_COLORDIALOG
-
-QT_END_NAMESPACE
-
-#endif // QCOLORDIALOG_P_H
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 054c220b84..5124960ab4 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -243,7 +243,7 @@ void QDialogPrivate::deletePlatformHelper()
\section1 Escape Key
If the user presses the Esc key in a dialog, QDialog::reject()
- will be called. This will cause the window to close: The \l{QCloseEvent}{close event} cannot be \l{QCloseEvent::ignore()}{ignored}.
+ will be called. This will cause the window to close: The \l{QCloseEvent}{close event} cannot be \l{QEvent::ignore()}{ignored}.
\section1 Extensibility
@@ -565,7 +565,7 @@ int QDialog::exec()
last window closed, the QApplication::lastWindowClosed() signal is
emitted.
- \sa accept(), reject(), QApplication::activeWindow(), QApplication::quit()
+ \sa accept(), reject(), QApplication::activeWindow(), QCoreApplication::quit()
*/
void QDialog::done(int r)
@@ -651,11 +651,9 @@ void QDialog::keyPressEvent(QKeyEvent *e)
// Calls reject() if Escape is pressed. Simulates a button
// click for the default button if Enter is pressed. Move focus
// for the arrow keys. Ignore the rest.
-#ifdef Q_OS_MAC
- if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) {
+ if (e->matches(QKeySequence::Cancel)) {
reject();
} else
-#endif
if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
switch (e->key()) {
case Qt::Key_Enter:
@@ -671,9 +669,6 @@ void QDialog::keyPressEvent(QKeyEvent *e)
}
}
break;
- case Qt::Key_Escape:
- reject();
- break;
default:
e->ignore();
return;
diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h
index cd53378f9a..5ea5375387 100644
--- a/src/widgets/dialogs/qdialog.h
+++ b/src/widgets/dialogs/qdialog.h
@@ -51,7 +51,7 @@ class Q_WIDGETS_EXPORT QDialog : public QWidget
Q_PROPERTY(bool modal READ isModal WRITE setModal)
public:
- explicit QDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
+ explicit QDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
~QDialog();
enum DialogCode { Rejected, Accepted };
@@ -90,7 +90,7 @@ public Q_SLOTS:
void showExtension(bool);
protected:
- QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = 0);
+ QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
#if defined(Q_OS_WINCE)
bool event(QEvent *e);
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 4c3a5497d4..855bae3c9f 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -47,9 +47,10 @@
#include "qpixmap.h"
#include "qmetaobject.h"
#include "qthread.h"
-#include "qqueue.h"
#include "qset.h"
+#include <queue>
+
#include <stdio.h>
#include <stdlib.h>
@@ -68,16 +69,18 @@ public:
QCheckBox * again;
QTextEdit * errors;
QLabel * icon;
- QQueue<QPair<QString, QString> > pending;
+ std::queue<QPair<QString, QString> > pending;
QSet<QString> doNotShow;
QSet<QString> doNotShowType;
QString currentMessage;
QString currentType;
+ bool isMessageToBeShown(const QString &message, const QString &type) const;
bool nextPending();
void retranslateStrings();
};
+namespace {
class QErrorMessageTextView : public QTextEdit
{
public:
@@ -87,6 +90,7 @@ public:
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
};
+} // unnamed namespace
QSize QErrorMessageTextView::minimumSizeHint() const
{
@@ -217,29 +221,32 @@ QErrorMessage::QErrorMessage(QWidget * parent)
: QDialog(*new QErrorMessagePrivate, parent)
{
Q_D(QErrorMessage);
- QGridLayout * grid = new QGridLayout(this);
+
d->icon = new QLabel(this);
-#ifndef QT_NO_MESSAGEBOX
- d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
- d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
-#endif
- grid->addWidget(d->icon, 0, 0, Qt::AlignTop);
d->errors = new QErrorMessageTextView(this);
- grid->addWidget(d->errors, 0, 1);
d->again = new QCheckBox(this);
- d->again->setChecked(true);
- grid->addWidget(d->again, 1, 1, Qt::AlignTop);
d->ok = new QPushButton(this);
+ QGridLayout * grid = new QGridLayout(this);
+
+ connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
+ grid->addWidget(d->icon, 0, 0, Qt::AlignTop);
+ grid->addWidget(d->errors, 0, 1);
+ grid->addWidget(d->again, 1, 1, Qt::AlignTop);
+ grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter);
+ grid->setColumnStretch(1, 42);
+ grid->setRowStretch(0, 42);
+#ifndef QT_NO_MESSAGEBOX
+ d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
+ d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
+#endif
+ d->again->setChecked(true);
#if defined(Q_OS_WINCE)
d->ok->setFixedSize(0,0);
#endif
- connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
d->ok->setFocus();
- grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter);
- grid->setColumnStretch(1, 42);
- grid->setRowStretch(0, 42);
+
d->retranslateStrings();
}
@@ -265,11 +272,13 @@ QErrorMessage::~QErrorMessage()
void QErrorMessage::done(int a)
{
Q_D(QErrorMessage);
- if (!d->again->isChecked() && !d->currentMessage.isEmpty() && d->currentType.isEmpty()) {
- d->doNotShow.insert(d->currentMessage);
- }
- if (!d->again->isChecked() && !d->currentType.isEmpty()) {
- d->doNotShowType.insert(d->currentType);
+ if (!d->again->isChecked()) {
+ if (d->currentType.isEmpty()) {
+ if (!d->currentMessage.isEmpty())
+ d->doNotShow.insert(d->currentMessage);
+ } else {
+ d->doNotShowType.insert(d->currentType);
+ }
}
d->currentMessage.clear();
d->currentType.clear();
@@ -301,20 +310,27 @@ QErrorMessage * QErrorMessage::qtHandler()
/*! \internal */
+bool QErrorMessagePrivate::isMessageToBeShown(const QString &message, const QString &type) const
+{
+ return !message.isEmpty()
+ && (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type));
+}
+
bool QErrorMessagePrivate::nextPending()
{
- while (!pending.isEmpty()) {
- QPair<QString,QString> pendingMessage = pending.dequeue();
- QString message = pendingMessage.first;
- QString type = pendingMessage.second;
- if (!message.isEmpty() && ((type.isEmpty() && !doNotShow.contains(message)) || (!type.isEmpty() && !doNotShowType.contains(type)))) {
+ while (!pending.empty()) {
+ QPair<QString,QString> &pendingMessage = pending.front();
+ QString message = qMove(pendingMessage.first);
+ QString type = qMove(pendingMessage.second);
+ pending.pop();
+ if (isMessageToBeShown(message, type)) {
#ifndef QT_NO_TEXTHTMLPARSER
errors->setHtml(message);
#else
errors->setPlainText(message);
#endif
- currentMessage = message;
- currentType = type;
+ currentMessage = qMove(message);
+ currentType = qMove(type);
return true;
}
}
@@ -333,12 +349,7 @@ bool QErrorMessagePrivate::nextPending()
void QErrorMessage::showMessage(const QString &message)
{
- Q_D(QErrorMessage);
- if (d->doNotShow.contains(message))
- return;
- d->pending.enqueue(qMakePair(message,QString()));
- if (!isVisible() && d->nextPending())
- show();
+ showMessage(message, QString());
}
/*!
@@ -358,9 +369,9 @@ void QErrorMessage::showMessage(const QString &message)
void QErrorMessage::showMessage(const QString &message, const QString &type)
{
Q_D(QErrorMessage);
- if (d->doNotShow.contains(message) && d->doNotShowType.contains(type))
+ if (!d->isMessageToBeShown(message, type))
return;
- d->pending.push_back(qMakePair(message,type));
+ d->pending.push(qMakePair(message, type));
if (!isVisible() && d->nextPending())
show();
}
diff --git a/src/widgets/dialogs/qerrormessage.h b/src/widgets/dialogs/qerrormessage.h
index 55d0b389b1..1d69515dfb 100644
--- a/src/widgets/dialogs/qerrormessage.h
+++ b/src/widgets/dialogs/qerrormessage.h
@@ -48,7 +48,7 @@ class Q_WIDGETS_EXPORT QErrorMessage: public QDialog
Q_OBJECT
Q_DECLARE_PRIVATE(QErrorMessage)
public:
- explicit QErrorMessage(QWidget* parent = 0);
+ explicit QErrorMessage(QWidget* parent = Q_NULLPTR);
~QErrorMessage();
static QErrorMessage * qtHandler();
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 4e0d70fb9a..06102ec1d6 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -330,14 +330,8 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir)
*/
QT_BEGIN_INCLUDE_NAMESPACE
-#ifdef Q_DEAD_CODE_FROM_QT4_WIN
-#include <qwindowsstyle_p.h>
-#endif
#include <QMetaEnum>
#include <qshortcut.h>
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
-#include <qmacstyle_mac_p.h>
-#endif
QT_END_INCLUDE_NAMESPACE
/*!
@@ -983,7 +977,7 @@ void QFileDialog::setDirectoryUrl(const QUrl &directory)
else if (directory.isLocalFile())
setDirectory(directory.toLocalFile());
else if (d->usingWidgets())
- qWarning() << "Non-native QFileDialog supports only local files";
+ qWarning("Non-native QFileDialog supports only local files");
}
/*!
@@ -1093,7 +1087,7 @@ void QFileDialog::selectUrl(const QUrl &url)
else if (url.isLocalFile())
selectFile(url.toLocalFile());
else
- qWarning() << "Non-native QFileDialog supports only local files";
+ qWarning("Non-native QFileDialog supports only local files");
}
#ifdef Q_OS_UNIX
@@ -1191,12 +1185,17 @@ QList<QUrl> QFileDialogPrivate::userSelectedFiles() const
if (!usingWidgets())
return addDefaultSuffixToUrls(selectedFiles_sys());
- foreach (const QModelIndex &index, qFileDialogUi->listView->selectionModel()->selectedRows())
+ const QModelIndexList selectedRows = qFileDialogUi->listView->selectionModel()->selectedRows();
+ files.reserve(selectedRows.size());
+ foreach (const QModelIndex &index, selectedRows)
files.append(QUrl::fromLocalFile(index.data(QFileSystemModel::FilePathRole).toString()));
- if (files.isEmpty() && !lineEdit()->text().isEmpty())
- foreach (const QString &path, typedFiles())
+ if (files.isEmpty() && !lineEdit()->text().isEmpty()) {
+ const QStringList typedFilesList = typedFiles();
+ files.reserve(typedFilesList.size());
+ foreach (const QString &path, typedFilesList)
files.append(QUrl::fromLocalFile(path));
+ }
return files;
}
@@ -1230,7 +1229,9 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files
QList<QUrl> QFileDialogPrivate::addDefaultSuffixToUrls(const QList<QUrl> &urlsToFix) const
{
QList<QUrl> urls;
- for (int i=0; i<urlsToFix.size(); ++i) {
+ const int numUrlsToFix = urlsToFix.size();
+ urls.reserve(numUrlsToFix);
+ for (int i = 0; i < numUrlsToFix; ++i) {
QUrl url = urlsToFix.at(i);
// if the filename has no suffix, add the default suffix
const QString defaultSuffix = options->defaultSuffix();
@@ -1254,7 +1255,9 @@ QStringList QFileDialog::selectedFiles() const
Q_D(const QFileDialog);
QStringList files;
- foreach (const QUrl &file, d->userSelectedFiles())
+ const QList<QUrl> userSelectedFiles = d->userSelectedFiles();
+ files.reserve(userSelectedFiles.size());
+ foreach (const QUrl &file, userSelectedFiles)
files.append(file.toLocalFile());
if (files.isEmpty() && d->usingWidgets()) {
const FileMode fm = fileMode();
@@ -1279,7 +1282,9 @@ QList<QUrl> QFileDialog::selectedUrls() const
return d->userSelectedFiles();
} else {
QList<QUrl> urls;
- foreach (const QString &file, selectedFiles())
+ const QStringList selectedFileList = selectedFiles();
+ urls.reserve(selectedFileList.size());
+ foreach (const QString &file, selectedFileList)
urls.append(QUrl::fromLocalFile(file));
return urls;
}
@@ -1358,7 +1363,9 @@ QStringList qt_strip_filters(const QStringList &filters)
{
QStringList strippedFilters;
QRegExp r(QString::fromLatin1(QPlatformFileDialogHelper::filterRegExp));
- for (int i = 0; i < filters.count(); ++i) {
+ const int numFilters = filters.count();
+ strippedFilters.reserve(numFilters);
+ for (int i = 0; i < numFilters; ++i) {
QString filterName;
int index = r.indexIn(filters[i]);
if (index >= 0)
@@ -1393,7 +1400,9 @@ void QFileDialog::setNameFilters(const QStringList &filters)
Q_D(QFileDialog);
d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));
QStringList cleanedFilters;
- for (int i = 0; i < filters.count(); ++i) {
+ const int numFilters = filters.count();
+ cleanedFilters.reserve(numFilters);
+ for (int i = 0; i < numFilters; ++i) {
cleanedFilters << filters[i].simplified();
}
d->options->setNameFilters(cleanedFilters);
@@ -1693,6 +1702,30 @@ void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode)
d->retranslateWindowTitle();
}
+/*!
+ \property QFileDialog::supportedSchemes
+ \brief the URL schemes that the file dialog should allow navigating to.
+ \since 5.6
+
+ Setting this property allows to restrict the type of URLs the
+ user will be able to select. It is a way for the application to declare
+ the protocols it will support to fetch the file content. An empty list
+ means that no restriction is applied (the default).
+ Supported for local files ("file" scheme) is implicit and always enabled;
+ it is not necessary to include it in the restriction.
+*/
+
+void QFileDialog::setSupportedSchemes(const QStringList &schemes)
+{
+ Q_D(QFileDialog);
+ d->options->setSupportedSchemes(schemes);
+}
+
+QStringList QFileDialog::supportedSchemes() const
+{
+ return d_func()->options->supportedSchemes();
+}
+
/*
Returns the file system model index that is the root index in the
views
@@ -2091,8 +2124,8 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
user will be able to select. It is a way for the application to declare
the protocols it will support to fetch the file content. An empty list
means that no restriction is applied (the default).
- Supported for local files ("file" scheme) is implicit and always enabled.
- it is not necessary to include in the restriction.
+ Supported for local files ("file" scheme) is implicit and always enabled;
+ it is not necessary to include it in the restriction.
When possible, this static function will use the native file dialog and
not a QFileDialog. On platforms which don't support selecting remote
@@ -2109,8 +2142,6 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
- Q_UNUSED(supportedSchemes); // TODO
-
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -2121,6 +2152,7 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
args.options = options;
QFileDialog dialog(args);
+ dialog.setSupportedSchemes(supportedSchemes);
if (selectedFilter && !selectedFilter->isEmpty())
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
@@ -2169,11 +2201,6 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
see the QFileDialog::Option enum for more information on the flags you can
pass.
- \note If you want to iterate over the list of files, you should iterate
- over a copy. For example:
-
- \snippet code/src_gui_dialogs_qfiledialog.cpp 10
-
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -2190,6 +2217,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
const QStringList schemes = QStringList(QStringLiteral("file"));
const QList<QUrl> selectedUrls = getOpenFileUrls(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes);
QStringList fileNames;
+ fileNames.reserve(selectedUrls.size());
foreach (const QUrl &url, selectedUrls)
fileNames << url.toLocalFile();
return fileNames;
@@ -2213,8 +2241,8 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
user will be able to select. It is a way for the application to declare
the protocols it will support to fetch the file content. An empty list
means that no restriction is applied (the default).
- Supported for local files ("file" scheme) is implicit and always enabled.
- it is not necessary to include in the restriction.
+ Supported for local files ("file" scheme) is implicit and always enabled;
+ it is not necessary to include it in the restriction.
When possible, this static function will use the native file dialog and
not a QFileDialog. On platforms which don't support selecting remote
@@ -2231,8 +2259,6 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
- Q_UNUSED(supportedSchemes);
-
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -2243,6 +2269,7 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
args.options = options;
QFileDialog dialog(args);
+ dialog.setSupportedSchemes(supportedSchemes);
if (selectedFilter && !selectedFilter->isEmpty())
dialog.selectNameFilter(*selectedFilter);
if (dialog.exec() == QDialog::Accepted) {
@@ -2332,8 +2359,8 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
user will be able to select. It is a way for the application to declare
the protocols it will support to save the file content. An empty list
means that no restriction is applied (the default).
- Supported for local files ("file" scheme) is implicit and always enabled.
- it is not necessary to include in the restriction.
+ Supported for local files ("file" scheme) is implicit and always enabled;
+ it is not necessary to include it in the restriction.
When possible, this static function will use the native file dialog and
not a QFileDialog. On platforms which don't support selecting remote
@@ -2350,8 +2377,6 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
- Q_UNUSED(supportedSchemes);
-
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -2362,6 +2387,7 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
args.options = options;
QFileDialog dialog(args);
+ dialog.setSupportedSchemes(supportedSchemes);
dialog.setAcceptMode(AcceptSave);
if (selectedFilter && !selectedFilter->isEmpty())
dialog.selectNameFilter(*selectedFilter);
@@ -2442,8 +2468,8 @@ QString QFileDialog::getExistingDirectory(QWidget *parent,
user will be able to select. It is a way for the application to declare
the protocols it will support to fetch the file content. An empty list
means that no restriction is applied (the default).
- Supported for local files ("file" scheme) is implicit and always enabled.
- it is not necessary to include in the restriction.
+ Supported for local files ("file" scheme) is implicit and always enabled;
+ it is not necessary to include it in the restriction.
When possible, this static function will use the native file dialog and
not a QFileDialog. On platforms which don't support selecting remote
@@ -2458,8 +2484,6 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
- Q_UNUSED(supportedSchemes);
-
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -2468,6 +2492,7 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent,
args.options = options;
QFileDialog dialog(args);
+ dialog.setSupportedSchemes(supportedSchemes);
if (dialog.exec() == QDialog::Accepted)
return dialog.selectedUrls().value(0);
return QUrl();
@@ -2669,7 +2694,9 @@ void QFileDialogPrivate::saveSettings()
settings.setValue(QLatin1String("treeViewHeader"), qFileDialogUi->treeView->header()->saveState());
}
QStringList historyUrls;
- foreach (const QString &path, q->history())
+ const QStringList history = q->history();
+ historyUrls.reserve(history.size());
+ foreach (const QString &path, history)
historyUrls << QUrl::fromLocalFile(path).toString();
settings.setValue(QLatin1String("history"), historyUrls);
settings.setValue(QLatin1String("lastVisited"), lastVisitedDir()->toString());
@@ -2795,7 +2822,9 @@ void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter,
qFileDialogUi->sidebar->hide();
#endif
- q->resize(q->sizeHint());
+ const QSize sizeHint = q->sizeHint();
+ if (sizeHint.isValid())
+ q->resize(sizeHint);
}
/*!
@@ -2971,7 +3000,7 @@ void QFileDialogPrivate::createWidgets()
q->setHistory(options->history());
if (options->initiallySelectedFiles().count() == 1)
q->selectFile(options->initiallySelectedFiles().first().fileName());
- foreach (QUrl url, options->initiallySelectedFiles())
+ foreach (const QUrl &url, options->initiallySelectedFiles())
q->selectUrl(url);
lineEdit()->selectAll();
_q_updateOkButton();
@@ -3764,6 +3793,12 @@ void QFileDialogPrivate::_q_nativeEnterDirectory(const QUrl &directory)
bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) {
Q_Q(QFileDialog);
+
+ if (event->matches(QKeySequence::Cancel)) {
+ q->reject();
+ return true;
+ }
+
switch (event->key()) {
case Qt::Key_Backspace:
_q_navigateToParent();
@@ -3779,9 +3814,6 @@ bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) {
return true;
}
break;
- case Qt::Key_Escape:
- q->hide();
- return true;
default:
break;
}
@@ -3792,7 +3824,7 @@ QString QFileDialogPrivate::getEnvironmentVariable(const QString &string)
{
#ifdef Q_OS_UNIX
if (string.size() > 1 && string.startsWith(QLatin1Char('$'))) {
- return QString::fromLocal8Bit(getenv(string.mid(1).toLatin1().constData()));
+ return QString::fromLocal8Bit(qgetenv(string.mid(1).toLatin1().constData()));
}
#else
if (string.size() > 2 && string.startsWith(QLatin1Char('%')) && string.endsWith(QLatin1Char('%'))) {
@@ -3968,7 +4000,7 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
int key = e->key();
QLineEdit::keyPressEvent(e);
- if (key != Qt::Key_Escape && key != Qt::Key_Back)
+ if (!e->matches(QKeySequence::Cancel) && key != Qt::Key_Back)
e->accept();
}
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
index 95209bceb5..ffe49a2dd2 100644
--- a/src/widgets/dialogs/qfiledialog.h
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -66,6 +66,7 @@ class Q_WIDGETS_EXPORT QFileDialog : public QDialog
Q_PROPERTY(bool nameFilterDetailsVisible READ isNameFilterDetailsVisible
WRITE setNameFilterDetailsVisible DESIGNABLE false)
Q_PROPERTY(Options options READ options WRITE setOptions)
+ Q_PROPERTY(QStringList supportedSchemes READ supportedSchemes WRITE setSupportedSchemes)
public:
enum ViewMode { Detail, List };
@@ -91,7 +92,7 @@ public:
Q_DECLARE_FLAGS(Options, Option)
QFileDialog(QWidget *parent, Qt::WindowFlags f);
- explicit QFileDialog(QWidget *parent = 0,
+ explicit QFileDialog(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QString &directory = QString(),
const QString &filter = QString());
@@ -167,6 +168,9 @@ public:
void setLabelText(DialogLabel label, const QString &text);
QString labelText(DialogLabel label) const;
+ void setSupportedSchemes(const QStringList &schemes);
+ QStringList supportedSchemes() const;
+
#ifndef QT_NO_PROXYMODEL
void setProxyModel(QAbstractProxyModel *model);
QAbstractProxyModel *proxyModel() const;
@@ -196,60 +200,60 @@ Q_SIGNALS:
public:
- static QString getOpenFileName(QWidget *parent = 0,
+ static QString getOpenFileName(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QString &dir = QString(),
const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0);
+ QString *selectedFilter = Q_NULLPTR,
+ Options options = Options());
- static QUrl getOpenFileUrl(QWidget *parent = 0,
+ static QUrl getOpenFileUrl(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0,
+ QString *selectedFilter = Q_NULLPTR,
+ Options options = Options(),
const QStringList &supportedSchemes = QStringList());
- static QString getSaveFileName(QWidget *parent = 0,
+ static QString getSaveFileName(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QString &dir = QString(),
const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0);
+ QString *selectedFilter = Q_NULLPTR,
+ Options options = Options());
- static QUrl getSaveFileUrl(QWidget *parent = 0,
+ static QUrl getSaveFileUrl(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0,
+ QString *selectedFilter = Q_NULLPTR,
+ Options options = Options(),
const QStringList &supportedSchemes = QStringList());
- static QString getExistingDirectory(QWidget *parent = 0,
+ static QString getExistingDirectory(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QString &dir = QString(),
Options options = ShowDirsOnly);
- static QUrl getExistingDirectoryUrl(QWidget *parent = 0,
+ static QUrl getExistingDirectoryUrl(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
Options options = ShowDirsOnly,
const QStringList &supportedSchemes = QStringList());
- static QStringList getOpenFileNames(QWidget *parent = 0,
+ static QStringList getOpenFileNames(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QString &dir = QString(),
const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0);
+ QString *selectedFilter = Q_NULLPTR,
+ Options options = Options());
- static QList<QUrl> getOpenFileUrls(QWidget *parent = 0,
+ static QList<QUrl> getOpenFileUrls(QWidget *parent = Q_NULLPTR,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0,
+ QString *selectedFilter = Q_NULLPTR,
+ Options options = Options(),
const QStringList &supportedSchemes = QStringList());
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index 7329019a87..92d6b8f3be 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -287,7 +287,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
}
for (int i = infoList.count() - 1; i >= 0; --i) {
QString driveName = translateDriveName(infoList.at(i));
- QList<QPair<QString,QFileInfo> > updatedFiles;
+ QVector<QPair<QString,QFileInfo> > updatedFiles;
updatedFiles.append(QPair<QString,QFileInfo>(driveName, infoList.at(i)));
emit updates(path, updatedFiles);
}
@@ -298,7 +298,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
base.start();
QFileInfo fileInfo;
bool firstTime = true;
- QList<QPair<QString, QFileInfo> > updatedFiles;
+ QVector<QPair<QString, QFileInfo> > updatedFiles;
QStringList filesToCheck = files;
QString itPath = QDir::fromNativeSeparators(files.isEmpty() ? path : QLatin1String(""));
@@ -324,7 +324,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
emit directoryLoaded(path);
}
-void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bool &firstTime, QList<QPair<QString, QFileInfo> > &updatedFiles, const QString &path) {
+void QFileInfoGatherer::fetch(const QFileInfo &fileInfo, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, QFileInfo> > &updatedFiles, const QString &path) {
updatedFiles.append(QPair<QString, QFileInfo>(fileInfo.fileName(), fileInfo));
QElapsedTimer current;
current.start();
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index 6bd15b5388..03f87fdba5 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -149,7 +149,7 @@ class Q_AUTOTEST_EXPORT QFileInfoGatherer : public QThread
Q_OBJECT
Q_SIGNALS:
- void updates(const QString &directory, const QList<QPair<QString, QFileInfo> > &updates);
+ void updates(const QString &directory, const QVector<QPair<QString, QFileInfo> > &updates);
void newListOfFiles(const QString &directory, const QStringList &listOfFiles) const;
void nameResolved(const QString &fileName, const QString &resolvedName) const;
void directoryLoaded(const QString &path);
@@ -176,7 +176,7 @@ private:
void run() Q_DECL_OVERRIDE;
// called by run():
void getFileInfos(const QString &path, const QStringList &files);
- void fetch(const QFileInfo &info, QElapsedTimer &base, bool &firstTime, QList<QPair<QString, QFileInfo> > &updatedFiles, const QString &path);
+ void fetch(const QFileInfo &info, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, QFileInfo> > &updatedFiles, const QString &path);
private:
mutable QMutex mutex;
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 4859231d95..d23737f130 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -39,6 +39,7 @@
#include <qdebug.h>
#include <qmessagebox.h>
#include <qapplication.h>
+#include <QtCore/qcollator.h>
#include <algorithm>
@@ -154,6 +155,11 @@ QT_BEGIN_NAMESPACE
Returns the QFileInfo for the item stored in the model under the given
\a index.
*/
+QFileInfo QFileSystemModel::fileInfo(const QModelIndex &index) const
+{
+ Q_D(const QFileSystemModel);
+ return d->node(index)->fileInfo();
+}
/*!
\fn void QFileSystemModel::rootPathChanged(const QString &newPath);
@@ -192,13 +198,14 @@ QT_BEGIN_NAMESPACE
bool QFileSystemModel::remove(const QModelIndex &aindex)
{
const QString path = filePath(aindex);
+ const bool success = QFileInfo(path).isFile() ? QFile::remove(path) : QDir(path).removeRecursively();
#ifndef QT_NO_FILESYSTEMWATCHER
- QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
- d->fileInfoGatherer.removePath(path);
+ if (success) {
+ QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
+ d->fileInfoGatherer.removePath(path);
+ }
#endif
- if (QFileInfo(path).isFile())
- return QFile::remove(path);
- return QDir(path).removeRecursively();
+ return success;
}
/*!
@@ -243,7 +250,7 @@ QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &pare
Q_ASSERT(parentNode);
// now get the internal pointer for the index
- QString childName = parentNode->visibleChildren[d->translateVisibleLocation(parentNode, row)];
+ const QString &childName = parentNode->visibleChildren.at(d->translateVisibleLocation(parentNode, row));
const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName);
Q_ASSERT(indexNode);
@@ -259,10 +266,7 @@ QModelIndex QFileSystemModel::index(const QString &path, int column) const
{
Q_D(const QFileSystemModel);
QFileSystemModelPrivate::QFileSystemNode *node = d->node(path, false);
- QModelIndex idx = d->index(node);
- if (idx.column() != column)
- idx = idx.sibling(idx.row(), column);
- return idx;
+ return d->index(node, column);
}
/*!
@@ -375,7 +379,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
{
- if (!pathElements.at(0).contains(QLatin1String(":"))) {
+ if (!pathElements.at(0).contains(QLatin1Char(':'))) {
QString rootPath = QDir(longPath).rootPath();
pathElements.prepend(rootPath);
}
@@ -476,7 +480,7 @@ void QFileSystemModel::timerEvent(QTimerEvent *event)
d->fileInfoGatherer.fetchExtendedInformation(d->toFetch.at(i).dir,
QStringList(d->toFetch.at(i).file));
} else {
- // qDebug() << "yah!, you saved a little gerbil soul";
+ // qDebug("yah!, you saved a little gerbil soul");
}
}
#endif
@@ -562,7 +566,7 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const
return the index for node
*/
-QModelIndex QFileSystemModelPrivate::index(const QFileSystemModelPrivate::QFileSystemNode *node) const
+QModelIndex QFileSystemModelPrivate::index(const QFileSystemModelPrivate::QFileSystemNode *node, int column) const
{
Q_Q(const QFileSystemModel);
QFileSystemModelPrivate::QFileSystemNode *parentNode = (node ? node->parent : 0);
@@ -575,7 +579,7 @@ QModelIndex QFileSystemModelPrivate::index(const QFileSystemModelPrivate::QFileS
return QModelIndex();
int visualRow = translateVisibleLocation(parentNode, parentNode->visibleLocation(node->fileName));
- return q->createIndex(visualRow, 0, const_cast<QFileSystemNode*>(node));
+ return q->createIndex(visualRow, column, const_cast<QFileSystemNode*>(node));
}
/*!
@@ -643,7 +647,7 @@ int QFileSystemModel::rowCount(const QModelIndex &parent) const
*/
int QFileSystemModel::columnCount(const QModelIndex &parent) const
{
- return (parent.column() > 0) ? 0 : 4;
+ return (parent.column() > 0) ? 0 : QFileSystemModelPrivate::NumColumns;
}
/*!
@@ -799,8 +803,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
#endif
!resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
QString fullPath = QDir::fromNativeSeparators(filePath(index));
- if (resolvedSymLinks.contains(fullPath))
- return resolvedSymLinks[fullPath];
+ return resolvedSymLinks.value(fullPath, dirNode->fileName);
}
return dirNode->fileName;
}
@@ -978,84 +981,6 @@ void QFileSystemModelPrivate::_q_performDelayedSort()
q->sort(sortColumn, sortOrder);
}
-static inline QChar getNextChar(const QString &s, int location)
-{
- return (location < s.length()) ? s.at(location) : QChar();
-}
-
-/*!
- Natural number sort, skips spaces.
-
- Examples:
- 1, 2, 10, 55, 100
- 01.jpg, 2.jpg, 10.jpg
-
- Note on the algorithm:
- Only as many characters as necessary are looked at and at most they all
- are looked at once.
-
- Slower then QString::compare() (of course)
- */
-int QFileSystemModelPrivate::naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
-{
- for (int l1 = 0, l2 = 0; l1 <= s1.count() && l2 <= s2.count(); ++l1, ++l2) {
- // skip spaces, tabs and 0's
- QChar c1 = getNextChar(s1, l1);
- while (c1.isSpace())
- c1 = getNextChar(s1, ++l1);
- QChar c2 = getNextChar(s2, l2);
- while (c2.isSpace())
- c2 = getNextChar(s2, ++l2);
-
- if (c1.isDigit() && c2.isDigit()) {
- while (c1.digitValue() == 0)
- c1 = getNextChar(s1, ++l1);
- while (c2.digitValue() == 0)
- c2 = getNextChar(s2, ++l2);
-
- int lookAheadLocation1 = l1;
- int lookAheadLocation2 = l2;
- int currentReturnValue = 0;
- // find the last digit, setting currentReturnValue as we go if it isn't equal
- for (
- QChar lookAhead1 = c1, lookAhead2 = c2;
- (lookAheadLocation1 <= s1.length() && lookAheadLocation2 <= s2.length());
- lookAhead1 = getNextChar(s1, ++lookAheadLocation1),
- lookAhead2 = getNextChar(s2, ++lookAheadLocation2)
- ) {
- bool is1ADigit = !lookAhead1.isNull() && lookAhead1.isDigit();
- bool is2ADigit = !lookAhead2.isNull() && lookAhead2.isDigit();
- if (!is1ADigit && !is2ADigit)
- break;
- if (!is1ADigit)
- return -1;
- if (!is2ADigit)
- return 1;
- if (currentReturnValue == 0) {
- if (lookAhead1 < lookAhead2) {
- currentReturnValue = -1;
- } else if (lookAhead1 > lookAhead2) {
- currentReturnValue = 1;
- }
- }
- }
- if (currentReturnValue != 0)
- return currentReturnValue;
- }
-
- if (cs == Qt::CaseInsensitive) {
- if (!c1.isLower()) c1 = c1.toLower();
- if (!c2.isLower()) c2 = c2.toLower();
- }
- int r = QString::localeAwareCompare(c1, c2);
- if (r < 0)
- return -1;
- if (r > 0)
- return 1;
- }
- // The two strings are the same (02 == 2) so fall back to the normal sort
- return QString::compare(s1, s2, cs);
-}
/*
\internal
@@ -1064,7 +989,11 @@ int QFileSystemModelPrivate::naturalCompare(const QString &s1, const QString &s2
class QFileSystemModelSorter
{
public:
- inline QFileSystemModelSorter(int column) : sortColumn(column) {}
+ inline QFileSystemModelSorter(int column) : sortColumn(column)
+ {
+ naturalCompare.setNumericMode(true);
+ naturalCompare.setCaseSensitivity(Qt::CaseInsensitive);
+ }
bool compareNodes(const QFileSystemModelPrivate::QFileSystemNode *l,
const QFileSystemModelPrivate::QFileSystemNode *r) const
@@ -1078,8 +1007,7 @@ public:
if (left ^ right)
return left;
#endif
- return QFileSystemModelPrivate::naturalCompare(l->fileName,
- r->fileName, Qt::CaseInsensitive) < 0;
+ return naturalCompare.compare(l->fileName, r->fileName) < 0;
}
case 1:
{
@@ -1091,22 +1019,22 @@ public:
qint64 sizeDifference = l->size() - r->size();
if (sizeDifference == 0)
- return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
+ return naturalCompare.compare(l->fileName, r->fileName) < 0;
return sizeDifference < 0;
}
case 2:
{
- int compare = QString::localeAwareCompare(l->type(), r->type());
+ int compare = naturalCompare.compare(l->type(), r->type());
if (compare == 0)
- return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
+ return naturalCompare.compare(l->fileName, r->fileName) < 0;
return compare < 0;
}
case 3:
{
if (l->lastModified() == r->lastModified())
- return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
+ return naturalCompare.compare(l->fileName, r->fileName) < 0;
return l->lastModified() < r->lastModified();
}
@@ -1115,14 +1043,15 @@ public:
return false;
}
- bool operator()(const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &l,
- const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &r) const
+ bool operator()(const QFileSystemModelPrivate::QFileSystemNode *l,
+ const QFileSystemModelPrivate::QFileSystemNode *r) const
{
- return compareNodes(l.first, r.first);
+ return compareNodes(l, r);
}
private:
+ QCollator naturalCompare;
int sortColumn;
};
@@ -1138,16 +1067,14 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent
if (indexNode->children.count() == 0)
return;
- QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > values;
+ QVector<QFileSystemModelPrivate::QFileSystemNode*> values;
QHash<QString, QFileSystemNode *>::const_iterator iterator;
- int i = 0;
for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd() ; ++iterator) {
if (filtersAcceptsNode(iterator.value())) {
- values.append(QPair<QFileSystemModelPrivate::QFileSystemNode*, int>((iterator.value()), i));
+ values.append(iterator.value());
} else {
iterator.value()->isVisible = false;
}
- i++;
}
QFileSystemModelSorter ms(column);
std::sort(values.begin(), values.end(), ms);
@@ -1155,9 +1082,11 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent
indexNode->visibleChildren.clear();
//No more dirty item we reset our internal dirty index
indexNode->dirtyChildrenIndex = -1;
- for (int i = 0; i < values.count(); ++i) {
- indexNode->visibleChildren.append(values.at(i).first->fileName);
- values.at(i).first->isVisible = true;
+ const int numValues = values.count();
+ indexNode->visibleChildren.reserve(numValues);
+ for (int i = 0; i < numValues; ++i) {
+ indexNode->visibleChildren.append(values.at(i)->fileName);
+ values.at(i)->isVisible = true;
}
if (!disableRecursiveSort) {
@@ -1182,9 +1111,12 @@ void QFileSystemModel::sort(int column, Qt::SortOrder order)
emit layoutAboutToBeChanged();
QModelIndexList oldList = persistentIndexList();
- QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > oldNodes;
- for (int i = 0; i < oldList.count(); ++i) {
- QPair<QFileSystemModelPrivate::QFileSystemNode*, int> pair(d->node(oldList.at(i)), oldList.at(i).column());
+ QVector<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > oldNodes;
+ const int nodeCount = oldList.count();
+ oldNodes.reserve(nodeCount);
+ for (int i = 0; i < nodeCount; ++i) {
+ const QModelIndex &oldNode = oldList.at(i);
+ QPair<QFileSystemModelPrivate::QFileSystemNode*, int> pair(d->node(oldNode), oldNode.column());
oldNodes.append(pair);
}
@@ -1197,10 +1129,11 @@ void QFileSystemModel::sort(int column, Qt::SortOrder order)
d->sortOrder = order;
QModelIndexList newList;
- for (int i = 0; i < oldNodes.count(); ++i) {
- QModelIndex idx = d->index(oldNodes.at(i).first);
- idx = idx.sibling(idx.row(), oldNodes.at(i).second);
- newList.append(idx);
+ const int numOldNodes = oldNodes.size();
+ newList.reserve(numOldNodes);
+ for (int i = 0; i < numOldNodes; ++i) {
+ const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &oldNode = oldNodes.at(i);
+ newList.append(d->index(oldNode.first, oldNode.second));
}
changePersistentIndexList(oldList, newList);
emit layoutChanged();
@@ -1648,7 +1581,9 @@ QStringList QFileSystemModel::nameFilters() const
Q_D(const QFileSystemModel);
QStringList filters;
#ifndef QT_NO_REGEXP
- for (int i = 0; i < d->nameFilters.size(); ++i) {
+ const int numNameFilters = d->nameFilters.size();
+ filters.reserve(numNameFilters);
+ for (int i = 0; i < numNameFilters; ++i) {
filters << d->nameFilters.at(i).pattern();
}
#endif
@@ -1673,11 +1608,14 @@ bool QFileSystemModel::event(QEvent *event)
bool QFileSystemModel::rmdir(const QModelIndex &aindex)
{
QString path = filePath(aindex);
+ const bool success = QDir().rmdir(path);
#ifndef QT_NO_FILESYSTEMWATCHER
- QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
- d->fileInfoGatherer.removePath(path);
+ if (success) {
+ QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
+ d->fileInfoGatherer.removePath(path);
+ }
#endif
- return QDir().rmdir(path);
+ return success;
}
/*!
@@ -1765,26 +1703,6 @@ void QFileSystemModelPrivate::removeNode(QFileSystemModelPrivate::QFileSystemNod
q->endRemoveRows();
}
-/*
- \internal
- Helper functor used by addVisibleFiles()
-*/
-class QFileSystemModelVisibleFinder
-{
-public:
- inline QFileSystemModelVisibleFinder(QFileSystemModelPrivate::QFileSystemNode *node, QFileSystemModelSorter *sorter) : parentNode(node), sorter(sorter) {}
-
- bool operator()(const QString &, QString r) const
- {
- return sorter->compareNodes(parentNode->children.value(name), parentNode->children.value(r));
- }
-
- QString name;
-private:
- QFileSystemModelPrivate::QFileSystemNode *parentNode;
- QFileSystemModelSorter *sorter;
-};
-
/*!
\internal
@@ -1806,9 +1724,9 @@ void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const
parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count();
for (int i = 0; i < newFiles.count(); ++i) {
- parentNode->visibleChildren.append(newFiles.at(i));
- parentNode->children[newFiles.at(i)]->isVisible = true;
- }
+ parentNode->visibleChildren.append(newFiles.at(i));
+ parentNode->children.value(newFiles.at(i))->isVisible = true;
+ }
if (!indexHidden)
q->endInsertRows();
}
@@ -1830,7 +1748,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int
if (!indexHidden)
q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
translateVisibleLocation(parentNode, vLocation));
- parentNode->children[parentNode->visibleChildren.at(vLocation)]->isVisible = false;
+ parentNode->children.value(parentNode->visibleChildren.at(vLocation))->isVisible = false;
parentNode->visibleChildren.removeAt(vLocation);
if (!indexHidden)
q->endRemoveRows();
@@ -1842,7 +1760,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int
The thread has received new information about files,
update and emit dataChanged if it has actually changed.
*/
-void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &updates)
+void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QVector<QPair<QString, QFileInfo> > &updates)
{
#ifndef QT_NO_FILESYSTEMWATCHER
Q_Q(QFileSystemModel);
@@ -1873,10 +1791,6 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QL
node->fileName = fileName;
}
- if (info.size() == -1 && !info.isSymLink()) {
- removeNode(parentNode, fileName);
- continue;
- }
if (*node != info ) {
node->populate(info);
bypassFilters.remove(node);
@@ -1961,12 +1875,12 @@ void QFileSystemModelPrivate::_q_resolvedName(const QString &fileName, const QSt
void QFileSystemModelPrivate::init()
{
Q_Q(QFileSystemModel);
- qRegisterMetaType<QList<QPair<QString,QFileInfo> > >();
+ qRegisterMetaType<QVector<QPair<QString,QFileInfo> > >();
#ifndef QT_NO_FILESYSTEMWATCHER
q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)),
q, SLOT(_q_directoryChanged(QString,QStringList)));
- q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QList<QPair<QString,QFileInfo> >)),
- q, SLOT(_q_fileSystemChanged(QString,QList<QPair<QString,QFileInfo> >)));
+ q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QVector<QPair<QString,QFileInfo> >)),
+ q, SLOT(_q_fileSystemChanged(QString,QVector<QPair<QString,QFileInfo> >)));
q->connect(&fileInfoGatherer, SIGNAL(nameResolved(QString,QString)),
q, SLOT(_q_resolvedName(QString,QString)));
q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)),
diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h
index 7c98a102f3..515417f225 100644
--- a/src/widgets/dialogs/qfilesystemmodel.h
+++ b/src/widgets/dialogs/qfilesystemmodel.h
@@ -69,7 +69,7 @@ public:
FilePermissions = Qt::UserRole + 3
};
- explicit QFileSystemModel(QObject *parent = 0);
+ explicit QFileSystemModel(QObject *parent = Q_NULLPTR);
~QFileSystemModel();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
@@ -132,11 +132,11 @@ public:
inline QString fileName(const QModelIndex &index) const;
inline QIcon fileIcon(const QModelIndex &index) const;
QFile::Permissions permissions(const QModelIndex &index) const;
- inline QFileInfo fileInfo(const QModelIndex &index) const;
+ QFileInfo fileInfo(const QModelIndex &index) const;
bool remove(const QModelIndex &index);
protected:
- QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = 0);
+ QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = Q_NULLPTR);
void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
bool event(QEvent *event) Q_DECL_OVERRIDE;
@@ -146,7 +146,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QStringList &list))
Q_PRIVATE_SLOT(d_func(), void _q_performDelayedSort())
- Q_PRIVATE_SLOT(d_func(), void _q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &))
+ Q_PRIVATE_SLOT(d_func(), void _q_fileSystemChanged(const QString &path, const QVector<QPair<QString, QFileInfo> > &))
Q_PRIVATE_SLOT(d_func(), void _q_resolvedName(const QString &fileName, const QString &resolvedName))
friend class QFileDialogPrivate;
@@ -156,8 +156,6 @@ inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const
{ return aindex.data(Qt::DisplayRole).toString(); }
inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const
{ return qvariant_cast<QIcon>(aindex.data(Qt::DecorationRole)); }
-inline QFileInfo QFileSystemModel::fileInfo(const QModelIndex &aindex) const
-{ return QFileInfo(filePath(aindex)); }
#endif // QT_NO_FILESYSTEMMODEL
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index dd4b25d59c..d2a40a1cb5 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -70,6 +70,8 @@ class Q_AUTOTEST_EXPORT QFileSystemModelPrivate : public QAbstractItemModelPriva
Q_DECLARE_PUBLIC(QFileSystemModel)
public:
+ enum { NumColumns = 4 };
+
class QFileSystemNode
{
public:
@@ -105,6 +107,7 @@ public:
return true;
return false;
}
+ inline QFileInfo fileInfo() const { if (info) return info->fileInfo(); return QFileInfo(); }
inline bool isFile() const { if (info) return info->isFile(); return true; }
inline bool isSystem() const { if (info) return info->isSystem(); return true; }
inline bool isHidden() const { if (info) return info->isHidden(); return false; }
@@ -220,8 +223,8 @@ public:
}
QFileSystemNode *node(const QModelIndex &index) const;
QFileSystemNode *node(const QString &path, bool fetch = true) const;
- inline QModelIndex index(const QString &path) { return index(node(path)); }
- QModelIndex index(const QFileSystemNode *node) const;
+ inline QModelIndex index(const QString &path, int column = 0) { return index(node(path), column); }
+ QModelIndex index(const QFileSystemNode *node, int column = 0) const;
bool filtersAcceptsNode(const QFileSystemNode *node) const;
bool passNameFilters(const QFileSystemNode *node) const;
void removeNode(QFileSystemNode *parentNode, const QString &name);
@@ -280,7 +283,7 @@ public:
void _q_directoryChanged(const QString &directory, const QStringList &list);
void _q_performDelayedSort();
- void _q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &);
+ void _q_fileSystemChanged(const QString &path, const QVector<QPair<QString, QFileInfo> > &);
void _q_resolvedName(const QString &fileName, const QString &resolvedName);
static int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs);
@@ -318,6 +321,7 @@ public:
QList<Fetching> toFetch;
};
+Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_MOVABLE_TYPE);
#endif // QT_NO_FILESYSTEMMODEL
QT_END_NAMESPACE
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index d47dd3562f..d0177941f7 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -102,6 +102,16 @@ QFontListView::QFontListView(QWidget *parent)
static const Qt::WindowFlags DefaultWindowFlags =
Qt::Dialog | Qt::WindowSystemMenuHint;
+QFontDialogPrivate::QFontDialogPrivate()
+ : writingSystem(QFontDatabase::Any),
+ options(QSharedPointer<QFontDialogOptions>::create())
+{
+}
+
+QFontDialogPrivate::~QFontDialogPrivate()
+{
+}
+
/*!
\class QFontDialog
\ingroup standard-dialogs
@@ -619,6 +629,7 @@ void QFontDialogPrivate::updateSizes()
int i = 0;
int current = -1;
QStringList str_sizes;
+ str_sizes.reserve(sizes.size());
for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) {
str_sizes.append(QString::number(*it));
if (current == -1 && *it == size)
diff --git a/src/widgets/dialogs/qfontdialog.h b/src/widgets/dialogs/qfontdialog.h
index 8ca9bf14dd..c3c3050174 100644
--- a/src/widgets/dialogs/qfontdialog.h
+++ b/src/widgets/dialogs/qfontdialog.h
@@ -65,8 +65,8 @@ public:
Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
- explicit QFontDialog(QWidget *parent = 0);
- explicit QFontDialog(const QFont &initial, QWidget *parent = 0);
+ explicit QFontDialog(QWidget *parent = Q_NULLPTR);
+ explicit QFontDialog(const QFont &initial, QWidget *parent = Q_NULLPTR);
~QFontDialog();
void setCurrentFont(const QFont &font);
@@ -84,9 +84,9 @@ public:
void setVisible(bool visible) Q_DECL_OVERRIDE;
- static QFont getFont(bool *ok, QWidget *parent = 0);
- static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = 0, const QString &title = QString(),
- FontDialogOptions options = 0);
+ static QFont getFont(bool *ok, QWidget *parent = Q_NULLPTR);
+ static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = Q_NULLPTR, const QString &title = QString(),
+ FontDialogOptions options = FontDialogOptions());
Q_SIGNALS:
void currentFontChanged(const QFont &font);
diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h
index e456faaa61..7b92b67f5c 100644
--- a/src/widgets/dialogs/qfontdialog_p.h
+++ b/src/widgets/dialogs/qfontdialog_p.h
@@ -65,14 +65,13 @@ class QGroupBox;
class QLabel;
class QLineEdit;
-class QFontDialogPrivate : public QDialogPrivate
+class Q_AUTOTEST_EXPORT QFontDialogPrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QFontDialog)
public:
- inline QFontDialogPrivate()
- : writingSystem(QFontDatabase::Any), options(new QFontDialogOptions)
- { }
+ QFontDialogPrivate();
+ ~QFontDialogPrivate();
QPlatformFontDialogHelper *platformFontDialogHelper() const
{ return static_cast<QPlatformFontDialogHelper *>(platformHelper()); }
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index 9c78f5e9ac..fb52fa4651 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -791,6 +791,7 @@ QStringList QInputDialog::comboBoxItems() const
QStringList result;
if (d->comboBox) {
const int count = d->comboBox->count();
+ result.reserve(count);
for (int i = 0; i < count; ++i)
result.append(d->comboBox->itemText(i));
}
diff --git a/src/widgets/dialogs/qinputdialog.h b/src/widgets/dialogs/qinputdialog.h
index 84130d5f90..600f6c9753 100644
--- a/src/widgets/dialogs/qinputdialog.h
+++ b/src/widgets/dialogs/qinputdialog.h
@@ -83,7 +83,7 @@ public:
DoubleInput
};
- QInputDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ QInputDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
~QInputDialog();
void setInputMode(InputMode mode);
@@ -153,27 +153,29 @@ public:
static QString getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode echo = QLineEdit::Normal,
- const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0,
+ const QString &text = QString(), bool *ok = Q_NULLPTR,
+ Qt::WindowFlags flags = Qt::WindowFlags(),
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
static QString getMultiLineText(QWidget *parent, const QString &title, const QString &label,
- const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0,
- Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
+ const QString &text = QString(), bool *ok = Q_NULLPTR,
+ Qt::WindowFlags flags = Qt::WindowFlags(),
+ Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
static QString getItem(QWidget *parent, const QString &title, const QString &label,
const QStringList &items, int current = 0, bool editable = true,
- bool *ok = 0, Qt::WindowFlags flags = 0,
+ bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags(),
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
int minValue = -2147483647, int maxValue = 2147483647,
- int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
+ int step = 1, bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
double minValue = -2147483647, double maxValue = 2147483647,
- int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
+ int decimals = 1, bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED static inline int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
int minValue = -2147483647, int maxValue = 2147483647,
- int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0)
+ int step = 1, bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
{
return getInt(parent, title, label, value, minValue, maxValue, step, ok, flags);
}
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index ef9b55acd6..8a48100ea7 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -1450,11 +1450,8 @@ void QMessageBox::changeEvent(QEvent *ev)
void QMessageBox::keyPressEvent(QKeyEvent *e)
{
Q_D(QMessageBox);
- if (e->key() == Qt::Key_Escape
-#ifdef Q_OS_MAC
- || (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period)
-#endif
- ) {
+
+ if (e->matches(QKeySequence::Cancel)) {
if (d->detectedEscapeButton) {
#ifdef Q_OS_MAC
d->detectedEscapeButton->animateClick();
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index 464bf734dc..b108354466 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -125,9 +125,9 @@ public:
Q_DECLARE_FLAGS(StandardButtons, StandardButton)
- explicit QMessageBox(QWidget *parent = 0);
+ explicit QMessageBox(QWidget *parent = Q_NULLPTR);
QMessageBox(Icon icon, const QString &title, const QString &text,
- StandardButtons buttons = NoButton, QWidget *parent = 0,
+ StandardButtons buttons = NoButton, QWidget *parent = Q_NULLPTR,
Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
~QMessageBox();
@@ -198,7 +198,7 @@ public:
QMessageBox(const QString &title, const QString &text, Icon icon,
int button0, int button1, int button2,
- QWidget *parent = 0,
+ QWidget *parent = Q_NULLPTR,
Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
static int information(QWidget *parent, const QString &title,
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 4e8e245813..bbb251c8b2 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -411,7 +411,8 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton)
if (cancelButton) {
connect(d->cancel, SIGNAL(clicked()), this, SIGNAL(canceled()));
#ifndef QT_NO_SHORTCUT
- d->escapeShortcut = new QShortcut(Qt::Key_Escape, this, SIGNAL(canceled()));
+ // FIXME: This only registers the primary key sequence of the cancel action
+ d->escapeShortcut = new QShortcut(QKeySequence::Cancel, this, SIGNAL(canceled()));
#endif
} else {
#ifndef QT_NO_SHORTCUT
@@ -697,9 +698,6 @@ void QProgressDialog::setValue(int progress)
d->shown_once = true;
}
}
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
- QApplication::flush();
-#endif
}
if (progress == d->bar->maximum() && d->autoReset)
diff --git a/src/widgets/dialogs/qprogressdialog.h b/src/widgets/dialogs/qprogressdialog.h
index 51c45f5d30..28de623385 100644
--- a/src/widgets/dialogs/qprogressdialog.h
+++ b/src/widgets/dialogs/qprogressdialog.h
@@ -61,9 +61,10 @@ class Q_WIDGETS_EXPORT QProgressDialog : public QDialog
Q_PROPERTY(QString labelText READ labelText WRITE setLabelText)
public:
- explicit QProgressDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QProgressDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
QProgressDialog(const QString &labelText, const QString &cancelButtonText,
- int minimum, int maximum, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ int minimum, int maximum, QWidget *parent = Q_NULLPTR,
+ Qt::WindowFlags flags = Qt::WindowFlags());
~QProgressDialog();
void setLabel(QLabel *label);
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index 6fbcce801d..f883705cc3 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -60,6 +60,8 @@ void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option,
}
/*!
+ \internal
+ \class QUrlModel
QUrlModel lets you have indexes from a QFileSystemModel to a list. When QFileSystemModel
changes them QUrlModel will automatically update.
@@ -274,7 +276,9 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
QList<QUrl> QUrlModel::urls() const
{
QList<QUrl> list;
- for (int i = 0; i < rowCount(); ++i)
+ const int numRows = rowCount();
+ list.reserve(numRows);
+ for (int i = 0; i < numRows; ++i)
list.append(data(index(i, 0), UrlRole).toUrl());
return list;
}
@@ -334,10 +338,12 @@ void QUrlModel::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto
void QUrlModel::layoutChanged()
{
QStringList paths;
- for (int i = 0; i < watching.count(); ++i)
+ const int numPaths = watching.count();
+ paths.reserve(numPaths);
+ for (int i = 0; i < numPaths; ++i)
paths.append(watching.at(i).second);
watching.clear();
- for (int i = 0; i < paths.count(); ++i) {
+ for (int i = 0; i < numPaths; ++i) {
QString path = paths.at(i);
QModelIndex newIndex = fileSystemModel->index(path);
watching.append(QPair<QModelIndex, QString>(newIndex, path));
@@ -453,12 +459,14 @@ void QSidebar::removeEntry()
{
QList<QModelIndex> idxs = selectionModel()->selectedIndexes();
QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
+ const int numIndexes = idxs.count();
+ for (int i = 0; i < numIndexes; i++)
indexes.append(idxs.at(i));
- for (int i = 0; i < indexes.count(); ++i)
+ for (int i = 0; i < numIndexes; ++i) {
if (!indexes.at(i).data(QUrlModel::UrlRole).toUrl().path().isEmpty())
model()->removeRow(indexes.at(i).row());
+ }
}
/*!
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 139fbc3843..b9906f13da 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -170,6 +170,7 @@ public:
const char *changedSignal)
: className(className), property(property), changedSignal(changedSignal) {}
};
+Q_DECLARE_TYPEINFO(QWizardDefaultProperty, Q_MOVABLE_TYPE);
class QWizardField
{
@@ -189,6 +190,7 @@ public:
QByteArray changedSignal;
QVariant initialValue;
};
+Q_DECLARE_TYPEINFO(QWizardField, Q_MOVABLE_TYPE);
QWizardField::QWizardField(QWizardPage *page, const QString &spec, QObject *object,
const char *property, const char *changedSignal)
@@ -751,6 +753,7 @@ void QWizardPrivate::init()
updateButtonLayout();
+ defaultPropertyTable.reserve(NFallbackDefaultProperties);
for (uint i = 0; i < NFallbackDefaultProperties; ++i)
defaultPropertyTable.append(QWizardDefaultProperty(fallbackProperties[i].className,
fallbackProperties[i].property,
@@ -1344,7 +1347,6 @@ void QWizardPrivate::updateMinMaxSizes(const QWizardLayoutInfo &info)
}
if (info.watermark && !info.sideWidget) {
minimumSize.setHeight(mainLayout->totalSizeHint().height());
- maximumSize.setHeight(mainLayout->totalSizeHint().height());
}
if (q->minimumWidth() == minimumWidth) {
minimumWidth = minimumSize.width();
@@ -3660,7 +3662,7 @@ bool QWizardPage::validatePage()
from the rest of your implementation, whenever the value of isComplete()
changes. This ensures that QWizard updates the enabled or disabled state of
its buttons. An example of the reimplementation is
- available \l{http://doc.qt.digia.com/qq/qq22-qwizard.html#validatebeforeitstoolate}
+ available \l{http://doc.qt.io/archives/qq/qq22-qwizard.html#validatebeforeitstoolate}
{here}.
\sa completeChanged(), isFinalPage()
diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h
index 517edde377..9193f0b659 100644
--- a/src/widgets/dialogs/qwizard.h
+++ b/src/widgets/dialogs/qwizard.h
@@ -114,7 +114,7 @@ public:
Q_DECLARE_FLAGS(WizardOptions, WizardOption)
- explicit QWizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QWizard(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
~QWizard();
int addPage(QWizardPage *page);
@@ -209,7 +209,7 @@ class Q_WIDGETS_EXPORT QWizardPage : public QWidget
Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
public:
- explicit QWizardPage(QWidget *parent = 0);
+ explicit QWizardPage(QWidget *parent = Q_NULLPTR);
~QWizardPage();
void setTitle(const QString &title);
@@ -237,8 +237,8 @@ Q_SIGNALS:
protected:
void setField(const QString &name, const QVariant &value);
QVariant field(const QString &name) const;
- void registerField(const QString &name, QWidget *widget, const char *property = 0,
- const char *changedSignal = 0);
+ void registerField(const QString &name, QWidget *widget, const char *property = Q_NULLPTR,
+ const char *changedSignal = Q_NULLPTR);
QWizard *wizard() const;
private:
diff --git a/src/widgets/doc/images/listview.png b/src/widgets/doc/images/listview.png
index fa49c52c62..fa49c52c62 100755..100644
--- a/src/widgets/doc/images/listview.png
+++ b/src/widgets/doc/images/listview.png
Binary files differ
diff --git a/src/widgets/doc/images/modelview-combobox.png b/src/widgets/doc/images/modelview-combobox.png
index d172b413eb..d172b413eb 100755..100644
--- a/src/widgets/doc/images/modelview-combobox.png
+++ b/src/widgets/doc/images/modelview-combobox.png
Binary files differ
diff --git a/src/widgets/doc/images/tableview.png b/src/widgets/doc/images/tableview.png
index 8be1b6ce62..8be1b6ce62 100755..100644
--- a/src/widgets/doc/images/tableview.png
+++ b/src/widgets/doc/images/tableview.png
Binary files differ
diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf
index f307e9d3e4..8160396ca2 100644
--- a/src/widgets/doc/qtwidgets.qdocconf
+++ b/src/widgets/doc/qtwidgets.qdocconf
@@ -4,7 +4,7 @@ project = QtWidgets
description = Qt Widgets Reference Documentation
version = $QT_VERSION
-examplesinstallpath = widgets
+examplesinstallpath = qtbase/widgets
qhp.projects = QtWidgets
diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
index 39dfe32ace..e5c0f5cea1 100644
--- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -106,16 +106,6 @@ QStringList files = QFileDialog::getOpenFileNames(
//! [9]
-//! [10]
-QStringList list = files;
-QStringList::Iterator it = list.begin();
-while(it != list.end()) {
- myProcessing(*it);
- ++it;
-}
-//! [10]
-
-
//! [11]
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
"/home/jana/untitled.png",
diff --git a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
index 2f6865c9dd..074b214f80 100644
--- a/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_graphicsview_qgraphicsview.cpp
@@ -116,7 +116,7 @@ void CustomView::mousePressEvent(QMouseEvent *event)
if (QGraphicsItem *item = itemAt(event->pos())) {
qDebug() << "You clicked on item" << item;
} else {
- qDebug() << "You didn't click on an item.";
+ qDebug("You didn't click on an item.");
}
}
//! [6]
diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp
index b0b548e731..4997e25ada 100644
--- a/src/widgets/doc/snippets/javastyle.cpp
+++ b/src/widgets/doc/snippets/javastyle.cpp
@@ -236,9 +236,8 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
break;
}
case CE_DockWidgetTitle: {
- const QStyleOptionDockWidgetV2 *docker =
- new QStyleOptionDockWidgetV2(
- *qstyleoption_cast<const QStyleOptionDockWidget *>(option));
+ const QStyleOptionDockWidget *docker =
+ qstyleoption_cast<const QStyleOptionDockWidget *>(option);
QRect rect = docker->rect;
QRect titleRect = rect;
@@ -366,11 +365,9 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
break;
}
case CE_ProgressBar: {
- const QStyleOptionProgressBar *bar1 =
+ const QStyleOptionProgressBar *bar =
qstyleoption_cast<const QStyleOptionProgressBar *>(option);
- QStyleOptionProgressBarV2 *bar = new QStyleOptionProgressBarV2(*bar1);
-
QRect rect = bar->rect;
if (bar->orientation == Qt::Vertical) {
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width());
@@ -416,7 +413,6 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
if (bar->textVisible)
drawControl(CE_ProgressBarLabel, &subBar, painter, widget);
- delete bar;
break;
}
case CE_ProgressBarGroove: {
@@ -2366,18 +2362,17 @@ void JavaStyle::drawPrimitive(PrimitiveElement element,
case PE_FrameLineEdit: {
const QStyleOptionFrame *frame =
qstyleoption_cast<const QStyleOptionFrame *>(option);
- const QStyleOptionFrameV2 frameV2(*frame);
painter->setPen(frame->palette.color(QPalette::Mid));
- painter->drawRect(frameV2.rect.adjusted(0, 0, -2, -2));
+ painter->drawRect(frame->rect.adjusted(0, 0, -2, -2));
painter->setPen(Qt::white);
- painter->drawRect(frameV2.rect.adjusted(1, 1, -1, -1));
- painter->setPen(frameV2.palette.color(QPalette::Active,
+ painter->drawRect(frame->rect.adjusted(1, 1, -1, -1));
+ painter->setPen(frame->palette.color(QPalette::Active,
QPalette::Background));
- painter->drawLine(frameV2.rect.bottomLeft(),
- frameV2.rect.bottomLeft() + QPoint(1, -1));
- painter->drawLine(frameV2.rect.topRight(),
- frameV2.rect.topRight() + QPoint(-1, 1));
+ painter->drawLine(frame->rect.bottomLeft(),
+ frame->rect.bottomLeft() + QPoint(1, -1));
+ painter->drawLine(frame->rect.topRight(),
+ frame->rect.topRight() + QPoint(-1, 1));
break;
}
case PE_FrameFocusRect: {
diff --git a/src/widgets/doc/snippets/macmainwindow.mm b/src/widgets/doc/snippets/macmainwindow.mm
index d0d74631ab..d0d74631ab 100755..100644
--- a/src/widgets/doc/snippets/macmainwindow.mm
+++ b/src/widgets/doc/snippets/macmainwindow.mm
diff --git a/src/widgets/doc/snippets/qstyleoption/main.cpp b/src/widgets/doc/snippets/qstyleoption/main.cpp
index aa4220d8ea..05d5ece33d 100644
--- a/src/widgets/doc/snippets/qstyleoption/main.cpp
+++ b/src/widgets/doc/snippets/qstyleoption/main.cpp
@@ -75,44 +75,11 @@ void MyPushButton::paintEvent(QPaintEvent *)
class MyStyle : public QStyle
{
public:
- MyStyle();
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget);
};
-MyStyle::MyStyle()
-{
-//! [1]
- QStyleOptionFrame *option;
-
- if (const QStyleOptionFrame *frameOption =
- qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- QStyleOptionFrameV2 frameOptionV2(*frameOption);
-
- // draw the frame using frameOptionV2
- }
-//! [1]
-
-//! [2]
- if (const QStyleOptionProgressBar *progressBarOption =
- qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- QStyleOptionProgressBarV2 progressBarV2(*progressBarOption);
-
- // draw the progress bar using progressBarV2
- }
-//! [2]
-
-//! [3]
- if (const QStyleOptionTab *tabOption =
- qstyleoption_cast<const QStyleOptionTab *>(option)) {
- QStyleOptionTabV2 tabV2(*tabOption);
-
- // draw the tab using tabV2
- }
-//! [3]
-}
-
//! [4]
void MyStyle::drawPrimitive(PrimitiveElement element,
const QStyleOption *option,
diff --git a/src/widgets/doc/src/guibooks.qdoc b/src/widgets/doc/src/guibooks.qdoc
index 8a1198c328..b3afe06961 100644
--- a/src/widgets/doc/src/guibooks.qdoc
+++ b/src/widgets/doc/src/guibooks.qdoc
@@ -76,7 +76,7 @@
advises against will produce more easily comprehensible software.
Doing what it tells you to do may also help.
- \b{\l{http://www.amazon.com/exec/obidos/ASIN/047159900X/trolltech/t}{The
+ \b{\l{http://www.amazon.com/New-Windows-Interface-Microsoft-Press/dp/1556156790/}{The
Microsoft Windows User Experience}}, ISBN 1-55615-679-0,
is Microsoft's look and feel bible. Indispensable for everyone who
has customers that worship Microsoft, and it's quite good, too.
diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc
index 098bb39fe2..0032e77c6a 100644
--- a/src/widgets/doc/src/model-view-programming.qdoc
+++ b/src/widgets/doc/src/model-view-programming.qdoc
@@ -2301,7 +2301,7 @@
{fetchMore()} must be reimplemented as their default implementation returns
false and does nothing.
- \keyword Model/View Classes
+ \target Model/View Classes
\section1 The Model/View Classes
These classes use the model/view design pattern in which the
diff --git a/src/widgets/doc/src/qtwidgets-examples.qdoc b/src/widgets/doc/src/qtwidgets-examples.qdoc
index 7b727183b8..9c0b29d687 100644
--- a/src/widgets/doc/src/qtwidgets-examples.qdoc
+++ b/src/widgets/doc/src/qtwidgets-examples.qdoc
@@ -127,7 +127,7 @@
/*!
\ingroup all-examples
- \target Graphicsview Examples
+ \keyword Graphicsview Examples
\title Graphics View Examples
\brief Using the Graphics View framework.
\page examples-graphicsview.html
diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
index 3f093ab2d6..47c2a17e7e 100644
--- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
@@ -197,7 +197,7 @@
\section2 Stretch Factors
- \keyword stretch factor
+ \target stretch factor
Widgets are normally created without any stretch factor set. When they are
laid out in a layout the widgets are given a share of space in accordance
@@ -249,7 +249,7 @@
For further guidance when implementing these functions, see the
\e{Qt Quarterly} article
- \l{http://doc.qt.digia.com/qq/qq04-height-for-width.html}
+ \l{http://doc.qt.io/archives/qq/qq04-height-for-width.html}
{Trading Height for Width}.
diff --git a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
index 0a5a079969..7d1bffd0b4 100644
--- a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
@@ -989,9 +989,7 @@
The style option for tabs (QStyleOptionTab) contains the necessary
information for drawing tabs. The option contains the position of
the tab in the tab bar, the position of the selected tab, the
- shape of the tab, the text, and the icon. After Qt 4.1, the option
- should be cast to a QStyleOptionTabV2, which also contains the
- icon's size.
+ shape of the tab, the text, the icon, and the icon's size.
As the Java style tabs don't overlap, we also present an image of
a tab widget in the common style. Note that if you want the tabs
@@ -1024,7 +1022,7 @@
Note that individual tabs may be disabled even if the tab bar
is not. The tab will be active if the tab bar is active.
- Here follows a table of QStyleOptionTabV2's members:
+ Here follows a table of QStyleOptionTab's members:
\table 90%
\header
@@ -1450,7 +1448,7 @@
\li Content
\row
\li features
- \li Flags of the QStyleOptionFrameV2::FrameFeatures
+ \li Flags of the QStyleOptionFrame::FrameFeatures
enum describing the frame of the group box.
\row
\li lineWidth
@@ -1501,7 +1499,7 @@
\image javastyle/progressbarimage.png
- The style option for QProgressBar is QStyleOptionProgressBarV2.
+ The style option for QProgressBar is QStyleOptionProgressBar.
The bar does not set any state flags, but the other members of the
option are:
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index fc3ac345a8..2fb6819c47 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -829,7 +829,7 @@
\l{#selected-ps}{:selected},
and \l{#checked-ps}{:checked} pseudo states.
- Sort indicator in can be styled using the
+ The sort indicator can be styled using the
\l{#up-arrow-sub}{::up-arrow} and the
\l{#down-arrow-sub}{::down-arrow} Sub-control.
@@ -2186,6 +2186,54 @@
\snippet code/doc_src_stylesheet.qdoc 68
\row
+ \li \b outline
+ \li
+ \li The outline drawn around the object's border.
+
+ \row
+ \li \b outline-color
+ \li \l{#Color}{Color}
+ \li The color of the outline.
+ See also \l{Qt Style Sheets Reference#border-color-prop}{border-color}
+
+ \row
+ \li \b outline-offset
+ \li \l{#Length}{Length}
+ \li The outline's offset from the border of the widget.
+
+ \row
+ \li \b outline-style
+ \li
+ \li Specifies the pattern used to draw the outline.
+ See also \l{Qt Style Sheets Reference#border-style-prop}{border-style}
+
+ \row
+ \li \b outline-radius
+ \li
+ \li Adds rounded corners to the outline
+
+ \row
+ \li \b outline-bottom-left-radius
+ \li \l{#Radius}{Radius}
+ \li The radius for the bottom-left rounded corner of the outline.
+
+ \row
+ \li \b outline-bottom-right-radius
+ \li \l{#Radius}{Radius}
+ \li The radius for the bottom-right rounded corner of the outline.
+
+ \row
+ \li \b outline-top-left-radius
+ \li \l{#Radius}{Radius}
+ \li The radius for the top-left corner of the outline.
+
+ \row
+ \li \b outline-top-right-radius
+ \li \l{#Radius}{Radius}
+ \li The radius for the top-right rounded corner of the outline.
+
+
+ \row
\li \b{\c padding} \target padding-prop
\li \l{#Box Lengths}{Box Lengths}
\li The widget's padding. Equivalent to specifying \c
@@ -2981,7 +3029,7 @@
\li \b{Url} \target Url
\li \tt{url(\e{filename})}
\li \tt{\e{filename}} is the name of a file on the local disk
- or stored using \l{the Qt Resource System}. Setting an
+ or stored using \l{The Qt Resource System}. Setting an
image implicitly sets the width and height of the element.
\endtable
diff --git a/src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc b/src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc
index 7610174744..6e58fe4499 100644
--- a/src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc
+++ b/src/widgets/doc/src/windows-and-dialogs/mainwindow.qdoc
@@ -78,7 +78,7 @@
design ideas. Creating designs visually and reading the code generated by
\l{uic} is a great way to learn Qt!
- \keyword window geometry
+ \target window geometry
\section1 Window Geometry
QWidget provides several functions that deal with a widget's
@@ -226,7 +226,11 @@
We create a toolbar as a child of the main window, and add the desired
actions to it:
- \snippet mainwindows/sdi/mainwindow.cpp 0
+ \code
+ fileToolBar = addToolBar(tr("File"));
+ fileToolBar->addAction(newAct);
+ fileToolBar->addAction(openAct);
+ \endcode
\dots
\snippet code/doc_src_qt4-mainwindow.cpp 1
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
index f53804e494..5a97be3d96 100644
--- a/src/widgets/effects/qgraphicseffect.cpp
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -111,6 +111,10 @@
#ifndef QT_NO_GRAPHICSEFFECT
QT_BEGIN_NAMESPACE
+QGraphicsEffectPrivate::~QGraphicsEffectPrivate()
+{
+}
+
/*!
\internal
\class QGraphicsEffectSource
diff --git a/src/widgets/effects/qgraphicseffect.h b/src/widgets/effects/qgraphicseffect.h
index 678ece3dd2..c43b607d39 100644
--- a/src/widgets/effects/qgraphicseffect.h
+++ b/src/widgets/effects/qgraphicseffect.h
@@ -72,7 +72,7 @@ public:
PadToEffectiveBoundingRect
};
- QGraphicsEffect(QObject *parent = 0);
+ QGraphicsEffect(QObject *parent = Q_NULLPTR);
virtual ~QGraphicsEffect();
virtual QRectF boundingRectFor(const QRectF &sourceRect) const;
@@ -88,7 +88,7 @@ Q_SIGNALS:
void enabledChanged(bool enabled);
protected:
- QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0);
+ QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = Q_NULLPTR);
virtual void draw(QPainter *painter) = 0;
virtual void sourceChanged(ChangeFlags flags);
void updateBoundingRect();
@@ -97,7 +97,7 @@ protected:
QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const;
void drawSource(QPainter *painter);
QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
- QPoint *offset = 0,
+ QPoint *offset = Q_NULLPTR,
PixmapPadMode mode = PadToEffectiveBoundingRect) const;
private:
@@ -122,7 +122,7 @@ class Q_WIDGETS_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
public:
- QGraphicsColorizeEffect(QObject *parent = 0);
+ QGraphicsColorizeEffect(QObject *parent = Q_NULLPTR);
~QGraphicsColorizeEffect();
QColor color() const;
@@ -159,7 +159,7 @@ public:
};
Q_DECLARE_FLAGS(BlurHints, BlurHint)
- QGraphicsBlurEffect(QObject *parent = 0);
+ QGraphicsBlurEffect(QObject *parent = Q_NULLPTR);
~QGraphicsBlurEffect();
QRectF boundingRectFor(const QRectF &rect) const Q_DECL_OVERRIDE;
@@ -194,7 +194,7 @@ class Q_WIDGETS_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect
Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
public:
- QGraphicsDropShadowEffect(QObject *parent = 0);
+ QGraphicsDropShadowEffect(QObject *parent = Q_NULLPTR);
~QGraphicsDropShadowEffect();
QRectF boundingRectFor(const QRectF &rect) const Q_DECL_OVERRIDE;
@@ -247,7 +247,7 @@ class Q_WIDGETS_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged)
public:
- QGraphicsOpacityEffect(QObject *parent = 0);
+ QGraphicsOpacityEffect(QObject *parent = Q_NULLPTR);
~QGraphicsOpacityEffect();
qreal opacity() const;
diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h
index 6e990cc52e..35264c0d30 100644
--- a/src/widgets/effects/qgraphicseffect_p.h
+++ b/src/widgets/effects/qgraphicseffect_p.h
@@ -142,6 +142,7 @@ class Q_WIDGETS_EXPORT QGraphicsEffectPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QGraphicsEffect)
public:
QGraphicsEffectPrivate() : source(0), isEnabled(1) {}
+ ~QGraphicsEffectPrivate();
inline void setGraphicsEffectSource(QGraphicsEffectSource *newSource)
{
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.h b/src/widgets/graphicsview/qgraphicsanchorlayout.h
index 90406fe71f..2fdfe75be9 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.h
@@ -71,7 +71,7 @@ private:
class Q_WIDGETS_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout
{
public:
- QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = 0);
+ QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
virtual ~QGraphicsAnchorLayout();
QGraphicsAnchor *addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 8327777217..dac8e61645 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -751,9 +751,12 @@ static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph,
AnchorVertex *prev = before;
QVector<AnchorData *> edges;
+ edges.reserve(vertices.count() + 1);
+ const int numVertices = vertices.count();
+ edges.reserve(numVertices + 1);
// Take from the graph, the edges that will be simplificated
- for (int i = 0; i < vertices.count(); ++i) {
+ for (int i = 0; i < numVertices; ++i) {
AnchorVertex *next = vertices.at(i);
AnchorData *ad = graph->takeEdge(prev, next);
Q_ASSERT(ad);
@@ -2569,6 +2572,7 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
if (!remainingConstraints.isEmpty()) {
QList<QSimplexConstraint *> nonTrunkConstraints;
+ nonTrunkConstraints.reserve(remainingConstraints.size());
QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin();
while (it != remainingConstraints.end()) {
nonTrunkConstraints += *it;
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
index c0bb8ef63a..a5c7f1e2ce 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
@@ -317,6 +317,7 @@ public:
QSet<AnchorData *> positives;
QSet<AnchorData *> negatives;
};
+Q_DECLARE_TYPEINFO(GraphPath, Q_MOVABLE_TYPE);
class QGraphicsAnchorLayoutPrivate;
/*!
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.h b/src/widgets/graphicsview/qgraphicsgridlayout.h
index 90cc316025..f6aa3af91d 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayout.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.h
@@ -47,12 +47,12 @@ class QGraphicsGridLayoutPrivate;
class Q_WIDGETS_EXPORT QGraphicsGridLayout : public QGraphicsLayout
{
public:
- QGraphicsGridLayout(QGraphicsLayoutItem *parent = 0);
+ QGraphicsGridLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
virtual ~QGraphicsGridLayout();
void addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan,
- Qt::Alignment alignment = 0);
- inline void addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = 0);
+ Qt::Alignment alignment = Qt::Alignment());
+ inline void addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = Qt::Alignment());
void setHorizontalSpacing(qreal spacing);
qreal horizontalSpacing() const;
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 1332134000..5f5c402a4a 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -10832,9 +10832,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
range.start = 0;
range.length = layout.text().length();
range.format.setTextOutline(d->pen);
- QList<QTextLayout::FormatRange> formats;
- formats.append(range);
- layout.setAdditionalFormats(formats);
+ layout.setFormats(QVector<QTextLayout::FormatRange>(1, range));
}
setupTextLayout(&layout);
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index d3540beb77..b2f8fcbe74 100644
--- a/src/widgets/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
@@ -153,7 +153,7 @@ public:
SceneModal
};
- explicit QGraphicsItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsItem(QGraphicsItem *parent = Q_NULLPTR);
virtual ~QGraphicsItem();
QGraphicsScene *scene() const;
@@ -189,7 +189,7 @@ public:
PanelModality panelModality() const;
void setPanelModality(PanelModality panelModality);
- bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = 0) const;
+ bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = Q_NULLPTR) const;
#ifndef QT_NO_TOOLTIP
QString toolTip() const;
@@ -285,7 +285,7 @@ public:
QTransform transform() const;
QTransform sceneTransform() const;
QTransform deviceTransform(const QTransform &viewportTransform) const;
- QTransform itemTransform(const QGraphicsItem *other, bool *ok = 0) const;
+ QTransform itemTransform(const QGraphicsItem *other, bool *ok = Q_NULLPTR) const;
void setTransform(const QTransform &matrix, bool combine = false);
void resetTransform();
#if QT_DEPRECATED_SINCE(5, 0)
@@ -336,7 +336,7 @@ public:
void setBoundingRegionGranularity(qreal granularity);
// Drawing
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) = 0;
void update(const QRectF &rect = QRectF());
inline void update(qreal x, qreal y, qreal width, qreal height);
void scroll(qreal dx, qreal dy, const QRectF &rect = QRectF());
@@ -553,7 +553,7 @@ class Q_WIDGETS_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_CLASSINFO("DefaultProperty", "children")
Q_INTERFACES(QGraphicsItem)
public:
- explicit QGraphicsObject(QGraphicsItem *parent = 0);
+ explicit QGraphicsObject(QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsObject();
using QObject::children;
@@ -595,7 +595,7 @@ class QAbstractGraphicsShapeItemPrivate;
class Q_WIDGETS_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem
{
public:
- explicit QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0);
+ explicit QAbstractGraphicsShapeItem(QGraphicsItem *parent = Q_NULLPTR);
~QAbstractGraphicsShapeItem();
QPen pen() const;
@@ -620,8 +620,8 @@ class QGraphicsPathItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsPathItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsPathItem(QGraphicsItem *parent = 0);
- explicit QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0);
+ explicit QGraphicsPathItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsPathItem();
QPainterPath path() const;
@@ -631,7 +631,7 @@ public:
QPainterPath shape() const Q_DECL_OVERRIDE;
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
@@ -653,9 +653,9 @@ class QGraphicsRectItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsRectItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsRectItem(QGraphicsItem *parent = 0);
- explicit QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0);
- explicit QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0);
+ explicit QGraphicsRectItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsRectItem();
QRectF rect() const;
@@ -666,7 +666,7 @@ public:
QPainterPath shape() const Q_DECL_OVERRIDE;
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
@@ -691,9 +691,9 @@ class QGraphicsEllipseItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsEllipseItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsEllipseItem(QGraphicsItem *parent = 0);
- explicit QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0);
- explicit QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0);
+ explicit QGraphicsEllipseItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsEllipseItem();
QRectF rect() const;
@@ -710,7 +710,7 @@ public:
QPainterPath shape() const Q_DECL_OVERRIDE;
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
@@ -735,9 +735,9 @@ class QGraphicsPolygonItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsPolygonItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsPolygonItem(QGraphicsItem *parent = 0);
+ explicit QGraphicsPolygonItem(QGraphicsItem *parent = Q_NULLPTR);
explicit QGraphicsPolygonItem(const QPolygonF &polygon,
- QGraphicsItem *parent = 0);
+ QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsPolygonItem();
QPolygonF polygon() const;
@@ -750,7 +750,7 @@ public:
QPainterPath shape() const Q_DECL_OVERRIDE;
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
@@ -772,9 +772,9 @@ class QGraphicsLineItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsLineItem : public QGraphicsItem
{
public:
- explicit QGraphicsLineItem(QGraphicsItem *parent = 0);
- explicit QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0);
- explicit QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0);
+ explicit QGraphicsLineItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsLineItem();
QPen pen() const;
@@ -789,7 +789,7 @@ public:
QPainterPath shape() const Q_DECL_OVERRIDE;
bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
@@ -817,8 +817,8 @@ public:
HeuristicMaskShape
};
- explicit QGraphicsPixmapItem(QGraphicsItem *parent = 0);
- explicit QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0);
+ explicit QGraphicsPixmapItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsPixmapItem();
QPixmap pixmap() const;
@@ -869,8 +869,8 @@ class Q_WIDGETS_EXPORT QGraphicsTextItem : public QGraphicsObject
QDOC_PROPERTY(QTextCursor textCursor READ textCursor WRITE setTextCursor)
public:
- explicit QGraphicsTextItem(QGraphicsItem *parent = 0);
- explicit QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0);
+ explicit QGraphicsTextItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsTextItem(const QString &text, QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsTextItem();
QString toHtml() const;
@@ -960,8 +960,8 @@ class QGraphicsSimpleTextItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsSimpleTextItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsSimpleTextItem(QGraphicsItem *parent = 0);
- explicit QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0);
+ explicit QGraphicsSimpleTextItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsSimpleTextItem();
void setText(const QString &text);
@@ -996,14 +996,14 @@ class QGraphicsItemGroupPrivate;
class Q_WIDGETS_EXPORT QGraphicsItemGroup : public QGraphicsItem
{
public:
- explicit QGraphicsItemGroup(QGraphicsItem *parent = 0);
+ explicit QGraphicsItemGroup(QGraphicsItem *parent = Q_NULLPTR);
~QGraphicsItemGroup();
void addToGroup(QGraphicsItem *item);
void removeFromGroup(QGraphicsItem *item);
QRectF boundingRect() const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h
index bf788d2c39..fe4bac12bc 100644
--- a/src/widgets/graphicsview/qgraphicsitem_p.h
+++ b/src/widgets/graphicsview/qgraphicsitem_p.h
@@ -353,6 +353,7 @@ public:
}
struct ExtraStruct {
+ ExtraStruct() {} // for QVector, don't use
ExtraStruct(Extra type, QVariant value)
: type(type), value(value)
{ }
@@ -364,7 +365,7 @@ public:
{ return type < extra; }
};
- QList<ExtraStruct> extras;
+ QVector<ExtraStruct> extras;
QGraphicsItemCache *maybeExtraItemCache() const;
QGraphicsItemCache *extraItemCache() const;
@@ -584,6 +585,7 @@ public:
int globalStackingOrder;
QGraphicsItem *q_ptr;
};
+Q_DECLARE_TYPEINFO(QGraphicsItemPrivate::ExtraStruct, Q_MOVABLE_TYPE);
struct QGraphicsItemPrivate::TransformData
{
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
index 0a6fccf559..585539de94 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
@@ -116,7 +116,6 @@ public:
qreal step;
struct Pair {
- Pair(qreal a, qreal b) : step(a), value(b) {}
bool operator <(const Pair &other) const
{ return step < other.step; }
bool operator==(const Pair &other) const
@@ -124,21 +123,22 @@ public:
qreal step;
qreal value;
};
- QList<Pair> xPosition;
- QList<Pair> yPosition;
- QList<Pair> rotation;
- QList<Pair> verticalScale;
- QList<Pair> horizontalScale;
- QList<Pair> verticalShear;
- QList<Pair> horizontalShear;
- QList<Pair> xTranslation;
- QList<Pair> yTranslation;
-
- qreal linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue = 0);
- void insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method);
+ QVector<Pair> xPosition;
+ QVector<Pair> yPosition;
+ QVector<Pair> rotation;
+ QVector<Pair> verticalScale;
+ QVector<Pair> horizontalScale;
+ QVector<Pair> verticalShear;
+ QVector<Pair> horizontalShear;
+ QVector<Pair> xTranslation;
+ QVector<Pair> yTranslation;
+
+ qreal linearValueForStep(qreal step, QVector<Pair> *source, qreal defaultValue = 0);
+ void insertUniquePair(qreal step, qreal value, QVector<Pair> *binList, const char* method);
};
+Q_DECLARE_TYPEINFO(QGraphicsItemAnimationPrivate::Pair, Q_PRIMITIVE_TYPE);
-qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue)
+qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QVector<Pair> *source, qreal defaultValue)
{
if (source->isEmpty())
return defaultValue;
@@ -168,20 +168,18 @@ qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QList<Pair>
return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore));
}
-void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method)
+void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QVector<Pair> *binList, const char* method)
{
if (!check_step_valid(step, method))
return;
- Pair pair(step, value);
+ const Pair pair = { step, value };
- QList<Pair>::iterator result = std::lower_bound(binList->begin(), binList->end(), pair);
- if ((result != binList->end()) && !(pair < *result))
+ const QVector<Pair>::iterator result = std::lower_bound(binList->begin(), binList->end(), pair);
+ if (result == binList->end() || pair < *result)
+ binList->insert(result, pair);
+ else
result->value = value;
- else {
- *binList << pair;
- std::sort(binList->begin(), binList->end());
- }
}
/*!
@@ -284,7 +282,9 @@ void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &pos)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->xPosition.size(); ++i)
+ const int xPosCount = d->xPosition.size();
+ list.reserve(xPosCount);
+ for (int i = 0; i < xPosCount; ++i)
list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value));
return list;
@@ -338,7 +338,9 @@ void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle)
QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const
{
QList<QPair<qreal, qreal> > list;
- for (int i = 0; i < d->rotation.size(); ++i)
+ const int numRotations = d->rotation.size();
+ list.reserve(numRotations);
+ for (int i = 0; i < numRotations; ++i)
list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value);
return list;
@@ -386,7 +388,9 @@ void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->xTranslation.size(); ++i)
+ const int numTranslations = d->xTranslation.size();
+ list.reserve(numTranslations);
+ for (int i = 0; i < numTranslations; ++i)
list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));
return list;
@@ -435,7 +439,9 @@ void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->horizontalScale.size(); ++i)
+ const int numScales = d->horizontalScale.size();
+ list.reserve(numScales);
+ for (int i = 0; i < numScales; ++i)
list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value));
return list;
@@ -483,7 +489,9 @@ void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv)
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const
{
QList<QPair<qreal, QPointF> > list;
- for (int i = 0; i < d->horizontalShear.size(); ++i)
+ const int numShears = d->horizontalShear.size();
+ list.reserve(numShears);
+ for (int i = 0; i < numShears; ++i)
list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value));
return list;
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h
index 02a20f3f01..a54ba3a9e9 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.h
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.h
@@ -52,7 +52,7 @@ class Q_WIDGETS_EXPORT QGraphicsItemAnimation : public QObject
{
Q_OBJECT
public:
- QGraphicsItemAnimation(QObject *parent = 0);
+ QGraphicsItemAnimation(QObject *parent = Q_NULLPTR);
virtual ~QGraphicsItemAnimation();
QGraphicsItem *item() const;
diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h
index ebd90735f1..84a8d97943 100644
--- a/src/widgets/graphicsview/qgraphicslayout.h
+++ b/src/widgets/graphicsview/qgraphicslayout.h
@@ -48,7 +48,7 @@ class QGraphicsWidget;
class Q_WIDGETS_EXPORT QGraphicsLayout : public QGraphicsLayoutItem
{
public:
- QGraphicsLayout(QGraphicsLayoutItem *parent = 0);
+ QGraphicsLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
~QGraphicsLayout();
void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h
index 85b6d901f2..1608d79836 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem.h
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.h
@@ -48,7 +48,7 @@ class QGraphicsItem;
class Q_WIDGETS_EXPORT QGraphicsLayoutItem
{
public:
- QGraphicsLayoutItem(QGraphicsLayoutItem *parent = 0, bool isLayout = false);
+ QGraphicsLayoutItem(QGraphicsLayoutItem *parent = Q_NULLPTR, bool isLayout = false);
virtual ~QGraphicsLayoutItem();
void setSizePolicy(const QSizePolicy &policy);
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
index efdf6a595c..0384364ad4 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
@@ -512,7 +512,7 @@ void QGraphicsLinearLayout::setGeometry(const QRectF &rect)
d->engine.setGeometries(effectiveRect, d->styleInfo());
#ifdef QGRIDLAYOUTENGINE_DEBUG
if (qt_graphicsLayoutDebug()) {
- qDebug() << "post dump";
+ qDebug("post dump");
dump(1);
}
#endif
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.h b/src/widgets/graphicsview/qgraphicslinearlayout.h
index 997bff7da1..3232da22ca 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.h
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.h
@@ -47,8 +47,8 @@ class QGraphicsLinearLayoutPrivate;
class Q_WIDGETS_EXPORT QGraphicsLinearLayout : public QGraphicsLayout
{
public:
- QGraphicsLinearLayout(QGraphicsLayoutItem *parent = 0);
- QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = 0);
+ QGraphicsLinearLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
+ QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = Q_NULLPTR);
virtual ~QGraphicsLinearLayout();
void setOrientation(Qt::Orientation orientation);
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index db4d18299b..88bed7cf0e 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -269,8 +269,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
// Send mouse event.
QMouseEvent mouseEvent(type, pos, receiver->mapTo(receiver->topLevelWidget(), pos.toPoint()),
receiver->mapToGlobal(pos.toPoint()),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&mouseEvent, event->source());
+ event->button(), event->buttons(), event->modifiers(), event->source());
QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
@@ -880,6 +879,19 @@ bool QGraphicsProxyWidget::event(QEvent *event)
break;
}
#endif
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd: {
+ if (event->spontaneous())
+ qt_sendSpontaneousEvent(d->widget, event);
+ else
+ QApplication::sendEvent(d->widget, event);
+
+ if (event->isAccepted())
+ return true;
+
+ break;
+ }
default:
break;
}
@@ -1156,7 +1168,7 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::hoverMoveEvent";
+ qDebug("QGraphicsProxyWidget::hoverMoveEvent");
#endif
// Ignore events on the window frame.
if (!d->widget || !rect().contains(event->pos())) {
@@ -1196,7 +1208,7 @@ void QGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mouseMoveEvent";
+ qDebug("QGraphicsProxyWidget::mouseMoveEvent");
#endif
d->sendWidgetMouseEvent(event);
}
@@ -1208,7 +1220,7 @@ void QGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mousePressEvent";
+ qDebug("QGraphicsProxyWidget::mousePressEvent");
#endif
d->sendWidgetMouseEvent(event);
}
@@ -1220,7 +1232,7 @@ void QGraphicsProxyWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mouseDoubleClickEvent";
+ qDebug("QGraphicsProxyWidget::mouseDoubleClickEvent");
#endif
d->sendWidgetMouseEvent(event);
}
@@ -1233,7 +1245,7 @@ void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::wheelEvent";
+ qDebug("QGraphicsProxyWidget::wheelEvent");
#endif
if (!d->widget)
return;
@@ -1271,7 +1283,7 @@ void QGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mouseReleaseEvent";
+ qDebug("QGraphicsProxyWidget::mouseReleaseEvent");
#endif
d->sendWidgetMouseEvent(event);
}
@@ -1283,7 +1295,7 @@ void QGraphicsProxyWidget::keyPressEvent(QKeyEvent *event)
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::keyPressEvent";
+ qDebug("QGraphicsProxyWidget::keyPressEvent");
#endif
d->sendWidgetKeyEvent(event);
}
@@ -1295,7 +1307,7 @@ void QGraphicsProxyWidget::keyReleaseEvent(QKeyEvent *event)
{
Q_D(QGraphicsProxyWidget);
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::keyReleaseEvent";
+ qDebug("QGraphicsProxyWidget::keyReleaseEvent");
#endif
d->sendWidgetKeyEvent(event);
}
@@ -1306,7 +1318,7 @@ void QGraphicsProxyWidget::keyReleaseEvent(QKeyEvent *event)
void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
{
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::focusInEvent";
+ qDebug("QGraphicsProxyWidget::focusInEvent");
#endif
Q_D(QGraphicsProxyWidget);
@@ -1345,7 +1357,7 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
void QGraphicsProxyWidget::focusOutEvent(QFocusEvent *event)
{
#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::focusOutEvent";
+ qDebug("QGraphicsProxyWidget::focusOutEvent");
#endif
Q_D(QGraphicsProxyWidget);
if (d->widget) {
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h
index ae52f88f16..5a03a8a9dd 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.h
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.h
@@ -47,7 +47,7 @@ class Q_WIDGETS_EXPORT QGraphicsProxyWidget : public QGraphicsWidget
{
Q_OBJECT
public:
- QGraphicsProxyWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ QGraphicsProxyWidget(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags());
~QGraphicsProxyWidget();
void setWidget(QWidget *widget);
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget_p.h b/src/widgets/graphicsview/qgraphicsproxywidget_p.h
index 7b164a0067..c0e0d73aa9 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget_p.h
+++ b/src/widgets/graphicsview/qgraphicsproxywidget_p.h
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
-class QGraphicsProxyWidgetPrivate : public QGraphicsWidgetPrivate
+class Q_AUTOTEST_EXPORT QGraphicsProxyWidgetPrivate : public QGraphicsWidgetPrivate
{
Q_DECLARE_PUBLIC(QGraphicsProxyWidget)
public:
diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h
index 68382bf498..c93db20716 100644
--- a/src/widgets/graphicsview/qgraphicsscene.h
+++ b/src/widgets/graphicsview/qgraphicsscene.h
@@ -115,9 +115,9 @@ public:
};
Q_DECLARE_FLAGS(SceneLayers, SceneLayer)
- QGraphicsScene(QObject *parent = 0);
- QGraphicsScene(const QRectF &sceneRect, QObject *parent = 0);
- QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0);
+ QGraphicsScene(QObject *parent = Q_NULLPTR);
+ QGraphicsScene(const QRectF &sceneRect, QObject *parent = Q_NULLPTR);
+ QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = Q_NULLPTR);
virtual ~QGraphicsScene();
QRectF sceneRect() const;
@@ -192,7 +192,7 @@ public:
QGraphicsRectItem *addRect(const QRectF &rect, const QPen &pen = QPen(), const QBrush &brush = QBrush());
QGraphicsTextItem *addText(const QString &text, const QFont &font = QFont());
QGraphicsSimpleTextItem *addSimpleText(const QString &text, const QFont &font = QFont());
- QGraphicsProxyWidget *addWidget(QWidget *widget, Qt::WindowFlags wFlags = 0);
+ QGraphicsProxyWidget *addWidget(QWidget *widget, Qt::WindowFlags wFlags = Qt::WindowFlags());
inline QGraphicsEllipseItem *addEllipse(qreal x, qreal y, qreal w, qreal h, const QPen &pen = QPen(), const QBrush &brush = QBrush())
{ return addEllipse(QRectF(x, y, w, h), pen, brush); }
inline QGraphicsLineItem *addLine(qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen = QPen())
@@ -279,7 +279,7 @@ protected:
virtual void drawItems(QPainter *painter, int numItems,
QGraphicsItem *items[],
const QStyleOptionGraphicsItem options[],
- QWidget *widget = 0);
+ QWidget *widget = Q_NULLPTR);
protected Q_SLOTS:
// ### Qt 6: make unconditional
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h
index 1e3554fa36..ffa708ea23 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.h
+++ b/src/widgets/graphicsview/qgraphicssceneevent.h
@@ -40,7 +40,9 @@
#include <QtCore/qrect.h>
#include <QtGui/qpolygon.h>
#include <QtCore/qset.h>
+#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/graphicsview/qgraphicssceneindex.cpp b/src/widgets/graphicsview/qgraphicssceneindex.cpp
index 8662f73d64..a76f6b6565 100644
--- a/src/widgets/graphicsview/qgraphicssceneindex.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneindex.cpp
@@ -520,7 +520,9 @@ QList<QGraphicsItem *> QGraphicsSceneIndex::estimateTopLevelItems(const QRectF &
scened->ensureSortedTopLevelItems();
if (order == Qt::DescendingOrder) {
QList<QGraphicsItem *> sorted;
- for (int i = scened->topLevelItems.size() - 1; i >= 0; --i)
+ const int numTopLevelItems = scened->topLevelItems.size();
+ sorted.reserve(numTopLevelItems);
+ for (int i = numTopLevelItems - 1; i >= 0; --i)
sorted << scened->topLevelItems.at(i);
return sorted;
}
diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp
index 67564b5a8b..fe963fbf3c 100644
--- a/src/widgets/graphicsview/qgraphicstransform.cpp
+++ b/src/widgets/graphicsview/qgraphicstransform.cpp
@@ -89,6 +89,11 @@
#ifndef QT_NO_GRAPHICSVIEW
QT_BEGIN_NAMESPACE
+
+QGraphicsTransformPrivate::~QGraphicsTransformPrivate()
+{
+}
+
void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
{
if (item == i)
diff --git a/src/widgets/graphicsview/qgraphicstransform.h b/src/widgets/graphicsview/qgraphicstransform.h
index 4a7a3d0c0b..6fa76683f2 100644
--- a/src/widgets/graphicsview/qgraphicstransform.h
+++ b/src/widgets/graphicsview/qgraphicstransform.h
@@ -50,7 +50,7 @@ class Q_WIDGETS_EXPORT QGraphicsTransform : public QObject
{
Q_OBJECT
public:
- QGraphicsTransform(QObject *parent = 0);
+ QGraphicsTransform(QObject *parent = Q_NULLPTR);
~QGraphicsTransform();
virtual void applyTo(QMatrix4x4 *matrix) const = 0;
@@ -78,7 +78,7 @@ class Q_WIDGETS_EXPORT QGraphicsScale : public QGraphicsTransform
Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY yScaleChanged)
Q_PROPERTY(qreal zScale READ zScale WRITE setZScale NOTIFY zScaleChanged)
public:
- QGraphicsScale(QObject *parent = 0);
+ QGraphicsScale(QObject *parent = Q_NULLPTR);
~QGraphicsScale();
QVector3D origin() const;
@@ -116,7 +116,7 @@ class Q_WIDGETS_EXPORT QGraphicsRotation : public QGraphicsTransform
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged)
public:
- QGraphicsRotation(QObject *parent = 0);
+ QGraphicsRotation(QObject *parent = Q_NULLPTR);
~QGraphicsRotation();
QVector3D origin() const;
diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h
index dde085935f..c81a95fd3d 100644
--- a/src/widgets/graphicsview/qgraphicstransform_p.h
+++ b/src/widgets/graphicsview/qgraphicstransform_p.h
@@ -51,12 +51,14 @@ QT_BEGIN_NAMESPACE
class QGraphicsItem;
-class QGraphicsTransformPrivate : public QObjectPrivate {
+// ### Qt 6: unexport again, if QtQuick1's QDeclarativeTranslatePrivate is gone by then
+class Q_WIDGETS_EXPORT QGraphicsTransformPrivate : public QObjectPrivate {
public:
Q_DECLARE_PUBLIC(QGraphicsTransform)
QGraphicsTransformPrivate()
: QObjectPrivate(), item(0) {}
+ ~QGraphicsTransformPrivate();
QGraphicsItem *item;
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index c270c4be88..ac8cd45f9e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -362,6 +362,10 @@ QGraphicsViewPrivate::QGraphicsViewPrivate()
styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS);
}
+QGraphicsViewPrivate::~QGraphicsViewPrivate()
+{
+}
+
/*!
\internal
*/
@@ -2460,6 +2464,7 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const
QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const
{
QPolygonF poly;
+ poly.reserve(polygon.count());
foreach (const QPoint &point, polygon)
poly << mapToScene(point);
return poly;
@@ -2555,6 +2560,7 @@ QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const
QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const
{
QPolygon poly;
+ poly.reserve(polygon.count());
foreach (const QPointF &point, polygon)
poly << mapFromScene(point);
return poly;
@@ -2669,7 +2675,9 @@ void QGraphicsView::updateScene(const QList<QRectF> &rects)
// Extract and reset dirty scene rect info.
QVector<QRect> dirtyViewportRects;
const QVector<QRect> &dirtyRects = d->dirtyRegion.rects();
- for (int i = 0; i < dirtyRects.size(); ++i)
+ const int dirtyRectsCount = dirtyRects.size();
+ dirtyViewportRects.reserve(dirtyRectsCount + rects.count());
+ for (int i = 0; i < dirtyRectsCount; ++i)
dirtyViewportRects += dirtyRects.at(i);
d->dirtyRegion = QRegion();
d->dirtyBoundingRect = QRect();
diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h
index d426273d97..667fa76fe7 100644
--- a/src/widgets/graphicsview/qgraphicsview.h
+++ b/src/widgets/graphicsview/qgraphicsview.h
@@ -108,8 +108,8 @@ public:
};
Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)
- QGraphicsView(QWidget *parent = 0);
- QGraphicsView(QGraphicsScene *scene, QWidget *parent = 0);
+ QGraphicsView(QWidget *parent = Q_NULLPTR);
+ QGraphicsView(QGraphicsScene *scene, QWidget *parent = Q_NULLPTR);
~QGraphicsView();
QSize sizeHint() const Q_DECL_OVERRIDE;
@@ -230,7 +230,7 @@ protected Q_SLOTS:
void setupViewport(QWidget *widget) Q_DECL_OVERRIDE;
protected:
- QGraphicsView(QGraphicsViewPrivate &, QWidget *parent = 0);
+ QGraphicsView(QGraphicsViewPrivate &, QWidget *parent = Q_NULLPTR);
bool event(QEvent *event) Q_DECL_OVERRIDE;
bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE;
diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h
index fec8336695..dcbffb1c39 100644
--- a/src/widgets/graphicsview/qgraphicsview_p.h
+++ b/src/widgets/graphicsview/qgraphicsview_p.h
@@ -63,6 +63,7 @@ class Q_WIDGETS_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
Q_DECLARE_PUBLIC(QGraphicsView)
public:
QGraphicsViewPrivate();
+ ~QGraphicsViewPrivate();
void recalculateContentSize();
void centerView(QGraphicsView::ViewportAnchor anchor);
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index 6f10e2854c..8ffb60411c 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -304,6 +304,7 @@ void QGraphicsWidget::resize(const QSizeF &size)
/*!
\fn void QGraphicsWidget::resize(qreal w, qreal h)
+ \overload
This convenience function is equivalent to calling resize(QSizeF(w, h)).
@@ -2397,7 +2398,7 @@ bool QGraphicsWidget::close()
#if 0
void QGraphicsWidget::dumpFocusChain()
{
- qDebug() << "=========== Dumping focus chain ==============";
+ qDebug("=========== Dumping focus chain ==============");
int i = 0;
QGraphicsWidget *next = this;
QSet<QGraphicsWidget*> visited;
diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h
index 3ecdeac158..0878e020bc 100644
--- a/src/widgets/graphicsview/qgraphicswidget.h
+++ b/src/widgets/graphicsview/qgraphicswidget.h
@@ -74,7 +74,7 @@ class Q_WIDGETS_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphic
Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
Q_PROPERTY(QGraphicsLayout* layout READ layout WRITE setLayout NOTIFY layoutChanged)
public:
- QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ QGraphicsWidget(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags());
~QGraphicsWidget();
QGraphicsLayout *layout() const;
void setLayout(QGraphicsLayout *layout);
@@ -156,8 +156,8 @@ public:
};
int type() const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) Q_DECL_OVERRIDE;
- virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
+ virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR);
QRectF boundingRect() const Q_DECL_OVERRIDE;
QPainterPath shape() const Q_DECL_OVERRIDE;
@@ -213,7 +213,7 @@ protected:
virtual void ungrabMouseEvent(QEvent *event);
virtual void grabKeyboardEvent(QEvent *event);
virtual void ungrabKeyboardEvent(QEvent *event);
- QGraphicsWidget(QGraphicsWidgetPrivate &, QGraphicsItem *parent, Qt::WindowFlags wFlags = 0);
+ QGraphicsWidget(QGraphicsWidgetPrivate &, QGraphicsItem *parent, Qt::WindowFlags wFlags = Qt::WindowFlags());
private:
Q_DISABLE_COPY(QGraphicsWidget)
diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp
index 1aeade6640..b827ab1400 100644
--- a/src/widgets/graphicsview/qsimplex_p.cpp
+++ b/src/widgets/graphicsview/qsimplex_p.cpp
@@ -140,7 +140,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints)
// Remove constraints of type Var == K and replace them for their value.
if (!simplifyConstraints(&constraints)) {
- qWarning() << "QSimplex: No feasible solution!";
+ qWarning("QSimplex: No feasible solution!");
clearDataStructures();
return false;
}
@@ -230,7 +230,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints)
matrix = (qreal *)malloc(sizeof(qreal) * columns * rows);
if (!matrix) {
- qWarning() << "QSimplex: Unable to allocate memory!";
+ qWarning("QSimplex: Unable to allocate memory!");
return false;
}
for (int i = columns * rows - 1; i >= 0; --i)
@@ -281,7 +281,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints)
// Otherwise, we clean up our structures and report there is
// no feasible solution.
if ((valueAt(0, columns - 1) != 0.0) && (qAbs(valueAt(0, columns - 1)) > 0.00001)) {
- qWarning() << "QSimplex: No feasible solution!";
+ qWarning("QSimplex: No feasible solution!");
clearDataStructures();
return false;
}
@@ -471,7 +471,7 @@ bool QSimplex::iterate()
// Find Pivot row for column
int pivotRow = pivotRowForColumn(pivotColumn);
if (pivotRow == -1) {
- qWarning() << "QSimplex: Unbounded problem!";
+ qWarning("QSimplex: Unbounded problem!");
return false;
}
diff --git a/src/widgets/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri
index 2bbf7ac1ff..245962d35f 100644
--- a/src/widgets/itemviews/itemviews.pri
+++ b/src/widgets/itemviews/itemviews.pri
@@ -4,6 +4,7 @@ HEADERS += \
itemviews/qabstractitemview.h \
itemviews/qabstractitemview_p.h \
itemviews/qheaderview.h \
+ itemviews/qheaderview_p.h \
itemviews/qlistview.h \
itemviews/qlistview_p.h \
itemviews/qbsptree_p.h \
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index 6efe5ccb71..c2dd1ec8fd 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -455,6 +455,12 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev
if (editorHandlesKeyEvent(editor, keyEvent))
return false;
+ if (keyEvent->matches(QKeySequence::Cancel)) {
+ // don't commit data
+ emit q->closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
+ return true;
+ }
+
switch (keyEvent->key()) {
case Qt::Key_Tab:
if (tryFixup(editor)) {
@@ -479,10 +485,6 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev
QMetaObject::invokeMethod(q, "_q_commitDataAndCloseEditor",
Qt::QueuedConnection, Q_ARG(QWidget*, editor));
return false;
- case Qt::Key_Escape:
- // don't commit data
- emit q->closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
- return true;
default:
return false;
}
@@ -509,7 +511,7 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev
emit q->closeEditor(editor, QAbstractItemDelegate::NoHint);
}
} else if (event->type() == QEvent::ShortcutOverride) {
- if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
+ if (static_cast<QKeyEvent*>(event)->matches(QKeySequence::Cancel)) {
event->accept();
return true;
}
diff --git a/src/widgets/itemviews/qabstractitemdelegate.h b/src/widgets/itemviews/qabstractitemdelegate.h
index c250179087..b29717d1e1 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.h
+++ b/src/widgets/itemviews/qabstractitemdelegate.h
@@ -63,7 +63,7 @@ public:
RevertModelCache
};
- explicit QAbstractItemDelegate(QObject *parent = 0);
+ explicit QAbstractItemDelegate(QObject *parent = Q_NULLPTR);
virtual ~QAbstractItemDelegate();
// painting
@@ -113,7 +113,7 @@ Q_SIGNALS:
void sizeHintChanged(const QModelIndex &);
protected:
- QAbstractItemDelegate(QObjectPrivate &, QObject *parent = 0);
+ QAbstractItemDelegate(QObjectPrivate &, QObject *parent = Q_NULLPTR);
private:
Q_DECLARE_PRIVATE(QAbstractItemDelegate)
Q_DISABLE_COPY(QAbstractItemDelegate)
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 2caf5d1eb3..ad7be840d0 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1882,8 +1882,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
|| (d->pressedIndex != index)) {
QMouseEvent me(QEvent::MouseButtonPress,
event->localPos(), event->windowPos(), event->screenPos(),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&me, event->source());
+ event->button(), event->buttons(), event->modifiers(), event->source());
mousePressEvent(&me);
return;
}
@@ -2386,7 +2385,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
}
#endif
break;
-#ifdef Q_OS_MAC
+#ifdef Q_OS_OSX
case Qt::Key_Enter:
case Qt::Key_Return:
// Propagate the enter if you couldn't edit the item and there are no
@@ -2416,7 +2415,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
selectAll();
break;
}
-#ifdef Q_OS_MAC
+#ifdef Q_OS_OSX
if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) {
emit activated(currentIndex());
break;
@@ -2637,6 +2636,11 @@ void QAbstractItemView::updateEditorGeometries()
Q_D(QAbstractItemView);
if(d->editorIndexHash.isEmpty())
return;
+ if (d->delayedPendingLayout) {
+ // doItemsLayout() will end up calling this function again
+ d->executePostedLayout();
+ return;
+ }
QStyleOptionViewItem option = d->viewOptionsV1();
QEditorIndexHash::iterator it = d->editorIndexHash.begin();
QWidgetList editorsToRelease;
@@ -3017,13 +3021,12 @@ int QAbstractItemView::sizeHintForRow(int row) const
QStyleOptionViewItem option = d->viewOptionsV1();
int height = 0;
int colCount = d->model->columnCount(d->root);
- QModelIndex index;
for (int c = 0; c < colCount; ++c) {
- index = d->model->index(row, c, d->root);
+ const QModelIndex index = d->model->index(row, c, d->root);
if (QWidget *editor = d->editorForIndex(index).widget.data())
height = qMax(height, editor->height());
- int hint = d->delegateForIndex(index)->sizeHint(option, index).height();
- height = qMax(height, hint);
+ if (const QAbstractItemDelegate *delegate = d->delegateForIndex(index))
+ height = qMax(height, delegate->sizeHint(option, index).height());
}
return height;
}
@@ -3048,13 +3051,12 @@ int QAbstractItemView::sizeHintForColumn(int column) const
QStyleOptionViewItem option = d->viewOptionsV1();
int width = 0;
int rows = d->model->rowCount(d->root);
- QModelIndex index;
for (int r = 0; r < rows; ++r) {
- index = d->model->index(r, column, d->root);
+ const QModelIndex index = d->model->index(r, column, d->root);
if (QWidget *editor = d->editorForIndex(index).widget.data())
width = qMax(width, editor->sizeHint().width());
- int hint = d->delegateForIndex(index)->sizeHint(option, index).width();
- width = qMax(width, hint);
+ if (const QAbstractItemDelegate *delegate = d->delegateForIndex(index))
+ width = qMax(width, delegate->sizeHint(option, index).width());
}
return width;
}
diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h
index 1be17b6c0e..ff1848b149 100644
--- a/src/widgets/itemviews/qabstractitemview.h
+++ b/src/widgets/itemviews/qabstractitemview.h
@@ -115,7 +115,7 @@ public:
};
Q_ENUM(ScrollMode)
- explicit QAbstractItemView(QWidget *parent = 0);
+ explicit QAbstractItemView(QWidget *parent = Q_NULLPTR);
~QAbstractItemView();
virtual void setModel(QAbstractItemModel *model);
@@ -258,7 +258,7 @@ Q_SIGNALS:
void iconSizeChanged(const QSize &size);
protected:
- QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = 0);
+ QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = Q_NULLPTR);
void setHorizontalStepsPerItem(int steps);
int horizontalStepsPerItem() const;
@@ -283,7 +283,7 @@ protected:
virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
- const QEvent *event = 0) const;
+ const QEvent *event = Q_NULLPTR) const;
#ifndef QT_NO_DRAGANDDROP
virtual void startDrag(Qt::DropActions supportedActions);
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
index 016c50436b..bb88b25652 100644
--- a/src/widgets/itemviews/qabstractitemview_p.h
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -74,7 +74,7 @@ typedef QHash<QWidget *, QPersistentModelIndex> QEditorIndexHash;
typedef QHash<QPersistentModelIndex, QEditorInfo> QIndexEditorHash;
typedef QPair<QRect, QModelIndex> QItemViewPaintPair;
-typedef QList<QItemViewPaintPair> QItemViewPaintPairs;
+typedef QVector<QItemViewPaintPair> QItemViewPaintPairs;
class QEmptyModel : public QAbstractItemModel
{
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index 5c317bbb0c..92bbdf6b69 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -861,11 +861,15 @@ void QColumnView::setColumnWidths(const QList<int> &list)
{
Q_D(QColumnView);
int i = 0;
- for (; (i < list.count() && i < d->columns.count()); ++i) {
+ const int listCount = list.count();
+ const int count = qMin(listCount, d->columns.count());
+ for (; i < count; ++i) {
d->columns.at(i)->resize(list.at(i), d->columns.at(i)->height());
d->columnSizes[i] = list.at(i);
}
- for (; i < list.count(); ++i)
+
+ d->columnSizes.reserve(listCount);
+ for (; i < listCount; ++i)
d->columnSizes.append(list.at(i));
}
@@ -878,7 +882,9 @@ QList<int> QColumnView::columnWidths() const
{
Q_D(const QColumnView);
QList<int> list;
- for (int i = 0; i < d->columns.count(); ++i)
+ const int columnCount = d->columns.count();
+ list.reserve(columnCount);
+ for (int i = 0; i < columnCount; ++i)
list.append(d->columnSizes.at(i));
return list;
}
diff --git a/src/widgets/itemviews/qcolumnview.h b/src/widgets/itemviews/qcolumnview.h
index 792ae04eb6..58472ddd8e 100644
--- a/src/widgets/itemviews/qcolumnview.h
+++ b/src/widgets/itemviews/qcolumnview.h
@@ -52,7 +52,7 @@ Q_SIGNALS:
void updatePreviewWidget(const QModelIndex &index);
public:
- explicit QColumnView(QWidget *parent = 0);
+ explicit QColumnView(QWidget *parent = Q_NULLPTR);
~QColumnView();
// QAbstractItemView overloads
@@ -76,7 +76,7 @@ public:
QList<int> columnWidths() const;
protected:
- QColumnView(QColumnViewPrivate &dd, QWidget *parent = 0);
+ QColumnView(QColumnViewPrivate &dd, QWidget *parent = Q_NULLPTR);
// QAbstractItemView overloads
bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp
index c9fdf9967a..ee7b3613a2 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.cpp
+++ b/src/widgets/itemviews/qdatawidgetmapper.cpp
@@ -756,7 +756,7 @@ void QDataWidgetMapper::clearMapping()
QList<QDataWidgetMapperPrivate::WidgetMapper> copy;
d->widgetMap.swap(copy); // a C++98 move
- for (std::reverse_iterator<QList<QDataWidgetMapperPrivate::WidgetMapper>::const_iterator> it(copy.cend()), end(copy.cbegin()); it != end; ++it) {
+ for (QList<QDataWidgetMapperPrivate::WidgetMapper>::const_reverse_iterator it = copy.crbegin(), end = copy.crend(); it != end; ++it) {
if (it->widget)
it->widget->removeEventFilter(d->delegate);
}
diff --git a/src/widgets/itemviews/qdatawidgetmapper.h b/src/widgets/itemviews/qdatawidgetmapper.h
index 5ccbee4d68..4dd5e0e14c 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.h
+++ b/src/widgets/itemviews/qdatawidgetmapper.h
@@ -55,7 +55,7 @@ class Q_WIDGETS_EXPORT QDataWidgetMapper: public QObject
Q_PROPERTY(SubmitPolicy submitPolicy READ submitPolicy WRITE setSubmitPolicy)
public:
- explicit QDataWidgetMapper(QObject *parent = 0);
+ explicit QDataWidgetMapper(QObject *parent = Q_NULLPTR);
~QDataWidgetMapper();
void setModel(QAbstractItemModel *model);
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index 50406b51f4..0c157c940f 100644
--- a/src/widgets/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
@@ -66,7 +66,6 @@ public:
struct QDirNode
{
QDirNode() : parent(0), populated(false), stat(false) {}
- ~QDirNode() { children.clear(); }
QDirNode *parent;
QFileInfo info;
QIcon icon; // cache the icon
diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h
index dcc337244c..536e5299a2 100644
--- a/src/widgets/itemviews/qdirmodel.h
+++ b/src/widgets/itemviews/qdirmodel.h
@@ -60,8 +60,8 @@ public:
};
QDirModel(const QStringList &nameFilters, QDir::Filters filters,
- QDir::SortFlags sort, QObject *parent = 0);
- explicit QDirModel(QObject *parent = 0);
+ QDir::SortFlags sort, QObject *parent = Q_NULLPTR);
+ explicit QDirModel(QObject *parent = Q_NULLPTR);
~QDirModel();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
@@ -127,7 +127,7 @@ public Q_SLOTS:
void refresh(const QModelIndex &parent = QModelIndex());
protected:
- QDirModel(QDirModelPrivate &, QObject *parent = 0);
+ QDirModel(QDirModelPrivate &, QObject *parent = Q_NULLPTR);
friend class QFileDialogPrivate;
private:
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index 051cb8e7cc..f43bcd5d5a 100644
--- a/src/widgets/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
@@ -117,6 +117,7 @@ public:
if (themeSizes.isEmpty())
return sizes;
+ sizes.reserve(themeSizes.count());
foreach (int size, themeSizes)
sizes << QSize(size, size);
}
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 4cb28d0804..338627c79f 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2608,10 +2608,12 @@ bool QHeaderView::viewportEvent(QEvent *e)
}
return true; }
#endif // QT_NO_STATUSTIP
- case QEvent::Hide:
- case QEvent::Show:
case QEvent::FontChange:
- case QEvent::StyleChange:{
+ case QEvent::StyleChange:
+ d->invalidateCachedSizeHint();
+ // Fall through
+ case QEvent::Hide:
+ case QEvent::Show: {
QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea *>(parentWidget());
if (parent && parent->isVisible()) // Only resize if we have a visible parent
resizeSections();
diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h
index e0f57130c0..d892614a39 100644
--- a/src/widgets/itemviews/qheaderview.h
+++ b/src/widgets/itemviews/qheaderview.h
@@ -68,7 +68,7 @@ public:
};
Q_ENUM(ResizeMode)
- explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = 0);
+ explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
virtual ~QHeaderView();
void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
@@ -202,7 +202,7 @@ protected Q_SLOTS:
void sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast);
protected:
- QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = 0);
+ QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
void initialize();
void initializeSections();
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
index 621c3c990e..7f92d2a81b 100644
--- a/src/widgets/itemviews/qheaderview_p.h
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -369,6 +369,7 @@ public:
#endif
};
+Q_DECLARE_TYPEINFO(QHeaderViewPrivate::SectionItem, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
diff --git a/src/widgets/itemviews/qitemdelegate.h b/src/widgets/itemviews/qitemdelegate.h
index edc224b0f3..beba6b90fb 100644
--- a/src/widgets/itemviews/qitemdelegate.h
+++ b/src/widgets/itemviews/qitemdelegate.h
@@ -53,7 +53,7 @@ class Q_WIDGETS_EXPORT QItemDelegate : public QAbstractItemDelegate
Q_PROPERTY(bool clipping READ hasClipping WRITE setClipping)
public:
- explicit QItemDelegate(QObject *parent = 0);
+ explicit QItemDelegate(QObject *parent = Q_NULLPTR);
~QItemDelegate();
bool hasClipping() const;
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 8257944821..9c79509874 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
/*!
\class QListView
@@ -796,6 +798,35 @@ void QListView::mouseReleaseEvent(QMouseEvent *e)
}
}
+#ifndef QT_NO_WHEELEVENT
+/*!
+ \reimp
+*/
+void QListView::wheelEvent(QWheelEvent *e)
+{
+ Q_D(QListView);
+ if (e->orientation() == Qt::Vertical) {
+ if (e->angleDelta().x() == 0
+ && ((d->flow == TopToBottom && d->wrap) || (d->flow == LeftToRight && !d->wrap))
+ && d->vbar->minimum() == 0 && d->vbar->maximum() == 0) {
+ QPoint pixelDelta(e->pixelDelta().y(), e->pixelDelta().x());
+ QPoint angleDelta(e->angleDelta().y(), e->angleDelta().x());
+ QWheelEvent hwe(e->pos(), e->globalPos(), pixelDelta, angleDelta, e->delta(),
+ Qt::Horizontal, e->buttons(), e->modifiers(), e->phase());
+ if (e->spontaneous())
+ qt_sendSpontaneousEvent(d->hbar, &hwe);
+ else
+ QApplication::sendEvent(d->hbar, &hwe);
+ e->setAccepted(hwe.isAccepted());
+ } else {
+ QApplication::sendEvent(d->vbar, e);
+ }
+ } else {
+ QApplication::sendEvent(d->hbar, e);
+ }
+}
+#endif // QT_NO_WHEELEVENT
+
/*!
\reimp
*/
diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h
index f62c96067f..433933b500 100644
--- a/src/widgets/itemviews/qlistview.h
+++ b/src/widgets/itemviews/qlistview.h
@@ -72,7 +72,7 @@ public:
enum ViewMode { ListMode, IconMode };
Q_ENUM(ViewMode)
- explicit QListView(QWidget *parent = 0);
+ explicit QListView(QWidget *parent = Q_NULLPTR);
~QListView();
void setMovement(Movement movement);
@@ -131,7 +131,7 @@ Q_SIGNALS:
void indexesMoved(const QModelIndexList &indexes);
protected:
- QListView(QListViewPrivate &, QWidget *parent = 0);
+ QListView(QListViewPrivate &, QWidget *parent = Q_NULLPTR);
bool event(QEvent *e) Q_DECL_OVERRIDE;
@@ -146,6 +146,9 @@ protected:
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+#endif
void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h
index fe059d73dd..62fa45e640 100644
--- a/src/widgets/itemviews/qlistview_p.h
+++ b/src/widgets/itemviews/qlistview_p.h
@@ -93,6 +93,7 @@ private:
mutable int indexHint;
uint visited;
};
+Q_DECLARE_TYPEINFO(QListViewItem, Q_PRIMITIVE_TYPE);
struct QListViewLayoutInfo
{
@@ -105,6 +106,7 @@ struct QListViewLayoutInfo
QListView::Flow flow;
int max;
};
+Q_DECLARE_TYPEINFO(QListViewLayoutInfo, Q_PRIMITIVE_TYPE);
class QListView;
class QListViewPrivate;
@@ -291,7 +293,7 @@ private:
};
-class QListViewPrivate: public QAbstractItemViewPrivate
+class Q_AUTOTEST_EXPORT QListViewPrivate: public QAbstractItemViewPrivate
{
Q_DECLARE_PUBLIC(QListView)
public:
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 66f965aa54..d4d22c8bef 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -299,7 +299,10 @@ void QListModel::sort(int column, Qt::SortOrder order)
std::sort(sorting.begin(), sorting.end(), compare);
QModelIndexList fromIndexes;
QModelIndexList toIndexes;
- for (int r = 0; r < sorting.count(); ++r) {
+ const int sortingCount = sorting.count();
+ fromIndexes.reserve(sortingCount);
+ toIndexes.reserve(sortingCount);
+ for (int r = 0; r < sortingCount; ++r) {
QListWidgetItem *item = sorting.at(r).first;
toIndexes.append(createIndex(r, 0, item));
fromIndexes.append(createIndex(sorting.at(r).second, 0, sorting.at(r).first));
@@ -423,7 +426,9 @@ QMimeData *QListModel::internalMimeData() const
QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const
{
QList<QListWidgetItem*> itemlist;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ itemlist.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
itemlist << at(indexes.at(i).row());
const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent());
@@ -1257,7 +1262,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
activated when the user clicks or double clicks on it, depending on the
system configuration. It is also activated when the user presses the
activation key (on Windows and X11 this is the \uicontrol Return key, on Mac OS
- X it is \uicontrol{Ctrl+0}).
+ X it is \uicontrol{Command+O}).
*/
/*!
@@ -1694,7 +1699,9 @@ QList<QListWidgetItem*> QListWidget::selectedItems() const
Q_D(const QListWidget);
QModelIndexList indexes = selectionModel()->selectedIndexes();
QList<QListWidgetItem*> items;
- for (int i = 0; i < indexes.count(); ++i)
+ const int numIndexes = indexes.count();
+ items.reserve(numIndexes);
+ for (int i = 0; i < numIndexes; ++i)
items.append(d->listModel()->at(indexes.at(i).row()));
return items;
}
@@ -1710,7 +1717,9 @@ QList<QListWidgetItem*> QListWidget::findItems(const QString &text, Qt::MatchFla
QModelIndexList indexes = d->listModel()->match(model()->index(0, 0, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QListWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexesSize = indexes.size();
+ items.reserve(indexesSize);
+ for (int i = 0; i < indexesSize; ++i)
items.append(d->listModel()->at(indexes.at(i).row()));
return items;
}
@@ -1795,6 +1804,7 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
+ cachedIndexes.reserve(items.count());
foreach (QListWidgetItem *item, items)
cachedIndexes << indexFromItem(item);
@@ -1845,7 +1855,9 @@ void QListWidget::dropEvent(QDropEvent *event) {
if (d->dropOn(event, &row, &col, &topIndex)) {
QList<QModelIndex> selIndexes = selectedIndexes();
QList<QPersistentModelIndex> persIndexes;
- for (int i = 0; i < selIndexes.count(); i++)
+ const int selIndexesCount = selIndexes.count();
+ persIndexes.reserve(selIndexesCount);
+ for (int i = 0; i < selIndexesCount; i++)
persIndexes.append(selIndexes.at(i));
if (persIndexes.contains(topIndex))
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
index 8ab864c930..1fbdc472db 100644
--- a/src/widgets/itemviews/qlistwidget.h
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -55,10 +55,10 @@ class Q_WIDGETS_EXPORT QListWidgetItem
friend class QListWidget;
public:
enum ItemType { Type = 0, UserType = 1000 };
- explicit QListWidgetItem(QListWidget *view = 0, int type = Type);
- explicit QListWidgetItem(const QString &text, QListWidget *view = 0, int type = Type);
+ explicit QListWidgetItem(QListWidget *view = Q_NULLPTR, int type = Type);
+ explicit QListWidgetItem(const QString &text, QListWidget *view = Q_NULLPTR, int type = Type);
explicit QListWidgetItem(const QIcon &icon, const QString &text,
- QListWidget *view = 0, int type = Type);
+ QListWidget *view = Q_NULLPTR, int type = Type);
QListWidgetItem(const QListWidgetItem &other);
virtual ~QListWidgetItem();
@@ -198,7 +198,7 @@ class Q_WIDGETS_EXPORT QListWidget : public QListView
friend class QListWidgetItem;
friend class QListModel;
public:
- explicit QListWidget(QWidget *parent = 0);
+ explicit QListWidget(QWidget *parent = Q_NULLPTR);
~QListWidget();
QListWidgetItem *item(int row) const;
@@ -299,7 +299,7 @@ private:
};
inline void QListWidget::removeItemWidget(QListWidgetItem *aItem)
-{ setItemWidget(aItem, 0); }
+{ setItemWidget(aItem, Q_NULLPTR); }
inline void QListWidget::addItem(QListWidgetItem *aitem)
{ insertItem(count(), aitem); }
diff --git a/src/widgets/itemviews/qstyleditemdelegate.h b/src/widgets/itemviews/qstyleditemdelegate.h
index 590ddf6614..541830239a 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.h
+++ b/src/widgets/itemviews/qstyleditemdelegate.h
@@ -52,7 +52,7 @@ class Q_WIDGETS_EXPORT QStyledItemDelegate : public QAbstractItemDelegate
Q_OBJECT
public:
- explicit QStyledItemDelegate(QObject *parent = 0);
+ explicit QStyledItemDelegate(QObject *parent = Q_NULLPTR);
~QStyledItemDelegate();
// painting
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index ae31387faf..ee0d41ce15 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -190,7 +190,7 @@ QList<QSpanCollection::Span *> QSpanCollection::spansInRect(int x, int y, int w,
#ifdef DEBUG_SPAN_UPDATE
QDebug operator<<(QDebug str, const QSpanCollection::Span &span)
{
- str << "(" << span.top() << "," << span.left() << "," << span.bottom() << "," << span.right() << ")";
+ str << '(' << span.top() << ',' << span.left() << ',' << span.bottom() << ',' << span.right() << ')';
return str;
}
#endif
@@ -201,9 +201,7 @@ QDebug operator<<(QDebug str, const QSpanCollection::Span &span)
void QSpanCollection::updateInsertedRows(int start, int end)
{
#ifdef DEBUG_SPAN_UPDATE
- qDebug() << Q_FUNC_INFO;
- qDebug() << start << end;
- qDebug() << index;
+ qDebug() << start << end << endl << index;
#endif
if (spans.isEmpty())
return;
@@ -251,9 +249,7 @@ void QSpanCollection::updateInsertedRows(int start, int end)
void QSpanCollection::updateInsertedColumns(int start, int end)
{
#ifdef DEBUG_SPAN_UPDATE
- qDebug() << Q_FUNC_INFO;
- qDebug() << start << end;
- qDebug() << index;
+ qDebug() << start << end << endl << index;
#endif
if (spans.isEmpty())
return;
@@ -334,9 +330,7 @@ bool QSpanCollection::cleanSpanSubIndex(QSpanCollection::SubIndex &subindex, int
void QSpanCollection::updateRemovedRows(int start, int end)
{
#ifdef DEBUG_SPAN_UPDATE
- qDebug() << Q_FUNC_INFO;
- qDebug() << start << end;
- qDebug() << index;
+ qDebug() << start << end << endl << index;
#endif
if (spans.isEmpty())
return;
@@ -463,9 +457,7 @@ void QSpanCollection::updateRemovedRows(int start, int end)
void QSpanCollection::updateRemovedColumns(int start, int end)
{
#ifdef DEBUG_SPAN_UPDATE
- qDebug() << Q_FUNC_INFO;
- qDebug() << start << end;
- qDebug() << index;
+ qDebug() << start << end << endl << index;
#endif
if (spans.isEmpty())
return;
@@ -670,13 +662,14 @@ void QTableViewPrivate::trimHiddenSelections(QItemSelectionRange *range) const
void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan)
{
if (row < 0 || column < 0 || rowSpan <= 0 || columnSpan <= 0) {
- qWarning() << "QTableView::setSpan: invalid span given: (" << row << ',' << column << ',' << rowSpan << ',' << columnSpan << ')';
+ qWarning("QTableView::setSpan: invalid span given: (%d, %d, %d, %d)",
+ row, column, rowSpan, columnSpan);
return;
}
QSpanCollection::Span *sp = spans.spanAt(column, row);
if (sp) {
if (sp->top() != row || sp->left() != column) {
- qWarning() << "QTableView::setSpan: span cannot overlap";
+ qWarning("QTableView::setSpan: span cannot overlap");
return;
}
if (rowSpan == 1 && columnSpan == 1) {
@@ -688,7 +681,7 @@ void QTableViewPrivate::setSpan(int row, int column, int rowSpan, int columnSpan
spans.updateSpan(sp, old_height);
return;
} else if (rowSpan == 1 && columnSpan == 1) {
- qWarning() << "QTableView::setSpan: single cell span won't be added";
+ qWarning("QTableView::setSpan: single cell span won't be added");
return;
}
sp = new QSpanCollection::Span(row, column, rowSpan, columnSpan);
@@ -1884,6 +1877,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
break;
}
} while (expanded);
+ selection.reserve((right - left + 1) * (bottom - top + 1));
for (int horizontal = left; horizontal <= right; ++horizontal) {
int column = d->logicalColumn(horizontal);
for (int vertical = top; vertical <= bottom; ++vertical) {
@@ -1897,6 +1891,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
int left = d->visualColumn(tl.column());
int bottom = d->visualRow(br.row());
int right = d->visualColumn(br.column());
+ selection.reserve((right - left + 1) * (bottom - top + 1));
for (int horizontal = left; horizontal <= right; ++horizontal) {
int column = d->logicalColumn(horizontal);
for (int vertical = top; vertical <= bottom; ++vertical) {
@@ -1908,6 +1903,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
} else if (horizontalMoved) {
int left = d->visualColumn(tl.column());
int right = d->visualColumn(br.column());
+ selection.reserve(right - left + 1);
for (int visual = left; visual <= right; ++visual) {
int column = d->logicalColumn(visual);
QModelIndex topLeft = d->model->index(tl.row(), column, d->root);
@@ -1917,6 +1913,7 @@ void QTableView::setSelection(const QRect &rect, QItemSelectionModel::SelectionF
} else if (verticalMoved) {
int top = d->visualRow(tl.row());
int bottom = d->visualRow(br.row());
+ selection.reserve(bottom - top + 1);
for (int visual = top; visual <= bottom; ++visual) {
int row = d->logicalRow(visual);
QModelIndex topLeft = d->model->index(row, tl.column(), d->root);
@@ -2540,7 +2537,7 @@ void QTableView::setColumnHidden(int column, bool hide)
*/
/*!
- If \a enabled true enables sorting for the table and immediately
+ If \a enable is true, enables sorting for the table and immediately
trigger a call to sortByColumn() with the current sort section and
order
*/
diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h
index d69b78c6fe..1bb23844cc 100644
--- a/src/widgets/itemviews/qtableview.h
+++ b/src/widgets/itemviews/qtableview.h
@@ -54,7 +54,7 @@ class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView
Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
public:
- explicit QTableView(QWidget *parent = 0);
+ explicit QTableView(QWidget *parent = Q_NULLPTR);
~QTableView();
void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 9ebcbc35a7..cd38f4b282 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -507,11 +507,15 @@ void QTableModel::sort(int column, Qt::SortOrder order)
QVector<QTableWidgetItem*> sorted_table(tableItems.count());
QModelIndexList from;
QModelIndexList to;
- for (int i = 0; i < rowCount(); ++i) {
+ const int numRows = rowCount();
+ const int numColumns = columnCount();
+ from.reserve(numRows * numColumns);
+ to.reserve(numRows * numColumns);
+ for (int i = 0; i < numRows; ++i) {
int r = (i < sortable.count()
? sortable.at(i).second
: unsortable.at(i - sortable.count()));
- for (int c = 0; c < columnCount(); ++c) {
+ for (int c = 0; c < numColumns; ++c) {
sorted_table[tableIndex(i, c)] = item(r, c);
from.append(createIndex(r, c));
to.append(createIndex(i, c));
@@ -551,9 +555,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan);
std::stable_sort(sorting.begin(), sorting.end(), compare);
-
- QModelIndexList oldPersistentIndexes = persistentIndexList();
- QModelIndexList newPersistentIndexes = oldPersistentIndexes;
+ QModelIndexList oldPersistentIndexes, newPersistentIndexes;
QVector<QTableWidgetItem*> newTable = tableItems;
QVector<QTableWidgetItem*> newVertical = verticalHeaderItems;
QVector<QTableWidgetItem*> colItems = columnItems(column);
@@ -569,7 +571,12 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
newRow = oldRow;
vit = colItems.insert(vit, item);
if (newRow != oldRow) {
- changed = true;
+ if (!changed) {
+ emit layoutAboutToBeChanged();
+ oldPersistentIndexes = persistentIndexList();
+ newPersistentIndexes = oldPersistentIndexes;
+ changed = true;
+ }
// move the items @ oldRow to newRow
int cc = columnCount();
QVector<QTableWidgetItem*> rowItems(cc);
@@ -596,7 +603,6 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
}
if (changed) {
- emit layoutAboutToBeChanged();
tableItems = newTable;
verticalHeaderItems = newVertical;
changePersistentIndexList(oldPersistentIndexes,
@@ -812,7 +818,9 @@ QMimeData *QTableModel::internalMimeData() const
QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const
{
QList<QTableWidgetItem*> items;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ items.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
items << item(indexes.at(i));
const QTableWidget *view = qobject_cast<const QTableWidget*>(QObject::parent());
@@ -2021,6 +2029,8 @@ QTableWidgetItem *QTableWidget::horizontalHeaderItem(int column) const
/*!
Sets the horizontal header item for column \a column to \a item.
+ If necessary, the column count is increased to fit the item.
+ The previous header item (if there was one) is deleted.
*/
void QTableWidget::setHorizontalHeaderItem(int column, QTableWidgetItem *item)
{
@@ -2326,7 +2336,9 @@ QList<QTableWidgetSelectionRange> QTableWidget::selectedRanges() const
{
const QList<QItemSelectionRange> ranges = selectionModel()->selection();
QList<QTableWidgetSelectionRange> result;
- for (int i = 0; i < ranges.count(); ++i)
+ const int rangesCount = ranges.count();
+ result.reserve(rangesCount);
+ for (int i = 0; i < rangesCount; ++i)
result.append(QTableWidgetSelectionRange(ranges.at(i).top(),
ranges.at(i).left(),
ranges.at(i).bottom(),
@@ -2372,7 +2384,9 @@ QList<QTableWidgetItem*> QTableWidget::findItems(const QString &text, Qt::MatchF
indexes += d->model->match(model()->index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QTableWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexCount = indexes.size();
+ items.reserve(indexCount);
+ for (int i = 0; i < indexCount; ++i)
items.append(d->tableModel()->item(indexes.at(i)));
return items;
}
@@ -2565,6 +2579,7 @@ QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem*> items) const
// if non empty, it's called from the model's own mimeData
if (cachedIndexes.isEmpty()) {
+ cachedIndexes.reserve(items.count());
foreach (QTableWidgetItem *item, items)
cachedIndexes << indexFromItem(item);
@@ -2676,7 +2691,9 @@ void QTableWidget::dropEvent(QDropEvent *event) {
}
QList<QTableWidgetItem *> taken;
- for (int i = 0; i < indexes.count(); ++i)
+ const int indexesCount = indexes.count();
+ taken.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; ++i)
taken.append(takeItem(indexes.at(i).row(), indexes.at(i).column()));
for (int i = 0; i < indexes.count(); ++i) {
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index 93639f0753..9acdc19863 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -214,8 +214,8 @@ class Q_WIDGETS_EXPORT QTableWidget : public QTableView
friend class QTableModel;
public:
- explicit QTableWidget(QWidget *parent = 0);
- QTableWidget(int rows, int columns, QWidget *parent = 0);
+ explicit QTableWidget(QWidget *parent = Q_NULLPTR);
+ QTableWidget(int rows, int columns, QWidget *parent = Q_NULLPTR);
~QTableWidget();
void setRowCount(int rows);
@@ -344,7 +344,7 @@ private:
};
inline void QTableWidget::removeCellWidget(int arow, int acolumn)
-{ setCellWidget(arow, acolumn, 0); }
+{ setCellWidget(arow, acolumn, Q_NULLPTR); }
inline QTableWidgetItem *QTableWidget::itemAt(int ax, int ay) const
{ return itemAt(QPoint(ax, ay)); }
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index e9e2e78e17..546cc488cb 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -60,7 +60,7 @@ class Q_WIDGETS_EXPORT QTreeView : public QAbstractItemView
Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick)
public:
- explicit QTreeView(QWidget *parent = 0);
+ explicit QTreeView(QWidget *parent = Q_NULLPTR);
~QTreeView();
void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
@@ -163,7 +163,7 @@ protected Q_SLOTS:
void rowsRemoved(const QModelIndex &parent, int first, int last);
protected:
- QTreeView(QTreeViewPrivate &dd, QWidget *parent = 0);
+ QTreeView(QTreeViewPrivate &dd, QWidget *parent = Q_NULLPTR);
void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
void rowsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index bf736bc387..676893ebf0 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -1720,12 +1720,12 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value)
}
} break;
case Qt::CheckStateRole:
- if ((itemFlags & Qt::ItemIsTristate) && value != Qt::PartiallyChecked) {
+ if ((itemFlags & Qt::ItemIsAutoTristate) && value != Qt::PartiallyChecked) {
for (int i = 0; i < children.count(); ++i) {
QTreeWidgetItem *child = children.at(i);
if (child->data(column, role).isValid()) {// has a CheckState
Qt::ItemFlags f = itemFlags; // a little hack to avoid multiple dataChanged signals
- itemFlags &= ~Qt::ItemIsTristate;
+ itemFlags &= ~Qt::ItemIsAutoTristate;
child->setData(column, role, value);
itemFlags = f;
}
@@ -1760,7 +1760,7 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value)
model->emitDataChanged(this, column);
if (role == Qt::CheckStateRole) {
QTreeWidgetItem *p;
- for (p = par; p && (p->itemFlags & Qt::ItemIsTristate); p = p->par)
+ for (p = par; p && (p->itemFlags & Qt::ItemIsAutoTristate); p = p->par)
model->emitDataChanged(p, column);
}
}
@@ -1779,7 +1779,7 @@ QVariant QTreeWidgetItem::data(int column, int role) const
break;
case Qt::CheckStateRole:
// special case for check state in tristate
- if (children.count() && (itemFlags & Qt::ItemIsTristate))
+ if (children.count() && (itemFlags & Qt::ItemIsAutoTristate))
return childrenCheckState(column);
// fallthrough intended
default:
@@ -3042,7 +3042,9 @@ QList<QTreeWidgetItem*> QTreeWidget::findItems(const QString &text, Qt::MatchFla
QModelIndexList indexes = d->model->match(model()->index(0, column, QModelIndex()),
Qt::DisplayRole, text, -1, flags);
QList<QTreeWidgetItem*> items;
- for (int i = 0; i < indexes.size(); ++i)
+ const int indexesSize = indexes.size();
+ items.reserve(indexesSize);
+ for (int i = 0; i < indexesSize; ++i)
items.append(d->item(indexes.at(i)));
return items;
}
@@ -3279,7 +3281,7 @@ QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const
for (int i = 0; i < items.count(); ++i) {
QTreeWidgetItem *item = items.at(i);
if (!item) {
- qWarning() << "QTreeWidget::mimeData: Null-item passed";
+ qWarning("QTreeWidget::mimeData: Null-item passed");
return 0;
}
@@ -3371,7 +3373,9 @@ void QTreeWidget::dropEvent(QDropEvent *event) {
if (d->dropOn(event, &row, &col, &topIndex)) {
QList<QModelIndex> idxs = selectedIndexes();
QList<QPersistentModelIndex> indexes;
- for (int i = 0; i < idxs.count(); i++)
+ const int indexesCount = idxs.count();
+ indexes.reserve(indexesCount);
+ for (int i = 0; i < indexesCount; i++)
indexes.append(idxs.at(i));
if (indexes.contains(topIndex))
@@ -3382,7 +3386,7 @@ void QTreeWidget::dropEvent(QDropEvent *event) {
// Remove the items
QList<QTreeWidgetItem *> taken;
- for (int i = indexes.count() - 1; i >= 0; --i) {
+ for (int i = 0; i < indexes.count(); ++i) {
QTreeWidgetItem *parent = itemFromIndex(indexes.at(i));
if (!parent || !parent->parent()) {
taken.append(takeTopLevelItem(indexes.at(i).row()));
diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h
index 564e10ac1a..995528fe37 100644
--- a/src/widgets/itemviews/qtreewidget.h
+++ b/src/widgets/itemviews/qtreewidget.h
@@ -172,7 +172,7 @@ public:
inline QTreeWidgetItem *parent() const { return par; }
inline QTreeWidgetItem *child(int index) const {
if (index < 0 || index >= children.size())
- return 0;
+ return Q_NULLPTR;
executePendingSort();
return children.at(index);
}
@@ -255,7 +255,7 @@ class Q_WIDGETS_EXPORT QTreeWidget : public QTreeView
friend class QTreeModel;
friend class QTreeWidgetItem;
public:
- explicit QTreeWidget(QWidget *parent = 0);
+ explicit QTreeWidget(QWidget *parent = Q_NULLPTR);
~QTreeWidget();
int columnCount() const;
@@ -375,7 +375,7 @@ private:
};
inline void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column)
-{ setItemWidget(item, column, 0); }
+{ setItemWidget(item, column, Q_NULLPTR); }
inline QTreeWidgetItem *QTreeWidget::itemAt(int ax, int ay) const
{ return itemAt(QPoint(ax, ay)); }
diff --git a/src/widgets/itemviews/qwidgetitemdata_p.h b/src/widgets/itemviews/qwidgetitemdata_p.h
index 307d228c74..d8c1fc2ff7 100644
--- a/src/widgets/itemviews/qwidgetitemdata_p.h
+++ b/src/widgets/itemviews/qwidgetitemdata_p.h
@@ -58,6 +58,7 @@ public:
QVariant value;
inline bool operator==(const QWidgetItemData &other) const { return role == other.role && value == other.value; }
};
+Q_DECLARE_TYPEINFO(QWidgetItemData, Q_MOVABLE_TYPE);
#ifndef QT_NO_DATASTREAM
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 4dd10720d6..2c4e4d3125 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -223,8 +223,9 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
\snippet mainwindows/application/mainwindow.cpp 19
\codeline
- \snippet mainwindows/application/mainwindow.cpp 28
- \snippet mainwindows/application/mainwindow.cpp 31
+ \code
+ fileMenu->addAction(openAct);
+ \endcode
We recommend that actions are created as children of the window
they are used in. In most cases actions will be children of
@@ -254,7 +255,7 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
\value TextHeuristicRole This action should be put in the application menu based on the action's text
as described in the QMenuBar documentation.
\value ApplicationSpecificRole This action should be put in the application menu with an application specific role
- \value AboutQtRole This action matches handles the "About Qt" menu item.
+ \value AboutQtRole This action handles the "About Qt" menu item.
\value AboutRole This action should be placed where the "About" menu item is in the application menu. The text of
the menu item will be set to "About <application name>". The application name is fetched from the
\c{Info.plist} file in the application's bundle (See \l{Qt for OS X - Deployment}).
@@ -1230,7 +1231,7 @@ void QAction::activate(ActionEvent event)
\since 4.2
This indicates what role the action serves in the application menu on Mac
- OS X. By default all action have the TextHeuristicRole, which means that
+ OS X. By default all actions have the TextHeuristicRole, which means that
the action is added based on its text (see QMenuBar for more information).
The menu role can only be changed before the actions are put into the menu
@@ -1269,7 +1270,7 @@ QAction::MenuRole QAction::menuRole() const
For example:
\snippet code/src_gui_kernel_qaction.cpp 0
- \sa QAction::icon, QApplication::setAttribute()
+ \sa QAction::icon, QCoreApplication::setAttribute()
*/
void QAction::setIconVisibleInMenu(bool visible)
{
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index 1d69694699..8ef26b60bf 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -153,7 +153,7 @@ public:
enum ActionEvent { Trigger, Hover };
void activate(ActionEvent event);
- bool showStatusText(QWidget *widget=0);
+ bool showStatusText(QWidget *widget = Q_NULLPTR);
void setMenuRole(MenuRole menuRole);
MenuRole menuRole() const;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 078feb4b03..e20e820f12 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -398,8 +398,6 @@ void qt_cleanup();
QStyle *QApplicationPrivate::app_style = 0; // default application style
bool QApplicationPrivate::overrides_native_style = false; // whether native QApplication style is
// overridden, i.e. not native
-QString QApplicationPrivate::styleOverride; // style override
-
#ifndef QT_NO_STYLE_STYLESHEET
QString QApplicationPrivate::styleSheet; // default application stylesheet
#endif
@@ -465,6 +463,13 @@ QDesktopWidget *qt_desktopWidget = 0; // root window widgets
*/
void QApplicationPrivate::process_cmdline()
{
+ if (!styleOverride.isEmpty()) {
+ if (app_style) {
+ delete app_style;
+ app_style = 0;
+ }
+ }
+
// process platform-indep command line
if (!qt_is_gui_used || !argc)
return;
@@ -480,13 +485,8 @@ void QApplicationPrivate::process_cmdline()
QByteArray arg = argv[i];
if (arg.startsWith("--"))
arg.remove(0, 1);
- QString s;
if (arg == "-qdevel" || arg == "-qdebug") {
// obsolete argument
- } else if (arg.indexOf("-style=", 0) != -1) {
- s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
- } else if (arg == "-style" && i < argc-1) {
- s = QString::fromLocal8Bit(argv[++i]).toLower();
#ifndef QT_NO_STYLE_STYLESHEET
} else if (arg == "-stylesheet" && i < argc -1) {
styleSheet = QLatin1String("file:///");
@@ -500,13 +500,6 @@ void QApplicationPrivate::process_cmdline()
} else {
argv[j++] = argv[i];
}
- if (!s.isEmpty()) {
- if (app_style) {
- delete app_style;
- app_style = 0;
- }
- styleOverride = s;
- }
}
if(j < argc) {
@@ -557,7 +550,7 @@ void QApplicationPrivate::process_cmdline()
and will make the application wait until a debugger connects to it.
\endlist
- \sa arguments()
+ \sa QCoreApplication::arguments()
*/
#ifdef Q_QDOC
@@ -747,15 +740,15 @@ void QApplicationPrivate::initializeWidgetFontHash()
if (const QFont *font = theme->font(QPlatformTheme::ItemViewFont))
fontHash->insert(QByteArrayLiteral("QAbstractItemView"), *font);
if (const QFont *font = theme->font(QPlatformTheme::ListViewFont))
- fontHash->insert(QByteArrayLiteral("QListViewFont"), *font);
+ fontHash->insert(QByteArrayLiteral("QListView"), *font);
if (const QFont *font = theme->font(QPlatformTheme::HeaderViewFont))
- fontHash->insert(QByteArrayLiteral("QHeaderViewFont"), *font);
+ fontHash->insert(QByteArrayLiteral("QHeaderView"), *font);
if (const QFont *font = theme->font(QPlatformTheme::ListBoxFont))
fontHash->insert(QByteArrayLiteral("QListBox"), *font);
if (const QFont *font = theme->font(QPlatformTheme::ComboMenuItemFont))
- fontHash->insert(QByteArrayLiteral("QComboMenuItemFont"), *font);
+ fontHash->insert(QByteArrayLiteral("QComboMenuItem"), *font);
if (const QFont *font = theme->font(QPlatformTheme::ComboLineEditFont))
- fontHash->insert(QByteArrayLiteral("QComboLineEditFont"), *font);
+ fontHash->insert(QByteArrayLiteral("QComboLineEdit"), *font);
if (const QFont *font = theme->font(QPlatformTheme::SmallFont))
fontHash->insert(QByteArrayLiteral("QSmallFont"), *font);
if (const QFont *font = theme->font(QPlatformTheme::MiniFont))
@@ -1905,7 +1898,7 @@ bool QApplicationPrivate::tryCloseAllWidgetWindows(QWindowList *processedWindows
if (!w->isVisible() || w->data->is_closing)
break;
QWindow *window = w->windowHandle();
- if (!w->close()) // Qt::WA_DeleteOnClose may cause deletion.
+ if (!window->close()) // Qt::WA_DeleteOnClose may cause deletion.
return false;
if (window)
processedWindows->append(window);
@@ -1917,7 +1910,7 @@ bool QApplicationPrivate::tryCloseAllWidgetWindows(QWindowList *processedWindows
if (w->isVisible() && w->windowType() != Qt::Desktop &&
!w->testAttribute(Qt::WA_DontShowOnScreen) && !w->data->is_closing) {
QWindow *window = w->windowHandle();
- if (!w->close()) // Qt::WA_DeleteOnClose may cause deletion.
+ if (!window->close()) // Qt::WA_DeleteOnClose may cause deletion.
return false;
if (window)
processedWindows->append(window);
@@ -1950,7 +1943,7 @@ bool QApplicationPrivate::tryCloseAllWindows()
\l quitOnLastWindowClosed to false.
\sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(),
- QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(),
+ QWidget::closeEvent(), lastWindowClosed(), QCoreApplication::quit(), topLevelWidgets(),
QWidget::isWindow()
*/
void QApplication::closeAllWindows()
@@ -2970,8 +2963,8 @@ int QApplication::startDragDistance()
application will have time to exit its event loop and execute code at the
end of the \c{main()} function, after the QApplication::exec() call.
- \sa quitOnLastWindowClosed, quit(), exit(), processEvents(),
- QCoreApplication::exec()
+ \sa quitOnLastWindowClosed, QCoreApplication::quit(), QCoreApplication::exit(),
+ QCoreApplication::processEvents(), QCoreApplication::exec()
*/
int QApplication::exec()
{
@@ -3251,12 +3244,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QPointer<QWidget> pw = w;
while (w) {
- QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(), mouse->button(), mouse->buttons(),
- mouse->modifiers());
+ QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(),
+ mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source());
me.spont = mouse->spontaneous();
me.setTimestamp(mouse->timestamp());
QGuiApplicationPrivate::setMouseEventFlags(&me, mouse->flags());
- QGuiApplicationPrivate::setMouseEventSource(&me, mouse->source());
// throw away any mouse-tracking-only mouse events
if (!w->hasMouseTracking()
&& mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
@@ -3690,7 +3682,9 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
{
// send to all application event filters
- if (sendThroughApplicationEventFilters(receiver, e))
+ if (threadRequiresCoreApplication()
+ && receiver->d_func()->threadData->thread == mainThread()
+ && sendThroughApplicationEventFilters(receiver, e))
return true;
if (receiver->isWidgetType()) {
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index d4b2326afd..7aaea2a947 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -104,11 +104,11 @@ public:
using QGuiApplication::palette;
static QPalette palette(const QWidget *);
static QPalette palette(const char *className);
- static void setPalette(const QPalette &, const char* className = 0);
+ static void setPalette(const QPalette &, const char* className = Q_NULLPTR);
static QFont font();
static QFont font(const QWidget*);
static QFont font(const char *className);
- static void setFont(const QFont &, const char* className = 0);
+ static void setFont(const QFont &, const char* className = Q_NULLPTR);
static QFontMetrics fontMetrics();
#if QT_VERSION < 0x060000 // remove these forwarders in Qt 6
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index ba8d7ff63c..75d86a5eba 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -219,8 +219,6 @@ public:
static QApplicationPrivate *instance() { return self; }
- static QString styleOverride;
-
#ifdef QT_KEYPAD_NAVIGATION
static QWidget *oldEditFocus;
static Qt::NavigationMode navigationMode;
diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h
index 5ce9ca26f6..10209e05c9 100644
--- a/src/widgets/kernel/qboxlayout.h
+++ b/src/widgets/kernel/qboxlayout.h
@@ -54,7 +54,7 @@ public:
enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
Down = TopToBottom, Up = BottomToTop };
- explicit QBoxLayout(Direction, QWidget *parent = 0);
+ explicit QBoxLayout(Direction, QWidget *parent = Q_NULLPTR);
~QBoxLayout();
@@ -64,7 +64,7 @@ public:
void addSpacing(int size);
void addStretch(int stretch = 0);
void addSpacerItem(QSpacerItem *spacerItem);
- void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = 0);
+ void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = Qt::Alignment());
void addLayout(QLayout *layout, int stretch = 0);
void addStrut(int);
void addItem(QLayoutItem *) Q_DECL_OVERRIDE;
@@ -72,7 +72,7 @@ public:
void insertSpacing(int index, int size);
void insertStretch(int index, int stretch = 0);
void insertSpacerItem(int index, QSpacerItem *spacerItem);
- void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = 0);
+ void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = Qt::Alignment());
void insertLayout(int index, QLayout *layout, int stretch = 0);
void insertItem(int index, QLayoutItem *);
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 94716025b9..2ddd025239 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -36,6 +36,7 @@
#include "qdesktopwidget_p.h"
#include "qscreen.h"
#include "qwidget_p.h"
+#include "qwindow.h"
QT_BEGIN_NAMESPACE
@@ -99,13 +100,18 @@ void QDesktopWidgetPrivate::_q_updateScreens()
QRegion virtualGeometry;
- // update the geometry of each screen widget, determine virtual geometry
- // and emit change signals afterwards.
+ // update the geometry of each screen widget, determine virtual geometry,
+ // set the new screen for window handle and emit change signals afterwards.
QList<int> changedScreens;
for (int i = 0; i < screens.length(); i++) {
- const QRect screenGeometry = screenList.at(i)->geometry();
- if (screenGeometry != screens.at(i)->geometry()) {
- screens.at(i)->setGeometry(screenGeometry);
+ QDesktopScreenWidget *screenWidget = screens.at(i);
+ QScreen *qScreen = screenList.at(i);
+ QWindow *winHandle = screenWidget->windowHandle();
+ if (winHandle && winHandle->screen() != qScreen)
+ winHandle->setScreen(qScreen);
+ const QRect screenGeometry = qScreen->geometry();
+ if (screenGeometry != screenWidget->geometry()) {
+ screenWidget->setGeometry(screenGeometry);
changedScreens.push_back(i);
}
virtualGeometry += screenGeometry;
@@ -134,6 +140,7 @@ QDesktopWidget::QDesktopWidget()
setObjectName(QLatin1String("desktop"));
d->_q_updateScreens();
connect(qApp, SIGNAL(screenAdded(QScreen*)), this, SLOT(_q_updateScreens()));
+ connect(qApp, SIGNAL(primaryScreenChanged(QScreen*)), this, SIGNAL(primaryScreenChanged()));
}
QDesktopWidget::~QDesktopWidget()
@@ -188,23 +195,69 @@ const QRect QDesktopWidget::screenGeometry(int screenNo) const
int QDesktopWidget::screenNumber(const QWidget *w) const
{
if (!w)
- return 0;
+ return primaryScreen();
+ const QList<QScreen *> allScreens = QGuiApplication::screens();
+ QList<QScreen *> screens = allScreens;
+ if (screens.isEmpty()) // This should never happen
+ return primaryScreen();
+
+ // If there is more than one virtual desktop
+ if (screens.count() != screens.constFirst()->virtualSiblings().count()) {
+ // Find the root widget, get a QScreen from it and use the
+ // virtual siblings for checking the window position.
+ const QWidget *root = w;
+ const QWidget *tmp = w;
+ while ((tmp = tmp->parentWidget()))
+ root = tmp;
+ const QWindow *winHandle = root->windowHandle();
+ if (winHandle) {
+ const QScreen *winScreen = winHandle->screen();
+ if (winScreen)
+ screens = winScreen->virtualSiblings();
+ }
+ }
+
+ // Get the screen number from window position using screen geometry
+ // and proper screens.
QRect frame = w->frameGeometry();
if (!w->isWindow())
frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
- const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
- return screenNumber(midpoint);
+
+ QScreen *widgetScreen = Q_NULLPTR;
+ int largestArea = 0;
+ foreach (QScreen *screen, screens) {
+ QRect intersected = screen->geometry().intersected(frame);
+ int area = intersected.width() * intersected.height();
+ if (largestArea < area) {
+ widgetScreen = screen;
+ largestArea = area;
+ }
+ }
+ return allScreens.indexOf(widgetScreen);
}
int QDesktopWidget::screenNumber(const QPoint &p) const
{
- QList<QScreen *> screens = QGuiApplication::screens();
-
- for (int i = 0; i < screens.size(); ++i)
- if (screens.at(i)->geometry().contains(p))
- return i;
-
+ const QList<QScreen *> screens = QGuiApplication::screens();
+ if (!screens.isEmpty()) {
+ const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings();
+ // Find the screen index on the primary virtual desktop first
+ foreach (QScreen *screen, primaryScreens) {
+ if (screen->geometry().contains(p))
+ return screens.indexOf(screen);
+ }
+ // If the screen index is not found on primary virtual desktop, find
+ // the screen index on all screens except the first which was for
+ // sure in the previous loop. Some other screens may repeat. Find
+ // only when there is more than one virtual desktop.
+ if (screens.count() != primaryScreens.count()) {
+ for (int i = 1; i < screens.size(); ++i) {
+ if (screens[i]->geometry().contains(p))
+ return i;
+ }
+ }
+ }
return primaryScreen(); //even better would be closest screen
}
diff --git a/src/widgets/kernel/qdesktopwidget.h b/src/widgets/kernel/qdesktopwidget.h
index 5412c5bc4a..1dfec2d4ad 100644
--- a/src/widgets/kernel/qdesktopwidget.h
+++ b/src/widgets/kernel/qdesktopwidget.h
@@ -47,7 +47,7 @@ class Q_WIDGETS_EXPORT QDesktopWidget : public QWidget
Q_OBJECT
Q_PROPERTY(bool virtualDesktop READ isVirtualDesktop)
Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged)
- Q_PROPERTY(int primaryScreen READ primaryScreen)
+ Q_PROPERTY(int primaryScreen READ primaryScreen NOTIFY primaryScreenChanged)
public:
QDesktopWidget();
~QDesktopWidget();
@@ -58,7 +58,7 @@ public:
int screenCount() const;
int primaryScreen() const;
- int screenNumber(const QWidget *widget = 0) const;
+ int screenNumber(const QWidget *widget = Q_NULLPTR) const;
int screenNumber(const QPoint &) const;
QWidget *screen(int screen = -1);
@@ -77,6 +77,7 @@ Q_SIGNALS:
void resized(int);
void workAreaResized(int);
void screenCountChanged(int);
+ void primaryScreenChanged();
protected:
void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
diff --git a/src/widgets/kernel/qdesktopwidget.qdoc b/src/widgets/kernel/qdesktopwidget.qdoc
index 31a99f1acb..d1a6ecabd6 100644
--- a/src/widgets/kernel/qdesktopwidget.qdoc
+++ b/src/widgets/kernel/qdesktopwidget.qdoc
@@ -271,3 +271,17 @@
\sa screenCount
*/
+
+
+/*!
+ \fn void QDesktopWidget::primaryScreenChanged()
+
+ \since 5.6
+
+ \brief This signal is emitted whenever the primary screen changes.
+
+ \note This doesn't mean the QDesktopWidget::primaryScreen index will
+ necessarily be different, but now it will refer to the new primary screen.
+
+ \sa primaryScreen, screenGeometry()
+*/
diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h
index 18f3c84354..0767d78ce6 100644
--- a/src/widgets/kernel/qformlayout.h
+++ b/src/widgets/kernel/qformlayout.h
@@ -74,7 +74,7 @@ public:
};
Q_ENUM(ItemRole)
- explicit QFormLayout(QWidget *parent = 0);
+ explicit QFormLayout(QWidget *parent = Q_NULLPTR);
~QFormLayout();
void setFieldGrowthPolicy(FieldGrowthPolicy policy);
diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h
index dfe9450365..bcf583a507 100644
--- a/src/widgets/kernel/qgesture.h
+++ b/src/widgets/kernel/qgesture.h
@@ -63,7 +63,7 @@ class Q_WIDGETS_EXPORT QGesture : public QObject
Q_PROPERTY(bool hasHotSpot READ hasHotSpot)
public:
- explicit QGesture(QObject *parent = 0);
+ explicit QGesture(QObject *parent = Q_NULLPTR);
~QGesture();
Qt::GestureType gestureType() const;
@@ -107,7 +107,7 @@ class Q_WIDGETS_EXPORT QPanGesture : public QGesture
Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
public:
- explicit QPanGesture(QObject *parent = 0);
+ explicit QPanGesture(QObject *parent = Q_NULLPTR);
~QPanGesture();
QPointF lastOffset() const;
@@ -154,7 +154,7 @@ public:
Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint)
public:
- explicit QPinchGesture(QObject *parent = 0);
+ explicit QPinchGesture(QObject *parent = Q_NULLPTR);
~QPinchGesture();
ChangeFlags totalChangeFlags() const;
@@ -210,7 +210,7 @@ public:
enum SwipeDirection { NoDirection, Left, Right, Up, Down };
Q_ENUM(SwipeDirection)
- explicit QSwipeGesture(QObject *parent = 0);
+ explicit QSwipeGesture(QObject *parent = Q_NULLPTR);
~QSwipeGesture();
SwipeDirection horizontalDirection() const;
@@ -231,7 +231,7 @@ class Q_WIDGETS_EXPORT QTapGesture : public QGesture
Q_PROPERTY(QPointF position READ position WRITE setPosition)
public:
- explicit QTapGesture(QObject *parent = 0);
+ explicit QTapGesture(QObject *parent = Q_NULLPTR);
~QTapGesture();
QPointF position() const;
@@ -249,7 +249,7 @@ class Q_WIDGETS_EXPORT QTapAndHoldGesture : public QGesture
Q_PROPERTY(QPointF position READ position WRITE setPosition)
public:
- explicit QTapAndHoldGesture(QObject *parent = 0);
+ explicit QTapAndHoldGesture(QObject *parent = Q_NULLPTR);
~QTapAndHoldGesture();
QPointF position() const;
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 8b918a72a2..fb2914d53a 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -66,7 +66,7 @@ static inline int panTouchPoints()
static const char panTouchPointVariable[] = "QT_PAN_TOUCHPOINTS";
if (qEnvironmentVariableIsSet(panTouchPointVariable)) {
bool ok;
- const int result = qgetenv(panTouchPointVariable).toInt(&ok);
+ const int result = qEnvironmentVariableIntValue(panTouchPointVariable, &ok);
if (ok && result >= 1)
return result;
qWarning() << "Ignoring invalid value of " << panTouchPointVariable;
@@ -572,18 +572,19 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
}
// for each gesture type
- foreach (Qt::GestureType type, gestureByTypes.keys()) {
- QHash<QWidget *, QGesture *> gestures = gestureByTypes.value(type);
- foreach (QWidget *widget, gestures.keys()) {
+ for (GestureByTypes::const_iterator git = gestureByTypes.cbegin(), gend = gestureByTypes.cend(); git != gend; ++git) {
+ const QHash<QWidget *, QGesture *> &gestures = git.value();
+ for (QHash<QWidget *, QGesture *>::const_iterator wit = gestures.cbegin(), wend = gestures.cend(); wit != wend; ++wit) {
+ QWidget *widget = wit.key();
QWidget *w = widget->parentWidget();
while (w) {
QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it
- = w->d_func()->gestureContext.constFind(type);
+ = w->d_func()->gestureContext.constFind(git.key());
if (it != w->d_func()->gestureContext.constEnd()) {
// i.e. 'w' listens to gesture 'type'
if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {
// conflicting gesture!
- (*conflicts)[widget].append(gestures[widget]);
+ (*conflicts)[widget].append(wit.value());
break;
}
}
@@ -594,7 +595,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
w = w->parentWidget();
}
if (!w)
- (*normal)[widget].append(gestures[widget]);
+ (*normal)[widget].append(wit.value());
}
}
}
diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h
index a582d31634..ae3fe125b6 100644
--- a/src/widgets/kernel/qgridlayout.h
+++ b/src/widgets/kernel/qgridlayout.h
@@ -93,10 +93,10 @@ public:
void invalidate() Q_DECL_OVERRIDE;
inline void addWidget(QWidget *w) { QLayout::addWidget(w); }
- void addWidget(QWidget *, int row, int column, Qt::Alignment = 0);
- void addWidget(QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
- void addLayout(QLayout *, int row, int column, Qt::Alignment = 0);
- void addLayout(QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
+ void addWidget(QWidget *, int row, int column, Qt::Alignment = Qt::Alignment());
+ void addWidget(QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = Qt::Alignment());
+ void addLayout(QLayout *, int row, int column, Qt::Alignment = Qt::Alignment());
+ void addLayout(QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = Qt::Alignment());
void setOriginCorner(Qt::Corner);
Qt::Corner originCorner() const;
@@ -107,7 +107,7 @@ public:
int count() const Q_DECL_OVERRIDE;
void setGeometry(const QRect&) Q_DECL_OVERRIDE;
- void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = 0);
+ void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = Qt::Alignment());
void setDefaultPositioning(int n, Qt::Orientation orient);
void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan) const;
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index d3e5986103..e74f17b6f7 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
if (index == -1)
return 0;
+ addChildWidget(to);
QLayoutItem *newitem = new QWidgetItem(to);
newitem->setAlignment(item->alignment());
QLayoutItem *r = d->replaceAt(index, newitem);
if (!r)
delete newitem;
- else
- addChildWidget(to);
return r;
}
diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h
index 650e114c76..cdb612728f 100644
--- a/src/widgets/kernel/qlayoutitem.h
+++ b/src/widgets/kernel/qlayoutitem.h
@@ -53,7 +53,7 @@ class QSize;
class Q_WIDGETS_EXPORT QLayoutItem
{
public:
- inline explicit QLayoutItem(Qt::Alignment alignment = 0);
+ inline explicit QLayoutItem(Qt::Alignment alignment = Qt::Alignment());
virtual ~QLayoutItem();
virtual QSize sizeHint() const = 0;
virtual QSize minimumSize() const = 0;
diff --git a/src/widgets/kernel/qmacgesturerecognizer.cpp b/src/widgets/kernel/qmacgesturerecognizer.cpp
index 47003f5866..9f55e23cee 100644
--- a/src/widgets/kernel/qmacgesturerecognizer.cpp
+++ b/src/widgets/kernel/qmacgesturerecognizer.cpp
@@ -256,6 +256,7 @@ void QMacPanGestureRecognizer::reset(QGesture *gesture)
QPanGesture *g = static_cast<QPanGesture *>(gesture);
_startPos = QPointF();
_panCanceled = true;
+ _panTimer.stop();
g->setOffset(QPointF(0, 0));
g->setLastOffset(QPointF(0, 0));
g->setAcceleration(qreal(1));
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 1ee28f2e9a..a80db3f60b 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -425,7 +425,12 @@ QT_BEGIN_NAMESPACE
Note that this does not apply when there are no other widgets underneath and
the intention is to have a semi-transparent window. In that case the
- traditional approach of setting Qt::WA_TranslucentBackground is sufficient.
+ traditional approach of setting Qt::WA_TranslucentBackground
+ on the top-level window is sufficient. Note that if the transparent areas are
+ only desired in the QOpenGLWidget, then Qt::WA_NoSystemBackground will need
+ to be turned back to \c false after enabling Qt::WA_TranslucentBackground.
+ Additionally, requesting an alpha channel for the QOpenGLWidget's context via
+ setFormat() may be necessary too, depending on the system.
QOpenGLWidget supports multiple update behaviors, just like QOpenGLWindow. In
preserved mode the rendered content from the previous paintGL() call is
@@ -553,7 +558,9 @@ public:
hasBeenComposed(false),
flushPending(false),
paintDevice(0),
- updateBehavior(QOpenGLWidget::NoPartialUpdate)
+ updateBehavior(QOpenGLWidget::NoPartialUpdate),
+ requestedSamples(0),
+ inPaintGL(false)
{
requestedFormat = QSurfaceFormat::defaultFormat();
}
@@ -595,6 +602,8 @@ public:
QOpenGLPaintDevice *paintDevice;
QSurfaceFormat requestedFormat;
QOpenGLWidget::UpdateBehavior updateBehavior;
+ int requestedSamples;
+ bool inPaintGL;
};
void QOpenGLWidgetPaintDevicePrivate::beginPaint()
@@ -605,7 +614,7 @@ void QOpenGLWidgetPaintDevicePrivate::beginPaint()
// with the palette's background color.
if (w->autoFillBackground()) {
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
- if (w->testAttribute(Qt::WA_TranslucentBackground)) {
+ if (w->format().hasAlpha()) {
f->glClearColor(0, 0, 0, 0);
} else {
QColor c = w->palette().brush(w->backgroundRole()).color();
@@ -636,12 +645,6 @@ void QOpenGLWidgetPaintDevice::ensureActiveTarget()
GLuint QOpenGLWidgetPrivate::textureId() const
{
- Q_Q(const QOpenGLWidget);
- if (!q->isWindow() && q->internalWinId()) {
- qWarning() << "QOpenGLWidget cannot be used as a native child widget."
- << "Consider setting Qt::WA_DontCreateNativeAncestors and Qt::AA_DontCreateNativeWidgetSiblings.";
- return 0;
- }
return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0);
}
@@ -686,7 +689,7 @@ void QOpenGLWidgetPrivate::recreateFbo()
delete resolvedFbo;
resolvedFbo = 0;
- int samples = context->format().samples();
+ int samples = requestedSamples;
QOpenGLExtensions *extfuncs = static_cast<QOpenGLExtensions *>(context->functions());
if (!extfuncs->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample))
samples = 0;
@@ -695,7 +698,7 @@ void QOpenGLWidgetPrivate::recreateFbo()
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(samples);
- const QSize deviceSize = q->size() * q->devicePixelRatio();
+ const QSize deviceSize = q->size() * q->devicePixelRatioF();
fbo = new QOpenGLFramebufferObject(deviceSize, format);
if (samples > 0)
resolvedFbo = new QOpenGLFramebufferObject(deviceSize);
@@ -704,7 +707,7 @@ void QOpenGLWidgetPrivate::recreateFbo()
context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
paintDevice->setSize(deviceSize);
- paintDevice->setDevicePixelRatio(q->devicePixelRatio());
+ paintDevice->setDevicePixelRatio(q->devicePixelRatioF());
emit q->resized();
}
@@ -742,6 +745,13 @@ void QOpenGLWidgetPrivate::initialize()
return;
}
+ // Do not include the sample count. Requesting a multisampled context is not necessary
+ // since we render into an FBO, never to an actual surface. What's more, attempting to
+ // create a pbuffer with a multisampled config crashes certain implementations. Just
+ // avoid the entire hassle, the result is the same.
+ requestedSamples = requestedFormat.samples();
+ requestedFormat.setSamples(0);
+
QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
ctx->setShareContext(shareContext);
ctx->setFormat(requestedFormat);
@@ -778,8 +788,8 @@ void QOpenGLWidgetPrivate::initialize()
}
paintDevice = new QOpenGLWidgetPaintDevice(q);
- paintDevice->setSize(q->size() * q->devicePixelRatio());
- paintDevice->setDevicePixelRatio(q->devicePixelRatio());
+ paintDevice->setSize(q->size() * q->devicePixelRatioF());
+ paintDevice->setDevicePixelRatio(q->devicePixelRatioF());
context = ctx.take();
initialized = true;
@@ -808,8 +818,10 @@ void QOpenGLWidgetPrivate::invokeUserPaint()
QOpenGLFunctions *f = ctx->functions();
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle();
- f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio());
+ f->glViewport(0, 0, q->width() * q->devicePixelRatioF(), q->height() * q->devicePixelRatioF());
+ inPaintGL = true;
q->paintGL();
+ inPaintGL = false;
flushPending = true;
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0;
@@ -856,11 +868,24 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer()
if (!initialized)
return QImage();
- render();
- resolveSamples();
- q->makeCurrent();
- QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatio(), false, false);
- res.setDevicePixelRatio(q->devicePixelRatio());
+ if (!inPaintGL)
+ render();
+
+ if (resolvedFbo) {
+ resolveSamples();
+ resolvedFbo->bind();
+ } else {
+ q->makeCurrent();
+ }
+
+ QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), false, false);
+ res.setDevicePixelRatio(q->devicePixelRatioF());
+
+ // While we give no guarantees of what is going to be left bound, prefer the
+ // multisample fbo instead of the resolved one. Clients may continue to
+ // render straight after calling this function.
+ if (resolvedFbo)
+ q->makeCurrent();
return res;
}
@@ -879,7 +904,7 @@ void QOpenGLWidgetPrivate::resizeViewportFramebuffer()
if (!initialized)
return;
- if (!fbo || q->size() * q->devicePixelRatio() != fbo->size())
+ if (!fbo || q->size() * q->devicePixelRatioF() != fbo->size())
recreateFbo();
}
@@ -946,13 +971,12 @@ QOpenGLWidget::UpdateBehavior QOpenGLWidget::updateBehavior() const
OpenGL widgets, individual calls to this function can be replaced by one single call to
QSurfaceFormat::setDefaultFormat() before creating the first widget.
- \note Requesting an alpha buffer via this function, or by setting
- Qt::WA_TranslucentBackground, will not lead to the desired results when the intention is
- to make other widgets beneath visible. Instead, use Qt::WA_AlwaysStackOnTop to enable
- semi-transparent QOpenGLWidget instances with other widgets visible underneath. Keep in
- mind however that this breaks the stacking order, so it will no longer be possible to
- have other widgets on top of the QOpenGLWidget. When the intention is to have a
- semi-transparent top-level window, Qt::WA_TranslucentBackground is sufficient.
+ \note Requesting an alpha buffer via this function will not lead to the
+ desired results when the intention is to make other widgets beneath visible.
+ Instead, use Qt::WA_AlwaysStackOnTop to enable semi-transparent QOpenGLWidget
+ instances with other widgets visible underneath. Keep in mind however that
+ this breaks the stacking order, so it will no longer be possible to have
+ other widgets on top of the QOpenGLWidget.
\sa format(), Qt::WA_AlwaysStackOnTop, QSurfaceFormat::setDefaultFormat()
*/
@@ -1148,8 +1172,7 @@ void QOpenGLWidget::resizeEvent(QResizeEvent *e)
d->recreateFbo();
resizeGL(width(), height());
- d->invokeUserPaint();
- d->resolveSamples();
+ d->sendPaintEvent(QRect(QPoint(0, 0), size()));
}
/*!
@@ -1196,6 +1219,7 @@ int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric) const
return QWidget::metric(metric);
QWidget *tlw = window();
+ QWindow *window = tlw ? tlw->windowHandle() : 0;
QScreen *screen = tlw && tlw->windowHandle() ? tlw->windowHandle()->screen() : 0;
if (!screen && QGuiApplication::primaryScreen())
screen = QGuiApplication::primaryScreen();
@@ -1243,8 +1267,13 @@ int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric) const
else
return qRound(dpmy * 0.0254);
case PdmDevicePixelRatio:
- if (screen)
- return screen->devicePixelRatio();
+ if (window)
+ return int(window->devicePixelRatio());
+ else
+ return 1.0;
+ case PdmDevicePixelRatioScaled:
+ if (window)
+ return int(window->devicePixelRatio() * devicePixelRatioFScale());
else
return 1.0;
default:
@@ -1304,7 +1333,7 @@ bool QOpenGLWidget::event(QEvent *e)
}
break;
case QEvent::ScreenChangeInternal:
- if (d->initialized && d->paintDevice->devicePixelRatio() != devicePixelRatio())
+ if (d->initialized && d->paintDevice->devicePixelRatioF() != devicePixelRatioF())
d->recreateFbo();
break;
default:
diff --git a/src/widgets/kernel/qopenglwidget.h b/src/widgets/kernel/qopenglwidget.h
index 4a9edb8180..ca65d75ca8 100644
--- a/src/widgets/kernel/qopenglwidget.h
+++ b/src/widgets/kernel/qopenglwidget.h
@@ -57,7 +57,7 @@ public:
PartialUpdate
};
- explicit QOpenGLWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
+ explicit QOpenGLWidget(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
~QOpenGLWidget();
void setUpdateBehavior(UpdateBehavior updateBehavior);
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h
index 9171f855ba..e816bbe06d 100644
--- a/src/widgets/kernel/qshortcut.h
+++ b/src/widgets/kernel/qshortcut.h
@@ -55,7 +55,7 @@ class Q_WIDGETS_EXPORT QShortcut : public QObject
public:
explicit QShortcut(QWidget *parent);
QShortcut(const QKeySequence& key, QWidget *parent,
- const char *member = 0, const char *ambiguousMember = 0,
+ const char *member = Q_NULLPTR, const char *ambiguousMember = Q_NULLPTR,
Qt::ShortcutContext context = Qt::WindowShortcut);
~QShortcut();
diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp
index 1476b4c5d7..3c28f5ccf7 100644
--- a/src/widgets/kernel/qsizepolicy.cpp
+++ b/src/widgets/kernel/qsizepolicy.cpp
@@ -332,6 +332,15 @@ void QSizePolicy::setControlType(ControlType type)
*/
/*!
+ \fn uint qHash(QSizePolicy key, uint seed = 0)
+ \since 5.6
+ \relates QSizePolicy
+
+ Returns the hash value for \a key, using
+ \a seed to seed the calculation.
+*/
+
+/*!
\fn int QSizePolicy::horizontalStretch() const
Returns the horizontal stretch factor of the size policy.
diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index 6cd511f513..7c9a356973 100644
--- a/src/widgets/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
@@ -40,6 +40,9 @@ QT_BEGIN_NAMESPACE
class QVariant;
+class QSizePolicy;
+
+Q_DECL_CONST_FUNCTION inline uint qHash(QSizePolicy key, uint seed = 0) Q_DECL_NOTHROW;
class Q_WIDGETS_EXPORT QSizePolicy
{
@@ -112,6 +115,9 @@ public:
bool operator==(const QSizePolicy& s) const { return data == s.data; }
bool operator!=(const QSizePolicy& s) const { return data != s.data; }
+
+ friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) Q_DECL_NOTHROW { return qHash(key.data, seed); }
+
operator QVariant() const;
int horizontalStretch() const { return static_cast<int>(bits.horStretch); }
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 8a800ab9d0..51bf6e4684 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -37,7 +37,6 @@
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qevent.h>
-#include <qhash.h>
#include <qlabel.h>
#include <qpointer.h>
#include <qstyle.h>
diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h
index 286d8fb327..54cf71d2f0 100644
--- a/src/widgets/kernel/qtooltip.h
+++ b/src/widgets/kernel/qtooltip.h
@@ -46,7 +46,7 @@ class Q_WIDGETS_EXPORT QToolTip
QToolTip() Q_DECL_EQ_DELETE;
public:
// ### Qt 6 - merge the three showText functions below
- static void showText(const QPoint &pos, const QString &text, QWidget *w = 0);
+ static void showText(const QPoint &pos, const QString &text, QWidget *w = Q_NULLPTR);
static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect);
static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecShowTime);
static inline void hideText() { showText(QPoint(), QString()); }
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp
index 5fb4695687..81de2f25ca 100644
--- a/src/widgets/kernel/qwhatsthis.cpp
+++ b/src/widgets/kernel/qwhatsthis.cpp
@@ -42,7 +42,6 @@
#include "qscreen.h"
#include "qpainter.h"
#include "qtimer.h"
-#include "qhash.h"
#include "qaction.h"
#include "qcursor.h"
#include "qbitmap.h"
@@ -460,7 +459,7 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e)
{
QKeyEvent* kev = (QKeyEvent*)e;
- if (kev->key() == Qt::Key_Escape) {
+ if (kev->matches(QKeySequence::Cancel)) {
QWhatsThis::leaveWhatsThisMode();
return true;
} else if (customWhatsThis) {
diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h
index 999c66486c..367b8aab3c 100644
--- a/src/widgets/kernel/qwhatsthis.h
+++ b/src/widgets/kernel/qwhatsthis.h
@@ -53,10 +53,10 @@ public:
static bool inWhatsThisMode();
static void leaveWhatsThisMode();
- static void showText(const QPoint &pos, const QString &text, QWidget *w = 0);
+ static void showText(const QPoint &pos, const QString &text, QWidget *w = Q_NULLPTR);
static void hideText();
- static QAction *createAction(QObject *parent = 0);
+ static QAction *createAction(QObject *parent = Q_NULLPTR);
};
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 7136714d39..b2b5c539e5 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -37,7 +37,6 @@
#include "qcursor.h"
#include "qdesktopwidget_p.h"
#include "qevent.h"
-#include "qhash.h"
#include "qlayout.h"
#include "qmenu.h"
#include "qmetaobject.h"
@@ -61,6 +60,7 @@
# include <private/qmainwindowlayout_p.h>
#endif
#include <qpa/qplatformwindow.h>
+#include <qpa/qplatformbackingstore.h>
#include "private/qwidgetwindow_p.h"
#include "qpainter.h"
#include "qtooltip.h"
@@ -69,6 +69,7 @@
#include "private/qstylesheetstyle_p.h"
#include "private/qstyle_p.h"
#include "qfileinfo.h"
+#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/qinputmethod.h>
#include <QtGui/qopenglcontext.h>
#include <QtGui/private/qopenglcontext_p.h>
@@ -101,6 +102,7 @@
#include "qwindowcontainer_p.h"
+#include <QtPlatformHeaders/qxcbwindowfunctions.h>
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
@@ -270,6 +272,9 @@ QWidgetPrivate::QWidgetPrivate(int version)
#ifndef QT_NO_IM
, inheritsInputMethodHints(0)
#endif
+#ifndef QT_NO_OPENGL
+ , renderToTextureReallyDirty(1)
+#endif
#if defined(Q_OS_WIN)
, noPaintOnScreen(0)
#endif
@@ -712,7 +717,7 @@ void QWidget::setAutoFillBackground(bool enabled)
close().
\row \li Top-level windows \li
- \l windowModified, \l windowTitle, \l windowIcon, \l windowIconText,
+ \l windowModified, \l windowTitle, \l windowIcon,
\l isActiveWindow, activateWindow(), \l minimized, showMinimized(),
\l maximized, showMaximized(), \l fullScreen, showFullScreen(),
showNormal().
@@ -1482,9 +1487,12 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (extra && !extra->mask.isEmpty())
setMask_sys(extra->mask);
- // If widget is already shown, set window visible, too
- if (q->isVisible())
+ if (data.crect.width() == 0 || data.crect.height() == 0) {
+ q->setAttribute(Qt::WA_OutsideWSRange, true);
+ } else if (q->isVisible()) {
+ // If widget is already shown, set window visible, too
win->setVisible(true);
+ }
}
#ifdef Q_OS_WIN
@@ -1859,6 +1867,8 @@ void QWidgetPrivate::deleteTLSysExtra()
extra->topextra->backingStoreTracker.destroy();
deleteBackingStore(this);
#ifndef QT_NO_OPENGL
+ qDeleteAll(extra->topextra->widgetTextures);
+ extra->topextra->widgetTextures.clear();
delete extra->topextra->shareContext;
extra->topextra->shareContext = 0;
#endif
@@ -2062,7 +2072,7 @@ void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion &reg
// Transform the system clip region from device-independent pixels to device pixels
QPaintEngine *paintEngine = paintDevice->paintEngine();
QTransform scaleTransform;
- const qreal devicePixelRatio = paintDevice->devicePixelRatio();
+ const qreal devicePixelRatio = paintDevice->devicePixelRatioF();
scaleTransform.scale(devicePixelRatio, devicePixelRatio);
paintEngine->d_func()->systemClip = scaleTransform.map(region);
}
@@ -5230,7 +5240,7 @@ QPixmap QWidget::grab(const QRect &rectangle)
QPixmap res(r.size());
if (!d->isOpaque)
res.fill(Qt::transparent);
- render(&res, QPoint(), QRegion(r), renderFlags);
+ d->render(&res, QPoint(), QRegion(r), renderFlags);
d->dirtyOpaqueChildren = oldDirtyOpaqueChildren;
return res;
@@ -5392,7 +5402,7 @@ void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset
if (size.isNull())
return;
- const qreal pixmapDevicePixelRatio = qreal(painter->device()->devicePixelRatio());
+ const qreal pixmapDevicePixelRatio = painter->device()->devicePixelRatioF();
QPixmap pixmap(size * pixmapDevicePixelRatio);
pixmap.setDevicePixelRatio(pixmapDevicePixelRatio);
@@ -5567,7 +5577,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
<< "geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size());
#endif
- bool grabbed = false;
+ bool skipPaintEvent = false;
#ifndef QT_NO_OPENGL
if (renderToTexture) {
// This widget renders into a texture which is composed later. We just need to
@@ -5581,14 +5591,18 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
} else {
// We are not drawing to a backingstore: fall back to QImage
p.drawImage(q->rect(), grabFramebuffer());
- grabbed = true;
+ skipPaintEvent = true;
}
endBackingStorePainting();
}
+ if (renderToTextureReallyDirty)
+ renderToTextureReallyDirty = 0;
+ else
+ skipPaintEvent = true;
}
#endif // QT_NO_OPENGL
- if (!grabbed) {
+ if (!skipPaintEvent) {
//actually send the paint event
sendPaintEvent(toBePainted);
}
@@ -5980,7 +5994,7 @@ void QWidget::unsetLocale()
window title, if set. This is done by the QPA plugin, so it is shown to the
user, but isn't part of the windowTitle string.
- \sa windowIcon, windowIconText, windowModified, windowFilePath
+ \sa windowIcon, windowModified, windowFilePath
*/
QString QWidget::windowTitle() const
{
@@ -6075,7 +6089,11 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title)
void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
{
- Q_UNUSED(iconText);
+ Q_Q(QWidget);
+ // ### The QWidget property is deprecated, but the XCB window function is not.
+ // It should remain available for the rare application that needs it.
+ if (QWindow *window = q->windowHandle())
+ QXcbWindowFunctions::setWmWindowIconText(window, iconText);
}
/*!
@@ -6085,6 +6103,9 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
new \a iconText as an argument.
\since 5.2
+ \obsolete
+
+ This signal is deprecated.
*/
void QWidget::setWindowIconText(const QString &iconText)
@@ -6135,7 +6156,7 @@ void QWidget::setWindowTitle(const QString &title)
has been set, windowIcon() returns the application icon
(QApplication::windowIcon()).
- \sa windowIconText, windowTitle
+ \sa windowTitle
*/
QIcon QWidget::windowIcon() const
{
@@ -6151,8 +6172,15 @@ QIcon QWidget::windowIcon() const
void QWidgetPrivate::setWindowIcon_helper()
{
+ Q_Q(QWidget);
QEvent e(QEvent::WindowIconChange);
- QApplication::sendEvent(q_func(), &e);
+
+ // Do not send the event if the widget is a top level.
+ // In that case, setWindowIcon_sys does it, and event propagation from
+ // QWidgetWindow to the top level QWidget ensures that the event reaches
+ // the top level anyhow
+ if (!q->windowHandle())
+ QApplication::sendEvent(q, &e);
for (int i = 0; i < children.size(); ++i) {
QWidget *w = qobject_cast<QWidget *>(children.at(i));
if (w && !w->isWindow())
@@ -6195,10 +6223,15 @@ void QWidgetPrivate::setWindowIcon_sys()
/*!
\property QWidget::windowIconText
- \brief the widget's icon text
+ \brief the text to be displayed on the icon of a minimized window
This property only makes sense for windows. If no icon
- text has been set, this functions returns an empty string.
+ text has been set, this accessor returns an empty string.
+ It is only implemented on the X11 platform, and only certain
+ window managers use this window property.
+
+ \obsolete
+ This property is deprecated.
\sa windowIcon, windowTitle
*/
@@ -7177,10 +7210,10 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
bool needsShow = false;
- if (q->isWindow()) {
+ if (q->isWindow() || q->windowHandle()) {
if (!(data.window_state & Qt::WindowFullScreen) && (w == 0 || h == 0)) {
q->setAttribute(Qt::WA_OutsideWSRange, true);
- if (q->isVisible() && q->testAttribute(Qt::WA_Mapped))
+ if (q->isVisible())
hide_sys();
data.crect = QRect(x, y, w, h);
} else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) {
@@ -7884,8 +7917,9 @@ void QWidgetPrivate::show_sys()
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
invalidateBuffer(q->rect());
q->setAttribute(Qt::WA_Mapped);
- if (q->isWindow() && q->windowModality() != Qt::NonModal && window) {
- // add our window to the modal window list
+ // add our window the modal window list (native dialogs)
+ if ((q->isWindow() && (!extra || !extra->proxyWidget))
+ && q->windowModality() != Qt::NonModal && window) {
QGuiApplicationPrivate::showModalWindow(window);
}
return;
@@ -7896,8 +7930,10 @@ void QWidgetPrivate::show_sys()
else
QApplication::postEvent(q, new QUpdateLaterEvent(q->rect()));
- if (!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
+ if ((!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
+ || q->testAttribute(Qt::WA_OutsideWSRange)) {
return;
+ }
if (window) {
if (q->isWindow())
@@ -8016,8 +8052,9 @@ void QWidgetPrivate::hide_sys()
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
q->setAttribute(Qt::WA_Mapped, false);
- if (q->isWindow() && q->windowModality() != Qt::NonModal && window) {
- // remove our window from the modal window list
+ // remove our window from the modal window list (native dialogs)
+ if ((q->isWindow() && (!extra || !extra->proxyWidget))
+ && q->windowModality() != Qt::NonModal && window) {
QGuiApplicationPrivate::hideModalWindow(window);
}
// do not return here, if window non-zero, we must hide it
@@ -8339,8 +8376,8 @@ bool QWidgetPrivate::close_helper(CloseMode mode)
otherwise returns \c false.
First it sends the widget a QCloseEvent. The widget is
- \l{hide()}{hidden} if it \l{QCloseEvent::accept()}{accepts}
- the close event. If it \l{QCloseEvent::ignore()}{ignores}
+ \l{hide()}{hidden} if it \l{QEvent::accept()}{accepts}
+ the close event. If it \l{QEvent::ignore()}{ignores}
the event, nothing happens. The default
implementation of QWidget::closeEvent() accepts the close event.
@@ -9313,12 +9350,12 @@ void QWidget::mouseDoubleClickEvent(QMouseEvent *event)
subclass to receive wheel events for the widget.
If you reimplement this handler, it is very important that you
- \l{QWheelEvent}{ignore()} the event if you do not handle
+ \l{QEvent}{ignore()} the event if you do not handle
it, so that the widget's parent can interpret it.
The default implementation ignores the event.
- \sa QWheelEvent::ignore(), QWheelEvent::accept(), event(),
+ \sa QEvent::ignore(), QEvent::accept(), event(),
QWheelEvent
*/
@@ -9334,12 +9371,12 @@ void QWidget::wheelEvent(QWheelEvent *event)
subclass to receive tablet events for the widget.
If you reimplement this handler, it is very important that you
- \l{QTabletEvent}{ignore()} the event if you do not handle
+ \l{QEvent}{ignore()} the event if you do not handle
it, so that the widget's parent can interpret it.
The default implementation ignores the event.
- \sa QTabletEvent::ignore(), QTabletEvent::accept(), event(),
+ \sa QEvent::ignore(), QEvent::accept(), event(),
QTabletEvent
*/
@@ -9360,7 +9397,8 @@ void QWidget::tabletEvent(QTabletEvent *event)
call the base class implementation if you do not act upon the key.
The default implementation closes popup widgets if the user
- presses Esc. Otherwise the event is ignored, so that the widget's
+ presses the key sequence for QKeySequence::Cancel (typically the
+ Escape key). Otherwise the event is ignored, so that the widget's
parent can interpret it.
Note that QKeyEvent starts with isAccepted() == true, so you do not
@@ -9373,7 +9411,7 @@ void QWidget::tabletEvent(QTabletEvent *event)
void QWidget::keyPressEvent(QKeyEvent *event)
{
- if ((windowType() == Qt::Popup) && event->key() == Qt::Key_Escape) {
+ if ((windowType() == Qt::Popup) && event->matches(QKeySequence::Cancel)) {
event->accept();
close();
} else {
@@ -9399,7 +9437,7 @@ void QWidget::keyPressEvent(QKeyEvent *event)
need to call QKeyEvent::accept() - just do not call the base class
implementation if you act upon the key.
- \sa keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(),
+ \sa keyPressEvent(), QEvent::ignore(), setFocusPolicy(),
focusInEvent(), focusOutEvent(), event(), QKeyEvent
*/
@@ -9752,6 +9790,8 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints)
d->imHints = hints;
if (this == QGuiApplication::focusObject())
QGuiApplication::inputMethod()->update(Qt::ImHints);
+#else
+ Q_UNUSED(hints);
#endif //QT_NO_IM
}
@@ -11846,13 +11886,11 @@ void QWidgetPrivate::updateFrameStrut()
Q_Q(QWidget);
if (q->data->fstrut_dirty) {
if (QTLWExtra *te = maybeTopData()) {
- if (te->window) {
- if (const QPlatformWindow *pw = te->window->handle()) {
- const QMargins margins = pw->frameMargins();
- if (!margins.isNull()) {
- te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom());
- q->data->fstrut_dirty = false;
- }
+ if (te->window && te->window->handle()) {
+ const QMargins margins = te->window->frameMargins();
+ if (!margins.isNull()) {
+ te->frameStrut.setCoords(margins.left(), margins.top(), margins.right(), margins.bottom());
+ q->data->fstrut_dirty = false;
}
}
}
@@ -12106,7 +12144,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const
return 0;
#else
if (!extra || !extra->topextra || !extra->topextra->window) {
- qWarning() << "Asking for share context for widget that does not have a window handle";
+ qWarning("Asking for share context for widget that does not have a window handle");
return 0;
}
QWidgetPrivate *that = const_cast<QWidgetPrivate *>(this);
@@ -12294,6 +12332,12 @@ QPaintEngine *QWidget::paintEngine() const
return 0; //##### @@@
}
+// Do not call QWindow::mapToGlobal() until QPlatformWindow is properly showing.
+static inline bool canMapPosition(QWindow *window)
+{
+ return window->handle() && !qt_window_private(window)->resizeEventPending;
+}
+
/*!
\fn QPoint QWidget::mapToGlobal(const QPoint &pos) const
@@ -12320,7 +12364,7 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
const QWidget *w = this;
while (w) {
QWindow *window = w->windowHandle();
- if (window && window->handle())
+ if (window && canMapPosition(window))
return window->mapToGlobal(QPoint(x, y));
x += w->data->crect.x();
@@ -12355,7 +12399,7 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const
const QWidget *w = this;
while (w) {
QWindow *window = w->windowHandle();
- if (window && window->handle())
+ if (window && canMapPosition(window))
return window->mapFromGlobal(QPoint(x, y));
x -= w->data->crect.x();
@@ -12669,6 +12713,9 @@ int QWidget::metric(PaintDeviceMetric m) const
return qRound(screen->physicalDotsPerInchY());
} else if (m == PdmDevicePixelRatio) {
return topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio();
+ } else if (m == PdmDevicePixelRatioScaled) {
+ return (QPaintDevice::devicePixelRatioFScale() *
+ (topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio()));
} else {
val = QPaintDevice::metric(m);// XXX
}
@@ -12794,7 +12841,7 @@ void QWidgetPrivate::setMask_sys(const QRegion &region)
Q_Q(QWidget);
if (const QWindow *window = q->windowHandle())
if (QPlatformWindow *platformWindow = window->handle())
- platformWindow->setMask(region);
+ platformWindow->setMask(QHighDpi::toNativeLocalRegion(region, window));
}
/*!
@@ -12847,6 +12894,65 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new
widget->setParent(static_cast<QWidget*>(newParent));
}
+#ifndef QT_NO_DEBUG_STREAM
+
+static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget)
+{
+ const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount);
+ const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute"));
+ debug << ", attributes=[";
+ int count = 0;
+ for (int a = 0; a < Qt::WA_AttributeCount; ++a) {
+ if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) {
+ if (count++)
+ debug << ',';
+ debug << me.valueToKey(a);
+ }
+ }
+ debug << ']';
+}
+
+QDebug operator<<(QDebug debug, const QWidget *widget)
+{
+ const QDebugStateSaver saver(debug);
+ debug.nospace();
+ if (widget) {
+ debug << widget->metaObject()->className() << '(' << (const void *)widget;
+ if (!widget->objectName().isEmpty())
+ debug << ", name=" << widget->objectName();
+ if (debug.verbosity() > 2) {
+ const QRect geometry = widget->geometry();
+ const QRect frameGeometry = widget->frameGeometry();
+ if (widget->isVisible())
+ debug << ", visible";
+ if (!widget->isEnabled())
+ debug << ", disabled";
+ debug << ", states=" << widget->windowState()
+ << ", type=" << widget->windowType() << ", flags=" << widget->windowFlags();
+ formatWidgetAttributes(debug, widget);
+ if (widget->isWindow())
+ debug << ", window";
+ debug << ", " << geometry.width() << 'x' << geometry.height()
+ << forcesign << geometry.x() << geometry.y() << noforcesign;
+ if (frameGeometry != geometry) {
+ const QMargins margins(geometry.x() - frameGeometry.x(),
+ geometry.y() - frameGeometry.y(),
+ frameGeometry.right() - geometry.right(),
+ frameGeometry.bottom() - geometry.bottom());
+ debug << ", margins=" << margins;
+ }
+ debug << ", devicePixelRatio=" << widget->devicePixelRatioF();
+ if (const WId wid = widget->internalWinId())
+ debug << ", winId=0x" << hex << wid << dec;
+ }
+ debug << ')';
+ } else {
+ debug << "QWidget(0x0)";
+ }
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
/*! \fn Qt::HANDLE QWidget::macCGHandle() const
\internal
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index c3913e9d45..a56f6e1133 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -89,6 +89,9 @@ class QGraphicsEffect;
class QRasterWindowSurface;
class QUnifiedToolbarSurface;
class QPixmap;
+#ifndef QT_NO_DEBUG_STREAM
+class QDebug;
+#endif
class QWidgetData
{
@@ -165,7 +168,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow)
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow)
- Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow)
+ Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) // deprecated
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
#ifndef QT_NO_TOOLTIP
@@ -200,7 +203,7 @@ public:
};
Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
- explicit QWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
+ explicit QWidget(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
~QWidget();
int devType() const Q_DECL_OVERRIDE;
@@ -590,7 +593,7 @@ public:
QWindow *windowHandle() const;
- static QWidget *createWindowContainer(QWindow *window, QWidget *parent=0, Qt::WindowFlags flags=0);
+ static QWidget *createWindowContainer(QWindow *window, QWidget *parent=Q_NULLPTR, Qt::WindowFlags flags=Qt::WindowFlags());
friend class QDesktopScreenWidget;
@@ -731,12 +734,12 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
#ifndef Q_QDOC
template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
{
- if (!o || !o->isWidgetType()) return 0;
+ if (!o || !o->isWidgetType()) return Q_NULLPTR;
return static_cast<QWidget*>(o);
}
template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
{
- if (!o || !o->isWidgetType()) return 0;
+ if (!o || !o->isWidgetType()) return Q_NULLPTR;
return static_cast<const QWidget*>(o);
}
#endif // !Q_QDOC
@@ -858,6 +861,10 @@ inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
#define QWIDGETSIZE_MAX ((1<<24)-1)
+#ifndef QT_NO_DEBUG_STREAM
+Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QWidget *);
+#endif
+
QT_END_NAMESPACE
#endif // QWIDGET_H
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index fe65cb19c7..7eb8d048b3 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -75,6 +75,7 @@ class QWidgetBackingStore;
class QGraphicsProxyWidget;
class QWidgetItemV2;
class QOpenGLContext;
+class QPlatformTextureList;
class QStyle;
@@ -153,6 +154,8 @@ struct QTLWExtra {
QWidgetBackingStoreTracker backingStoreTracker;
QBackingStore *backingStore;
QPainter *sharedPainter;
+ QWidgetWindow *window;
+ QOpenGLContext *shareContext;
// Implicit pointers (shared_null).
QString caption; // widget caption
@@ -167,6 +170,9 @@ struct QTLWExtra {
QRect frameStrut;
QRect normalGeometry; // used by showMin/maximized/FullScreen
Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
+ int initialScreenIndex; // Screen number when passing a QDesktop[Screen]Widget as parent.
+
+ QVector<QPlatformTextureList *> widgetTextures;
// *************************** Cross-platform bit fields ****************************
uint opacity : 8;
@@ -210,9 +216,6 @@ struct QTLWExtra {
// starting position as 0,0 instead of the normal starting position.
bool wasMaximized;
#endif
- QWidgetWindow *window;
- QOpenGLContext *shareContext;
- int initialScreenIndex; // Screen number when passing a QDesktop[Screen]Widget as parent.
};
struct QWExtra {
@@ -740,6 +743,9 @@ public:
#ifndef QT_NO_IM
uint inheritsInputMethodHints : 1;
#endif
+#ifndef QT_NO_OPENGL
+ uint renderToTextureReallyDirty : 1;
+#endif
// *************************** Platform specific ************************************
#if defined(Q_OS_WIN)
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 2a339cda4c..d9d1c887c1 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -79,7 +79,6 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion &region, QBack
Q_ASSERT(widget);
Q_ASSERT(backingStore);
Q_ASSERT(tlw);
-
#if !defined(QT_NO_PAINT_DEBUG)
static int flushUpdate = qEnvironmentVariableIntValue("QT_FLUSH_UPDATE");
if (flushUpdate > 0)
@@ -105,13 +104,16 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion &region, QBack
#ifndef QT_NO_OPENGL
if (widgetTextures) {
+ qt_window_private(tlw->windowHandle())->compositing = true;
widget->window()->d_func()->sendComposeStatus(widget->window(), false);
// A window may have alpha even when the app did not request
// WA_TranslucentBackground. Therefore the compositor needs to know whether the app intends
// to rely on translucency, in order to decide if it should clear to transparent or opaque.
const bool translucentBackground = widget->testAttribute(Qt::WA_TranslucentBackground);
+ // Use the tlw's context, not widget's. The difference is important with native child
+ // widgets where tlw != widget.
backingStore->handle()->composeAndFlush(widget->windowHandle(), region, offset, widgetTextures,
- widget->d_func()->shareContext(), translucentBackground);
+ tlw->d_func()->shareContext(), translucentBackground);
widget->window()->d_func()->sendComposeStatus(widget->window(), true);
} else
#endif
@@ -446,6 +448,26 @@ void QWidgetBackingStore::sendUpdateRequest(QWidget *widget, UpdateTime updateTi
if (!widget)
return;
+#ifndef QT_NO_OPENGL
+ // Having every repaint() leading to a sync/flush is bad as it causes
+ // compositing and waiting for vsync each and every time. Change to
+ // UpdateLater, except for approx. once per frame to prevent starvation in
+ // case the control does not get back to the event loop.
+ QWidget *w = widget->window();
+ if (updateTime == UpdateNow && w && w->windowHandle() && QWindowPrivate::get(w->windowHandle())->compositing) {
+ int refresh = 60;
+ QScreen *ws = w->windowHandle()->screen();
+ if (ws)
+ refresh = ws->refreshRate();
+ QWindowPrivate *wd = QWindowPrivate::get(w->windowHandle());
+ if (wd->lastComposeTime.isValid()) {
+ const qint64 elapsed = wd->lastComposeTime.elapsed();
+ if (elapsed <= qint64(1000.0f / refresh))
+ updateTime = UpdateLater;
+ }
+ }
+#endif
+
switch (updateTime) {
case UpdateLater:
updateRequestSent = true;
@@ -619,7 +641,11 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget,
const QRect widgetRect = widget->d_func()->effectiveRectFor(rect);
- const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint())));
+ QRect translatedRect = widgetRect;
+ if (widget != tlw)
+ translatedRect.translate(widget->mapTo(tlw, QPoint()));
+ // Graphics effects may exceed window size, clamp.
+ translatedRect = translatedRect.intersected(QRect(QPoint(), tlw->size()));
if (qt_region_strictContains(dirty, translatedRect)) {
if (updateTime == UpdateNow)
sendUpdateRequest(tlw, updateTime);
@@ -741,7 +767,6 @@ void QWidgetBackingStore::updateLists(QWidget *cur)
QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel)
: tlw(topLevel),
dirtyOnScreenWidgets(0),
- widgetTextures(0),
fullUpdatePending(0),
updateRequestSent(0),
textureListWatcher(0),
@@ -761,11 +786,7 @@ QWidgetBackingStore::~QWidgetBackingStore()
for (int c = 0; c < dirtyRenderToTextureWidgets.size(); ++c)
resetWidget(dirtyRenderToTextureWidgets.at(c));
-#ifndef QT_NO_OPENGL
- delete widgetTextures;
delete dirtyOnScreenWidgets;
-#endif
- dirtyOnScreenWidgets = 0;
}
//parent's coordinates; move whole rect; update parent and widget
@@ -793,8 +814,9 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
destRect = destRect.translated(dx, dy).intersected(clipR);
const QRect sourceRect(destRect.translated(-dx, -dy));
const QRect parentRect(rect & clipR);
+ const bool nativeWithTextureChild = textureChildSeen && q->internalWinId();
- bool accelerateMove = accelEnv && isOpaque
+ bool accelerateMove = accelEnv && isOpaque && !nativeWithTextureChild
#ifndef QT_NO_GRAPHICSVIEW
// No accelerate move for proxy widgets.
&& !tlw->d_func()->extra->proxyWidget
@@ -914,6 +936,121 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy)
}
}
+#ifndef QT_NO_OPENGL
+static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatformTextureList *widgetTextures, QVector<QWidget *> *nativeChildren)
+{
+ QWidgetPrivate *wd = QWidgetPrivate::get(widget);
+ if (wd->renderToTexture) {
+ QPlatformTextureList::Flags flags = 0;
+ if (widget->testAttribute(Qt::WA_AlwaysStackOnTop))
+ flags |= QPlatformTextureList::StacksOnTop;
+ const QRect rect(widget->mapTo(tlw, QPoint()), widget->size());
+ widgetTextures->appendTexture(widget, wd->textureId(), rect, wd->clipRect(), flags);
+ }
+
+ for (int i = 0; i < wd->children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(wd->children.at(i));
+ // Stop at native widgets but store them. Stop at hidden widgets too.
+ if (w && !w->isWindow() && w->internalWinId())
+ nativeChildren->append(w);
+ if (w && !w->isWindow() && !w->internalWinId() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen)
+ findTextureWidgetsRecursively(tlw, w, widgetTextures, nativeChildren);
+ }
+}
+
+static void findAllTextureWidgetsRecursively(QWidget *tlw, QWidget *widget)
+{
+ // textureChildSeen does not take native child widgets into account and that's good.
+ if (QWidgetPrivate::get(widget)->textureChildSeen) {
+ QVector<QWidget *> nativeChildren;
+ QScopedPointer<QPlatformTextureList> tl(new QPlatformTextureList);
+ // Look for texture widgets (incl. widget itself) from 'widget' down,
+ // but skip subtrees with a parent of a native child widget.
+ findTextureWidgetsRecursively(tlw, widget, tl.data(), &nativeChildren);
+ // tl may be empty regardless of textureChildSeen if we have native or hidden children.
+ if (!tl->isEmpty())
+ QWidgetPrivate::get(tlw)->topData()->widgetTextures.append(tl.take());
+ // Native child widgets, if there was any, get their own separate QPlatformTextureList.
+ foreach (QWidget *ncw, nativeChildren) {
+ if (QWidgetPrivate::get(ncw)->textureChildSeen)
+ findAllTextureWidgetsRecursively(tlw, ncw);
+ }
+ }
+}
+
+Q_GLOBAL_STATIC(QPlatformTextureList, qt_dummy_platformTextureList)
+
+static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget)
+{
+ foreach (QPlatformTextureList *tl, QWidgetPrivate::get(tlw)->topData()->widgetTextures) {
+ Q_ASSERT(!tl->isEmpty());
+ for (int i = 0; i < tl->count(); ++i) {
+ QWidget *w = static_cast<QWidget *>(tl->source(i));
+ if ((w->internalWinId() && w == widget) || (!w->internalWinId() && w->nativeParentWidget() == widget))
+ return tl;
+ }
+ }
+
+ if (QWidgetPrivate::get(tlw)->textureChildSeen) {
+ // No render-to-texture widgets in the (sub-)tree due to hidden or native
+ // children. Returning null results in using the normal backingstore flush path
+ // without OpenGL-based compositing. This is very desirable normally. However,
+ // some platforms cannot handle switching between the non-GL and GL paths for
+ // their windows so it has to be opt-in.
+ static bool switchableWidgetComposition =
+ QGuiApplicationPrivate::instance()->platformIntegration()
+ ->hasCapability(QPlatformIntegration::SwitchableWidgetComposition);
+ if (!switchableWidgetComposition)
+ return qt_dummy_platformTextureList();
+ }
+
+ return 0;
+}
+
+// Watches one or more QPlatformTextureLists for changes in the lock state and
+// triggers a backingstore sync when all the registered lists turn into
+// unlocked state. This is essential when a custom composeAndFlush()
+// implementation in a platform plugin is not synchronous and keeps
+// holding on to the textures for some time even after returning from there.
+QPlatformTextureListWatcher::QPlatformTextureListWatcher(QWidgetBackingStore *backingStore)
+ : m_backingStore(backingStore)
+{
+}
+
+void QPlatformTextureListWatcher::watch(QPlatformTextureList *textureList)
+{
+ connect(textureList, SIGNAL(locked(bool)), SLOT(onLockStatusChanged(bool)));
+ m_locked[textureList] = textureList->isLocked();
+}
+
+bool QPlatformTextureListWatcher::isLocked() const
+{
+ foreach (bool v, m_locked) {
+ if (v)
+ return true;
+ }
+ return false;
+}
+
+void QPlatformTextureListWatcher::onLockStatusChanged(bool locked)
+{
+ QPlatformTextureList *tl = static_cast<QPlatformTextureList *>(sender());
+ m_locked[tl] = locked;
+ if (!isLocked())
+ m_backingStore->sync();
+}
+
+#else
+
+static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget)
+{
+ Q_UNUSED(tlw);
+ Q_UNUSED(widget);
+ return Q_NULLPTR;
+}
+
+#endif // QT_NO_OPENGL
+
static inline bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra)
{
if (!tlw || !tlwExtra || !tlw->testAttribute(Qt::WA_Mapped) || !tlw->isVisible())
@@ -942,7 +1079,8 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg
// Nothing to repaint.
if (!isDirty() && store->size().isValid()) {
- qt_flush(exposedWidget, exposedRegion, store, tlw, tlwOffset, widgetTextures, this);
+ QPlatformTextureList *tl = widgetTexturesFor(tlw, exposedWidget);
+ qt_flush(exposedWidget, tl ? QRegion() : exposedRegion, store, tlw, tlwOffset, tl, this);
return;
}
@@ -954,45 +1092,6 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg
doSync();
}
-#ifndef QT_NO_OPENGL
-static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatformTextureList *widgetTextures)
-{
- QWidgetPrivate *wd = QWidgetPrivate::get(widget);
- if (wd->renderToTexture) {
- QPlatformTextureList::Flags flags = 0;
- if (widget->testAttribute(Qt::WA_AlwaysStackOnTop))
- flags |= QPlatformTextureList::StacksOnTop;
- const QRect rect(widget->mapTo(tlw, QPoint()), widget->size());
- widgetTextures->appendTexture(widget, wd->textureId(), rect, wd->clipRect(), flags);
- }
-
- for (int i = 0; i < wd->children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(wd->children.at(i));
- if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen)
- findTextureWidgetsRecursively(tlw, w, widgetTextures);
- }
-}
-
-QPlatformTextureListWatcher::QPlatformTextureListWatcher(QWidgetBackingStore *backingStore)
- : m_locked(false),
- m_backingStore(backingStore)
-{
-}
-
-void QPlatformTextureListWatcher::watch(QPlatformTextureList *textureList)
-{
- connect(textureList, SIGNAL(locked(bool)), SLOT(onLockStatusChanged(bool)));
- m_locked = textureList->isLocked();
-}
-
-void QPlatformTextureListWatcher::onLockStatusChanged(bool locked)
-{
- m_locked = locked;
- if (!locked)
- m_backingStore->sync();
-}
-#endif // QT_NO_OPENGL
-
/*!
Synchronizes the backing store, i.e. dirty areas are repainted and flushed.
*/
@@ -1020,12 +1119,19 @@ void QWidgetBackingStore::sync()
if (textureListWatcher && !textureListWatcher->isLocked()) {
textureListWatcher->deleteLater();
textureListWatcher = 0;
- } else if (widgetTextures && widgetTextures->isLocked()) {
- if (!textureListWatcher)
- textureListWatcher = new QPlatformTextureListWatcher(this);
- if (!textureListWatcher->isLocked())
- textureListWatcher->watch(widgetTextures);
- return;
+ } else if (!tlwExtra->widgetTextures.isEmpty()) {
+ bool skipSync = false;
+ foreach (QPlatformTextureList *tl, tlwExtra->widgetTextures) {
+ if (tl->isLocked()) {
+ if (!textureListWatcher)
+ textureListWatcher = new QPlatformTextureListWatcher(this);
+ if (!textureListWatcher->isLocked())
+ textureListWatcher->watch(tl);
+ skipSync = true;
+ }
+ }
+ if (skipSync) // cannot compose due to widget textures being in use
+ return;
}
#endif
@@ -1118,13 +1224,14 @@ void QWidgetBackingStore::doSync()
dirtyWidgets.clear();
#ifndef QT_NO_OPENGL
- delete widgetTextures;
- widgetTextures = 0;
- if (tlw->d_func()->textureChildSeen) {
- widgetTextures = new QPlatformTextureList;
- findTextureWidgetsRecursively(tlw, tlw, widgetTextures);
- }
- qt_window_private(tlw->windowHandle())->compositing = widgetTextures;
+ // Find all render-to-texture child widgets (including self).
+ // The search is cut at native widget boundaries, meaning that each native child widget
+ // has its own list for the subtree below it.
+ QTLWExtra *tlwExtra = tlw->d_func()->topData();
+ qDeleteAll(tlwExtra->widgetTextures);
+ tlwExtra->widgetTextures.clear();
+ findAllTextureWidgetsRecursively(tlw, tlw);
+ qt_window_private(tlw->windowHandle())->compositing = false; // will get updated in qt_flush()
fullUpdatePending = false;
#endif
@@ -1144,6 +1251,17 @@ void QWidgetBackingStore::doSync()
for (int i = 0; i < paintPending.count(); ++i) {
QWidget *w = paintPending[i];
w->d_func()->sendPaintEvent(w->rect());
+ if (w != tlw) {
+ QWidget *npw = w->nativeParentWidget();
+ if (w->internalWinId() || (npw && npw != tlw)) {
+ if (!w->internalWinId())
+ w = npw;
+ QWidgetPrivate *wPrivate = w->d_func();
+ if (!wPrivate->needsFlush)
+ wPrivate->needsFlush = new QRegion;
+ appendDirtyOnScreenWidget(w);
+ }
+ }
}
// We might have newly exposed areas on the screen if this function was
@@ -1155,11 +1273,14 @@ void QWidgetBackingStore::doSync()
}
#ifndef QT_NO_OPENGL
- if (widgetTextures && widgetTextures->count()) {
- for (int i = 0; i < widgetTextures->count(); ++i) {
- QWidget *w = static_cast<QWidget *>(widgetTextures->source(i));
+ foreach (QPlatformTextureList *tl, tlwExtra->widgetTextures) {
+ for (int i = 0; i < tl->count(); ++i) {
+ QWidget *w = static_cast<QWidget *>(tl->source(i));
if (dirtyRenderToTextureWidgets.contains(w)) {
- const QRect rect = widgetTextures->geometry(i); // mapped to the tlw already
+ const QRect rect = tl->geometry(i); // mapped to the tlw already
+ // Set a flag to indicate that the paint event for this
+ // render-to-texture widget must not to be optimized away.
+ w->d_func()->renderToTextureReallyDirty = 1;
dirty += rect;
toClean += rect;
}
@@ -1236,31 +1357,39 @@ void QWidgetBackingStore::doSync()
*/
void QWidgetBackingStore::flush(QWidget *widget)
{
+ const bool hasDirtyOnScreenWidgets = dirtyOnScreenWidgets && !dirtyOnScreenWidgets->isEmpty();
+ bool flushed = false;
+
+ // Flush the region in dirtyOnScreen.
if (!dirtyOnScreen.isEmpty()) {
QWidget *target = widget ? widget : tlw;
- qt_flush(target, dirtyOnScreen, store, tlw, tlwOffset, widgetTextures, this);
+ qt_flush(target, dirtyOnScreen, store, tlw, tlwOffset, widgetTexturesFor(tlw, tlw), this);
dirtyOnScreen = QRegion();
-#ifndef QT_NO_OPENGL
- if (widgetTextures && widgetTextures->count())
- return;
-#endif
+ flushed = true;
}
- if (!dirtyOnScreenWidgets || dirtyOnScreenWidgets->isEmpty()) {
+ // Render-to-texture widgets are not in dirtyOnScreen so flush if we have not done it above.
+ if (!flushed && !hasDirtyOnScreenWidgets) {
#ifndef QT_NO_OPENGL
- if (widgetTextures && widgetTextures->count()) {
- QWidget *target = widget ? widget : tlw;
- qt_flush(target, QRegion(), store, tlw, tlwOffset, widgetTextures, this);
+ if (!tlw->d_func()->topData()->widgetTextures.isEmpty()) {
+ QPlatformTextureList *tl = widgetTexturesFor(tlw, tlw);
+ if (tl) {
+ QWidget *target = widget ? widget : tlw;
+ qt_flush(target, QRegion(), store, tlw, tlwOffset, tl, this);
+ }
}
#endif
- return;
}
+ if (!hasDirtyOnScreenWidgets)
+ return;
+
for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
QWidget *w = dirtyOnScreenWidgets->at(i);
QWidgetPrivate *wd = w->d_func();
Q_ASSERT(wd->needsFlush);
- qt_flush(w, *wd->needsFlush, store, tlw, tlwOffset, 0, this);
+ QPlatformTextureList *widgetTexturesForNative = wd->textureChildSeen ? widgetTexturesFor(tlw, w) : 0;
+ qt_flush(w, *wd->needsFlush, store, tlw, tlwOffset, widgetTexturesForNative, this);
*wd->needsFlush = QRegion();
}
dirtyOnScreenWidgets->clear();
diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h
index bcffa3be79..c45e60ef6e 100644
--- a/src/widgets/kernel/qwidgetbackingstore_p.h
+++ b/src/widgets/kernel/qwidgetbackingstore_p.h
@@ -71,13 +71,13 @@ class QPlatformTextureListWatcher : public QObject
public:
QPlatformTextureListWatcher(QWidgetBackingStore *backingStore);
void watch(QPlatformTextureList *textureList);
- bool isLocked() const { return m_locked; }
+ bool isLocked() const;
private slots:
void onLockStatusChanged(bool locked);
private:
- bool m_locked;
+ QHash<QPlatformTextureList *, bool> m_locked;
QWidgetBackingStore *m_backingStore;
};
#endif
@@ -128,7 +128,6 @@ private:
QVector<QWidget *> dirtyRenderToTextureWidgets;
QVector<QWidget *> *dirtyOnScreenWidgets;
QList<QWidget *> staticWidgets;
- QPlatformTextureList *widgetTextures;
QBackingStore *store;
uint fullUpdatePending : 1;
uint updateRequestSent : 1;
@@ -301,6 +300,8 @@ private:
friend class QWidgetPrivate;
friend class QWidget;
friend class QBackingStore;
+
+ Q_DISABLE_COPY(QWidgetBackingStore)
};
QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp
index b0dcc4aa1b..fc02c9c77d 100644
--- a/src/widgets/kernel/qwidgetsvariant.cpp
+++ b/src/widgets/kernel/qwidgetsvariant.cpp
@@ -109,7 +109,7 @@ static void streamDebug(QDebug dbg, const QVariant &v)
dbg.nospace() << *v_cast<QSizePolicy>(d);
break;
default:
- dbg.nospace() << "QMetaType::Type(" << d->type << ")";
+ dbg.nospace() << "QMetaType::Type(" << d->type << ')';
}
}
#endif
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index cc50cde799..6f8d97e028 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -45,13 +45,13 @@
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformwindow.h>
#include <private/qgesturemanager_p.h>
+#include <private/qhighdpiscaling_p.h>
QT_BEGIN_NAMESPACE
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
QWidget *qt_button_down = 0; // widget got last button-down
-static QPointer<QWidget> qt_tablet_target = 0;
// popup control
QWidget *qt_popup_down = 0; // popup that contains the pressed widget
@@ -161,7 +161,7 @@ bool QWidgetWindow::event(QEvent *event)
if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) {
// \a event is uninteresting for QWidgetWindow, the event was probably
// generated before WA_DontShowOnScreen was set
- return m_widget->event(event);
+ return QCoreApplication::sendEvent(m_widget, event);
}
switch (event->type()) {
@@ -303,7 +303,7 @@ bool QWidgetWindow::event(QEvent *event)
break;
}
- if (m_widget->event(event) && event->type() != QEvent::Timer)
+ if (QCoreApplication::sendEvent(m_widget, event) && event->type() != QEvent::Timer)
return true;
return QWindow::event(event);
@@ -446,8 +446,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (receiver != popup)
widgetPos = receiver->mapFromGlobal(event->globalPos());
QWidget *alien = m_widget->childAt(m_widget->mapFromGlobal(event->globalPos()));
- QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event));
+ QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
+ event->button(), event->buttons(), event->modifiers(), event->source());
e.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &e, alien, receiver->window(), &qt_button_down, qt_last_mouse_receiver);
qt_last_mouse_receiver = receiver;
@@ -489,9 +489,9 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (globalGeometry.contains(event->globalPos())) {
// Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec()
const QPoint localPos = win->mapFromGlobal(event->globalPos());
- QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(),
+ event->button(), event->buttons(), event->modifiers(), event->source());
QCoreApplicationPrivate::setEventSpontaneous(e, true);
- QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
e->setTimestamp(event->timestamp());
QCoreApplication::postEvent(win, e);
}
@@ -548,11 +548,11 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
// The preceding statement excludes MouseButtonPress events which caused
// creation of a MouseButtonDblClick event. QTBUG-25831
QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(),
- event->button(), event->buttons(), event->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&translated, QGuiApplicationPrivate::mouseEventSource(event));
+ event->button(), event->buttons(), event->modifiers(), event->source());
translated.setTimestamp(event->timestamp());
QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget,
&qt_button_down, qt_last_mouse_receiver);
+ event->setAccepted(translated.isAccepted());
}
#ifndef QT_NO_CONTEXTMENU
if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton
@@ -673,7 +673,7 @@ void QWidgetWindow::updateNormalGeometry()
// Ask platform window, default to widget geometry.
QRect normalGeometry;
if (const QPlatformWindow *pw = handle())
- normalGeometry = pw->normalGeometry();
+ normalGeometry = QHighDpi::fromNativePixels(pw->normalGeometry(), this);
if (!normalGeometry.isValid() && effectiveState(m_widget->windowState()) == Qt::WindowNoState)
normalGeometry = m_widget->geometry();
if (normalGeometry.isValid())
@@ -708,6 +708,7 @@ void QWidgetWindow::handleCloseEvent(QCloseEvent *event)
{
bool is_closing = m_widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
event->setAccepted(is_closing);
+ QWindow::event(event); // Call QWindow QCloseEvent handler.
}
#ifndef QT_NO_WHEELEVENT
@@ -794,7 +795,7 @@ void QWidgetWindow::handleDragLeaveEvent(QDragLeaveEvent *event)
void QWidgetWindow::handleDropEvent(QDropEvent *event)
{
if (m_dragTarget.isNull()) {
- qWarning() << Q_FUNC_INFO << m_widget << ": No drag target set.";
+ qWarning() << m_widget << ": No drag target set.";
event->ignore();
return;
}
@@ -874,6 +875,7 @@ bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long
#ifndef QT_NO_TABLETEVENT
void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
{
+ static QPointer<QWidget> qt_tablet_target = 0;
if (event->type() == QEvent::TabletPress) {
QWidget *widget = m_widget->childAt(event->pos());
if (!widget)
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index 9d3a4ef0b2..3885431b05 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -34,6 +34,8 @@
#include "qwindowcontainer_p.h"
#include "qwidget_p.h"
#include <QtGui/qwindow.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
#include <QDebug>
#include <QMdiSubWindow>
@@ -196,6 +198,13 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt:
return;
}
+ // The embedded QWindow must use the same logic as QWidget when it comes to the surface type.
+ // Otherwise we may end up with BadMatch failures on X11.
+ if (embeddedWindow->surfaceType() == QSurface::RasterSurface
+ && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)
+ && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets))
+ embeddedWindow->setSurfaceType(QSurface::RasterGLSurface);
+
d->window = embeddedWindow;
d->window->setParent(&d->fakeParent);
setAcceptDrops(true);
diff --git a/src/widgets/statemachine/qkeyeventtransition.cpp b/src/widgets/statemachine/qkeyeventtransition.cpp
index 3283003e2e..67af85dd27 100644
--- a/src/widgets/statemachine/qkeyeventtransition.cpp
+++ b/src/widgets/statemachine/qkeyeventtransition.cpp
@@ -117,7 +117,7 @@ int QKeyEventTransition::key() const
}
/*!
- Sets the key that this key event transition will check for.
+ Sets the \a key that this key event transition will check for.
*/
void QKeyEventTransition::setKey(int key)
{
diff --git a/src/widgets/statemachine/qkeyeventtransition.h b/src/widgets/statemachine/qkeyeventtransition.h
index 5dd0685d0b..ad159eaa22 100644
--- a/src/widgets/statemachine/qkeyeventtransition.h
+++ b/src/widgets/statemachine/qkeyeventtransition.h
@@ -48,9 +48,9 @@ class Q_WIDGETS_EXPORT QKeyEventTransition : public QEventTransition
Q_PROPERTY(int key READ key WRITE setKey)
Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
- QKeyEventTransition(QState *sourceState = 0);
+ QKeyEventTransition(QState *sourceState = Q_NULLPTR);
QKeyEventTransition(QObject *object, QEvent::Type type, int key,
- QState *sourceState = 0);
+ QState *sourceState = Q_NULLPTR);
~QKeyEventTransition();
int key() const;
diff --git a/src/widgets/statemachine/qmouseeventtransition.h b/src/widgets/statemachine/qmouseeventtransition.h
index d9bac9e1a0..b4db61279d 100644
--- a/src/widgets/statemachine/qmouseeventtransition.h
+++ b/src/widgets/statemachine/qmouseeventtransition.h
@@ -49,9 +49,9 @@ class Q_WIDGETS_EXPORT QMouseEventTransition : public QEventTransition
Q_PROPERTY(Qt::MouseButton button READ button WRITE setButton)
Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
- QMouseEventTransition(QState *sourceState = 0);
+ QMouseEventTransition(QState *sourceState = Q_NULLPTR);
QMouseEventTransition(QObject *object, QEvent::Type type,
- Qt::MouseButton button, QState *sourceState = 0);
+ Qt::MouseButton button, QState *sourceState = Q_NULLPTR);
~QMouseEventTransition();
Qt::MouseButton button() const;
diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp
index c73908d0a5..4489f36ab7 100644
--- a/src/widgets/styles/qandroidstyle.cpp
+++ b/src/widgets/styles/qandroidstyle.cpp
@@ -298,8 +298,7 @@ void QAndroidStyle::drawPrimitive(PrimitiveElement pe,
}
} else if (pe == PE_FrameGroupBox) {
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt);
- if (frame2 && (frame2->features & QStyleOptionFrameV2::Flat)) {
+ if (frame->features & QStyleOptionFrame::Flat) {
QRect fr = frame->rect;
QPoint p1(fr.x(), fr.y() + 1);
QPoint p2(fr.x() + fr.width(), p1.y());
@@ -403,7 +402,7 @@ void QAndroidStyle::drawComplexControl(ComplexControl cc,
if (groupBox->subControls & SC_GroupBoxCheckBox)
checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget);
if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
- QStyleOptionFrameV2 frame;
+ QStyleOptionFrame frame;
frame.QStyleOption::operator=(*groupBox);
frame.features = groupBox->features;
frame.lineWidth = groupBox->lineWidth;
@@ -1617,15 +1616,13 @@ void QAndroidStyle::AndroidProgressBarControl::drawControl(const QStyleOption *o
if (const QStyleOptionProgressBar *progressBarOption =
qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- QStyleOptionProgressBarV2 progressBarV2(*progressBarOption);
if (m_progressDrawable->type() == QAndroidStyle::Layer) {
+ const double fraction = progressBarOption->progress / double(progressBarOption->maximum - progressBarOption->minimum);
QAndroidStyle::AndroidDrawable *clipDrawable = static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->layer(m_progressId);
if (clipDrawable->type() == QAndroidStyle::Clip)
- static_cast<QAndroidStyle::AndroidClipDrawable *>(clipDrawable)->setFactor(double(progressBarV2.progress) / double(progressBarV2.maximum - progressBarV2.minimum),
- progressBarV2.orientation);
+ static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, progressBarOption->orientation);
else
- static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, double(progressBarV2.progress) / double(progressBarV2.maximum - progressBarV2.minimum),
- progressBarV2.orientation);
+ static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, progressBarOption->orientation);
}
m_progressDrawable->draw(p, option);
}
@@ -1637,8 +1634,7 @@ QRect QAndroidStyle::AndroidProgressBarControl::subElementRect(QStyle::SubElemen
{
if (const QStyleOptionProgressBar *progressBarOption =
qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- QStyleOptionProgressBarV2 progressBarV2(*progressBarOption);
- const bool horizontal = progressBarV2.orientation == Qt::Vertical;
+ const bool horizontal = progressBarOption->orientation == Qt::Vertical;
if (!m_background)
return option->rect;
@@ -1680,8 +1676,7 @@ QSize QAndroidStyle::AndroidProgressBarControl::sizeFromContents(const QStyleOpt
if (const QStyleOptionProgressBar *progressBarOption =
qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
- QStyleOptionProgressBarV2 progressBarV2(*progressBarOption);
- if (progressBarV2.orientation == Qt::Vertical) {
+ if (progressBarOption->orientation == Qt::Vertical) {
if (sz.height() > m_maxSize.height())
sz.setHeight(m_maxSize.height());
} else {
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index a4ecfc547b..355a3d2c3f 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -80,6 +80,11 @@
QT_BEGIN_NAMESPACE
+static QWindow *qt_getWindow(const QWidget *widget)
+{
+ return widget ? widget->window()->windowHandle() : 0;
+}
+
/*!
\class QCommonStyle
\brief The QCommonStyle class encapsulates the common Look and Feel of a GUI.
@@ -260,8 +265,8 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
case PE_IndicatorProgressChunk:
{
bool vertical = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt))
- vertical = (pb2->orientation == Qt::Vertical);
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt))
+ vertical = pb->orientation == Qt::Vertical;
if (!vertical) {
p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6,
opt->palette.brush(QPalette::Highlight));
@@ -395,7 +400,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
mode = QIcon::Disabled;
QIcon::State state = opt->state & State_Sunken ? QIcon::On : QIcon::Off;
- QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(size, mode, state);
+ QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(qt_getWindow(widget), QSize(size, size), mode, state);
proxy()->drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap);
break;
}
@@ -1067,7 +1072,7 @@ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItem *opt, QRect
Uses the same computation than in QTabBar::tabSizeHint
*/
-void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const
+void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const
{
Q_ASSERT(textRect);
Q_ASSERT(iconRect);
@@ -1237,7 +1242,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (button->state & State_On)
state = QIcon::On;
- QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
+ QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state);
int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
@@ -1314,7 +1319,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
QPixmap pix;
QRect textRect = btn->rect;
if (!btn->icon.isNull()) {
- pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
+ pix = btn->icon.pixmap(qt_getWindow(widget), btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
proxy()->drawItemPixmap(p, btn->rect, alignment, pix);
if (btn->direction == Qt::RightToLeft)
textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
@@ -1355,7 +1360,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
| Qt::TextSingleLine;
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
alignment |= Qt::TextHideMnemonic;
- QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
+ int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
+ QPixmap pix = mbi->icon.pixmap(qt_getWindow(widget), QSize(iconExtent, iconExtent), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
if (!pix.isNull())
proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
else
@@ -1372,7 +1378,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
case CE_ProgressBar:
if (const QStyleOptionProgressBar *pb
= qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
- QStyleOptionProgressBarV2 subopt = *pb;
+ QStyleOptionProgressBar subopt = *pb;
subopt.rect = subElementRect(SE_ProgressBarGroove, pb, widget);
proxy()->drawControl(CE_ProgressBarGroove, &subopt, p, widget);
subopt.rect = subElementRect(SE_ProgressBarContents, pb, widget);
@@ -1390,10 +1396,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
break;
case CE_ProgressBarLabel:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
- bool vertical = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- vertical = (pb2->orientation == Qt::Vertical);
- }
+ const bool vertical = pb->orientation == Qt::Vertical;
if (!vertical) {
QPalette::ColorRole textRole = QPalette::NoRole;
if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible
@@ -1418,18 +1421,12 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
QRect rect = pb->rect;
- bool vertical = false;
- bool inverted = false;
+ const bool vertical = pb->orientation == Qt::Vertical;
+ const bool inverted = pb->invertedAppearance;
qint64 minimum = qint64(pb->minimum);
qint64 maximum = qint64(pb->maximum);
qint64 progress = qint64(pb->progress);
- // Get extra style options if version 2
- const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
- if (pb2) {
- vertical = (pb2->orientation == Qt::Vertical);
- inverted = pb2->invertedAppearance;
- }
QMatrix m;
if (vertical) {
@@ -1489,7 +1486,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
int x0 = reverse ? rect.right() - ((unit_width > 1) ? unit_width : 0)
: rect.x();
- QStyleOptionProgressBarV2 pbBits = *pb;
+ QStyleOptionProgressBar pbBits = *pb;
pbBits.rect = rect;
pbBits.palette = pal2;
int myY = pbBits.rect.y();
@@ -1519,8 +1516,9 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
QRect rect = header->rect;
if (!header->icon.isNull()) {
+ int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
QPixmap pixmap
- = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
+ = header->icon.pixmap(qt_getWindow(widget), QSize(iconExtent, iconExtent), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
int pixw = pixmap.width() / pixmap.devicePixelRatio();
QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size() / pixmap.devicePixelRatio(), rect);
@@ -1579,7 +1577,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
mode = QIcon::Active;
else
mode = QIcon::Normal;
- pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize),
+ pm = toolbutton->icon.pixmap(qt_getWindow(widget), toolbutton->rect.size().boundedTo(toolbutton->iconSize),
mode, state);
pmSize = pm.size() / pm.devicePixelRatio();
}
@@ -1800,7 +1798,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
bool enabled = tb->state & State_Enabled;
bool selected = tb->state & State_Selected;
- QPixmap pm = tb->icon.pixmap(proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget),
+ int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget);
+ QPixmap pm = tb->icon.pixmap(qt_getWindow(widget), QSize(iconExtent, iconExtent),
enabled ? QIcon::Normal : QIcon::Disabled);
QRect cr = subElementRect(QStyle::SE_ToolBoxTabContents, tb, widget);
@@ -1843,12 +1842,11 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
break;
case CE_TabBarTabLabel:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- QStyleOptionTabV3 tabV2(*tab);
- QRect tr = tabV2.rect;
- bool verticalTabs = tabV2.shape == QTabBar::RoundedEast
- || tabV2.shape == QTabBar::RoundedWest
- || tabV2.shape == QTabBar::TriangularEast
- || tabV2.shape == QTabBar::TriangularWest;
+ QRect tr = tab->rect;
+ bool verticalTabs = tab->shape == QTabBar::RoundedEast
+ || tab->shape == QTabBar::RoundedWest
+ || tab->shape == QTabBar::TriangularEast
+ || tab->shape == QTabBar::TriangularWest;
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic;
if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget))
@@ -1857,7 +1855,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (verticalTabs) {
p->save();
int newX, newY, newRot;
- if (tabV2.shape == QTabBar::RoundedEast || tabV2.shape == QTabBar::TriangularEast) {
+ if (tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::TriangularEast) {
newX = tr.width() + tr.x();
newY = tr.y();
newRot = 90;
@@ -1871,15 +1869,15 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
p->setTransform(m, true);
}
QRect iconRect;
- d->tabLayout(&tabV2, widget, &tr, &iconRect);
+ d->tabLayout(tab, widget, &tr, &iconRect);
tr = proxy()->subElementRect(SE_TabBarTabText, opt, widget); //we compute tr twice because the style may override subElementRect
- if (!tabV2.icon.isNull()) {
- QPixmap tabIcon = tabV2.icon.pixmap(tabV2.iconSize,
- (tabV2.state & State_Enabled) ? QIcon::Normal
- : QIcon::Disabled,
- (tabV2.state & State_Selected) ? QIcon::On
- : QIcon::Off);
+ if (!tab->icon.isNull()) {
+ QPixmap tabIcon = tab->icon.pixmap(qt_getWindow(widget), tab->iconSize,
+ (tab->state & State_Enabled) ? QIcon::Normal
+ : QIcon::Disabled,
+ (tab->state & State_Selected) ? QIcon::On
+ : QIcon::Off);
p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon);
}
@@ -1887,17 +1885,17 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (verticalTabs)
p->restore();
- if (tabV2.state & State_HasFocus) {
+ if (tab->state & State_HasFocus) {
const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
int x1, x2;
- x1 = tabV2.rect.left();
- x2 = tabV2.rect.right() - 1;
+ x1 = tab->rect.left();
+ x2 = tab->rect.right() - 1;
QStyleOptionFocusRect fropt;
fropt.QStyleOption::operator=(*tab);
- fropt.rect.setRect(x1 + 1 + OFFSET, tabV2.rect.y() + OFFSET,
- x2 - x1 - 2*OFFSET, tabV2.rect.height() - 2*OFFSET);
+ fropt.rect.setRect(x1 + 1 + OFFSET, tab->rect.y() + OFFSET,
+ x2 - x1 - 2*OFFSET, tab->rect.height() - 2*OFFSET);
drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
}
}
@@ -2016,9 +2014,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
}
if (!dwOpt->title.isEmpty()) {
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+ const bool verticalTitleBar = dwOpt->verticalTitleBar;
if (verticalTitleBar) {
r.setSize(r.size().transposed());
@@ -2077,7 +2073,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (!cb->currentIcon.isNull()) {
QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
: QIcon::Disabled;
- QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
+ QPixmap pixmap = cb->currentIcon.pixmap(qt_getWindow(widget), cb->iconSize, mode);
QRect iconRect(editRect);
iconRect.setWidth(cb->iconSize.width() + 4);
iconRect = alignedRect(cb->direction,
@@ -2376,7 +2372,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
if (!btn->icon.isNull()) {
iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter
| Qt::TextShowMnemonic,
- btn->icon.pixmap(btn->iconSize, QIcon::Normal));
+ btn->icon.pixmap(qt_getWindow(widget), btn->iconSize, QIcon::Normal));
if (!textRect.isEmpty())
textRect.translate(iconRect.right() + 4, 0);
}
@@ -2424,7 +2420,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
if (!btn->icon.isNull()) {
iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic,
- btn->icon.pixmap(btn->iconSize, QIcon::Normal));
+ btn->icon.pixmap(qt_getWindow(widget), btn->iconSize, QIcon::Normal));
if (!textRect.isEmpty())
textRect.translate(iconRect.right() + 4, 0);
}
@@ -2454,10 +2450,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
case SE_ProgressBarLabel:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
int textw = 0;
- bool vertical = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- vertical = (pb2->orientation == Qt::Vertical);
- }
+ const bool vertical = pb->orientation == Qt::Vertical;
if (!vertical) {
if (pb->textVisible)
textw = qMax(pb->fontMetrics.width(pb->text), pb->fontMetrics.width(QLatin1String("100%"))) + 6;
@@ -2710,14 +2703,13 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
break;
case SE_TabBarTabText:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- QStyleOptionTabV3 tabV3(*tab);
QRect dummyIconRect;
- d->tabLayout(&tabV3, widget, &r, &dummyIconRect);
+ d->tabLayout(tab, widget, &r, &dummyIconRect);
}
break;
case SE_TabBarTabLeftButton:
case SE_TabBarTabRightButton:
- if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
bool selected = tab->state & State_Selected;
int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget);
int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget);
@@ -2889,9 +2881,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
= qstyleoption_cast<const QStyleOptionDockWidget*>(opt);
bool canClose = dwOpt == 0 ? true : dwOpt->closable;
bool canFloat = dwOpt == 0 ? false : dwOpt->floatable;
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+
+ const bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar;
// If this is a vertical titlebar, we transpose and work as if it was
// horizontal, then transpose again.
@@ -3398,9 +3389,9 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|| qobject_cast<const QDockWidget *>(widget)
#endif
)
- pm = proxy()->standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
else
- pm = proxy()->standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@@ -3419,7 +3410,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, widget);
down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken);
- pm = proxy()->standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@@ -3437,7 +3428,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
&& !(tb->titleBarState & Qt::WindowMinimized)) {
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, widget);
down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken);
- pm = proxy()->standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@@ -3459,7 +3450,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
if (drawNormalButton) {
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, widget);
down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken);
- pm = proxy()->standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@@ -3477,7 +3468,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
&& !(tb->titleBarState & Qt::WindowMinimized)) {
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, widget);
down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken));
- pm = proxy()->standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@@ -3495,7 +3486,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, widget);
down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken);
- pm = proxy()->standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@@ -3511,7 +3502,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, widget);
down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken);
- pm = proxy()->standardIcon(SP_TitleBarContextHelpButton, &tool, widget).pixmap(10, 10);
+ pm = proxy()->standardIcon(SP_TitleBarContextHelpButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(10, 10));
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@@ -3528,7 +3519,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
tb->icon.paint(p, ir);
} else {
int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget);
- pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(iconSize, iconSize);
+ pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(qt_getWindow(widget), QSize(iconSize, iconSize));
tool.rect = ir;
p->save();
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
@@ -3715,7 +3706,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(16, 16);
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(qt_getWindow(widget), QSize(16, 16));
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiNormalButton) {
@@ -3732,7 +3723,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(16, 16);
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(qt_getWindow(widget), QSize(16, 16));
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiMinButton) {
@@ -3749,7 +3740,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(16, 16);
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(qt_getWindow(widget), QSize(16, 16));
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
}
@@ -5762,8 +5753,8 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
for (int i = 0 ; i < sizes.size() ; ++i) {
int size = sizes[i].width();
- QPixmap basePixmap = baseIcon.pixmap(size);
- QPixmap linkPixmap = linkIcon.pixmap(size/2);
+ QPixmap basePixmap = baseIcon.pixmap(qt_getWindow(widget), QSize(size, size));
+ QPixmap linkPixmap = linkIcon.pixmap(qt_getWindow(widget), QSize(size / 2, size / 2));
QPainter painter(&basePixmap);
painter.drawPixmap(size/2, size/2, linkPixmap);
icon.addPixmap(basePixmap);
@@ -5779,8 +5770,8 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
for (int i = 0 ; i < sizes.size() ; ++i) {
int size = sizes[i].width();
- QPixmap basePixmap = baseIcon.pixmap(size);
- QPixmap linkPixmap = linkIcon.pixmap(size/2);
+ QPixmap basePixmap = baseIcon.pixmap(qt_getWindow(widget), QSize(size, size));
+ QPixmap linkPixmap = linkIcon.pixmap(qt_getWindow(widget), QSize(size / 2, size / 2));
QPainter painter(&basePixmap);
painter.drawPixmap(size/2, size/2, linkPixmap);
icon.addPixmap(basePixmap);
diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h
index 06fd755fa1..0d040f1b3e 100644
--- a/src/widgets/styles/qcommonstyle.h
+++ b/src/widgets/styles/qcommonstyle.h
@@ -49,34 +49,34 @@ public:
~QCommonStyle();
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QPoint &pt, const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QSize &contentsSize, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- int pixelMetric(PixelMetric m, const QStyleOption *opt = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ int pixelMetric(PixelMetric m, const QStyleOption *opt = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
- QStyleHintReturn *shret = 0) const Q_DECL_OVERRIDE;
+ int styleHint(StyleHint sh, const QStyleOption *opt = Q_NULLPTR, const QWidget *w = Q_NULLPTR,
+ QStyleHintReturn *shret = Q_NULLPTR) const Q_DECL_OVERRIDE;
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = Q_NULLPTR,
+ const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt = Q_NULLPTR,
+ const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
const QStyleOption *opt) const Q_DECL_OVERRIDE;
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ Qt::Orientation orientation, const QStyleOption *option = Q_NULLPTR,
+ const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
void polish(QPalette &) Q_DECL_OVERRIDE;
void polish(QApplication *app) Q_DECL_OVERRIDE;
diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index 1287528bdb..8f512f7d72 100644
--- a/src/widgets/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
@@ -104,7 +104,7 @@ public:
#endif
mutable QIcon tabBarcloseButtonIcon;
#ifndef QT_NO_TABBAR
- void tabLayout(const QStyleOptionTabV3 *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
+ void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
#endif
int animationFps;
diff --git a/src/widgets/styles/qdrawutil.h b/src/widgets/styles/qdrawutil.h
index 1f2078a931..f34a2857a7 100644
--- a/src/widgets/styles/qdrawutil.h
+++ b/src/widgets/styles/qdrawutil.h
@@ -63,42 +63,42 @@ Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint
Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = 0);
+ const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = 0);
+ const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = 0);
+ int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = 0);
+ int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
+ const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
+ const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
+ const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
+ const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
- int lineWidth = 1, const QBrush *fill = 0);
+ int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
- int lineWidth = 1, const QBrush *fill = 0);
+ int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
@@ -145,7 +145,7 @@ Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter,
const QMargins &sourceMargins,
const QTileRules &rules = QTileRules()
#ifndef Q_QDOC
- , QDrawBorderPixmap::DrawingHints hints = 0
+ , QDrawBorderPixmap::DrawingHints hints = QDrawBorderPixmap::DrawingHints()
#endif
);
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 6d722c680b..2fc52e9a32 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -40,7 +40,6 @@
#include <qpushbutton.h>
#include <qpainter.h>
#include <qdir.h>
-#include <qhash.h>
#include <qstyleoption.h>
#include <qapplication.h>
#include <qmainwindow.h>
@@ -555,11 +554,19 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
QColor arrowColor = header->palette.foreground().color();
QPoint offset = QPoint(0, -1);
+#if defined(Q_OS_LINUX)
if (header->sortIndicator & QStyleOptionHeader::SortUp) {
arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor);
} else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180);
}
+#else
+ if (header->sortIndicator & QStyleOptionHeader::SortUp) {
+ arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180);
+ } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
+ arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor);
+ }
+#endif
if (!arrow.isNull()) {
r.setSize(QSize(arrow.width()/2, arrow.height()/2));
diff --git a/src/widgets/styles/qgtk2painter.cpp b/src/widgets/styles/qgtk2painter.cpp
index 489d456617..ea8afbc93c 100644
--- a/src/widgets/styles/qgtk2painter.cpp
+++ b/src/widgets/styles/qgtk2painter.cpp
@@ -93,6 +93,7 @@ namespace QGtk2PainterPrivate {
static void initGtk()
{
+#ifndef QT_NO_LIBRARY
static bool initialized = false;
if (!initialized) {
// enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
@@ -123,6 +124,7 @@ static void initGtk()
initialized = true;
}
+#endif // !QT_NO_LIBRARY
}
// To recover alpha we apply the gtk painting function two times to
diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp
index 348727b328..7ed0dce91d 100644
--- a/src/widgets/styles/qgtkstyle.cpp
+++ b/src/widgets/styles/qgtkstyle.cpp
@@ -3633,6 +3633,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
QFont font = widget->font();
font.setBold(true);
fontMetrics = QFontMetrics(font);
+#ifndef QT_NO_ACCESSIBILITY
} else if (QStyleHelper::isInstanceOf(groupBox->styleObject, QAccessible::Grouping)) {
QVariant var = groupBox->styleObject->property("font");
if (var.isValid() && var.canConvert<QFont>()) {
@@ -3640,6 +3641,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
font.setBold(true);
fontMetrics = QFontMetrics(font);
}
+#endif // QT_NO_ACCESSIBILITY
}
QSize textRect = fontMetrics.boundingRect(groupBox->text).size() + QSize(4, 4);
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
index 0e119a11ae..00682c1c0f 100644
--- a/src/widgets/styles/qgtkstyle_p.cpp
+++ b/src/widgets/styles/qgtkstyle_p.cpp
@@ -326,6 +326,7 @@ void QGtkStylePrivate::gtkWidgetSetFocus(GtkWidget *widget, bool focus)
*/
void QGtkStylePrivate::resolveGtk() const
{
+#ifndef QT_NO_LIBRARY
// enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
@@ -427,6 +428,7 @@ void QGtkStylePrivate::resolveGtk() const
gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
+#endif // !QT_NO_LIBRARY
}
/* \internal
@@ -593,11 +595,13 @@ void QGtkStylePrivate::cleanupGtkWidgets()
static bool resolveGConf()
{
+#ifndef QT_NO_LIBRARY
if (!QGtkStylePrivate::gconf_client_get_default) {
QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
QGtkStylePrivate::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
QGtkStylePrivate::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
}
+#endif // !QT_NO_LIBRARY
return (QGtkStylePrivate::gconf_client_get_default !=0);
}
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index d13754b36b..ac23512f1d 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -93,16 +93,9 @@
QT_USE_NAMESPACE
-namespace {
-class AutoReleasePool
+static QWindow *qt_getWindow(const QWidget *widget)
{
-public:
- AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
- ~AutoReleasePool() { [pool release]; }
-
-private:
- NSAutoreleasePool *pool;
-};
+ return widget ? widget->window()->windowHandle() : 0;
}
@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject {
@@ -126,7 +119,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(NotificationReceiver);
{
Q_UNUSED(notification);
QEvent event(QEvent::StyleChange);
- QMutableSetIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars);
+ QMutableVectorIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars);
while (it.hasNext()) {
if (!it.next())
it.remove();
@@ -150,12 +143,7 @@ const int QMacStylePrivate::BevelButtonW = 50;
const int QMacStylePrivate::BevelButtonH = 22;
const int QMacStylePrivate::PushButtonContentPadding = 6;
-QSet<QPointer<QObject> > QMacStylePrivate::scrollBars;
-
-static uint qHash(const QPointer<QObject> &ptr)
-{
- return qHash(ptr.data());
-}
+QVector<QPointer<QObject> > QMacStylePrivate::scrollBars;
// Title bar gradient colors for Lion were determined by inspecting PSDs exported
// using CoreUI's CoreThemeDocument; there is no public API to retrieve them
@@ -277,7 +265,7 @@ QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect)
return tabRect;
}
-void drawTabShape(QPainter *p, const QStyleOptionTabV3 *tabOpt, bool isUnified)
+void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified)
{
QRect r = tabOpt->rect;
p->translate(tabOpt->rect.x(), tabOpt->rect.y());
@@ -381,7 +369,7 @@ void drawTabShape(QPainter *p, const QStyleOptionTabV3 *tabOpt, bool isUnified)
}
}
-void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget *w)
+void drawTabBase(QPainter *p, const QStyleOptionTabBarBase *tbb, const QWidget *w)
{
QRect r = tbb->rect;
if (isVerticalTabs(tbb->shape)) {
@@ -1753,7 +1741,7 @@ QMacStylePrivate::QMacStylePrivate()
QMacStylePrivate::~QMacStylePrivate()
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
Q_FOREACH (NSView *b, cocoaControls)
[b release];
}
@@ -1884,7 +1872,7 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const
if ([bv isKindOfClass:[NSButton class]]) {
NSButton *bc = (NSButton *)bv;
- bc.title = nil;
+ bc.title = @"";
}
if ([bv isKindOfClass:[NSControl class]]) {
@@ -1977,7 +1965,7 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
const bool button = opt->type == QStyleOption::SO_Button;
const bool viewItem = opt->type == QStyleOption::SO_ViewItem;
const bool pressed = bdi->state == kThemeStatePressed;
- const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
+ const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10;
if (button && pressed) {
if (bdi->kind == kThemePushButton) {
@@ -1989,7 +1977,7 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
}
}
- int devicePixelRatio = p->device()->devicePixelRatio();
+ int devicePixelRatio = p->device()->devicePixelRatioF();
int width = devicePixelRatio * (int(macRect.size.width) + extraWidth);
int height = devicePixelRatio * (int(macRect.size.height) + extraHeight);
@@ -2135,7 +2123,7 @@ QMacStyle::QMacStyle()
: QCommonStyle(*new QMacStylePrivate)
{
Q_D(QMacStyle);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
@@ -2152,7 +2140,7 @@ QMacStyle::QMacStyle()
QMacStyle::~QMacStyle()
{
Q_D(QMacStyle);
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
[reinterpret_cast<NSScroller*>(d->nsscroller) release];
@@ -2169,7 +2157,7 @@ QMacStyle::~QMacStyle()
*/
QPixmap QMacStylePrivate::generateBackgroundPattern() const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
QPixmap px(4, 4);
QMacCGContext cg(&px);
HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
@@ -2767,7 +2755,7 @@ QPalette QMacStyle::standardPalette() const
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
QStyleHintReturn *hret) const
{
- AutoReleasePool pool;
+ QMacAutoReleasePool pool;
SInt32 ret = 0;
switch (sh) {
@@ -2868,7 +2856,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
ret = QEvent::MouseButtonRelease;
break;
case SH_TabBar_SelectMouseType:
- if (const QStyleOptionTabBarBaseV2 *opt2 = qstyleoption_cast<const QStyleOptionTabBarBaseV2 *>(opt)) {
+ if (const QStyleOptionTabBarBase *opt2 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {
ret = opt2->documentMode ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
} else {
ret = QEvent::MouseButtonRelease;
@@ -3141,7 +3129,7 @@ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOpt
size = 64;
break;
}
- return icon.pixmap(size, size);
+ return icon.pixmap(qt_getWindow(widget), QSize(size, size));
}
void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy)
@@ -3234,8 +3222,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
p->restore();
break; }
case PE_FrameTabBarBase:
- if (const QStyleOptionTabBarBaseV2 *tbb
- = qstyleoption_cast<const QStyleOptionTabBarBaseV2 *>(opt)) {
+ if (const QStyleOptionTabBarBase *tbb
+ = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {
if (tbb->documentMode) {
p->save();
drawTabBase(p, tbb, w);
@@ -3273,8 +3261,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
break;
case PE_FrameGroupBox:
if (const QStyleOptionFrame *groupBox = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt);
- if (frame2 && frame2->features & QStyleOptionFrameV2::Flat) {
+ if (groupBox->features & QStyleOptionFrame::Flat) {
QCommonStyle::drawPrimitive(pe, groupBox, p, w);
} else {
HIThemeGroupBoxDrawInfo gdi;
@@ -3618,6 +3605,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QWindow *window = w && w->window() ? w->window()->windowHandle() :
QStyleHelper::styleObjectWindow(opt->styleObject);
const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
+ const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10;
switch (ce) {
case CE_HeaderSection:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
@@ -3701,7 +3689,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QIcon::Mode mode = QIcon::Disabled;
if (opt->state & State_Enabled)
mode = QIcon::Normal;
- QPixmap pixmap = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), mode);
+ int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
+ QPixmap pixmap = header->icon.pixmap(window, QSize(iconExtent, iconExtent), mode);
QRect pixr = header->rect;
pixr.setY(header->rect.center().y() - (pixmap.height() / pixmap.devicePixelRatio() - 1) / 2);
@@ -3709,7 +3698,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
textr.translate(pixmap.width() / pixmap.devicePixelRatio() + 2, 0);
}
- p->setFont(qt_app_fonts_hash()->value("QSmallFont", QFont()));
proxy()->drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette,
header->state & State_Enabled, header->text, QPalette::ButtonText);
p->restore();
@@ -3753,7 +3741,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
: QIcon::Disabled;
QIcon::State iconState = (tb->state & State_On) ? QIcon::On
: QIcon::Off;
- QPixmap pixmap = tb->icon.pixmap(tb->rect.size().boundedTo(tb->iconSize), iconMode, iconState);
+ QPixmap pixmap = tb->icon.pixmap(window,
+ tb->rect.size().boundedTo(tb->iconSize),
+ iconMode, iconState);
// Draw the text if it's needed.
if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) {
@@ -3829,13 +3819,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// No default button pulsating animation on Yosemite,
// so we have to do few things differently.
- const bool yosemiteOrLater = QSysInfo::QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
// a focused auto-default button within an active window
// takes precedence over a normal default button
if (btn->features & QStyleOptionButton::AutoDefaultButton
&& opt->state & State_Active && opt->state & State_HasFocus) {
- if (yosemiteOrLater)
+ if (usingYosemiteOrLater)
d->autoDefaultButton = opt->styleObject;
else
d->setAutoDefaultButton(opt->styleObject);
@@ -3846,7 +3835,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
if (!d->autoDefaultButton) {
if (btn->features & QStyleOptionButton::DefaultButton && opt->state & State_Active) {
d->defaultButton = opt->styleObject;
- if (!yosemiteOrLater && !d->animation(opt->styleObject))
+ if (!usingYosemiteOrLater && !d->animation(opt->styleObject))
d->startAnimation(new QStyleAnimation(opt->styleObject));
} else if (d->defaultButton == opt->styleObject) {
if (QStyleAnimation *animation = d->animation(opt->styleObject)) {
@@ -3868,7 +3857,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
HIThemeButtonDrawInfo bdi;
d->initHIThemePushButton(btn, w, tds, &bdi);
- if (yosemiteOrLater) {
+ if (usingYosemiteOrLater) {
if (!hasMenu) {
// HITheme is not drawing a nice focus frame around buttons.
// We'll do it ourselves further down.
@@ -3921,7 +3910,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4;
}
- if (hasMenu && yosemiteOrLater && bdi.kind != kThemeBevelButton) {
+ if (hasMenu && usingYosemiteOrLater && bdi.kind != kThemeBevelButton) {
QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi.kind);
cw.first = QCocoaPullDownButton;
NSPopUpButton *pdb = (NSPopUpButton *)d->cocoaControl(cw);
@@ -3935,7 +3924,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
else
HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0);
- if (yosemiteOrLater && btn->state & State_HasFocus) {
+ if (usingYosemiteOrLater && btn->state & State_HasFocus) {
CGRect focusRect = newRect;
if (bdi.kind == kThemePushButton)
focusRect.size.height += 1; // Another thing HITheme and Cocoa seem to disagree about.
@@ -3966,7 +3955,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath);
}
- if (hasMenu && (!yosemiteOrLater || bdi.kind == kThemeBevelButton)) {
+ if (hasMenu && (!usingYosemiteOrLater || bdi.kind == kThemeBevelButton)) {
int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w);
QRect ir = btn->rect;
int arrowXOffset = bdi.kind == kThemePushButton ? 6 :
@@ -4084,7 +4073,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QIcon::State state = QIcon::Off;
if (btn.state & State_On)
state = QIcon::On;
- QPixmap pixmap = btn.icon.pixmap(btn.iconSize, mode, state);
+ QPixmap pixmap = btn.icon.pixmap(window, btn.iconSize, mode, state);
int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
contentW += pixmapWidth + QMacStylePrivate::PushButtonContentPadding;
@@ -4122,23 +4111,19 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
case CE_TabBarTabShape:
if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- if (const QStyleOptionTabV3 *tabOptV3 = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
- if (tabOptV3->documentMode) {
- p->save();
- bool isUnified = false;
- if (w) {
- QRect tabRect = tabOptV3->rect;
- QPoint windowTabStart = w->mapTo(w->window(), tabRect.topLeft());
- isUnified = isInMacUnifiedToolbarArea(w->window()->windowHandle(), windowTabStart.y());
- }
-
- drawTabShape(p, tabOptV3, isUnified);
- p->restore();
- return;
+ if (tabOpt->documentMode) {
+ p->save();
+ bool isUnified = false;
+ if (w) {
+ QRect tabRect = tabOpt->rect;
+ QPoint windowTabStart = w->mapTo(w->window(), tabRect.topLeft());
+ isUnified = isInMacUnifiedToolbarArea(w->window()->windowHandle(), windowTabStart.y());
}
- }
- bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
+ drawTabShape(p, tabOpt, isUnified);
+ p->restore();
+ return;
+ }
HIThemeTabDrawInfo tdi;
tdi.version = 1;
@@ -4247,11 +4232,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
break;
case CE_TabBarTabLabel:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- QStyleOptionTabV3 myTab = *tab;
+ QStyleOptionTab myTab = *tab;
ThemeTabDirection ttd = getTabDirection(myTab.shape);
bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast;
bool selected = (myTab.state & QStyle::State_Selected);
- bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
if (selected && !myTab.documentMode
&& (!usingYosemiteOrLater || myTab.state & State_Active))
@@ -4283,7 +4267,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QPalette np = tab->palette;
np.setColor(QPalette::WindowText, shadowColor);
- QRect nr = subElementRect(SE_TabBarTabText, opt, w);
+ QRect nr = proxy()->subElementRect(SE_TabBarTabText, opt, w);
nr.moveTop(-1);
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic;
proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled,
@@ -4375,9 +4359,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// Draw the text...
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
if (!dwOpt->title.isEmpty()) {
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+
+ const bool verticalTitleBar = dwOpt->verticalTitleBar;
QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, opt, w);
if (verticalTitleBar) {
@@ -4537,7 +4520,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
if (const QComboBox *comboBox = qobject_cast<const QComboBox *>(w)) {
iconSize = comboBox->iconSize();
}
- QPixmap pixmap = mi->icon.pixmap(iconSize, mode);
+ QPixmap pixmap = mi->icon.pixmap(window, iconSize, mode);
int pixw = pixmap.width() / pixmap.devicePixelRatio();
int pixh = pixmap.height() / pixmap.devicePixelRatio();
QRect cr(xpos, contentRect.y(), checkcol, contentRect.height());
@@ -4642,10 +4625,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
if (!mi->icon.isNull()) {
+ int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
drawItemPixmap(p, mi->rect,
Qt::AlignCenter | Qt::TextHideMnemonic | Qt::TextDontClip
| Qt::TextSingleLine,
- mi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize),
+ mi->icon.pixmap(window, QSize(iconExtent, iconExtent),
(mi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled));
} else {
drawItemText(p, mi->rect,
@@ -4673,12 +4657,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
tdi.version = qt_mac_hitheme_version;
tdi.reserved = 0;
bool isIndeterminate = (pb->minimum == 0 && pb->maximum == 0);
- bool vertical = false;
- bool inverted = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- vertical = (pb2->orientation == Qt::Vertical);
- inverted = pb2->invertedAppearance;
- }
+ const bool vertical = pb->orientation == Qt::Vertical;
+ const bool inverted = pb->invertedAppearance;
bool reverse = (!vertical && (pb->direction == Qt::RightToLeft));
if (inverted)
reverse = !reverse;
@@ -4699,7 +4679,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
tdi.value = pb->progress;
tdi.attributes = vertical ? 0 : kThemeTrackHorizontal;
- const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
if (isIndeterminate || (tdi.value < tdi.max && !usingYosemiteOrLater)) {
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
tdi.trackInfo.progress.phase = animation->animationStep();
@@ -4782,8 +4761,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
HIThemeSplitterDrawInfo sdi;
sdi.version = qt_mac_hitheme_version;
sdi.state = tds;
- sdi.adornment = qt_mac_is_metal(w) ? kHIThemeSplitterAdornmentMetal
- : kHIThemeSplitterAdornmentNone;
+ sdi.adornment = qt_mac_is_metal(w) || usingYosemiteOrLater ?
+ kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone;
HIRect hirect = qt_hirectForQRect(opt->rect);
HIThemeDrawPaneSplitter(&hirect, &sdi, cg, kHIThemeOrientationNormal);
} else {
@@ -5142,7 +5121,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
break;
case SE_FrameLayoutItem:
- // hack because QStyleOptionFrameV2 doesn't have a frameStyle member
+ // hack because QStyleOptionFrame doesn't have a frameStyle member
if (const QFrame *frame = qobject_cast<const QFrame *>(widget)) {
rect = opt->rect;
switch (frame->frameStyle() & QFrame::Shape_Mask) {
@@ -5205,9 +5184,8 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
= qstyleoption_cast<const QStyleOptionDockWidget*>(opt);
bool canClose = dwOpt == 0 ? true : dwOpt->closable;
bool canFloat = dwOpt == 0 ? false : dwOpt->floatable;
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+
+ const bool verticalTitleBar = dwOpt->verticalTitleBar;
// If this is a vertical titlebar, we transpose and work as if it was
// horizontal, then transpose again.
@@ -5318,6 +5296,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
QWindow *window = widget && widget->window() ? widget->window()->windowHandle() :
QStyleHelper::styleObjectWindow(opt->styleObject);
const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window);
+ const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10;
switch (cc) {
case CC_Slider:
case CC_ScrollBar:
@@ -5380,7 +5359,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
// there is not enough space for them.
if (cc == CC_ScrollBar) {
if (opt && opt->styleObject && !QMacStylePrivate::scrollBars.contains(opt->styleObject))
- QMacStylePrivate::scrollBars.insert(QPointer<QObject>(opt->styleObject));
+ QMacStylePrivate::scrollBars.append(QPointer<QObject>(opt->styleObject));
const int scrollBarLength = (slider->orientation == Qt::Horizontal)
? slider->rect.width() : slider->rect.height();
const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget, opt);
@@ -5395,7 +5374,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
tdi.attributes |= kThemeTrackHideTrack;
}
- const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
const bool isHorizontal = slider->orientation == Qt::Horizontal;
if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient, opt, widget)) {
@@ -5771,7 +5749,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
break;
case CC_ComboBox:
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){
- const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9;
HIThemeButtonDrawInfo bdi;
d->initComboboxBdi(combo, &bdi, widget, tds);
HIRect rect = qt_hirectForQRect(combo->rect);
@@ -5889,9 +5866,11 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
x += iw;
else
x += br.width() / 2 - p->fontMetrics().width(titlebar->text) / 2;
- if (iw)
+ if (iw) {
+ int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
p->drawPixmap(x - iw, y,
- titlebar->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), QIcon::Normal));
+ titlebar->icon.pixmap(window, QSize(iconExtent, iconExtent), QIcon::Normal));
+ }
drawItemText(p, br, Qt::AlignCenter, opt->palette, tds == kThemeStateActive,
titlebar->text, QPalette::Text);
p->restore();
@@ -5904,7 +5883,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
= qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
QStyleOptionGroupBox groupBox(*gb);
- bool flat = (groupBox.features & QStyleOptionFrameV2::Flat);
+ const bool flat = groupBox.features & QStyleOptionFrame::Flat;
if (!flat)
groupBox.state |= QStyle::State_Mini; // Force mini-sized checkbox to go with small-sized label
else
@@ -6356,7 +6335,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
case CC_GroupBox:
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
bool checkable = groupBox->subControls & SC_GroupBoxCheckBox;
- bool flat = (groupBox->features & QStyleOptionFrameV2::Flat);
+ const bool flat = groupBox->features & QStyleOptionFrame::Flat;
bool hasNoText = !checkable && groupBox->text.isEmpty();
switch (sc) {
case SC_GroupBoxLabel:
@@ -6635,7 +6614,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
break;
case QStyle::CT_TabBarTab:
- if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget);
const bool differentFont = (widget && widget->testAttribute(Qt::WA_SetFont))
|| !QApplication::desktopSettingsAware();
@@ -7213,11 +7192,11 @@ CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(),
8, image->bytesPerLine(), colorspace, flags);
} else {
- qDebug() << "qt_mac_cg_context: Unsupported pixmap class";
+ qDebug("qt_mac_cg_context: Unsupported pixmap class");
}
CGContextTranslateCTM(ret, 0, pm->height());
- int devicePixelRatio = pdev->devicePixelRatio();
+ qreal devicePixelRatio = pdev->devicePixelRatioF();
CGContextScaleCTM(ret, devicePixelRatio, devicePixelRatio);
CGContextScaleCTM(ret, 1, -1);
return ret;
@@ -7225,7 +7204,7 @@ CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
//CGContextRef ret = static_cast<CGContextRef>(static_cast<const QWidget *>(pdev)->macCGHandle());
///CGContextRetain(ret);
//return ret;
- qDebug() << "qt_mac_cg_context: not implemented: Widget class";
+ qDebug("qt_mac_cg_context: not implemented: Widget class");
return 0;
}
return 0;
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index b09e81d595..33818568ec 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -86,7 +86,7 @@
#include <qdatetimeedit.h>
#include <qmath.h>
#include <qpair.h>
-#include <qset.h>
+#include <qvector.h>
#include <QtWidgets/qgraphicsproxywidget.h>
#include <QtWidgets/qgraphicsview.h>
@@ -213,7 +213,7 @@ public:
mutable QPointer<QObject> pressedButton;
mutable QPointer<QObject> defaultButton;
mutable QPointer<QObject> autoDefaultButton;
- static QSet<QPointer<QObject> > scrollBars;
+ static QVector<QPointer<QObject> > scrollBars;
struct ButtonState {
int frame;
diff --git a/src/widgets/styles/qproxystyle.h b/src/widgets/styles/qproxystyle.h
index cac4cde0f2..072965bbd7 100644
--- a/src/widgets/styles/qproxystyle.h
+++ b/src/widgets/styles/qproxystyle.h
@@ -47,16 +47,16 @@ class Q_WIDGETS_EXPORT QProxyStyle : public QCommonStyle
Q_OBJECT
public:
- QProxyStyle(QStyle *style = 0);
+ QProxyStyle(QStyle *style = Q_NULLPTR);
QProxyStyle(const QString &key);
~QProxyStyle();
QStyle *baseStyle() const;
void setBaseStyle(QStyle *style);
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled,
const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const Q_DECL_OVERRIDE;
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
@@ -68,14 +68,14 @@ public:
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const Q_DECL_OVERRIDE;
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
- SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const Q_DECL_OVERRIDE;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ int styleHint(StyleHint hint, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR, QStyleHintReturn *returnData = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ Qt::Orientation orientation, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const Q_DECL_OVERRIDE;
QPalette standardPalette() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index b41762795d..1e9d15c993 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -192,7 +192,7 @@ public:
Q_ENUM(PrimitiveElement)
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const = 0;
+ const QWidget *w = Q_NULLPTR) const = 0;
enum ControlElement {
CE_PushButton,
CE_PushButtonBevel,
@@ -263,7 +263,7 @@ public:
Q_ENUM(ControlElement)
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const = 0;
+ const QWidget *w = Q_NULLPTR) const = 0;
enum SubElement {
SE_PushButtonContents,
@@ -347,7 +347,7 @@ public:
Q_ENUM(SubElement)
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option,
- const QWidget *widget = 0) const = 0;
+ const QWidget *widget = Q_NULLPTR) const = 0;
enum ComplexControl {
@@ -426,11 +426,11 @@ public:
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *widget = 0) const = 0;
+ const QWidget *widget = Q_NULLPTR) const = 0;
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *widget = 0) const = 0;
+ const QPoint &pt, const QWidget *widget = Q_NULLPTR) const = 0;
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget = 0) const = 0;
+ SubControl sc, const QWidget *widget = Q_NULLPTR) const = 0;
enum PixelMetric {
PM_ButtonMargin,
@@ -561,8 +561,8 @@ public:
};
Q_ENUM(PixelMetric)
- virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const = 0;
+ virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = Q_NULLPTR,
+ const QWidget *widget = Q_NULLPTR) const = 0;
enum ContentsType {
CT_PushButton,
@@ -594,7 +594,7 @@ public:
Q_ENUM(ContentsType)
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *w = 0) const = 0;
+ const QSize &contentsSize, const QWidget *w = Q_NULLPTR) const = 0;
enum RequestSoftwareInputPanel {
RSIP_OnMouseClickAndAlreadyFocused,
@@ -724,8 +724,8 @@ public:
};
Q_ENUM(StyleHint)
- virtual int styleHint(StyleHint stylehint, const QStyleOption *opt = 0,
- const QWidget *widget = 0, QStyleHintReturn* returnData = 0) const = 0;
+ virtual int styleHint(StyleHint stylehint, const QStyleOption *opt = Q_NULLPTR,
+ const QWidget *widget = Q_NULLPTR, QStyleHintReturn* returnData = Q_NULLPTR) const = 0;
enum StandardPixmap {
SP_TitleBarMenuButton,
@@ -804,11 +804,11 @@ public:
};
Q_ENUM(StandardPixmap)
- virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const = 0;
+ virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = Q_NULLPTR,
+ const QWidget *widget = Q_NULLPTR) const = 0;
- virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const = 0;
+ virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = Q_NULLPTR,
+ const QWidget *widget = Q_NULLPTR) const = 0;
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
const QStyleOption *opt) const = 0;
@@ -827,10 +827,10 @@ public:
virtual int layoutSpacing(QSizePolicy::ControlType control1,
QSizePolicy::ControlType control2, Qt::Orientation orientation,
- const QStyleOption *option = 0, const QWidget *widget = 0) const = 0;
+ const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const = 0;
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
- QStyleOption *option = 0, QWidget *widget = 0) const;
+ QStyleOption *option = Q_NULLPTR, QWidget *widget = Q_NULLPTR) const;
const QStyle * proxy() const;
diff --git a/src/widgets/styles/qstylepainter.h b/src/widgets/styles/qstylepainter.h
index 33d17d42b9..8492d231ae 100644
--- a/src/widgets/styles/qstylepainter.h
+++ b/src/widgets/styles/qstylepainter.h
@@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
class QStylePainter : public QPainter
{
public:
- inline QStylePainter() : QPainter(), widget(0), wstyle(0) {}
+ inline QStylePainter() : QPainter(), widget(Q_NULLPTR), wstyle(Q_NULLPTR) {}
inline explicit QStylePainter(QWidget *w) { begin(w, w); }
inline QStylePainter(QPaintDevice *pd, QWidget *w) { begin(pd, w); }
inline bool begin(QWidget *w) { return begin(w, w); }
diff --git a/src/widgets/styles/qstyleplugin.h b/src/widgets/styles/qstyleplugin.h
index b83774a39d..c8f6344758 100644
--- a/src/widgets/styles/qstyleplugin.h
+++ b/src/widgets/styles/qstyleplugin.h
@@ -48,7 +48,7 @@ class Q_WIDGETS_EXPORT QStylePlugin : public QObject
{
Q_OBJECT
public:
- explicit QStylePlugin(QObject *parent = 0);
+ explicit QStylePlugin(QObject *parent = Q_NULLPTR);
~QStylePlugin();
virtual QStyle *create(const QString &key) = 0;
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index ce10b92d85..d3f667748e 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -460,7 +460,6 @@ class QRenderRule
public:
QRenderRule() : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { }
QRenderRule(const QVector<QCss::Declaration> &, const QObject *);
- ~QRenderRule() { }
QRect borderRect(const QRect &r) const;
QRect outlineRect(const QRect &r) const;
@@ -558,16 +557,22 @@ public:
return csz;
}
+ bool hasStyleHint(const QString &sh) const { return styleHints.contains(sh); }
+ QVariant styleHint(const QString &sh) const { return styleHints.value(sh); }
+
+ void fixupBorder(int);
+
+ // Shouldn't be here
+ void setClip(QPainter *p, const QRect &rect);
+ void unsetClip(QPainter *);
+
+public:
int features;
QBrush defaultBackground;
QFont font;
bool hasFont;
QHash<QString, QVariant> styleHints;
- bool hasStyleHint(const QString& sh) const { return styleHints.contains(sh); }
- QVariant styleHint(const QString& sh) const { return styleHints.value(sh); }
-
- void fixupBorder(int);
QSharedDataPointer<QStyleSheetPaletteData> pal;
QSharedDataPointer<QStyleSheetBoxData> b;
@@ -578,12 +583,10 @@ public:
QSharedDataPointer<QStyleSheetPositionData> p;
QSharedDataPointer<QStyleSheetImageData> img;
- // Shouldn't be here
- void setClip(QPainter *p, const QRect &rect);
- void unsetClip(QPainter *);
int clipset;
QPainterPath clipPath;
};
+Q_DECLARE_TYPEINFO(QRenderRule, Q_MOVABLE_TYPE);
///////////////////////////////////////////////////////////////////////////////////////////
static const char *const knownStyleHints[] = {
@@ -728,6 +731,7 @@ namespace {
int width;
};
}
+template <> class QTypeInfo<ButtonInfo> : public QTypeInfoMerger<ButtonInfo, QRenderRule, int> {};
QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const
{
@@ -742,16 +746,19 @@ QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget
int offsets[3] = { 0, 0, 0 };
enum Where { Left, Right, Center, NoWhere } where = Left;
- QList<ButtonInfo> infos;
- for (int i = 0; i < layout.count(); i++) {
- ButtonInfo info;
- info.element = layout[i].toInt();
- if (info.element == '(') {
+ QVector<ButtonInfo> infos;
+ const int numLayouts = layout.size();
+ infos.reserve(numLayouts);
+ for (int i = 0; i < numLayouts; i++) {
+ const int element = layout[i].toInt();
+ if (element == '(') {
where = Center;
- } else if (info.element == ')') {
+ } else if (element == ')') {
where = Right;
} else {
- switch (info.element) {
+ ButtonInfo info;
+ info.element = element;
+ switch (element) {
case PseudoElement_TitleBar:
if (!(tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)))
continue;
@@ -796,14 +803,14 @@ QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget
info.rule = subRule;
info.offset = offsets[where];
info.where = where;
- infos.append(info);
+ infos.append(qMove(info));
offsets[where] += info.width;
}
}
- for (int i = 0; i < infos.count(); i++) {
- ButtonInfo info = infos[i];
+ for (int i = 0; i < infos.size(); i++) {
+ const ButtonInfo &info = infos[i];
QRect lr = cr;
switch (info.where) {
case Center: {
@@ -1951,24 +1958,24 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
}
#endif // QT_NO_TOOLBAR
#ifndef QT_NO_TOOLBOX
- else if (const QStyleOptionToolBoxV2 *tab = qstyleoption_cast<const QStyleOptionToolBoxV2 *>(opt)) {
- if (tab->position == QStyleOptionToolBoxV2::OnlyOneTab)
+ else if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
+ if (tb->position == QStyleOptionToolBox::OnlyOneTab)
extraClass |= PseudoClass_OnlyOne;
- else if (tab->position == QStyleOptionToolBoxV2::Beginning)
+ else if (tb->position == QStyleOptionToolBox::Beginning)
extraClass |= PseudoClass_First;
- else if (tab->position == QStyleOptionToolBoxV2::End)
+ else if (tb->position == QStyleOptionToolBox::End)
extraClass |= PseudoClass_Last;
- else if (tab->position == QStyleOptionToolBoxV2::Middle)
+ else if (tb->position == QStyleOptionToolBox::Middle)
extraClass |= PseudoClass_Middle;
- if (tab->selectedPosition == QStyleOptionToolBoxV2::NextIsSelected)
+ if (tb->selectedPosition == QStyleOptionToolBox::NextIsSelected)
extraClass |= PseudoClass_NextSelected;
- else if (tab->selectedPosition == QStyleOptionToolBoxV2::PreviousIsSelected)
+ else if (tb->selectedPosition == QStyleOptionToolBox::PreviousIsSelected)
extraClass |= PseudoClass_PreviousSelected;
}
#endif // QT_NO_TOOLBOX
#ifndef QT_NO_DOCKWIDGET
- else if (const QStyleOptionDockWidgetV2 *dw = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
+ else if (const QStyleOptionDockWidget *dw = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
if (dw->verticalTitleBar)
extraClass |= PseudoClass_Vertical;
else
@@ -2393,6 +2400,13 @@ static bool unstylable(const QWidget *w)
return true;
}
#endif
+
+#ifndef QT_NO_TABBAR
+ if (w->metaObject() == &QWidget::staticMetaObject
+ && qobject_cast<const QTabBar*>(w->parentWidget()))
+ return true; // The moving tab of a QTabBar
+#endif
+
return false;
}
@@ -3793,7 +3807,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
case CE_ProgressBarContents: {
QRenderRule subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk);
if (subRule.hasDrawable()) {
- if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
p->save();
p->setClipRect(pb->rect);
@@ -3874,12 +3888,12 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
break;
case CE_ProgressBarLabel:
- if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
drawItemText(p, pb->rect, pb->textAlignment | Qt::TextSingleLine, pb->palette,
pb->state & State_Enabled, pb->text, QPalette::Text);
} else {
- QStyleOptionProgressBarV2 pbCopy(*pb);
+ QStyleOptionProgressBar pbCopy(*pb);
rule.configurePalette(&pbCopy.palette, QPalette::HighlightedText, QPalette::Highlight);
baseStyle()->drawControl(ce, &pbCopy, p, w);
}
@@ -4002,13 +4016,13 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
case CE_TabBarTabLabel:
case CE_TabBarTabShape:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- QStyleOptionTabV3 tabCopy(*tab);
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction);
if (ce == CE_TabBarTabShape && subRule.hasDrawable()) {
subRule.drawRule(p, r);
return;
}
+ QStyleOptionTab tabCopy(*tab);
subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Window);
QFont oldFont = p->font();
if (subRule.hasFont)
@@ -4036,14 +4050,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
break;
case CE_DockWidgetTitle:
- if (const QStyleOptionDockWidgetV2 *dwOpt = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
+ if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle);
if (!subRule.hasDrawable() && !subRule.hasPosition())
break;
if (subRule.hasDrawable()) {
subRule.drawRule(p, opt->rect);
} else {
- QStyleOptionDockWidgetV2 dwCopy(*dwOpt);
+ QStyleOptionDockWidget dwCopy(*dwOpt);
dwCopy.title = QString();
baseStyle()->drawControl(ce, &dwCopy, p, w);
}
@@ -4379,7 +4393,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane);
if (subRule.hasNativeBorder()) {
subRule.drawBackground(p, opt->rect);
- QStyleOptionTabWidgetFrameV2 frmCopy(*frm);
+ QStyleOptionTabWidgetFrame frmCopy(*frm);
subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window);
baseStyle()->drawPrimitive(pe, &frmCopy, p, w);
} else {
@@ -5695,7 +5709,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
case SE_ProgressBarGroove:
case SE_ProgressBarContents:
case SE_ProgressBarLabel:
- if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasPosition() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
if (se == SE_ProgressBarGroove)
return rule.borderRect(pb->rect);
diff --git a/src/widgets/styles/qwindowscestyle.cpp b/src/widgets/styles/qwindowscestyle.cpp
index fd9ac6fecf..e26925807f 100644
--- a/src/widgets/styles/qwindowscestyle.cpp
+++ b/src/widgets/styles/qwindowscestyle.cpp
@@ -1536,7 +1536,7 @@ void QWindowsCEStyle::drawComplexControl(ComplexControl control, const QStyleOpt
QRect textRect = subControlRect(CC_GroupBox, &groupBoxFont, SC_GroupBoxLabel, widget);
QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget);
if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
- QStyleOptionFrameV2 frame;
+ QStyleOptionFrame frame;
frame.QStyleOption::operator=(*groupBox);
frame.features = groupBox->features;
frame.lineWidth = groupBox->lineWidth;
@@ -2002,7 +2002,7 @@ QRect QWindowsCEStyle::subControlRect(ComplexControl control, const QStyleOption
}
int frameWidth = 0;
- if ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)
+ if ((groupBox->features & QStyleOptionFrame::Flat) == 0)
frameWidth = pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
rect = frameRect.adjusted(frameWidth, frameWidth + topHeight, -frameWidth, -frameWidth - noLabelMargin);
break;
@@ -2013,7 +2013,7 @@ QRect QWindowsCEStyle::subControlRect(ComplexControl control, const QStyleOption
QFontMetrics fontMetrics = groupBox->fontMetrics;
int h = fontMetrics.height();
int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
- int marg = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 8;
+ const int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8;
rect = groupBox->rect.adjusted(marg, 0, -marg, 0);
rect.setHeight(h);
diff --git a/src/widgets/styles/qwindowsmobilestyle.cpp b/src/widgets/styles/qwindowsmobilestyle.cpp
index 2f5ea7a54c..e34c2dfe00 100644
--- a/src/widgets/styles/qwindowsmobilestyle.cpp
+++ b/src/widgets/styles/qwindowsmobilestyle.cpp
@@ -4682,8 +4682,8 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
#ifndef QT_NO_PROGRESSBAR
case PE_IndicatorProgressChunk: {
bool vertical = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
- vertical = (pb2->orientation == Qt::Vertical);
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
+ vertical = pb->orientation == Qt::Vertical;
if (!vertical) {
painter->fillRect(option->rect.x(), option->rect.y()+2, option->rect.width(), option->rect.height()-4,
option->palette.brush(QPalette::Highlight));
@@ -4806,8 +4806,7 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
case PE_FrameGroupBox:
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(option);
- if (frame2 && !(frame2->features & QStyleOptionFrameV2::Flat)) {
+ if (!(frame->features & QStyleOptionFrame::Flat)) {
QPen oldPen = painter->pen();
QRect r = frame->rect;
painter->setPen(frame->palette.shadow().color());
@@ -5678,9 +5677,8 @@ void QWindowsMobileStyle::drawControl(ControlElement element, const QStyleOption
#ifndef QT_NO_DOCKWIDGET
case CE_DockWidgetTitle:
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(option);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+
+ const bool verticalTitleBar = dwOpt->verticalTitleBar;
QRect rect = dwOpt->rect;
QRect r = rect;
@@ -6168,7 +6166,7 @@ void QWindowsMobileStyle::drawComplexControl(ComplexControl control, const QStyl
QRect textRect = proxy()->subControlRect(CC_GroupBox, &groupBoxFont, SC_GroupBoxLabel, widget);
QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget).adjusted(0,0,0,0);
if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
- QStyleOptionFrameV2 frame;
+ QStyleOptionFrame frame;
frame.QStyleOption::operator=(*groupBox);
frame.features = groupBox->features;
frame.lineWidth = groupBox->lineWidth;
@@ -6800,8 +6798,8 @@ QRect QWindowsMobileStyle::subControlRect(ComplexControl control, const QStyleOp
QFontMetrics fontMetrics = groupBox->fontMetrics;
int h = fontMetrics.height();
int textWidth = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
- int margX = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 2;
- int margY = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 2;
+ const int margX = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 2;
+ const int margY = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 2;
rect = groupBox->rect.adjusted(margX, margY, -margX, 0);
if (groupBox->text.size())
rect.setHeight(h);
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 14af5ede39..01b82424c8 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -1024,9 +1024,9 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
case PE_IndicatorProgressChunk:
{
bool vertical = false, inverted = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- vertical = (pb2->orientation == Qt::Vertical);
- inverted = pb2->invertedAppearance;
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
+ vertical = pb->orientation == Qt::Vertical;
+ inverted = pb->invertedAppearance;
}
int space = 2;
@@ -1689,15 +1689,9 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
if (!rect.isValid())
return;
- bool vertical = false;
- bool inverted = false;
+ const bool vertical = pb->orientation == Qt::Vertical;
+ const bool inverted = pb->invertedAppearance;
- // Get extra style options if version 2
- const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
- if (pb2) {
- vertical = (pb2->orientation == Qt::Vertical);
- inverted = pb2->invertedAppearance;
- }
QMatrix m;
if (vertical) {
rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
@@ -1716,7 +1710,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
Q_D(const QWindowsStyle);
if (pb->minimum == 0 && pb->maximum == 0) {
const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
- QStyleOptionProgressBarV2 pbBits = *pb;
+ QStyleOptionProgressBar pbBits = *pb;
Q_ASSERT(unit_width >0);
pbBits.rect = rect;
@@ -1773,9 +1767,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
Q_D(const QWindowsStyle);
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+ const bool verticalTitleBar = dwOpt->verticalTitleBar;
QRect rect = dwOpt->rect;
QRect r = rect;
@@ -1796,7 +1788,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
QColor left, right;
//Titlebar gradient
- if (widget && widget->isWindow()) {
+ if (opt->state & QStyle::State_Window) {
floating = true;
if (active) {
left = d->activeCaptionColor;
@@ -1874,9 +1866,9 @@ QRect QWindowsStyle::subElementRect(SubElement sr, const QStyleOption *opt, cons
break;
case SE_DockWidgetTitleBarText: {
r = QCommonStyle::subElementRect(sr, opt, w);
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+ const QStyleOptionDockWidget *dwOpt
+ = qstyleoption_cast<const QStyleOptionDockWidget*>(opt);
+ const bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar;
int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w);
if (verticalTitleBar) {
r.adjust(0, 0, 0, -m);
diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h
index f1a4a390e1..c8778cc914 100644
--- a/src/widgets/styles/qwindowsstyle_p_p.h
+++ b/src/widgets/styles/qwindowsstyle_p_p.h
@@ -50,7 +50,6 @@
#ifndef QT_NO_STYLE_WINDOWS
#include <qlist.h>
-#include <qhash.h>
QT_BEGIN_NAMESPACE
@@ -66,7 +65,7 @@ public:
static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0);
static int fixedPixelMetric(QStyle::PixelMetric pm);
static int devicePixelRatio(const QWidget *widget = 0)
- { return widget ? widget->devicePixelRatio() : QWindowsStylePrivate::appDevicePixelRatio(); }
+ { return widget ? int(widget->devicePixelRatioF()) : QWindowsStylePrivate::appDevicePixelRatio(); }
bool hasSeenAlt(const QWidget *widget) const;
bool altDown() const { return alt_down; }
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index 375ada6a64..083b1d1707 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -657,12 +657,12 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
newStyle = !qobject_cast<const QTableView*>(view);
selectionBehavior = view->selectionBehavior();
selectionMode = view->selectionMode();
- }
#ifndef QT_NO_ACCESSIBILITY
- else if (!widget) {
+ } else if (!widget) {
newStyle = !QStyleHelper::hasAncestor(option->styleObject, QAccessible::MenuItem) ;
- }
#endif
+ }
+
if (newStyle && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option))) {
bool selected = vopt->state & QStyle::State_Selected;
const bool hover = selectionMode != QAbstractItemView::NoSelection && (vopt->state & QStyle::State_MouseOver);
@@ -1007,12 +1007,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
if (const QStyleOptionProgressBar *bar
= qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
bool isIndeterminate = (bar->minimum == 0 && bar->maximum == 0);
- bool vertical = false;
- bool inverted = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
- vertical = (pb2->orientation == Qt::Vertical);
- inverted = pb2->invertedAppearance;
- }
+ const bool vertical = bar->orientation == Qt::Vertical;
+ const bool inverted = bar->invertedAppearance;
if (isIndeterminate || (bar->progress > 0 && (bar->progress < bar->maximum) && d->transitionsEnabled())) {
if (!d->animation(styleObject(option)))
@@ -1378,9 +1374,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
break; //otherwise fall through
}
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+ const bool verticalTitleBar = dwOpt->verticalTitleBar;
if (verticalTitleBar) {
rect.setSize(rect.size().transposed());
@@ -2478,12 +2472,12 @@ bool QWindowsVistaStylePrivate::initTreeViewTheming()
m_treeViewHelper = createTreeViewHelperWindow();
if (!m_treeViewHelper) {
- qWarning("%s: Unable to create the treeview helper window.", Q_FUNC_INFO);
+ qWarning("Unable to create the treeview helper window.");
return false;
}
const HRESULT hr = QWindowsXPStylePrivate::pSetWindowTheme(m_treeViewHelper, L"explorer", NULL);
if (hr != S_OK) {
- qErrnoWarning("%s: SetWindowTheme() failed.", Q_FUNC_INFO);
+ qErrnoWarning("SetWindowTheme() failed.");
return false;
}
return QWindowsXPStylePrivate::createTheme(QWindowsXPStylePrivate::TreeViewTheme, m_treeViewHelper);
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index 7776773b87..c350e82c69 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -338,15 +338,15 @@ void QWindowsXPStylePrivate::cleanupHandleMap()
HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd)
{
if (theme < 0 || theme >= NThemes || !hwnd) {
- qWarning("%s: Invalid parameters #%d, %p", Q_FUNC_INFO, theme, hwnd);
+ qWarning("Invalid parameters #%d, %p", theme, hwnd);
return 0;
}
if (!m_themes[theme]) {
const wchar_t *name = themeNames[theme];
m_themes[theme] = pOpenThemeData(hwnd, name);
if (!m_themes[theme])
- qErrnoWarning("%s: OpenThemeData() failed for theme %d (%s).",
- Q_FUNC_INFO, theme, qPrintable(themeName(theme)));
+ qErrnoWarning("OpenThemeData() failed for theme %d (%s).",
+ theme, qPrintable(themeName(theme)));
}
return m_themes[theme];
}
@@ -1690,7 +1690,7 @@ case PE_Frame:
// This should work, but currently there's an error in the ::drawBackgroundDirectly()
// code, when using the HDC directly..
if (useGradient) {
- QStyleOptionTabWidgetFrameV2 frameOpt = *tab;
+ QStyleOptionTabWidgetFrame frameOpt = *tab;
frameOpt.rect = widget->rect();
QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget);
QRegion reg = option->rect;
@@ -1810,8 +1810,7 @@ case PE_Frame:
else
stateId = GBS_NORMAL;
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(option);
- if (frame2->features & QStyleOptionFrameV2::Flat) {
+ if (frame->features & QStyleOptionFrame::Flat) {
// Windows XP does not have a theme part for a flat GroupBox, paint it with the windows style
QRect fr = frame->rect;
QPoint p1(fr.x(), fr.y() + 1);
@@ -1826,10 +1825,9 @@ case PE_Frame:
{
Qt::Orientation orient = Qt::Horizontal;
bool inverted = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
- orient = pb2->orientation;
- if (pb2->invertedAppearance)
- inverted = true;
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ orient = pb->orientation;
+ inverted = pb->invertedAppearance;
}
if (orient == Qt::Horizontal) {
partId = PP_CHUNK;
@@ -2207,8 +2205,8 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
case CE_ProgressBarGroove:
{
Qt::Orientation orient = Qt::Horizontal;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
- orient = pb2->orientation;
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
+ orient = pb->orientation;
partId = (orient == Qt::Horizontal) ? PP_BAR : PP_BARVERT;
themeNumber = QWindowsXPStylePrivate::ProgressTheme;
stateId = 1;
@@ -2378,9 +2376,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
bool isFloating = widget && widget->isWindow();
bool isActive = dwOpt->state & State_Active;
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+ const bool verticalTitleBar = dwOpt->verticalTitleBar;
if (verticalTitleBar) {
rect.setSize(rect.size().transposed());
@@ -3316,8 +3312,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = 0)
{
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
- return pb2->orientation;
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
+ return pb->orientation;
return Qt::Horizontal;
}
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index fedc928f61..4382abaf50 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -432,7 +432,7 @@ void QCompletionEngine::filter(const QStringList& parts)
QModelIndex parent;
for (int i = 0; i < curParts.count() - 1; i++) {
- QString part = curParts[i];
+ QString part = curParts.at(i);
int emi = filter(part, parent, -1).exactMatchIndex;
if (emi == -1)
return;
@@ -442,10 +442,10 @@ void QCompletionEngine::filter(const QStringList& parts)
// Note that we set the curParent to a valid parent, even if we have no matches
// When filtering is disabled, we show all the items under this parent
curParent = parent;
- if (curParts.last().isEmpty())
+ if (curParts.constLast().isEmpty())
curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false);
else
- curMatch = filter(curParts.last(), curParent, 1); // build at least one
+ curMatch = filter(curParts.constLast(), curParent, 1); // build at least one
curRow = curMatch.isValid() ? 0 : -1;
}
@@ -1337,6 +1337,11 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e)
}
// default implementation for keys not handled by the widget when popup is open
+ if (ke->matches(QKeySequence::Cancel)) {
+ d->popup->hide();
+ return true;
+ }
+
switch (key) {
#ifdef QT_KEYPAD_NAVIGATION
case Qt::Key_Select:
@@ -1357,7 +1362,6 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e)
break;
case Qt::Key_Backtab:
- case Qt::Key_Escape:
d->popup->hide();
break;
@@ -1816,26 +1820,23 @@ QStringList QCompleter::splitPath(const QString& path) const
return QStringList(completionPrefix());
QString pathCopy = QDir::toNativeSeparators(path);
- QString sep = QDir::separator();
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
return QStringList(pathCopy);
- QString doubleSlash(QLatin1String("\\\\"));
- if (pathCopy.startsWith(doubleSlash))
+ const bool startsWithDoubleSlash = pathCopy.startsWith(QLatin1String("\\\\"));
+ if (startsWithDoubleSlash)
pathCopy = pathCopy.mid(2);
- else
- doubleSlash.clear();
#endif
- QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));
- QStringList parts = pathCopy.split(re);
+ const QChar sep = QDir::separator();
+ QStringList parts = pathCopy.split(sep);
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- if (!doubleSlash.isEmpty())
- parts[0].prepend(doubleSlash);
+ if (startsWithDoubleSlash)
+ parts[0].prepend(QLatin1String("\\\\"));
#else
- if (pathCopy[0] == sep[0]) // readd the "/" at the beginning as the split removed it
- parts[0] = QDir::fromNativeSeparators(QString(sep[0]));
+ if (pathCopy[0] == sep) // readd the "/" at the beginning as the split removed it
+ parts[0] = QLatin1Char('/');
#endif
return parts;
diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h
index 22230fc39e..32ee6296ca 100644
--- a/src/widgets/util/qcompleter.h
+++ b/src/widgets/util/qcompleter.h
@@ -76,10 +76,10 @@ public:
CaseInsensitivelySortedModel
};
- QCompleter(QObject *parent = 0);
- QCompleter(QAbstractItemModel *model, QObject *parent = 0);
+ QCompleter(QObject *parent = Q_NULLPTR);
+ QCompleter(QAbstractItemModel *model, QObject *parent = Q_NULLPTR);
#ifndef QT_NO_STRINGLISTMODEL
- QCompleter(const QStringList& completions, QObject *parent = 0);
+ QCompleter(const QStringList& completions, QObject *parent = Q_NULLPTR);
#endif
~QCompleter();
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 0e598717c8..c7e0861a0f 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -66,8 +66,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
case QEvent::MouseButtonRelease:
case QEvent::MouseMove: {
QMouseEvent *me = static_cast<QMouseEvent *>(e);
- QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(), me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
+ QMouseEvent *cme = new QMouseEvent(me->type(), QPoint(0, 0), me->windowPos(), me->screenPos(),
+ me->button(), me->buttons(), me->modifiers(), me->source());
return cme;
}
#ifndef QT_NO_GRAPHICSVIEW
@@ -78,8 +78,8 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
#if 1
QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
(me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
- QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(cme, me->source());
+ QMouseEvent *cme = new QMouseEvent(met, QPoint(0, 0), QPoint(0, 0), me->screenPos(),
+ me->button(), me->buttons(), me->modifiers(), me->source());
return cme;
#else
QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
@@ -155,9 +155,9 @@ public:
mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos());
mouseButton = pressDelayEvent->button();
mouseEventSource = pressDelayEvent->source();
- qFGDebug() << "QFG: consuming/delaying mouse press";
+ qFGDebug("QFG: consuming/delaying mouse press");
} else {
- qFGDebug() << "QFG: NOT consuming/delaying mouse press";
+ qFGDebug("QFG: NOT consuming/delaying mouse press");
}
e->setAccepted(true);
}
@@ -194,7 +194,7 @@ public:
void scrollerWasIntercepted()
{
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller was only intercepted";
+ qFGDebug("QFG: deleting delayed mouse press, since scroller was only intercepted");
if (pressDelayEvent) {
// we still haven't even sent the press, so just throw it away now
if (pressDelayTimer) {
@@ -210,7 +210,7 @@ public:
{
if (pressDelayEvent) {
// we still haven't even sent the press, so just throw it away now
- qFGDebug() << "QFG: deleting delayed mouse press, since scroller is active now";
+ qFGDebug("QFG: deleting delayed mouse press, since scroller is active now");
if (pressDelayTimer) {
killTimer(pressDelayTimer);
pressDelayTimer = 0;
@@ -240,8 +240,7 @@ public:
qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway,
mouseButton, QApplication::mouseButtons() & ~mouseButton,
- QApplication::keyboardModifiers());
- QGuiApplicationPrivate::setMouseEventSource(&re, mouseEventSource);
+ QApplication::keyboardModifiers(), mouseEventSource);
sendMouseEvent(&re, RegrabMouseAfterwards);
// don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
}
@@ -291,8 +290,7 @@ protected:
if (me) {
QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()),
mouseTarget->topLevelWidget()->mapFromGlobal(me->globalPos()), me->screenPos(),
- me->button(), me->buttons(), me->modifiers());
- QGuiApplicationPrivate::setMouseEventSource(&copy, me->source());
+ me->button(), me->buttons(), me->modifiers(), me->source());
qt_sendSpontaneousEvent(mouseTarget, &copy);
}
diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index de12983f21..38b104f9e9 100644
--- a/src/widgets/util/qscroller.cpp
+++ b/src/widgets/util/qscroller.cpp
@@ -976,7 +976,7 @@ bool QScroller::handleInput(Input input, const QPointF &position, qint64 timesta
{
Q_D(QScroller);
- qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")";
+ qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ')';
struct statechange {
State state;
Input input;
@@ -1296,7 +1296,7 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos,
qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation);
qreal higherSnapPos = nextSnapPos(startPos, 1, orientation);
- qScrollerDebug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos;
+ qScrollerDebug() << " Real Delta:" << lowerSnapPos << '-' << nextSnap << '-' <<higherSnapPos;
// - check if we can reach another snap point
if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos))
@@ -1668,7 +1668,7 @@ bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 time
void QScrollerPrivate::timerEventWhileScrolling()
{
- qScrollerDebug() << "QScroller::timerEventWhileScrolling()";
+ qScrollerDebug("QScroller::timerEventWhileScrolling()");
setContentPositionHelperScrolling();
if (xSegments.isEmpty() && ySegments.isEmpty())
@@ -1703,7 +1703,7 @@ void QScrollerPrivate::setState(QScroller::State newstate)
if (state == newstate)
return;
- qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ")";
+ qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ')';
switch (newstate) {
case QScroller::Inactive:
@@ -1870,8 +1870,8 @@ void QScrollerPrivate::setContentPositionHelperScrolling()
newPos.setY(nextSegmentPosition(ySegments, now, newPos.y()));
// -- set the position and handle overshoot
- qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()";
- qScrollerDebug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos;
+ qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()\n"
+ " --> overshoot:" << overshootPosition << "- new pos:" << newPos;
QPointF newClampedPos = clampToRect(newPos, contentPosRange);
diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm
index 9120c43075..07de07de52 100644
--- a/src/widgets/util/qscroller_mac.mm
+++ b/src/widgets/util/qscroller_mac.mm
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
QPointF QScrollerPrivate::realDpi(int screen)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ QMacAutoReleasePool pool;
NSArray *nsscreens = [NSScreen screens];
if (screen < 0 || screen >= int([nsscreens count]))
@@ -59,7 +59,6 @@ QPointF QScrollerPrivate::realDpi(int screen)
} else {
return QPointF();
}
- [pool release];
}
QT_END_NAMESPACE
diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h
index bb00c12905..d09f78d130 100644
--- a/src/widgets/util/qscroller_p.h
+++ b/src/widgets/util/qscroller_p.h
@@ -196,6 +196,9 @@ public:
QScroller *q_ptr;
};
+template <>
+class QTypeInfo<QScrollerPrivate::ScrollSegment>
+ : public QTypeInfoMerger<QScrollerPrivate::ScrollSegment, QEasingCurve> {};
QT_END_NAMESPACE
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index df3c291840..ebb29211a4 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
\l{http://standards.freedesktop.org/systemtray-spec/systemtray-spec-0.2.html freedesktop.org}
XEmbed system tray specification.
\li All X11 desktop environments that implement the D-Bus
- \l{http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/ StatusNotifierItem}
+ \l{http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem}
specification, including recent versions of KDE and Unity.
\li All supported versions of OS X. Note that the Growl
notification system must be installed for
@@ -284,12 +284,6 @@ bool QSystemTrayIcon::isVisible() const
*/
bool QSystemTrayIcon::event(QEvent *e)
{
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
- if (e->type() == QEvent::ToolTip) {
- Q_D(QSystemTrayIcon);
- return d->sys->deliverToolTipEvent(e);
- }
-#endif
return QObject::event(e);
}
diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h
index a4da0861e9..aba126b4fc 100644
--- a/src/widgets/util/qsystemtrayicon.h
+++ b/src/widgets/util/qsystemtrayicon.h
@@ -59,8 +59,8 @@ class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject
Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
public:
- QSystemTrayIcon(QObject *parent = 0);
- QSystemTrayIcon(const QIcon &icon, QObject *parent = 0);
+ QSystemTrayIcon(QObject *parent = Q_NULLPTR);
+ QSystemTrayIcon(const QIcon &icon, QObject *parent = Q_NULLPTR);
~QSystemTrayIcon();
enum ActivationReason {
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
index 1809c36483..f1b86ba2df 100644
--- a/src/widgets/util/qsystemtrayicon_win.cpp
+++ b/src/widgets/util/qsystemtrayicon_win.cpp
@@ -395,7 +395,7 @@ void QSystemTrayIconPrivate::install_sys()
sys->createIcon();
sys->trayMessage(NIM_ADD);
} else {
- qWarning("%s: The platform plugin failed to create a message window.", Q_FUNC_INFO);
+ qWarning("The platform plugin failed to create a message window.");
}
}
}
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 4060655d45..02bab236c8 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -52,6 +52,8 @@
#include <private/qguiapplication_p.h>
#include <qdebug.h>
+#include <QtPlatformHeaders/qxcbwindowfunctions.h>
+#include <QtPlatformHeaders/qxcbintegrationfunctions.h>
#ifndef QT_NO_SYSTEMTRAYICON
QT_BEGIN_NAMESPACE
@@ -112,17 +114,11 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn)
// window to ParentRelative (so that it inherits the background of its X11 parent window), call
// xcb_clear_region before painting (so that the inherited background is visible) and then grab
// the just-drawn background from the X11 server.
- bool hasAlphaChannel = false;
- QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "systrayVisualHasAlphaChannel", Qt::DirectConnection,
- Q_RETURN_ARG(bool, hasAlphaChannel));
+ bool hasAlphaChannel = QXcbIntegrationFunctions::xEmbedSystemTrayVisualHasAlphaChannel();
setAttribute(Qt::WA_TranslucentBackground, hasAlphaChannel);
if (!hasAlphaChannel) {
createWinId();
- QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "setParentRelativeBackPixmap", Qt::DirectConnection,
- Q_ARG(const QWindow *, windowHandle())
- );
+ QXcbWindowFunctions::setParentRelativeBackPixmap(windowHandle());
// XXX: This is actually required, but breaks things ("QWidget::paintEngine: Should no
// longer be called"). Why is this needed? When the widget is drawn, we use tricks to grab
@@ -143,15 +139,9 @@ bool QSystemTrayIconSys::addToTray()
createWinId();
setMouseTracking(true);
- bool requestResult = false;
- if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "requestSystemTrayWindowDock", Qt::DirectConnection,
- Q_RETURN_ARG(bool, requestResult),
- Q_ARG(const QWindow *, windowHandle()))
- || !requestResult) {
- qWarning("requestSystemTrayWindowDock failed.");
+ if (!QXcbWindowFunctions::requestSystemTrayWindowDock(windowHandle()))
return false;
- }
+
if (!background.isNull())
background = QPixmap();
show();
@@ -171,15 +161,7 @@ void QSystemTrayIconSys::systemTrayWindowChanged(QScreen *)
QRect QSystemTrayIconSys::globalGeometry() const
{
- QRect result;
- if (!QMetaObject::invokeMethod(QGuiApplication::platformNativeInterface(),
- "systemTrayWindowGlobalGeometry", Qt::DirectConnection,
- Q_RETURN_ARG(QRect, result),
- Q_ARG(const QWindow *, windowHandle()))
- || !result.isValid()) {
- qWarning("systemTrayWindowGlobalGeometry failed.");
- }
- return result;
+ return QXcbWindowFunctions::systemTrayWindowGlobalGeometry(windowHandle());
}
void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)
@@ -212,6 +194,9 @@ void QSystemTrayIconSys::mouseDoubleClickEvent(QMouseEvent *ev)
bool QSystemTrayIconSys::event(QEvent *e)
{
switch (e->type()) {
+ case QEvent::ToolTip:
+ QApplication::sendEvent(q, e);
+ break;
#ifndef QT_NO_WHEELEVENT
case QEvent::Wheel:
return QApplication::sendEvent(q, e);
diff --git a/src/widgets/util/qundogroup.h b/src/widgets/util/qundogroup.h
index ea4b226a18..ec6e67f4d3 100644
--- a/src/widgets/util/qundogroup.h
+++ b/src/widgets/util/qundogroup.h
@@ -52,7 +52,7 @@ class Q_WIDGETS_EXPORT QUndoGroup : public QObject
Q_DECLARE_PRIVATE(QUndoGroup)
public:
- explicit QUndoGroup(QObject *parent = 0);
+ explicit QUndoGroup(QObject *parent = Q_NULLPTR);
~QUndoGroup();
void addStack(QUndoStack *stack);
diff --git a/src/widgets/util/qundostack.h b/src/widgets/util/qundostack.h
index f6589da4ec..0b14a442c2 100644
--- a/src/widgets/util/qundostack.h
+++ b/src/widgets/util/qundostack.h
@@ -51,8 +51,8 @@ class Q_WIDGETS_EXPORT QUndoCommand
QUndoCommandPrivate *d;
public:
- explicit QUndoCommand(QUndoCommand *parent = 0);
- explicit QUndoCommand(const QString &text, QUndoCommand *parent = 0);
+ explicit QUndoCommand(QUndoCommand *parent = Q_NULLPTR);
+ explicit QUndoCommand(const QString &text, QUndoCommand *parent = Q_NULLPTR);
virtual ~QUndoCommand();
virtual void undo();
@@ -85,7 +85,7 @@ class Q_WIDGETS_EXPORT QUndoStack : public QObject
Q_PROPERTY(int undoLimit READ undoLimit WRITE setUndoLimit)
public:
- explicit QUndoStack(QObject *parent = 0);
+ explicit QUndoStack(QObject *parent = Q_NULLPTR);
~QUndoStack();
void clear();
diff --git a/src/widgets/util/qundoview.h b/src/widgets/util/qundoview.h
index a239d9b38e..2a15207ca5 100644
--- a/src/widgets/util/qundoview.h
+++ b/src/widgets/util/qundoview.h
@@ -55,10 +55,10 @@ class Q_WIDGETS_EXPORT QUndoView : public QListView
Q_PROPERTY(QIcon cleanIcon READ cleanIcon WRITE setCleanIcon)
public:
- explicit QUndoView(QWidget *parent = 0);
- explicit QUndoView(QUndoStack *stack, QWidget *parent = 0);
+ explicit QUndoView(QWidget *parent = Q_NULLPTR);
+ explicit QUndoView(QUndoStack *stack, QWidget *parent = Q_NULLPTR);
#ifndef QT_NO_UNDOGROUP
- explicit QUndoView(QUndoGroup *group, QWidget *parent = 0);
+ explicit QUndoView(QUndoGroup *group, QWidget *parent = Q_NULLPTR);
#endif
~QUndoView();
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index e413b3b87a..a1707b9cab 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -221,13 +221,12 @@ void QButtonGroup::addButton(QAbstractButton *button, int id)
button->d_func()->group = this;
d->buttonList.append(button);
if (id == -1) {
- QList<int> ids = d->mapping.values();
- if (ids.isEmpty())
- d->mapping[button] = -2;
- else {
- std::sort(ids.begin(), ids.end());
- d->mapping[button] = ids.first()-1;
- }
+ const QHash<QAbstractButton*, int>::const_iterator it
+ = std::min_element(d->mapping.cbegin(), d->mapping.cend());
+ if (it == d->mapping.cend())
+ d->mapping[button] = -2;
+ else
+ d->mapping[button] = *it - 1;
} else {
d->mapping[button] = id;
}
@@ -1222,16 +1221,14 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
}
break;
}
- case Qt::Key_Escape:
- if (d->down) {
+ default:
+ if (e->matches(QKeySequence::Cancel) && d->down) {
setDown(false);
repaint(); //flush paint event before invoking potentially expensive operation
QApplication::flush();
d->emitReleased();
- break;
+ return;
}
- // fall through
- default:
e->ignore();
}
}
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h
index 4b397e2396..5f3e82a2e6 100644
--- a/src/widgets/widgets/qabstractbutton.h
+++ b/src/widgets/widgets/qabstractbutton.h
@@ -63,7 +63,7 @@ class Q_WIDGETS_EXPORT QAbstractButton : public QWidget
Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false)
public:
- explicit QAbstractButton(QWidget* parent=0);
+ explicit QAbstractButton(QWidget *parent = Q_NULLPTR);
~QAbstractButton();
void setText(const QString &text);
@@ -135,7 +135,7 @@ protected:
protected:
- QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0);
+ QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = Q_NULLPTR);
private:
Q_DECLARE_PRIVATE(QAbstractButton)
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 2e1caedde7..65d06eafc5 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -168,6 +168,10 @@ QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
{
}
+QAbstractScrollAreaPrivate::~QAbstractScrollAreaPrivate()
+{
+}
+
QAbstractScrollAreaScrollBarContainer::QAbstractScrollAreaScrollBarContainer(Qt::Orientation orientation, QWidget *parent)
:QWidget(parent), scrollBar(new QScrollBar(orientation, this)),
layout(new QBoxLayout(orientation == Qt::Horizontal ? QBoxLayout::LeftToRight : QBoxLayout::TopToBottom)),
@@ -206,10 +210,12 @@ QWidgetList QAbstractScrollAreaScrollBarContainer::widgets(LogicalPosition posit
QWidgetList list;
const int scrollBarIndex = scrollBarLayoutIndex();
if (position == LogicalLeft) {
+ list.reserve(scrollBarIndex);
for (int i = 0; i < scrollBarIndex; ++i)
list.append(layout->itemAt(i)->widget());
} else if (position == LogicalRight) {
const int layoutItemCount = layout->count();
+ list.reserve(layoutItemCount - (scrollBarIndex + 1));
for (int i = scrollBarIndex + 1; i < layoutItemCount; ++i)
list.append(layout->itemAt(i)->widget());
}
diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h
index 13dafd547b..8bc32b1c78 100644
--- a/src/widgets/widgets/qabstractscrollarea.h
+++ b/src/widgets/widgets/qabstractscrollarea.h
@@ -54,7 +54,7 @@ class Q_WIDGETS_EXPORT QAbstractScrollArea : public QFrame
Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
public:
- explicit QAbstractScrollArea(QWidget* parent=0);
+ explicit QAbstractScrollArea(QWidget *parent = Q_NULLPTR);
~QAbstractScrollArea();
enum SizeAdjustPolicy {
@@ -94,7 +94,7 @@ public:
void setSizeAdjustPolicy(SizeAdjustPolicy policy);
protected:
- QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0);
+ QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = Q_NULLPTR);
void setViewportMargins(int left, int top, int right, int bottom);
void setViewportMargins(const QMargins &margins);
QMargins viewportMargins() const;
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index f770bb69f8..33222573f4 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -54,12 +54,15 @@ QT_BEGIN_NAMESPACE
class QScrollBar;
class QAbstractScrollAreaScrollBarContainer;
+
+// ### Qt 6: is the export still needed? If not, unexport QFramePrivate, too.
class Q_WIDGETS_EXPORT QAbstractScrollAreaPrivate: public QFramePrivate
{
Q_DECLARE_PUBLIC(QAbstractScrollArea)
public:
QAbstractScrollAreaPrivate();
+ ~QAbstractScrollAreaPrivate();
void replaceScrollBar(QScrollBar *scrollBar, Qt::Orientation orientation);
diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h
index 2f649e3d3d..6faca5ea3c 100644
--- a/src/widgets/widgets/qabstractslider.h
+++ b/src/widgets/widgets/qabstractslider.h
@@ -58,7 +58,7 @@ class Q_WIDGETS_EXPORT QAbstractSlider : public QWidget
Q_PROPERTY(bool sliderDown READ isSliderDown WRITE setSliderDown DESIGNABLE false)
public:
- explicit QAbstractSlider(QWidget *parent=0);
+ explicit QAbstractSlider(QWidget *parent = Q_NULLPTR);
~QAbstractSlider();
Qt::Orientation orientation() const;
@@ -144,7 +144,7 @@ protected:
protected:
- QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent=0);
+ QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent = Q_NULLPTR);
private:
Q_DISABLE_COPY(QAbstractSlider)
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index c96c779d6a..ba4bbe40a8 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -720,7 +720,16 @@ void QAbstractSpinBox::interpretText()
QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const
{
Q_D(const QAbstractSpinBox);
- return d->edit->inputMethodQuery(query);
+ const QVariant lineEditValue = d->edit->inputMethodQuery(query);
+ switch (query) {
+ case Qt::ImHints:
+ if (const int hints = inputMethodHints())
+ return QVariant(hints | lineEditValue.toInt());
+ break;
+ default:
+ break;
+ }
+ return lineEditValue;
}
/*!
diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h
index a80a89c894..046036b9a8 100644
--- a/src/widgets/widgets/qabstractspinbox.h
+++ b/src/widgets/widgets/qabstractspinbox.h
@@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QAbstractSpinBox : public QWidget
Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking)
Q_PROPERTY(bool showGroupSeparator READ isGroupSeparatorShown WRITE setGroupSeparatorShown)
public:
- explicit QAbstractSpinBox(QWidget *parent = 0);
+ explicit QAbstractSpinBox(QWidget *parent = Q_NULLPTR);
~QAbstractSpinBox();
enum StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01,
@@ -154,7 +154,7 @@ protected:
Q_SIGNALS:
void editingFinished();
protected:
- QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = 0);
+ QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = Q_NULLPTR);
private:
Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &))
diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h
index 01de03ac84..ba4f8e26c1 100644
--- a/src/widgets/widgets/qbuttongroup.h
+++ b/src/widgets/widgets/qbuttongroup.h
@@ -51,7 +51,7 @@ class Q_WIDGETS_EXPORT QButtonGroup : public QObject
Q_PROPERTY(bool exclusive READ exclusive WRITE setExclusive)
public:
- explicit QButtonGroup(QObject *parent = 0);
+ explicit QButtonGroup(QObject *parent = Q_NULLPTR);
~QButtonGroup();
void setExclusive(bool);
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 2150fc7a50..48b224fe13 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -776,7 +776,7 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e)
applyDate();
emit editingFinished();
removeDateLabel();
- } else if (ke->key() == Qt::Key_Escape) {
+ } else if (ke->matches(QKeySequence::Cancel)) {
removeDateLabel();
} else if (e->type() == QEvent::KeyPress) {
createDateLabel();
@@ -3078,8 +3078,7 @@ void QCalendarWidget::resizeEvent(QResizeEvent * event)
void QCalendarWidget::keyPressEvent(QKeyEvent * event)
{
Q_D(QCalendarWidget);
- if(d->yearEdit->isVisible()&& event->key() == Qt::Key_Escape)
- {
+ if (d->yearEdit->isVisible()&& event->matches(QKeySequence::Cancel)) {
d->yearEdit->setValue(yearShown());
d->_q_yearEditingFinished();
return;
diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h
index c456cc2161..df54985351 100644
--- a/src/widgets/widgets/qcalendarwidget.h
+++ b/src/widgets/widgets/qcalendarwidget.h
@@ -83,7 +83,7 @@ public:
};
Q_ENUM(SelectionMode)
- explicit QCalendarWidget(QWidget *parent = 0);
+ explicit QCalendarWidget(QWidget *parent = Q_NULLPTR);
~QCalendarWidget();
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h
index b614659f02..61d03eb8e6 100644
--- a/src/widgets/widgets/qcheckbox.h
+++ b/src/widgets/widgets/qcheckbox.h
@@ -49,8 +49,8 @@ class Q_WIDGETS_EXPORT QCheckBox : public QAbstractButton
Q_PROPERTY(bool tristate READ isTristate WRITE setTristate)
public:
- explicit QCheckBox(QWidget *parent=0);
- explicit QCheckBox(const QString &text, QWidget *parent=0);
+ explicit QCheckBox(QWidget *parent = Q_NULLPTR);
+ explicit QCheckBox(const QString &text, QWidget *parent = Q_NULLPTR);
~QCheckBox();
QSize sizeHint() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index b04aa7053a..35c54f102f 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -546,7 +546,8 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
disconnect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
- delete view;
+ if (isAncestorOf(view))
+ delete view;
view = 0;
}
@@ -653,8 +654,9 @@ void QComboBoxPrivateContainer::changeEvent(QEvent *e)
bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
{
switch (e->type()) {
- case QEvent::ShortcutOverride:
- switch (static_cast<QKeyEvent*>(e)->key()) {
+ case QEvent::ShortcutOverride: {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(e);
+ switch (keyEvent->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
#ifdef QT_KEYPAD_NAVIGATION
@@ -666,17 +668,21 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
}
return true;
case Qt::Key_Down:
- if (!(static_cast<QKeyEvent*>(e)->modifiers() & Qt::AltModifier))
+ if (!(keyEvent->modifiers() & Qt::AltModifier))
break;
// fall through
case Qt::Key_F4:
- case Qt::Key_Escape:
combo->hidePopup();
return true;
default:
+ if (keyEvent->matches(QKeySequence::Cancel)) {
+ combo->hidePopup();
+ return true;
+ }
break;
}
- break;
+ break;
+ }
case QEvent::MouseMove:
if (isVisible()) {
QMouseEvent *m = static_cast<QMouseEvent *>(e);
@@ -2268,6 +2274,7 @@ void QComboBox::insertItems(int index, const QStringList &list)
// construct a QStandardItem, reducing the number of expensive signals from the model
if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(d->model)) {
QList<QStandardItem *> items;
+ items.reserve(insertCount);
QStandardItem *hiddenRoot = m->invisibleRootItem();
for (int i = 0; i < insertCount; ++i)
items.append(new QStandardItem(list.at(i)));
@@ -3032,9 +3039,6 @@ void QComboBox::mousePressEvent(QMouseEvent *e)
d->showPopupFromMouseEvent(e);
}
-/*!
- \reimp
-*/
void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e)
{
Q_Q(QComboBox);
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index ae35f7a89a..3182a0a3aa 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -74,7 +74,7 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget
Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
public:
- explicit QComboBox(QWidget *parent = 0);
+ explicit QComboBox(QWidget *parent = Q_NULLPTR);
~QComboBox();
int maxVisibleItems() const;
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 3fdfdcc22f..b69b94f3b9 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -57,7 +57,6 @@
#include "QtGui/qpainter.h"
#include "QtWidgets/qstyle.h"
#include "QtWidgets/qstyleoption.h"
-#include "QtCore/qhash.h"
#include "QtCore/qpair.h"
#include "QtCore/qtimer.h"
#include "private/qwidget_p.h"
diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h
index 486c48af5d..9ddb14270d 100644
--- a/src/widgets/widgets/qcommandlinkbutton.h
+++ b/src/widgets/widgets/qcommandlinkbutton.h
@@ -49,9 +49,9 @@ class Q_WIDGETS_EXPORT QCommandLinkButton: public QPushButton
Q_PROPERTY(bool flat READ isFlat WRITE setFlat DESIGNABLE false)
public:
- explicit QCommandLinkButton(QWidget *parent=0);
- explicit QCommandLinkButton(const QString &text, QWidget *parent=0);
- explicit QCommandLinkButton(const QString &text, const QString &description, QWidget *parent=0);
+ explicit QCommandLinkButton(QWidget *parent = Q_NULLPTR);
+ explicit QCommandLinkButton(const QString &text, QWidget *parent = Q_NULLPTR);
+ explicit QCommandLinkButton(const QString &text, const QString &description, QWidget *parent = Q_NULLPTR);
~QCommandLinkButton();
QString description() const;
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index a8da78a025..abee788a46 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -1687,6 +1687,10 @@ QDateTimeEditPrivate::QDateTimeEditPrivate()
#endif
}
+QDateTimeEditPrivate::~QDateTimeEditPrivate()
+{
+}
+
void QDateTimeEditPrivate::updateTimeSpec()
{
minimum = minimum.toDateTime().toTimeSpec(spec);
@@ -2655,7 +2659,7 @@ bool QCalendarPopup::event(QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
- if (keyEvent->key()== Qt::Key_Escape)
+ if (keyEvent->matches(QKeySequence::Cancel))
dateChanged = false;
}
return QWidget::event(event);
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
index 4e77713fd0..829ce205be 100644
--- a/src/widgets/widgets/qdatetimeedit.h
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -86,10 +86,10 @@ public:
Q_DECLARE_FLAGS(Sections, Section)
- explicit QDateTimeEdit(QWidget *parent = 0);
- explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = 0);
- explicit QDateTimeEdit(const QDate &d, QWidget *parent = 0);
- explicit QDateTimeEdit(const QTime &t, QWidget *parent = 0);
+ explicit QDateTimeEdit(QWidget *parent = Q_NULLPTR);
+ explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = Q_NULLPTR);
+ explicit QDateTimeEdit(const QDate &d, QWidget *parent = Q_NULLPTR);
+ explicit QDateTimeEdit(const QTime &t, QWidget *parent = Q_NULLPTR);
~QDateTimeEdit();
QDateTime dateTime() const;
@@ -185,7 +185,7 @@ protected:
virtual void paintEvent(QPaintEvent *event);
void initStyleOption(QStyleOptionSpinBox *option) const;
- QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = 0);
+ QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = Q_NULLPTR);
private:
Q_DECLARE_PRIVATE(QDateTimeEdit)
Q_DISABLE_COPY(QDateTimeEdit)
@@ -198,8 +198,8 @@ class Q_WIDGETS_EXPORT QTimeEdit : public QDateTimeEdit
Q_OBJECT
Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY userTimeChanged USER true)
public:
- explicit QTimeEdit(QWidget *parent = 0);
- explicit QTimeEdit(const QTime &time, QWidget *parent = 0);
+ explicit QTimeEdit(QWidget *parent = Q_NULLPTR);
+ explicit QTimeEdit(const QTime &time, QWidget *parent = Q_NULLPTR);
~QTimeEdit();
Q_SIGNALS:
@@ -211,8 +211,8 @@ class Q_WIDGETS_EXPORT QDateEdit : public QDateTimeEdit
Q_OBJECT
Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY userDateChanged USER true)
public:
- explicit QDateEdit(QWidget *parent = 0);
- explicit QDateEdit(const QDate &date, QWidget *parent = 0);
+ explicit QDateEdit(QWidget *parent = Q_NULLPTR);
+ explicit QDateEdit(const QDate &date, QWidget *parent = Q_NULLPTR);
~QDateEdit();
Q_SIGNALS:
diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h
index 50e2cde8cc..4a6014000b 100644
--- a/src/widgets/widgets/qdatetimeedit_p.h
+++ b/src/widgets/widgets/qdatetimeedit_p.h
@@ -62,11 +62,12 @@
QT_BEGIN_NAMESPACE
class QCalendarPopup;
-class QDateTimeEditPrivate : public QAbstractSpinBoxPrivate, public QDateTimeParser
+class Q_AUTOTEST_EXPORT QDateTimeEditPrivate : public QAbstractSpinBoxPrivate, public QDateTimeParser
{
Q_DECLARE_PUBLIC(QDateTimeEdit)
public:
QDateTimeEditPrivate();
+ ~QDateTimeEditPrivate();
void init(const QVariant &var);
void readLocaleSettings();
diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h
index 7e01aefce3..cb69e02301 100644
--- a/src/widgets/widgets/qdial.h
+++ b/src/widgets/widgets/qdial.h
@@ -54,7 +54,7 @@ class Q_WIDGETS_EXPORT QDial: public QAbstractSlider
Q_PROPERTY(qreal notchTarget READ notchTarget WRITE setNotchTarget)
Q_PROPERTY(bool notchesVisible READ notchesVisible WRITE setNotchesVisible)
public:
- explicit QDial(QWidget *parent = 0);
+ explicit QDial(QWidget *parent = Q_NULLPTR);
~QDial();
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 5b6bfb3b3c..4d2c32d43e 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -261,7 +261,7 @@ void QDialogButtonBoxPrivate::layoutButtons()
if (center)
buttonLayout->addStretch();
- QList<QAbstractButton *> acceptRoleList = buttonLists[QPlatformDialogHelper::AcceptRole];
+ const QList<QAbstractButton *> &acceptRoleList = buttonLists[QPlatformDialogHelper::AcceptRole];
while (*currentLayout != QPlatformDialogHelper::EOL) {
int role = (*currentLayout & ~QPlatformDialogHelper::Reverse);
diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h
index 02960b5b79..83c1fd66fd 100644
--- a/src/widgets/widgets/qdialogbuttonbox.h
+++ b/src/widgets/widgets/qdialogbuttonbox.h
@@ -106,11 +106,11 @@ public:
GnomeLayout
};
- QDialogButtonBox(QWidget *parent = 0);
- QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = 0);
- explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = 0);
+ QDialogButtonBox(QWidget *parent = Q_NULLPTR);
+ QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
+ explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = Q_NULLPTR);
QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
- QWidget *parent = 0);
+ QWidget *parent = Q_NULLPTR);
~QDialogButtonBox();
void setOrientation(Qt::Orientation orientation);
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index e71b9616fc..8c79425e44 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -1017,7 +1018,7 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)
index = -index - 1;
if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
+ QDockAreaLayoutItem &item = item_list[index];
Q_ASSERT(item.subinfo != 0);
return item.subinfo->plug(path.mid(1));
}
@@ -1063,7 +1064,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
const int index = path.first();
if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
+ QDockAreaLayoutItem &item = item_list[index];
Q_ASSERT(item.subinfo != 0);
return item.subinfo->unplug(path.mid(1));
}
@@ -1815,7 +1816,8 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
stream << flags;
if (w->isWindow()) {
- stream << w->x() << w->y() << w->width() << w->height();
+ const QRect geometry = w->geometry();
+ stream << geometry.x() << geometry.y() << geometry.width() << geometry.height();
} else {
stream << item.pos << item.size << pick(o, item.minimumSize())
<< pick(o, item.maximumSize());
@@ -1854,20 +1856,6 @@ static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
return Qt::NoDockWidgetArea;
}
-static QRect constrainedRect(QRect rect, const QRect &desktop)
-{
- if (desktop.isValid()) {
- rect.setWidth(qMin(rect.width(), desktop.width()));
- rect.setHeight(qMin(rect.height(), desktop.height()));
- rect.moveLeft(qMax(rect.left(), desktop.left()));
- rect.moveTop(qMax(rect.top(), desktop.top()));
- rect.moveRight(qMin(rect.right(), desktop.right()));
- rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
- }
-
- return rect;
-}
-
bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing)
{
uchar marker;
@@ -1958,11 +1946,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
#endif
if (!testing) {
QRect r(x, y, w, h);
- QDesktopWidget *desktop = QApplication::desktop();
- if (desktop->isVirtualDesktop())
- r = constrainedRect(r, desktop->screenGeometry(desktop->screenNumber(r.topLeft())));
- else
- r = constrainedRect(r, desktop->screenGeometry(widget));
+ r = QDockAreaLayout::constrainedRect(r, widget);
widget->move(r.topLeft());
widget->resize(r.size());
}
@@ -2075,6 +2059,36 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const
#endif //QT_NO_TABBAR
#ifndef QT_NO_TABBAR
+/*! \internal
+ reparent all the widgets contained in this layout portion to the
+ specified parent. This is used to reparent dock widgets and tabbars
+ to the floating window or the main window
+ */
+void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent)
+{
+ if (tabBar)
+ tabBar->setParent(parent);
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.flags & QDockAreaLayoutItem::GapItem)
+ continue;
+ if (item.skip())
+ continue;
+ if (item.subinfo)
+ item.subinfo->reparentWidgets(parent);
+ if (item.widgetItem) {
+ QWidget *w = item.widgetItem->widget();
+ if (w->parent() != parent) {
+ bool hidden = w->isHidden();
+ w->setParent(parent);
+ if (!hidden)
+ w->show();
+ }
+ }
+ }
+}
+
//returns whether the tabbar is visible or not
bool QDockAreaLayoutInfo::updateTabBar() const
{
@@ -2092,6 +2106,8 @@ bool QDockAreaLayoutInfo::updateTabBar() const
const QSignalBlocker blocker(tabBar);
bool gap = false;
+ const quintptr oldCurrentId = currentTabId();
+
int tab_idx = 0;
for (int i = 0; i < item_list.count(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
@@ -2140,6 +2156,9 @@ bool QDockAreaLayoutInfo::updateTabBar() const
tabBar->removeTab(tab_idx);
}
+ if (oldCurrentId > 0 && currentTabId() != oldCurrentId)
+ that->setCurrentTabId(oldCurrentId);
+
//returns if the tabbar is visible or not
return ( (gap ? 1 : 0) + tabBar->count()) > 1;
}
@@ -2198,8 +2217,10 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const
QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const
{
QSet<QWidget*> result;
+ const int numSeparatorWidgets = separatorWidgets.count();
+ result.reserve(numSeparatorWidgets);
- for (int i = 0; i < separatorWidgets.count(); ++i)
+ for (int i = 0; i < numSeparatorWidgets; ++i)
result << separatorWidgets.at(i);
for (int i = 0; i < item_list.count(); ++i) {
@@ -2244,6 +2265,22 @@ QRect QDockAreaLayoutInfo::tabContentRect() const
return result;
}
+
+int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const
+{
+ Q_ASSERT(tabbed && tabBar);
+ quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex));
+ for (int i = 0; i < item_list.count(); ++i) {
+ if (tabId(item_list.at(i)) == data)
+ return i;
+ }
+ return -1;
+}
+
+void QDockAreaLayoutInfo::moveTab(int from, int to)
+{
+ item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to));
+}
#endif // QT_NO_TABBAR
/******************************************************************************
@@ -2965,6 +3002,33 @@ QSize QDockAreaLayout::minimumSize() const
return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
}
+/*! \internal
+ Try to fit the given rectangle \a rect on the screen which contains
+ the window \a widget.
+ Used to compute the geometry of a dragged a dock widget that should
+ be shown with \a rect, but needs to be visible on the screen
+ */
+QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)
+{
+ QRect desktop;
+ QDesktopWidget *desktopW = QApplication::desktop();
+ if (desktopW->isVirtualDesktop())
+ desktop = desktopW->screenGeometry(rect.topLeft());
+ else
+ desktop = desktopW->screenGeometry(widget);
+
+ if (desktop.isValid()) {
+ rect.setWidth(qMin(rect.width(), desktop.width()));
+ rect.setHeight(qMin(rect.height(), desktop.height()));
+ rect.moveLeft(qMax(rect.left(), desktop.left()));
+ rect.moveTop(qMax(rect.top(), desktop.top()));
+ rect.moveRight(qMin(rect.right(), desktop.right()));
+ rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
+ }
+
+ return rect;
+}
+
bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
{
QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
@@ -2978,9 +3042,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
item.widgetItem = new QDockWidgetItem(dockWidget);
if (placeHolder->window) {
- const QRect screenGeometry =
- QApplication::desktop()->screenGeometry(placeHolder->topLevelRect.center());
- const QRect r = constrainedRect(placeHolder->topLevelRect, screenGeometry);
+ const QRect r = constrainedRect(placeHolder->topLevelRect, dockWidget);
dockWidget->d_func()->setWindowState(true, true, r);
}
dockWidget->setVisible(!placeHolder->hidden);
@@ -3045,6 +3107,53 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
remove(index);
}
+void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks,
+ const QList<int> &sizes, Qt::Orientation o)
+{
+ if (docks.count() != sizes.count()) {
+ qWarning("QMainWidget::resizeDocks: size of the lists are not the same");
+ return;
+ }
+ int count = docks.count();
+ fallbackToSizeHints = false;
+ for (int i = 0; i < count; ++i) {
+ QList<int> path = indexOf(docks[i]);
+ if (path.isEmpty()) {
+ qWarning("QMainWidget::resizeDocks: one QDockWidget is not part of the layout");
+ continue;
+ }
+ int size = sizes[i];
+ if (size <= 0) {
+ qWarning("QMainWidget::resizeDocks: all sizes need to be larger than 0");
+ size = 1;
+ }
+
+ while (path.size() > 1) {
+ QDockAreaLayoutInfo *info = this->info(path);
+ if (!info->tabbed && info->o == o) {
+ info->item_list[path.last()].size = size;
+ int totalSize = 0;
+ foreach (const QDockAreaLayoutItem &item, info->item_list) {
+ if (!item.skip()) {
+ if (totalSize != 0)
+ totalSize += sep;
+ totalSize += item.size == -1 ? pick(o, item.sizeHint()) : item.size;
+ }
+ }
+ size = totalSize;
+ }
+ path.removeLast();
+ }
+
+ const int dockNum = path.first();
+ Q_ASSERT(dockNum < QInternal::DockCount);
+ QRect &r = this->docks[dockNum].rect;
+ QSize s = r.size();
+ rpick(o, s) = size;
+ r.setSize(s);
+ }
+}
+
void QDockAreaLayout::splitDockWidget(QDockWidget *after,
QDockWidget *dockWidget,
Qt::Orientation orientation)
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
index 7c67466c7b..5d352f0124 100644
--- a/src/widgets/widgets/qdockarealayout_p.h
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -202,12 +202,16 @@ public:
QTabBar *tabBar;
int tabBarShape;
+ void reparentWidgets(QWidget *p);
bool updateTabBar() const;
void setTabBarShape(int shape);
QSize tabBarMinimumSize() const;
QSize tabBarSizeHint() const;
QSet<QTabBar*> usedTabBars() const;
+
+ int tabIndexToListIndex(int) const;
+ void moveTab(int from, int to);
#endif // QT_NO_TABBAR
};
@@ -229,7 +233,8 @@ public:
bool isValid() const;
- enum { DockWidgetStateMarker = 0xfd };
+ enum { DockWidgetStateMarker = 0xfd, FloatingDockWidgetTabMarker = 0xf9 };
+ static QRect constrainedRect(QRect rect, QWidget *widget);
void saveState(QDataStream &stream) const;
bool restoreState(QDataStream &stream, const QList<QDockWidget*> &widgets, bool testing = false);
@@ -263,6 +268,7 @@ public:
void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget,
Qt::Orientation orientation);
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
+ void resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation o);
void apply(bool animate);
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 21b0904cc0..67eb466ba8 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -65,6 +65,18 @@ extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); /
// qmainwindow.cpp
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
+static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock)
+{
+ const QWidget *p = dock->parentWidget();
+ while (p) {
+ const QMainWindow *window = qobject_cast<const QMainWindow*>(p);
+ if (window)
+ return qt_mainwindow_layout(window);
+ p = p->parentWidget();
+ }
+ return Q_NULLPTR;
+}
+
static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
{ return (priv->features & feature) == feature; }
@@ -194,31 +206,46 @@ QDockWidgetLayout::~QDockWidgetLayout()
qDeleteAll(item_list);
}
+/*! \internal
+ Returns true if the dock widget managed by this layout should have a native
+ window decoration or if Qt needs to draw it.
+ */
bool QDockWidgetLayout::nativeWindowDeco() const
{
- return nativeWindowDeco(parentWidget()->isWindow());
+ bool floating = parentWidget()->isWindow();
+ if (!floating && qobject_cast<QDockWidgetGroupWindow*>(parentWidget()->parentWidget()))
+ return wmSupportsNativeWindowDeco();
+ return nativeWindowDeco(floating);
}
-static bool isXcb()
+/*! \internal
+ Returns true if the window manager can draw natively the windows decoration
+ of a dock widget
+ */
+bool QDockWidgetLayout::wmSupportsNativeWindowDeco()
{
+#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID)
+ return false;
+#else
static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive);
- return xcb;
+ return !xcb;
+#endif
}
+/*! \internal
+ Returns true if the dock widget managed by this layout should have a native
+ window decoration or if Qt needs to draw it. The \a floating parameter
+ overrides the floating current state of the dock widget.
+ */
bool QDockWidgetLayout::nativeWindowDeco(bool floating) const
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID)
- Q_UNUSED(floating)
- return false;
-#else
- return !isXcb() && (floating && item_list[QDockWidgetLayout::TitleBar] == 0);
-#endif
+ return wmSupportsNativeWindowDeco() && floating && item_list.at(QDockWidgetLayout::TitleBar) == 0;
}
void QDockWidgetLayout::addItem(QLayoutItem*)
{
- qWarning() << "QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()";
+ qWarning("QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()");
return;
}
@@ -480,7 +507,7 @@ void QDockWidgetLayout::setGeometry(const QRect &geometry)
if (QLayoutItem *item = item_list[TitleBar]) {
item->setGeometry(_titleArea);
} else {
- QStyleOptionDockWidgetV2 opt;
+ QStyleOptionDockWidget opt;
q->initStyleOption(&opt);
if (QLayoutItem *item = item_list[CloseButton]) {
@@ -587,6 +614,7 @@ void QDockWidgetPrivate::init()
#ifndef QT_NO_ACTION
toggleViewAction = new QAction(q);
toggleViewAction->setCheckable(true);
+ toggleViewAction->setMenuRole(QAction::NoRole);
fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q);
toggleViewAction->setText(fixedWindowTitle);
QObject::connect(toggleViewAction, SIGNAL(triggered(bool)),
@@ -611,7 +639,10 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const
return;
QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout());
- option->initFrom(this);
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent());
+ // If we are in a floating tab, init from the parent because the attributes and the geometry
+ // of the title bar should be taken from the floating window.
+ option->initFrom(floatingTab && !isFloating() ? parentWidget() : this);
option->rect = dwlayout->titleArea();
option->title = d->fixedWindowTitle;
option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
@@ -619,10 +650,7 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const
option->floatable = hasFeature(this, QDockWidget::DockWidgetFloatable);
QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(layout());
- QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<QStyleOptionDockWidgetV2*>(option);
- if (v2 != 0)
- v2->verticalTitleBar = l->verticalTitleBar;
+ option->verticalTitleBar = l->verticalTitleBar;
}
void QDockWidgetPrivate::_q_toggleView(bool b)
@@ -681,14 +709,20 @@ void QDockWidgetPrivate::_q_toggleTopLevel()
q->setFloating(!q->isFloating());
}
+/*! \internal
+ Initialize the drag state structure and remember the position of the click.
+ This is called when the mouse is pressed, but the dock is not yet dragged out.
+
+ \a nca specify that the event comes from NonClientAreaMouseButtonPress
+ */
void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
{
+ Q_Q(QDockWidget);
+
if (state != 0)
return;
- QMainWindow *win = qobject_cast<QMainWindow*>(parent);
- Q_ASSERT(win != 0);
- QMainWindowLayout *layout = qt_mainwindow_layout(win);
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
if (layout->pluggingWidget != 0) // the main window is animating a docking operation
return;
@@ -702,23 +736,33 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
state->ctrlDrag = false;
}
-void QDockWidgetPrivate::startDrag()
+/*! \internal
+ Actually start the drag and detach the dockwidget.
+ The \a group parameter is true when we should potentially drag a group of
+ tabbed widgets, and false if the dock widget should always be dragged
+ alone.
+ */
+void QDockWidgetPrivate::startDrag(bool group)
{
Q_Q(QDockWidget);
if (state == 0 || state->dragging)
return;
- QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
- state->widgetItem = layout->unplug(q);
+ state->widgetItem = layout->unplug(q, group);
if (state->widgetItem == 0) {
/* I have a QMainWindow parent, but I was never inserted with
QMainWindow::addDockWidget, so the QMainWindowLayout has no
widget item for me. :( I have to create it myself, and then
delete it if I don't get dropped into a dock area. */
- state->widgetItem = new QDockWidgetItem(q);
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
+ if (floatingTab && !q->isFloating())
+ state->widgetItem = new QDockWidgetGroupWindowItem(floatingTab);
+ else
+ state->widgetItem = new QDockWidgetItem(q);
state->ownWidgetItem = true;
}
@@ -728,6 +772,11 @@ void QDockWidgetPrivate::startDrag()
state->dragging = true;
}
+/*! \internal
+ Ends the drag end drop operation of the QDockWidget.
+ The \a abort parameter specifies that it ends because of programmatic state
+ reset rather than mouse release event.
+ */
void QDockWidgetPrivate::endDrag(bool abort)
{
Q_Q(QDockWidget);
@@ -736,29 +785,31 @@ void QDockWidgetPrivate::endDrag(bool abort)
q->releaseMouse();
if (state->dragging) {
- QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwLayout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(mwLayout != 0);
if (abort || !mwLayout->plug(state->widgetItem)) {
if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
+ // This QDockWidget will now stay in the floating state.
if (state->ownWidgetItem)
delete state->widgetItem;
mwLayout->restore();
- if (isXcb()) {
+ QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
+ if (!dwLayout->nativeWindowDeco()) {
// get rid of the X11BypassWindowManager window flag and activate the resizer
Qt::WindowFlags flags = q->windowFlags();
flags &= ~Qt::X11BypassWindowManagerHint;
q->setWindowFlags(flags);
- setResizerActive(true);
+ setResizerActive(q->isFloating());
q->show();
} else {
- QDockWidgetLayout *myLayout
- = qobject_cast<QDockWidgetLayout*>(layout);
- setResizerActive(myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0);
+ setResizerActive(false);
}
undockedGeometry = q->geometry();
q->activateWindow();
} else {
+ // The tab was not plugged back in the QMainWindow but the QDockWidget cannot
+ // stay floating, revert to the previous state.
mwLayout->revert(state->widgetItem);
}
}
@@ -782,11 +833,7 @@ bool QDockWidgetPrivate::isAnimating() const
{
Q_Q(const QDockWidget);
- QMainWindow *mainWin = qobject_cast<QMainWindow*>(parent);
- if (mainWin == 0)
- return false;
-
- QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
+ QMainWindowLayout *mainWinLayout = qt_mainwindow_layout_from_dock(q);
if (mainWinLayout == 0)
return false;
@@ -804,12 +851,14 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
if (!dwLayout->nativeWindowDeco()) {
QRect titleArea = dwLayout->titleArea();
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
+
if (event->button() != Qt::LeftButton ||
!titleArea.contains(event->pos()) ||
// check if the tool window is movable... do nothing if it
// is not (but allow moving if the window is floating)
(!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
- qobject_cast<QMainWindow*>(parent) == 0 ||
+ (qobject_cast<QMainWindow*>(parent) == 0 && !floatingTab) ||
isAnimating() || state != 0) {
return false;
}
@@ -853,7 +902,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
QDockWidgetLayout *dwlayout
= qobject_cast<QDockWidgetLayout *>(layout);
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (!dwlayout->nativeWindowDeco()) {
if (!state->dragging
&& mwlayout->pluggingWidget == 0
@@ -871,7 +920,12 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
if (state->dragging && !state->nca) {
QPoint pos = event->globalPos() - state->pressPos;
- q->move(pos);
+
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent);
+ if (floatingTab && !q->isFloating())
+ floatingTab->move(pos);
+ else
+ q->move(pos);
if (state && !state->ctrlDrag)
mwlayout->hover(state->widgetItem, event->globalPos());
@@ -902,8 +956,9 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
- QRect geo = q->geometry();
- QRect titleRect = q->frameGeometry();
+ QWidget *tl = q->topLevelWidget();
+ QRect geo = tl->geometry();
+ QRect titleRect = tl->frameGeometry();
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
if ((features & QDockWidget::DockWidgetVerticalTitleBar)) {
titleRect.setTop(geo.top());
@@ -924,7 +979,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
break;
if (state != 0)
break;
- if (qobject_cast<QMainWindow*>(parent) == 0)
+ if (qobject_cast<QMainWindow*>(parent) == 0 && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
break;
if (isAnimating())
break;
@@ -958,11 +1013,17 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
}
}
+/*! \internal
+ Called when the QDockWidget or the QDockWidgetGroupWindow is moved
+ */
void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
{
Q_Q(QDockWidget);
- if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
+ if (state == 0 || !state->dragging || !state->nca)
+ return;
+
+ if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
return;
// When the native window frame is being dragged, all we get is these mouse
@@ -971,7 +1032,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
if (state->ctrlDrag)
return;
- QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
Q_ASSERT(layout != 0);
QPoint globalMousePos = event->pos() + state->pressPos;
@@ -999,8 +1060,9 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
Q_Q(QDockWidget);
if (!floating && parent) {
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
- if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
+ if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea
+ && !qobject_cast<QDockWidgetGroupWindow *>(parent))
return; // this dockwidget can't be redocked
}
@@ -1031,14 +1093,8 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
q->setWindowFlags(flags);
- if (!rect.isNull()) {
- if (floating) {
- q->resize(rect.size());
- q->move(rect.topLeft());
- } else {
+ if (!rect.isNull())
q->setGeometry(rect);
- }
- }
updateButtons();
@@ -1048,7 +1104,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
if (floating != wasFloating) {
emit q->topLevelChanged(floating);
if (!floating && parent) {
- QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
+ QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (mwlayout)
emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
}
@@ -1230,8 +1286,11 @@ void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features)
emit featuresChanged(d->features);
update();
if (closableChanged && layout->nativeWindowDeco()) {
- //this ensures the native decoration is drawn
- d->setWindowState(true /*floating*/, true /*unplug*/);
+ QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow *>(parent());
+ if (floatingTab && !isFloating())
+ floatingTab->adjustFlags();
+ else
+ d->setWindowState(true /*floating*/, true /*unplug*/); //this ensures the native decoration is drawn
}
}
@@ -1323,11 +1382,12 @@ void QDockWidget::changeEvent(QEvent *event)
#endif
#ifndef QT_NO_TABBAR
{
- QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
- if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
+ if (QMainWindowLayout *winLayout = qt_mainwindow_layout_from_dock(this)) {
if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
info->updateTabBar();
}
+ if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
+ p->adjustFlags();
}
#endif // QT_NO_TABBAR
break;
@@ -1368,7 +1428,7 @@ void QDockWidget::paintEvent(QPaintEvent *event)
// Title must be painted after the frame, since the areas overlap, and
// the title may wish to extend out to all sides (eg. XP style)
- QStyleOptionDockWidgetV2 titleOpt;
+ QStyleOptionDockWidget titleOpt;
initStyleOption(&titleOpt);
p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
}
@@ -1380,7 +1440,7 @@ bool QDockWidget::event(QEvent *event)
Q_D(QDockWidget);
QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
- QMainWindowLayout *layout = qt_mainwindow_layout(win);
+ QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(this);
switch (event->type()) {
#ifndef QT_NO_ACTION
@@ -1417,6 +1477,9 @@ bool QDockWidget::event(QEvent *event)
}
if (!isFloating() && layout != 0 && onTop)
layout->raise(this);
+ if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
+ p->adjustFlags();
+
break;
}
case QEvent::WindowActivate:
diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h
index af4a5521bf..25e4d4d0a4 100644
--- a/src/widgets/widgets/qdockwidget.h
+++ b/src/widgets/widgets/qdockwidget.h
@@ -58,8 +58,9 @@ class Q_WIDGETS_EXPORT QDockWidget : public QWidget
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE true)
public:
- explicit QDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
- explicit QDockWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QDockWidget(const QString &title, QWidget *parent = Q_NULLPTR,
+ Qt::WindowFlags flags = Qt::WindowFlags());
+ explicit QDockWidget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
~QDockWidget();
QWidget *widget() const;
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 752d6519e5..9c68bc5fb1 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -108,7 +108,7 @@ public:
void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
void nonClientAreaMouseEvent(QMouseEvent *event);
void initDrag(const QPoint &pos, bool nca);
- void startDrag();
+ void startDrag(bool group = true);
void endDrag(bool abort = false);
void moveEvent(QMoveEvent *event);
@@ -151,6 +151,7 @@ public:
int minimumTitleWidth() const;
int titleHeight() const;
void updateMaxSize();
+ static bool wmSupportsNativeWindowDeco();
bool nativeWindowDeco() const;
bool nativeWindowDeco(bool floating) const;
diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp
index 708e90cc32..b256861d08 100644
--- a/src/widgets/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
@@ -197,7 +197,7 @@ bool QAlphaWidget::eventFilter(QObject *o, QEvent *e)
break;
case QEvent::KeyPress: {
QKeyEvent *ke = (QKeyEvent*)e;
- if (ke->key() == Qt::Key_Escape) {
+ if (ke->matches(QKeySequence::Cancel)) {
showWidget = false;
} else {
duration = 0;
diff --git a/src/widgets/widgets/qfocusframe.cpp b/src/widgets/widgets/qfocusframe.cpp
index 5a403fa669..bf8cb30ef7 100644
--- a/src/widgets/widgets/qfocusframe.cpp
+++ b/src/widgets/widgets/qfocusframe.cpp
@@ -250,6 +250,10 @@ void
QFocusFrame::paintEvent(QPaintEvent *)
{
Q_D(QFocusFrame);
+
+ if (!d->widget)
+ return;
+
QStylePainter p(this);
QStyleOption option;
initStyleOption(&option);
diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h
index f976ba9827..bbd639c2f9 100644
--- a/src/widgets/widgets/qfocusframe.h
+++ b/src/widgets/widgets/qfocusframe.h
@@ -46,7 +46,7 @@ class Q_WIDGETS_EXPORT QFocusFrame : public QWidget
{
Q_OBJECT
public:
- QFocusFrame(QWidget *parent=0);
+ QFocusFrame(QWidget *parent = Q_NULLPTR);
~QFocusFrame();
void setWidget(QWidget *widget);
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index faa2f41a51..957d148c74 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -401,14 +401,6 @@ void QFontComboBoxPrivate::_q_currentChanged(const QString &text)
*/
/*!
- \fn void QFontComboBox::setWritingSystem(QFontDatabase::WritingSystem script)
-*/
-
-/*!
- \fn void QFontComboBox::setCurrentFont(const QFont &font);
-*/
-
-/*!
Constructs a font combobox with the given \a parent.
*/
QFontComboBox::QFontComboBox(QWidget *parent)
diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h
index 0c8cf5d58d..412acd041e 100644
--- a/src/widgets/widgets/qfontcombobox.h
+++ b/src/widgets/widgets/qfontcombobox.h
@@ -53,7 +53,7 @@ class Q_WIDGETS_EXPORT QFontComboBox : public QComboBox
Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
public:
- explicit QFontComboBox(QWidget *parent = 0);
+ explicit QFontComboBox(QWidget *parent = Q_NULLPTR);
~QFontComboBox();
void setWritingSystem(QFontDatabase::WritingSystem);
diff --git a/src/widgets/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp
index 0861ea70b5..755b03a4ca 100644
--- a/src/widgets/widgets/qframe.cpp
+++ b/src/widgets/widgets/qframe.cpp
@@ -45,7 +45,7 @@
QT_BEGIN_NAMESPACE
QFramePrivate::QFramePrivate()
- : frect(QRect(0, 0, 0, 0)),
+ : frect(0, 0, 0, 0),
frameStyle(QFrame::NoFrame | QFrame::Plain),
lineWidth(1),
midLineWidth(0),
@@ -55,6 +55,10 @@ QFramePrivate::QFramePrivate()
{
}
+QFramePrivate::~QFramePrivate()
+{
+}
+
inline void QFramePrivate::init()
{
setLayoutItemMargins(QStyle::SE_FrameLayoutItem);
diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h
index c32e38f311..eb4d74c72a 100644
--- a/src/widgets/widgets/qframe.h
+++ b/src/widgets/widgets/qframe.h
@@ -54,7 +54,7 @@ class Q_WIDGETS_EXPORT QFrame : public QWidget
Q_PROPERTY(QRect frameRect READ frameRect WRITE setFrameRect DESIGNABLE false)
public:
- explicit QFrame(QWidget* parent = 0, Qt::WindowFlags f = 0);
+ explicit QFrame(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
~QFrame();
int frameStyle() const;
@@ -108,7 +108,7 @@ protected:
protected:
- QFrame(QFramePrivate &dd, QWidget* parent = 0, Qt::WindowFlags f = 0);
+ QFrame(QFramePrivate &dd, QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
void initStyleOption(QStyleOptionFrame *option) const;
private:
diff --git a/src/widgets/widgets/qframe_p.h b/src/widgets/widgets/qframe_p.h
index 2b80e9abbe..eb04bbed4a 100644
--- a/src/widgets/widgets/qframe_p.h
+++ b/src/widgets/widgets/qframe_p.h
@@ -50,11 +50,13 @@
QT_BEGIN_NAMESPACE
-class QFramePrivate : public QWidgetPrivate
+// ### unexport this class when and if QAbstractScrollAreaPrivate is unexported
+class Q_WIDGETS_EXPORT QFramePrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QFrame)
public:
QFramePrivate();
+ ~QFramePrivate();
void updateFrameWidth();
void updateStyledFrameWidths();
diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h
index 8100fadff4..57ebdce8dd 100644
--- a/src/widgets/widgets/qgroupbox.h
+++ b/src/widgets/widgets/qgroupbox.h
@@ -53,8 +53,8 @@ class Q_WIDGETS_EXPORT QGroupBox : public QWidget
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
public:
- explicit QGroupBox(QWidget* parent=0);
- explicit QGroupBox(const QString &title, QWidget* parent=0);
+ explicit QGroupBox(QWidget *parent = Q_NULLPTR);
+ explicit QGroupBox(const QString &title, QWidget *parent = Q_NULLPTR);
~QGroupBox();
QString title() const;
diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h
index 1887a40bfc..ad60bcc513 100644
--- a/src/widgets/widgets/qkeysequenceedit.h
+++ b/src/widgets/widgets/qkeysequenceedit.h
@@ -48,8 +48,8 @@ class Q_WIDGETS_EXPORT QKeySequenceEdit : public QWidget
Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence NOTIFY keySequenceChanged USER true)
public:
- explicit QKeySequenceEdit(QWidget *parent = 0);
- explicit QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent = 0);
+ explicit QKeySequenceEdit(QWidget *parent = Q_NULLPTR);
+ explicit QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent = Q_NULLPTR);
~QKeySequenceEdit();
QKeySequence keySequence() const;
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 83e94c4128..55e277026c 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -53,6 +53,54 @@
QT_BEGIN_NAMESPACE
+QLabelPrivate::QLabelPrivate()
+ : QFramePrivate(),
+ sh(),
+ msh(),
+ text(),
+ pixmap(Q_NULLPTR),
+ scaledpixmap(Q_NULLPTR),
+ cachedimage(Q_NULLPTR),
+#ifndef QT_NO_PICTURE
+ picture(Q_NULLPTR),
+#endif
+#ifndef QT_NO_MOVIE
+ movie(),
+#endif
+ control(Q_NULLPTR),
+ shortcutCursor(),
+#ifndef QT_NO_CURSOR
+ cursor(),
+#endif
+#ifndef QT_NO_SHORTCUT
+ buddy(),
+ shortcutId(0),
+#endif
+ textformat(Qt::AutoText),
+ textInteractionFlags(Qt::LinksAccessibleByMouse),
+ sizePolicy(),
+ margin(0),
+ align(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs),
+ indent(-1),
+ valid_hints(false),
+ scaledcontents(false),
+ textLayoutDirty(false),
+ textDirty(false),
+ isRichText(false),
+ isTextLabel(false),
+ hasShortcut(/*???*/),
+#ifndef QT_NO_CURSOR
+ validCursor(false),
+ onAnchor(false),
+#endif
+ openExternalLinks(false)
+{
+}
+
+QLabelPrivate::~QLabelPrivate()
+{
+}
+
/*!
\class QLabel
\brief The QLabel widget provides a text or image display.
@@ -202,41 +250,8 @@ void QLabelPrivate::init()
{
Q_Q(QLabel);
- valid_hints = false;
- margin = 0;
-#ifndef QT_NO_MOVIE
- movie = 0;
-#endif
-#ifndef QT_NO_SHORTCUT
- shortcutId = 0;
-#endif
- pixmap = 0;
- scaledpixmap = 0;
- cachedimage = 0;
-#ifndef QT_NO_PICTURE
- picture = 0;
-#endif
- align = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs;
- indent = -1;
- scaledcontents = false;
- textLayoutDirty = false;
- textDirty = false;
- textformat = Qt::AutoText;
- control = 0;
- textInteractionFlags = Qt::LinksAccessibleByMouse;
- isRichText = false;
- isTextLabel = false;
-
q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred,
QSizePolicy::Label));
-
-#ifndef QT_NO_CURSOR
- validCursor = false;
- onAnchor = false;
-#endif
-
- openExternalLinks = false;
-
setLayoutItemMargins(QStyle::SE_LabelLayoutItem);
}
@@ -1081,7 +1096,7 @@ void QLabel::paintEvent(QPaintEvent *)
d->cachedimage = new QImage(d->pixmap->toImage());
delete d->scaledpixmap;
QImage scaledImage =
- d->cachedimage->scaled(cr.size() * devicePixelRatio(),
+ d->cachedimage->scaled(cr.size() * devicePixelRatioF(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage));
}
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 330626a9c5..1a3a68db60 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -58,8 +58,8 @@ class Q_WIDGETS_EXPORT QLabel : public QFrame
Q_PROPERTY(QString selectedText READ selectedText)
public:
- explicit QLabel(QWidget *parent=0, Qt::WindowFlags f=0);
- explicit QLabel(const QString &text, QWidget *parent=0, Qt::WindowFlags f=0);
+ explicit QLabel(QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags());
+ explicit QLabel(const QString &text, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags());
~QLabel();
QString text() const;
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index 3778cb9d47..b4da56c290 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -60,54 +60,25 @@
QT_BEGIN_NAMESPACE
-class QLabelPrivate : public QFramePrivate
+class Q_AUTOTEST_EXPORT QLabelPrivate : public QFramePrivate
{
Q_DECLARE_PUBLIC(QLabel)
public:
- QLabelPrivate() {}
+ QLabelPrivate();
+ ~QLabelPrivate();
void init();
void clearContents();
void updateLabel();
QSize sizeForWidth(int w) const;
- mutable QSize sh;
- mutable QSize msh;
- mutable bool valid_hints;
- mutable QSizePolicy sizePolicy;
- int margin;
- QString text;
- QPixmap *pixmap;
- QPixmap *scaledpixmap;
- QImage *cachedimage;
-#ifndef QT_NO_PICTURE
- QPicture *picture;
-#endif
#ifndef QT_NO_MOVIE
- QPointer<QMovie> movie;
void _q_movieUpdated(const QRect&);
void _q_movieResized(const QSize&);
#endif
#ifndef QT_NO_SHORTCUT
void updateShortcut();
#endif
-#ifndef QT_NO_SHORTCUT
- QPointer<QWidget> buddy;
- int shortcutId;
-#endif
- ushort align;
- short indent;
- uint scaledcontents :1;
- mutable uint textLayoutDirty : 1;
- mutable uint textDirty : 1;
- mutable uint isRichText : 1;
- mutable uint isTextLabel : 1;
- mutable uint hasShortcut : 1;
- Qt::TextFormat textformat;
- mutable QWidgetTextControl *control;
- mutable QTextCursor shortcutCursor;
- Qt::TextInteractionFlags textInteractionFlags;
-
inline bool needTextControl() const {
return isTextLabel
&& (isRichText
@@ -129,13 +100,46 @@ public:
QMenu *createStandardContextMenu(const QPoint &pos);
#endif
- bool openExternalLinks;
-
+ mutable QSize sh;
+ mutable QSize msh;
+ QString text;
+ QPixmap *pixmap;
+ QPixmap *scaledpixmap;
+ QImage *cachedimage;
+#ifndef QT_NO_PICTURE
+ QPicture *picture;
+#endif
+#ifndef QT_NO_MOVIE
+ QPointer<QMovie> movie;
+#endif
+ mutable QWidgetTextControl *control;
+ mutable QTextCursor shortcutCursor;
+#ifndef QT_NO_CURSOR
+ QCursor cursor;
+#endif
+#ifndef QT_NO_SHORTCUT
+ QPointer<QWidget> buddy;
+ int shortcutId;
+#endif
+ Qt::TextFormat textformat;
+ Qt::TextInteractionFlags textInteractionFlags;
+ mutable QSizePolicy sizePolicy;
+ int margin;
+ ushort align;
+ short indent;
+ mutable uint valid_hints : 1;
+ uint scaledcontents : 1;
+ mutable uint textLayoutDirty : 1;
+ mutable uint textDirty : 1;
+ mutable uint isRichText : 1;
+ mutable uint isTextLabel : 1;
+ mutable uint hasShortcut : 1;
#ifndef QT_NO_CURSOR
uint validCursor : 1;
uint onAnchor : 1;
- QCursor cursor;
#endif
+ uint openExternalLinks : 1;
+ // <-- space for more bit field values here
friend class QMessageBoxPrivate;
};
diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h
index d93edc75ca..9a7904a8bb 100644
--- a/src/widgets/widgets/qlcdnumber.h
+++ b/src/widgets/widgets/qlcdnumber.h
@@ -53,8 +53,8 @@ class Q_WIDGETS_EXPORT QLCDNumber : public QFrame // LCD number widget
Q_PROPERTY(int intValue READ intValue WRITE display)
public:
- explicit QLCDNumber(QWidget* parent = 0);
- explicit QLCDNumber(uint numDigits, QWidget* parent = 0);
+ explicit QLCDNumber(QWidget* parent = Q_NULLPTR);
+ explicit QLCDNumber(uint numDigits, QWidget* parent = Q_NULLPTR);
~QLCDNumber();
enum Mode {
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 0500907b3d..6b32665065 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1488,7 +1488,7 @@ void QLineEdit::mousePressEvent(QMouseEvent* e)
int cursor = d->xToPos(e->pos().x());
#ifndef QT_NO_DRAGANDDROP
if (!mark && d->dragEnabled && d->control->echoMode() == Normal &&
- e->button() == Qt::LeftButton && d->control->inSelection(e->pos().x())) {
+ e->button() == Qt::LeftButton && d->inSelection(e->pos().x())) {
if (!d->dndTimer.isActive())
d->dndTimer.start(QApplication::startDragTime(), this);
} else
@@ -1897,18 +1897,14 @@ void QLineEdit::paintEvent(QPaintEvent *)
}
QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height());
- int minLB = qMax(0, -fm.minLeftBearing());
- int minRB = qMax(0, -fm.minRightBearing());
-
if (d->shouldShowPlaceholderText()) {
if (!d->placeholderText.isEmpty()) {
QColor col = pal.text().color();
col.setAlpha(128);
QPen oldpen = p.pen();
p.setPen(col);
- QRect ph = lineRect.adjusted(minLB, 0, 0, 0);
- QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, ph.width());
- p.drawText(ph, va, elidedText);
+ QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width());
+ p.drawText(lineRect, va, elidedText);
p.setPen(oldpen);
}
}
@@ -1918,11 +1914,10 @@ void QLineEdit::paintEvent(QPaintEvent *)
// horizontal scrolling. d->hscroll is the left indent from the beginning
// of the text line to the left edge of lineRect. we update this value
// depending on the delta from the last paint event; in effect this means
- // the below code handles all scrolling based on the textline (widthUsed,
- // minLB, minRB), the line edit rect (lineRect) and the cursor position
- // (cix).
- int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB;
- if ((minLB + widthUsed) <= lineRect.width()) {
+ // the below code handles all scrolling based on the textline (widthUsed),
+ // the line edit rect (lineRect) and the cursor position (cix).
+ int widthUsed = qRound(d->control->naturalTextWidth()) + 1;
+ if (widthUsed <= lineRect.width()) {
// text fits in lineRect; use hscroll for alignment
switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
case Qt::AlignRight:
@@ -1936,7 +1931,6 @@ void QLineEdit::paintEvent(QPaintEvent *)
d->hscroll = 0;
break;
}
- d->hscroll -= minLB;
} else if (cix - d->hscroll >= lineRect.width()) {
// text doesn't fit, cursor is to the right of lineRect (scroll right)
d->hscroll = cix - lineRect.width() + 1;
diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h
index e006f1c0d8..ac192f0da8 100644
--- a/src/widgets/widgets/qlineedit.h
+++ b/src/widgets/widgets/qlineedit.h
@@ -84,8 +84,8 @@ public:
};
Q_ENUM(ActionPosition)
- explicit QLineEdit(QWidget* parent=0);
- explicit QLineEdit(const QString &, QWidget* parent=0);
+ explicit QLineEdit(QWidget *parent = Q_NULLPTR);
+ explicit QLineEdit(const QString &, QWidget *parent = Q_NULLPTR);
~QLineEdit();
QString text() const;
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index e24cc8a03a..599ebce0ab 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -70,6 +70,12 @@ int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const
return control->xToPos(x, betweenOrOn);
}
+bool QLineEditPrivate::inSelection(int x) const
+{
+ x -= adjustedContentsRect().x() - hscroll + horizontalMargin;
+ return control->inSelection(x);
+}
+
QRect QLineEditPrivate::cursorRect() const
{
return adjustedControlRect(control->cursorRect());
@@ -364,7 +370,7 @@ void QLineEditIconButton::startOpacityAnimation(qreal endValue)
void QLineEditIconButton::updateCursor()
{
#ifndef QT_NO_CURSOR
- setCursor(qFuzzyCompare(m_opacity, 1.0) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor());
+ setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor());
#endif
}
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index 5a22285149..60372ab393 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -114,7 +114,7 @@ public:
QAction *action;
int flags;
};
- typedef QList<SideWidgetEntry> SideWidgetEntryList;
+ typedef QVector<SideWidgetEntry> SideWidgetEntryList;
QLineEditPrivate()
: control(0), frame(1), contextMenuEnabled(1), cursorVisible(0),
@@ -139,6 +139,7 @@ public:
QRect adjustedControlRect(const QRect &) const;
int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
+ bool inSelection(int x) const;
QRect cursorRect() const;
void setCursorVisible(bool visible);
@@ -228,6 +229,7 @@ private:
int lastTextSize;
mutable QSize m_iconSize;
};
+Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetEntry, Q_PRIMITIVE_TYPE);
static bool isSideWidgetVisible(const QLineEditPrivate::SideWidgetEntry &e)
{
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
index 5920c1f8bf..a27d8f8690 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
@@ -45,7 +45,7 @@ class Q_WIDGETS_EXPORT QMacCocoaViewContainer : public QWidget
{
Q_OBJECT
public:
- QMacCocoaViewContainer(NSView *cocoaViewToWrap, QWidget *parent = 0);
+ QMacCocoaViewContainer(NSView *cocoaViewToWrap, QWidget *parent = Q_NULLPTR);
virtual ~QMacCocoaViewContainer();
void setCocoaView(NSView *view);
diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h
index 761e55656b..5e82872faa 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.h
+++ b/src/widgets/widgets/qmacnativewidget_mac.h
@@ -45,7 +45,7 @@ class Q_WIDGETS_EXPORT QMacNativeWidget : public QWidget
{
Q_OBJECT
public:
- QMacNativeWidget(NSView *parentView = 0);
+ QMacNativeWidget(NSView *parentView = Q_NULLPTR);
~QMacNativeWidget();
QSize sizeHint() const;
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 4d5d3e5ec1..ff4bb3cc98 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -263,7 +263,14 @@ void QMainWindowPrivate::init()
An example of how to create menus follows:
- \snippet mainwindows/application/mainwindow.cpp 26
+ \code
+ void MainWindow::createMenus()
+ {
+ fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(newAct);
+ fileMenu->addAction(openAct);
+ fileMenu->addAction(saveAct);
+ \endcode
The \c createPopupMenu() function creates popup menus when the
main window receives context menu events. The default
@@ -290,7 +297,12 @@ void QMainWindowPrivate::init()
An example of toolbar creation follows:
- \snippet mainwindows/application/mainwindow.cpp 29
+ \code
+ void MainWindow::createToolBars()
+ {
+ fileToolBar = addToolBar(tr("File"));
+ fileToolBar->addAction(newAct);
+ \endcode
\section2 Creating Dock Widgets
@@ -420,6 +432,13 @@ QMainWindow::~QMainWindow()
at the bottom. Implies AllowTabbedDocks. See also
\l setTabPosition().
+ \value GroupedDragging When dragging the titlebar of a dock, all the tabs
+ that are tabbed with it are going to be dragged.
+ Implies AllowTabbedDocks. Does not work well if
+ some QDockWidgets have restrictions in which area
+ they are allowed. (This enum value was added in Qt
+ 5.6.)
+
These options only control how dock widgets may be dropped in a QMainWindow.
They do not re-arrange the dock widgets to conform with the specified
options. For this reason they should be set before any dock widgets
@@ -1080,7 +1099,7 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget
addDockWidget(area, dockwidget, orientation);
#ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support
- QMacCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
if (qt_mac_is_macdrawer(dockwidget)) {
extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
@@ -1218,6 +1237,35 @@ void QMainWindow::removeDockWidget(QDockWidget *dockwidget)
Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const
{ return d_func()->layout->dockWidgetArea(dockwidget); }
+
+/*!
+ \since 5.6
+ Resizes the dock widgets in the list \a docks to the corresponding size in
+ pixels from the list \a sizes. If \a orientation is Qt::Horizontal, adjusts
+ the width, otherwise adjusts the height of the dock widgets.
+ The sizes will be adjusted such that the maximum and the minimum sizes are
+ respected and the QMainWindow itself will not be resized.
+ Any additional/missing space is distributed amongst the widgets according
+ to the relative weight of the sizes.
+
+ Example:
+ \code
+ resizeDocks({blueWidget, yellowWidget}, {20 , 40}, Qt::Horizontal);
+ \endcode
+ If the blue and the yellow widget are nested on the same level they will be
+ resized such that the yellowWidget is twice as big as the blueWidget
+
+ If some widgets are grouped in tabs, only one widget per group should be
+ specified. Widgets not in the list might be changed to repect the constraints.
+*/
+void QMainWindow::resizeDocks(const QList<QDockWidget *> &docks,
+ const QList<int> &sizes, Qt::Orientation orientation)
+{
+ d_func()->layout->layoutState.dockAreaLayout.resizeDocks(docks, sizes, orientation);
+ d_func()->layout->invalidate();
+}
+
+
#endif // QT_NO_DOCKWIDGET
/*!
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index cbbea74b9b..70d78a7904 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -77,12 +77,13 @@ public:
AllowNestedDocks = 0x02,
AllowTabbedDocks = 0x04,
ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks
- VerticalTabs = 0x10 // implies AllowTabbedDocks
+ VerticalTabs = 0x10, // implies AllowTabbedDocks
+ GroupedDragging = 0x20 // implies AllowTabbedDocks
};
Q_ENUM(DockOption)
Q_DECLARE_FLAGS(DockOptions, DockOption)
- explicit QMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QMainWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
~QMainWindow();
QSize iconSize() const;
@@ -164,6 +165,9 @@ public:
bool restoreDockWidget(QDockWidget *dockwidget);
Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
+
+ void resizeDocks(const QList<QDockWidget *> &docks,
+ const QList<int> &sizes, Qt::Orientation orientation);
#endif // QT_NO_DOCKWIDGET
QByteArray saveState(int version = 0) const;
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 046666f571..54e956c4cf 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -49,6 +50,7 @@
#include <qstatusbar.h>
#include <qstring.h>
#include <qstyle.h>
+#include <qstylepainter.h>
#include <qvarlengtharray.h>
#include <qstack.h>
#include <qmap.h>
@@ -61,6 +63,7 @@
#include <private/qapplication_p.h>
#include <private/qlayoutengine_p.h>
+#include <private/qwidgetresizehandler_p.h>
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
# include <private/qcore_mac_p.h>
# include <private/qt_cocoa_helpers_mac_p.h>
@@ -68,9 +71,7 @@
QT_BEGIN_NAMESPACE
-#ifdef QT_NO_DOCKWIDGET
extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
-#endif
/******************************************************************************
** debug
@@ -165,6 +166,228 @@ QDebug operator<<(QDebug debug, const QMainWindowLayout *layout)
#endif // !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_DEBUG)
/******************************************************************************
+ ** QDockWidgetGroupWindow
+ */
+// QDockWidgetGroupWindow is the floating window containing the tabbed dockwidgets in case several
+// dockwidgets are dragged together (QMainWindow::GroupedDragging feature).
+// QDockWidgetGroupLayout is the layout of that window and use a QDockAreaLayoutInfo to layout
+// the tabs inside it.
+#ifndef QT_NO_DOCKWIDGET
+class QDockWidgetGroupLayout : public QLayout {
+ QDockAreaLayoutInfo info;
+ QWidgetResizeHandler *resizer;
+public:
+ QDockWidgetGroupLayout(QWidget* parent) : QLayout(parent) {
+ setSizeConstraint(QLayout::SetMinAndMaxSize);
+ resizer = new QWidgetResizeHandler(parent);
+ resizer->setMovingEnabled(false);
+ }
+ ~QDockWidgetGroupLayout() {
+ info.deleteAllLayoutItems();
+ }
+
+ void addItem(QLayoutItem*) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
+ int count() const Q_DECL_OVERRIDE { return 0; }
+ QLayoutItem* itemAt(int index) const Q_DECL_OVERRIDE
+ {
+ int x = 0;
+ return info.itemAt(&x, index);
+ }
+ QLayoutItem* takeAt(int index) Q_DECL_OVERRIDE
+ {
+ int x = 0;
+ return info.takeAt(&x, index);
+ }
+ QSize sizeHint() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.sizeHint() + QSize(fw, fw);
+ }
+ QSize minimumSize() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.minimumSize() + QSize(fw, fw);
+ }
+ QSize maximumSize() const Q_DECL_OVERRIDE
+ {
+ int fw = frameWidth();
+ return info.maximumSize() + QSize(fw, fw);
+ }
+ void setGeometry(const QRect&r) Q_DECL_OVERRIDE
+ {
+ QDockAreaLayoutInfo *li = layoutInfo();
+ if (li->isEmpty()) {
+ static_cast<QDockWidgetGroupWindow *>(parent())->destroyIfEmpty();
+ return;
+ }
+ int fw = frameWidth();
+ li->reparentWidgets(parentWidget());
+ li->rect = r.adjusted(fw, fw, -fw, -fw);
+ li->fitItems();
+ li->apply(false);
+ resizer->setActive(QWidgetResizeHandler::Resize, !nativeWindowDeco());
+ }
+
+ QDockAreaLayoutInfo *layoutInfo() {
+ return &info;
+ }
+
+ bool nativeWindowDeco() const
+ {
+ return QDockWidgetLayout::wmSupportsNativeWindowDeco();
+ }
+
+ int frameWidth() const
+ {
+ return nativeWindowDeco() ? 0 :
+ parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget());
+ }
+};
+
+bool QDockWidgetGroupWindow::event(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::Close:
+ // Forward the close to the QDockWidget just as if its close button was pressed
+ if (QDockWidget *dw = topDockWidget()) {
+ e->ignore();
+ dw->close();
+ adjustFlags();
+ }
+ return true;
+ case QEvent::Move:
+ // Let QDockWidgetPrivate::moseEvent handle the dragging
+ if (QDockWidget *dw = topDockWidget())
+ static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e));
+ return true;
+ case QEvent::NonClientAreaMouseMove:
+ case QEvent::NonClientAreaMouseButtonPress:
+ case QEvent::NonClientAreaMouseButtonRelease:
+ case QEvent::NonClientAreaMouseButtonDblClick:
+ // Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop
+ if (QDockWidget *dw = topDockWidget())
+ static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e));
+ return true;
+ case QEvent::ChildAdded:
+ if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child()))
+ adjustFlags();
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(e);
+}
+
+void QDockWidgetGroupWindow::paintEvent(QPaintEvent *)
+{
+ QDockWidgetGroupLayout *lay = static_cast<QDockWidgetGroupLayout *>(layout());
+ bool nativeDeco = lay->nativeWindowDeco();
+
+ if (!nativeDeco) {
+ QStyleOptionFrame framOpt;
+ framOpt.init(this);
+ QStylePainter p(this);
+ p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
+ }
+}
+
+QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const
+{
+ return static_cast<QDockWidgetGroupLayout*>(layout())->layoutInfo();
+}
+
+/*! \internal
+ Returns the currently active QDockWidget.
+ */
+QDockWidget *QDockWidgetGroupWindow::topDockWidget() const
+{
+ QDockAreaLayoutInfo *info = layoutInfo();
+ QDockWidget *dw = 0;
+ if (info->tabBar && info->tabBar->currentIndex() >= 0) {
+ int i = info->tabIndexToListIndex(info->tabBar->currentIndex());
+ if (i >= 0) {
+ const QDockAreaLayoutItem &item = info->item_list.at(i);
+ if (item.widgetItem)
+ dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
+ }
+ }
+ if (!dw) {
+ for (int i = 0; !dw && i < info->item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = info->item_list.at(i);
+ if (item.skip())
+ continue;
+ if (!item.widgetItem)
+ continue;
+ dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
+ }
+ }
+ return dw;
+}
+
+/*! \internal
+ Destroy this window if there is no more QDockWidget in it.
+ */
+void QDockWidgetGroupWindow::destroyIfEmpty()
+{
+ if (layoutInfo()->isEmpty()) {
+ // Make sure to reparent the possibly floating or hidden QDockWidgets to the parent
+ foreach (QDockWidget *dw,
+ findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly)) {
+ bool wasFloating = dw->isFloating();
+ bool wasHidden = dw->isHidden();
+ dw->setParent(parentWidget());
+ if (wasFloating) {
+ dw->setFloating(true);
+ } else {
+ // maybe it was hidden, we still have to put it back in the main layout.
+ QMainWindowLayout *ml = qt_mainwindow_layout(static_cast<QMainWindow*>(parentWidget()));
+ Qt::DockWidgetArea area = ml->dockWidgetArea(this);
+ if (area == Qt::NoDockWidgetArea)
+ area = Qt::LeftDockWidgetArea;
+ static_cast<QMainWindow*>(parentWidget())->addDockWidget(area, dw);
+ }
+ if (!wasHidden)
+ dw->show();
+ }
+ foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly))
+ tb->setParent(parentWidget());
+ deleteLater();
+ }
+}
+
+/*! \internal
+ Sets the flags of this window in accordence to the capabilities of the dock widgets
+ */
+void QDockWidgetGroupWindow::adjustFlags()
+{
+ QDockWidget *top = topDockWidget();
+ if (!top)
+ return;
+ const bool nativeDeco = static_cast<QDockWidgetGroupLayout *>(layout())->nativeWindowDeco();
+
+ Qt::WindowFlags oldFlags = windowFlags();
+ Qt::WindowFlags flags = oldFlags;
+ if (nativeDeco) {
+ flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
+ if (top->features() & QDockWidget::DockWidgetClosable)
+ flags |= Qt::WindowCloseButtonHint;
+ else
+ flags &= ~Qt::WindowCloseButtonHint;
+ flags &= ~Qt::FramelessWindowHint;
+ } else {
+ flags |= Qt::FramelessWindowHint;
+ }
+ if (oldFlags != flags) {
+ setWindowFlags(flags);
+ show(); // setWindowFlags hides the window
+ }
+
+ setWindowTitle(top->windowTitle());
+ setWindowIcon(top->windowIcon());
+}
+#endif
+
+/******************************************************************************
** QMainWindowLayoutState
*/
@@ -335,8 +558,8 @@ QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const
#ifndef QT_NO_DOCKWIDGET
// is it a dock widget?
- if (QDockWidget *dockWidget = qobject_cast<QDockWidget *>(widget)) {
- result = dockAreaLayout.indexOf(dockWidget);
+ if (qobject_cast<QDockWidget *>(widget) || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ result = dockAreaLayout.indexOf(widget);
if (!result.isEmpty())
result.prepend(1);
return result;
@@ -413,7 +636,8 @@ QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
#ifndef QT_NO_DOCKWIDGET
// is it a dock widget?
- if (qobject_cast<QDockWidget *>(widget) != 0) {
+ if (qobject_cast<QDockWidget *>(widget) != 0
+ || qobject_cast<QDockWidgetGroupWindow *>(widget)) {
result = dockAreaLayout.gapIndex(pos);
if (!result.isEmpty())
result.prepend(1);
@@ -440,7 +664,7 @@ bool QMainWindowLayoutState::insertGap(const QList<int> &path, QLayoutItem *item
#ifndef QT_NO_DOCKWIDGET
if (i == 1) {
- Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) != 0);
+ Q_ASSERT(qobject_cast<QDockWidget*>(item->widget()) || qobject_cast<QDockWidgetGroupWindow*>(item->widget()));
return dockAreaLayout.insertGap(path.mid(1), item);
}
#endif //QT_NO_DOCKWIDGET
@@ -593,6 +817,17 @@ void QMainWindowLayoutState::saveState(QDataStream &stream) const
{
#ifndef QT_NO_DOCKWIDGET
dockAreaLayout.saveState(stream);
+#ifndef QT_NO_TABBAR
+ QList<QDockWidgetGroupWindow *> floatingTabs =
+ mainWindow->findChildren<QDockWidgetGroupWindow *>(QString(), Qt::FindDirectChildrenOnly);
+
+ foreach (QDockWidgetGroupWindow *floating, floatingTabs) {
+ if (floating->layoutInfo()->isEmpty())
+ continue;
+ stream << uchar(QDockAreaLayout::FloatingDockWidgetTabMarker) << floating->geometry();
+ floating->layoutInfo()->saveState(stream);
+ }
+#endif
#endif
#ifndef QT_NO_TOOLBAR
toolBarAreaLayout.saveState(stream);
@@ -638,12 +873,28 @@ bool QMainWindowLayoutState::checkFormat(QDataStream &stream)
case QDockAreaLayout::DockWidgetStateMarker:
{
QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
if (!dockAreaLayout.restoreState(stream, dockWidgets, true /*testing*/)) {
return false;
}
}
break;
-#endif
+#ifndef QT_NO_TABBAR
+ case QDockAreaLayout::FloatingDockWidgetTabMarker:
+ {
+ QRect geom;
+ stream >> geom;
+ QDockAreaLayoutInfo info;
+ QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
+ if (!info.restoreState(stream, dockWidgets, true /* testing*/))
+ return false;
+ }
+ break;
+#endif // QT_NO_TABBAR
+#endif // QT_NO_DOCKWIDGET
default:
//there was an error during the parsing
return false;
@@ -682,6 +933,8 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
case QDockAreaLayout::DockWidgetStateMarker:
{
QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
if (!dockAreaLayout.restoreState(stream, dockWidgets))
return false;
@@ -702,6 +955,26 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
}
}
break;
+#ifndef QT_NO_TABBAR
+ case QDockAreaLayout::FloatingDockWidgetTabMarker:
+ {
+ QList<QDockWidget *> dockWidgets = findChildrenHelper<QDockWidget*>(mainWindow);
+ foreach (QDockWidgetGroupWindow *floating, findChildrenHelper<QDockWidgetGroupWindow*>(mainWindow))
+ dockWidgets += findChildrenHelper<QDockWidget*>(floating);
+ QDockWidgetGroupWindow* floatingTab = qt_mainwindow_layout(mainWindow)->createTabbedDockWindow();
+ *floatingTab->layoutInfo() = QDockAreaLayoutInfo(&dockAreaLayout.sep, QInternal::LeftDock,
+ Qt::Horizontal, QTabBar::RoundedSouth, mainWindow);
+ QRect geometry;
+ stream >> geometry;
+ if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false))
+ return false;
+ geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab);
+ floatingTab->move(geometry.topLeft());
+ floatingTab->resize(geometry.size());
+ floatingTab->show();
+ }
+ break;
+#endif // QT_NO_TABBAR
#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
@@ -1223,7 +1496,7 @@ void QMainWindowLayout::splitDockWidget(QDockWidget *after,
invalidate();
}
-Qt::DockWidgetArea QMainWindowLayout::dockWidgetArea(QDockWidget *widget) const
+Qt::DockWidgetArea QMainWindowLayout::dockWidgetArea(QWidget *widget) const
{
QList<int> pathToWidget = layoutState.dockAreaLayout.indexOf(widget);
if (pathToWidget.isEmpty())
@@ -1238,20 +1511,88 @@ void QMainWindowLayout::keepSize(QDockWidget *w)
#ifndef QT_NO_TABBAR
+// Handle custom tooltip, and allow to drag tabs away.
class QMainWindowTabBar : public QTabBar
{
+ QMainWindow *mainWindow;
+ QDockWidget *draggingDock; // Currently dragging (detached) dock widget
public:
- QMainWindowTabBar(QWidget *parent);
+ QMainWindowTabBar(QMainWindow *parent);
protected:
bool event(QEvent *e) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+
};
-QMainWindowTabBar::QMainWindowTabBar(QWidget *parent)
- : QTabBar(parent)
+QMainWindowTabBar::QMainWindowTabBar(QMainWindow *parent)
+ : QTabBar(parent), mainWindow(parent), draggingDock(0)
{
setExpanding(false);
}
+void QMainWindowTabBar::mouseMoveEvent(QMouseEvent *e)
+{
+ // The QTabBar handles the moving (reordering) of tabs.
+ // When QTabBarPrivate::dragInProgress is true, and that the mouse is outside of a region
+ // around the QTabBar, we will consider the user wants to drag that QDockWidget away from this
+ // tab area.
+
+ QTabBarPrivate *d = static_cast<QTabBarPrivate*>(d_ptr.data());
+ if (!draggingDock && (mainWindow->dockOptions() & QMainWindow::GroupedDragging)) {
+ int offset = QApplication::startDragDistance() + 1;
+ offset *= 3;
+ QRect r = rect().adjusted(-offset, -offset, offset, offset);
+ if (d->dragInProgress && !r.contains(e->pos()) && d->validIndex(d->pressedIndex)) {
+ QMainWindowLayout* mlayout = qt_mainwindow_layout(mainWindow);
+ QDockAreaLayoutInfo *info = mlayout->dockInfo(this);
+ Q_ASSERT(info);
+ int idx = info->tabIndexToListIndex(d->pressedIndex);
+ const QDockAreaLayoutItem &item = info->item_list.at(idx);
+ if (item.widgetItem
+ && (draggingDock = qobject_cast<QDockWidget *>(item.widgetItem->widget()))) {
+ // We should drag this QDockWidget away by unpluging it.
+ // First cancel the QTabBar's internal move
+ d->moveTabFinished(d->pressedIndex);
+ d->pressedIndex = -1;
+ if (d->movingTab)
+ d->movingTab->setVisible(false);
+ d->dragStartPosition = QPoint();
+
+ // Then starts the drag using QDockWidgetPrivate's API
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ QDockWidgetLayout *dwlayout = static_cast<QDockWidgetLayout *>(draggingDock->layout());
+ dockPriv->initDrag(dwlayout->titleArea().center(), true);
+ dockPriv->startDrag(false);
+ if (dockPriv->state)
+ dockPriv->state->ctrlDrag = e->modifiers() & Qt::ControlModifier;
+ }
+ }
+ }
+
+ if (draggingDock) {
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ if (dockPriv->state && dockPriv->state->dragging) {
+ QPoint pos = e->globalPos() - dockPriv->state->pressPos;
+ draggingDock->move(pos);
+ // move will call QMainWindowLayout::hover
+ }
+ }
+ QTabBar::mouseMoveEvent(e);
+}
+
+void QMainWindowTabBar::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (draggingDock && e->button() == Qt::LeftButton) {
+ QDockWidgetPrivate *dockPriv = static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(draggingDock));
+ if (dockPriv->state && dockPriv->state->dragging) {
+ dockPriv->endDrag();
+ }
+ draggingDock = 0;
+ }
+ QTabBar::mouseReleaseEvent(e);
+}
+
bool QMainWindowTabBar::event(QEvent *e)
{
// show the tooltip if tab is too small to fit label
@@ -1276,11 +1617,13 @@ QTabBar *QMainWindowLayout::getTabBar()
if (!unusedTabBars.isEmpty()) {
result = unusedTabBars.takeLast();
} else {
- result = new QMainWindowTabBar(parentWidget());
+ result = new QMainWindowTabBar(static_cast<QMainWindow *>(parentWidget()));
result->setDrawBase(true);
result->setElideMode(Qt::ElideRight);
result->setDocumentMode(_documentMode);
+ result->setMovable(true);
connect(result, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()));
+ connect(result, &QTabBar::tabMoved, this, &QMainWindowLayout::tabMoved);
}
usedTabBars.insert(result);
@@ -1303,12 +1646,30 @@ QWidget *QMainWindowLayout::getSeparatorWidget()
return result;
}
+/*! \internal
+ Returns a pointer QDockAreaLayoutInfo which contains this \a widget directly
+ (in its internal list)
+ */
+QDockAreaLayoutInfo *QMainWindowLayout::dockInfo(QWidget *widget)
+{
+ QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget);
+ if (info)
+ return info;
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ info = dwgw->layoutInfo()->info(widget);
+ if (info)
+ return info;
+ }
+ return 0;
+}
+
void QMainWindowLayout::tabChanged()
{
QTabBar *tb = qobject_cast<QTabBar*>(sender());
if (tb == 0)
return;
- QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(tb);
+ QDockAreaLayoutInfo *info = dockInfo(tb);
if (info == 0)
return;
info->apply(false);
@@ -1316,6 +1677,16 @@ void QMainWindowLayout::tabChanged()
if (QWidget *w = centralWidget())
w->raise();
}
+
+void QMainWindowLayout::tabMoved(int from, int to)
+{
+ QTabBar *tb = qobject_cast<QTabBar*>(sender());
+ Q_ASSERT(tb);
+ QDockAreaLayoutInfo *info = dockInfo(tb);
+ Q_ASSERT(info);
+
+ info->moveTab(from, to);
+}
#endif // QT_NO_TABBAR
bool QMainWindowLayout::startSeparatorMove(const QPoint &pos)
@@ -1353,7 +1724,7 @@ bool QMainWindowLayout::endSeparatorMove(const QPoint&)
void QMainWindowLayout::raise(QDockWidget *widget)
{
- QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget);
+ QDockAreaLayoutInfo *info = dockInfo(widget);
if (info == 0)
return;
#ifndef QT_NO_TABBAR
@@ -1537,6 +1908,8 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
QWidget *widget = widgetItem->widget();
layoutState = savedState;
currentGapPos = layoutState.indexOf(widget);
+ if (currentGapPos.isEmpty())
+ return;
fixToolBarOrientation(widgetItem, currentGapPos.at(1));
layoutState.unplug(currentGapPos);
layoutState.fitLayout();
@@ -1547,6 +1920,54 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
{
+#ifndef QT_NO_DOCKWIDGET
+ if (currentHoveredFloat) {
+ QWidget *widget = widgetItem->widget();
+ QList<int> previousPath = layoutState.indexOf(widget);
+ if (!previousPath.isEmpty())
+ layoutState.remove(previousPath);
+ // Let's remove the widget from any possible group window
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ QList<int> path = dwgw->layoutInfo()->indexOf(widget);
+ if (!path.isEmpty())
+ dwgw->layoutInfo()->remove(path);
+ }
+ currentGapRect = QRect();
+
+ if (QDockWidget *dropTo = qobject_cast<QDockWidget*>(currentHoveredFloat)) {
+ //dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two tabs
+ QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow();
+ floatingTabs->setGeometry(dropTo->geometry());
+ QDockAreaLayoutInfo *info = floatingTabs->layoutInfo();
+ *info = QDockAreaLayoutInfo(&layoutState.dockAreaLayout.sep, QInternal::LeftDock,
+ Qt::Horizontal, QTabBar::RoundedSouth,
+ static_cast<QMainWindow*>(parentWidget()));
+ info->tabbed = true;
+ QLayout *parentLayout = currentHoveredFloat->parentWidget()->layout();
+ info->item_list.append(parentLayout->takeAt(parentLayout->indexOf(currentHoveredFloat)));
+
+ dropTo->setParent(floatingTabs);
+ dropTo->show();
+ dropTo->d_func()->plug(QRect());
+ currentHoveredFloat = floatingTabs;
+ }
+
+ QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat);
+ Q_ASSERT(dwgw);
+ Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed
+ previousPath = dwgw->layoutInfo()->indexOf(widget);
+ if (!previousPath.isEmpty())
+ dwgw->layoutInfo()->remove(previousPath);
+ dwgw->layoutInfo()->tab(0, widgetItem);
+ QRect globalRect = dwgw->layoutInfo()->tabContentRect();
+ globalRect.moveTopLeft(dwgw->mapToGlobal(globalRect.topLeft()));
+ pluggingWidget = widget;
+ widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);
+ return true;
+ }
+#endif
+
if (!parentWidget()->isVisible() || parentWidget()->isMinimized() || currentGapPos.isEmpty())
return false;
@@ -1554,6 +1975,16 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
QWidget *widget = widgetItem->widget();
+#ifndef QT_NO_DOCKWIDGET
+ // Let's remove the widget from any possible group window
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ QList<int> path = dwgw->layoutInfo()->indexOf(widget);
+ if (!path.isEmpty())
+ dwgw->layoutInfo()->remove(path);
+ }
+#endif
+
QList<int> previousPath = layoutState.indexOf(widget);
const QLayoutItem *it = layoutState.plug(currentGapPos);
@@ -1601,8 +2032,59 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
if (widget == pluggingWidget) {
#ifndef QT_NO_DOCKWIDGET
- if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
+ if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ // When the animated widget was a QDockWidgetGroupWindow, it means each of the
+ // embedded QDockWidget needs to be plugged back into the QMainWindow layout.
+ savedState.clear();
+ QDockAreaLayoutInfo* info = dwgw->layoutInfo();
+ QDockAreaLayoutInfo* parentInfo;
+ QList<int> path;
+
+ if (QDockWidgetGroupWindow *dropTo = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat)) {
+ parentInfo = dropTo->layoutInfo();
+ Q_ASSERT(parentInfo->tabbed);
+ path = parentInfo->indexOf(widget);
+ Q_ASSERT(path.size() == 1);
+ } else {
+ path = layoutState.dockAreaLayout.indexOf(widget);
+ Q_ASSERT(path.size() >= 2);
+ parentInfo = layoutState.dockAreaLayout.info(path);
+ Q_ASSERT(parentInfo);
+ }
+
+ if (parentInfo->tabbed) {
+ // merge the two tab widgets
+ int idx = path.last();
+ Q_ASSERT(parentInfo->item_list[idx].widgetItem->widget() == dwgw);
+ delete parentInfo->item_list[idx].widgetItem;
+ parentInfo->item_list.removeAt(idx);
+ std::copy(info->item_list.cbegin(), info->item_list.cend(),
+ std::inserter(parentInfo->item_list, parentInfo->item_list.begin() + idx));
+ quintptr currentId = info->currentTabId();
+ *info = QDockAreaLayoutInfo();
+ parentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget());
+ parentInfo->updateTabBar();
+ parentInfo->setCurrentTabId(currentId);
+ } else {
+ QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path);
+ Q_ASSERT(item.widgetItem->widget() == dwgw);
+ delete item.widgetItem;
+ item.widgetItem = 0;
+ item.subinfo = new QDockAreaLayoutInfo(qMove(*info));
+ *info = QDockAreaLayoutInfo();
+ item.subinfo->reparentWidgets(parentWidget());
+ item.subinfo->setTabBarShape(parentInfo->tabBarShape);
+ }
+ dwgw->destroyIfEmpty();
+ }
+
+ if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
+ if (currentHoveredFloat) {
+ dw->setParent(currentHoveredFloat);
+ dw->show();
+ }
dw->d_func()->plug(currentGapRect);
+ }
#endif
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
@@ -1612,6 +2094,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
savedState.clear();
currentGapPos.clear();
pluggingWidget = 0;
+ currentHoveredFloat = Q_NULLPTR;
//applying the state will make sure that the currentGap is updated correctly
//and all the geometries (especially the one from the central widget) is correct
layoutState.apply(false);
@@ -1621,7 +2104,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
if (qobject_cast<QDockWidget*>(widget) != 0) {
// info() might return null if the widget is destroyed while
// animating but before the animationFinished signal is received.
- if (QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(widget))
+ if (QDockAreaLayoutInfo *info = dockInfo(widget))
info->setCurrentTab(widget);
}
#endif
@@ -1673,9 +2156,6 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay
#endif // QT_NO_DOCKWIDGET
, widgetAnimator(this)
, pluggingWidget(0)
-#ifndef QT_NO_RUBBERBAND
- , gapIndicator(new QRubberBand(QRubberBand::Rectangle, mainwindow))
-#endif //QT_NO_RUBBERBAND
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
, blockVisiblityCheck(false)
#endif
@@ -1693,12 +2173,6 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay
tabPositions[i] = QTabWidget::South;
#endif
#endif // QT_NO_DOCKWIDGET
-
-#ifndef QT_NO_RUBBERBAND
- // For accessibility to identify this special widget.
- gapIndicator->setObjectName(QLatin1String("qt_rubberband"));
- gapIndicator->hide();
-#endif
pluggingWidget = 0;
setObjectName(mainwindow->objectName() + QLatin1String("_layout"));
@@ -1765,8 +2239,33 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
invalidate();
}
-QLayoutItem *QMainWindowLayout::unplug(QWidget *widget)
-{
+/*! \internal
+ Unplug \a widget (QDockWidget or QToolBar) from it's parent container.
+
+ If \a group is true we might actually unplug the group of tabs this
+ widget is part if QMainWindow::GroupedDragging is set. When \a group
+ is false, the widget itself is always unplugged alone
+
+ Returns the QLayoutItem of the dragged element.
+ The layout item is kept in the layout but set as a gap item.
+ */
+QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
+{
+#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_TABBAR)
+ QDockWidgetGroupWindow *floatingParent = qobject_cast<QDockWidgetGroupWindow *>(widget->parentWidget());
+ if (group && floatingParent && !widget->isWindow()) {
+ // We are just dragging a floating window as it, not need to do anything, we just have to
+ // look up the corresponding QWidgetItem* if it exists
+ QList<int> tabbedWindowPath = layoutState.indexOf(widget->parentWidget());
+ return tabbedWindowPath.isEmpty() ? 0 : layoutState.item(tabbedWindowPath);
+ } else if (floatingParent) {
+ // We are unplugging a dock widget from a floating window.
+ if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
+ dw->d_func()->unplug(widget->geometry());
+ return 0;
+ }
+ }
+#endif
QList<int> path = layoutState.indexOf(widget);
if (path.isEmpty())
return 0;
@@ -1780,9 +2279,35 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget)
#ifndef QT_NO_DOCKWIDGET
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
- dw->d_func()->unplug(r);
+ Q_ASSERT(path.first() == 1);
+ bool actualGroup = false;
+#ifndef QT_NO_TABBAR
+ if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) {
+ QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2));
+ if (parentItem.subinfo && parentItem.subinfo->tabbed) {
+ // The QDockWidget is part of a group of tab and we need to unplug them all.
+ actualGroup = true;
+ path.removeLast();
+
+ QDockWidgetGroupWindow* floatingTabs = createTabbedDockWindow();
+ QDockAreaLayoutInfo* info = floatingTabs->layoutInfo();
+ *info = qMove(*parentItem.subinfo);
+ delete parentItem.subinfo;
+ parentItem.subinfo = 0;
+ floatingTabs->setGeometry(info->rect.translated(parentWidget()->pos()));
+ floatingTabs->show();
+ floatingTabs->raise();
+ item = new QDockWidgetGroupWindowItem(floatingTabs);
+ parentItem.widgetItem = item;
+ savedState = layoutState;
+ }
+ }
+#endif // QT_NO_TABBAR
+ if (!actualGroup) {
+ dw->d_func()->unplug(r);
+ }
}
-#endif
+#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget)) {
tb->d_func()->unplug(r);
@@ -1804,18 +2329,75 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget)
void QMainWindowLayout::updateGapIndicator()
{
#ifndef QT_NO_RUBBERBAND
- gapIndicator->setVisible(!widgetAnimator.animating() && !currentGapPos.isEmpty());
- gapIndicator->setGeometry(currentGapRect);
-#endif
+ if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) || currentHoveredFloat) {
+ QWidget *expectedParent = currentHoveredFloat ? currentHoveredFloat.data() : parentWidget();
+ if (!gapIndicator) {
+ gapIndicator = new QRubberBand(QRubberBand::Rectangle, expectedParent);
+ // For accessibility to identify this special widget.
+ gapIndicator->setObjectName(QLatin1String("qt_rubberband"));
+ } else if (gapIndicator->parent() != expectedParent) {
+ gapIndicator->setParent(expectedParent);
+ }
+ gapIndicator->setGeometry(currentHoveredFloat ? currentHoveredFloat->rect() : currentGapRect);
+ gapIndicator->show();
+ gapIndicator->raise();
+ } else if (gapIndicator) {
+ gapIndicator->hide();
+ }
+#endif //QT_NO_RUBBERBAND
}
-QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
+void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
{
if (!parentWidget()->isVisible() || parentWidget()->isMinimized()
|| pluggingWidget != 0 || widgetItem == 0)
- return QList<int>();
+ return;
QWidget *widget = widgetItem->widget();
+
+#ifndef QT_NO_DOCKWIDGET
+ if ((dockOptions & QMainWindow::GroupedDragging) && (qobject_cast<QDockWidget*>(widget)
+ || qobject_cast<QDockWidgetGroupWindow *>(widget))) {
+
+ // Check if we are over another floating dock widget
+ QVarLengthArray<QWidget *, 10> candidates;
+ foreach (QObject *c, parentWidget()->children()) {
+ QWidget *w = qobject_cast<QWidget*>(c);
+ if (!w)
+ continue;
+ if (w == widget)
+ continue;
+ if (!w->isTopLevel() || !w->isVisible() || w->isMinimized())
+ continue;
+ if (!qobject_cast<QDockWidget*>(w) && !qobject_cast<QDockWidgetGroupWindow *>(w))
+ continue;
+ candidates << w;
+ if (QDockWidgetGroupWindow *group = qobject_cast<QDockWidgetGroupWindow *>(w)) {
+ // Sometimes, there are floating QDockWidget that have a QDockWidgetGroupWindow as a parent.
+ foreach (QObject *c, group->children()) {
+ if (QDockWidget *dw = qobject_cast<QDockWidget*>(c)) {
+ if (dw != widget && dw->isFloating() && dw->isVisible() && !dw->isMinimized())
+ candidates << dw;
+ }
+ }
+ }
+ }
+ foreach (QWidget *w, candidates) {
+ QWindow *handle1 = widget->windowHandle();
+ QWindow *handle2 = w->windowHandle();
+ if (handle1 && handle2 && handle1->screen() != handle2->screen())
+ continue;
+ if (!w->geometry().contains(mousePos))
+ continue;
+
+ currentHoveredFloat = w;
+ restore(true);
+ return;
+ }
+ }
+ currentHoveredFloat = Q_NULLPTR;
+#endif //QT_NO_DOCKWIDGET
+
QPoint pos = parentWidget()->mapFromGlobal(mousePos);
if (!savedState.isValid())
@@ -1829,6 +2411,9 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
#ifndef QT_NO_DOCKWIDGET
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget))
allowed = dw->isAreaAllowed(toDockWidgetArea(path.at(1)));
+
+ if (qobject_cast<QDockWidgetGroupWindow *>(widget))
+ allowed = true;
#endif
#ifndef QT_NO_TOOLBAR
if (QToolBar *tb = qobject_cast<QToolBar*>(widget))
@@ -1840,13 +2425,13 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
}
if (path == currentGapPos)
- return currentGapPos; // the gap is already there
+ return; // the gap is already there
currentGapPos = path;
if (path.isEmpty()) {
fixToolBarOrientation(widgetItem, 2); // 2 = top dock, ie. horizontal
restore(true);
- return QList<int>();
+ return;
}
fixToolBarOrientation(widgetItem, currentGapPos.at(1));
@@ -1855,7 +2440,7 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
if (!newState.insertGap(path, widgetItem)) {
restore(true); // not enough space
- return QList<int>();
+ return;
}
QSize min = newState.minimumSize();
@@ -1863,7 +2448,7 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
if (min.width() > size.width() || min.height() > size.height()) {
restore(true);
- return QList<int>();
+ return;
}
newState.fitLayout();
@@ -1877,8 +2462,13 @@ QList<int> QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mouse
applyState(layoutState);
updateGapIndicator();
+}
- return path;
+QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow()
+{
+ QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool);
+ new QDockWidgetGroupLayout(f);
+ return f;
}
void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate)
@@ -1886,6 +2476,11 @@ void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animat
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
QSet<QTabBar*> used = newState.dockAreaLayout.usedTabBars();
+ foreach (QDockWidgetGroupWindow *dwgw,
+ parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ used += dwgw->layoutInfo()->usedTabBars();
+ }
+
QSet<QTabBar*> retired = usedTabBars - used;
usedTabBars = used;
foreach (QTabBar *tab_bar, retired) {
@@ -1904,6 +2499,8 @@ void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animat
}
}
+ for (int i = 0; i < QInternal::DockCount; ++i)
+ newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget());
#endif // QT_NO_TABBAR
#endif // QT_NO_DOCKWIDGET
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 9f84ee95db..9a13e5f5ce 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -77,6 +77,37 @@ QT_BEGIN_NAMESPACE
class QToolBar;
class QRubberBand;
+#ifndef QT_NO_DOCKWIDGET
+class QDockWidgetGroupWindow : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit QDockWidgetGroupWindow(QWidget* parent = 0, Qt::WindowFlags f = 0)
+ : QWidget(parent, f) {}
+ QDockAreaLayoutInfo *layoutInfo() const;
+ QDockWidget *topDockWidget() const;
+ void destroyIfEmpty();
+ void adjustFlags();
+protected:
+ bool event(QEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
+};
+
+// This item will be used in the layout for the gap item. We cannot use QWidgetItem directly
+// because QWidgetItem functions return an empty size for widgets that are are floating.
+class QDockWidgetGroupWindowItem : public QWidgetItem
+{
+public:
+ explicit QDockWidgetGroupWindowItem(QDockWidgetGroupWindow *parent) : QWidgetItem(parent) {}
+ QSize minimumSize() const Q_DECL_OVERRIDE { return lay()->minimumSize(); }
+ QSize maximumSize() const Q_DECL_OVERRIDE { return lay()->maximumSize(); }
+ QSize sizeHint() const Q_DECL_OVERRIDE { return lay()->sizeHint(); }
+
+private:
+ QLayout *lay() const { return const_cast<QDockWidgetGroupWindowItem *>(this)->widget()->layout(); }
+};
+#endif
+
/* This data structure represents the state of all the tool-bars and dock-widgets. It's value based
so it can be easilly copied into a temporary variable. All operations are performed without moving
any widgets. Only when we are sure we have the desired state, we call apply(), which moves the
@@ -196,10 +227,11 @@ public:
QDockWidget *dockwidget,
Qt::Orientation orientation);
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
- Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
+ Qt::DockWidgetArea dockWidgetArea(QWidget* widget) const;
void raise(QDockWidget *widget);
void setVerticalTabsEnabled(bool enabled);
bool restoreDockWidget(QDockWidget *dockwidget);
+ QDockAreaLayoutInfo *dockInfo(QWidget *w);
#ifndef QT_NO_TABBAR
bool _documentMode;
@@ -224,6 +256,8 @@ public:
void setTabShape(QTabWidget::TabShape tabShape);
QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
+
+ QDockWidgetGroupWindow *createTabbedDockWindow();
#endif // QT_NO_TABWIDGET
#endif // QT_NO_TABBAR
@@ -268,12 +302,15 @@ public:
QRect currentGapRect;
QWidget *pluggingWidget;
#ifndef QT_NO_RUBBERBAND
- QRubberBand *gapIndicator;
+ QPointer<QRubberBand> gapIndicator;
+#endif
+#ifndef QT_NO_DOCKWIDGET
+ QPointer<QWidget> currentHoveredFloat; // set when dragging over a floating dock widget
#endif
- QList<int> hover(QLayoutItem *widgetItem, const QPoint &mousePos);
+ void hover(QLayoutItem *widgetItem, const QPoint &mousePos);
bool plug(QLayoutItem *widgetItem);
- QLayoutItem *unplug(QWidget *widget);
+ QLayoutItem *unplug(QWidget *widget, bool group = false);
void revert(QLayoutItem *widgetItem);
void updateGapIndicator();
void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
@@ -286,6 +323,7 @@ private Q_SLOTS:
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
void tabChanged();
+ void tabMoved(int from, int to);
#endif
#endif
private:
diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h
index 461282f8a8..e05535b2af 100644
--- a/src/widgets/widgets/qmdiarea.h
+++ b/src/widgets/widgets/qmdiarea.h
@@ -79,7 +79,7 @@ public:
};
Q_ENUM(ViewMode)
- QMdiArea(QWidget *parent = 0);
+ QMdiArea(QWidget *parent = Q_NULLPTR);
~QMdiArea();
QSize sizeHint() const Q_DECL_OVERRIDE;
@@ -89,7 +89,7 @@ public:
QMdiSubWindow *activeSubWindow() const;
QList<QMdiSubWindow *> subWindowList(WindowOrder order = CreationOrder) const;
- QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = 0);
+ QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = Qt::WindowFlags());
void removeSubWindow(QWidget *widget);
QBrush background() const;
diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h
index 7f28879f8d..f6bdf61492 100644
--- a/src/widgets/widgets/qmdiarea_p.h
+++ b/src/widgets/widgets/qmdiarea_p.h
@@ -142,8 +142,8 @@ public:
#endif
QMdiAreaTabBar *tabBar;
QList<QMdi::Rearranger *> pendingRearrangements;
- QList< QPointer<QMdiSubWindow> > pendingPlacements;
- QList< QPointer<QMdiSubWindow> > childWindows;
+ QVector< QPointer<QMdiSubWindow> > pendingPlacements;
+ QVector< QPointer<QMdiSubWindow> > childWindows;
QList<int> indicesToActivatedChildren;
QPointer<QMdiSubWindow> active;
QPointer<QMdiSubWindow> aboutToBecomeActive;
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index 1808030639..14aeb73baf 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -1091,8 +1091,8 @@ void QMdiSubWindowPrivate::updateDirtyRegions()
if (!parent)
return;
- foreach (Operation operation, operationMap.keys())
- operationMap.find(operation).value().region = getRegion(operation);
+ for (OperationInfoMap::iterator it = operationMap.begin(), end = operationMap.end(); it != end; ++it)
+ it.value().region = getRegion(it.key());
}
/*!
@@ -2689,7 +2689,10 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event)
// System menu events.
if (d->systemMenu && d->systemMenu == object) {
if (event->type() == QEvent::MouseButtonDblClick) {
- close();
+ const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
+ const QAction *action = d->systemMenu->actionAt(mouseEvent->pos());
+ if (!action || action->isEnabled())
+ close();
} else if (event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
d->hoveredSubControl = d->getSubControl(mapFromGlobal(mouseEvent->globalPos()));
diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h
index 693477c894..e7d0ca4e44 100644
--- a/src/widgets/widgets/qmdisubwindow.h
+++ b/src/widgets/widgets/qmdisubwindow.h
@@ -60,7 +60,7 @@ public:
};
Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)
- QMdiSubWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ QMdiSubWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
~QMdiSubWindow();
QSize sizeHint() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index e81359feac..ea3e4c4488 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -102,9 +102,9 @@ class QTornOffMenu : public QMenu
causedPopup.action = ((QTornOffMenu*)p)->d_func()->causedPopup.action;
causedStack = ((QTornOffMenu*)p)->d_func()->calcCausedStack();
}
- QList<QPointer<QWidget> > calcCausedStack() const Q_DECL_OVERRIDE { return causedStack; }
+ QVector<QPointer<QWidget> > calcCausedStack() const Q_DECL_OVERRIDE { return causedStack; }
QPointer<QMenu> causedMenu;
- QList<QPointer<QWidget> > causedStack;
+ QVector<QPointer<QWidget> > causedStack;
};
public:
QTornOffMenu(QMenu *p) : QMenu(*(new QTornOffMenuPrivate(p)))
@@ -192,11 +192,10 @@ void QMenuPrivate::syncPlatformMenu()
return;
QPlatformMenuItem *beforeItem = Q_NULLPTR;
- QListIterator<QAction*> it(q->actions());
- it.toBack();
- while (it.hasPrevious()) {
+ const QList<QAction*> actions = q->actions();
+ for (QList<QAction*>::const_reverse_iterator it = actions.rbegin(), end = actions.rend(); it != end; ++it) {
QPlatformMenuItem *menuItem = platformMenu->createMenuItem();
- QAction *action = it.previous();
+ QAction *action = *it;
menuItem->setTag(reinterpret_cast<quintptr>(action));
QObject::connect(menuItem, SIGNAL(activated()), action, SLOT(trigger()), Qt::QueuedConnection);
QObject::connect(menuItem, SIGNAL(hovered()), action, SIGNAL(hovered()), Qt::QueuedConnection);
@@ -236,9 +235,9 @@ QRect QMenuPrivate::popupGeometry(int screen) const
}
}
-QList<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const
+QVector<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const
{
- QList<QPointer<QWidget> > ret;
+ QVector<QPointer<QWidget> > ret;
for(QWidget *widget = causedPopup.widget; widget; ) {
ret.append(widget);
if (QTornOffMenu *qtmenu = qobject_cast<QTornOffMenu*>(widget))
@@ -503,8 +502,8 @@ void QMenuPrivate::hideMenu(QMenu *menu)
if (activeMenu == menu)
activeMenu = 0;
menu->d_func()->causedPopup.action = 0;
- menu->d_func()->causedPopup.widget = 0;
menu->close();
+ menu->d_func()->causedPopup.widget = 0;
if (previousMouseMenu.data() == menu)
handleEnterLeaveEvents(&previousMouseMenu, Q_NULLPTR);
}
@@ -1110,8 +1109,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
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());
+ e->button(), e->buttons(), e->modifiers(), e->source());
QApplication::sendEvent(caused, &new_e);
return true;
}
@@ -1123,7 +1121,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
return false;
}
-void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)
+void QMenuPrivate::activateCausedStack(const QVector<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)
{
QBoolBlocker guard(activationRecursionGuard);
if(self)
@@ -1171,7 +1169,7 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e
/* I have to save the caused stack here because it will be undone after popup execution (ie in the hide).
Then I iterate over the list to actually send the events. --Sam
*/
- const QList<QPointer<QWidget> > causedStack = calcCausedStack();
+ const QVector<QPointer<QWidget> > causedStack = calcCausedStack();
if (action_e == QAction::Trigger) {
#ifndef QT_NO_WHATSTHIS
if (!inWhatsThisMode)
@@ -1233,7 +1231,7 @@ void QMenuPrivate::_q_actionTriggered()
if (!activationRecursionGuard && actionGuard) {
//in case the action has not been activated by the mouse
//we check the parent hierarchy
- QList< QPointer<QWidget> > list;
+ QVector< QPointer<QWidget> > list;
for(QWidget *widget = q->parentWidget(); widget; ) {
if (qobject_cast<QMenu*>(widget)
#ifndef QT_NO_MENUBAR
@@ -1266,7 +1264,7 @@ void QMenuPrivate::_q_platformMenuAboutToShow()
#ifdef Q_OS_OSX
if (platformMenu)
Q_FOREACH (QAction *action, q->actions())
- if (QWidget *widget = widgetItems.value(const_cast<QAction *>(action)))
+ if (QWidget *widget = widgetItems.value(action))
if (widget->parent() == q) {
QPlatformMenuItem *menuItem = platformMenu->menuItemForTag(reinterpret_cast<quintptr>(action));
moveWidgetToPlatformItem(widget, menuItem);
@@ -1444,7 +1442,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
addSeparator(), and addMenu().
\sa QMenuBar, {fowler}{GUI Design Handbook: Menu, Drop-Down and Pop-Up},
- {Application Example}, {Menus Example}, {Recent Files Example}
+ {Application Example}, {Menus Example}
*/
@@ -1572,6 +1570,100 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
return action;
}
+/*!\fn QAction *QMenu::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
+
+ \since 5.6
+
+ \overload
+
+ This convenience function creates a new action with the text \a
+ text and an optional shortcut \a shortcut. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a method of the \a receiver. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
+/*!\fn QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0)
+
+ \since 5.6
+
+ \overload
+
+ This convenience function creates a new action with the text \a
+ text and an optional shortcut \a shortcut. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
+/*!\fn QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0)
+
+ \since 5.6
+
+ \overload
+
+ This convenience function creates a new action with the text \a
+ text and an optional shortcut \a shortcut. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ If \a context is destroyed, the functor will not be called.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
+/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
+
+ \since 5.6
+
+ \overload
+
+ This convenience function creates a new action with an \a icon
+ and some \a text and an optional shortcut \a shortcut. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a method of the \a receiver. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
+/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0)
+
+ \since 5.6
+
+ \overload
+
+ This convenience function creates a new action with an \a icon
+ and some \a text and an optional shortcut \a shortcut. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
+/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0)
+
+ \since 5.6
+
+ \overload
+
+ This convenience function creates a new action with an \a icon
+ and some \a text and an optional shortcut \a shortcut. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ If \a context is destroyed, the functor will not be called.
+
+ QMenu takes ownership of the returned QAction.
+*/
+
/*!
\overload
@@ -2494,7 +2586,11 @@ void QMenu::mousePressEvent(QMouseEvent *e)
Q_D(QMenu);
if (d->aboutToHide || d->mouseEventTaken(e))
return;
- if (!rect().contains(e->pos())) {
+ // Workaround for XCB on multiple screens which doesn't have offset. If the menu is open on one screen
+ // and mouse clicks on second screen, e->pos() is QPoint(0,0) and the menu doesn't hide. This trick makes
+ // possible to hide the menu when mouse clicks on another screen (e->screenPos() returns correct value).
+ // Only when mouse clicks in QPoint(0,0) on second screen, the menu doesn't hide.
+ if ((e->pos().isNull() && !e->screenPos().isNull()) || !rect().contains(e->pos())) {
if (d->noReplayFor
&& QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos()))
setAttribute(Qt::WA_NoMouseReplay);
@@ -2586,7 +2682,7 @@ QMenu::event(QEvent *e)
if (kev->key() == Qt::Key_Up || kev->key() == Qt::Key_Down
|| kev->key() == Qt::Key_Left || kev->key() == Qt::Key_Right
|| kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return
- || kev->key() == Qt::Key_Escape) {
+ || kev->matches(QKeySequence::Cancel)) {
e->accept();
return true;
}
@@ -2872,27 +2968,6 @@ void QMenu::keyPressEvent(QKeyEvent *e)
}
break;
- case Qt::Key_Escape:
-#ifdef QT_KEYPAD_NAVIGATION
- case Qt::Key_Back:
-#endif
- key_consumed = true;
- if (d->tornoff) {
- close();
- return;
- }
- {
- QPointer<QWidget> caused = d->causedPopup.widget;
- d->hideMenu(this); // hide after getting causedPopup
-#ifndef QT_NO_MENUBAR
- if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
- mb->d_func()->setCurrentAction(d->menuAction);
- mb->d_func()->setKeyboardMode(true);
- }
-#endif
- }
- break;
-
case Qt::Key_Space:
if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this))
break;
@@ -2929,6 +3004,28 @@ void QMenu::keyPressEvent(QKeyEvent *e)
key_consumed = false;
}
+ if (!key_consumed && (e->matches(QKeySequence::Cancel)
+#ifdef QT_KEYPAD_NAVIGATION
+ || e->key() == Qt::Key_Back
+#endif
+ )) {
+ key_consumed = true;
+ if (d->tornoff) {
+ close();
+ return;
+ }
+ {
+ QPointer<QWidget> caused = d->causedPopup.widget;
+ d->hideMenu(this); // hide after getting causedPopup
+#ifndef QT_NO_MENUBAR
+ if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
+ mb->d_func()->setCurrentAction(d->menuAction);
+ mb->d_func()->setKeyboardMode(true);
+ }
+#endif
+ }
+ }
+
if (!key_consumed) { // send to menu bar
if ((!e->modifiers() || e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ShiftModifier) &&
e->text().length()==1) {
@@ -3049,7 +3146,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
d->activeMenu->d_func()->setCurrentAction(0);
QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction);
- if (sloppyEventResult == QMenuSloppyState::EventShouldBePropogated) {
+ if (sloppyEventResult == QMenuSloppyState::EventShouldBePropagated) {
d->setCurrentAction(action, d->mousePopupDelay);
} else if (sloppyEventResult == QMenuSloppyState::EventDiscardsSloppyState) {
d->sloppyState.reset();
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 5dda8b2370..6bbe54186e 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -68,8 +68,8 @@ private:
Q_PROPERTY(bool toolTipsVisible READ toolTipsVisible WRITE setToolTipsVisible)
public:
- explicit QMenu(QWidget *parent = 0);
- explicit QMenu(const QString &title, QWidget *parent = 0);
+ explicit QMenu(QWidget *parent = Q_NULLPTR);
+ explicit QMenu(const QString &title, QWidget *parent = Q_NULLPTR);
~QMenu();
using QWidget::addAction;
@@ -78,6 +78,72 @@ public:
QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
+#ifdef Q_QDOC
+ QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
+#else
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+ // addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(actionIcon, text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QIcon, QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ {
+ QAction *result = addAction(actionIcon, text);
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(shortcut)
+#else
+ result->setShortcut(shortcut);
+#endif
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+#endif // !Q_QDOC
+
QAction *addMenu(QMenu *menu);
QMenu *addMenu(const QString &title);
QMenu *addMenu(const QIcon &icon, const QString &title);
@@ -107,14 +173,14 @@ public:
void setActiveAction(QAction *act);
QAction *activeAction() const;
- void popup(const QPoint &pos, QAction *at=0);
+ void popup(const QPoint &pos, QAction *at = Q_NULLPTR);
QAction *exec();
- QAction *exec(const QPoint &pos, QAction *at=0);
+ QAction *exec(const QPoint &pos, QAction *at = Q_NULLPTR);
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
- static QAction *exec(const QList<QAction *> &actions, const QPoint &pos, QAction *at = 0, QWidget *parent = 0);
+ static QAction *exec(const QList<QAction *> &actions, const QPoint &pos, QAction *at = Q_NULLPTR, QWidget *parent = Q_NULLPTR);
#else
- static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at=0, QWidget *parent=0);
+ static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at = Q_NULLPTR, QWidget *parent = Q_NULLPTR);
#endif
QSize sizeHint() const Q_DECL_OVERRIDE;
@@ -189,7 +255,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_platformMenuAboutToShow())
protected:
- QMenu(QMenuPrivate &dd, QWidget* parent = 0);
+ QMenu(QMenuPrivate &dd, QWidget* parent = Q_NULLPTR);
private:
Q_DISABLE_COPY(QMenu)
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index a42879fc73..8b29011178 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -115,6 +115,7 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
QObject::connect(platformMenu, SIGNAL(destroyed()), container, SLOT(deleteLater()));
container->resize(widget->sizeHint());
widget->setParent(container);
+ widget->setVisible(true);
NSView *containerView = container->nativeView();
QWindow *containerWindow = container->windowHandle();
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index ab6ca068fb..e717d923ae 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -126,7 +126,7 @@ public:
enum MouseEventResult {
EventIsProcessed,
- EventShouldBePropogated,
+ EventShouldBePropagated,
EventDiscardsSloppyState
};
@@ -187,14 +187,14 @@ public:
m_parent->stopTimer();
if (!m_enabled)
- return EventShouldBePropogated;
+ return EventShouldBePropagated;
if (!m_time.isActive())
startTimer();
if (!m_sub_menu) {
reset();
- return EventShouldBePropogated;
+ return EventShouldBePropagated;
}
QSetValueOnDestroy<bool> setFirstMouse(m_first_mouse, false);
@@ -208,7 +208,7 @@ public:
if (m_action_rect.contains(mousePos)) {
startTimer();
- return currentAction == m_menu->menuAction() ? EventIsProcessed : EventShouldBePropogated;
+ return currentAction == m_menu->menuAction() ? EventIsProcessed : EventShouldBePropagated;
}
if (m_uni_directional && !m_first_mouse && resetAction != m_origin_action) {
@@ -247,7 +247,7 @@ public:
}
- return m_select_other_actions ? EventShouldBePropogated : EventIsProcessed;
+ return m_select_other_actions ? EventShouldBePropagated : EventIsProcessed;
}
void setSubMenuPopup(const QRect &actionRect, QAction *resetAction, QMenu *subMenu);
@@ -422,7 +422,7 @@ public:
QPointer<QWidget> widget;
QPointer<QAction> action;
};
- virtual QList<QPointer<QWidget> > calcCausedStack() const;
+ virtual QVector<QPointer<QWidget> > calcCausedStack() const;
QMenuCaused causedPopup;
void hideUpToMenuBar();
void hideMenu(QMenu *menu);
@@ -450,7 +450,7 @@ public:
//firing of events
void activateAction(QAction *, QAction::ActionEvent, bool self=true);
- void activateCausedStack(const QList<QPointer<QWidget> > &, QAction *, QAction::ActionEvent, bool);
+ void activateCausedStack(const QVector<QPointer<QWidget> > &, QAction *, QAction::ActionEvent, bool);
void _q_actionTriggered();
void _q_actionHovered();
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 883fd3a945..2e48607f82 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -195,7 +195,9 @@ void QMenuBarPrivate::updateGeometries()
for(int j = 0; j < shortcutIndexMap.size(); ++j)
q->releaseShortcut(shortcutIndexMap.value(j));
shortcutIndexMap.resize(0); // faster than clear
- for(int i = 0; i < actions.count(); i++)
+ const int actionsCount = actions.count();
+ shortcutIndexMap.reserve(actionsCount);
+ for (int i = 0; i < actionsCount; i++)
shortcutIndexMap.append(q->grabShortcut(QKeySequence::mnemonic(actions.at(i)->text())));
}
#endif
@@ -636,7 +638,7 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti
\row \li quit or exit
\li Application Menu | Quit <application name>
\li If this entry is not found a default Quit item will be
- created to call QApplication::quit()
+ created to call QCoreApplication::quit()
\endtable
You can override this behavior by using the QAction::menuRole()
@@ -1120,14 +1122,14 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
}
break; }
- case Qt::Key_Escape:
+ default:
+ key_consumed = false;
+ }
+
+ if (!key_consumed && e->matches(QKeySequence::Cancel)) {
d->setCurrentAction(0);
d->setKeyboardMode(false);
key_consumed = true;
- break;
-
- default:
- key_consumed = false;
}
if(!key_consumed &&
@@ -1430,7 +1432,7 @@ bool QMenuBar::event(QEvent *e)
case QEvent::ShortcutOverride: {
QKeyEvent *kev = static_cast<QKeyEvent*>(e);
//we only filter out escape if there is a current action
- if (kev->key() == Qt::Key_Escape && d->currentAction) {
+ if (kev->matches(QKeySequence::Cancel) && d->currentAction) {
e->accept();
return true;
}
diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h
index 461dec8a94..3b3980c860 100644
--- a/src/widgets/widgets/qmenubar.h
+++ b/src/widgets/widgets/qmenubar.h
@@ -54,7 +54,7 @@ class Q_WIDGETS_EXPORT QMenuBar : public QWidget
Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
public:
- explicit QMenuBar(QWidget *parent = 0);
+ explicit QMenuBar(QWidget *parent = Q_NULLPTR);
~QMenuBar();
using QWidget::addAction;
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 93c9ddc285..91788a3383 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -1615,7 +1615,7 @@ void QPlainTextEdit::timerEvent(QTimerEvent *e)
Note that the undo/redo history is cleared by this function.
- \sa toText()
+ \sa toPlainText()
*/
void QPlainTextEdit::setPlainText(const QString &text)
diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h
index 69bd2ab647..60f1d6e984 100644
--- a/src/widgets/widgets/qplaintextedit.h
+++ b/src/widgets/widgets/qplaintextedit.h
@@ -82,8 +82,8 @@ public:
};
Q_ENUM(LineWrapMode)
- explicit QPlainTextEdit(QWidget *parent = 0);
- explicit QPlainTextEdit(const QString &text, QWidget *parent = 0);
+ explicit QPlainTextEdit(QWidget *parent = Q_NULLPTR);
+ explicit QPlainTextEdit(const QString &text, QWidget *parent = Q_NULLPTR);
virtual ~QPlainTextEdit();
void setDocument(QTextDocument *document);
@@ -136,9 +136,9 @@ public:
void setCenterOnScroll(bool enabled);
bool centerOnScroll() const;
- bool find(const QString &exp, QTextDocument::FindFlags options = 0);
+ bool find(const QString &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#ifndef QT_NO_REGEXP
- bool find(const QRegExp &exp, QTextDocument::FindFlags options = 0);
+ bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
inline QString toPlainText() const
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index 8034a0237a..5b06e75abe 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -107,10 +107,8 @@ void QProgressBarPrivate::resetLayoutItemMargins()
/*!
Initialize \a option with the values from this QProgressBar. This method is useful
- for subclasses when they need a QStyleOptionProgressBar or QStyleOptionProgressBarV2,
- but don't want to fill in all the information themselves. This function will check the version
- of the QStyleOptionProgressBar and fill in the additional values for a
- QStyleOptionProgressBarV2.
+ for subclasses when they need a QStyleOptionProgressBar,
+ but don't want to fill in all the information themselves.
\sa QStyleOption::initFrom()
*/
@@ -129,13 +127,9 @@ void QProgressBar::initStyleOption(QStyleOptionProgressBar *option) const
option->textAlignment = d->alignment;
option->textVisible = d->textVisible;
option->text = text();
-
- if (QStyleOptionProgressBarV2 *optionV2
- = qstyleoption_cast<QStyleOptionProgressBarV2 *>(option)) {
- optionV2->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBarV2
- optionV2->invertedAppearance = d->invertedAppearance;
- optionV2->bottomToTop = (d->textDirection == QProgressBar::BottomToTop);
- }
+ option->orientation = d->orientation; // ### Qt 6: remove this member from QStyleOptionProgressBar
+ option->invertedAppearance = d->invertedAppearance;
+ option->bottomToTop = d->textDirection == QProgressBar::BottomToTop;
}
bool QProgressBarPrivate::repaintRequired() const
@@ -158,7 +152,7 @@ bool QProgressBarPrivate::repaintRequired() const
}
// Check if the bar needs to be repainted
- QStyleOptionProgressBarV2 opt;
+ QStyleOptionProgressBar opt;
q->initStyleOption(&opt);
int cw = q->style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, q);
QRect groove = q->style()->subElementRect(QStyle::SE_ProgressBarGroove, &opt, q);
@@ -410,7 +404,7 @@ Qt::Alignment QProgressBar::alignment() const
void QProgressBar::paintEvent(QPaintEvent *)
{
QStylePainter paint(this);
- QStyleOptionProgressBarV2 opt;
+ QStyleOptionProgressBar opt;
initStyleOption(&opt);
paint.drawControl(QStyle::CE_ProgressBar, opt);
d_func()->lastPaintedValue = d_func()->value;
@@ -423,7 +417,7 @@ QSize QProgressBar::sizeHint() const
{
ensurePolished();
QFontMetrics fm = fontMetrics();
- QStyleOptionProgressBarV2 opt;
+ QStyleOptionProgressBar opt;
initStyleOption(&opt);
int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);
QSize size = QSize(qMax(9, cw) * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);
diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h
index 0c3200f82c..e17e01c17b 100644
--- a/src/widgets/widgets/qprogressbar.h
+++ b/src/widgets/widgets/qprogressbar.h
@@ -62,7 +62,7 @@ public:
enum Direction { TopToBottom, BottomToTop };
Q_ENUM(Direction)
- explicit QProgressBar(QWidget *parent = 0);
+ explicit QProgressBar(QWidget *parent = Q_NULLPTR);
~QProgressBar();
int minimum() const;
diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h
index 2521c0982e..3db12be380 100644
--- a/src/widgets/widgets/qpushbutton.h
+++ b/src/widgets/widgets/qpushbutton.h
@@ -52,9 +52,9 @@ class Q_WIDGETS_EXPORT QPushButton : public QAbstractButton
Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
public:
- explicit QPushButton(QWidget *parent=0);
- explicit QPushButton(const QString &text, QWidget *parent=0);
- QPushButton(const QIcon& icon, const QString &text, QWidget *parent=0);
+ explicit QPushButton(QWidget *parent = Q_NULLPTR);
+ explicit QPushButton(const QString &text, QWidget *parent = Q_NULLPTR);
+ QPushButton(const QIcon& icon, const QString &text, QWidget *parent = Q_NULLPTR);
~QPushButton();
QSize sizeHint() const Q_DECL_OVERRIDE;
@@ -88,7 +88,7 @@ protected:
void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE;
void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE;
void initStyleOption(QStyleOptionButton *option) const;
- QPushButton(QPushButtonPrivate &dd, QWidget* parent = 0);
+ QPushButton(QPushButtonPrivate &dd, QWidget* parent = Q_NULLPTR);
public:
diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h
index f323f5af99..df0b1051bf 100644
--- a/src/widgets/widgets/qradiobutton.h
+++ b/src/widgets/widgets/qradiobutton.h
@@ -47,8 +47,8 @@ class Q_WIDGETS_EXPORT QRadioButton : public QAbstractButton
Q_OBJECT
public:
- explicit QRadioButton(QWidget *parent=0);
- explicit QRadioButton(const QString &text, QWidget *parent=0);
+ explicit QRadioButton(QWidget *parent = Q_NULLPTR);
+ explicit QRadioButton(const QString &text, QWidget *parent = Q_NULLPTR);
~QRadioButton();
QSize sizeHint() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h
index 3ff6eb47fa..b0dc14ed98 100644
--- a/src/widgets/widgets/qrubberband.h
+++ b/src/widgets/widgets/qrubberband.h
@@ -50,7 +50,7 @@ class Q_WIDGETS_EXPORT QRubberBand : public QWidget
public:
enum Shape { Line, Rectangle };
- explicit QRubberBand(Shape, QWidget * =0);
+ explicit QRubberBand(Shape, QWidget * = Q_NULLPTR);
~QRubberBand();
Shape shape() const;
diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h
index cafb1ec6de..1658236034 100644
--- a/src/widgets/widgets/qscrollarea.h
+++ b/src/widgets/widgets/qscrollarea.h
@@ -50,7 +50,7 @@ class Q_WIDGETS_EXPORT QScrollArea : public QAbstractScrollArea
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
public:
- explicit QScrollArea(QWidget* parent=0);
+ explicit QScrollArea(QWidget *parent = Q_NULLPTR);
~QScrollArea();
QWidget *widget() const;
@@ -71,7 +71,7 @@ public:
void ensureWidgetVisible(QWidget *childWidget, int xmargin = 50, int ymargin = 50);
protected:
- QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = 0);
+ QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = Q_NULLPTR);
bool event(QEvent *) Q_DECL_OVERRIDE;
bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h
index 5934469045..4af5fb4a55 100644
--- a/src/widgets/widgets/qscrollbar.h
+++ b/src/widgets/widgets/qscrollbar.h
@@ -49,8 +49,8 @@ class Q_WIDGETS_EXPORT QScrollBar : public QAbstractSlider
{
Q_OBJECT
public:
- explicit QScrollBar(QWidget *parent=0);
- explicit QScrollBar(Qt::Orientation, QWidget *parent=0);
+ explicit QScrollBar(QWidget *parent = Q_NULLPTR);
+ explicit QScrollBar(Qt::Orientation, QWidget *parent = Q_NULLPTR);
~QScrollBar();
QSize sizeHint() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h
index 3a528382a7..801a684fdf 100644
--- a/src/widgets/widgets/qslider.h
+++ b/src/widgets/widgets/qslider.h
@@ -61,8 +61,8 @@ public:
};
Q_ENUM(TickPosition)
- explicit QSlider(QWidget *parent = 0);
- explicit QSlider(Qt::Orientation orientation, QWidget *parent = 0);
+ explicit QSlider(QWidget *parent = Q_NULLPTR);
+ explicit QSlider(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
~QSlider();
diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h
index 606206d4f0..066fe88562 100644
--- a/src/widgets/widgets/qspinbox.h
+++ b/src/widgets/widgets/qspinbox.h
@@ -56,7 +56,7 @@ class Q_WIDGETS_EXPORT QSpinBox : public QAbstractSpinBox
Q_PROPERTY(int displayIntegerBase READ displayIntegerBase WRITE setDisplayIntegerBase)
public:
- explicit QSpinBox(QWidget *parent = 0);
+ explicit QSpinBox(QWidget *parent = Q_NULLPTR);
~QSpinBox();
int value() const;
@@ -117,7 +117,7 @@ class Q_WIDGETS_EXPORT QDoubleSpinBox : public QAbstractSpinBox
Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
public:
- explicit QDoubleSpinBox(QWidget *parent = 0);
+ explicit QDoubleSpinBox(QWidget *parent = Q_NULLPTR);
~QDoubleSpinBox();
double value() const;
diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h
index 58b8484f4c..dec24a5608 100644
--- a/src/widgets/widgets/qsplashscreen.h
+++ b/src/widgets/widgets/qsplashscreen.h
@@ -47,8 +47,8 @@ class Q_WIDGETS_EXPORT QSplashScreen : public QWidget
{
Q_OBJECT
public:
- explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0);
- QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0);
+ explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
+ QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
virtual ~QSplashScreen();
void setPixmap(const QPixmap &pixmap);
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index de6e45234c..c2081c15f8 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -58,6 +58,10 @@ QT_BEGIN_NAMESPACE
//#define QSPLITTER_DEBUG
+QSplitterPrivate::~QSplitterPrivate()
+{
+}
+
/*!
\class QSplitterHandle
\brief The QSplitterHandle class provides handle functionality for the splitter.
@@ -1498,8 +1502,11 @@ QList<int> QSplitter::sizes() const
Q_D(const QSplitter);
ensurePolished();
+ const int numSizes = d->list.size();
QList<int> list;
- for (int i = 0; i < d->list.size(); ++i) {
+ list.reserve(numSizes);
+
+ for (int i = 0; i < numSizes; ++i) {
QSplitterLayoutStruct *s = d->list.at(i);
list.append(d->pick(s->rect.size()));
}
@@ -1594,8 +1601,10 @@ QByteArray QSplitter::saveState() const
stream << qint32(SplitterMagic);
stream << qint32(version);
+ const int numSizes = d->list.size();
QList<int> list;
- for (int i = 0; i < d->list.size(); ++i) {
+ list.reserve(numSizes);
+ for (int i = 0; i < numSizes; ++i) {
QSplitterLayoutStruct *s = d->list.at(i);
list.append(s->sizer);
}
diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h
index 4da92acd22..84010c236b 100644
--- a/src/widgets/widgets/qsplitter.h
+++ b/src/widgets/widgets/qsplitter.h
@@ -58,8 +58,8 @@ class Q_WIDGETS_EXPORT QSplitter : public QFrame
Q_PROPERTY(bool childrenCollapsible READ childrenCollapsible WRITE setChildrenCollapsible)
public:
- explicit QSplitter(QWidget* parent = 0);
- explicit QSplitter(Qt::Orientation, QWidget* parent = 0);
+ explicit QSplitter(QWidget* parent = Q_NULLPTR);
+ explicit QSplitter(Qt::Orientation, QWidget* parent = Q_NULLPTR);
~QSplitter();
void addWidget(QWidget *widget);
diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h
index a45f776da1..890bd535ec 100644
--- a/src/widgets/widgets/qsplitter_p.h
+++ b/src/widgets/widgets/qsplitter_p.h
@@ -76,6 +76,7 @@ class QSplitterPrivate : public QFramePrivate
public:
QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true),
childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false), opaqueResizeSet(false) {}
+ ~QSplitterPrivate();
QPointer<QRubberBand> rubberBand;
mutable QList<QSplitterLayoutStruct *> list;
diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h
index 4267d8241f..9fcdf80833 100644
--- a/src/widgets/widgets/qstackedwidget.h
+++ b/src/widgets/widgets/qstackedwidget.h
@@ -50,7 +50,7 @@ class Q_WIDGETS_EXPORT QStackedWidget : public QFrame
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
Q_PROPERTY(int count READ count)
public:
- explicit QStackedWidget(QWidget *parent=0);
+ explicit QStackedWidget(QWidget *parent = Q_NULLPTR);
~QStackedWidget();
int addWidget(QWidget *w);
diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h
index 42248d7958..92785aa4c4 100644
--- a/src/widgets/widgets/qstatusbar.h
+++ b/src/widgets/widgets/qstatusbar.h
@@ -50,7 +50,7 @@ class Q_WIDGETS_EXPORT QStatusBar: public QWidget
Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled)
public:
- explicit QStatusBar(QWidget* parent=0);
+ explicit QStatusBar(QWidget *parent = Q_NULLPTR);
virtual ~QStatusBar();
void addWidget(QWidget *widget, int stretch = 0);
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index f2e98474b3..7ea5455bf7 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -118,10 +118,8 @@ void QTabBarPrivate::updateMacBorderMetrics()
/*!
Initialize \a option with the values from the tab at \a tabIndex. This method
- is useful for subclasses when they need a QStyleOptionTab, QStyleOptionTabV2,
- or QStyleOptionTabV3 but don't want to fill in all the information themselves.
- This function will check the version of the QStyleOptionTab and fill in the
- additional values for a QStyleOptionTabV2 and QStyleOptionTabV3.
+ is useful for subclasses when they need a QStyleOptionTab,
+ but don't want to fill in all the information themselves.
\sa QStyleOption::initFrom(), QTabWidget::initStyleOption()
*/
@@ -158,14 +156,11 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
option->palette.setColor(foregroundRole(), tab.textColor);
option->icon = tab.icon;
- if (QStyleOptionTabV2 *optionV2 = qstyleoption_cast<QStyleOptionTabV2 *>(option))
- optionV2->iconSize = iconSize(); // Will get the default value then.
+ option->iconSize = iconSize(); // Will get the default value then.
- if (QStyleOptionTabV3 *optionV3 = qstyleoption_cast<QStyleOptionTabV3 *>(option)) {
- optionV3->leftButtonSize = tab.leftWidget ? tab.leftWidget->size() : QSize();
- optionV3->rightButtonSize = tab.rightWidget ? tab.rightWidget->size() : QSize();
- optionV3->documentMode = d->documentMode;
- }
+ option->leftButtonSize = tab.leftWidget ? tab.leftWidget->size() : QSize();
+ option->rightButtonSize = tab.rightWidget ? tab.rightWidget->size() : QSize();
+ option->documentMode = d->documentMode;
if (tabIndex > 0 && tabIndex - 1 == d->currentIndex)
option->selectedPosition = QStyleOptionTab::PreviousIsSelected;
@@ -600,7 +595,7 @@ void QTabBarPrivate::layoutTab(int index)
if (!(tab.leftWidget || tab.rightWidget))
return;
- QStyleOptionTabV3 opt;
+ QStyleOptionTab opt;
q->initStyleOption(&opt, index);
if (tab.leftWidget) {
QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);
@@ -778,7 +773,7 @@ void QTabBar::setShape(Shape shape)
If true then QTabBar draws a base in relation to the styles overlab.
Otherwise only the tabs are drawn.
- \sa QStyle::pixelMetric(), QStyle::PM_TabBarBaseOverlap, QStyleOptionTabBarBaseV2
+ \sa QStyle::pixelMetric(), QStyle::PM_TabBarBaseOverlap, QStyleOptionTabBarBase
*/
void QTabBar::setDrawBase(bool drawBase)
@@ -857,7 +852,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
++d->currentIndex;
if (d->closeButtonOnTabs) {
- QStyleOptionTabV3 opt;
+ QStyleOptionTab opt;
initStyleOption(&opt, index);
ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);
QAbstractButton *closeButton = new CloseButton(this);
@@ -1363,7 +1358,7 @@ QSize QTabBar::tabSizeHint(int index) const
//Note: this must match with the computations in QCommonStylePrivate::tabLayout
Q_D(const QTabBar);
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
- QStyleOptionTabV3 opt;
+ QStyleOptionTab opt;
initStyleOption(&opt, index);
opt.text = d->tabList.at(index).text;
QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize;
@@ -1571,7 +1566,7 @@ void QTabBar::paintEvent(QPaintEvent *)
{
Q_D(QTabBar);
- QStyleOptionTabBarBaseV2 optTabBase;
+ QStyleOptionTabBarBase optTabBase;
QTabBarPrivate::initStyleBaseOption(&optTabBase, this, size());
QStylePainter p(this);
@@ -1593,7 +1588,7 @@ void QTabBar::paintEvent(QPaintEvent *)
p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
for (int i = 0; i < d->tabList.count(); ++i) {
- QStyleOptionTabV3 tab;
+ QStyleOptionTab tab;
initStyleOption(&tab, i);
if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) {
if (vertical) {
@@ -1626,7 +1621,7 @@ void QTabBar::paintEvent(QPaintEvent *)
// Draw the selected tab last to get it "on top"
if (selected >= 0) {
- QStyleOptionTabV3 tab;
+ QStyleOptionTab tab;
initStyleOption(&tab, selected);
if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) {
if (vertical)
@@ -1806,7 +1801,7 @@ void QTabBar::mousePressEvent(QMouseEvent *event)
d->previousPressedIndex = d->pressedIndex;
#endif
if (d->validIndex(d->pressedIndex)) {
- QStyleOptionTabBarBaseV2 optTabBase;
+ QStyleOptionTabBarBase optTabBase;
optTabBase.init(this);
optTabBase.documentMode = d->documentMode;
if (event->type() == style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this))
@@ -1902,7 +1897,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
event->ignore();
return;
}
- QStyleOptionTabBarBaseV2 optTabBase;
+ QStyleOptionTabBarBase optTabBase;
optTabBase.init(this);
optTabBase.documentMode = d->documentMode;
}
@@ -1922,7 +1917,7 @@ void QTabBarPrivate::setupMovableTab()
QStylePainter p(&grabImage, q);
p.initFrom(q);
- QStyleOptionTabV3 tab;
+ QStyleOptionTab tab;
q->initStyleOption(&tab, pressedIndex);
tab.rect.moveTopLeft(QPoint(taboverlap, 0));
p.drawControl(QStyle::CE_TabBarTab, tab);
@@ -2006,7 +2001,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
int i = d->indexAtPos(event->pos()) == d->pressedIndex ? d->pressedIndex : -1;
d->pressedIndex = -1;
- QStyleOptionTabBarBaseV2 optTabBase;
+ QStyleOptionTabBarBase optTabBase;
optTabBase.initFrom(this);
optTabBase.documentMode = d->documentMode;
if (style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this) == QEvent::MouseButtonRelease)
diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h
index 6d8bdb0c86..94a83142b0 100644
--- a/src/widgets/widgets/qtabbar.h
+++ b/src/widgets/widgets/qtabbar.h
@@ -65,7 +65,7 @@ class Q_WIDGETS_EXPORT QTabBar: public QWidget
Q_PROPERTY(bool changeCurrentOnDrag READ changeCurrentOnDrag WRITE setChangeCurrentOnDrag)
public:
- explicit QTabBar(QWidget* parent=0);
+ explicit QTabBar(QWidget *parent = Q_NULLPTR);
~QTabBar();
enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index d5a59b05ad..38a3c138cc 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -206,7 +206,7 @@ public:
int previousPressedIndex;
#endif
// shared by tabwidget and qtabbar
- static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
+ static void initStyleBaseOption(QStyleOptionTabBarBase *optTabBase, QTabBar *tabbar, QSize size)
{
QStyleOptionTab tabOverlap;
tabOverlap.shape = tabbar->shape();
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index 1edb548206..0379bad723 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -331,13 +331,11 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const
option->tabBarSize = t;
- if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(option)) {
- QRect tbRect = tabBar()->geometry();
- QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex());
- tabframe->tabBarRect = tbRect;
- selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft());
- tabframe->selectedTabRect = selectedTabRect;
- }
+ QRect tbRect = tabBar()->geometry();
+ QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex());
+ option->tabBarRect = tbRect;
+ selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft());
+ option->selectedTabRect = selectedTabRect;
}
/*!
@@ -768,7 +766,7 @@ void QTabWidget::setUpLayout(bool onlyCheck)
if (onlyCheck && !d->dirty)
return; // nothing to do
- QStyleOptionTabWidgetFrameV2 option;
+ QStyleOptionTabWidgetFrame option;
initStyleOption(&option);
// this must be done immediately, because QWidgetItem relies on it (even if !isVisible())
@@ -817,7 +815,7 @@ QSize QTabWidget::sizeHint() const
{
Q_D(const QTabWidget);
QSize lc(0, 0), rc(0, 0);
- QStyleOptionTabWidgetFrameV2 opt;
+ QStyleOptionTabWidgetFrame opt;
initStyleOption(&opt);
opt.state = QStyle::State_None;
@@ -866,7 +864,7 @@ QSize QTabWidget::minimumSizeHint() const
QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);
- QStyleOptionTabWidgetFrameV2 opt;
+ QStyleOptionTabWidgetFrame opt;
initStyleOption(&opt);
opt.palette = palette();
opt.state = QStyle::State_None;
@@ -880,7 +878,7 @@ QSize QTabWidget::minimumSizeHint() const
int QTabWidget::heightForWidth(int width) const
{
Q_D(const QTabWidget);
- QStyleOptionTabWidgetFrameV2 opt;
+ QStyleOptionTabWidgetFrame opt;
initStyleOption(&opt);
opt.state = QStyle::State_None;
@@ -1226,14 +1224,14 @@ void QTabWidget::paintEvent(QPaintEvent *)
if (documentMode()) {
QStylePainter p(this, tabBar());
if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) {
- QStyleOptionTabBarBaseV2 opt;
+ QStyleOptionTabBarBase opt;
QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size());
opt.rect.moveLeft(w->x() + opt.rect.x());
opt.rect.moveTop(w->y() + opt.rect.y());
p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt);
}
if (QWidget *w = cornerWidget(Qt::TopRightCorner)) {
- QStyleOptionTabBarBaseV2 opt;
+ QStyleOptionTabBarBase opt;
QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size());
opt.rect.moveLeft(w->x() + opt.rect.x());
opt.rect.moveTop(w->y() + opt.rect.y());
@@ -1243,7 +1241,7 @@ void QTabWidget::paintEvent(QPaintEvent *)
}
QStylePainter p(this);
- QStyleOptionTabWidgetFrameV2 opt;
+ QStyleOptionTabWidgetFrame opt;
initStyleOption(&opt);
opt.rect = d->panelRect;
p.drawPrimitive(QStyle::PE_FrameTabWidget, opt);
diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h
index 702563127d..f12d584475 100644
--- a/src/widgets/widgets/qtabwidget.h
+++ b/src/widgets/widgets/qtabwidget.h
@@ -62,7 +62,7 @@ class Q_WIDGETS_EXPORT QTabWidget : public QWidget
Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide WRITE setTabBarAutoHide)
public:
- explicit QTabWidget(QWidget *parent = 0);
+ explicit QTabWidget(QWidget *parent = Q_NULLPTR);
~QTabWidget();
int addTab(QWidget *widget, const QString &);
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 9bf305a055..2c073342b0 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -139,6 +139,7 @@ public:
int lastKeypadScrollValue;
#endif
};
+Q_DECLARE_TYPEINFO(QTextBrowserPrivate::HistoryEntry, Q_MOVABLE_TYPE);
QString QTextBrowserPrivate::findFile(const QUrl &name) const
{
diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h
index 4d4d9f4880..339814e948 100644
--- a/src/widgets/widgets/qtextbrowser.h
+++ b/src/widgets/widgets/qtextbrowser.h
@@ -57,7 +57,7 @@ class Q_WIDGETS_EXPORT QTextBrowser : public QTextEdit
Q_PROPERTY(bool openLinks READ openLinks WRITE setOpenLinks)
public:
- explicit QTextBrowser(QWidget* parent = 0);
+ explicit QTextBrowser(QWidget* parent = Q_NULLPTR);
virtual ~QTextBrowser();
QUrl source() const;
diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h
index 689f45bea9..88b7444daa 100644
--- a/src/widgets/widgets/qtextedit.h
+++ b/src/widgets/widgets/qtextedit.h
@@ -94,8 +94,8 @@ public:
Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)
- explicit QTextEdit(QWidget *parent = 0);
- explicit QTextEdit(const QString &text, QWidget *parent = 0);
+ explicit QTextEdit(QWidget *parent = Q_NULLPTR);
+ explicit QTextEdit(const QString &text, QWidget *parent = Q_NULLPTR);
virtual ~QTextEdit();
void setDocument(QTextDocument *document);
@@ -153,9 +153,9 @@ public:
QTextOption::WrapMode wordWrapMode() const;
void setWordWrapMode(QTextOption::WrapMode policy);
- bool find(const QString &exp, QTextDocument::FindFlags options = 0);
+ bool find(const QString &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#ifndef QT_NO_REGEXP
- bool find(const QRegExp &exp, QTextDocument::FindFlags options = 0);
+ bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
QString toPlainText() const;
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index ecba6f1974..1e4a39088c 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -793,6 +793,82 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
return action;
}
+/*!\fn QAction *QToolBar::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method)
+
+ \since 5.6
+
+ \overload
+
+ Creates a new action with the given \a text. This action is added to
+ the end of the toolbar. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a method of the \a receiver.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QString &text, Functor functor)
+
+ \since 5.6
+
+ \overload
+
+ Creates a new action with the given \a text. This action is added to
+ the end of the toolbar. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QString &text, const QObject *context, Functor functor)
+
+ \since 5.6
+
+ \overload
+
+ Creates a new action with the given \a text. This action is added to
+ the end of the toolbar. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor.
+
+ If \a context is destroyed, the functor will not be called.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method)
+
+ \since 5.6
+
+ \overload
+
+ Creates a new action with the given \a icon and \a text. This
+ action is added to the end of the toolbar. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a method of the \a receiver.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)
+
+ \since 5.6
+
+ \overload
+
+ Creates a new action with the given \a icon and \a text. This
+ action is added to the end of the toolbar. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor.
+*/
+
+/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor)
+
+ \since 5.6
+
+ \overload
+
+ Creates a new action with the given \a icon and \a text. This
+ action is added to the end of the toolbar. The action's
+ \l{QAction::triggered()}{triggered()} signal is connected to the
+ \a functor.
+
+ If \a context is destroyed, the functor will not be called.
+*/
+
/*!
Adds a separator to the end of the toolbar.
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index f925577646..9eeb7ccd71 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -34,6 +34,7 @@
#ifndef QDYNAMICTOOLBAR_H
#define QDYNAMICTOOLBAR_H
+#include <QtWidgets/qaction.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
@@ -68,8 +69,8 @@ class Q_WIDGETS_EXPORT QToolBar : public QWidget
Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable)
public:
- explicit QToolBar(const QString &title, QWidget *parent = 0);
- explicit QToolBar(QWidget *parent = 0);
+ explicit QToolBar(const QString &title, QWidget *parent = Q_NULLPTR);
+ explicit QToolBar(QWidget *parent = Q_NULLPTR);
~QToolBar();
void setMovable(bool movable);
@@ -92,6 +93,51 @@ public:
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
QAction *addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member);
+#ifdef Q_QDOC
+ QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method);
+ QAction *addAction(const QString &text, Functor functor);
+ QAction *addAction(const QString &text, const QObject *context, Functor functor);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method);
+ QAction *addAction(const QIcon &icon, const QString &text, Functor functor);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor);
+#else
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QString &text, const Obj *object, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QString &text, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<class Obj, typename Func1>
+ inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
+ {
+ QAction *result = addAction(actionIcon, text);
+ connect(result, &QAction::triggered, object, slot);
+ return result;
+ }
+ // addAction(QIcon, QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot)
+ {
+ QAction *result = addAction(actionIcon, text);
+ connect(result, &QAction::triggered, slot);
+ return result;
+ }
+#endif // !Q_QDOC
QAction *addSeparator();
QAction *insertSeparator(QAction *before);
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index 89e3da1383..16b1115dd6 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -1129,7 +1129,7 @@ QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path)
{
QToolBarAreaLayoutItem *item = this->item(path);
if (!item) {
- qWarning() << Q_FUNC_INFO << "No item at" << path;
+ qWarning() << "No item at" << path;
return 0;
}
Q_ASSERT(item->gap);
diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index d478b028a6..42fd93fda2 100644
--- a/src/widgets/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
@@ -153,7 +153,7 @@ void QToolBarLayout::checkUsePopupMenu()
void QToolBarLayout::addItem(QLayoutItem*)
{
- qWarning() << "QToolBarLayout::addItem(): please use addAction() instead";
+ qWarning("QToolBarLayout::addItem(): please use addAction() instead");
return;
}
diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp
index 32fcdc3665..beb70f1283 100644
--- a/src/widgets/widgets/qtoolbox.cpp
+++ b/src/widgets/widgets/qtoolbox.cpp
@@ -206,26 +206,24 @@ void QToolBoxButton::initStyleOption(QStyleOptionToolBox *option) const
option->text = text();
option->icon = icon();
- if (QStyleOptionToolBoxV2 *optionV2 = qstyleoption_cast<QStyleOptionToolBoxV2 *>(option)) {
- QToolBox *toolBox = static_cast<QToolBox *>(parentWidget()); // I know I'm in a tool box.
- int widgetCount = toolBox->count();
- int currIndex = toolBox->currentIndex();
- if (widgetCount == 1) {
- optionV2->position = QStyleOptionToolBoxV2::OnlyOneTab;
- } else if (indexInPage == 0) {
- optionV2->position = QStyleOptionToolBoxV2::Beginning;
- } else if (indexInPage == widgetCount - 1) {
- optionV2->position = QStyleOptionToolBoxV2::End;
- } else {
- optionV2->position = QStyleOptionToolBoxV2::Middle;
- }
- if (currIndex == indexInPage - 1) {
- optionV2->selectedPosition = QStyleOptionToolBoxV2::PreviousIsSelected;
- } else if (currIndex == indexInPage + 1) {
- optionV2->selectedPosition = QStyleOptionToolBoxV2::NextIsSelected;
- } else {
- optionV2->selectedPosition = QStyleOptionToolBoxV2::NotAdjacent;
- }
+ QToolBox *toolBox = static_cast<QToolBox *>(parentWidget()); // I know I'm in a tool box.
+ const int widgetCount = toolBox->count();
+ const int currIndex = toolBox->currentIndex();
+ if (widgetCount == 1) {
+ option->position = QStyleOptionToolBox::OnlyOneTab;
+ } else if (indexInPage == 0) {
+ option->position = QStyleOptionToolBox::Beginning;
+ } else if (indexInPage == widgetCount - 1) {
+ option->position = QStyleOptionToolBox::End;
+ } else {
+ option->position = QStyleOptionToolBox::Middle;
+ }
+ if (currIndex == indexInPage - 1) {
+ option->selectedPosition = QStyleOptionToolBox::PreviousIsSelected;
+ } else if (currIndex == indexInPage + 1) {
+ option->selectedPosition = QStyleOptionToolBox::NextIsSelected;
+ } else {
+ option->selectedPosition = QStyleOptionToolBox::NotAdjacent;
}
}
@@ -233,7 +231,7 @@ void QToolBoxButton::paintEvent(QPaintEvent *)
{
QPainter paint(this);
QPainter *p = &paint;
- QStyleOptionToolBoxV2 opt;
+ QStyleOptionToolBox opt;
initStyleOption(&opt);
style()->drawControl(QStyle::CE_ToolBoxTab, &opt, p, parentWidget());
}
diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h
index cff5ae09ae..42b06e205c 100644
--- a/src/widgets/widgets/qtoolbox.h
+++ b/src/widgets/widgets/qtoolbox.h
@@ -51,7 +51,7 @@ class Q_WIDGETS_EXPORT QToolBox : public QFrame
Q_PROPERTY(int count READ count)
public:
- explicit QToolBox(QWidget *parent = 0, Qt::WindowFlags f = 0);
+ explicit QToolBox(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
~QToolBox();
int addItem(QWidget *widget, const QString &text);
diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h
index 69ad032324..c76f58577b 100644
--- a/src/widgets/widgets/qtoolbutton.h
+++ b/src/widgets/widgets/qtoolbutton.h
@@ -64,7 +64,7 @@ public:
};
Q_ENUM(ToolButtonPopupMode)
- explicit QToolButton(QWidget * parent=0);
+ explicit QToolButton(QWidget *parent = Q_NULLPTR);
~QToolButton();
QSize sizeHint() const Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 759e41a5fa..436937be72 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -189,7 +189,7 @@ void QWidgetLineControl::commitPreedit()
m_preeditCursor = 0;
setPreeditArea(-1, QString());
- m_textLayout.clearAdditionalFormats();
+ m_textLayout.clearFormats();
updateDisplayText(/*force*/ true);
#endif
}
@@ -557,7 +557,8 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
const int oldPreeditCursor = m_preeditCursor;
m_preeditCursor = event->preeditString().length();
m_hideCursor = false;
- QList<QTextLayout::FormatRange> formats;
+ QVector<QTextLayout::FormatRange> formats;
+ formats.reserve(event->attributes().size());
for (int i = 0; i < event->attributes().size(); ++i) {
const QInputMethodEvent::Attribute &a = event->attributes().at(i);
if (a.type == QInputMethodEvent::Cursor) {
@@ -574,7 +575,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
}
}
}
- m_textLayout.setAdditionalFormats(formats);
+ m_textLayout.setFormats(formats);
updateDisplayText(/*force*/ true);
if (cursorPositionChanged)
emitCursorPositionChanged();
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 72007ac3e8..deca002bf5 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -883,7 +883,8 @@ void QWidgetTextControl::setTextCursor(const QTextCursor &cursor)
const bool posChanged = cursor.position() != d->cursor.position();
const QTextCursor oldSelection = d->cursor;
d->cursor = cursor;
- d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
+ d->cursorOn = d->hasFocus
+ && (d->interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
d->_q_updateCurrentCharFormatAndSelection();
ensureCursorVisible();
d->repaintOldAndNewSelection(oldSelection);
@@ -2028,7 +2029,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
QTextLayout *layout = block.layout();
if (isGettingInput)
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
- QList<QTextLayout::FormatRange> overrides;
+ QVector<QTextLayout::FormatRange> overrides;
+ overrides.reserve(e->attributes().size());
const int oldPreeditCursor = preeditCursor;
preeditCursor = e->preeditString().length();
hideCursor = false;
@@ -2048,7 +2050,7 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
}
- layout->setAdditionalFormats(overrides);
+ layout->setFormats(overrides);
cursor.endEditBlock();
@@ -2138,7 +2140,7 @@ void QWidgetTextControlPrivate::focusEvent(QFocusEvent *e)
#ifdef QT_KEYPAD_NAVIGATION
if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason))) {
#endif
- cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard);
+ cursorOn = (interactionFlags & (Qt::TextSelectableByKeyboard | Qt::TextEditable));
if (interactionFlags & Qt::TextEditable) {
setBlinkingCursorEnabled(true);
}
@@ -2437,10 +2439,13 @@ QList<QTextEdit::ExtraSelection> QWidgetTextControl::extraSelections() const
{
Q_D(const QWidgetTextControl);
QList<QTextEdit::ExtraSelection> selections;
- for (int i = 0; i < d->extraSelections.count(); ++i) {
+ const int numExtraSelections = d->extraSelections.count();
+ selections.reserve(numExtraSelections);
+ for (int i = 0; i < numExtraSelections; ++i) {
QTextEdit::ExtraSelection sel;
- sel.cursor = d->extraSelections.at(i).cursor;
- sel.format = d->extraSelections.at(i).format;
+ const QAbstractTextDocumentLayout::Selection &sel2 = d->extraSelections.at(i);
+ sel.cursor = sel2.cursor;
+ sel.format = sel2.format;
selections.append(sel);
}
return selections;
@@ -2877,7 +2882,7 @@ void QWidgetTextControlPrivate::commitPreedit()
QTextBlock block = cursor.block();
QTextLayout *layout = block.layout();
layout->setPreeditArea(-1, QString());
- layout->clearAdditionalFormats();
+ layout->clearFormats();
cursor.endEditBlock();
}