summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/Qt5WidgetsConfigExtras.cmake.in11
-rw-r--r--src/widgets/Qt5WidgetsMacros.cmake14
-rw-r--r--src/widgets/accessible/complexwidgets.cpp18
-rw-r--r--src/widgets/accessible/itemviews.cpp50
-rw-r--r--src/widgets/accessible/qaccessiblemenu.cpp14
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp4
-rw-r--r--src/widgets/accessible/qaccessiblewidgetfactory.cpp6
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp28
-rw-r--r--src/widgets/accessible/simplewidgets.cpp19
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp22
-rw-r--r--src/widgets/dialogs/qdialog.cpp16
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp10
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp48
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp14
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h2
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp22
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp10
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp62
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp24
-rw-r--r--src/widgets/dialogs/qsidebar.cpp8
-rw-r--r--src/widgets/dialogs/qwizard.cpp46
-rw-r--r--src/widgets/doc/snippets/code/doc_src_layout.cpp53
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp17
-rw-r--r--src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp2
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp9
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp5
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp3
-rw-r--r--src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp8
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp2
-rw-r--r--src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp4
-rw-r--r--src/widgets/doc/snippets/javastyle.cpp6
-rw-r--r--src/widgets/doc/snippets/qsplashscreen/main.cpp7
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/layout.qdoc2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc17
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp2
-rw-r--r--src/widgets/effects/qpixmapfilter.cpp18
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp50
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp109
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslayout_p.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp12
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp68
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp165
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.h1
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.cpp23
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp65
-rw-r--r--src/widgets/graphicsview/qgraphicsview.h8
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp24
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp8
-rw-r--r--src/widgets/graphicsview/qsimplex_p.cpp10
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp62
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp55
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp12
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip.cpp2
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip_p.h2
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.cpp8
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp26
-rw-r--r--src/widgets/itemviews/qdirmodel.h11
-rw-r--r--src/widgets/itemviews/qheaderview.cpp20
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp40
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp48
-rw-r--r--src/widgets/itemviews/qlistview.cpp14
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp46
-rw-r--r--src/widgets/itemviews/qlistwidget.h6
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp20
-rw-r--r--src/widgets/itemviews/qtableview.cpp2
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp68
-rw-r--r--src/widgets/itemviews/qtablewidget.h6
-rw-r--r--src/widgets/itemviews/qtreeview.cpp18
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp71
-rw-r--r--src/widgets/itemviews/qtreewidget.h6
-rw-r--r--src/widgets/itemviews/qtreewidgetitemiterator.cpp16
-rw-r--r--src/widgets/kernel/qaction.cpp2
-rw-r--r--src/widgets/kernel/qaction.h2
-rw-r--r--src/widgets/kernel/qactiongroup.cpp6
-rw-r--r--src/widgets/kernel/qapplication.cpp396
-rw-r--r--src/widgets/kernel/qapplication.h4
-rw-r--r--src/widgets/kernel/qapplication_p.h10
-rw-r--r--src/widgets/kernel/qboxlayout.cpp22
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp2
-rw-r--r--src/widgets/kernel/qformlayout.cpp102
-rw-r--r--src/widgets/kernel/qgesture.cpp4
-rw-r--r--src/widgets/kernel/qgesture_p.h3
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp25
-rw-r--r--src/widgets/kernel/qgridlayout.cpp28
-rw-r--r--src/widgets/kernel/qlayout.cpp44
-rw-r--r--src/widgets/kernel/qlayout_p.h2
-rw-r--r--src/widgets/kernel/qlayoutengine.cpp13
-rw-r--r--src/widgets/kernel/qlayoutengine_p.h6
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp20
-rw-r--r--src/widgets/kernel/qlayoutitem.h8
-rw-r--r--src/widgets/kernel/qmacgesturerecognizer.cpp4
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp26
-rw-r--r--src/widgets/kernel/qshortcut.cpp76
-rw-r--r--src/widgets/kernel/qshortcut.h60
-rw-r--r--src/widgets/kernel/qsizepolicy.cpp2
-rw-r--r--src/widgets/kernel/qstackedlayout.cpp14
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp4
-rw-r--r--src/widgets/kernel/qtooltip.cpp16
-rw-r--r--src/widgets/kernel/qwhatsthis.cpp16
-rw-r--r--src/widgets/kernel/qwidget.cpp198
-rw-r--r--src/widgets/kernel/qwidget.h12
-rw-r--r--src/widgets/kernel/qwidget_p.h4
-rw-r--r--src/widgets/kernel/qwidgetaction.cpp8
-rw-r--r--src/widgets/kernel/qwidgetrepaintmanager.cpp16
-rw-r--r--src/widgets/kernel/qwidgetsvariant.cpp18
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp34
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp10
-rw-r--r--src/widgets/kernel/qwindowcontainer_p.h2
-rw-r--r--src/widgets/kernel/win.pri1
-rw-r--r--src/widgets/statemachine/qguistatemachine.cpp2
-rw-r--r--src/widgets/styles/qcommonstyle.cpp43
-rw-r--r--src/widgets/styles/qcommonstyle_p.h2
-rw-r--r--src/widgets/styles/qdrawutil.cpp20
-rw-r--r--src/widgets/styles/qfusionstyle.cpp12
-rw-r--r--src/widgets/styles/qproxystyle.cpp6
-rw-r--r--src/widgets/styles/qstyle.cpp10
-rw-r--r--src/widgets/styles/qstyle.h2
-rw-r--r--src/widgets/styles/qstylefactory.cpp2
-rw-r--r--src/widgets/styles/qstylehelper.cpp2
-rw-r--r--src/widgets/styles/qstyleoption.cpp26
-rw-r--r--src/widgets/styles/qstyleoption.h8
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp212
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp19
-rw-r--r--src/widgets/styles/qwindowsstyle_p_p.h1
-rw-r--r--src/widgets/util/qcolormap.cpp4
-rw-r--r--src/widgets/util/qcompleter.cpp12
-rw-r--r--src/widgets/util/qflickgesture.cpp38
-rw-r--r--src/widgets/util/qscroller.cpp10
-rw-r--r--src/widgets/util/qscrollerproperties.cpp12
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp10
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp4
-rw-r--r--src/widgets/util/qundogroup.cpp26
-rw-r--r--src/widgets/util/qundostack.cpp18
-rw-r--r--src/widgets/util/qundoview.cpp42
-rw-r--r--src/widgets/widgets.pro2
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp34
-rw-r--r--src/widgets/widgets/qabstractbutton.h2
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp28
-rw-r--r--src/widgets/widgets/qabstractslider.cpp4
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp82
-rw-r--r--src/widgets/widgets/qabstractspinbox_p.h2
-rw-r--r--src/widgets/widgets/qbuttongroup.cpp10
-rw-r--r--src/widgets/widgets/qbuttongroup.h12
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp44
-rw-r--r--src/widgets/widgets/qcombobox.cpp216
-rw-r--r--src/widgets/widgets/qcombobox.h4
-rw-r--r--src/widgets/widgets/qcombobox_p.h89
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp51
-rw-r--r--src/widgets/widgets/qdatetimeedit.h3
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp26
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp234
-rw-r--r--src/widgets/widgets/qdockwidget.cpp95
-rw-r--r--src/widgets/widgets/qdockwidget_p.h4
-rw-r--r--src/widgets/widgets/qeffects.cpp16
-rw-r--r--src/widgets/widgets/qfocusframe.cpp20
-rw-r--r--src/widgets/widgets/qgroupbox.cpp6
-rw-r--r--src/widgets/widgets/qgroupbox.h2
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp2
-rw-r--r--src/widgets/widgets/qlabel.cpp78
-rw-r--r--src/widgets/widgets/qlabel.h20
-rw-r--r--src/widgets/widgets/qlcdnumber.cpp6
-rw-r--r--src/widgets/widgets/qlineedit.cpp20
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp6
-rw-r--r--src/widgets/widgets/qlineedit_p.h2
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm2
-rw-r--r--src/widgets/widgets/qmainwindow.cpp16
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp88
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h2
-rw-r--r--src/widgets/widgets/qmdiarea.cpp72
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp98
-rw-r--r--src/widgets/widgets/qmenu.cpp338
-rw-r--r--src/widgets/widgets/qmenu_p.h6
-rw-r--r--src/widgets/widgets/qmenubar.cpp127
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp30
-rw-r--r--src/widgets/widgets/qprogressbar.cpp2
-rw-r--r--src/widgets/widgets/qpushbutton.cpp17
-rw-r--r--src/widgets/widgets/qpushbutton.h1
-rw-r--r--src/widgets/widgets/qscrollarea.cpp6
-rw-r--r--src/widgets/widgets/qscrollarea_p.h2
-rw-r--r--src/widgets/widgets/qscrollbar.cpp18
-rw-r--r--src/widgets/widgets/qsizegrip.cpp20
-rw-r--r--src/widgets/widgets/qspinbox.cpp4
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp44
-rw-r--r--src/widgets/widgets/qsplashscreen.h4
-rw-r--r--src/widgets/widgets/qsplitter.cpp6
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp2
-rw-r--r--src/widgets/widgets/qstatusbar.cpp24
-rw-r--r--src/widgets/widgets/qtabbar.cpp232
-rw-r--r--src/widgets/widgets/qtabbar.h3
-rw-r--r--src/widgets/widgets/qtabbar_p.h13
-rw-r--r--src/widgets/widgets/qtabwidget.cpp64
-rw-r--r--src/widgets/widgets/qtabwidget.h3
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp41
-rw-r--r--src/widgets/widgets/qtextbrowser.h3
-rw-r--r--src/widgets/widgets/qtextedit.cpp26
-rw-r--r--src/widgets/widgets/qtoolbar.cpp64
-rw-r--r--src/widgets/widgets/qtoolbar.h12
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp40
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp38
-rw-r--r--src/widgets/widgets/qtoolbox.cpp16
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp81
-rw-r--r--src/widgets/widgets/qwidgetanimator.cpp2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp4
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp52
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h8
213 files changed, 3520 insertions, 2727 deletions
diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
index 99d87e2e46..236d1d4159 100644
--- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in
+++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in
@@ -17,3 +17,14 @@ endif()
include(\"${CMAKE_CURRENT_LIST_DIR}/Qt5Widgets_AccessibleFactory.cmake\" OPTIONAL)
set(Qt5Widgets_UIC_EXECUTABLE Qt5::uic)
+
+# Create versionless tool targets.
+foreach(__qt_tool uic)
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool}
+ AND TARGET Qt5::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+ get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION)
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\")
+ endif()
+endforeach()
diff --git a/src/widgets/Qt5WidgetsMacros.cmake b/src/widgets/Qt5WidgetsMacros.cmake
index 737371a5ad..35d2a2dc54 100644
--- a/src/widgets/Qt5WidgetsMacros.cmake
+++ b/src/widgets/Qt5WidgetsMacros.cmake
@@ -41,7 +41,7 @@ include(CMakeParseArguments)
# qt5_wrap_ui(outfiles inputfile ... )
-function(QT5_WRAP_UI outfiles )
+function(qt5_wrap_ui outfiles )
set(options)
set(oneValueArgs)
set(multiValueArgs OPTIONS)
@@ -66,3 +66,15 @@ function(QT5_WRAP_UI outfiles )
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+
+# This will override the CMake upstream command, because that one is for Qt 3.
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_wrap_ui outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_wrap_ui("${outfiles}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_wrap_ui("${outfiles}" ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp
index 5c993262bf..ce2ceac938 100644
--- a/src/widgets/accessible/complexwidgets.cpp
+++ b/src/widgets/accessible/complexwidgets.cpp
@@ -97,10 +97,10 @@ public:
if (t == QAccessible::ActionInterface) {
return static_cast<QAccessibleActionInterface*>(this);
}
- return 0;
+ return nullptr;
}
- QObject *object() const override { return 0; }
+ QObject *object() const override { return nullptr; }
QAccessible::Role role() const override { return QAccessible::PageTab; }
QAccessible::State state() const override {
if (!isValid()) {
@@ -132,7 +132,7 @@ public:
return false;
}
- QAccessibleInterface *childAt(int, int) const override { return 0; }
+ QAccessibleInterface *childAt(int, int) const override { return nullptr; }
int childCount() const override { return 0; }
int indexOfChild(const QAccessibleInterface *) const override { return -1; }
@@ -171,7 +171,7 @@ public:
QAccessibleInterface *parent() const override {
return QAccessible::queryAccessibleInterface(m_parent.data());
}
- QAccessibleInterface *child(int) const override { return 0; }
+ QAccessibleInterface *child(int) const override { return nullptr; }
// action interface
QStringList actionNames() const override
@@ -250,7 +250,7 @@ QAccessibleInterface* QAccessibleTabBar::child(int index) const
return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB);
}
}
- return 0;
+ return nullptr;
}
int QAccessibleTabBar::indexOfChild(const QAccessibleInterface *child) const
@@ -327,7 +327,7 @@ QAccessibleInterface *QAccessibleComboBox::child(int index) const
} else if (index == 1 && comboBox()->isEditable()) {
return QAccessible::queryAccessibleInterface(comboBox()->lineEdit());
}
- return 0;
+ return nullptr;
}
int QAccessibleComboBox::childCount() const
@@ -340,7 +340,7 @@ QAccessibleInterface *QAccessibleComboBox::childAt(int x, int y) const
{
if (comboBox()->isEditable() && comboBox()->lineEdit()->rect().contains(x, y))
return child(1);
- return 0;
+ return nullptr;
}
int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const
@@ -445,7 +445,7 @@ bool QAccessibleAbstractScrollArea::isValid() const
QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const
{
if (!abstractScrollArea()->isVisible())
- return 0;
+ return nullptr;
for (int i = 0; i < childCount(); ++i) {
QPoint wpos = accessibleChildren().at(i)->mapToGlobal(QPoint(0, 0));
@@ -453,7 +453,7 @@ QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const
if (rect.contains(x, y))
return child(i);
}
- return 0;
+ return nullptr;
}
QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index 3bfe215c05..5a7fdf9a03 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -121,7 +121,7 @@ QAccessibleTable::~QAccessibleTable()
QHeaderView *QAccessibleTable::horizontalHeader() const
{
- QHeaderView *header = 0;
+ QHeaderView *header = nullptr;
if (false) {
#if QT_CONFIG(tableview)
} else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) {
@@ -137,7 +137,7 @@ QHeaderView *QAccessibleTable::horizontalHeader() const
QHeaderView *QAccessibleTable::verticalHeader() const
{
- QHeaderView *header = 0;
+ QHeaderView *header = nullptr;
if (false) {
#if QT_CONFIG(tableview)
} else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) {
@@ -150,19 +150,19 @@ QHeaderView *QAccessibleTable::verticalHeader() const
QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const
{
if (!view()->model())
- return 0;
+ return nullptr;
Q_ASSERT(role() != QAccessible::Tree);
QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
if (Q_UNLIKELY(!index.isValid())) {
qWarning() << "QAccessibleTable::cellAt: invalid index: " << index << " for " << view();
- return 0;
+ return nullptr;
}
return child(logicalIndex(index));
}
QAccessibleInterface *QAccessibleTable::caption() const
{
- return 0;
+ return nullptr;
}
QString QAccessibleTable::columnDescription(int column) const
@@ -254,7 +254,7 @@ QList<int> QAccessibleTable::selectedRows() const
QAccessibleInterface *QAccessibleTable::summary() const
{
- return 0;
+ return nullptr;
}
bool QAccessibleTable::isColumnSelected(int column) const
@@ -422,7 +422,7 @@ QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const
if (index.isValid()) {
return child(logicalIndex(index));
}
- return 0;
+ return nullptr;
}
int QAccessibleTable::childCount() const
@@ -485,13 +485,13 @@ QAccessibleInterface *QAccessibleTable::parent() const
}
return QAccessible::queryAccessibleInterface(view()->parent());
}
- return 0;
+ return nullptr;
}
QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
{
if (!view()->model())
- return 0;
+ return nullptr;
auto id = childToId.constFind(logicalIndex);
if (id != childToId.constEnd())
@@ -505,7 +505,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
int row = logicalIndex / columns;
int column = logicalIndex % columns;
- QAccessibleInterface *iface = 0;
+ QAccessibleInterface *iface = nullptr;
if (vHeader) {
if (column == 0) {
@@ -528,7 +528,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
if (Q_UNLIKELY(!index.isValid())) {
qWarning("QAccessibleTable::child: Invalid index at: %d %d", row, column);
- return 0;
+ return nullptr;
}
iface = new QAccessibleTableCell(view(), index, cellRole());
}
@@ -542,7 +542,7 @@ void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::TableInterface)
return static_cast<QAccessibleTableInterface*>(this);
- return 0;
+ return nullptr;
}
void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event)
@@ -676,13 +676,13 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const
QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const
{
if (!view()->model())
- return 0;
+ return nullptr;
QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0));
QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset);
QModelIndex index = view()->indexAt(indexPosition);
if (!index.isValid())
- return 0;
+ return nullptr;
const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0);
@@ -706,9 +706,9 @@ int QAccessibleTree::childCount() const
QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const
{
if (logicalIndex < 0 || !view()->model() || !view()->model()->columnCount())
- return 0;
+ return nullptr;
- QAccessibleInterface *iface = 0;
+ QAccessibleInterface *iface = nullptr;
int index = logicalIndex;
if (horizontalHeader()) {
@@ -724,7 +724,7 @@ QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const
int column = index % view()->model()->columnCount();
QModelIndex modelIndex = indexFromLogical(row, column);
if (!modelIndex.isValid())
- return 0;
+ return nullptr;
iface = new QAccessibleTableCell(view(), modelIndex, cellRole());
}
QAccessible::registerAccessibleInterface(iface);
@@ -772,7 +772,7 @@ QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const
QModelIndex index = indexFromLogical(row, column);
if (Q_UNLIKELY(!index.isValid())) {
qWarning("Requested invalid tree cell: %d %d", row, column);
- return 0;
+ return nullptr;
}
const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
Q_ASSERT(treeView);
@@ -841,7 +841,7 @@ void *QAccessibleTableCell::interface_cast(QAccessible::InterfaceType t)
return static_cast<QAccessibleTableCellInterface*>(this);
if (t == QAccessible::ActionInterface)
return static_cast<QAccessibleActionInterface*>(this);
- return 0;
+ return nullptr;
}
int QAccessibleTableCell::columnExtent() const { return 1; }
@@ -869,7 +869,7 @@ QList<QAccessibleInterface*> QAccessibleTableCell::columnHeaderCells() const
QHeaderView *QAccessibleTableCell::horizontalHeader() const
{
- QHeaderView *header = 0;
+ QHeaderView *header = nullptr;
if (false) {
#if QT_CONFIG(tableview)
@@ -887,7 +887,7 @@ QHeaderView *QAccessibleTableCell::horizontalHeader() const
QHeaderView *QAccessibleTableCell::verticalHeader() const
{
- QHeaderView *header = 0;
+ QHeaderView *header = nullptr;
#if QT_CONFIG(tableview)
if (const QTableView *tv = qobject_cast<const QTableView*>(view))
header = tv->verticalHeader();
@@ -1115,7 +1115,7 @@ QAccessibleInterface *QAccessibleTableCell::parent() const
QAccessibleInterface *QAccessibleTableCell::child(int) const
{
- return 0;
+ return nullptr;
}
QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_)
@@ -1143,7 +1143,7 @@ QAccessible::State QAccessibleTableHeaderCell::state() const
QRect QAccessibleTableHeaderCell::rect() const
{
- QHeaderView *header = 0;
+ QHeaderView *header = nullptr;
if (false) {
#if QT_CONFIG(tableview)
} else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
@@ -1206,12 +1206,12 @@ QAccessibleInterface *QAccessibleTableHeaderCell::parent() const
QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const
{
- return 0;
+ return nullptr;
}
QHeaderView *QAccessibleTableHeaderCell::headerView() const
{
- QHeaderView *header = 0;
+ QHeaderView *header = nullptr;
if (false) {
#if QT_CONFIG(tableview)
} else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp
index 048d4062b8..99a9444ff1 100644
--- a/src/widgets/accessible/qaccessiblemenu.cpp
+++ b/src/widgets/accessible/qaccessiblemenu.cpp
@@ -88,8 +88,8 @@ QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const
{
QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y)));
if(act && act->isSeparator())
- act = 0;
- return act ? getOrCreateMenu(menu(), act) : 0;
+ act = nullptr;
+ return act ? getOrCreateMenu(menu(), act) : nullptr;
}
QString QAccessibleMenu::text(QAccessible::Text t) const
@@ -112,7 +112,7 @@ QAccessibleInterface *QAccessibleMenu::child(int index) const
{
if (index < childCount())
return getOrCreateMenu(menu(), menu()->actions().at(index));
- return 0;
+ return nullptr;
}
QAccessibleInterface *QAccessibleMenu::parent() const
@@ -165,7 +165,7 @@ QAccessibleInterface *QAccessibleMenuBar::child(int index) const
if (index < childCount()) {
return getOrCreateMenu(menuBar(), menuBar()->actions().at(index));
}
- return 0;
+ return nullptr;
}
int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const
@@ -195,7 +195,7 @@ QAccessibleInterface *QAccessibleMenuItem::childAt(int x, int y ) const
return childInterface;
}
}
- return 0;
+ return nullptr;
}
int QAccessibleMenuItem::childCount() const
@@ -224,14 +224,14 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const
{
if (index == 0 && action()->menu())
return QAccessible::queryAccessibleInterface(action()->menu());
- return 0;
+ return nullptr;
}
void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::ActionInterface)
return static_cast<QAccessibleActionInterface*>(this);
- return 0;
+ return nullptr;
}
QObject *QAccessibleMenuItem::object() const
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
index 3ab66c4ce4..68ad855c7c 100644
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -363,7 +363,7 @@ QAccessibleInterface *QAccessibleWidget::child(int index) const
QWidgetList childList = childWidgets(widget());
if (index >= 0 && index < childList.size())
return QAccessible::queryAccessibleInterface(childList.at(index));
- return 0;
+ return nullptr;
}
/*! \reimp */
@@ -526,7 +526,7 @@ void *QAccessibleWidget::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::ActionInterface)
return static_cast<QAccessibleActionInterface*>(this);
- return 0;
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp
index 0bac45de27..d59da86076 100644
--- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp
+++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *object)
{
- QAccessibleInterface *iface = 0;
+ QAccessibleInterface *iface = nullptr;
if (!object || !object->isWidgetType())
return iface;
@@ -79,7 +79,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
#if QT_CONFIG(lineedit)
} else if (classname == QLatin1String("QLineEdit")) {
if (widget->objectName() == QLatin1String("qt_spinbox_lineedit"))
- iface = 0;
+ iface = nullptr;
else
iface = new QAccessibleLineEdit(widget);
#endif
@@ -223,7 +223,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
#endif
} else if (classname == QLatin1String("QDesktopScreenWidget")) {
- iface = 0;
+ iface = nullptr;
} else if (classname == QLatin1String("QWidget")) {
iface = new QAccessibleWidget(widget);
} else if (classname == QLatin1String("QWindowContainer")) {
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index 52c953ed3a..574be1f5ea 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -332,14 +332,14 @@ QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget)
QAccessibleInterface *QAccessibleStackedWidget::childAt(int x, int y) const
{
if (!stackedWidget()->isVisible())
- return 0;
+ return nullptr;
QWidget *currentWidget = stackedWidget()->currentWidget();
if (!currentWidget)
- return 0;
+ return nullptr;
QPoint position = currentWidget->mapFromGlobal(QPoint(x, y));
if (currentWidget->rect().contains(position))
return child(stackedWidget()->currentIndex());
- return 0;
+ return nullptr;
}
int QAccessibleStackedWidget::childCount() const
@@ -359,7 +359,7 @@ int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) co
QAccessibleInterface *QAccessibleStackedWidget::child(int index) const
{
if (index < 0 || index >= stackedWidget()->count())
- return 0;
+ return nullptr;
return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index));
}
@@ -401,7 +401,7 @@ QAccessibleInterface *QAccessibleMdiArea::child(int index) const
QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList();
QWidget *targetObject = subWindows.value(index);
if (!targetObject)
- return 0;
+ return nullptr;
return QAccessible::queryAccessibleInterface(targetObject);
}
@@ -478,7 +478,7 @@ QAccessibleInterface *QAccessibleMdiSubWindow::child(int index) const
{
QMdiSubWindow *source = mdiSubWindow();
if (index != 0 || !source->widget())
- return 0;
+ return nullptr;
return QAccessible::queryAccessibleInterface(source->widget());
}
@@ -554,7 +554,7 @@ int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) c
QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const
{
if (index < 0 || index >= childCount())
- return 0;
+ return nullptr;
if (childCount() > 1 && index == 0)
return QAccessible::queryAccessibleInterface(navigationBar());
@@ -573,7 +573,7 @@ QAbstractItemView *QAccessibleCalendarWidget::calendarView() const
if (child->objectName() == QLatin1String("qt_calendar_calendarview"))
return static_cast<QAbstractItemView *>(child);
}
- return 0;
+ return nullptr;
}
QWidget *QAccessibleCalendarWidget::navigationBar() const
@@ -582,7 +582,7 @@ QWidget *QAccessibleCalendarWidget::navigationBar() const
if (child->objectName() == QLatin1String("qt_calendar_navigationbar"))
return static_cast<QWidget *>(child);
}
- return 0;
+ return nullptr;
}
#endif // QT_CONFIG(calendarwidget)
@@ -624,7 +624,7 @@ QAccessibleInterface *QAccessibleDockWidget::child(int index) const
if (item)
return QAccessible::queryAccessibleInterface(item->widget());
}
- return 0;
+ return nullptr;
}
int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const
@@ -1109,7 +1109,7 @@ QAccessibleInterface *QAccessibleMainWindow::child(int index) const
if (index >= 0 && index < kids.count()) {
return QAccessible::queryAccessibleInterface(kids.at(index));
}
- return 0;
+ return nullptr;
}
int QAccessibleMainWindow::childCount() const
@@ -1128,10 +1128,10 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const
{
QWidget *w = widget();
if (!w->isVisible())
- return 0;
+ return nullptr;
QPoint gp = w->mapToGlobal(QPoint(0, 0));
if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
- return 0;
+ return nullptr;
const QWidgetList kids = childWidgets(mainWindow());
QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y));
@@ -1140,7 +1140,7 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const
return QAccessible::queryAccessibleInterface(child);
}
}
- return 0;
+ return nullptr;
}
QMainWindow *QAccessibleMainWindow::mainWindow() const
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index ca74ee4b12..107fd729fe 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -76,6 +76,9 @@
#include <qlineedit.h>
#include <private/qlineedit_p.h>
#endif
+#ifndef QT_NO_PICTURE
+#include <QtGui/qpicture.h>
+#endif
#include <qstyle.h>
#include <qstyleoption.h>
#include <qtextdocument.h>
@@ -364,7 +367,7 @@ QAccessibleInterface *QAccessibleToolButton::child(int index) const
#else
Q_UNUSED(index)
#endif
- return 0;
+ return nullptr;
}
/*
@@ -431,10 +434,10 @@ QAccessible::Role QAccessibleDisplay::role() const
#if QT_CONFIG(label)
QLabel *l = qobject_cast<QLabel*>(object());
if (l) {
- if (l->pixmap())
+ if (!l->pixmap(Qt::ReturnByValue).isNull())
return QAccessible::Graphic;
#ifndef QT_NO_PICTURE
- if (l->picture())
+ if (!l->picture(Qt::ReturnByValue).isNull())
return QAccessible::Graphic;
#endif
#if QT_CONFIG(movie)
@@ -558,10 +561,7 @@ QSize QAccessibleDisplay::imageSize() const
#endif
return QSize();
#if QT_CONFIG(label)
- const QPixmap *pixmap = label->pixmap();
- if (!pixmap)
- return QSize();
- return pixmap->size();
+ return label->pixmap(Qt::ReturnByValue).size();
#endif
}
@@ -574,8 +574,7 @@ QPoint QAccessibleDisplay::imagePosition() const
#endif
return QPoint();
#if QT_CONFIG(label)
- const QPixmap *pixmap = label->pixmap();
- if (!pixmap)
+ if (label->pixmap(Qt::ReturnByValue).isNull())
return QPoint();
return QPoint(label->mapToGlobal(label->pos()));
@@ -976,7 +975,7 @@ QAccessibleInterface *QAccessibleWindowContainer::child(int i) const
{
if (i == 0)
return QAccessible::queryAccessibleInterface(container()->containedWindow());
- return 0;
+ return nullptr;
}
QWindowContainer *QAccessibleWindowContainer::container() const
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index d00a600424..689002b589 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -192,7 +192,7 @@ class QWellArray : public QWidget
Q_PROPERTY(int selectedRow READ selectedRow)
public:
- QWellArray(int rows, int cols, QWidget* parent=0);
+ QWellArray(int rows, int cols, QWidget* parent=nullptr);
~QWellArray() {}
QString cellContent(int row, int col) const;
@@ -744,7 +744,7 @@ class QColorLuminancePicker : public QWidget
{
Q_OBJECT
public:
- QColorLuminancePicker(QWidget* parent=0);
+ QColorLuminancePicker(QWidget* parent=nullptr);
~QColorLuminancePicker();
public slots:
@@ -789,7 +789,7 @@ QColorLuminancePicker::QColorLuminancePicker(QWidget* parent)
:QWidget(parent)
{
hue = 100; val = 100; sat = 100;
- pix = 0;
+ pix = nullptr;
// setAttribute(WA_NoErase, true);
}
@@ -812,7 +812,7 @@ void QColorLuminancePicker::setVal(int v)
if (val == v)
return;
val = qMax(0, qMin(v,255));
- delete pix; pix=0;
+ delete pix; pix=nullptr;
repaint();
emit newHsv(hue, sat, val);
}
@@ -861,7 +861,7 @@ void QColorLuminancePicker::setCol(int h, int s , int v)
val = v;
hue = h;
sat = s;
- delete pix; pix=0;
+ delete pix; pix=nullptr;
repaint();
}
@@ -1678,8 +1678,8 @@ void QColorDialogPrivate::init(const QColor &initial)
q->setWindowTitle(QColorDialog::tr("Select Color"));
// default: use the native dialog if possible. Can be overridden in setOptions()
- nativeDialogInUse = (platformColorDialogHelper() != 0);
- colorPickingEventFilter = 0;
+ nativeDialogInUse = (platformColorDialogHelper() != nullptr);
+ colorPickingEventFilter = nullptr;
nextCust = 0;
if (!nativeDialogInUse)
@@ -1703,7 +1703,7 @@ void QColorDialogPrivate::initWidgets()
QHBoxLayout *topLay = new QHBoxLayout();
mainLay->addLayout(topLay);
- leftLay = 0;
+ leftLay = nullptr;
#if defined(QT_SMALL_COLORDIALOG)
smallDisplay = true;
@@ -1773,8 +1773,8 @@ void QColorDialogPrivate::initWidgets()
pWidth = 150;
pHeight = 100;
#endif
- custom = 0;
- standard = 0;
+ custom = nullptr;
+ standard = nullptr;
}
QVBoxLayout *rightLay = new QVBoxLayout;
@@ -2302,7 +2302,7 @@ void QColorDialog::done(int result)
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(colorSelected(QColor)),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
+ d->receiverToDisconnectOnClose = nullptr;
}
d->memberToDisconnectOnClose.clear();
}
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 3cdd9a5f04..906022a185 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -187,7 +187,7 @@ QWindow *QDialogPrivate::transientParentWindow() const
return parent->windowHandle();
else if (q->windowHandle())
return q->windowHandle()->transientParent();
- return 0;
+ return nullptr;
}
bool QDialogPrivate::setNativeDialogVisible(bool visible)
@@ -214,7 +214,7 @@ QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const
void QDialogPrivate::deletePlatformHelper()
{
delete m_platformHelper;
- m_platformHelper = 0;
+ m_platformHelper = nullptr;
m_platformHelperCreated = false;
nativeDialogInUse = false;
}
@@ -460,7 +460,7 @@ void QDialogPrivate::setDefault(QPushButton *pushButton)
*/
void QDialogPrivate::setMainDefault(QPushButton *pushButton)
{
- mainDef = 0;
+ mainDef = nullptr;
setDefault(pushButton);
}
@@ -602,7 +602,7 @@ int QDialog::exec()
}
if (guard.isNull())
return QDialog::Rejected;
- d->eventLoop = 0;
+ d->eventLoop = nullptr;
setAttribute(Qt::WA_ShowModal, wasShowModal);
@@ -679,12 +679,12 @@ void QDialog::contextMenuEvent(QContextMenuEvent *e)
#else
QWidget *w = childAt(e->pos());
if (!w) {
- w = rect().contains(e->pos()) ? this : 0;
+ w = rect().contains(e->pos()) ? this : nullptr;
if (!w)
return;
}
while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis))
- w = w->isWindow() ? 0 : w->parentWidget();
+ w = w->isWindow() ? nullptr : w->parentWidget();
if (w) {
QPointer<QMenu> p = new QMenu(this);
QAction *wt = p.data()->addAction(tr("What's This?"));
@@ -920,7 +920,7 @@ void QDialog::adjustPosition(QWidget* w)
if (w) {
// Use pos() if the widget is embedded into a native window
QPoint pp;
- if (w->windowHandle() && w->windowHandle()->property("_q_embedded_native_parent_handle").value<WId>())
+ if (w->windowHandle() && qvariant_cast<WId>(w->windowHandle()->property("_q_embedded_native_parent_handle")))
pp = w->pos();
else
pp = w->mapToGlobal(QPoint(0,0));
@@ -1191,7 +1191,7 @@ void QDialog::setSizeGripEnabled(bool enabled)
d->resizer->show();
} else {
delete d->resizer;
- d->resizer = 0;
+ d->resizer = nullptr;
}
}
#endif // QT_CONFIG(sizegrip)
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index f0ec2c0102..790d09414b 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -149,13 +149,13 @@ QSize QErrorMessageTextView::sizeHint() const
\sa QMessageBox, QStatusBar::showMessage(), {Standard Dialogs Example}
*/
-static QErrorMessage * qtMessageHandler = 0;
+static QErrorMessage * qtMessageHandler = nullptr;
static void deleteStaticcQErrorMessage() // post-routine
{
if (qtMessageHandler) {
delete qtMessageHandler;
- qtMessageHandler = 0;
+ qtMessageHandler = nullptr;
}
}
@@ -252,8 +252,8 @@ QErrorMessage::QErrorMessage(QWidget * parent)
QErrorMessage::~QErrorMessage()
{
if (this == qtMessageHandler) {
- qtMessageHandler = 0;
- QtMessageHandler tmp = qInstallMessageHandler(0);
+ qtMessageHandler = nullptr;
+ QtMessageHandler tmp = qInstallMessageHandler(nullptr);
// in case someone else has later stuck in another...
if (tmp != jump)
qInstallMessageHandler(tmp);
@@ -293,7 +293,7 @@ void QErrorMessage::done(int a)
QErrorMessage * QErrorMessage::qtHandler()
{
if (!qtMessageHandler) {
- qtMessageHandler = new QErrorMessage(0);
+ qtMessageHandler = new QErrorMessage(nullptr);
qAddPostRoutine(deleteStaticcQErrorMessage); // clean up
qtMessageHandler->setWindowTitle(QCoreApplication::applicationName());
qInstallMessageHandler(jump);
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 787c0e6511..7c2c202cd6 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -370,7 +370,7 @@ QFileDialog::QFileDialog(QWidget *parent,
const QString &caption,
const QString &directory,
const QString &filter)
- : QDialog(*new QFileDialogPrivate, parent, 0)
+ : QDialog(*new QFileDialogPrivate, parent, { })
{
Q_D(QFileDialog);
d->init(QUrl::fromLocalFile(directory), filter, caption);
@@ -380,7 +380,7 @@ QFileDialog::QFileDialog(QWidget *parent,
\internal
*/
QFileDialog::QFileDialog(const QFileDialogArgs &args)
- : QDialog(*new QFileDialogPrivate, args.parent, 0)
+ : QDialog(*new QFileDialogPrivate, args.parent, { })
{
Q_D(QFileDialog);
d->init(args.directory, args.filter, args.caption);
@@ -531,15 +531,15 @@ void QFileDialog::changeEvent(QEvent *e)
QFileDialogPrivate::QFileDialogPrivate()
:
#if QT_CONFIG(proxymodel)
- proxyModel(0),
+ proxyModel(nullptr),
#endif
- model(0),
+ model(nullptr),
currentHistoryLocation(-1),
- renameAction(0),
- deleteAction(0),
- showHiddenAction(0),
+ renameAction(nullptr),
+ deleteAction(nullptr),
+ showHiddenAction(nullptr),
useDefaultCaption(true),
- qFileDialogUi(0),
+ qFileDialogUi(nullptr),
options(QFileDialogOptions::create())
{
}
@@ -882,14 +882,14 @@ void QFileDialog::setVisible(bool visible)
#if QT_CONFIG(fscompleter)
// So the completer doesn't try to complete and therefore show a popup
if (!d->nativeDialogInUse)
- d->completer->setModel(0);
+ d->completer->setModel(nullptr);
#endif
} else {
d->createWidgets();
setAttribute(Qt::WA_DontShowOnScreen, false);
#if QT_CONFIG(fscompleter)
if (!d->nativeDialogInUse) {
- if (d->proxyModel != 0)
+ if (d->proxyModel != nullptr)
d->completer->setModel(d->proxyModel);
else
d->completer->setModel(d->model);
@@ -1824,7 +1824,7 @@ QModelIndex QFileDialogPrivate::rootIndex() const {
QAbstractItemView *QFileDialogPrivate::currentView() const {
if (!qFileDialogUi->stackedWidget)
- return 0;
+ return nullptr;
if (qFileDialogUi->stackedWidget->currentWidget() == qFileDialogUi->listView->parent())
return qFileDialogUi->listView;
return qFileDialogUi->treeView;
@@ -2038,7 +2038,7 @@ QAbstractItemDelegate *QFileDialog::itemDelegate() const
{
Q_D(const QFileDialog);
if (!d->usingWidgets())
- return 0;
+ return nullptr;
return d->qFileDialogUi->listView->itemDelegate();
}
@@ -2777,7 +2777,7 @@ void QFileDialog::done(int result)
if (d->receiverToDisconnectOnClose) {
disconnect(this, d->signalToDisconnectOnClose,
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
+ d->receiverToDisconnectOnClose = nullptr;
}
d->memberToDisconnectOnClose.clear();
d->signalToDisconnectOnClose.clear();
@@ -3016,7 +3016,7 @@ void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter,
}
q->setAcceptMode(QFileDialog::AcceptOpen);
- nativeDialogInUse = platformFileDialogHelper() != 0;
+ nativeDialogInUse = platformFileDialogHelper() != nullptr;
if (!nativeDialogInUse)
createWidgets();
q->setFileMode(QFileDialog::AnyFile);
@@ -3274,7 +3274,7 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel)
this, SLOT(_q_rowsInserted(QModelIndex)));
}
- if (proxyModel != 0) {
+ if (proxyModel != nullptr) {
proxyModel->setParent(this);
d->proxyModel = proxyModel;
proxyModel->setSourceModel(d->model);
@@ -3287,13 +3287,13 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel)
connect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(_q_rowsInserted(QModelIndex)));
} else {
- d->proxyModel = 0;
+ d->proxyModel = nullptr;
d->qFileDialogUi->listView->setModel(d->model);
d->qFileDialogUi->treeView->setModel(d->model);
#if QT_CONFIG(fscompleter)
d->completer->setModel(d->model);
d->completer->sourceModel = d->model;
- d->completer->proxyModel = 0;
+ d->completer->proxyModel = nullptr;
#endif
connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(_q_rowsInserted(QModelIndex)));
@@ -3331,27 +3331,27 @@ QAbstractProxyModel *QFileDialog::proxyModel() const
void QFileDialogPrivate::createToolButtons()
{
Q_Q(QFileDialog);
- qFileDialogUi->backButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowBack, 0, q));
+ qFileDialogUi->backButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowBack, nullptr, q));
qFileDialogUi->backButton->setAutoRaise(true);
qFileDialogUi->backButton->setEnabled(false);
QObject::connect(qFileDialogUi->backButton, SIGNAL(clicked()), q, SLOT(_q_navigateBackward()));
- qFileDialogUi->forwardButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowForward, 0, q));
+ qFileDialogUi->forwardButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowForward, nullptr, q));
qFileDialogUi->forwardButton->setAutoRaise(true);
qFileDialogUi->forwardButton->setEnabled(false);
QObject::connect(qFileDialogUi->forwardButton, SIGNAL(clicked()), q, SLOT(_q_navigateForward()));
- qFileDialogUi->toParentButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogToParent, 0, q));
+ qFileDialogUi->toParentButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogToParent, nullptr, q));
qFileDialogUi->toParentButton->setAutoRaise(true);
qFileDialogUi->toParentButton->setEnabled(false);
QObject::connect(qFileDialogUi->toParentButton, SIGNAL(clicked()), q, SLOT(_q_navigateToParent()));
- qFileDialogUi->listModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogListView, 0, q));
+ qFileDialogUi->listModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogListView, nullptr, q));
qFileDialogUi->listModeButton->setAutoRaise(true);
qFileDialogUi->listModeButton->setDown(true);
QObject::connect(qFileDialogUi->listModeButton, SIGNAL(clicked()), q, SLOT(_q_showListView()));
- qFileDialogUi->detailModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogDetailedView, 0, q));
+ qFileDialogUi->detailModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogDetailedView, nullptr, q));
qFileDialogUi->detailModeButton->setAutoRaise(true);
QObject::connect(qFileDialogUi->detailModeButton, SIGNAL(clicked()), q, SLOT(_q_showDetailsView()));
@@ -3362,7 +3362,7 @@ void QFileDialogPrivate::createToolButtons()
qFileDialogUi->forwardButton->setFixedSize(toolSize);
qFileDialogUi->toParentButton->setFixedSize(toolSize);
- qFileDialogUi->newFolderButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogNewFolder, 0, q));
+ qFileDialogUi->newFolderButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogNewFolder, nullptr, q));
qFileDialogUi->newFolderButton->setFixedSize(toolSize);
qFileDialogUi->newFolderButton->setAutoRaise(true);
qFileDialogUi->newFolderButton->setEnabled(false);
@@ -3599,7 +3599,7 @@ void QFileDialogPrivate::_q_showContextMenu(const QPoint &position)
Q_UNUSED(position);
#else
Q_Q(QFileDialog);
- QAbstractItemView *view = 0;
+ QAbstractItemView *view = nullptr;
if (q->viewMode() == QFileDialog::Detail)
view = qFileDialogUi->treeView;
else
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 9b8c303620..d516b1b312 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -586,9 +586,9 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const
return QModelIndex();
QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);
- Q_ASSERT(indexNode != 0);
+ Q_ASSERT(indexNode != nullptr);
QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;
- if (parentNode == 0 || parentNode == &d->root)
+ if (parentNode == nullptr || parentNode == &d->root)
return QModelIndex();
// get the parent's row
@@ -608,7 +608,7 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const
QModelIndex QFileSystemModelPrivate::index(const QFileSystemModelPrivate::QFileSystemNode *node, int column) const
{
Q_Q(const QFileSystemModel);
- QFileSystemModelPrivate::QFileSystemNode *parentNode = (node ? node->parent : 0);
+ QFileSystemModelPrivate::QFileSystemNode *parentNode = (node ? node->parent : nullptr);
if (node == &root || !parentNode)
return QModelIndex();
@@ -948,9 +948,8 @@ QVariant QFileSystemModel::headerData(int section, Qt::Orientation orientation,
if (section == 0) {
// ### TODO oh man this is ugly and doesn't even work all the way!
// it is still 2 pixels off
- QImage pixmap(16, 1, QImage::Format_Mono);
- pixmap.fill(0);
- pixmap.setAlphaChannel(pixmap.createAlphaMask());
+ QImage pixmap(16, 1, QImage::Format_ARGB32_Premultiplied);
+ pixmap.fill(Qt::transparent);
return pixmap;
}
break;
@@ -2078,7 +2077,8 @@ void QFileSystemModelPrivate::init()
#endif // filesystemwatcher
q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
- roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
+ roleNames.insert(QFileSystemModel::FileIconRole,
+ QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QFileSystemModel::FilePathRole, QByteArrayLiteral("filePath"));
roleNames.insert(QFileSystemModel::FileNameRole, QByteArrayLiteral("fileName"));
roleNames.insert(QFileSystemModel::FilePermissions, QByteArrayLiteral("filePermissions"));
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index 844e417e2d..ad98b9ef44 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -116,7 +116,7 @@ public:
inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; }
inline QString type() const { if (info) return info->displayType; return QLatin1String(""); }
inline QDateTime lastModified() const { if (info) return info->lastModified(); return QDateTime(); }
- inline QFile::Permissions permissions() const { if (info) return info->permissions(); return nullptr; }
+ inline QFile::Permissions permissions() const { if (info) return info->permissions(); return { }; }
inline bool isReadable() const { return ((permissions() & QFile::ReadUser) != 0); }
inline bool isWritable() const { return ((permissions() & QFile::WriteUser) != 0); }
inline bool isExecutable() const { return ((permissions() & QFile::ExeUser) != 0); }
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 7e3592e034..fe8f88d64f 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -276,7 +276,7 @@ void QFontDialogPrivate::init()
mainGrid->setColumnMinimumWidth(3, spacing);
int margin = 0;
- mainGrid->getContentsMargins(0, 0, 0, &margin);
+ mainGrid->getContentsMargins(nullptr, nullptr, nullptr, &margin);
mainGrid->setRowMinimumHeight(3, margin);
mainGrid->setRowMinimumHeight(6, 2);
@@ -391,7 +391,7 @@ QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, cons
QFont QFontDialog::getFont(bool *ok, QWidget *parent)
{
QFont initial;
- return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
+ return QFontDialogPrivate::getFont(ok, initial, parent, QString(), { });
}
QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
@@ -435,7 +435,7 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e)
QCoreApplication::sendEvent(d->sizeList, k);
if (ci != d->sizeList->currentItem()
- && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this))
+ && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this))
d->sizeEdit->selectAll();
return true;
} else if ((o == d->familyList || o == d->styleList) &&
@@ -445,7 +445,7 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e)
return true;
}
} else if (e->type() == QEvent::FocusIn
- && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) {
+ && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this)) {
if (o == d->familyList)
d->familyEdit->selectAll();
else if (o == d->styleList)
@@ -550,7 +550,7 @@ void QFontDialogPrivate::updateFamilies()
else
familyList->setCurrentItem(0);
familyEdit->setText(familyList->currentText());
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
&& familyList->hasFocus())
familyEdit->selectAll();
@@ -602,7 +602,7 @@ void QFontDialogPrivate::updateStyles()
}
styleEdit->setText(styleList->currentText());
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
&& styleList->hasFocus())
styleEdit->selectAll();
@@ -641,7 +641,7 @@ void QFontDialogPrivate::updateSizes()
const QSignalBlocker blocker(sizeEdit);
sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText()));
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
&& sizeList->hasFocus())
sizeEdit->selectAll();
} else {
@@ -692,7 +692,7 @@ void QFontDialogPrivate::_q_familyHighlighted(int i)
Q_Q(QFontDialog);
family = familyList->text(i);
familyEdit->setText(family);
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
&& familyList->hasFocus())
familyEdit->selectAll();
@@ -709,7 +709,7 @@ void QFontDialogPrivate::_q_styleHighlighted(int index)
Q_Q(QFontDialog);
QString s = styleList->text(index);
styleEdit->setText(s);
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
&& styleList->hasFocus())
styleEdit->selectAll();
@@ -728,7 +728,7 @@ void QFontDialogPrivate::_q_sizeHighlighted(int index)
Q_Q(QFontDialog);
QString s = sizeList->text(index);
sizeEdit->setText(s);
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q)
&& sizeEdit->hasFocus())
sizeEdit->selectAll();
@@ -1019,7 +1019,7 @@ void QFontDialog::done(int result)
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(fontSelected(QFont)),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
+ d->receiverToDisconnectOnClose = nullptr;
}
d->memberToDisconnectOnClose.clear();
}
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index 3cfe8367e0..1cb4be0682 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -138,7 +138,7 @@ class QInputDialogDoubleSpinBox : public QDoubleSpinBox
Q_OBJECT
public:
- QInputDialogDoubleSpinBox(QWidget *parent = 0)
+ QInputDialogDoubleSpinBox(QWidget *parent = nullptr)
: QDoubleSpinBox(parent) {
connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged()));
connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged()));
@@ -171,7 +171,7 @@ private:
class QInputDialogListView : public QListView
{
public:
- QInputDialogListView(QWidget *parent = 0) : QListView(parent) {}
+ QInputDialogListView(QWidget *parent = nullptr) : QListView(parent) {}
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
{
if (query == Qt::ImEnabled)
@@ -223,8 +223,8 @@ public:
};
QInputDialogPrivate::QInputDialogPrivate()
- : label(0), buttonBox(0), lineEdit(0), plainTextEdit(0), intSpinBox(0), doubleSpinBox(0),
- comboBox(0), listView(0), inputWidget(0), mainLayout(0)
+ : label(nullptr), buttonBox(nullptr), lineEdit(nullptr), plainTextEdit(nullptr), intSpinBox(nullptr), doubleSpinBox(nullptr),
+ comboBox(nullptr), listView(nullptr), inputWidget(nullptr), mainLayout(nullptr)
{
}
@@ -1174,7 +1174,7 @@ void QInputDialog::done(int result)
if (d->receiverToDisconnectOnClose) {
disconnect(this, signalForMember(d->memberToDisconnectOnClose),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
+ d->receiverToDisconnectOnClose = nullptr;
}
d->memberToDisconnectOnClose.clear();
}
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index e1cc475a93..4e7a4a65e3 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -97,7 +97,7 @@ public:
class TextEdit : public QTextEdit
{
public:
- TextEdit(QWidget *parent=0) : QTextEdit(parent) { }
+ TextEdit(QWidget *parent=nullptr) : QTextEdit(parent) { }
#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent * e) override
{
@@ -108,7 +108,7 @@ public:
#endif // QT_NO_CONTEXTMENU
};
- QMessageBoxDetailsText(QWidget *parent=0)
+ QMessageBoxDetailsText(QWidget *parent=nullptr)
: QWidget(parent)
, copyAvailable(false)
{
@@ -197,12 +197,12 @@ class QMessageBoxPrivate : public QDialogPrivate
Q_DECLARE_PUBLIC(QMessageBox)
public:
- QMessageBoxPrivate() : escapeButton(0), defaultButton(0), checkbox(0), clickedButton(0), detailsButton(0),
+ QMessageBoxPrivate() : escapeButton(nullptr), defaultButton(nullptr), checkbox(nullptr), clickedButton(nullptr), detailsButton(nullptr),
#if QT_CONFIG(textedit)
- detailsText(0),
+ detailsText(nullptr),
#endif
compatMode(false), autoAddOkButton(true),
- detectedEscapeButton(0), informativeLabel(0),
+ detectedEscapeButton(nullptr), informativeLabel(nullptr),
options(QMessageDialogOptions::create()) { }
void init(const QString &title = QString(), const QString &text = QString());
@@ -274,7 +274,7 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text)
label = new QLabel;
label->setObjectName(QLatin1String("qt_msgbox_label"));
- label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));
+ label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, q)));
label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
label->setOpenExternalLinks(true);
iconLabel = new QLabel(q);
@@ -283,7 +283,7 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text)
buttonBox = new QDialogButtonBox;
buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox"));
- buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q));
+ buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q));
QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),
q, SLOT(_q_buttonClicked(QAbstractButton*)));
setupLayout();
@@ -305,7 +305,7 @@ void QMessageBoxPrivate::setupLayout()
Q_Q(QMessageBox);
delete q->layout();
QGridLayout *grid = new QGridLayout;
- bool hasIcon = iconLabel->pixmap() && !iconLabel->pixmap()->isNull();
+ bool hasIcon = !iconLabel->pixmap(Qt::ReturnByValue).isNull();
if (hasIcon)
grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
@@ -933,9 +933,9 @@ void QMessageBox::removeButton(QAbstractButton *button)
Q_D(QMessageBox);
d->customButtonList.removeAll(button);
if (d->escapeButton == button)
- d->escapeButton = 0;
+ d->escapeButton = nullptr;
if (d->defaultButton == button)
- d->defaultButton = 0;
+ d->defaultButton = nullptr;
d->buttonBox->removeButton(button);
d->updateSize();
}
@@ -958,9 +958,9 @@ void QMessageBox::setStandardButtons(StandardButtons buttons)
QList<QAbstractButton *> buttonList = d->buttonBox->buttons();
if (!buttonList.contains(d->escapeButton))
- d->escapeButton = 0;
+ d->escapeButton = nullptr;
if (!buttonList.contains(d->defaultButton))
- d->defaultButton = 0;
+ d->defaultButton = nullptr;
d->autoAddOkButton = false;
d->updateSize();
}
@@ -1087,7 +1087,7 @@ void QMessageBoxPrivate::detectEscapeButton()
for (auto *button : buttons) {
if (buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole) {
if (detectedEscapeButton) { // already detected!
- detectedEscapeButton = 0;
+ detectedEscapeButton = nullptr;
break;
}
detectedEscapeButton = button;
@@ -1100,7 +1100,7 @@ void QMessageBoxPrivate::detectEscapeButton()
for (auto *button : buttons) {
if (buttonBox->buttonRole(button) == QDialogButtonBox::NoRole) {
if (detectedEscapeButton) { // already detected!
- detectedEscapeButton = 0;
+ detectedEscapeButton = nullptr;
break;
}
detectedEscapeButton = button;
@@ -1195,7 +1195,7 @@ void QMessageBox::setCheckBox(QCheckBox *cb)
d->checkbox->hide();
layout()->removeWidget(d->checkbox);
if (d->checkbox->parentWidget() == this) {
- d->checkbox->setParent(0);
+ d->checkbox->setParent(nullptr);
d->checkbox->deleteLater();
}
}
@@ -1323,9 +1323,7 @@ void QMessageBox::setIcon(Icon icon)
QPixmap QMessageBox::iconPixmap() const
{
Q_D(const QMessageBox);
- if (d->iconLabel && d->iconLabel->pixmap())
- return *d->iconLabel->pixmap();
- return QPixmap();
+ return d->iconLabel->pixmap(Qt::ReturnByValue);
}
void QMessageBox::setIconPixmap(const QPixmap &pixmap)
@@ -1439,9 +1437,9 @@ void QMessageBox::changeEvent(QEvent *ev)
{
if (d->icon != NoIcon)
setIcon(d->icon);
- Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this));
+ Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this));
d->label->setTextInteractionFlags(flags);
- d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this));
+ d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, this));
if (d->informativeLabel)
d->informativeLabel->setTextInteractionFlags(flags);
Q_FALLTHROUGH();
@@ -1630,7 +1628,7 @@ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,
QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
- Q_ASSERT(buttonBox != 0);
+ Q_ASSERT(buttonBox != nullptr);
uint mask = QMessageBox::FirstButton;
while (mask <= QMessageBox::LastButton) {
@@ -2007,7 +2005,7 @@ QAbstractButton *QMessageBoxPrivate::abstractButtonForId(int id) const
if (result)
return result;
if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly)
- return 0;
+ return nullptr;
return q->button(newButton(id));
}
@@ -2528,13 +2526,13 @@ void QMessageBox::setDetailedText(const QString &text)
d->detailsText->hide();
d->detailsText->deleteLater();
}
- d->detailsText = 0;
+ d->detailsText = nullptr;
removeButton(d->detailsButton);
if (d->detailsButton) {
d->detailsButton->hide();
d->detailsButton->deleteLater();
}
- d->detailsButton = 0;
+ d->detailsButton = nullptr;
} else {
if (!d->detailsText) {
d->detailsText = new QMessageBoxDetailsText(this);
@@ -2583,12 +2581,12 @@ void QMessageBox::setInformativeText(const QString &text)
d->informativeLabel->hide();
d->informativeLabel->deleteLater();
}
- d->informativeLabel = 0;
+ d->informativeLabel = nullptr;
} else {
if (!d->informativeLabel) {
QLabel *label = new QLabel;
label->setObjectName(QLatin1String("qt_msgbox_informativelabel"));
- label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)));
+ label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this)));
label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
label->setOpenExternalLinks(true);
label->setWordWrap(true);
@@ -2650,20 +2648,20 @@ void QMessageBox::setWindowModality(Qt::WindowModality windowModality)
QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb)
{
QStyle *style = mb ? mb->style() : QApplication::style();
- int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, mb);
+ int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, mb);
QIcon tmpIcon;
switch (icon) {
case QMessageBox::Information:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, 0, mb);
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, mb);
break;
case QMessageBox::Warning:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, mb);
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, mb);
break;
case QMessageBox::Critical:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, 0, mb);
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, mb);
break;
case QMessageBox::Question:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mb);
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, mb);
default:
break;
}
@@ -2745,7 +2743,7 @@ void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHel
QPixmap QMessageBox::standardIcon(Icon icon)
{
- return QMessageBoxPrivate::standardIcon(icon, 0);
+ return QMessageBoxPrivate::standardIcon(icon, nullptr);
}
/*!
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 9507053ffe..40548e22a5 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -65,13 +65,13 @@ class QProgressDialogPrivate : public QDialogPrivate
Q_DECLARE_PUBLIC(QProgressDialog)
public:
- QProgressDialogPrivate() : label(0), cancel(0), bar(0),
+ QProgressDialogPrivate() : label(nullptr), cancel(nullptr), bar(nullptr),
shown_once(false),
cancellation_flag(false),
setValue_called(false),
showTime(defaultShowTime),
#ifndef QT_NO_SHORTCUT
- escapeShortcut(0),
+ escapeShortcut(nullptr),
#endif
useDefaultCancelText(false)
{
@@ -112,7 +112,7 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance
label = new QLabel(labelText, q);
bar = new QProgressBar(q);
bar->setRange(min, max);
- int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q);
+ int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, nullptr, q);
label->setAlignment(Qt::Alignment(align));
autoClose = true;
autoReset = true;
@@ -132,12 +132,12 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance
void QProgressDialogPrivate::layout()
{
Q_Q(QProgressDialog);
- int sp = q->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, 0, q);
- int mb = q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, q);
- int ml = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q));
- int mr = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q));
+ int sp = q->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, nullptr, q);
+ int mb = q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, q);
+ int ml = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q));
+ int mr = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q));
const bool centered =
- bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q));
+ bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, nullptr, q));
int additionalSpacing = 0;
QSize cs = cancel ? cancel->sizeHint() : QSize(0,0);
@@ -188,7 +188,7 @@ void QProgressDialogPrivate::_q_disconnectOnClose()
if (receiverToDisconnectOnClose) {
QObject::disconnect(q, SIGNAL(canceled()), receiverToDisconnectOnClose,
memberToDisconnectOnClose);
- receiverToDisconnectOnClose = 0;
+ receiverToDisconnectOnClose = nullptr;
}
memberToDisconnectOnClose.clear();
}
@@ -418,7 +418,7 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton)
} else {
#ifndef QT_NO_SHORTCUT
delete d->escapeShortcut;
- d->escapeShortcut = 0;
+ d->escapeShortcut = nullptr;
#endif
}
d->adoptChildWidget(cancelButton);
@@ -450,7 +450,7 @@ void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText
q->setCancelButton(new QPushButton(cancelButtonText, q));
}
} else {
- q->setCancelButton(0);
+ q->setCancelButton(nullptr);
}
ensureSizeIsAtLeastSizeHint();
}
@@ -492,7 +492,7 @@ void QProgressDialogPrivate::adoptChildWidget(QWidget *c)
if (c->parentWidget() == q)
c->hide(); // until after ensureSizeIsAtLeastSizeHint()
else
- c->setParent(q, 0);
+ c->setParent(q, { });
}
ensureSizeIsAtLeastSizeHint();
if (c)
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index 2c8c66e1e2..4272b612ec 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -73,7 +73,7 @@ void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option,
Example usage: File dialog sidebar and combo box
*/
-QUrlModel::QUrlModel(QObject *parent) : QStandardItemModel(parent), showFullPath(false), fileSystemModel(0)
+QUrlModel::QUrlModel(QObject *parent) : QStandardItemModel(parent), showFullPath(false), fileSystemModel(nullptr)
{
}
@@ -163,7 +163,7 @@ bool QUrlModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
*/
bool QUrlModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- if (value.type() == QVariant::Url) {
+ if (value.userType() == QMetaType::QUrl) {
QUrl url = value.toUrl();
QModelIndex dirIndex = fileSystemModel->index(url.toLocalFile());
//On windows the popup display the "C:\", convert to nativeSeparators
@@ -298,7 +298,7 @@ void QUrlModel::setFileSystemModel(QFileSystemModel *model)
{
if (model == fileSystemModel)
return;
- if (fileSystemModel != 0) {
+ if (fileSystemModel != nullptr) {
disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(dataChanged(QModelIndex,QModelIndex)));
disconnect(model, SIGNAL(layoutChanged()),
@@ -307,7 +307,7 @@ void QUrlModel::setFileSystemModel(QFileSystemModel *model)
this, SLOT(layoutChanged()));
}
fileSystemModel = model;
- if (fileSystemModel != 0) {
+ if (fileSystemModel != nullptr) {
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(dataChanged(QModelIndex,QModelIndex)));
connect(model, SIGNAL(layoutChanged()),
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 0295241a74..87f6875c8c 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -115,7 +115,7 @@ static QWidget *iWantTheFocus(QWidget *ancestor)
return candidate;
}
}
- return 0;
+ return nullptr;
}
static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX,
@@ -165,7 +165,7 @@ static const char *changed_signal(int which)
};
Q_STATIC_ASSERT(7 == NFallbackDefaultProperties);
Q_UNREACHABLE();
- return 0;
+ return nullptr;
}
class QWizardDefaultProperty
@@ -286,9 +286,9 @@ class QWizardHeader : public QWidget
public:
enum RulerType { Ruler };
- inline QWizardHeader(RulerType /* ruler */, QWidget *parent = 0)
+ inline QWizardHeader(RulerType /* ruler */, QWidget *parent = nullptr)
: QWidget(parent) { setFixedHeight(2); }
- QWizardHeader(QWidget *parent = 0);
+ QWizardHeader(QWidget *parent = nullptr);
void setup(const QWizardLayoutInfo &info, const QString &title,
const QString &subTitle, const QPixmap &logo, const QPixmap &banner,
@@ -438,7 +438,7 @@ void QWizardHeader::paintEvent(QPaintEvent * /* event */)
class QWizardRuler : public QWizardHeader
{
public:
- inline QWizardRuler(QWidget *parent = 0)
+ inline QWizardRuler(QWidget *parent = nullptr)
: QWizardHeader(Ruler, parent) {}
};
@@ -452,8 +452,8 @@ public:
}
QSize minimumSizeHint() const override {
- if (pixmap() && !pixmap()->isNull())
- return pixmap()->size() / pixmap()->devicePixelRatio();
+ if (!pixmap(Qt::ReturnByValue).isNull())
+ return pixmap(Qt::ReturnByValue).size() / pixmap(Qt::ReturnByValue).devicePixelRatio();
return QFrame::minimumSizeHint();
}
@@ -684,7 +684,7 @@ void QWizardPrivate::init()
std::fill(btns, btns + QWizard::NButtons, nullptr);
antiFlickerWidget = new QWizardAntiFlickerWidget(q, this);
- wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, 0, q));
+ wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, nullptr, q));
if (wizStyle == QWizard::MacStyle) {
opts = (QWizard::NoDefaultButton | QWizard::NoCancelButton);
} else if (wizStyle == QWizard::ModernStyle) {
@@ -836,7 +836,7 @@ void QWizardPrivate::switchToPage(int newId, Direction direction)
newPage && newPage->isCommitPage() ? QWizard::CommitButton : QWizard::NextButton;
QAbstractButton *nextOrFinishButton =
btns[canContinue ? nextOrCommit : QWizard::FinishButton];
- QWidget *candidate = 0;
+ QWidget *candidate = nullptr;
/*
If there is no default button and the Next or Finish button
@@ -887,7 +887,7 @@ static const char * buttonSlots(QWizard::WizardButton which)
case QWizard::NoButton:
Q_UNREACHABLE();
};
- return 0;
+ return nullptr;
};
QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
@@ -898,14 +898,14 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
QWizardLayoutInfo info;
const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
- info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q);
- info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q);
- info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, q);
- info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, q);
- info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, titleLabel);
- info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, titleLabel);
- info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, titleLabel);
- info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, titleLabel);
+ info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q);
+ info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q);
+ info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, q);
+ info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, q);
+ info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, titleLabel);
+ info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, titleLabel);
+ info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, titleLabel);
+ info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, titleLabel);
info.hspacing = (layoutHorizontalSpacing == -1)
? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal)
: layoutHorizontalSpacing;
@@ -959,7 +959,7 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info)
for (int i = mainLayout->count() - 1; i >= 0; --i) {
QLayoutItem *item = mainLayout->takeAt(i);
if (item->layout()) {
- item->layout()->setParent(0);
+ item->layout()->setParent(nullptr);
} else {
delete item;
}
@@ -2281,7 +2281,7 @@ void QWizard::removePage(int id)
{
Q_D(QWizard);
- QWizardPage *removedPage = 0;
+ QWizardPage *removedPage = nullptr;
// update startItem accordingly
if (d->pageMap.count() > 0) { // only if we have any pages
@@ -2792,7 +2792,7 @@ QAbstractButton *QWizard::button(WizardButton which) const
return d->vistaHelper->backButton();
#endif
if (!d->ensureButton(which))
- return 0;
+ return nullptr;
return d->btns[which];
}
@@ -2924,7 +2924,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property,
or when the watermark is not provided the side widget is displayed
on the left side of the wizard.
- Passing 0 shows no side widget.
+ Passing \nullptr shows no side widget.
When the \a widget is not \nullptr the wizard reparents it.
@@ -3444,7 +3444,7 @@ int QWizard::nextId() const
\sa wizard()
*/
QWizardPage::QWizardPage(QWidget *parent)
- : QWidget(*new QWizardPagePrivate, parent, 0)
+ : QWidget(*new QWizardPagePrivate, parent, { })
{
connect(this, SIGNAL(completeChanged()), this, SLOT(_q_updateCachedCompleteState()));
}
diff --git a/src/widgets/doc/snippets/code/doc_src_layout.cpp b/src/widgets/doc/snippets/code/doc_src_layout.cpp
index 5e9a740244..7bbd781bb2 100644
--- a/src/widgets/doc/snippets/code/doc_src_layout.cpp
+++ b/src/widgets/doc/snippets/code/doc_src_layout.cpp
@@ -53,14 +53,15 @@
#define CARD_H
#include <QtWidgets>
-#include <QList>
+#include <QVector>
class CardLayout : public QLayout
{
public:
- CardLayout(QWidget *parent, int dist): QLayout(parent, 0, dist) {}
- CardLayout(QLayout *parent, int dist): QLayout(parent, dist) {}
- CardLayout(int dist): QLayout(dist) {}
+ CardLayout(int spacing): QLayout()
+ { setSpacing(spacing); }
+ CardLayout(int spacing, QWidget *parent): QLayout(parent)
+ { setSpacing(spacing); }
~CardLayout();
void addItem(QLayoutItem *item) override;
@@ -72,7 +73,7 @@ public:
void setGeometry(const QRect &rect) override;
private:
- QList<QLayoutItem*> list;
+ QVector<QLayoutItem*> m_items;
};
#endif
//! [0]
@@ -85,23 +86,23 @@ private:
//! [2]
int CardLayout::count() const
{
- // QList::size() returns the number of QLayoutItems in the list
- return list.size();
+ // QVector::size() returns the number of QLayoutItems in m_items
+ return m_items.size();
}
//! [2]
//! [3]
QLayoutItem *CardLayout::itemAt(int idx) const
{
- // QList::value() performs index checking, and returns 0 if we are
+ // QVector::value() performs index checking, and returns nullptr if we are
// outside the valid range
- return list.value(idx);
+ return m_items.value(idx);
}
QLayoutItem *CardLayout::takeAt(int idx)
{
- // QList::take does not do index checking
- return idx >= 0 && idx < list.size() ? list.takeAt(idx) : 0;
+ // QVector::take does not do index checking
+ return idx >= 0 && idx < m_items.size() ? m_items.takeAt(idx) : 0;
}
//! [3]
@@ -109,7 +110,7 @@ QLayoutItem *CardLayout::takeAt(int idx)
//! [4]
void CardLayout::addItem(QLayoutItem *item)
{
- list.append(item);
+ m_items.append(item);
}
//! [4]
@@ -129,14 +130,14 @@ void CardLayout::setGeometry(const QRect &r)
{
QLayout::setGeometry(r);
- if (list.size() == 0)
+ if (m_items.size() == 0)
return;
- int w = r.width() - (list.count() - 1) * spacing();
- int h = r.height() - (list.count() - 1) * spacing();
+ int w = r.width() - (m_items.count() - 1) * spacing();
+ int h = r.height() - (m_items.count() - 1) * spacing();
int i = 0;
- while (i < list.size()) {
- QLayoutItem *o = list.at(i);
+ while (i < m_items.size()) {
+ QLayoutItem *o = m_items.at(i);
QRect geom(r.x() + i * spacing(), r.y() + i * spacing(), w, h);
o->setGeometry(geom);
++i;
@@ -148,29 +149,29 @@ void CardLayout::setGeometry(const QRect &r)
//! [7]
QSize CardLayout::sizeHint() const
{
- QSize s(0,0);
- int n = list.count();
+ QSize s(0, 0);
+ int n = m_items.count();
if (n > 0)
- s = QSize(100,70); //start with a nice default size
+ s = QSize(100, 70); //start with a nice default size
int i = 0;
while (i < n) {
- QLayoutItem *o = list.at(i);
+ QLayoutItem *o = m_items.at(i);
s = s.expandedTo(o->sizeHint());
++i;
}
- return s + n*QSize(spacing(), spacing());
+ return s + n * QSize(spacing(), spacing());
}
QSize CardLayout::minimumSize() const
{
- QSize s(0,0);
- int n = list.count();
+ QSize s(0, 0);
+ int n = m_items.count();
int i = 0;
while (i < n) {
- QLayoutItem *o = list.at(i);
+ QLayoutItem *o = m_items.at(i);
s = s.expandedTo(o->minimumSize());
++i;
}
- return s + n*QSize(spacing(), spacing());
+ return s + n * QSize(spacing(), spacing());
}
//! [7]
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 4b4fb869f9..ed6043564b 100644
--- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -89,11 +89,10 @@ dialog.setNameFilter("*.cpp *.cc *.C *.cxx *.c++");
//! [7]
-QStringList filters;
-filters << "Image files (*.png *.xpm *.jpg)"
- << "Text files (*.txt)"
- << "Any files (*)";
-
+const QStringList filters({"Image files (*.png *.xpm *.jpg)",
+ "Text files (*.txt)",
+ "Any files (*)"
+ });
QFileDialog dialog(this);
dialog.setNameFilters(filters);
dialog.exec();
@@ -131,10 +130,10 @@ QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
//! [12]
//! [13]
-QStringList mimeTypeFilters;
-mimeTypeFilters << "image/jpeg" // will show "JPEG image (*.jpeg *.jpg *.jpe)
- << "image/png" // will show "PNG image (*.png)"
- << "application/octet-stream"; // will show "All files (*)"
+QStringList mimeTypeFilters({"image/jpeg", // will show "JPEG image (*.jpeg *.jpg *.jpe)
+ "image/png", // will show "PNG image (*.png)"
+ "application/octet-stream" // will show "All files (*)"
+ });
QFileDialog dialog(this);
dialog.setMimeTypeFilters(mimeTypeFilters);
diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp
index 792cc48ca7..f1e3b6ea45 100644
--- a/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp
@@ -53,6 +53,6 @@ QTreeWidget *treeWidget = new QTreeWidget();
treeWidget->setColumnCount(1);
QList<QTreeWidgetItem *> items;
for (int i = 0; i < 10; ++i)
- items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i))));
+ items.append(new QTreeWidgetItem(static_cast<QTreeWidget *>(nullptr), QStringList(QString("item: %1").arg(i))));
treeWidget->insertTopLevelItems(0, items);
//! [0]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
index 0a70c1d32a..a7bce6d378 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
@@ -51,9 +51,10 @@
//! [0]
QCoreApplication* createApplication(int &argc, char *argv[])
{
- for (int i = 1; i < argc; ++i)
+ for (int i = 1; i < argc; ++i) {
if (!qstrcmp(argv[i], "-no-gui"))
return new QCoreApplication(argc, argv);
+ }
return new QApplication(argc, argv);
}
@@ -92,7 +93,7 @@ int main(int argc, char *argv[])
//! [3]
QSize MyWidget::sizeHint() const
{
- return QSize(80, 25).expandedTo(QApplication::globalStrut());
+ return QSize(80, 25);
}
//! [3]
@@ -187,14 +188,14 @@ for (const QString &command : commands)
//! [12]
-QWidget *widget = qApp->widgetAt(x, y);
+QWidget *widget = QApplication::widgetAt(x, y);
if (widget)
widget = widget->window();
//! [12]
//! [13]
-QWidget *widget = qApp->widgetAt(point);
+QWidget *widget = QApplication::widgetAt(point);
if (widget)
widget = widget->window();
//! [13]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp
index 1a716029a9..c55834ebfb 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp
@@ -70,8 +70,9 @@ void MyWidget::paintEvent(QPaintEvent *)
//! [1]
QLayoutItem *child;
-while ((child = layout->takeAt(0)) != 0) {
+while ((child = layout->takeAt(0)) != nullptr) {
...
- delete child;
+ delete child->widget(); // delete the widget
+ delete child; // delete the layout item
}
//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp
index d9f70b91ed..dd0f860c01 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp
@@ -52,8 +52,7 @@
int MyLayout::heightForWidth(int w) const
{
if (cache_dirty || cached_width != w) {
- // not all C++ compilers support "mutable"
- MyLayout *that = (MyLayout*)this;
+ MyLayout *that = const_cast<MyLayout *>(this);
int h = calculateHeightForWidth(w);
that->cached_hfw = h;
return h;
diff --git a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp
index 3169d1c193..98dc0ff55b 100644
--- a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp
@@ -53,8 +53,8 @@ class MyProxyStyle : public QProxyStyle
{
public:
- int styleHint(StyleHint hint, const QStyleOption *option = 0,
- const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override
+ int styleHint(StyleHint hint, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override
{
if (hint == QStyle::SH_UnderlineShortcut)
return 1;
@@ -72,8 +72,8 @@ public:
class MyProxyStyle : public QProxyStyle
{
public:
- int styleHint(StyleHint hint, const QStyleOption *option = 0,
- const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override
+ int styleHint(StyleHint hint, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override
{
if (hint == QStyle::SH_UnderlineShortcut)
return 0;
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp
index b82c67b379..b52b0064ad 100644
--- a/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp
@@ -54,5 +54,5 @@ menubar->addMenu(fileMenu);
//! [1]
-QMenuBar *menuBar = new QMenuBar(0);
+QMenuBar *menuBar = new QMenuBar(nullptr);
//! [1]
diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp
index b9c0b1a38b..91aa8a9c4e 100644
--- a/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp
@@ -56,10 +56,10 @@ splash->show();
... // Loading some items
splash->showMessage("Loaded modules");
-qApp->processEvents();
+QCoreApplication::processEvents();
... // Establishing connections
splash->showMessage("Established connections");
-qApp->processEvents();
+QCoreApplication::processEvents();
//! [0]
diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp
index 8657d5ed29..ca6866376b 100644
--- a/src/widgets/doc/snippets/javastyle.cpp
+++ b/src/widgets/doc/snippets/javastyle.cpp
@@ -380,10 +380,10 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
QRect rect = bar->rect;
if (bar->orientation == Qt::Vertical) {
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width());
- QMatrix m;
+ QTransform m;
m.translate(rect.height()-1, 0);
m.rotate(90.0);
- painter->setMatrix(m);
+ painter->setTransform(m);
}
painter->setPen(bar->palette.color(QPalette::Mid));
@@ -2589,7 +2589,7 @@ int JavaStyle::styleHint(StyleHint hint, const QStyleOption *option,
switch (hint) {
case SH_Table_GridLineColor: {
- ret = static_cast<int>(option->palette.color(QPalette::Mid).rgb());
+ ret = static_cast<int>(option->palette.color(QPalette::Mid).rgba());
break;
}
case QStyle::SH_Menu_Scrollable:
diff --git a/src/widgets/doc/snippets/qsplashscreen/main.cpp b/src/widgets/doc/snippets/qsplashscreen/main.cpp
index 843932ca83..2512035879 100644
--- a/src/widgets/doc/snippets/qsplashscreen/main.cpp
+++ b/src/widgets/doc/snippets/qsplashscreen/main.cpp
@@ -71,3 +71,10 @@ int main(int argc, char *argv[])
return app.exec();
}
//! [1]
+
+//! [2]
+QScreen *screen = QGuiApplication::screens().at(1);
+QPixmap pixmap(":/splash.png");
+QSplashScreen splash(screen, pixmap);
+splash.show();
+//! [2]
diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
index 65569a9cd2..e42e6d42ec 100644
--- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
@@ -300,7 +300,7 @@
\list
\li A data structure to store the items handled by the layout. Each
item is a \l{QLayoutItem}{QLayoutItem}. We will use a
- QList in this example.
+ QVector in this example.
\li \l{QLayout::}{addItem()}, how to add items to the layout.
\li \l{QLayout::}{setGeometry()}, how to perform the layout.
\li \l{QLayout::}{sizeHint()}, the preferred size of the layout.
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index efe30308f0..50f626e7a6 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -993,6 +993,9 @@
\li Supports the \l{box model}. Supports the \l{#default-ps}{:default},
\l{#flat-ps}{:flat}, \l{#checked-ps}{:checked} pseudo states.
+ Since 5.15, the \l{#icon-prop}{icon} property can be set to
+ override the button icon.
+
For QPushButton with a menu, the menu indicator is styled
using the \l{#menu-indicator-sub}{::menu-indicator}
subcontrol. Appearance of checkable push buttons can be
@@ -1946,6 +1949,20 @@
See also \l{#width-prop}{width}.
\row
+ \li \b{\c icon} \target icon-prop
+ \li \l{#Url}{Url}+
+ \li The icon that is used, for widgets that have an icon.
+
+ The only widget currently supporting this property is QPushButton.
+
+ \note It's the application's responsibilty to assign an icon to a
+ button (using the QAbstractButton API), and not the style's. So be
+ careful setting it unless your stylesheet is targeting a specific
+ application.
+
+ Available since 5.15.
+
+ \row
\li \b{\c icon-size} \target icon-size-prop
\li \l{#Length}{Length}
\li The width and height of the icon in a widget.
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
index 94188f3485..2eb74ce2a8 100644
--- a/src/widgets/effects/qgraphicseffect.cpp
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -415,7 +415,7 @@ QGraphicsEffect::QGraphicsEffect(QGraphicsEffectPrivate &dd, QObject *parent)
QGraphicsEffect::~QGraphicsEffect()
{
Q_D(QGraphicsEffect);
- d->setGraphicsEffectSource(0);
+ d->setGraphicsEffectSource(nullptr);
}
/*!
diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp
index e1e8175423..1f899c2660 100644
--- a/src/widgets/effects/qpixmapfilter.cpp
+++ b/src/widgets/effects/qpixmapfilter.cpp
@@ -208,7 +208,7 @@ QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const
class QPixmapConvolutionFilterPrivate : public QPixmapFilterPrivate
{
public:
- QPixmapConvolutionFilterPrivate(): convolutionKernel(0), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {}
+ QPixmapConvolutionFilterPrivate(): convolutionKernel(nullptr), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {}
~QPixmapConvolutionFilterPrivate() {
delete[] convolutionKernel;
}
@@ -424,7 +424,7 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q
// raster implementation
- QImage *target = 0;
+ QImage *target = nullptr;
if (painter->paintEngine()->paintDevice()->devType() == QInternal::Image) {
target = static_cast<QImage *>(painter->paintEngine()->paintDevice());
@@ -432,18 +432,18 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q
if (mat.type() > QTransform::TxTranslate) {
// Disabled because of transformation...
- target = 0;
+ target = nullptr;
} else {
QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine());
if (pe->clipType() == QRasterPaintEngine::ComplexClip)
// disabled because of complex clipping...
- target = 0;
+ target = nullptr;
else {
QRectF clip = pe->clipBoundingRect();
QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect);
QTransform x = painter->deviceTransform();
if (!clip.contains(rect.translated(x.dx() + p.x(), x.dy() + p.y()))) {
- target = 0;
+ target = nullptr;
}
}
@@ -1135,8 +1135,12 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q
destImage = std::move(buffer);
}
- if (srcImage.hasAlphaChannel())
- destImage.setAlphaChannel(srcImage.alphaChannel());
+ if (srcImage.hasAlphaChannel()) {
+ Q_ASSERT(destImage.format() == QImage::Format_ARGB32_Premultiplied);
+ QPainter maskPainter(&destImage);
+ maskPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ maskPainter.drawImage(0, 0, srcImage);
+ }
painter->drawImage(dest, destImage);
}
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
index ea6a8018ca..4f1855a606 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
@@ -353,7 +353,7 @@ void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem,
bool ok = true;
if (orientations & Qt::Horizontal) {
// Currently, if the first is ok, then the rest of the calls should be ok
- ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != 0;
+ ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != nullptr;
if (ok)
addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
}
@@ -465,7 +465,7 @@ void QGraphicsAnchorLayout::removeAt(int index)
d->removeAnchors(item);
d->items.remove(index);
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
invalidate();
}
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
index 4f44373cad..af0ee3d38c 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32;
QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version)
- : QObjectPrivate(version), layoutPrivate(0), data(0),
+ : QObjectPrivate(version), layoutPrivate(nullptr), data(nullptr),
sizePolicy(QSizePolicy::Fixed), preferredSize(0),
hasSize(true)
{
@@ -72,7 +72,7 @@ QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate()
if (data) {
// The QGraphicsAnchor was already deleted at this moment. We must clean
// the dangling pointer to avoid double deletion in the AnchorData dtor.
- data->graphicsAnchor = 0;
+ data->graphicsAnchor = nullptr;
layoutPrivate->removeAnchor(data->from, data->to);
}
@@ -631,9 +631,9 @@ QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()
spacings[i] = -1;
graphHasConflicts[i] = false;
- layoutFirstVertex[i] = 0;
- layoutCentralVertex[i] = 0;
- layoutLastVertex[i] = 0;
+ layoutFirstVertex[i] = nullptr;
+ layoutCentralVertex[i] = nullptr;
+ layoutLastVertex[i] = nullptr;
}
}
@@ -981,7 +981,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation)
feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors);
// Update the layout vertex information if one of the vertices is a layout vertex.
- AnchorVertex *layoutVertex = 0;
+ AnchorVertex *layoutVertex = nullptr;
if (v->m_item == q)
layoutVertex = v;
else if (next->m_item == q)
@@ -1035,7 +1035,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
QSet<AnchorVertex *> visited;
QStack<QPair<AnchorVertex *, AnchorVertex *> > stack;
- stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation]));
+ stack.push(qMakePair(static_cast<AnchorVertex *>(nullptr), layoutFirstVertex[orientation]));
QVector<AnchorVertex*> candidates;
// Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence)
@@ -1384,7 +1384,7 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges()
// Save a reference to layout vertices
layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft);
- layoutCentralVertex[Horizontal] = 0;
+ layoutCentralVertex[Horizontal] = nullptr;
layoutLastVertex[Horizontal] = internalVertex(layout, Qt::AnchorRight);
// Vertical
@@ -1395,7 +1395,7 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges()
// Save a reference to layout vertices
layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop);
- layoutCentralVertex[Vertical] = 0;
+ layoutCentralVertex[Vertical] = nullptr;
layoutLastVertex[Vertical] = internalVertex(layout, Qt::AnchorBottom);
}
@@ -1581,7 +1581,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
}
if (item == q) {
- layoutCentralVertex[orientation] = 0;
+ layoutCentralVertex[orientation] = nullptr;
}
}
@@ -1636,29 +1636,29 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi
qreal *spacing)
{
Q_Q(QGraphicsAnchorLayout);
- if ((firstItem == 0) || (secondItem == 0)) {
+ if ((firstItem == nullptr) || (secondItem == nullptr)) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor NULL items");
- return 0;
+ return nullptr;
}
if (firstItem == secondItem) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor the item to itself");
- return 0;
+ return nullptr;
}
if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"Cannot anchor edges of different orientations");
- return 0;
+ return nullptr;
}
const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem();
if (firstItem == parentWidget || secondItem == parentWidget) {
qWarning("QGraphicsAnchorLayout::addAnchor(): "
"You cannot add the parent of the layout to the layout.");
- return 0;
+ return nullptr;
}
// In QGraphicsAnchorLayout, items are represented in its internal
@@ -1770,13 +1770,13 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi
{
// Do not expose internal anchors
if (firstItem == secondItem)
- return 0;
+ return nullptr;
const Orientation orientation = edgeOrientation(firstEdge);
AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
- QGraphicsAnchor *graphicsAnchor = 0;
+ QGraphicsAnchor *graphicsAnchor = nullptr;
AnchorData *data = graph[orientation].edgeData(v1, v2);
if (data) {
@@ -1811,7 +1811,7 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
removeAnchor_helper(firstVertex, secondVertex);
// Ensure no dangling pointer is left behind
- firstVertex = secondVertex = 0;
+ firstVertex = secondVertex = nullptr;
// Checking if the item stays in the layout or not
bool keepFirstItem = false;
@@ -2017,13 +2017,13 @@ QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const
if (styleInfoDirty) {
Q_Q(const QGraphicsAnchorLayout);
//### Fix this if QGV ever gets support for Metal style or different Aqua sizes.
- QWidget *wid = 0;
+ QWidget *wid = nullptr;
QGraphicsLayoutItem *parent = q->parentLayoutItem();
while (parent && parent->isLayout()) {
parent = parent->parentLayoutItem();
}
- QGraphicsWidget *w = 0;
+ QGraphicsWidget *w = nullptr;
if (parent) {
QGraphicsItem *parentItem = parent->graphicsItem();
if (parentItem && parentItem->isWidget())
@@ -2404,7 +2404,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin
// Look for the layout edge. That can be either the first half in case the
// layout is split in two, or the whole layout anchor.
Orientation orient = Orientation(anchors.first()->orientation);
- AnchorData *layoutEdge = 0;
+ AnchorData *layoutEdge = nullptr;
if (layoutCentralVertex[orient]) {
layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]);
} else {
@@ -2423,7 +2423,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin
actualMax = -layoutEdge->minSize;
}
if (actualMax != expectedMax) {
- layoutEdge = 0;
+ layoutEdge = nullptr;
}
// For each variable, create constraints based on size hints
@@ -2496,8 +2496,8 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
Q_ASSERT(layoutFirstVertex[orientation] && layoutLastVertex[orientation]);
- AnchorData *edgeL1 = 0;
- AnchorData *edgeL2 = 0;
+ AnchorData *edgeL1 = nullptr;
+ AnchorData *edgeL2 = nullptr;
// The layout may have a single anchor between Left and Right or two half anchors
// passing through the center
@@ -2625,7 +2625,7 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom)
qreal left;
qreal right;
- q->getContentsMargins(&left, &top, &right, 0);
+ q->getContentsMargins(&left, &top, &right, nullptr);
const Qt::LayoutDirection visualDir = visualDirection();
if (visualDir == Qt::RightToLeft)
qSwap(left, right);
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
index 6b7052a0ab..260e1861c7 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
@@ -137,7 +137,7 @@ QGraphicsGridLayout::~QGraphicsGridLayout()
// ~QGraphicsLayoutItem.
removeAt(i);
if (item) {
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
if (item->ownedByLayout())
delete item;
}
@@ -535,11 +535,11 @@ QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int row, int column) const
Q_D(const QGraphicsGridLayout);
if (row < 0 || row >= rowCount() || column < 0 || column >= columnCount()) {
qWarning("QGraphicsGridLayout::itemAt: invalid row, column %d, %d", row, column);
- return 0;
+ return nullptr;
}
if (QGraphicsGridLayoutEngineItem *engineItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(row, column)))
return engineItem->layoutItem();
- return 0;
+ return nullptr;
}
/*!
@@ -583,7 +583,7 @@ void QGraphicsGridLayout::removeAt(int index)
if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(index))) {
if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem())
- layoutItem->setParentLayoutItem(0);
+ layoutItem->setParentLayoutItem(nullptr);
d->engine.removeItem(gridItem);
// recalculate rowInfo.count if we remove an item that is on the right/bottommost row
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
index 6a8d5c907b..5797d9e539 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
@@ -96,7 +96,7 @@ Qt::Alignment QGraphicsGridLayoutEngine::alignment(QGraphicsLayoutItem *graphics
{
if (QGraphicsGridLayoutEngineItem *gridEngineItem = findLayoutItem(graphicsLayoutItem))
return gridEngineItem->alignment();
- return 0;
+ return { };
}
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
index e98160e40f..2f2c547977 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
@@ -68,7 +68,7 @@ class QGraphicsLayoutPrivate;
class QGraphicsGridLayoutEngineItem : public QGridLayoutItem {
public:
QGraphicsGridLayoutEngineItem(QGraphicsLayoutItem *item, int row, int columns, int rowSpan = 1, int columnSpan = 1,
- Qt::Alignment alignment = nullptr)
+ Qt::Alignment alignment = { })
: QGridLayoutItem(row, columns, rowSpan, columnSpan, alignment), q_layoutItem(item) {}
virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const override
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 7c0f836156..38cab60fc2 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1250,7 +1250,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
if (isWidget)
static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent &&
- newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0,
+ newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : nullptr,
scene);
if (scene) {
// Deliver the change to the index
@@ -1293,7 +1293,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
// Ensure any last parent focus scope does not point to this item or any of
// its descendents.
QGraphicsItem *p = parent;
- QGraphicsItem *parentFocusScopeItem = 0;
+ QGraphicsItem *parentFocusScopeItem = nullptr;
while (p) {
if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
// If this item's focus scope's focus scope item points
@@ -1301,7 +1301,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
parentFocusScopeItem = fsi;
- p->d_ptr->focusScopeItem = 0;
+ p->d_ptr->focusScopeItem = nullptr;
fsi->d_ptr->focusScopeItemChange(false);
}
break;
@@ -1321,7 +1321,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
if (subFocusItem && subFocusItem != q_ptr) {
// Find the subFocusItem's topmost focus scope within the new parent's focusscope
- QGraphicsItem *ancestorScope = 0;
+ QGraphicsItem *ancestorScope = nullptr;
QGraphicsItem *p2 = subFocusItem->d_ptr->parent;
while (p2 && p2 != p) {
if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope)
@@ -1587,7 +1587,7 @@ QGraphicsItem::~QGraphicsItem()
if (QAbstractDeclarativeData::destroyed)
QAbstractDeclarativeData::destroyed(p->declarativeData, o);
}
- p->declarativeData = 0;
+ p->declarativeData = nullptr;
p->wasDeleted = false;
}
}
@@ -1607,14 +1607,14 @@ QGraphicsItem::~QGraphicsItem()
#endif
clearFocus();
- setFocusProxy(0);
+ setFocusProxy(nullptr);
// Update focus scope item ptr.
QGraphicsItem *p = d_ptr->parent;
while (p) {
if (p->flags() & ItemIsFocusScope) {
if (p->d_ptr->focusScopeItem == this)
- p->d_ptr->focusScopeItem = 0;
+ p->d_ptr->focusScopeItem = nullptr;
break;
}
p = p->d_ptr->parent;
@@ -1630,7 +1630,7 @@ QGraphicsItem::~QGraphicsItem()
d_ptr->scene->d_func()->removeItemHelper(this);
} else {
d_ptr->resetFocusProxy();
- setParentItem(0);
+ setParentItem(nullptr);
}
#if QT_CONFIG(graphicseffect)
@@ -1639,7 +1639,7 @@ QGraphicsItem::~QGraphicsItem()
if (d_ptr->transformData) {
for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
- static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;
+ static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = nullptr;
delete t;
}
}
@@ -1751,7 +1751,7 @@ QGraphicsWidget *QGraphicsItem::parentWidget() const
QGraphicsItem *p = parentItem();
while (p && !p->isWidget())
p = p->parentItem();
- return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
+ return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : nullptr;
}
/*!
@@ -1811,7 +1811,7 @@ QGraphicsItem *QGraphicsItem::panel() const
*/
QGraphicsObject *QGraphicsItem::toGraphicsObject()
{
- return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
+ return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : nullptr;
}
/*!
@@ -1822,7 +1822,7 @@ QGraphicsObject *QGraphicsItem::toGraphicsObject()
*/
const QGraphicsObject *QGraphicsItem::toGraphicsObject() const
{
- return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
+ return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : nullptr;
}
/*!
@@ -2224,7 +2224,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
return false;
- QGraphicsItem *dummy = 0;
+ QGraphicsItem *dummy = nullptr;
if (!blockingPanel)
blockingPanel = &dummy;
@@ -2331,12 +2331,17 @@ void QGraphicsItem::setCursor(const QCursor &cursor)
view->viewport()->setMouseTracking(true);
// Note: Some of this logic is duplicated in QGraphicsView's mouse events.
if (view->underMouse()) {
- const auto itemsUnderCursor = view->items(view->mapFromGlobal(QCursor::pos()));
- for (QGraphicsItem *itemUnderCursor : itemsUnderCursor) {
- if (itemUnderCursor->hasCursor()) {
- QMetaObject::invokeMethod(view, "_q_setViewportCursor",
- Q_ARG(QCursor, itemUnderCursor->cursor()));
- break;
+ const QPoint viewPoint = view->mapFromGlobal(QCursor::pos());
+ const QPointF cursorPos = mapFromScene(view->mapToScene(viewPoint));
+ // the cursor can only change if the current item is under the mouse
+ if (boundingRect().contains(cursorPos)) {
+ const auto itemsUnderCursor = view->items(viewPoint);
+ for (QGraphicsItem *itemUnderCursor : itemsUnderCursor) {
+ if (itemUnderCursor->hasCursor()) {
+ QMetaObject::invokeMethod(view, "_q_setViewportCursor",
+ Q_ARG(QCursor, itemUnderCursor->cursor()));
+ break;
+ }
}
}
break;
@@ -2420,7 +2425,7 @@ bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const
if (p->d_ptr->explicitlyHidden)
return false;
} while ((p = p->d_ptr->parent));
- return parent == 0;
+ return parent == nullptr;
}
/*!
@@ -2959,7 +2964,7 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)
if (d_ptr->graphicsEffect) {
delete d_ptr->graphicsEffect;
- d_ptr->graphicsEffect = 0;
+ d_ptr->graphicsEffect = nullptr;
} else if (d_ptr->parent) {
d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
}
@@ -2984,7 +2989,7 @@ void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively()
if (itemPrivate->mayHaveChildWithGraphicsEffect)
return;
itemPrivate->mayHaveChildWithGraphicsEffect = 1;
- } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
+ } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : nullptr));
#endif
}
@@ -3396,13 +3401,13 @@ void QGraphicsItem::setActive(bool active)
if (!activePanel || activePanel == thisPanel) {
// Deactivate this item, and reactivate the parent panel,
// or the last active panel (if any).
- QGraphicsItem *nextToActivate = 0;
+ QGraphicsItem *nextToActivate = nullptr;
if (d_ptr->parent)
nextToActivate = d_ptr->parent->panel();
if (!nextToActivate)
nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
if (nextToActivate == this || isAncestorOf(nextToActivate))
- nextToActivate = 0;
+ nextToActivate = nullptr;
d_ptr->scene->setActivePanel(nextToActivate);
}
}
@@ -3499,7 +3504,7 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
}
// Update the child focus chain.
- QGraphicsItem *commonAncestor = 0;
+ QGraphicsItem *commonAncestor = nullptr;
if (scene && scene->focusItem() && scene->focusItem()->panel() == q_ptr->panel()) {
commonAncestor = scene->focusItem()->commonAncestorItem(f);
scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);
@@ -3552,7 +3557,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenB
while (p) {
if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
if (p->d_ptr->focusScopeItem == q_ptr) {
- p->d_ptr->focusScopeItem = 0;
+ p->d_ptr->focusScopeItem = nullptr;
if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
focusScopeItemChange(false);
}
@@ -3572,7 +3577,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenB
clearSubFocus(q_ptr);
// If this item has the scene's input focus, clear it.
- scene->setFocusItem(0);
+ scene->setFocusItem(nullptr);
}
}
@@ -3621,7 +3626,7 @@ void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");
return;
}
- for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) {
+ for (QGraphicsItem *f = item->focusProxy(); f != nullptr; f = f->focusProxy()) {
if (f == this) {
qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);
return;
@@ -4452,7 +4457,7 @@ QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) c
QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const
{
// Catch simple cases first.
- if (other == 0) {
+ if (other == nullptr) {
qWarning("QGraphicsItem::itemTransform: null pointer passed");
return QTransform();
}
@@ -4892,7 +4897,7 @@ void QGraphicsItem::stackBefore(const QGraphicsItem *sibling)
}
QList<QGraphicsItem *> *siblings = d_ptr->parent
? &d_ptr->parent->d_ptr->children
- : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
+ : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : nullptr);
if (!siblings) {
qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
return;
@@ -4949,7 +4954,7 @@ QRectF QGraphicsItem::childrenBoundingRect() const
return d_ptr->childrenBoundingRect;
d_ptr->childrenBoundingRect = QRectF();
- d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);
+ d_ptr->childrenBoundingRectHelper(nullptr, &d_ptr->childrenBoundingRect, nullptr);
d_ptr->dirtyChildrenBoundingRect = 0;
return d_ptr->childrenBoundingRect;
}
@@ -5422,7 +5427,7 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
// Render
QStyleOptionGraphicsItem option;
- const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);
+ const_cast<QGraphicsItem *>(this)->paint(&p, &option, nullptr);
p.end();
// Transform QRegion back to device space
@@ -5575,7 +5580,7 @@ void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively()
if (!itemPrivate->updateDueToGraphicsEffect)
static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
}
- } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
+ } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : nullptr));
}
void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason)
@@ -5739,7 +5744,7 @@ void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMost
if (*topMostDirtyItem == q_ptr) {
if (!dirtySceneTransform)
return; // OK, neither my ancestors nor I have dirty scene transforms.
- *topMostDirtyItem = 0;
+ *topMostDirtyItem = nullptr;
} else if (*topMostDirtyItem) {
return; // Continue backtrack.
}
@@ -5771,7 +5776,7 @@ void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *s
if (parent != q_ptr && parent->d_ptr->subFocusItem) {
if (parent->d_ptr->subFocusItem == q_ptr)
break;
- parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);
+ parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(nullptr, stopItem);
}
parent->d_ptr->subFocusItem = q_ptr;
parent->d_ptr->subFocusItemChange();
@@ -5793,7 +5798,7 @@ void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem
do {
if (parent->d_ptr->subFocusItem != q_ptr)
break;
- parent->d_ptr->subFocusItem = 0;
+ parent->d_ptr->subFocusItem = nullptr;
if (parent != stopItem && !parent->isAncestorOf(stopItem))
parent->d_ptr->subFocusItemChange();
} while (!parent->isPanel() && (parent = parent->d_ptr->parent));
@@ -5808,7 +5813,7 @@ void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem
void QGraphicsItemPrivate::resetFocusProxy()
{
for (int i = 0; i < focusProxyRefs.size(); ++i)
- *focusProxyRefs.at(i) = 0;
+ *focusProxyRefs.at(i) = nullptr;
focusProxyRefs.clear();
}
@@ -7322,7 +7327,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
// Find the active view.
- QGraphicsView *view = 0;
+ QGraphicsView *view = nullptr;
if (event->widget())
view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
@@ -7330,7 +7335,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
int i = 0;
bool movedMe = false;
while (i <= selectedItems.size()) {
- QGraphicsItem *item = 0;
+ QGraphicsItem *item = nullptr;
if (i < selectedItems.size())
item = selectedItems.at(i);
else
@@ -7891,7 +7896,7 @@ void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObj
if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
item->setParentItem(graphicsObject);
} else {
- QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
+ QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, nullptr, nullptr);
}
}
}
@@ -7908,7 +7913,7 @@ QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGra
if (index >= 0 && index < d->children.count())
return d->children.at(index)->toGraphicsObject();
else
- return 0;
+ return nullptr;
}
void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list)
@@ -7917,10 +7922,10 @@ void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObje
int childCount = d->children.count();
if (d->sendParentChangeNotification) {
for (int index = 0; index < childCount; index++)
- d->children.at(0)->setParentItem(0);
+ d->children.at(0)->setParentItem(nullptr);
} else {
for (int index = 0; index < childCount; index++)
- QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
+ QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(nullptr, nullptr, nullptr);
}
}
@@ -9949,7 +9954,7 @@ class QGraphicsTextItemPrivate
{
public:
QGraphicsTextItemPrivate()
- : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
+ : control(nullptr), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
{ }
mutable QWidgetTextControl *control;
@@ -10511,13 +10516,13 @@ QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const
v = int(inputMethodHints());
else if (dd->control)
v = dd->control->inputMethodQuery(query, QVariant());
- if (v.type() == QVariant::RectF)
+ if (v.userType() == QMetaType::QRectF)
v = v.toRectF().translated(-dd->controlOffset());
- else if (v.type() == QVariant::PointF)
+ else if (v.userType() == QMetaType::QPointF)
v = v.toPointF() - dd->controlOffset();
- else if (v.type() == QVariant::Rect)
+ else if (v.userType() == QMetaType::QRect)
v = v.toRect().translated(-dd->controlOffset().toPoint());
- else if (v.type() == QVariant::Point)
+ else if (v.userType() == QMetaType::QPoint)
v = v.toPoint() - dd->controlOffset().toPoint();
return v;
}
@@ -11232,7 +11237,7 @@ void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item)
// ### Expensive, we could maybe use dirtySceneTransform bit for optimization
item->setTransform(itemTransform);
- item->d_func()->setIsMemberOfGroup(item->group() != 0);
+ item->d_func()->setIsMemberOfGroup(item->group() != nullptr);
// ### Quite expensive. But removeFromGroup() isn't called very often.
prepareGeometryChange();
@@ -11412,18 +11417,18 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
QTransform sceneTransform = item->sceneTransform();
QTransform newEffectTransform = sceneTransform.inverted();
newEffectTransform *= effectTransform;
- scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),
+ scened->draw(item, &pixmapPainter, nullptr, &sceneTransform, nullptr, nullptr, qreal(1.0),
&newEffectTransform, false, true);
} else if (deviceCoordinates) {
// Device coordinates with info.
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, nullptr,
info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
info->drawItem);
} else {
// Item coordinates with info.
QTransform newEffectTransform = info->transformPtr->inverted();
newEffectTransform *= effectTransform;
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, nullptr,
info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,
info->drawItem);
}
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
index ad77e2f260..1c5dbf265c 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
@@ -106,7 +106,7 @@ class QGraphicsItemAnimationPrivate
{
public:
inline QGraphicsItemAnimationPrivate()
- : q(0), timeLine(0), item(0), step(0)
+ : q(nullptr), timeLine(nullptr), item(nullptr), step(0)
{ }
QGraphicsItemAnimation *q;
diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp
index 59ed7acd72..c10763d065 100644
--- a/src/widgets/graphicsview/qgraphicslayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp
@@ -97,7 +97,7 @@ void QGraphicsLayoutPrivate::getMargin(qreal *result, qreal userMargin, QStyle::
*result = 0.0;
if (QGraphicsItem *layoutParentItem = parentItem()) {
if (layoutParentItem->isWidget())
- *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0);
+ *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, nullptr);
}
}
}
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
index 1192bad51e..8694dcb36b 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
@@ -105,7 +105,7 @@ static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qre
\internal
*/
QGraphicsLayoutItemPrivate::QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *par, bool layout)
- : parent(par), userSizeHints(0), isLayout(layout), ownedByLayout(false), graphicsItem(0)
+ : parent(par), userSizeHints(nullptr), isLayout(layout), ownedByLayout(false), graphicsItem(nullptr)
{
}
diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp
index da2510a8cb..2f1526cc78 100644
--- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp
+++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
QGraphicsLayoutStyleInfo::QGraphicsLayoutStyleInfo(const QGraphicsLayoutPrivate *layout)
- : m_layout(layout), m_style(0)
+ : m_layout(layout), m_style(nullptr)
{
m_widget.reset(new QWidget); // pixelMetric might need a widget ptr
m_styleOption.initFrom(m_widget.get());
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
index 8964b3b77a..f76cc61586 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
@@ -211,7 +211,7 @@ QGraphicsLinearLayout::~QGraphicsLinearLayout()
// ~QGraphicsLayoutItem.
removeAt(i);
if (item) {
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
if (item->ownedByLayout())
delete item;
}
@@ -280,7 +280,7 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item)
Q_ASSERT(item);
d->fixIndex(&index);
d->engine.insertRow(index, d->orientation);
- QGraphicsGridLayoutEngineItem *gridEngineItem = new QGraphicsGridLayoutEngineItem(item, d->gridRow(index), d->gridColumn(index), 1, 1, 0);
+ QGraphicsGridLayoutEngineItem *gridEngineItem = new QGraphicsGridLayoutEngineItem(item, d->gridRow(index), d->gridColumn(index), 1, 1, { });
d->engine.insertItem(gridEngineItem, index);
invalidate();
}
@@ -310,7 +310,7 @@ void QGraphicsLinearLayout::removeItem(QGraphicsLayoutItem *item)
{
Q_D(QGraphicsLinearLayout);
if (QGraphicsGridLayoutEngineItem *gridItem = d->engine.findLayoutItem(item)) {
- item->setParentLayoutItem(0);
+ item->setParentLayoutItem(nullptr);
d->removeGridItem(gridItem);
delete gridItem;
invalidate();
@@ -333,7 +333,7 @@ void QGraphicsLinearLayout::removeAt(int index)
if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(index))) {
if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem())
- layoutItem->setParentLayoutItem(0);
+ layoutItem->setParentLayoutItem(nullptr);
d->removeGridItem(gridItem);
delete gridItem;
invalidate();
@@ -483,9 +483,9 @@ QGraphicsLayoutItem *QGraphicsLinearLayout::itemAt(int index) const
Q_D(const QGraphicsLinearLayout);
if (index < 0 || index >= d->engine.itemCount()) {
qWarning("QGraphicsLinearLayout::itemAt: invalid index %d", index);
- return 0;
+ return nullptr;
}
- QGraphicsLayoutItem *item = 0;
+ QGraphicsLayoutItem *item = nullptr;
if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem *>(d->engine.itemAt(index)))
item = gridItem->layoutItem();
return item;
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 7413a26261..a9a57c57fa 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -235,7 +235,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneHoverEvent
mouseEvent.setPos(event->pos());
mouseEvent.setScreenPos(event->screenPos());
mouseEvent.setButton(Qt::NoButton);
- mouseEvent.setButtons(0);
+ mouseEvent.setButtons({ });
mouseEvent.setModifiers(event->modifiers());
sendWidgetMouseEvent(&mouseEvent);
event->setAccepted(mouseEvent.isAccepted());
@@ -291,7 +291,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
}
if (!lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos());
+ QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, nullptr, event->screenPos());
lastWidgetUnderMouse = receiver;
}
@@ -315,10 +315,10 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
if (q->rect().contains(event->pos()) && q->acceptHoverEvents())
lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
else // released on the frame our outside the item, or doesn't accept hover events.
- lastWidgetUnderMouse = 0;
+ lastWidgetUnderMouse = nullptr;
QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos());
- embeddedMouseGrabber = 0;
+ embeddedMouseGrabber = nullptr;
#ifndef QT_NO_CURSOR
// ### Restore the cursor, don't override it.
@@ -368,7 +368,7 @@ void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::Focu
QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const
{
if (!widget)
- return 0;
+ return nullptr;
// Run around the focus chain until we find a widget that can take tab focus.
if (!child) {
@@ -376,12 +376,12 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next)
} else {
child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) {
- return 0;
+ return nullptr;
}
}
if (!child)
- return 0;
+ return nullptr;
QWidget *oldChild = child;
uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
@@ -394,7 +394,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next)
}
child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
} while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev));
- return 0;
+ return nullptr;
}
/*!
@@ -405,9 +405,9 @@ void QGraphicsProxyWidgetPrivate::_q_removeWidgetSlot()
Q_Q(QGraphicsProxyWidget);
if (!widget.isNull()) {
if (const auto &extra = widget->d_func()->extra)
- extra->proxyWidget = 0;
+ extra->proxyWidget = nullptr;
}
- widget = 0;
+ widget = nullptr;
delete q;
}
@@ -430,7 +430,7 @@ void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget()
QRectF widgetGeometry = widget->geometry();
QWidget *parentWidget = widget->parentWidget();
if (widget->isWindow()) {
- QGraphicsProxyWidget *proxyParent = 0;
+ QGraphicsProxyWidget *proxyParent = nullptr;
if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
// Nested window proxy (e.g., combobox popup), map widget to the
// parent widget's global coordinates, and map that to the parent
@@ -497,7 +497,7 @@ void QGraphicsProxyWidgetPrivate::unembedSubWindow(QWidget *subWin)
if (child->isWidget()) {
if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
if (proxy->widget() == subWin) {
- proxy->setWidget(0);
+ proxy->setWidget(nullptr);
scene->removeItem(proxy);
delete proxy;
return;
@@ -570,8 +570,8 @@ QGraphicsProxyWidget::~QGraphicsProxyWidget()
After this function returns, QGraphicsProxyWidget will keep its state
synchronized with that of \a widget whenever possible.
- If a widget is already embedded by this proxy when this function is
- called, that widget will first be automatically unembedded. Passing 0 for
+ If a widget is already embedded by this proxy when this function is called,
+ that widget will first be automatically unembedded. Passing \nullptr for
the \a widget argument will only unembed the widget, and the ownership of
the currently embedded widget will be passed on to the caller.
Every child widget that are embedded will also be embedded and their proxy
@@ -598,7 +598,7 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto
QObject::disconnect(widget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
widget->removeEventFilter(q);
widget->setAttribute(Qt::WA_DontShowOnScreen, false);
- widget->d_func()->extra->proxyWidget = 0;
+ widget->d_func()->extra->proxyWidget = nullptr;
resolveFont(inheritedFontResolveMask);
resolvePalette(inheritedPaletteResolveMask);
widget->update();
@@ -1081,7 +1081,7 @@ void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
return;
QDragLeaveEvent proxyDragLeave;
QCoreApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
- d->dragDropWidget = 0;
+ d->dragDropWidget = nullptr;
#endif
}
@@ -1143,7 +1143,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
// Leave the last drag drop item
QDragLeaveEvent dragLeave;
QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave);
- d->dragDropWidget = 0;
+ d->dragDropWidget = nullptr;
}
// Propagate
event->setDropAction(Qt::IgnoreAction);
@@ -1165,7 +1165,7 @@ void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event)
QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
QCoreApplication::sendEvent(d->dragDropWidget, &dropEvent);
event->setAccepted(dropEvent.isAccepted());
- d->dragDropWidget = 0;
+ d->dragDropWidget = nullptr;
}
#endif
}
@@ -1188,8 +1188,8 @@ void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_D(QGraphicsProxyWidget);
// If hoverMove was compressed away, make sure we update properly here.
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
- d->lastWidgetUnderMouse = 0;
+ QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos());
+ d->lastWidgetUnderMouse = nullptr;
}
}
@@ -1205,13 +1205,13 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
// Ignore events on the window frame.
if (!d->widget || !rect().contains(event->pos())) {
if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos());
- d->lastWidgetUnderMouse = 0;
+ QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos());
+ d->lastWidgetUnderMouse = nullptr;
}
return;
}
- d->embeddedMouseGrabber = 0;
+ d->embeddedMouseGrabber = nullptr;
d->sendWidgetMouseEvent(event);
}
@@ -1230,7 +1230,7 @@ void QGraphicsProxyWidget::ungrabMouseEvent(QEvent *event)
{
Q_D(QGraphicsProxyWidget);
Q_UNUSED(event);
- d->embeddedMouseGrabber = 0;
+ d->embeddedMouseGrabber = nullptr;
}
/*!
@@ -1372,12 +1372,12 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
switch (event->reason()) {
case Qt::TabFocusReason: {
- if (QWidget *focusChild = d->findFocusChild(0, true))
+ if (QWidget *focusChild = d->findFocusChild(nullptr, true))
focusChild->setFocus(event->reason());
break;
}
case Qt::BacktabFocusReason:
- if (QWidget *focusChild = d->findFocusChild(0, false))
+ if (QWidget *focusChild = d->findFocusChild(nullptr, false))
focusChild->setFocus(event->reason());
break;
default:
@@ -1441,17 +1441,17 @@ QVariant QGraphicsProxyWidget::inputMethodQuery(Qt::InputMethodQuery query) cons
focusWidget = d->widget;
QVariant v = focusWidget->inputMethodQuery(query);
QPointF focusWidgetPos = subWidgetRect(focusWidget).topLeft();
- switch (v.type()) {
- case QVariant::RectF:
+ switch (v.userType()) {
+ case QMetaType::QRectF:
v = v.toRectF().translated(focusWidgetPos);
break;
- case QVariant::PointF:
+ case QMetaType::QPointF:
v = v.toPointF() + focusWidgetPos;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
v = v.toRect().translated(focusWidgetPos.toPoint());
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
v = v.toPoint() + focusWidgetPos.toPoint();
break;
default:
@@ -1578,16 +1578,16 @@ QGraphicsProxyWidget *QGraphicsProxyWidget::createProxyForChildWidget(QWidget *c
return proxy;
if (!child->parentWidget()) {
qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
- return 0;
+ return nullptr;
}
QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget());
if (!parentProxy)
- return 0;
+ return nullptr;
if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection,
Q_RETURN_ARG(QGraphicsProxyWidget*, proxy), Q_ARG(const QWidget*, child)))
- return 0;
+ return nullptr;
proxy->setParent(parentProxy);
proxy->setWidget(child);
return proxy;
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index a47d0d879d..bbcceb1ce6 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -231,7 +231,6 @@
#include <QtWidgets/qgraphicslayout.h>
#include <QtWidgets/qgraphicsproxywidget.h>
#include <QtWidgets/qgraphicswidget.h>
-#include <QtGui/qmatrix.h>
#include <QtGui/qpaintengine.h>
#include <QtGui/qpainter.h>
#include <QtGui/qpixmapcache.h>
@@ -278,7 +277,7 @@ static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraph
*/
QGraphicsScenePrivate::QGraphicsScenePrivate()
: indexMethod(QGraphicsScene::BspTreeIndex),
- index(0),
+ index(nullptr),
lastItemCount(0),
hasSceneRect(false),
dirtyGrowingItemsBoundingRect(true),
@@ -301,19 +300,19 @@ QGraphicsScenePrivate::QGraphicsScenePrivate()
minimumRenderSize(0.0),
selectionChanging(0),
rectAdjust(2),
- focusItem(0),
- lastFocusItem(0),
- passiveFocusItem(0),
- tabFocusFirst(0),
- activePanel(0),
- lastActivePanel(0),
+ focusItem(nullptr),
+ lastFocusItem(nullptr),
+ passiveFocusItem(nullptr),
+ tabFocusFirst(nullptr),
+ activePanel(nullptr),
+ lastActivePanel(nullptr),
activationRefCount(0),
childExplicitActivation(0),
- lastMouseGrabberItem(0),
- dragDropItem(0),
- enterWidget(0),
+ lastMouseGrabberItem(nullptr),
+ dragDropItem(nullptr),
+ enterWidget(nullptr),
lastDropAction(Qt::IgnoreAction),
- style(0)
+ style(nullptr)
{
}
@@ -443,8 +442,8 @@ void QGraphicsScenePrivate::_q_polishItems()
return;
const QVariant booleanTrueVariant(true);
- QGraphicsItem *item = 0;
- QGraphicsItemPrivate *itemd = 0;
+ QGraphicsItem *item = nullptr;
+ QGraphicsItemPrivate *itemd = nullptr;
const int oldUnpolishedCount = unpolishedItems.count();
for (int i = 0; i < oldUnpolishedCount; ++i) {
@@ -602,7 +601,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
unregisterScenePosItem(item);
QGraphicsScene *oldScene = item->d_func()->scene;
- item->d_func()->scene = 0;
+ item->d_func()->scene = nullptr;
//We need to remove all children first because they might use their parent
//attributes (e.g. sceneTransform).
@@ -614,7 +613,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (!item->d_ptr->inDestructor && !item->parentItem() && item->isWidget()) {
QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
- widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0);
+ widget->d_func()->fixFocusChainBeforeReparenting(nullptr, oldScene, nullptr);
}
// Unregister focus proxy.
@@ -625,7 +624,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (parentItem->scene()) {
Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem",
"Parent item's scene is different from this item's scene");
- item->setParentItem(0);
+ item->setParentItem(nullptr);
}
} else {
unregisterTopLevelItem(item);
@@ -633,17 +632,17 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
// Reset the mouse grabber and focus item data.
if (item == focusItem)
- focusItem = 0;
+ focusItem = nullptr;
if (item == lastFocusItem)
- lastFocusItem = 0;
+ lastFocusItem = nullptr;
if (item == passiveFocusItem)
- passiveFocusItem = 0;
+ passiveFocusItem = nullptr;
if (item == activePanel) {
// ### deactivate...
- activePanel = 0;
+ activePanel = nullptr;
}
if (item == lastActivePanel)
- lastActivePanel = 0;
+ lastActivePanel = nullptr;
// Change tabFocusFirst to the next widget in focus chain if removing the current one.
if (item == tabFocusFirst) {
@@ -651,7 +650,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (wd->focusNext && wd->focusNext != tabFocusFirst && wd->focusNext->scene() == q)
tabFocusFirst = wd->focusNext;
else
- tabFocusFirst = 0;
+ tabFocusFirst = nullptr;
}
// Cancel active touches
@@ -705,11 +704,11 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
// Reset the last mouse grabber item
if (item == lastMouseGrabberItem)
- lastMouseGrabberItem = 0;
+ lastMouseGrabberItem = nullptr;
// Reset the current drop item
if (item == dragDropItem)
- dragDropItem = 0;
+ dragDropItem = nullptr;
// Reenable selectionChanged() for individual items
--selectionChanging;
@@ -752,8 +751,8 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin
q->setFocus(Qt::ActiveWindowFocusReason);
// Find the item's panel.
- QGraphicsItem *panel = item ? item->panel() : 0;
- lastActivePanel = panel ? activePanel : 0;
+ QGraphicsItem *panel = item ? item->panel() : nullptr;
+ lastActivePanel = panel ? activePanel : nullptr;
if (panel == activePanel || (!q->isActive() && !duringActivationEvent))
return;
@@ -764,7 +763,7 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin
if (QGraphicsItem *fi = activePanel->focusItem()) {
// Remove focus from the current focus item.
if (fi == q->focusItem())
- setFocusItemHelper(0, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);
+ setFocusItemHelper(nullptr, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false);
}
QEvent event(QEvent::WindowDeactivate);
@@ -841,7 +840,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
// accept input focus.
if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable)
|| !item->isVisible() || !item->isEnabled())) {
- item = 0;
+ item = nullptr;
}
// Set focus on the scene if an item requests focus.
@@ -849,7 +848,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
q->setFocus(focusReason);
if (item == focusItem) {
if (emitFocusChanged)
- emit q->focusItemChanged(focusItem, (QGraphicsItem *)0, focusReason);
+ emit q->focusItemChanged(focusItem, (QGraphicsItem *)nullptr, focusReason);
return;
}
}
@@ -869,7 +868,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
}
#endif //QT_NO_IM
- focusItem = 0;
+ focusItem = nullptr;
QFocusEvent event(QEvent::FocusOut, focusReason);
sendEvent(lastFocusItem, &event);
}
@@ -877,7 +876,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
// This handles the case that the item has been removed from the
// scene in response to the FocusOut event.
if (item && item->scene() != q)
- item = 0;
+ item = nullptr;
if (item)
focusItem = item;
@@ -1039,7 +1038,7 @@ void QGraphicsScenePrivate::clearMouseGrabber()
{
if (!mouseGrabberItems.isEmpty())
mouseGrabberItems.first()->ungrabMouse();
- lastMouseGrabberItem = 0;
+ lastMouseGrabberItem = nullptr;
}
/*!
@@ -1365,10 +1364,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// Update window activation.
QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);
- QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0;
+ QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : nullptr;
if (newActiveWindow && newActiveWindow->isBlockedByModalPanel(&topItem)) {
// pass activation to the blocking modal window
- newActiveWindow = topItem ? topItem->window() : 0;
+ newActiveWindow = topItem ? topItem->window() : nullptr;
}
if (newActiveWindow != q->activeWindow())
@@ -1409,7 +1408,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// If nobody could take focus, clear it.
if (!stickyFocus && !setFocus && !sceneModality)
- q->setFocusItem(0, Qt::MouseFocusReason);
+ q->setFocusItem(nullptr, Qt::MouseFocusReason);
// Any item will do.
if (sceneModality && cachedItemsUnderMouse.isEmpty())
@@ -1694,7 +1693,7 @@ QGraphicsScene::~QGraphicsScene()
// Remove this scene from all associated views.
for (int j = 0; j < d->views.size(); ++j)
- d->views.at(j)->setScene(0);
+ d->views.at(j)->setScene(nullptr);
}
/*!
@@ -2432,7 +2431,7 @@ QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *>
}
// Find the common ancestor for all items
- QGraphicsItem *commonAncestor = 0;
+ QGraphicsItem *commonAncestor = nullptr;
if (!ancestors.isEmpty()) {
while (n < items.size()) {
int commonIndex = -1;
@@ -2446,7 +2445,7 @@ QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *>
} while ((parent = parent->parentItem()));
if (commonIndex == -1) {
- commonAncestor = 0;
+ commonAncestor = nullptr;
break;
}
@@ -2545,7 +2544,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// from this scene.
if (QGraphicsItem *itemParent = item->d_ptr->parent) {
if (itemParent->d_ptr->scene != this)
- item->setParentItem(0);
+ item->setParentItem(nullptr);
}
// Add the item to this scene
@@ -2568,8 +2567,16 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
++d->selectionChanging;
int oldSelectedItemSize = d->selectedItems.size();
- // Enable mouse tracking if the item accepts hover events or has a cursor set.
- if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) {
+ // Enable mouse tracking if we haven't already done so, and the item needs it.
+ // We cannot use itemAcceptsHoverEvents_helper() here, since we need to enable
+ // mouse tracking also if this item is temporarily blocked by a modal panel.
+
+ auto needsMouseTracking = [](const QGraphicsItemPrivate *item) {
+ return item->acceptsHover
+ || (item->isWidget && static_cast<const QGraphicsWidgetPrivate *>(item)->hasDecoration());
+ };
+
+ if (d->allItemsIgnoreHoverEvents && needsMouseTracking(item->d_ptr.data())) {
d->allItemsIgnoreHoverEvents = false;
d->enableMouseTrackingOnViews();
}
@@ -2903,7 +2910,7 @@ QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, cons
*/
QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags)
{
- QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags);
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(nullptr, wFlags);
proxy->setWidget(widget);
addItem(proxy);
return proxy;
@@ -2936,7 +2943,7 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
QVariant::fromValue<QGraphicsScene *>(0)));
QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
- if (targetScene != 0 && targetScene != this) {
+ if (targetScene != nullptr && targetScene != this) {
targetScene->addItem(item);
return;
}
@@ -3038,7 +3045,7 @@ void QGraphicsScene::clearFocus()
if (d->hasFocus) {
d->hasFocus = false;
d->passiveFocusItem = d->focusItem;
- setFocusItem(0, Qt::OtherFocusReason);
+ setFocusItem(nullptr, Qt::OtherFocusReason);
}
}
@@ -3182,13 +3189,13 @@ QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
return QVariant();
const QTransform matrix = d->focusItem->sceneTransform();
QVariant value = d->focusItem->inputMethodQuery(query);
- if (value.type() == QVariant::RectF)
+ if (value.userType() == QMetaType::QRectF)
value = matrix.mapRect(value.toRectF());
- else if (value.type() == QVariant::PointF)
+ else if (value.userType() == QMetaType::QPointF)
value = matrix.map(value.toPointF());
- else if (value.type() == QVariant::Rect)
+ else if (value.userType() == QMetaType::QRect)
value = matrix.mapRect(value.toRect());
- else if (value.type() == QVariant::Point)
+ else if (value.userType() == QMetaType::QPoint)
value = matrix.map(value.toPoint());
return value;
}
@@ -3484,7 +3491,7 @@ bool QGraphicsScene::event(QEvent *event)
// Deactivate the active panel (but keep it so we can
// reactivate it later).
QGraphicsItem *lastActivePanel = d->activePanel;
- d->setActivePanelHelper(0, true);
+ d->setActivePanelHelper(nullptr, true);
d->lastActivePanel = lastActivePanel;
} else {
// Activate all toplevel items.
@@ -3613,7 +3620,7 @@ void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMen
void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
Q_D(QGraphicsScene);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
d->lastDropAction = Qt::IgnoreAction;
event->accept();
}
@@ -3697,7 +3704,7 @@ void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
d->cloneDragDropEvent(&dragLeave, event);
d->sendDragDropEvent(d->dragDropItem, &dragLeave);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
}
// Propagate
event->setDropAction(Qt::IgnoreAction);
@@ -3717,7 +3724,7 @@ void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
if (d->dragDropItem) {
// Leave the last drag drop item
d->sendDragDropEvent(d->dragDropItem, event);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
}
}
@@ -3735,7 +3742,7 @@ void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event)
if (d->dragDropItem) {
// Drop on the last drag drop item
d->sendDragDropEvent(d->dragDropItem, event);
- d->dragDropItem = 0;
+ d->dragDropItem = nullptr;
}
}
@@ -3785,7 +3792,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
Q_D(QGraphicsScene);
d->hasFocus = false;
d->passiveFocusItem = d->focusItem;
- setFocusItem(0, focusEvent->reason());
+ setFocusItem(nullptr, focusEvent->reason());
// Remove all popups when the scene loses focus.
if (!d->popupWidgets.isEmpty())
@@ -3817,7 +3824,7 @@ void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(),
helpEvent->scenePos(),
helpEvent->widget());
- QGraphicsItem *toolTipItem = 0;
+ QGraphicsItem *toolTipItem = nullptr;
for (int i = 0; i < itemsAtPos.size(); ++i) {
QGraphicsItem *tmp = itemsAtPos.at(i);
if (tmp->d_func()->isProxyWidget()) {
@@ -3875,7 +3882,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
hoverEvent->widget());
}
- QGraphicsItem *item = 0;
+ QGraphicsItem *item = nullptr;
for (int i = 0; i < cachedItemsUnderMouse.size(); ++i) {
QGraphicsItem *tmp = cachedItemsUnderMouse.at(i);
if (itemAcceptsHoverEvents_helper(tmp)) {
@@ -3886,13 +3893,13 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
// Find the common ancestor item for the new topmost hoverItem and the
// last item in the hoverItem list.
- QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : 0;
+ QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : nullptr;
while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
commonAncestorItem = commonAncestorItem->parentItem();
if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
// The common ancestor isn't in the same panel as the two hovered
// items.
- commonAncestorItem = 0;
+ commonAncestorItem = nullptr;
}
// Check if the common ancestor item is known.
@@ -4122,7 +4129,7 @@ void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
if (d->lastMouseGrabberItemHasImplicitMouseGrab)
d->mouseGrabberItems.constLast()->ungrabMouse();
} else {
- d->lastMouseGrabberItem = 0;
+ d->lastMouseGrabberItem = nullptr;
}
// Generate a hoverevent
@@ -4354,7 +4361,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &
pixmapPainter.setWorldTransform(itemToPixmap, true);
// Render.
- _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection);
+ _q_paintItem(item, &pixmapPainter, option, nullptr, false, painterStateProtection);
pixmapPainter.end();
if (!subPix.isNull()) {
@@ -4748,7 +4755,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
return;
QTransform transform(Qt::Uninitialized);
- QTransform *transformPtr = 0;
+ QTransform *transformPtr = nullptr;
bool translateOnlyTransform = false;
#define ENSURE_TRANSFORM_PTR \
if (!transformPtr) { \
@@ -4858,7 +4865,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
item->d_ptr->graphicsEffect->draw(painter);
painter->setWorldTransform(restoreTransform);
- sourced->info = 0;
+ sourced->info = nullptr;
} else
#endif // QT_CONFIG(graphicseffect)
{
@@ -4936,7 +4943,7 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q
Q_ASSERT(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents));
Q_ASSERT(transformPtr);
item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion
- ? *exposedRegion : QRegion(), exposedRegion == 0);
+ ? *exposedRegion : QRegion(), exposedRegion == nullptr);
const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape;
bool restorePainterClip = false;
@@ -5322,7 +5329,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool
if (itemClipsChildrenToShape) {
// Reset updateClip.
for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->setUpdateClip(0);
+ views.at(i)->d_func()->setUpdateClip(nullptr);
}
} else if (wasDirtyParentSceneTransform) {
item->d_ptr->invalidateChildrenSceneTransform();
@@ -5378,7 +5385,7 @@ void QGraphicsScene::drawItems(QPainter *painter,
// Determine view, expose and flags.
QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
- QRegion *expose = 0;
+ QRegion *expose = nullptr;
const quint32 oldRectAdjust = d->rectAdjust;
if (view) {
d->updateAll = false;
@@ -5462,7 +5469,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
}
// The item must be a widget.
- QGraphicsWidget *widget = 0;
+ QGraphicsWidget *widget = nullptr;
if (!item) {
widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev;
} else {
@@ -5478,7 +5485,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
// Run around the focus chain until we find a widget that can take tab focus.
do {
if (widget->flags() & QGraphicsItem::ItemIsFocusable
- && widget->isEnabled() && widget->isVisibleTo(0)
+ && widget->isEnabled() && widget->isVisibleTo(nullptr)
&& (widget->focusPolicy() & Qt::TabFocus)
&& (!item || !item->isPanel() || item->isAncestorOf(widget))
) {
@@ -5763,7 +5770,7 @@ void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget)
}
// Activate the widget's panel (all windows are panels).
- QGraphicsItem *panel = widget ? widget->panel() : 0;
+ QGraphicsItem *panel = widget ? widget->panel() : nullptr;
setActivePanel(panel);
// Raise
@@ -5945,7 +5952,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i);
// update state
- QGraphicsItem *item = 0;
+ QGraphicsItem *item = nullptr;
if (touchPoint.state() == Qt::TouchPointPressed) {
if (sceneTouchEvent->device()->type() == QTouchDevice::TouchPad) {
// on touch-pad devices, send all touch points to the same item
@@ -6103,7 +6110,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
// If nobody could take focus, clear it.
if (!stickyFocus && !setFocus)
- q->setFocusItem(0, Qt::MouseFocusReason);
+ q->setFocusItem(nullptr, Qt::MouseFocusReason);
}
bool res = false;
@@ -6117,7 +6124,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
eventAccepted = touchEvent->isAccepted();
if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
// item was deleted
- item = 0;
+ item = nullptr;
} else {
item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
}
@@ -6251,7 +6258,7 @@ void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &ges
if (!gesture->hasHotSpot())
continue;
const Qt::GestureType gestureType = gesture->gestureType();
- QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0);
+ QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, nullptr);
for (int j = 0; j < items.size(); ++j) {
QGraphicsItem *item = items.at(j);
@@ -6323,7 +6330,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
if (!startedGestures.isEmpty()) {
QSet<QGesture *> normalGestures; // that have just one target
QSet<QGesture *> conflictedGestures; // that have multiple possible targets
- gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0,
+ gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, nullptr,
&normalGestures, &conflictedGestures);
cachedTargetItems = cachedItemGestures.keys();
std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
@@ -6497,7 +6504,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
}
gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures,
- &cachedItemGestures, &targetsSet, 0, 0);
+ &cachedItemGestures, &targetsSet, nullptr, nullptr);
cachedTargetItems = targetsSet.values();
std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
@@ -6537,7 +6544,7 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
{
Q_ASSERT(original);
QGraphicsItem *originalItem = gestureTargets.value(original);
- if (originalItem == 0) // we only act on accepted gestures, which implies it has a target.
+ if (originalItem == nullptr) // we only act on accepted gestures, which implies it has a target.
return;
// iterate over all active gestures and for each find the owner
@@ -6560,13 +6567,13 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
QSet<QGesture *> almostCanceledGestures = canceledGestures;
QSet<QGesture *>::Iterator setIter;
while (!almostCanceledGestures.isEmpty()) {
- QGraphicsObject *target = 0;
+ QGraphicsObject *target = nullptr;
QSet<QGesture*> gestures;
setIter = almostCanceledGestures.begin();
// sort per target item
while (setIter != almostCanceledGestures.end()) {
QGraphicsObject *item = gestureTargets.value(*setIter);
- if (target == 0)
+ if (target == nullptr)
target = item;
if (target == item) {
gestures << *setIter;
@@ -6590,7 +6597,7 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
if (!g->hasHotSpot())
continue;
- QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0);
+ QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, nullptr);
for (int j = 0; j < items.size(); ++j) {
QGraphicsObject *item = items.at(j)->toGraphicsObject();
if (!item)
diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h
index d36a871533..3ba9bddc32 100644
--- a/src/widgets/graphicsview/qgraphicsscene.h
+++ b/src/widgets/graphicsview/qgraphicsscene.h
@@ -47,7 +47,6 @@
#include <QtGui/qbrush.h>
#include <QtGui/qfont.h>
#include <QtGui/qtransform.h>
-#include <QtGui/qmatrix.h>
#include <QtGui/qpen.h>
QT_REQUIRE_CONFIG(graphicsview);
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp
index 5077a39d67..048ea6dc7d 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp
@@ -278,8 +278,8 @@ class QGraphicsSceneEventPrivate
{
public:
inline QGraphicsSceneEventPrivate()
- : widget(0),
- q_ptr(0)
+ : widget(nullptr),
+ q_ptr(nullptr)
{ }
inline virtual ~QGraphicsSceneEventPrivate()
@@ -344,8 +344,7 @@ class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate
Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent)
public:
inline QGraphicsSceneMouseEventPrivate()
- : button(Qt::NoButton),
- buttons(0), modifiers(0), source(Qt::MouseEventNotSynthesized), flags(0)
+ : button(Qt::NoButton), source(Qt::MouseEventNotSynthesized)
{ }
QPointF pos;
@@ -691,17 +690,15 @@ class QGraphicsSceneWheelEventPrivate : public QGraphicsSceneEventPrivate
{
Q_DECLARE_PUBLIC(QGraphicsSceneWheelEvent)
public:
- inline QGraphicsSceneWheelEventPrivate()
- : buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal)
- { }
+ inline QGraphicsSceneWheelEventPrivate() = default;
QPointF pos;
QPointF scenePos;
QPoint screenPos;
Qt::MouseButtons buttons;
Qt::KeyboardModifiers modifiers;
- int delta;
- Qt::Orientation orientation;
+ int delta = 0;
+ Qt::Orientation orientation = Qt::Horizontal;
};
/*!
@@ -872,15 +869,13 @@ class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate
{
Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent)
public:
- inline QGraphicsSceneContextMenuEventPrivate()
- : modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other)
- { }
+ inline QGraphicsSceneContextMenuEventPrivate() = default;
QPointF pos;
QPointF scenePos;
QPoint screenPos;
Qt::KeyboardModifiers modifiers;
- QGraphicsSceneContextMenuEvent::Reason reason;
+ QGraphicsSceneContextMenuEvent::Reason reason = QGraphicsSceneContextMenuEvent::Other;
};
/*!
@@ -1295,7 +1290,7 @@ class QGraphicsSceneDragDropEventPrivate : public QGraphicsSceneEventPrivate
Q_DECLARE_PUBLIC(QGraphicsSceneDragDropEvent)
public:
inline QGraphicsSceneDragDropEventPrivate()
- : source(0), mimeData(0)
+ : source(nullptr), mimeData(nullptr)
{ }
QPointF pos;
diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp
index 0f0d9aaddc..fa763de05d 100644
--- a/src/widgets/graphicsview/qgraphicstransform.cpp
+++ b/src/widgets/graphicsview/qgraphicstransform.cpp
@@ -112,7 +112,7 @@ void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
Q_ASSERT(d_ptr->transformData);
d_ptr->transformData->graphicsTransforms.removeAll(q);
d_ptr->dirtySceneTransform = 1;
- item = 0;
+ item = nullptr;
}
item = i;
@@ -138,7 +138,7 @@ QGraphicsTransform::QGraphicsTransform(QObject *parent)
QGraphicsTransform::~QGraphicsTransform()
{
Q_D(QGraphicsTransform);
- d->setItem(0);
+ d->setItem(nullptr);
}
/*!
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 57be850829..686b41960a 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -348,22 +348,21 @@ QGraphicsViewPrivate::QGraphicsViewPrivate()
hasUpdateClip(false),
mousePressButton(Qt::NoButton),
leftIndent(0), topIndent(0),
- lastMouseEvent(QEvent::None, QPointF(), QPointF(), QPointF(), Qt::NoButton, 0, 0),
+ lastMouseEvent(QEvent::None, QPointF(), QPointF(), QPointF(), Qt::NoButton, { }, { }),
alignment(Qt::AlignCenter),
transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor),
viewportUpdateMode(QGraphicsView::MinimalViewportUpdate),
- optimizationFlags(0),
- scene(0),
+ scene(nullptr),
#if QT_CONFIG(rubberband)
rubberBanding(false),
rubberBandSelectionMode(Qt::IntersectsItemShape),
rubberBandSelectionOperation(Qt::ReplaceSelection),
#endif
- handScrollMotions(0), cacheMode(0),
+ handScrollMotions(0),
#ifndef QT_NO_CURSOR
hasStoredOriginalCursor(false),
#endif
- lastDragDropEvent(0),
+ lastDragDropEvent(nullptr),
updateSceneSlotReimplementedChecked(false)
{
styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS);
@@ -385,7 +384,7 @@ void QGraphicsViewPrivate::recalculateContentSize()
int height = maxSize.height();
QRectF viewRect = matrix.mapRect(q->sceneRect());
- bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q));
+ bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q));
if (frameOnlyAround) {
if (hbarpolicy == Qt::ScrollBarAlwaysOn)
height -= frameWidth * 2;
@@ -395,7 +394,7 @@ void QGraphicsViewPrivate::recalculateContentSize()
// Adjust the maximum width and height of the viewport based on the width
// of visible scroll bars.
- int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q);
+ int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, q);
if (frameOnlyAround)
scrollBarExtent += frameWidth * 2;
@@ -964,7 +963,7 @@ static inline void QRect_unite(QRect *rect, const QRect &other)
/*
Calling this function results in update rects being clipped to the item's
bounding rect. Note that updates prior to this function call is not clipped.
- The clip is removed by passing 0.
+ The clip is removed by passing \nullptr.
*/
void QGraphicsViewPrivate::setUpdateClip(QGraphicsItem *item)
{
@@ -1163,19 +1162,19 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg
void QGraphicsViewPrivate::updateInputMethodSensitivity()
{
Q_Q(QGraphicsView);
- QGraphicsItem *focusItem = 0;
+ QGraphicsItem *focusItem = nullptr;
bool enabled = scene && (focusItem = scene->focusItem())
&& (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod);
q->setAttribute(Qt::WA_InputMethodEnabled, enabled);
q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled);
if (!enabled) {
- q->setInputMethodHints(0);
+ q->setInputMethodHints({ });
return;
}
QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget()
- ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0;
+ ? static_cast<QGraphicsProxyWidget *>(focusItem) : nullptr;
if (!proxy) {
q->setInputMethodHints(focusItem->inputMethodHints());
} else if (QWidget *widget = proxy->widget()) {
@@ -1183,7 +1182,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity()
widget = fw;
q->setInputMethodHints(widget->inputMethodHints());
} else {
- q->setInputMethodHints(0);
+ q->setInputMethodHints({ });
}
}
@@ -1193,7 +1192,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity()
QGraphicsView::QGraphicsView(QWidget *parent)
: QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
{
- setViewport(0);
+ setViewport(nullptr);
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
// Investigate leaving these disabled by default.
@@ -1209,7 +1208,7 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
: QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
{
setScene(scene);
- setViewport(0);
+ setViewport(nullptr);
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
// Investigate leaving these disabled by default.
@@ -1223,7 +1222,7 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent)
: QAbstractScrollArea(dd, parent)
{
- setViewport(0);
+ setViewport(nullptr);
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
// Investigate leaving these disabled by default.
@@ -1796,7 +1795,13 @@ void QGraphicsView::setSceneRect(const QRectF &rect)
d->recalculateContentSize();
}
+#if QT_DEPRECATED_SINCE(5, 15)
+
/*!
+ \obsolete
+
+ Use transform() instead.
+
Returns the current transformation matrix for the view. If no current
transformation is set, the identity matrix is returned.
@@ -1809,6 +1814,10 @@ QMatrix QGraphicsView::matrix() const
}
/*!
+ \obsolete
+
+ Use setTransform() instead.
+
Sets the view's current transformation matrix to \a matrix.
If \a combine is true, then \a matrix is combined with the current matrix;
@@ -1840,6 +1849,10 @@ void QGraphicsView::setMatrix(const QMatrix &matrix, bool combine)
}
/*!
+ \obsolete
+
+ Use resetTransform() instead.
+
Resets the view transformation matrix to the identity matrix.
\sa resetTransform()
@@ -1849,6 +1862,8 @@ void QGraphicsView::resetMatrix()
resetTransform();
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
/*!
Rotates the current view transformation \a angle degrees clockwise.
@@ -2375,7 +2390,7 @@ QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const
{
Q_D(const QGraphicsView);
if (!d->scene)
- return 0;
+ return nullptr;
const QList<QGraphicsItem *> itemsAtPos = items(pos);
return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first();
}
@@ -2590,13 +2605,13 @@ QVariant QGraphicsView::inputMethodQuery(Qt::InputMethodQuery query) const
return QVariant();
QVariant value = d->scene->inputMethodQuery(query);
- if (value.type() == QVariant::RectF)
+ if (value.userType() == QMetaType::QRectF)
value = d->mapRectFromScene(value.toRectF());
- else if (value.type() == QVariant::PointF)
+ else if (value.userType() == QMetaType::QPointF)
value = mapFromScene(value.toPointF());
- else if (value.type() == QVariant::Rect)
+ else if (value.userType() == QMetaType::QRect)
value = d->mapRectFromScene(value.toRect()).toRect();
- else if (value.type() == QVariant::Point)
+ else if (value.userType() == QMetaType::QPoint)
value = mapFromScene(value.toPoint());
return value;
}
@@ -2889,7 +2904,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
}
d->useLastMouseEvent = false;
// a hack to pass a viewport pointer to the scene inside the leave event
- Q_ASSERT(event->d == 0);
+ Q_ASSERT(event->d == nullptr);
QScopedValueRollback<QEventPrivate *> rb(event->d);
event->d = reinterpret_cast<QEventPrivate *>(viewport());
QCoreApplication::sendEvent(d->scene, event);
@@ -3020,7 +3035,7 @@ void QGraphicsView::dropEvent(QDropEvent *event)
event->setDropAction(sceneEvent.dropAction());
delete d->lastDragDropEvent;
- d->lastDragDropEvent = 0;
+ d->lastDragDropEvent = nullptr;
}
/*!
@@ -3078,7 +3093,7 @@ void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
sceneEvent.setWidget(d->lastDragDropEvent->widget());
sceneEvent.setSource(d->lastDragDropEvent->source());
delete d->lastDragDropEvent;
- d->lastDragDropEvent = 0;
+ d->lastDragDropEvent = nullptr;
// Send it to the scene.
QCoreApplication::sendEvent(d->scene, &sceneEvent);
@@ -3526,7 +3541,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
d->scene->d_func()->rectAdjust = 1;
else
d->scene->d_func()->rectAdjust = 2;
- d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0,
+ d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : nullptr,
&d->exposedRegion, viewport());
d->scene->d_func()->rectAdjust = oldRectAdjust;
// Make sure the painter's world transform is restored correctly when
@@ -3795,7 +3810,7 @@ void QGraphicsView::drawItems(QPainter *painter, int numItems,
{
Q_D(QGraphicsView);
if (d->scene) {
- QWidget *widget = painter->device() == viewport() ? viewport() : 0;
+ QWidget *widget = painter->device() == viewport() ? viewport() : nullptr;
d->scene->drawItems(painter, numItems, items, options, widget);
}
}
diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h
index 1389796c3f..e98ec52d8f 100644
--- a/src/widgets/graphicsview/qgraphicsview.h
+++ b/src/widgets/graphicsview/qgraphicsview.h
@@ -165,9 +165,11 @@ public:
void setSceneRect(const QRectF &rect);
inline void setSceneRect(qreal x, qreal y, qreal w, qreal h);
- QMatrix matrix() const;
- void setMatrix(const QMatrix &matrix, bool combine = false);
- void resetMatrix();
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_X("Use transform()") QMatrix matrix() const;
+ QT_DEPRECATED_X("Use setTransform()") void setMatrix(const QMatrix &matrix, bool combine = false);
+ QT_DEPRECATED_X("Use resetTransform()") void resetMatrix();
+#endif // QT_DEPRECATED_SINCE(5, 15)
QTransform transform() const;
QTransform viewportTransform() const;
bool isTransformed() const;
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index cf041b9817..1035ed3575 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -172,7 +172,7 @@ QT_BEGIN_NAMESPACE
window, a tool, a popup, etc).
*/
QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QGraphicsObject(*new QGraphicsWidgetPrivate, 0), QGraphicsLayoutItem(0, false)
+ : QGraphicsObject(*new QGraphicsWidgetPrivate, nullptr), QGraphicsLayoutItem(nullptr, false)
{
Q_D(QGraphicsWidget);
d->init(parent, wFlags);
@@ -184,7 +184,7 @@ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
Constructs a new QGraphicsWidget, using \a dd as parent.
*/
QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QGraphicsObject(dd, 0), QGraphicsLayoutItem(0, false)
+ : QGraphicsObject(dd, nullptr), QGraphicsLayoutItem(nullptr, false)
{
Q_D(QGraphicsWidget);
d->init(parent, wFlags);
@@ -241,7 +241,7 @@ QGraphicsWidget::~QGraphicsWidget()
if (QGraphicsScene *scn = scene()) {
QGraphicsScenePrivate *sceneD = scn->d_func();
if (sceneD->tabFocusFirst == this)
- sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext);
+ sceneD->tabFocusFirst = (d->focusNext == this ? nullptr : d->focusNext);
}
d->focusPrev->d_func()->focusNext = d->focusNext;
d->focusNext->d_func()->focusPrev = d->focusPrev;
@@ -263,15 +263,15 @@ QGraphicsWidget::~QGraphicsWidget()
if (item->isWidget()) {
QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
if (widget->parentLayoutItem() == d->layout)
- widget->setParentLayoutItem(0);
+ widget->setParentLayoutItem(nullptr);
}
}
- d->layout = 0;
+ d->layout = nullptr;
delete temp;
}
// Remove this graphics widget from widgetStyles
- widgetStyles()->setStyleForWidget(this, 0);
+ widgetStyles()->setStyleForWidget(this, nullptr);
// Unset the parent here, when we're still a QGraphicsWidget.
// It is otherwise done in ~QGraphicsItem() where we'd be
@@ -942,7 +942,7 @@ QStyle *QGraphicsWidget::style() const
*/
void QGraphicsWidget::setStyle(QStyle *style)
{
- setAttribute(Qt::WA_SetStyle, style != 0);
+ setAttribute(Qt::WA_SetStyle, style != nullptr);
widgetStyles()->setStyleForWidget(this, style);
// Deliver StyleChange to the widget itself (doesn't propagate).
@@ -1557,7 +1557,7 @@ bool QGraphicsWidget::focusNextPrevChild(bool next)
{
Q_D(QGraphicsWidget);
// Let the parent's focusNextPrevChild implementation decide what to do.
- QGraphicsWidget *parent = 0;
+ QGraphicsWidget *parent = nullptr;
if (!isWindow() && (parent = parentWidget()))
return parent->focusNextPrevChild(next);
if (!d->scene)
@@ -1995,7 +1995,7 @@ void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled)
*/
void QGraphicsWidget::addAction(QAction *action)
{
- insertAction(0, action);
+ insertAction(nullptr, action);
}
/*!
@@ -2012,7 +2012,7 @@ void QGraphicsWidget::addActions(QList<QAction *> actions)
#endif
{
for (int i = 0; i < actions.count(); ++i)
- insertAction(0, actions.at(i));
+ insertAction(nullptr, actions.at(i));
}
/*!
@@ -2041,7 +2041,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action)
int pos = d->actions.indexOf(before);
if (pos < 0) {
- before = 0;
+ before = nullptr;
pos = d->actions.size();
}
d->actions.insert(pos, action);
@@ -2346,7 +2346,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap
frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal);
frameOptions.rect = windowFrameRect;
- frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget);
+ frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, widget);
frameOptions.midLineWidth = 1;
style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget);
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
index 0156faf8e4..e6f39d6803 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -322,7 +322,7 @@ void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *optio
option->titleBarState = Qt::WindowNoState;
}
QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar");
- QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0);
+ QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, nullptr);
option->text = QFontMetrics(windowTitleFont).elidedText(
windowData->windowTitle, Qt::ElideRight, textRect.width());
}
@@ -690,7 +690,7 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent
break;
case Qt::TitleBarArea:
windowData->buttonRect = q->style()->subControlRect(
- QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, 0);
+ QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, nullptr);
if (windowData->buttonRect.contains(pos.toPoint()))
windowData->buttonMouseOver = true;
event->ignore();
@@ -707,7 +707,7 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent
Q_UNUSED(cursorShape);
#endif
// update buttons if we hover over them
- windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0);
+ windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), nullptr);
if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton)
windowData->hoveredSubControl = QStyle::SC_TitleBarLabel;
@@ -781,7 +781,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new
if (!parent && oldScene && oldScene != newScene && oldScene->d_func()->tabFocusFirst == q) {
// detach from old scene's top level focus chain.
- oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : 0;
+ oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : nullptr;
}
// detach from current focus chain; skip this widget subtree.
diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp
index e18f1fa4c4..38c2df5fc6 100644
--- a/src/widgets/graphicsview/qsimplex_p.cpp
+++ b/src/widgets/graphicsview/qsimplex_p.cpp
@@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
/*!
\internal
*/
-QSimplex::QSimplex() : objective(0), rows(0), columns(0), firstArtificial(0), matrix(0)
+QSimplex::QSimplex() : objective(nullptr), rows(0), columns(0), firstArtificial(0), matrix(nullptr)
{
}
@@ -93,7 +93,7 @@ QSimplex::~QSimplex()
*/
void QSimplex::clearDataStructures()
{
- if (matrix == 0)
+ if (matrix == nullptr)
return;
// Matrix
@@ -101,7 +101,7 @@ void QSimplex::clearDataStructures()
columns = 0;
firstArtificial = 0;
free(matrix);
- matrix = 0;
+ matrix = nullptr;
// Constraints
for (int i = 0; i < constraints.size(); ++i) {
@@ -113,7 +113,7 @@ void QSimplex::clearDataStructures()
// Other
variables.clear();
- objective = 0;
+ objective = nullptr;
}
/*!
@@ -195,7 +195,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints)
QSimplexVariable *artificial;
Q_ASSERT(constraints[i]->helper.first == 0);
- Q_ASSERT(constraints[i]->artificial == 0);
+ Q_ASSERT(constraints[i]->artificial == nullptr);
switch(constraints[i]->ratio) {
case QSimplexConstraint::LessOrEqual:
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index 31dde8832b..c5b22b5667 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -255,7 +255,7 @@ QWidget *QAbstractItemDelegate::createEditor(QWidget *,
const QStyleOptionViewItem &,
const QModelIndex &) const
{
- return 0;
+ return nullptr;
}
@@ -387,44 +387,46 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
const QStyleOptionViewItem &option,
const QModelIndex &index)
{
- Q_D(QAbstractItemDelegate);
- Q_UNUSED(d);
- Q_UNUSED(index);
- Q_UNUSED(option);
-
if (!event || !view)
return false;
+ Q_D(QAbstractItemDelegate);
switch (event->type()) {
#ifndef QT_NO_TOOLTIP
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp
- const QString tooltip = d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision);
- if (!tooltip.isEmpty()) {
- QToolTip::showText(he->globalPos(), tooltip, view);
- return true;
+ const QString tooltip = index.isValid() ?
+ d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+ QString();
+ QRect rect;
+ if (index.isValid()) {
+ const QRect r = view->visualRect(index);
+ rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+ }
+ QToolTip::showText(he->globalPos(), tooltip, view, rect);
+ event->setAccepted(!tooltip.isEmpty());
+ break;
}
- break;}
#endif
#if QT_CONFIG(whatsthis)
- case QEvent::QueryWhatsThis: {
- if (index.data(Qt::WhatsThisRole).isValid())
- return true;
- break; }
+ case QEvent::QueryWhatsThis:
+ event->setAccepted(index.data(Qt::WhatsThisRole).isValid());
+ break;
case QEvent::WhatsThis: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp
- const QString whatsthis = d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision);
- if (!whatsthis.isEmpty()) {
- QWhatsThis::showText(he->globalPos(), whatsthis, view);
- return true;
+ const QString whatsthis = index.isValid() ?
+ d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision) :
+ QString();
+ QWhatsThis::showText(he->globalPos(), whatsthis, view);
+ event->setAccepted(!whatsthis.isEmpty());
+ break;
}
- break ; }
#endif
default:
break;
}
- return false;
+ return event->isAccepted();
}
/*!
@@ -583,27 +585,27 @@ QString QAbstractItemDelegatePrivate::textForRole(Qt::ItemDataRole role, const Q
case QMetaType::Float:
text = locale.toString(value.toFloat());
break;
- case QVariant::Double:
+ case QMetaType::Double:
text = locale.toString(value.toDouble(), 'g', precision);
break;
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
text = locale.toString(value.toLongLong());
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
text = locale.toString(value.toULongLong());
break;
- case QVariant::Date:
+ case QMetaType::QDate:
text = locale.toString(value.toDate(), formatType);
break;
- case QVariant::Time:
+ case QMetaType::QTime:
text = locale.toString(value.toTime(), formatType);
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
text = locale.toString(value.toDateTime(), formatType);
break;
- case QVariant::Type(QMetaType::QJsonValue): {
+ case QMetaType::QJsonValue: {
const QJsonValue val = value.toJsonValue();
if (val.isBool()) {
text = QVariant(val.toBool()).toString();
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index b07faf8be4..2524d4acfa 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -77,13 +77,13 @@ QT_BEGIN_NAMESPACE
QAbstractItemViewPrivate::QAbstractItemViewPrivate()
: model(QAbstractItemModelPrivate::staticEmptyModel()),
- itemDelegate(0),
- selectionModel(0),
+ itemDelegate(nullptr),
+ selectionModel(nullptr),
ctrlDragSelectionFlag(QItemSelectionModel::NoUpdate),
noSelectionOnMousePress(false),
selectionMode(QAbstractItemView::ExtendedSelection),
selectionBehavior(QAbstractItemView::SelectItems),
- currentlyCommittingEditor(0),
+ currentlyCommittingEditor(nullptr),
pressedModifiers(Qt::NoModifier),
pressedPosition(QPoint(-1, -1)),
pressedAlreadySelected(false),
@@ -145,8 +145,8 @@ void QAbstractItemViewPrivate::init()
q->setAttribute(Qt::WA_InputMethodEnabled);
- verticalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0));
- horizontalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0));
+ verticalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, q, nullptr));
+ horizontalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, q, nullptr));
}
void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index)
@@ -757,7 +757,7 @@ void QAbstractItemView::setModel(QAbstractItemModel *model)
QAbstractItemModel *QAbstractItemView::model() const
{
Q_D(const QAbstractItemView);
- return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? 0 : d->model);
+ return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? nullptr : d->model);
}
/*!
@@ -915,7 +915,7 @@ QVariant QAbstractItemView::inputMethodQuery(Qt::InputMethodQuery query) const
void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *delegate)
{
Q_D(QAbstractItemView);
- if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, 0)) {
+ if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, nullptr)) {
if (d->delegateRefCount(rowDelegate) == 1) {
disconnect(rowDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),
this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));
@@ -949,7 +949,7 @@ void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *de
QAbstractItemDelegate *QAbstractItemView::itemDelegateForRow(int row) const
{
Q_D(const QAbstractItemView);
- return d->rowDelegates.value(row, 0);
+ return d->rowDelegates.value(row, nullptr);
}
/*!
@@ -975,7 +975,7 @@ QAbstractItemDelegate *QAbstractItemView::itemDelegateForRow(int row) const
void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate)
{
Q_D(QAbstractItemView);
- if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, 0)) {
+ if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, nullptr)) {
if (d->delegateRefCount(columnDelegate) == 1) {
disconnect(columnDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),
this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)));
@@ -1009,7 +1009,7 @@ void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelega
QAbstractItemDelegate *QAbstractItemView::itemDelegateForColumn(int column) const
{
Q_D(const QAbstractItemView);
- return d->columnDelegates.value(column, 0);
+ return d->columnDelegates.value(column, nullptr);
}
/*!
@@ -1084,7 +1084,7 @@ void QAbstractItemView::setCurrentIndex(const QModelIndex &index)
{
Q_D(QAbstractItemView);
if (d->selectionModel && (!index.isValid() || d->isIndexEnabled(index))) {
- QItemSelectionModel::SelectionFlags command = selectionCommand(index, 0);
+ QItemSelectionModel::SelectionFlags command = selectionCommand(index, nullptr);
d->selectionModel->setCurrentIndex(index, command);
d->currentIndexSet = true;
if ((command & QItemSelectionModel::Current) == 0)
@@ -1201,7 +1201,7 @@ void QAbstractItemView::edit(const QModelIndex &index)
Q_D(QAbstractItemView);
if (Q_UNLIKELY(!d->isIndexValid(index)))
qWarning("edit: index was invalid");
- if (Q_UNLIKELY(!edit(index, AllEditTriggers, 0)))
+ if (Q_UNLIKELY(!edit(index, AllEditTriggers, nullptr)))
qWarning("edit: editing failed");
}
@@ -1286,7 +1286,7 @@ QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode() const
void QAbstractItemView::resetVerticalScrollMode()
{
- auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0));
+ auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, this, nullptr));
setVerticalScrollMode(sm);
d_func()->verticalScrollModeSet = false;
}
@@ -1323,7 +1323,7 @@ QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode() const
void QAbstractItemView::resetHorizontalScrollMode()
{
- auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0));
+ auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, this, nullptr));
setHorizontalScrollMode(sm);
d_func()->horizontalScrollModeSet = false;
}
@@ -1964,7 +1964,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)
QPersistentModelIndex persistent = index;
emit doubleClicked(persistent);
if ((event->button() == Qt::LeftButton) && !edit(persistent, DoubleClicked, event)
- && !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
+ && !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, this))
emit activated(persistent);
d->pressedIndex = QModelIndex();
}
@@ -2339,7 +2339,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
QVariant variant;
if (d->model)
variant = d->model->data(currentIndex(), Qt::DisplayRole);
- if (variant.type() == QVariant::String)
+ if (variant.userType() == QMetaType::QString)
QGuiApplication::clipboard()->setText(variant.toString());
event->accept();
}
@@ -2388,7 +2388,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
setFocus();
QItemSelectionModel::SelectionFlags command = selectionCommand(newCurrent, event);
if (command != QItemSelectionModel::NoUpdate
- || style()->styleHint(QStyle::SH_ItemView_MovementWithoutUpdatingSelection, 0, this)) {
+ || style()->styleHint(QStyle::SH_ItemView_MovementWithoutUpdatingSelection, nullptr, this)) {
// note that we don't check if the new current index is enabled because moveCursor() makes sure it is
if (command & QItemSelectionModel::Current) {
d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate);
@@ -2654,7 +2654,7 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve
if (!d->isIndexValid(index))
return false;
- if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(0) : d->editorForIndex(index).widget.data())) {
+ if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(nullptr) : d->editorForIndex(index).widget.data())) {
if (w->focusPolicy() == Qt::NoFocus)
return false;
w->setFocus();
@@ -2692,7 +2692,7 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve
if (trigger == SelectedClicked)
d->delayedEditing.start(QApplication::doubleClickInterval(), this);
else
- d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : 0);
+ d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : nullptr);
return true;
}
@@ -2909,7 +2909,7 @@ void QAbstractItemView::commitData(QWidget *editor)
editor->removeEventFilter(delegate);
delegate->setModelData(editor, d->model, index);
editor->installEventFilter(delegate);
- d->currentlyCommittingEditor = 0;
+ d->currentlyCommittingEditor = nullptr;
}
/*!
@@ -3074,9 +3074,10 @@ void QAbstractItemView::keyboardSearch(const QString &search)
QSize QAbstractItemView::sizeHintForIndex(const QModelIndex &index) const
{
Q_D(const QAbstractItemView);
- if (!d->isIndexValid(index) || !d->itemDelegate)
+ if (!d->isIndexValid(index))
return QSize();
- return d->delegateForIndex(index)->sizeHint(d->viewOptionsV1(), index);
+ const auto delegate = d->delegateForIndex(index);
+ return delegate ? delegate->sizeHint(d->viewOptionsV1(), index) : QSize();
}
/*!
@@ -3260,7 +3261,7 @@ QWidget* QAbstractItemView::indexWidget(const QModelIndex &index) const
if (QWidget *editor = d->editorForIndex(index).widget.data())
return editor;
- return 0;
+ return nullptr;
}
/*!
@@ -3675,7 +3676,7 @@ void QAbstractItemView::currentChanged(const QModelIndex &current, const QModelI
if (d->autoScroll)
scrollTo(current);
update(current);
- edit(current, CurrentChanged, 0);
+ edit(current, CurrentChanged, nullptr);
if (current.row() == (d->model->rowCount(d->root) - 1))
d->fetchMore();
} else {
@@ -3739,7 +3740,7 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const
if (d->iconSize.isValid()) {
option.decorationSize = d->iconSize;
} else {
- int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
+ int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
option.decorationSize = QSize(pm, pm);
}
option.decorationPosition = QStyleOptionViewItem::Left;
@@ -3747,7 +3748,7 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const
option.displayAlignment = Qt::AlignLeft|Qt::AlignVCenter;
option.textElideMode = d->textElideMode;
option.rect = QRect();
- option.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, this);
+ option.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, this);
if (d->wrapItemText)
option.features = QStyleOptionViewItem::WrapText;
option.locale = locale();
@@ -4233,7 +4234,7 @@ QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index,
if (!w) {
QAbstractItemDelegate *delegate = delegateForIndex(index);
if (!delegate)
- return 0;
+ return nullptr;
w = delegate->createEditor(viewport, options, index);
if (w) {
w->installEventFilter(delegate);
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index a4eed2d885..4d0161025c 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -142,7 +142,7 @@ void QColumnView::setResizeGripsVisible(bool visible)
connect(grip, SIGNAL(gripMoved(int)), this, SLOT(_q_gripMoved(int)));
} else {
QWidget *widget = view->cornerWidget();
- view->setCornerWidget(0);
+ view->setCornerWidget(nullptr);
widget->deleteLater();
}
}
@@ -327,7 +327,7 @@ void QColumnView::scrollTo(const QModelIndex &index, ScrollHint hint)
}
#if QT_CONFIG(animation)
- if (const int animationDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, this)) {
+ if (const int animationDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this)) {
d->currentAnimation.setDuration(animationDuration);
d->currentAnimation.setEndValue(newScrollbarValue);
d->currentAnimation.start();
@@ -638,7 +638,7 @@ void QColumnViewPrivate::_q_clicked(const QModelIndex &index)
{
Q_Q(QColumnView);
QModelIndex parent = index.parent();
- QAbstractItemView *columnClicked = 0;
+ QAbstractItemView *columnClicked = nullptr;
for (int column = 0; column < columns.count(); ++column) {
if (columns.at(column)->rootIndex() == parent) {
columnClicked = columns[column];
@@ -666,7 +666,7 @@ void QColumnViewPrivate::_q_clicked(const QModelIndex &index)
QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bool show)
{
Q_Q(QColumnView);
- QAbstractItemView *view = 0;
+ QAbstractItemView *view = nullptr;
if (model->hasChildren(index)) {
view = q->createColumn(index);
q->connect(view, SIGNAL(clicked(QModelIndex)),
@@ -1045,8 +1045,8 @@ QColumnViewPrivate::QColumnViewPrivate()
: QAbstractItemViewPrivate()
,showResizeGrips(true)
,offset(0)
-,previewWidget(0)
-,previewColumn(0)
+,previewWidget(nullptr)
+,previewColumn(nullptr)
{
}
diff --git a/src/widgets/itemviews/qcolumnviewgrip.cpp b/src/widgets/itemviews/qcolumnviewgrip.cpp
index 4a4237805f..00cd7df20a 100644
--- a/src/widgets/itemviews/qcolumnviewgrip.cpp
+++ b/src/widgets/itemviews/qcolumnviewgrip.cpp
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
Use setModel() to set the model.
*/
QColumnViewGrip::QColumnViewGrip(QWidget *parent)
-: QWidget(*new QColumnViewGripPrivate, parent, 0)
+ : QWidget(*new QColumnViewGripPrivate, parent, { })
{
#ifndef QT_NO_CURSOR
setCursor(Qt::SplitHCursor);
diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h
index 4311edbeb4..13e4c764e8 100644
--- a/src/widgets/itemviews/qcolumnviewgrip_p.h
+++ b/src/widgets/itemviews/qcolumnviewgrip_p.h
@@ -73,7 +73,7 @@ public:
int moveGrip(int offset);
protected:
- QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
+ QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = { });
void paintEvent(QPaintEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp
index 125ee73194..24039c42f6 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.cpp
+++ b/src/widgets/itemviews/qdatawidgetmapper.cpp
@@ -56,7 +56,7 @@ public:
Q_DECLARE_PUBLIC(QDataWidgetMapper)
QDataWidgetMapperPrivate()
- : model(QAbstractItemModelPrivate::staticEmptyModel()), delegate(0),
+ : model(QAbstractItemModelPrivate::staticEmptyModel()), delegate(nullptr),
orientation(Qt::Horizontal), submitPolicy(QDataWidgetMapper::AutoSubmit)
{
}
@@ -226,7 +226,7 @@ void QDataWidgetMapperPrivate::_q_modelDestroyed()
{
Q_Q(QDataWidgetMapper);
- model = 0;
+ model = nullptr;
q->setModel(QAbstractItemModelPrivate::staticEmptyModel());
}
@@ -374,7 +374,7 @@ QAbstractItemModel *QDataWidgetMapper::model() const
{
Q_D(const QDataWidgetMapper);
return d->model == QAbstractItemModelPrivate::staticEmptyModel()
- ? static_cast<QAbstractItemModel *>(0)
+ ? static_cast<QAbstractItemModel *>(nullptr)
: d->model;
}
@@ -567,7 +567,7 @@ QWidget *QDataWidgetMapper::mappedWidgetAt(int section) const
return e.widget;
}
- return 0;
+ return nullptr;
}
/*!
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index 3dea8bd405..8d1538a213 100644
--- a/src/widgets/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
@@ -39,6 +39,8 @@
#include "qdirmodel.h"
+#if QT_DEPRECATED_SINCE(5, 15)
+
#include <qfile.h>
#include <qfilesystemmodel.h>
#include <qurl.h>
@@ -73,7 +75,7 @@ class QDirModelPrivate : public QAbstractItemModelPrivate
public:
struct QDirNode
{
- QDirNode() : parent(0), populated(false), stat(false) {}
+ QDirNode() : parent(nullptr), populated(false), stat(false) {}
QDirNode *parent;
QFileInfo info;
QIcon icon; // cache the icon
@@ -236,7 +238,7 @@ QDirModel::QDirModel(const QStringList &nameFilters,
d->nameFilters = nameFilters.isEmpty() ? QStringList(QLatin1String("*")) : nameFilters;
d->filters = filters;
d->sort = sort;
- d->root.parent = 0;
+ d->root.parent = nullptr;
d->root.info = QFileInfo();
d->clear(&d->root);
}
@@ -291,7 +293,7 @@ QModelIndex QDirModel::index(int row, int column, const QModelIndex &parent) con
if (row >= p->children.count())
return QModelIndex();
// now get the internal pointer for the index
- QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : 0);
+ QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : nullptr);
Q_ASSERT(n);
return createIndex(row, column, n);
@@ -308,8 +310,8 @@ QModelIndex QDirModel::parent(const QModelIndex &child) const
if (!d->indexValid(child))
return QModelIndex();
QDirModelPrivate::QDirNode *node = d->node(child);
- QDirModelPrivate::QDirNode *par = (node ? node->parent : 0);
- if (par == 0) // parent is the root node
+ QDirModelPrivate::QDirNode *par = (node ? node->parent : nullptr);
+ if (par == nullptr) // parent is the root node
return QModelIndex();
// get the parent's row
@@ -1157,10 +1159,10 @@ void QDirModelPrivate::init()
filters = QDir::AllEntries | QDir::NoDotAndDotDot;
sort = QDir::Name;
nameFilters << QLatin1String("*");
- root.parent = 0;
+ root.parent = nullptr;
root.info = QFileInfo();
clear(&root);
- roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
+ roleNames.insert(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath"));
roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName"));
}
@@ -1168,7 +1170,7 @@ void QDirModelPrivate::init()
QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const
{
if (row < 0)
- return 0;
+ return nullptr;
bool isDir = !parent || parent->info.isDir();
QDirNode *p = (parent ? parent : &root);
@@ -1177,7 +1179,7 @@ QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) co
if (Q_UNLIKELY(row >= p->children.count())) {
qWarning("node: the row does not exist");
- return 0;
+ return nullptr;
}
return const_cast<QDirNode*>(&p->children.at(row));
@@ -1188,7 +1190,7 @@ QVector<QDirModelPrivate::QDirNode> QDirModelPrivate::children(QDirNode *parent,
Q_ASSERT(parent);
QFileInfoList infoList;
if (parent == &root) {
- parent = 0;
+ parent = nullptr;
infoList = QDir::drives();
} else if (parent->info.isDir()) {
//resolve directory links only if requested.
@@ -1331,7 +1333,7 @@ void QDirModelPrivate::appendChild(QDirModelPrivate::QDirNode *parent, const QSt
QDirModelPrivate::QDirNode node;
node.populated = false;
node.stat = shouldStat;
- node.parent = (parent == &root ? 0 : parent);
+ node.parent = (parent == &root ? nullptr : parent);
node.info = QFileInfo(path);
node.info.setCaching(true);
@@ -1372,3 +1374,5 @@ QFileInfo QDirModelPrivate::resolvedInfo(QFileInfo info)
QT_END_NAMESPACE
#include "moc_qdirmodel.cpp"
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h
index ab91bbd763..665a622dbe 100644
--- a/src/widgets/itemviews/qdirmodel.h
+++ b/src/widgets/itemviews/qdirmodel.h
@@ -45,6 +45,8 @@
#include <QtCore/qdir.h>
#include <QtWidgets/qfileiconprovider.h>
+#if QT_DEPRECATED_SINCE(5, 15)
+
QT_REQUIRE_CONFIG(dirmodel);
QT_BEGIN_NAMESPACE
@@ -65,9 +67,10 @@ public:
FileNameRole
};
- QDirModel(const QStringList &nameFilters, QDir::Filters filters,
- QDir::SortFlags sort, QObject *parent = nullptr);
- explicit QDirModel(QObject *parent = nullptr);
+ QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") QDirModel(const QStringList &nameFilters,
+ QDir::Filters filters, QDir::SortFlags sort,
+ QObject *parent = nullptr);
+ QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") explicit QDirModel(QObject *parent = nullptr);
~QDirModel();
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
@@ -144,4 +147,6 @@ private:
QT_END_NAMESPACE
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif // QDIRMODEL_H
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index d7bdf6aa4c..84e2fd72a9 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -1583,7 +1583,7 @@ int QHeaderView::minimumSectionSize() const
Q_D(const QHeaderView);
if (d->minimumSectionSize == -1) {
QSize strut = QApplication::globalStrut();
- int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
+ int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, nullptr, this);
if (d->orientation == Qt::Horizontal)
return qMax(strut.width(), (fontMetrics().maxWidth() + margin));
return qMax(strut.height(), (fontMetrics().height() + margin));
@@ -2883,12 +2883,12 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
opt.text = d->model->headerData(logicalIndex, d->orientation,
Qt::DisplayRole).toString();
- int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
+ int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, nullptr, this);
- const Qt::Alignment headerArrowAlignment = static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_Header_ArrowAlignment, 0, this));
+ const Qt::Alignment headerArrowAlignment = static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_Header_ArrowAlignment, nullptr, this));
const bool isHeaderArrowOnTheSide = headerArrowAlignment & Qt::AlignVCenter;
if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex && isHeaderArrowOnTheSide)
- margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, 0, this);
+ margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, nullptr, this);
const QVariant variant = d->model->headerData(logicalIndex, d->orientation,
Qt::DecorationRole);
@@ -2896,8 +2896,8 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
if (opt.icon.isNull())
opt.icon = qvariant_cast<QPixmap>(variant);
if (!opt.icon.isNull()) // see CT_HeaderSection
- margin += style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this) +
- style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
+ margin += style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this) +
+ style()->pixelMetric(QStyle::PM_HeaderMargin, nullptr, this);
if (d->textElideMode != Qt::ElideNone) {
const QRect textRect = style()->subElementRect(QStyle::SE_HeaderLabel, &opt, this);
@@ -3275,7 +3275,7 @@ int QHeaderViewPrivate::sectionHandleAt(int position)
return -1;
int log = logicalIndex(visual);
int pos = q->sectionViewportPosition(log);
- int grip = q->style()->pixelMetric(QStyle::PM_HeaderGripMargin, 0, q);
+ int grip = q->style()->pixelMetric(QStyle::PM_HeaderGripMargin, nullptr, q);
bool atLeft = position < pos + grip;
bool atRight = (position > pos + q->sectionSize(log) - grip);
@@ -3660,7 +3660,7 @@ void QHeaderViewPrivate::flipSortIndicator(int section)
sortOrder = (sortIndicatorOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder;
} else {
const QVariant value = model->headerData(section, orientation, Qt::InitialSortOrderRole);
- if (value.canConvert(QVariant::Int))
+ if (value.canConvert(QMetaType::Int))
sortOrder = static_cast<Qt::SortOrder>(value.toInt());
else
sortOrder = Qt::AscendingOrder;
@@ -3814,10 +3814,10 @@ void QHeaderViewPrivate::updateDefaultSectionSizeFromStyle()
{
Q_Q(QHeaderView);
if (orientation == Qt::Horizontal) {
- defaultSectionSize = q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeHorizontal, 0, q);
+ defaultSectionSize = q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeHorizontal, nullptr, q);
} else {
defaultSectionSize = qMax(q->minimumSectionSize(),
- q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeVertical, 0, q));
+ q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeVertical, nullptr, q));
}
}
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index 460764f1b8..4420d39b8e 100644
--- a/src/widgets/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
@@ -77,7 +77,7 @@ class QItemDelegatePrivate : public QAbstractItemDelegatePrivate
Q_DECLARE_PUBLIC(QItemDelegate)
public:
- QItemDelegatePrivate() : f(0), clipPainting(true) {}
+ QItemDelegatePrivate() : f(nullptr), clipPainting(true) {}
inline const QItemEditorFactory *editorFactory() const
{ return f ? f : QItemEditorFactory::defaultFactory(); }
@@ -149,7 +149,7 @@ QRect QItemDelegatePrivate::textLayoutBounds(const QStyleOptionViewItem &option,
QStyle *style = w ? w->style() : QApplication::style();
const bool wrapText = option.features & QStyleOptionViewItem::WrapText;
// see QItemDelegate::drawDisplay
- const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, w) + 1;
+ const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, w) + 1;
switch (option.decorationPosition) {
case QStyleOptionViewItem::Left:
case QStyleOptionViewItem::Right:
@@ -414,7 +414,7 @@ void QItemDelegate::paint(QPainter *painter,
if (value.isValid()) {
// ### we need the pixmap to call the virtual function
pixmap = decoration(opt, value);
- if (value.type() == QVariant::Icon) {
+ if (value.userType() == QMetaType::QIcon) {
d->tmp.icon = qvariant_cast<QIcon>(value);
d->tmp.mode = d->iconMode(option.state);
d->tmp.state = d->iconState(option.state);
@@ -502,9 +502,9 @@ QWidget *QItemDelegate::createEditor(QWidget *parent,
{
Q_D(const QItemDelegate);
if (!index.isValid())
- return 0;
+ return nullptr;
const QItemEditorFactory *factory = d->f;
- if (factory == 0)
+ if (factory == nullptr)
factory = QItemEditorFactory::defaultFactory();
QWidget *w = factory->createEditor(index.data(Qt::EditRole).userType(), parent);
if (w)
@@ -533,7 +533,7 @@ void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) con
if (!n.isEmpty()) {
if (!v.isValid())
- v = QVariant(editor->property(n).userType(), (const void *)0);
+ v = QVariant(editor->property(n).userType(), (const void *)nullptr);
editor->setProperty(n, v);
}
#endif
@@ -586,7 +586,7 @@ void QItemDelegate::updateEditorGeometry(QWidget *editor,
QPixmap pixmap = decoration(option, index.data(Qt::DecorationRole));
QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString());
QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect());
- QRect textRect = textRectangle(0, option.rect, option.font, text);
+ QRect textRect = textRectangle(nullptr, option.rect, option.font, text);
QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole));
QStyleOptionViewItem opt = option;
opt.showDecorationSelected = true; // let the editor take up all available space
@@ -654,7 +654,7 @@ void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &o
const QWidget *widget = d->widget(option);
QStyle *style = widget ? widget->style() : QApplication::style();
- const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
+ const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
const bool wrapText = opt.features & QStyleOptionViewItem::WrapText;
d->textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
@@ -841,7 +841,7 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
const bool hasText = textRect->isValid();
const bool hasMargin = (hasText | hasPixmap | hasCheck);
const int frameHMargin = hasMargin ?
- style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
+ style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1 : 0;
const int textMargin = hasText ? frameHMargin : 0;
const int pixmapMargin = hasPixmap ? frameHMargin : 0;
const int checkMargin = hasCheck ? frameHMargin : 0;
@@ -969,12 +969,12 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
QPixmap QItemDelegate::decoration(const QStyleOptionViewItem &option, const QVariant &variant) const
{
Q_D(const QItemDelegate);
- switch (variant.type()) {
- case QVariant::Icon: {
+ switch (variant.userType()) {
+ case QMetaType::QIcon: {
QIcon::Mode mode = d->iconMode(option.state);
QIcon::State state = d->iconState(option.state);
return qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, mode, state); }
- case QVariant::Color: {
+ case QMetaType::QColor: {
static QPixmap pixmap(option.decorationSize);
pixmap.fill(qvariant_cast<QColor>(variant));
return pixmap; }
@@ -1060,24 +1060,24 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option,
if (role == Qt::CheckStateRole)
return doCheck(option, option.rect, value);
if (value.isValid() && !value.isNull()) {
- switch (value.type()) {
- case QVariant::Invalid:
+ switch (value.userType()) {
+ case QMetaType::UnknownType:
break;
- case QVariant::Pixmap: {
+ case QMetaType::QPixmap: {
const QPixmap &pixmap = qvariant_cast<QPixmap>(value);
return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() ); }
- case QVariant::Image: {
+ case QMetaType::QImage: {
const QImage &image = qvariant_cast<QImage>(value);
return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() ); }
- case QVariant::Icon: {
+ case QMetaType::QIcon: {
QIcon::Mode mode = d->iconMode(option.state);
QIcon::State state = d->iconState(option.state);
QIcon icon = qvariant_cast<QIcon>(value);
QSize size = icon.actualSize(option.decorationSize, mode, state);
return QRect(QPoint(0, 0), size); }
- case QVariant::Color:
+ case QMetaType::QColor:
return QRect(QPoint(0, 0), option.decorationSize);
- case QVariant::String:
+ case QMetaType::QString:
default: {
const QString text = d->valueToText(value, option);
value = index.data(Qt::FontRole);
@@ -1242,7 +1242,7 @@ QStyleOptionViewItem QItemDelegate::setOptions(const QModelIndex &index,
opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
// disable style animations for checkboxes etc. within itemviews (QTBUG-30146)
- opt.styleObject = 0;
+ opt.styleObject = nullptr;
return opt;
}
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index 8ed2ee5f28..fe9b482122 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -91,7 +91,7 @@ class QUIntSpinBox : public QSpinBox
Q_OBJECT
Q_PROPERTY(uint value READ uintValue WRITE setUIntValue NOTIFY uintValueChanged USER true)
public:
- explicit QUIntSpinBox(QWidget *parent = 0)
+ explicit QUIntSpinBox(QWidget *parent = nullptr)
: QSpinBox(parent)
{
connect(this, SIGNAL(valueChanged(int)), SIGNAL(uintValueChanged()));
@@ -176,7 +176,7 @@ QWidget *QItemEditorFactory::createEditor(int userType, QWidget *parent) const
QItemEditorCreatorBase *creator = creatorMap.value(userType, 0);
if (!creator) {
const QItemEditorFactory *dfactory = defaultFactory();
- return dfactory == this ? 0 : dfactory->createEditor(userType, parent);
+ return dfactory == this ? nullptr : dfactory->createEditor(userType, parent);
}
return creator->createWidget(parent);
}
@@ -241,21 +241,21 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
{
switch (userType) {
#if QT_CONFIG(combobox)
- case QVariant::Bool: {
+ case QMetaType::Bool: {
QBooleanComboBox *cb = new QBooleanComboBox(parent);
cb->setFrame(false);
cb->setSizePolicy(QSizePolicy::Ignored, cb->sizePolicy().verticalPolicy());
return cb; }
#endif
#if QT_CONFIG(spinbox)
- case QVariant::UInt: {
+ case QMetaType::UInt: {
QSpinBox *sb = new QUIntSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(0);
sb->setMaximum(INT_MAX);
sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
- case QVariant::Int: {
+ case QMetaType::Int: {
QSpinBox *sb = new QSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(INT_MIN);
@@ -264,25 +264,25 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
return sb; }
#endif
#if QT_CONFIG(datetimeedit)
- case QVariant::Date: {
+ case QMetaType::QDate: {
QDateTimeEdit *ed = new QDateEdit(parent);
ed->setFrame(false);
return ed; }
- case QVariant::Time: {
+ case QMetaType::QTime: {
QDateTimeEdit *ed = new QTimeEdit(parent);
ed->setFrame(false);
return ed; }
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QDateTimeEdit *ed = new QDateTimeEdit(parent);
ed->setFrame(false);
return ed; }
#endif
#if QT_CONFIG(label)
- case QVariant::Pixmap:
+ case QMetaType::QPixmap:
return new QLabel(parent);
#endif
#if QT_CONFIG(spinbox)
- case QVariant::Double: {
+ case QMetaType::Double: {
QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(-DBL_MAX);
@@ -291,12 +291,12 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
return sb; }
#endif
#if QT_CONFIG(lineedit)
- case QVariant::String:
+ case QMetaType::QString:
default: {
// the default editor is a lineedit
QExpandingLineEdit *le = new QExpandingLineEdit(parent);
- le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le));
- if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le))
+ le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, nullptr, le));
+ if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, le))
le->setWidgetOwnsGeometry(true);
return le; }
#else
@@ -304,42 +304,42 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
break;
#endif
}
- return 0;
+ return nullptr;
}
QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const
{
switch (userType) {
#if QT_CONFIG(combobox)
- case QVariant::Bool:
+ case QMetaType::Bool:
return "currentIndex";
#endif
#if QT_CONFIG(spinbox)
- case QVariant::UInt:
- case QVariant::Int:
- case QVariant::Double:
+ case QMetaType::UInt:
+ case QMetaType::Int:
+ case QMetaType::Double:
return "value";
#endif
#if QT_CONFIG(datetimeedit)
- case QVariant::Date:
+ case QMetaType::QDate:
return "date";
- case QVariant::Time:
+ case QMetaType::QTime:
return "time";
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return "dateTime";
#endif
- case QVariant::String:
+ case QMetaType::QString:
default:
// the default editor is a lineedit
return "text";
}
}
-static QItemEditorFactory *q_default_factory = 0;
+static QItemEditorFactory *q_default_factory = nullptr;
struct QDefaultFactoryCleaner
{
inline QDefaultFactoryCleaner() {}
- ~QDefaultFactoryCleaner() { delete q_default_factory; q_default_factory = 0; }
+ ~QDefaultFactoryCleaner() { delete q_default_factory; q_default_factory = nullptr; }
};
/*!
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 62fffc17df..ec01922746 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -935,8 +935,8 @@ QStyleOptionViewItem QListView::viewOptions() const
QStyleOptionViewItem option = QAbstractItemView::viewOptions();
if (!d->iconSize.isValid()) { // otherwise it was already set in abstractitemview
int pm = (d->viewMode == QListView::ListMode
- ? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this)
- : style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this));
+ ? style()->pixelMetric(QStyle::PM_ListViewIconSize, nullptr, this)
+ : style()->pixelMetric(QStyle::PM_IconViewIconSize, nullptr, this));
option.decorationSize = QSize(pm, pm);
}
if (d->viewMode == QListView::IconMode) {
@@ -1690,7 +1690,7 @@ bool QListView::event(QEvent *e)
QListViewPrivate::QListViewPrivate()
: QAbstractItemViewPrivate(),
- commonListView(0),
+ commonListView(nullptr),
wrap(false),
space(0),
flow(QListView::TopToBottom),
@@ -1735,10 +1735,10 @@ void QListViewPrivate::prepareItemsLayout()
// Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
// is Qt::ScrollBarAsNeeded
int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded
- ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, vbar) + frameAroundContents
+ ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, vbar) + frameAroundContents
: 0;
int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded
- ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, hbar) + frameAroundContents
+ ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, hbar) + frameAroundContents
: 0;
layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin);
@@ -3074,7 +3074,7 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
moved.resize(items.count());
QRect rect(QPoint(), topLeft);
- QListViewItem *item = 0;
+ QListViewItem *item = nullptr;
for (int row = info.first; row <= info.last; ++row) {
item = &items[row];
if (isHidden(row)) {
@@ -3180,7 +3180,7 @@ QVector<QModelIndex> QIconModeViewBase::intersectingSet(const QRect &area) const
QVector<QModelIndex> res;
that->interSectingVector = &res;
that->tree.climbTree(area, &QIconModeViewBase::addLeaf, data);
- that->interSectingVector = 0;
+ that->interSectingVector = nullptr;
return res;
}
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index e7dcfac403..c9379f9a8a 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -75,7 +75,7 @@ void QListModel::clear()
for (int i = 0; i < items.count(); ++i) {
if (items.at(i)) {
items.at(i)->d->theid = -1;
- items.at(i)->view = 0;
+ items.at(i)->view = nullptr;
delete items.at(i);
}
}
@@ -96,7 +96,7 @@ void QListModel::remove(QListWidgetItem *item)
Q_ASSERT(row != -1);
beginRemoveRows(QModelIndex(), row, row);
items.at(row)->d->theid = -1;
- items.at(row)->view = 0;
+ items.at(row)->view = nullptr;
items.removeAt(row);
endRemoveRows();
}
@@ -156,11 +156,11 @@ void QListModel::insert(int row, const QStringList &labels)
QListWidgetItem *QListModel::take(int row)
{
if (row < 0 || row >= items.count())
- return 0;
+ return nullptr;
beginRemoveRows(QModelIndex(), row, row);
items.at(row)->d->theid = -1;
- items.at(row)->view = 0;
+ items.at(row)->view = nullptr;
QListWidgetItem *item = items.takeAt(row);
endRemoveRows();
return item;
@@ -263,7 +263,7 @@ bool QListModel::insertRows(int row, int count, const QModelIndex &parent)
beginInsertRows(QModelIndex(), row, row + count - 1);
QListWidget *view = qobject_cast<QListWidget*>(QObject::parent());
- QListWidgetItem *itm = 0;
+ QListWidgetItem *itm = nullptr;
for (int r = row; r < row + count; ++r) {
itm = new QListWidgetItem;
@@ -282,10 +282,10 @@ bool QListModel::removeRows(int row, int count, const QModelIndex &parent)
return false;
beginRemoveRows(QModelIndex(), row, row + count - 1);
- QListWidgetItem *itm = 0;
+ QListWidgetItem *itm = nullptr;
for (int r = row; r < row + count; ++r) {
itm = items.takeAt(row);
- itm->view = 0;
+ itm->view = nullptr;
itm->d->theid = -1;
delete itm;
}
@@ -301,16 +301,23 @@ bool QListModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int co
{
if (sourceRow < 0
|| sourceRow + count - 1 >= rowCount(sourceParent)
- || destinationChild <= 0
+ || destinationChild < 0
|| destinationChild > rowCount(destinationParent)
+ || sourceRow == destinationChild
|| sourceRow == destinationChild - 1
- || count <= 0) {
+ || count <= 0
+ || sourceParent.isValid()
+ || destinationParent.isValid()) {
return false;
}
if (!beginMoveRows(QModelIndex(), sourceRow, sourceRow + count - 1, QModelIndex(), destinationChild))
return false;
- destinationChild--;
- const int fromRow = destinationChild < sourceRow ? (sourceRow + count - 1) : sourceRow;
+
+ int fromRow = sourceRow;
+ if (destinationChild < sourceRow)
+ fromRow += count - 1;
+ else
+ destinationChild--;
while (count--)
items.move(fromRow, destinationChild);
endMoveRows();
@@ -987,8 +994,9 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
\fn void QListWidgetItem::setSizeHint(const QSize &size)
\since 4.1
- Sets the size hint for the list item to be \a size. If no size hint is set,
- the item delegate will compute the size hint based on the item data.
+ Sets the size hint for the list item to be \a size.
+ If no size hint is set or \a size is invalid, the item
+ delegate will compute the size hint based on the item data.
*/
/*!
@@ -1119,6 +1127,8 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the background brush of the list item to the given \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa background(), setForeground()
*/
@@ -1137,6 +1147,8 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the foreground brush of the list item to the given \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa foreground(), setBackground()
*/
@@ -1215,7 +1227,7 @@ void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex &current,
//persistentCurrent is invalid if something changed the model in response
//to the currentItemChanged signal emission and the item was removed
if (!persistentCurrent.isValid()) {
- currentItem = 0;
+ currentItem = nullptr;
}
emit q->currentTextChanged(currentItem ? currentItem->text() : QString());
@@ -1473,7 +1485,7 @@ QListWidgetItem *QListWidget::item(int row) const
{
Q_D(const QListWidget);
if (row < 0 || row >= d->model->rowCount())
- return 0;
+ return nullptr;
return d->listModel()->at(row);
}
@@ -1543,7 +1555,7 @@ QListWidgetItem *QListWidget::takeItem(int row)
{
Q_D(QListWidget);
if (row < 0 || row >= d->model->rowCount())
- return 0;
+ return nullptr;
return d->listModel()->take(row);
}
@@ -2059,7 +2071,7 @@ QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const
Q_D(const QListWidget);
if (d->isIndexValid(index))
return d->listModel()->at(index.row());
- return 0;
+ return nullptr;
}
/*!
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
index c102b144df..1319d658ab 100644
--- a/src/widgets/itemviews/qlistwidget.h
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -127,7 +127,7 @@ public:
inline QBrush background() const
{ return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
inline void setBackground(const QBrush &brush)
- { setData(Qt::BackgroundRole, brush); }
+ { setData(Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X ("Use QListWidgetItem::foreground() instead")
@@ -141,7 +141,7 @@ public:
inline QBrush foreground() const
{ return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
inline void setForeground(const QBrush &brush)
- { setData(Qt::ForegroundRole, brush); }
+ { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
inline Qt::CheckState checkState() const
{ return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
@@ -151,7 +151,7 @@ public:
inline QSize sizeHint() const
{ return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
inline void setSizeHint(const QSize &size)
- { setData(Qt::SizeHintRole, size); }
+ { setData(Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); }
virtual QVariant data(int role) const;
virtual void setData(int role, const QVariant &value);
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index 702e290da3..c685cc7f05 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -83,7 +83,7 @@ class QStyledItemDelegatePrivate : public QAbstractItemDelegatePrivate
Q_DECLARE_PUBLIC(QStyledItemDelegate)
public:
- QStyledItemDelegatePrivate() : factory(0) { }
+ QStyledItemDelegatePrivate() : factory(nullptr) { }
static const QWidget *widget(const QStyleOptionViewItem &option)
{
@@ -302,8 +302,8 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
value = index.data(Qt::DecorationRole);
if (value.isValid() && !value.isNull()) {
option->features |= QStyleOptionViewItem::HasDecoration;
- switch (value.type()) {
- case QVariant::Icon: {
+ switch (value.userType()) {
+ case QMetaType::QIcon: {
option->icon = qvariant_cast<QIcon>(value);
QIcon::Mode mode;
if (!(option->state & QStyle::State_Enabled))
@@ -319,19 +319,19 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
qMin(option->decorationSize.height(), actualSize.height()));
break;
}
- case QVariant::Color: {
+ case QMetaType::QColor: {
QPixmap pixmap(option->decorationSize);
pixmap.fill(qvariant_cast<QColor>(value));
option->icon = QIcon(pixmap);
break;
}
- case QVariant::Image: {
+ case QMetaType::QImage: {
QImage image = qvariant_cast<QImage>(value);
option->icon = QIcon(QPixmap::fromImage(image));
option->decorationSize = image.size() / image.devicePixelRatio();
break;
}
- case QVariant::Pixmap: {
+ case QMetaType::QPixmap: {
QPixmap pixmap = qvariant_cast<QPixmap>(value);
option->icon = QIcon(pixmap);
option->decorationSize = pixmap.size() / pixmap.devicePixelRatio();
@@ -351,7 +351,7 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
option->backgroundBrush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole));
// disable style animations for checkboxes etc. within itemviews (QTBUG-30146)
- option->styleObject = 0;
+ option->styleObject = nullptr;
}
/*!
@@ -426,7 +426,7 @@ QWidget *QStyledItemDelegate::createEditor(QWidget *parent,
{
Q_D(const QStyledItemDelegate);
if (!index.isValid())
- return 0;
+ return nullptr;
return d->editorFactory()->createEditor(index.data(Qt::EditRole).userType(), parent);
}
@@ -450,7 +450,7 @@ void QStyledItemDelegate::setEditorData(QWidget *editor, const QModelIndex &inde
if (!n.isEmpty()) {
if (!v.isValid())
- v = QVariant(editor->property(n).userType(), (const void *)0);
+ v = QVariant(editor->property(n).userType(), (const void *)nullptr);
editor->setProperty(n, v);
}
#endif
@@ -507,7 +507,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor,
//or it is in a QTableView
#if QT_CONFIG(tableview) && QT_CONFIG(lineedit)
if (qobject_cast<QExpandingLineEdit*>(editor) && !qobject_cast<const QTableView*>(widget))
- opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor);
+ opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, editor);
else
#endif
opt.showDecorationSelected = true;
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 11c5be10fd..81fceba8dc 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1431,7 +1431,7 @@ void QTableView::paintEvent(QPaintEvent *event)
const bool showGrid = d->showGrid;
const int gridSize = showGrid ? 1 : 0;
const int gridHint = style()->styleHint(QStyle::SH_Table_GridLineColor, &option, this);
- const QColor gridColor = static_cast<QRgb>(gridHint);
+ const QColor gridColor = QColor::fromRgba(static_cast<QRgb>(gridHint));
const QPen gridPen = QPen(gridColor, 0, d->gridStyle);
const QHeaderView *verticalHeader = d->verticalHeader;
const QHeaderView *horizontalHeader = d->horizontalHeader;
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 9134abe270..60abd02564 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
QTableModel::QTableModel(int rows, int columns, QTableWidget *parent)
: QAbstractTableModel(parent),
- prototype(0),
+ prototype(nullptr),
tableItems(rows * columns, 0),
verticalHeaderItems(rows, 0),
horizontalHeaderItems(columns, 0)
@@ -104,18 +104,18 @@ bool QTableModel::removeRows(int row, int count, const QModelIndex &)
beginRemoveRows(QModelIndex(), row, row + count - 1);
int i = tableIndex(row, 0);
int n = count * columnCount();
- QTableWidgetItem *oldItem = 0;
+ QTableWidgetItem *oldItem = nullptr;
for (int j = i; j < n + i; ++j) {
oldItem = tableItems.at(j);
if (oldItem)
- oldItem->view = 0;
+ oldItem->view = nullptr;
delete oldItem;
}
tableItems.remove(qMax(i, 0), n);
for (int v = row; v < row + count; ++v) {
oldItem = verticalHeaderItems.at(v);
if (oldItem)
- oldItem->view = 0;
+ oldItem->view = nullptr;
delete oldItem;
}
verticalHeaderItems.remove(row, count);
@@ -129,13 +129,13 @@ bool QTableModel::removeColumns(int column, int count, const QModelIndex &)
return false;
beginRemoveColumns(QModelIndex(), column, column + count - 1);
- QTableWidgetItem *oldItem = 0;
+ QTableWidgetItem *oldItem = nullptr;
for (int row = rowCount() - 1; row >= 0; --row) {
int i = tableIndex(row, column);
for (int j = i; j < i + count; ++j) {
oldItem = tableItems.at(j);
if (oldItem)
- oldItem->view = 0;
+ oldItem->view = nullptr;
delete oldItem;
}
tableItems.remove(i, count);
@@ -143,7 +143,7 @@ bool QTableModel::removeColumns(int column, int count, const QModelIndex &)
for (int h=column; h<column+count; ++h) {
oldItem = horizontalHeaderItems.at(h);
if (oldItem)
- oldItem->view = 0;
+ oldItem->view = nullptr;
delete oldItem;
}
horizontalHeaderItems.remove(column, count);
@@ -162,7 +162,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item)
// remove old
if (oldItem)
- oldItem->view = 0;
+ oldItem->view = nullptr;
delete tableItems.at(i);
QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent());
@@ -180,7 +180,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item)
if (row < colItems.count())
colItems.remove(row);
int sortedRow;
- if (item == 0) {
+ if (item == nullptr) {
// move to after all non-0 (sortable) items
sortedRow = colItems.count();
} else {
@@ -222,7 +222,7 @@ QTableWidgetItem *QTableModel::takeItem(int row, int column)
long i = tableIndex(row, column);
QTableWidgetItem *itm = tableItems.value(i);
if (itm) {
- itm->view = 0;
+ itm->view = nullptr;
itm->d->id = -1;
tableItems[i] = 0;
const QModelIndex ind = index(row, column);
@@ -239,7 +239,7 @@ QTableWidgetItem *QTableModel::item(int row, int column) const
QTableWidgetItem *QTableModel::item(const QModelIndex &index) const
{
if (!isValid(index))
- return 0;
+ return nullptr;
return tableItems.at(tableIndex(index.row(), index.column()));
}
@@ -277,7 +277,7 @@ void QTableModel::setHorizontalHeaderItem(int section, QTableWidgetItem *item)
return;
if (oldItem)
- oldItem->view = 0;
+ oldItem->view = nullptr;
delete oldItem;
QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent());
@@ -299,7 +299,7 @@ void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item)
return;
if (oldItem)
- oldItem->view = 0;
+ oldItem->view = nullptr;
delete oldItem;
QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent());
@@ -315,10 +315,10 @@ void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item)
QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section)
{
if (section < 0 || section >= horizontalHeaderItems.count())
- return 0;
+ return nullptr;
QTableWidgetItem *itm = horizontalHeaderItems.at(section);
if (itm) {
- itm->view = 0;
+ itm->view = nullptr;
itm->itemFlags &= ~ItemIsHeaderItem;
horizontalHeaderItems[section] = 0;
}
@@ -328,10 +328,10 @@ QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section)
QTableWidgetItem *QTableModel::takeVerticalHeaderItem(int section)
{
if (section < 0 || section >= verticalHeaderItems.count())
- return 0;
+ return nullptr;
QTableWidgetItem *itm = verticalHeaderItems.at(section);
if (itm) {
- itm->view = 0;
+ itm->view = nullptr;
itm->itemFlags &= ~ItemIsHeaderItem;
verticalHeaderItems[section] = 0;
}
@@ -571,7 +571,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
sorting.reserve(count);
for (int row = start; row <= end; ++row) {
QTableWidgetItem *itm = item(row, column);
- if (itm == 0) {
+ if (itm == nullptr) {
// no more sortable items (all 0-items are
// at the end of the table when it is sorted)
break;
@@ -649,7 +649,7 @@ QVector<QTableWidgetItem*> QTableModel::columnItems(int column) const
items.reserve(rc);
for (int row = 0; row < rc; ++row) {
QTableWidgetItem *itm = item(row, column);
- if (itm == 0) {
+ if (itm == nullptr) {
// no more sortable items (all 0-items are
// at the end of the table when it is sorted)
break;
@@ -718,7 +718,7 @@ QVariant QTableModel::headerData(int section, Qt::Orientation orientation, int r
if (section < 0)
return QVariant();
- QTableWidgetItem *itm = 0;
+ QTableWidgetItem *itm = nullptr;
if (orientation == Qt::Horizontal && section < horizontalHeaderItems.count())
itm = horizontalHeaderItems.at(section);
else if (orientation == Qt::Vertical && section < verticalHeaderItems.count())
@@ -741,7 +741,7 @@ bool QTableModel::setHeaderData(int section, Qt::Orientation orientation,
(orientation == Qt::Vertical && verticalHeaderItems.size() <= section))
return false;
- QTableWidgetItem *itm = 0;
+ QTableWidgetItem *itm = nullptr;
if (orientation == Qt::Horizontal)
itm = horizontalHeaderItems.at(section);
else
@@ -764,14 +764,14 @@ void QTableModel::clear()
{
for (int j = 0; j < verticalHeaderItems.count(); ++j) {
if (verticalHeaderItems.at(j)) {
- verticalHeaderItems.at(j)->view = 0;
+ verticalHeaderItems.at(j)->view = nullptr;
delete verticalHeaderItems.at(j);
verticalHeaderItems[j] = 0;
}
}
for (int k = 0; k < horizontalHeaderItems.count(); ++k) {
if (horizontalHeaderItems.at(k)) {
- horizontalHeaderItems.at(k)->view = 0;
+ horizontalHeaderItems.at(k)->view = nullptr;
delete horizontalHeaderItems.at(k);
horizontalHeaderItems[k] = 0;
}
@@ -784,7 +784,7 @@ void QTableModel::clearContents()
beginResetModel();
for (int i = 0; i < tableItems.count(); ++i) {
if (tableItems.at(i)) {
- tableItems.at(i)->view = 0;
+ tableItems.at(i)->view = nullptr;
delete tableItems.at(i);
tableItems[i] = 0;
}
@@ -853,7 +853,7 @@ QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const
// cachedIndexes is a little hack to avoid copying from QModelIndexList to
// QList<QTreeWidgetItem*> and back again in the view
cachedIndexes = indexes;
- QMimeData *mimeData = (view ? view->mimeData(items) : 0);
+ QMimeData *mimeData = (view ? view->mimeData(items) : nullptr);
cachedIndexes.clear();
return mimeData;
}
@@ -1064,8 +1064,8 @@ QTableWidgetSelectionRange::~QTableWidgetSelectionRange()
\since 4.1
Sets the size hint for the table item to be \a size.
- If no size hint is set, the item delegate will compute the
- size hint based on the item data.
+ If no size hint is set or \a size is invalid, the item
+ delegate will compute the size hint based on the item data.
*/
/*!
@@ -1279,6 +1279,8 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the item's background brush to the specified \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa setForeground()
*/
@@ -1313,6 +1315,8 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
\since 4.2
Sets the item's foreground brush to the specified \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa setBackground()
*/
@@ -2036,7 +2040,7 @@ QTableWidgetItem *QTableWidget::takeItem(int row, int column)
Q_D(QTableWidget);
QTableWidgetItem *item = d->tableModel()->takeItem(row, column);
if (item)
- item->view = 0;
+ item->view = nullptr;
return item;
}
@@ -2072,7 +2076,7 @@ QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row)
Q_D(QTableWidget);
QTableWidgetItem *itm = d->tableModel()->takeVerticalHeaderItem(row);
if (itm)
- itm->view = 0;
+ itm->view = nullptr;
return itm;
}
@@ -2111,7 +2115,7 @@ QTableWidgetItem *QTableWidget::takeHorizontalHeaderItem(int column)
Q_D(QTableWidget);
QTableWidgetItem *itm = d->tableModel()->takeHorizontalHeaderItem(column);
if (itm)
- itm->view = 0;
+ itm->view = nullptr;
return itm;
}
@@ -2122,7 +2126,7 @@ void QTableWidget::setVerticalHeaderLabels(const QStringList &labels)
{
Q_D(QTableWidget);
QTableModel *model = d->tableModel();
- QTableWidgetItem *item = 0;
+ QTableWidgetItem *item = nullptr;
for (int i = 0; i < model->rowCount() && i < labels.count(); ++i) {
item = model->verticalHeaderItem(i);
if (!item) {
@@ -2140,7 +2144,7 @@ void QTableWidget::setHorizontalHeaderLabels(const QStringList &labels)
{
Q_D(QTableWidget);
QTableModel *model = d->tableModel();
- QTableWidgetItem *item = 0;
+ QTableWidgetItem *item = nullptr;
for (int i = 0; i < model->columnCount() && i < labels.count(); ++i) {
item = model->horizontalHeaderItem(i);
if (!item) {
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index 0d93a0a075..70e2046400 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -146,7 +146,7 @@ public:
inline QBrush background() const
{ return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
inline void setBackground(const QBrush &brush)
- { setData(Qt::BackgroundRole, brush); }
+ { setData(Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X ("Use QTableWidgetItem::foreground() instead")
@@ -160,7 +160,7 @@ public:
inline QBrush foreground() const
{ return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
inline void setForeground(const QBrush &brush)
- { setData(Qt::ForegroundRole, brush); }
+ { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
inline Qt::CheckState checkState() const
{ return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
@@ -170,7 +170,7 @@ public:
inline QSize sizeHint() const
{ return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
inline void setSizeHint(const QSize &size)
- { setData(Qt::SizeHintRole, size); }
+ { setData(Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); }
virtual QVariant data(int role) const;
virtual void setData(int role, const QVariant &value);
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 442369c2ec..9aba17be70 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1517,7 +1517,7 @@ void QTreeView::drawTree(QPainter *painter, const QRegion &region) const
/// ### move to QObject :)
static inline bool ancestorOf(QObject *widget, QObject *other)
{
- for (QObject *parent = other; parent != 0; parent = parent->parent()) {
+ for (QObject *parent = other; parent != nullptr; parent = parent->parent()) {
if (parent == widget)
return true;
}
@@ -1888,7 +1888,7 @@ void QTreeView::mousePressEvent(QMouseEvent *event)
{
Q_D(QTreeView);
bool handled = false;
- if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress)
+ if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonPress)
handled = d->expandOrCollapseItemAtPos(event->pos());
if (!handled && d->itemDecorationAt(event->pos()) == -1)
QAbstractItemView::mousePressEvent(event);
@@ -1907,7 +1907,7 @@ void QTreeView::mouseReleaseEvent(QMouseEvent *event)
} else {
if (state() == QAbstractItemView::DragSelectingState || state() == QAbstractItemView::DraggingState)
setState(QAbstractItemView::NoState);
- if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease)
+ if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonRelease)
d->expandOrCollapseItemAtPos(event->pos());
}
}
@@ -1944,7 +1944,7 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event)
if (edit(persistent, DoubleClicked, event) || state() != NoState)
return; // the double click triggered editing
- if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this))
+ if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, this))
emit activated(persistent);
d->pressedIndex = QModelIndex();
@@ -2208,7 +2208,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
d->collapse(vi, true);
d->moveCursorUpdatedView = true;
} else {
- bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this);
+ bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, nullptr, this);
if (descend) {
QModelIndex par = current.parent();
if (par.isValid() && par != rootIndex())
@@ -2244,7 +2244,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
d->expand(vi, true);
d->moveCursorUpdatedView = true;
} else {
- bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this);
+ bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, nullptr, this);
if (descend) {
QModelIndex idx = d->modelIndex(d->below(vi));
if (idx.parent() == current)
@@ -3051,7 +3051,7 @@ void QTreeViewPrivate::initialize()
header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter);
q->setHeader(header);
#if QT_CONFIG(animation)
- animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0;
+ animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, q) > 0;
QObject::connect(&animatedOperation, SIGNAL(finished()), q, SLOT(_q_endAnimatedOperation()));
#endif // animation
}
@@ -3344,7 +3344,7 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit
int hidden = 0;
int last = 0;
int children = 0;
- QTreeViewItem *item = 0;
+ QTreeViewItem *item = nullptr;
for (int j = first; j < first + count; ++j) {
current = model->index(j - first, 0, parent);
if (isRowHidden(current)) {
@@ -3955,7 +3955,7 @@ int QTreeViewPrivate::accessibleTree2Index(const QModelIndex &index) const
void QTreeViewPrivate::updateIndentationFromStyle()
{
Q_Q(const QTreeView);
- indent = q->style()->pixelMetric(QStyle::PM_TreeViewIndentation, 0, q);
+ indent = q->style()->pixelMetric(QStyle::PM_TreeViewIndentation, nullptr, q);
}
/*!
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 6d0909108b..0d4c391e1c 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -48,6 +48,8 @@
#include <private/qwidgetitemdata_p.h>
#include <private/qtreewidgetitemiterator_p.h>
+#include <QtCore/private/qduplicatetracker_p.h>
+
#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -144,7 +146,7 @@ QTreeModel::~QTreeModel()
clear();
headerItem->view = nullptr;
delete headerItem;
- rootItem->view = 0;
+ rootItem->view = nullptr;
delete rootItem;
}
@@ -160,8 +162,8 @@ void QTreeModel::clear()
beginResetModel();
for (int i = 0; i < rootItem->childCount(); ++i) {
QTreeWidgetItem *item = rootItem->children.at(i);
- item->par = 0;
- item->view = 0;
+ item->par = nullptr;
+ item->view = nullptr;
delete item;
}
rootItem->children.clear();
@@ -214,7 +216,7 @@ void QTreeModel::setColumnCount(int columns)
QTreeWidgetItem *QTreeModel::item(const QModelIndex &index) const
{
if (!index.isValid())
- return 0;
+ return nullptr;
return static_cast<QTreeWidgetItem*>(index.internalPointer());
}
@@ -515,9 +517,9 @@ bool QTreeModel::removeRows(int row, int count, const QModelIndex &parent) {
for (int i = row + count - 1; i >= row; --i) {
QTreeWidgetItem *child = itm ? itm->takeChild(i) : rootItem->children.takeAt(i);
Q_ASSERT(child);
- child->view = 0;
+ child->view = nullptr;
delete child;
- child = 0;
+ child = nullptr;
}
blocker.unblock();
@@ -1285,6 +1287,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
Sets the background brush of the label in the given \a column to the
specified \a brush.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\note If \l{Qt Style Sheets} are used on the same widget as setBackground(),
style sheets will take precedence if the settings conflict.
@@ -1314,6 +1318,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
Returns the brush used to render the foreground (e.g. text) of the
specified \a column.
+ Setting a default-constructed brush will let the view use the
+ default color from the style.
\sa background()
*/
@@ -1357,8 +1363,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
\since 4.1
Sets the size hint for the tree item in the given \a column to be \a size.
- If no size hint is set, the item delegate will compute the size hint based
- on the item data.
+ If no size hint is set or \a size is invalid, the item
+ delegate will compute the size hint based on the item data.
*/
/*!
@@ -1608,11 +1614,11 @@ QTreeWidgetItem::~QTreeWidgetItem()
}
} else if (model) {
if (this == model->headerItem) {
- model->headerItem = 0;
+ model->headerItem = nullptr;
} else {
int i = model->rootItem->children.indexOf(this);
if (i >= 0) {
- model->beginRemoveItems(0, i, 1);
+ model->beginRemoveItems(nullptr, i, 1);
// users _could_ do changes when connected to rowsAboutToBeRemoved,
// so we check again to make sure 'i' is valid
if (!model->rootItem->children.isEmpty() && model->rootItem->children.at(i) == this)
@@ -1626,9 +1632,9 @@ QTreeWidgetItem::~QTreeWidgetItem()
for (int i = 0; i < children.count(); ++i) {
QTreeWidgetItem *child = children.at(i);
// make sure the child does not try to remove itself from our children list
- child->par = 0;
+ child->par = nullptr;
// make sure the child does not try to remove itself from the top level list
- child->view = 0;
+ child->view = nullptr;
delete child;
}
@@ -1644,16 +1650,16 @@ QTreeWidgetItem::~QTreeWidgetItem()
*/
QTreeWidgetItem *QTreeWidgetItem::clone() const
{
- QTreeWidgetItem *copy = 0;
+ QTreeWidgetItem *copy = nullptr;
QStack<const QTreeWidgetItem*> stack;
QStack<QTreeWidgetItem*> parentStack;
stack.push(this);
parentStack.push(0);
- QTreeWidgetItem *root = 0;
- const QTreeWidgetItem *item = 0;
- QTreeWidgetItem *parent = 0;
+ QTreeWidgetItem *root = nullptr;
+ const QTreeWidgetItem *item = nullptr;
+ QTreeWidgetItem *parent = nullptr;
while (!stack.isEmpty()) {
// get current item, and copied parent
item = stack.pop();
@@ -1988,8 +1994,8 @@ void QTreeWidgetItem::write(QDataStream &out) const
\sa data(), flags()
*/
QTreeWidgetItem::QTreeWidgetItem(const QTreeWidgetItem &other)
- : rtti(Type), values(other.values), view(0),
- d(new QTreeWidgetItemPrivate(this)), par(0),
+ : rtti(Type), values(other.values), view(nullptr),
+ d(new QTreeWidgetItemPrivate(this)), par(nullptr),
itemFlags(other.itemFlags)
{
d->display = other.d->display;
@@ -2032,14 +2038,14 @@ void QTreeWidgetItem::addChild(QTreeWidgetItem *child)
*/
void QTreeWidgetItem::insertChild(int index, QTreeWidgetItem *child)
{
- if (index < 0 || index > children.count() || child == 0 || child->view != 0 || child->par != 0)
+ if (index < 0 || index > children.count() || child == nullptr || child->view != nullptr || child->par != nullptr)
return;
if (QTreeModel *model = treeModel()) {
const bool wasSkipSort = model->skipPendingSort;
model->skipPendingSort = true;
if (model->rootItem == this)
- child->par = 0;
+ child->par = nullptr;
else
child->par = this;
if (view->isSortingEnabled()) {
@@ -2099,12 +2105,12 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index)
if (model) model->beginRemoveItems(this, index, 1);
d->updateHiddenStatus(children.at(index), false);
QTreeWidgetItem *item = children.takeAt(index);
- item->par = 0;
+ item->par = nullptr;
QStack<QTreeWidgetItem*> stack;
stack.push(item);
while (!stack.isEmpty()) {
QTreeWidgetItem *i = stack.pop();
- i->view = 0;
+ i->view = nullptr;
for (int c = 0; c < i->children.count(); ++c)
stack.push(i->children.at(c));
}
@@ -2112,7 +2118,7 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index)
if (model) model->endRemoveRows();
return item;
}
- return 0;
+ return nullptr;
}
/*!
@@ -2159,7 +2165,7 @@ void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &c
stack.push(child);
}
if (model && (model->rootItem == this))
- child->par = 0;
+ child->par = nullptr;
else
child->par = this;
}
@@ -2202,12 +2208,12 @@ QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren()
if (model) model->beginRemoveItems(this, 0, children.count());
for (int n = 0; n < children.count(); ++n) {
QTreeWidgetItem *item = children.at(n);
- item->par = 0;
+ item->par = nullptr;
QStack<QTreeWidgetItem*> stack;
stack.push(item);
while (!stack.isEmpty()) {
QTreeWidgetItem *i = stack.pop();
- i->view = 0;
+ i->view = nullptr;
for (int c = 0; c < i->children.count(); ++c)
stack.push(i->children.at(c));
}
@@ -3171,13 +3177,12 @@ QList<QTreeWidgetItem*> QTreeWidget::selectedItems() const
const QModelIndexList indexes = selectionModel()->selectedIndexes();
QList<QTreeWidgetItem*> items;
items.reserve(indexes.count());
- QSet<QTreeWidgetItem *> seen;
+ QDuplicateTracker<QTreeWidgetItem *> seen;
seen.reserve(indexes.count());
for (const auto &index : indexes) {
QTreeWidgetItem *item = d->item(index);
- if (item->isHidden() || seen.contains(item))
+ if (item->isHidden() || seen.hasSeen(item))
continue;
- seen.insert(item);
items.append(item);
}
return items;
@@ -3302,7 +3307,7 @@ QTreeWidgetItem *QTreeWidget::itemAbove(const QTreeWidgetItem *item) const
{
Q_D(const QTreeWidget);
if (item == d->treeModel()->headerItem)
- return 0;
+ return nullptr;
const QModelIndex index = d->index(item);
const QModelIndex above = indexAbove(index);
return d->item(above);
@@ -3317,7 +3322,7 @@ QTreeWidgetItem *QTreeWidget::itemBelow(const QTreeWidgetItem *item) const
{
Q_D(const QTreeWidget);
if (item == d->treeModel()->headerItem)
- return 0;
+ return nullptr;
const QModelIndex index = d->index(item);
const QModelIndex below = indexBelow(index);
return d->item(below);
@@ -3420,14 +3425,14 @@ QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const
for (const auto *item : items) {
if (Q_UNLIKELY(!item)) {
qWarning("QTreeWidget::mimeData: Null-item passed");
- return 0;
+ return nullptr;
}
for (int c = 0; c < item->values.count(); ++c) {
const QModelIndex index = indexFromItem(item, c);
if (Q_UNLIKELY(!index.isValid())) {
qWarning() << "QTreeWidget::mimeData: No index associated with item :" << item;
- return 0;
+ return nullptr;
}
indexes << index;
}
diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h
index bed77b336d..b9543fb954 100644
--- a/src/widgets/itemviews/qtreewidget.h
+++ b/src/widgets/itemviews/qtreewidget.h
@@ -146,7 +146,7 @@ public:
inline QBrush background(int column) const
{ return qvariant_cast<QBrush>(data(column, Qt::BackgroundRole)); }
inline void setBackground(int column, const QBrush &brush)
- { setData(column, Qt::BackgroundRole, brush); }
+ { setData(column, Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X ("Use QTreeWidgetItem::foreground() instead")
@@ -160,7 +160,7 @@ public:
inline QBrush foreground(int column) const
{ return qvariant_cast<QBrush>(data(column, Qt::ForegroundRole)); }
inline void setForeground(int column, const QBrush &brush)
- { setData(column, Qt::ForegroundRole, brush); }
+ { setData(column, Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); }
inline Qt::CheckState checkState(int column) const
{ return static_cast<Qt::CheckState>(data(column, Qt::CheckStateRole).toInt()); }
@@ -170,7 +170,7 @@ public:
inline QSize sizeHint(int column) const
{ return qvariant_cast<QSize>(data(column, Qt::SizeHintRole)); }
inline void setSizeHint(int column, const QSize &size)
- { setData(column, Qt::SizeHintRole, size); }
+ { setData(column, Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); }
virtual QVariant data(int column, int role) const;
virtual void setData(int column, int role, const QVariant &value);
diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.cpp b/src/widgets/itemviews/qtreewidgetitemiterator.cpp
index 14c19fcb9c..a24106d90e 100644
--- a/src/widgets/itemviews/qtreewidgetitemiterator.cpp
+++ b/src/widgets/itemviews/qtreewidgetitemiterator.cpp
@@ -90,7 +90,7 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(const QTreeWidgetItemIterator &
*/
QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFlags flags)
-: current(0), flags(flags)
+: current(nullptr), flags(flags)
{
Q_ASSERT(widget);
QTreeModel *model = qobject_cast<QTreeModel*>(widget->model());
@@ -266,7 +266,7 @@ bool QTreeWidgetItemIterator::matchesFlags(const QTreeWidgetItem *item) const
QTreeWidgetItem* QTreeWidgetItemIteratorPrivate::nextSibling(const QTreeWidgetItem* item) const
{
Q_ASSERT(item);
- QTreeWidgetItem *next = 0;
+ QTreeWidgetItem *next = nullptr;
if (QTreeWidgetItem *par = item->parent()) {
int i = par->indexOfChild(const_cast<QTreeWidgetItem*>(item));
next = par->child(i + 1);
@@ -280,9 +280,9 @@ QTreeWidgetItem* QTreeWidgetItemIteratorPrivate::nextSibling(const QTreeWidgetIt
QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::next(const QTreeWidgetItem *current)
{
- if (!current) return 0;
+ if (!current) return nullptr;
- QTreeWidgetItem *next = 0;
+ QTreeWidgetItem *next = nullptr;
if (current->childCount()) {
// walk the child
m_parentIndex.push(m_currentIndex);
@@ -307,9 +307,9 @@ QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::next(const QTreeWidgetItem *cur
QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::previous(const QTreeWidgetItem *current)
{
- if (!current) return 0;
+ if (!current) return nullptr;
- QTreeWidgetItem *prev = 0;
+ QTreeWidgetItem *prev = nullptr;
// walk the previous sibling
QTreeWidgetItem *parent = current->parent();
prev = parent ? parent->child(m_currentIndex - 1)
@@ -347,7 +347,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem *
// we need to adjust the iterator.
if (nextItem == itemToBeRemoved) {
QTreeWidgetItem *parent = nextItem;
- nextItem = 0;
+ nextItem = nullptr;
while (parent && !nextItem) {
nextItem = nextSibling(parent);
parent = parent->parent();
@@ -358,7 +358,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem *
if (!(q->matchesFlags(nextItem))) ++(*q);
} else {
// set it to null.
- q->current = 0;
+ q->current = nullptr;
m_parentIndex.clear();
return;
}
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 19ad65692b..64b0d69f6d 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -658,7 +658,7 @@ void QAction::setMenu(QMenu *menu)
{
Q_D(QAction);
if (d->menu)
- d->menu->d_func()->setOverrideMenuAction(0); //we reset the default action of any previous menu
+ d->menu->d_func()->setOverrideMenuAction(nullptr); //we reset the default action of any previous menu
d->menu = menu;
if (menu)
menu->d_func()->setOverrideMenuAction(this);
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index f7693f4dde..258a1ea0a0 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -63,7 +63,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
Q_DECLARE_PRIVATE(QAction)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY changed)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY changed)
Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY changed)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY changed)
diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp
index d359703db3..d51fb778c4 100644
--- a/src/widgets/kernel/qactiongroup.cpp
+++ b/src/widgets/kernel/qactiongroup.cpp
@@ -81,7 +81,7 @@ void QActionGroupPrivate::_q_actionChanged()
current = action;
}
} else if (action == current) {
- current = 0;
+ current = nullptr;
}
}
}
@@ -271,11 +271,11 @@ void QActionGroup::removeAction(QAction *action)
Q_D(QActionGroup);
if (d->actions.removeAll(action)) {
if (action == d->current)
- d->current = 0;
+ d->current = nullptr;
QObject::disconnect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
QObject::disconnect(action, SIGNAL(changed()), this, SLOT(_q_actionChanged()));
QObject::disconnect(action, SIGNAL(hovered()), this, SLOT(_q_actionHovered()));
- action->d_func()->group = 0;
+ action->d_func()->group = nullptr;
}
}
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index ce32fd39a8..129569a466 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -138,31 +138,7 @@ QT_BEGIN_NAMESPACE
Q_CORE_EXPORT void qt_call_post_routines();
Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1);
-QApplicationPrivate *QApplicationPrivate::self = 0;
-
-static void initSystemPalette()
-{
- if (QApplicationPrivate::sys_pal)
- return; // Already initialized
-
- QPalette defaultPalette;
- if (QApplicationPrivate::app_style)
- defaultPalette = QApplicationPrivate::app_style->standardPalette();
-
- auto *platformTheme = QGuiApplicationPrivate::platformTheme();
- if (const QPalette *themePalette = platformTheme ? platformTheme->palette() : nullptr) {
- QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPalette));
- QApplicationPrivate::initializeWidgetPaletteHash();
- } else {
- QApplicationPrivate::setSystemPalette(defaultPalette);
- }
-}
-
-static void clearSystemPalette()
-{
- delete QApplicationPrivate::sys_pal;
- QApplicationPrivate::sys_pal = 0;
-}
+QApplicationPrivate *QApplicationPrivate::self = nullptr;
bool QApplicationPrivate::autoSipEnabled = true;
@@ -172,8 +148,8 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags)
application_type = QApplicationPrivate::Gui;
#ifndef QT_NO_GESTURES
- gestureManager = 0;
- gestureWidget = 0;
+ gestureManager = nullptr;
+ gestureWidget = nullptr;
#endif // QT_NO_GESTURES
if (!self)
@@ -183,7 +159,7 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags)
QApplicationPrivate::~QApplicationPrivate()
{
if (self == this)
- self = 0;
+ self = nullptr;
}
void QApplicationPrivate::createEventDispatcher()
@@ -360,7 +336,7 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
if (const QWidgetWindow *widgetWindow = qobject_cast<const QWidgetWindow *>(window))
return widgetWindow->widget();
}
- return 0;
+ return nullptr;
}
/*!
@@ -375,21 +351,19 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
void qt_init_tooltip_palette();
void qt_cleanup();
-QStyle *QApplicationPrivate::app_style = 0; // default application style
+QStyle *QApplicationPrivate::app_style = nullptr; // default application style
#ifndef QT_NO_STYLE_STYLESHEET
QString QApplicationPrivate::styleSheet; // default application stylesheet
#endif
-QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0;
-
-QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
+QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = nullptr;
-QFont *QApplicationPrivate::sys_font = 0; // default system font
-QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
+QFont *QApplicationPrivate::sys_font = nullptr; // default system font
+QFont *QApplicationPrivate::set_font = nullptr; // default font set by programmer
-QWidget *QApplicationPrivate::main_widget = 0; // main application widget
-QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input focus
-QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show()
-QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus
+QWidget *QApplicationPrivate::main_widget = nullptr; // main application widget
+QWidget *QApplicationPrivate::focus_widget = nullptr; // has keyboard input focus
+QWidget *QApplicationPrivate::hidden_focus_widget = nullptr; // will get keyboard input focus after show()
+QWidget *QApplicationPrivate::active_window = nullptr; // toplevel with keyboard focus
#if QT_CONFIG(wheelevent)
QPointer<QWidget> QApplicationPrivate::wheel_widget;
#endif
@@ -419,9 +393,9 @@ Q_GLOBAL_STATIC(FontHash, app_fonts)
// Exported accessor for use outside of this file
FontHash *qt_app_fonts_hash() { return app_fonts(); }
-QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus
+QWidgetList *QApplicationPrivate::popupWidgets = nullptr; // has keyboard input focus
-QDesktopWidget *qt_desktopWidget = 0; // root window widgets
+QDesktopWidget *qt_desktopWidget = nullptr; // root window widgets
/*!
\internal
@@ -466,7 +440,7 @@ void QApplicationPrivate::process_cmdline()
}
if(j < argc) {
- argv[j] = 0;
+ argv[j] = nullptr;
argc = j;
}
}
@@ -545,12 +519,7 @@ void QApplicationPrivate::init()
// Must be called before initialize()
QColormap::initialize();
- if (sys_pal) {
- // Now that we have a platform theme we need to reset
- // the system palette to pick up the theme colors.
- clearSystemPalette();
- initSystemPalette();
- }
+ initializeWidgetPalettesFromTheme();
qt_init_tooltip_palette();
QApplicationPrivate::initializeWidgetFontHash();
@@ -629,38 +598,6 @@ void QApplicationPrivate::initialize()
is_app_running = true; // no longer starting up
}
-static void setPossiblePalette(const QPalette *palette, const char *className)
-{
- if (palette == 0)
- return;
- QApplicationPrivate::setPalette_helper(*palette, className);
-}
-
-void QApplicationPrivate::initializeWidgetPaletteHash()
-{
- QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme();
- if (!platformTheme)
- return;
-
- widgetPalettes.clear();
-
- setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::CheckBoxPalette), "QCheckBox");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::RadioButtonPalette), "QRadioButton");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::HeaderPalette), "QHeaderView");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::ItemViewPalette), "QAbstractItemView");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::MessageBoxLabelPalette), "QMessageBoxLabel");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::TabBarPalette), "QTabBar");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::LabelPalette), "QLabel");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::GroupBoxPalette), "QGroupBox");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuPalette), "QMenu");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuBarPalette), "QMenuBar");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextEdit");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextControl");
- setPossiblePalette(platformTheme->palette(QPlatformTheme::TextLineEditPalette), "QLineEdit");
-}
-
void QApplicationPrivate::initializeWidgetFontHash()
{
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
@@ -758,7 +695,7 @@ QWidget *QApplication::activePopupWidget()
QWidget *QApplication::activeModalWidget()
{
QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(modalWindow());
- return widgetWindow ? widgetWindow->widget() : 0;
+ return widgetWindow ? widgetWindow->widget() : nullptr;
}
/*!
@@ -781,12 +718,12 @@ QApplication::~QApplication()
QApplicationPrivate::is_app_running = false;
delete QWidgetPrivate::mapper;
- QWidgetPrivate::mapper = 0;
+ QWidgetPrivate::mapper = nullptr;
// delete all widgets
if (QWidgetPrivate::allWidgets) {
QWidgetSet *mySet = QWidgetPrivate::allWidgets;
- QWidgetPrivate::allWidgets = 0;
+ QWidgetPrivate::allWidgets = nullptr;
for (QWidgetSet::ConstIterator it = mySet->constBegin(), cend = mySet->constEnd(); it != cend; ++it) {
QWidget *w = *it;
if (!w->parent()) // window
@@ -796,21 +733,18 @@ QApplication::~QApplication()
}
delete qt_desktopWidget;
- qt_desktopWidget = 0;
+ qt_desktopWidget = nullptr;
- delete QApplicationPrivate::app_pal;
- QApplicationPrivate::app_pal = 0;
- clearSystemPalette();
QApplicationPrivate::widgetPalettes.clear();
delete QApplicationPrivate::sys_font;
- QApplicationPrivate::sys_font = 0;
+ QApplicationPrivate::sys_font = nullptr;
delete QApplicationPrivate::set_font;
- QApplicationPrivate::set_font = 0;
+ QApplicationPrivate::set_font = nullptr;
app_fonts()->clear();
delete QApplicationPrivate::app_style;
- QApplicationPrivate::app_style = 0;
+ QApplicationPrivate::app_style = nullptr;
#if QT_CONFIG(draganddrop)
if (qt_is_gui_used)
@@ -856,7 +790,7 @@ void qt_cleanup()
QPixmapCache::clear();
QColormap::cleanup();
- QApplicationPrivate::active_window = 0; //### this should not be necessary
+ QApplicationPrivate::active_window = nullptr; //### this should not be necessary
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
if (displayDC) {
@@ -902,7 +836,7 @@ QWidget *QApplication::widgetAt(const QPoint &p)
QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask)
- QRegion(wpoint.x(), wpoint.y(), 1, 1);
window->setMask(newmask);
- QWidget *recurse = 0;
+ QWidget *recurse = nullptr;
if (QApplication::topLevelAt(p) != window) // verify recursion will terminate
recurse = widgetAt(x, y);
if (oldmask.isEmpty())
@@ -935,7 +869,7 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
|| event->type() == QEvent::LanguageChange)) {
for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) {
const QPostEvent &cur = *it;
- if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
+ if (cur.receiver != receiver || cur.event == nullptr || cur.event->type() != event->type())
continue;
if (cur.event->type() == QEvent::LayoutRequest
|| cur.event->type() == QEvent::UpdateRequest) {
@@ -1045,16 +979,16 @@ QStyle *QApplication::style()
}
if (!defaultStyle) {
Q_ASSERT(!"No styles available!");
- return 0;
+ return nullptr;
}
// Take ownership of the style
defaultStyle->setParent(qApp);
- initSystemPalette();
-
if (testAttribute(Qt::AA_SetPalette))
defaultStyle->polish(*QGuiApplicationPrivate::app_pal);
+ else
+ QApplicationPrivate::initializeWidgetPalettesFromTheme();
#ifndef QT_NO_STYLE_STYLESHEET
if (!QApplicationPrivate::styleSheet.isEmpty()) {
@@ -1128,13 +1062,10 @@ void QApplication::setStyle(QStyle *style)
// take care of possible palette requirements of certain gui
// styles. Do it before polishing the application since the style
// might call QApplication::setPalette() itself
- if (testAttribute(Qt::AA_SetPalette)) {
+ if (testAttribute(Qt::AA_SetPalette))
QApplicationPrivate::app_style->polish(*QGuiApplicationPrivate::app_pal);
- } else {
- if (QApplicationPrivate::sys_pal)
- clearSystemPalette();
- initSystemPalette();
- }
+ else
+ QApplicationPrivate::initializeWidgetPalettesFromTheme();
// The default widget font hash is based on the platform theme,
// not the style, but the widget fonts could in theory have been
@@ -1206,7 +1137,7 @@ QStyle* QApplication::setStyle(const QString& style)
{
QStyle *s = QStyleFactory::create(style);
if (!s)
- return 0;
+ return nullptr;
setStyle(s);
return s;
@@ -1293,6 +1224,7 @@ void QApplication::setColorSpec(int spec)
\property QApplication::globalStrut
\brief the minimum size that any GUI element that the user can interact
with should have
+ \deprecated
For example, no button should be resized to be smaller than the global
strut size. The strut size should be considered when reimplementing GUI
@@ -1317,6 +1249,22 @@ void QApplication::setGlobalStrut(const QSize& strut)
// Widget specific palettes
QApplicationPrivate::PaletteHash QApplicationPrivate::widgetPalettes;
+QPalette QApplicationPrivate::basePalette() const
+{
+ // Start out with a palette based on the style, in case there's no theme
+ // available, or so that we can fill in missing roles in the theme.
+ QPalette palette = app_style ? app_style->standardPalette() : Qt::gray;
+
+ // Prefer theme palette if available, but fill in missing roles from style
+ // for compatibility. Note that the style's standard palette is not prioritized
+ // over the theme palette, as the documented way of applying the style's palette
+ // is to set it explicitly using QApplication::setPalette().
+ if (const QPalette *themePalette = platformTheme() ? platformTheme()->palette() : nullptr)
+ palette = themePalette->resolve(palette);
+
+ return palette;
+}
+
/*!
\fn QPalette QApplication::palette(const QWidget* widget)
@@ -1363,35 +1311,8 @@ QPalette QApplication::palette(const char *className)
return QGuiApplication::palette();
}
-void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className)
-{
- QPalette pal = palette;
-
- if (QApplicationPrivate::app_style)
- QApplicationPrivate::app_style->polish(pal); // NB: non-const reference
-
- bool all = false;
- if (!className) {
- if (!QGuiApplicationPrivate::setPalette(pal))
- return;
-
- if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))
- QCoreApplication::setAttribute(Qt::AA_SetPalette);
-
- if (!widgetPalettes.isEmpty()) {
- all = true;
- widgetPalettes.clear();
- }
- } else {
- widgetPalettes.insert(className, pal);
- }
-
- if (qApp)
- qApp->d_func()->sendApplicationPaletteChange(all, className);
-}
-
/*!
- Changes the default application palette to \a palette.
+ Changes the application palette to \a palette.
If \a className is passed, the change applies only to widgets that inherit
\a className (as reported by QObject::inherits()). If \a className is left
@@ -1412,23 +1333,87 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
\sa QWidget::setPalette(), palette(), QStyle::polish()
*/
-
void QApplication::setPalette(const QPalette &palette, const char* className)
{
- QApplicationPrivate::setPalette_helper(palette, className);
+ QPalette polishedPalette = palette;
+
+ if (QApplicationPrivate::app_style)
+ QApplicationPrivate::app_style->polish(polishedPalette);
+
+ if (className) {
+ QApplicationPrivate::widgetPalettes.insert(className, polishedPalette);
+ if (qApp)
+ qApp->d_func()->handlePaletteChanged(className);
+ } else {
+ QGuiApplication::setPalette(polishedPalette);
+ }
}
+void QApplicationPrivate::handlePaletteChanged(const char *className)
+{
+ if (!is_app_running || is_app_closing)
+ return;
+
+ // Setting the global application palette is documented to
+ // reset any previously set class specific widget palettes.
+ bool sendPaletteChangeToAllWidgets = false;
+ if (!className && !widgetPalettes.isEmpty()) {
+ sendPaletteChangeToAllWidgets = true;
+ widgetPalettes.clear();
+ }
+ QGuiApplicationPrivate::handlePaletteChanged(className);
-void QApplicationPrivate::setSystemPalette(const QPalette &pal)
+ QEvent event(QEvent::ApplicationPaletteChange);
+ const QWidgetList widgets = QApplication::allWidgets();
+ for (auto widget : widgets) {
+ if (sendPaletteChangeToAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className)))
+ QCoreApplication::sendEvent(widget, &event);
+ }
+
+#if QT_CONFIG(graphicsview)
+ for (auto scene : qAsConst(scene_list))
+ QCoreApplication::sendEvent(scene, &event);
+#endif
+
+ // Palette has been reset back to the default application palette,
+ // so we need to reinitialize the widget palettes from the theme.
+ if (!className && !testAttribute(Qt::AA_SetPalette))
+ initializeWidgetPalettesFromTheme();
+}
+
+void QApplicationPrivate::initializeWidgetPalettesFromTheme()
{
- if (!sys_pal)
- sys_pal = new QPalette(pal);
- else
- *sys_pal = pal;
+ QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme();
+ if (!platformTheme)
+ return;
+
+ widgetPalettes.clear();
- if (!testAttribute(Qt::AA_SetPalette))
- QApplication::setPalette(*sys_pal);
+ struct ThemedWidget { const char *className; QPlatformTheme::Palette palette; };
+
+ static const ThemedWidget themedWidgets[] = {
+ { "QToolButton", QPlatformTheme::ToolButtonPalette },
+ { "QAbstractButton", QPlatformTheme::ButtonPalette },
+ { "QCheckBox", QPlatformTheme::CheckBoxPalette },
+ { "QRadioButton", QPlatformTheme::RadioButtonPalette },
+ { "QHeaderView", QPlatformTheme::HeaderPalette },
+ { "QAbstractItemView", QPlatformTheme::ItemViewPalette },
+ { "QMessageBoxLabel", QPlatformTheme::MessageBoxLabelPalette },
+ { "QTabBar", QPlatformTheme::TabBarPalette },
+ { "QLabel", QPlatformTheme::LabelPalette },
+ { "QGroupBox", QPlatformTheme::GroupBoxPalette },
+ { "QMenu", QPlatformTheme::MenuPalette },
+ { "QMenuBar", QPlatformTheme::MenuBarPalette },
+ { "QTextEdit", QPlatformTheme::TextEditPalette },
+ { "QTextControl", QPlatformTheme::TextEditPalette },
+ { "QLineEdit", QPlatformTheme::TextLineEditPalette },
+ };
+
+ for (const auto themedWidget : themedWidgets) {
+ if (auto *palette = platformTheme->palette(themedWidget.palette))
+ QApplication::setPalette(*palette, themedWidget.className);
+ }
}
/*!
@@ -1686,7 +1671,7 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
return;
#endif
- hidden_focus_widget = 0;
+ hidden_focus_widget = nullptr;
if (focus != focus_widget) {
if (focus && focus->isHidden()) {
@@ -1884,7 +1869,7 @@ bool QApplication::event(QEvent *e)
#endif
} else if (e->type() == QEvent::Timer) {
QTimerEvent *te = static_cast<QTimerEvent*>(e);
- Q_ASSERT(te != 0);
+ Q_ASSERT(te != nullptr);
if (te->timerId() == d->toolTipWakeUp.timerId()) {
d->toolTipWakeUp.stop();
if (d->toolTipWidget) {
@@ -1896,14 +1881,14 @@ bool QApplication::event(QEvent *e)
while (w && !showToolTip) {
showToolTip = w->isActiveWindow();
w = w->parentWidget();
- w = w ? w->window() : 0;
+ w = w ? w->window() : nullptr;
}
if (showToolTip) {
QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos);
QCoreApplication::sendEvent(d->toolTipWidget, &e);
if (e.isAccepted()) {
QStyle *s = d->toolTipWidget->style();
- int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, 0, d->toolTipWidget, 0);
+ int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, nullptr, d->toolTipWidget, nullptr);
d->toolTipFallAsleep.start(sleepDelay, this);
}
}
@@ -1973,7 +1958,7 @@ void QApplicationPrivate::notifyLayoutDirectionChange()
*/
void QApplication::setActiveWindow(QWidget* act)
{
- QWidget* window = act?act->window():0;
+ QWidget* window = act?act->window():nullptr;
if (QApplicationPrivate::active_window == window)
return;
@@ -1989,7 +1974,7 @@ void QApplication::setActiveWindow(QWidget* act)
QWidgetList toBeDeactivated;
if (QApplicationPrivate::active_window) {
- if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
+ if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) {
const QWidgetList list = topLevelWidgets();
for (auto *w : list) {
if (w->isVisible() && w->isActiveWindow())
@@ -2011,7 +1996,7 @@ void QApplication::setActiveWindow(QWidget* act)
QApplicationPrivate::active_window = window;
if (QApplicationPrivate::active_window) {
- if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
+ if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) {
const QWidgetList list = topLevelWidgets();
for (auto *w : list) {
if (w->isVisible() && w->isActiveWindow())
@@ -2040,10 +2025,10 @@ void QApplication::setActiveWindow(QWidget* act)
sendSpontaneousEvent(w, &activationChange);
}
- if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode()
+ if (QApplicationPrivate::popupWidgets == nullptr) { // !inPopupMode()
// then focus events
if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) {
- QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
+ QApplicationPrivate::setFocusWidget(nullptr, Qt::ActiveWindowFocusReason);
} else if (QApplicationPrivate::active_window) {
QWidget *w = QApplicationPrivate::active_window->focusWidget();
if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/)
@@ -2058,7 +2043,7 @@ void QApplication::setActiveWindow(QWidget* act)
if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason);
else if (!QApplicationPrivate::active_window->isAncestorOf(w))
- QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
+ QApplicationPrivate::setFocusWidget(nullptr, Qt::ActiveWindowFocusReason);
}
}
}
@@ -2086,7 +2071,7 @@ QWidget *qt_tlw_for_window(QWindow *wnd)
return tlw;
}
}
- return 0;
+ return nullptr;
}
void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous)
@@ -2150,7 +2135,7 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
test = test->d_func()->focus_next;
}
- if (wrappingOccurred != 0)
+ if (wrappingOccurred != nullptr)
*wrappingOccurred = next ? focusWidgetAfterWindow : !focusWidgetAfterWindow;
if (w == f) {
@@ -2158,7 +2143,7 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
w->window()->setAttribute(Qt::WA_KeyboardFocusChange);
w->update();
}
- return 0;
+ return nullptr;
}
return w;
}
@@ -2240,7 +2225,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con
QEvent leaveEvent(QEvent::Leave);
for (int i = 0; i < leaveList.size(); ++i) {
auto *w = leaveList.at(i);
- if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
+ if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) {
QCoreApplication::sendEvent(w, &leaveEvent);
if (w->testAttribute(Qt::WA_Hover) &&
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
@@ -2259,7 +2244,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con
const QPoint windowPos = qAsConst(enterList).back()->window()->mapFromGlobal(globalPos);
for (auto it = enterList.crbegin(), end = enterList.crend(); it != end; ++it) {
auto *w = *it;
- if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
+ if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) {
const QPointF localPos = w->mapFromGlobal(globalPos);
QEnterEvent enterEvent(localPos, windowPos, globalPosF);
QCoreApplication::sendEvent(w, &enterEvent);
@@ -2279,7 +2264,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con
const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen)));
// Whenever we leave an alien widget on X11/QPA, we need to reset its nativeParentWidget()'s cursor.
// This is not required on Windows as the cursor is reset on every single mouse move.
- QWidget *parentOfLeavingCursor = 0;
+ QWidget *parentOfLeavingCursor = nullptr;
for (int i = 0; i < leaveList.size(); ++i) {
auto *w = leaveList.at(i);
if (!isAlien(w))
@@ -2345,7 +2330,7 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget)
bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const
{
- QWindow *unused = 0;
+ QWindow *unused = nullptr;
if (Q_UNLIKELY(!window)) {
qWarning().nospace() << "window == 0 passed.";
return false;
@@ -2354,13 +2339,13 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin
blockingWindow = &unused;
if (modalWindowList.isEmpty()) {
- *blockingWindow = 0;
+ *blockingWindow = nullptr;
return false;
}
QWidget *popupWidget = QApplication::activePopupWidget();
- QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : 0;
+ QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : nullptr;
if (popupWindow == window || (!popupWindow && QWindowPrivate::get(window)->isPopup())) {
- *blockingWindow = 0;
+ *blockingWindow = nullptr;
return false;
}
@@ -2370,7 +2355,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin
// A window is not blocked by another modal window if the two are
// the same, or if the window is a child of the modal window.
if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) {
- *blockingWindow = 0;
+ *blockingWindow = nullptr;
return false;
}
@@ -2381,7 +2366,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin
// modalWindow's widget, this normally happens when waiting for a
// native dialog. use WindowModal if we are the child of a group
// leader; otherwise use ApplicationModal.
- QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0;
+ QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : nullptr;
while (m && !m->testAttribute(Qt::WA_GroupLeader)) {
m = m->parentWidget();
if (m)
@@ -2396,13 +2381,13 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin
case Qt::ApplicationModal:
{
QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(window);
- QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : 0;
+ QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : nullptr;
while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader))
groupLeaderForWidget = groupLeaderForWidget->parentWidget();
if (groupLeaderForWidget) {
// if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children
- QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0;
+ QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : nullptr;
while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader))
m = m->parentWidget();
if (m == groupLeaderForWidget) {
@@ -2442,7 +2427,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin
break;
}
}
- *blockingWindow = 0;
+ *blockingWindow = nullptr;
return false;
}
@@ -2466,7 +2451,7 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop)
bool qt_try_modal(QWidget *widget, QEvent::Type type)
{
- QWidget * top = 0;
+ QWidget * top = nullptr;
if (QApplicationPrivate::tryModalHelper(widget, &top))
return true;
@@ -2491,7 +2476,7 @@ bool qt_try_modal(QWidget *widget, QEvent::Type type)
break;
}
- if (block_event && top && top->parentWidget() == 0)
+ if (block_event && top && top->parentWidget() == nullptr)
top->raise();
return !block_event;
@@ -2515,11 +2500,11 @@ QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint
QWidget *mouseGrabber = QWidget::mouseGrabber();
if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease))
&& !buttonDown && !mouseGrabber) {
- return 0;
+ return nullptr;
}
if (alienWidget && alienWidget->internalWinId())
- alienWidget = 0;
+ alienWidget = nullptr;
QWidget *receiver = candidate;
@@ -2552,7 +2537,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
Q_ASSERT(buttonDown);
if (alienWidget && !isAlien(alienWidget))
- alienWidget = 0;
+ alienWidget = nullptr;
QPointer<QWidget> receiverGuard = receiver;
QPointer<QWidget> nativeGuard = nativeWidget;
@@ -2567,7 +2552,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
// leaveAfterRelease has not been updated.
// This happens e.g. when modal dialog or popup is shown as a response to button click.
if (leaveAfterRelease && !*buttonDown && !event->buttons())
- leaveAfterRelease = 0;
+ leaveAfterRelease = nullptr;
if (*buttonDown) {
if (!graphicsWidget) {
@@ -2576,7 +2561,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber())
leaveAfterRelease = *buttonDown;
if (event->type() == QEvent::MouseButtonRelease && !event->buttons())
- *buttonDown = 0;
+ *buttonDown = nullptr;
}
} else if (lastMouseReceiver && widgetUnderMouse) {
// Dispatch enter/leave if we move:
@@ -2604,7 +2589,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
// We need this quard in case someone opens a modal dialog / popup. If that's the case
// leaveAfterRelease is set to null, but we shall not update lastMouseReceiver.
- const bool wasLeaveAfterRelease = leaveAfterRelease != 0;
+ const bool wasLeaveAfterRelease = leaveAfterRelease != nullptr;
bool result = true;
// This code is used for sending the synthetic enter/leave events for cases where it is needed
// due to other events causing the widget under the mouse to change. However in those cases
@@ -2622,18 +2607,18 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
// Dispatch enter/leave if:
// 1) the mouse grabber is an alien widget
// 2) the button is released on an alien widget
- QWidget *enter = 0;
+ QWidget *enter = nullptr;
if (nativeGuard)
enter = alienGuard ? alienWidget : nativeWidget;
else // The receiver is typically deleted on mouse release with drag'n'drop.
enter = QApplication::widgetAt(event->globalPos());
dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos());
- leaveAfterRelease = 0;
+ leaveAfterRelease = nullptr;
lastMouseReceiver = enter;
} else if (!wasLeaveAfterRelease) {
if (activePopupWidget) {
if (!QWidget::mouseGrabber())
- lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0);
+ lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : nullptr);
} else {
lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos());
}
@@ -2688,7 +2673,7 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
return; // Mouse cursor not inside the widget or any of its children.
if (widget->data->in_destructor && qt_button_down == widget)
- qt_button_down = 0;
+ qt_button_down = nullptr;
// A mouse move is not actually sent, but we utilize the sendMouseEvent() call to send the
// enter/leave events as appropriate
@@ -3040,9 +3025,9 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
key->accept();
else
key->ignore();
- QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0;
+ QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : nullptr;
#if QT_CONFIG(graphicsview)
- QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0;
+ QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : nullptr;
#endif
res = d->notify_helper(receiver, e);
@@ -3104,7 +3089,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
d->toolTipPos = relpos;
d->toolTipGlobalPos = mouse->globalPos();
QStyle *s = d->toolTipWidget->style();
- int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, 0, d->toolTipWidget, 0);
+ int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, d->toolTipWidget, nullptr);
d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive() ? 20 : wakeDelay, this);
}
}
@@ -3434,7 +3419,7 @@ QT_WARNING_POP
&& !isProxyWidget
#endif
)
- QDragManager::self()->setCurrentTarget(0, e->type() == QEvent::Drop);
+ QDragManager::self()->setCurrentTarget(nullptr, e->type() == QEvent::Drop);
}
break;
#endif
@@ -3465,7 +3450,7 @@ QT_WARNING_POP
eventAccepted = touchEvent->isAccepted();
if (p.isNull()) {
// widget was deleted
- widget = 0;
+ widget = nullptr;
} else {
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
}
@@ -3652,7 +3637,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
// send to all application event filters
if (threadRequiresCoreApplication()
- && receiver->d_func()->threadData->thread.loadAcquire() == mainThread()
+ && receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread()
&& sendThroughApplicationEventFilters(receiver, e)) {
filtered = true;
return filtered;
@@ -3690,7 +3675,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
bool QApplicationPrivate::inPopupMode()
{
- return QApplicationPrivate::popupWidgets != 0;
+ return QApplicationPrivate::popupWidgets != nullptr;
}
static void ungrabKeyboardForPopup(QWidget *popup)
@@ -3734,13 +3719,13 @@ void QApplicationPrivate::closePopup(QWidget *popup)
popupWidgets->removeAll(popup);
if (popup == qt_popup_down) {
- qt_button_down = 0;
- qt_popup_down = 0;
+ qt_button_down = nullptr;
+ qt_popup_down = nullptr;
}
if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup
delete QApplicationPrivate::popupWidgets;
- QApplicationPrivate::popupWidgets = 0;
+ QApplicationPrivate::popupWidgets = nullptr;
if (popupGrabOk) {
popupGrabOk = false;
@@ -3778,7 +3763,9 @@ void QApplicationPrivate::closePopup(QWidget *popup)
if (QWidget *fw = aw->focusWidget())
fw->setFocus(Qt::PopupFocusReason);
- if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
+ // can become nullptr due to setFocus() above
+ if (QApplicationPrivate::popupWidgets &&
+ QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard
grabForPopup(aw);
}
@@ -4108,7 +4095,7 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven
{
const bool setFocusOnRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease();
Qt::FocusPolicy focusPolicy = Qt::ClickFocus;
- static QPointer<QWidget> focusedWidgetOnTouchBegin = 0;
+ static QPointer<QWidget> focusedWidgetOnTouchBegin = nullptr;
switch (event->type()) {
case QEvent::MouseButtonPress:
@@ -4215,7 +4202,7 @@ QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device,
{
const QPointF screenPos = touchPoint.screenPos();
int closestTouchPointId = -1;
- QObject *closestTarget = 0;
+ QObject *closestTarget = nullptr;
qreal closestDistance = qreal(0.);
QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(),
ite = activeTouchPoints.constEnd();
@@ -4301,7 +4288,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
if (!target)
continue;
}
- Q_ASSERT(target.data() != 0);
+ Q_ASSERT(target.data() != nullptr);
QWidget *targetWidget = static_cast<QWidget *>(target.data());
@@ -4327,7 +4314,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window,
const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
for (; it != end; ++it) {
const QPointer<QWidget> widget = it.key();
- if (!QApplicationPrivate::tryModalHelper(widget, 0))
+ if (!QApplicationPrivate::tryModalHelper(widget, nullptr))
continue;
QEvent::Type eventType;
@@ -4414,29 +4401,8 @@ void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong times
void QApplicationPrivate::notifyThemeChanged()
{
QGuiApplicationPrivate::notifyThemeChanged();
- clearSystemPalette();
- initSystemPalette();
- qt_init_tooltip_palette();
-}
-
-void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className)
-{
- if (!is_app_running || is_app_closing)
- return;
- QGuiApplicationPrivate::sendApplicationPaletteChange(toAllWidgets, className);
-
- QEvent event(QEvent::ApplicationPaletteChange);
- const QWidgetList widgets = QApplication::allWidgets();
- for (auto widget : widgets) {
- if (toAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className)))
- QCoreApplication::sendEvent(widget, &event);
- }
-
-#if QT_CONFIG(graphicsview)
- for (auto scene : qAsConst(scene_list))
- QCoreApplication::sendEvent(scene, &event);
-#endif // QT_CONFIG(graphicsview)
+ qt_init_tooltip_palette();
}
#if QT_CONFIG(draganddrop)
@@ -4457,7 +4423,7 @@ QGestureManager* QGestureManager::instance(InstanceCreation ic)
{
QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
if (!qAppPriv)
- return 0;
+ return nullptr;
if (!qAppPriv->gestureManager && ic == ForceCreation)
qAppPriv->gestureManager = new QGestureManager(qApp);
return qAppPriv->gestureManager;
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index 27e743a28d..6de72899f1 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -79,7 +79,9 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
#if QT_CONFIG(wheelevent)
Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
#endif
+#if QT_DEPRECATED_SINCE(5, 15)
Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
+#endif
Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
#ifndef QT_NO_STYLE_STYLESHEET
@@ -158,8 +160,10 @@ public:
static void setWheelScrollLines(int);
static int wheelScrollLines();
#endif
+#if QT_DEPRECATED_SINCE(5, 15)
static void setGlobalStrut(const QSize &);
static QSize globalStrut();
+#endif
static void setStartDragTime(int ms);
static int startDragTime();
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 71f695cc18..ab6d85aeb9 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -158,12 +158,12 @@ public:
static QSize app_strut;
static QWidgetList *popupWidgets;
static QStyle *app_style;
- static QPalette *sys_pal;
protected:
void notifyThemeChanged() override;
- void sendApplicationPaletteChange(bool toAllWidgets = false,
- const char *className = nullptr) override;
+
+ QPalette basePalette() const override;
+ void handlePaletteChanged(const char *className = nullptr) override;
#if QT_CONFIG(draganddrop)
void notifyDragStarted(const QDrag *) override;
@@ -184,9 +184,7 @@ public:
static int enabledAnimations; // Combination of QPlatformTheme::UiEffect
static bool widgetCount; // Coupled with -widgetcount switch
- static void setSystemPalette(const QPalette &pal);
- static void setPalette_helper(const QPalette &palette, const char* className);
- static void initializeWidgetPaletteHash();
+ static void initializeWidgetPalettesFromTheme();
static void initializeWidgetFontHash();
static void setSystemFont(const QFont &font);
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index 76d8533271..7b09adfbf0 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -278,7 +278,7 @@ void QBoxLayoutPrivate::setupGeom()
int fixedSpacing = q->spacing();
int previousNonEmptyIndex = -1;
- QStyle *style = 0;
+ QStyle *style = nullptr;
if (fixedSpacing < 0) {
if (QWidget *parentWidget = q->parentWidget())
style = parentWidget->style();
@@ -318,7 +318,7 @@ void QBoxLayoutPrivate::setupGeom()
if (style) {
spacing = style->combinedLayoutSpacing(actual1, actual2,
horz(dir) ? Qt::Horizontal : Qt::Vertical,
- 0, q->parentWidget());
+ nullptr, q->parentWidget());
if (spacing < 0)
spacing = 0;
}
@@ -433,10 +433,10 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item)
{
Q_Q(QBoxLayout);
if (!item)
- return 0;
+ return nullptr;
QBoxLayoutItem *b = list.value(index);
if (!b)
- return 0;
+ return nullptr;
QLayoutItem *r = b->item;
b->item = item;
@@ -551,7 +551,7 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item)
\sa direction()
*/
QBoxLayout::QBoxLayout(Direction dir, QWidget *parent)
- : QLayout(*new QBoxLayoutPrivate, 0, parent)
+ : QLayout(*new QBoxLayoutPrivate, nullptr, parent)
{
Q_D(QBoxLayout);
d->dir = dir;
@@ -684,7 +684,7 @@ int QBoxLayout::minimumHeightForWidth(int w) const
Q_D(const QBoxLayout);
(void) heightForWidth(w);
int top, bottom;
- d->effectiveMargins(0, &top, 0, &bottom);
+ d->effectiveMargins(nullptr, &top, nullptr, &bottom);
return d->hasHfw ? (d->hfwMinHeight + top + bottom) : -1;
}
@@ -713,7 +713,7 @@ int QBoxLayout::count() const
QLayoutItem *QBoxLayout::itemAt(int index) const
{
Q_D(const QBoxLayout);
- return index >= 0 && index < d->list.count() ? d->list.at(index)->item : 0;
+ return index >= 0 && index < d->list.count() ? d->list.at(index)->item : nullptr;
}
/*!
@@ -723,16 +723,16 @@ QLayoutItem *QBoxLayout::takeAt(int index)
{
Q_D(QBoxLayout);
if (index < 0 || index >= d->list.count())
- return 0;
+ return nullptr;
QBoxLayoutItem *b = d->list.takeAt(index);
QLayoutItem *item = b->item;
- b->item = 0;
+ b->item = nullptr;
delete b;
if (QLayout *l = item->layout()) {
// sanity check in case the user passed something weird to QObject::setParent()
if (l->parent() == this)
- l->setParent(0);
+ l->setParent(nullptr);
}
invalidate();
@@ -1173,7 +1173,7 @@ void QBoxLayout::setDirection(Direction direction)
if (box->magic) {
QSpacerItem *sp = box->item->spacerItem();
if (sp) {
- if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) {
+ if (sp->expandingDirections() == Qt::Orientations{} /*No Direction*/) {
//spacing or strut
QSize s = sp->sizeHint();
sp->changeSize(s.height(), s.width(),
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 9e90adec46..9f98af86e3 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -205,7 +205,7 @@ QT_WARNING_POP
}
QDesktopWidget::QDesktopWidget()
- : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
+ : QWidget(*new QDesktopWidgetPrivate, nullptr, Qt::Desktop)
{
Q_D(QDesktopWidget);
setObjectName(QLatin1String("desktop"));
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 6f7527c013..4ffa226d7f 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -199,18 +199,17 @@ public:
ItemMatrix m_matrix;
QList<QFormLayoutItem *> m_things;
- int layoutWidth; // the last width that we called setupVerticalLayoutData on (for vLayouts)
+ int layoutWidth = -1; // the last width that we called setupVerticalLayoutData on (for vLayouts)
- int hfw_width; // the last width we calculated HFW for
- int hfw_height; // what that height was
- int hfw_minheight; // what that minheight was
+ int hfw_width = -1; // the last width we calculated HFW for
+ int hfw_height = -1; // what that height was
- int hfw_sh_height; // the hfw for sh_width
- int hfw_sh_minheight; // the minhfw for sh_width
+ int hfw_sh_height = -1; // the hfw for sh_width
+ int hfw_sh_minheight = -1; // the minhfw for sh_width
- int min_width; // the width that gets turned into minSize (from updateSizes)
- int sh_width; // the width that gets turned into prefSize (from updateSizes)
- int thresh_width; // the width that we start splitting label/field pairs at (from updateSizes)
+ int min_width = -1; // the width that gets turned into minSize (from updateSizes)
+ int sh_width = -1; // the width that gets turned into prefSize (from updateSizes)
+ int thresh_width = QLAYOUTSIZE_MAX; // the width that we start splitting label/field pairs at (from updateSizes)
QSize minSize;
QSize prefSize;
int formMaxWidth;
@@ -222,17 +221,15 @@ public:
QVector<QLayoutStruct> hfwLayouts;
- int hSpacing;
- int vSpacing;
+ int hSpacing = -1;
+ int vSpacing = -1;
QLayoutItem* replaceAt(int index, QLayoutItem*) override;
};
QFormLayoutPrivate::QFormLayoutPrivate()
: fieldGrowthPolicy(DefaultFieldGrowthPolicy),
rowWrapPolicy(DefaultRowWrapPolicy), has_hfw(false), dirty(true), sizesDirty(true),
- expandVertical(0), expandHorizontal(0), labelAlignment(0), formAlignment(0),
- layoutWidth(-1), hfw_width(-1), hfw_sh_height(-1), min_width(-1),
- sh_width(-1), thresh_width(QLAYOUTSIZE_MAX), hSpacing(-1), vSpacing(-1)
+ expandVertical(0), expandHorizontal(0)
{
}
@@ -298,11 +295,11 @@ void QFormLayoutPrivate::updateSizes()
bool expandH = false;
bool expandV = false;
- QFormLayoutItem *prevLbl = 0;
- QFormLayoutItem *prevFld = 0;
+ QFormLayoutItem *prevLbl = nullptr;
+ QFormLayoutItem *prevFld = nullptr;
QWidget *parent = q->parentWidget();
- QStyle *style = parent ? parent->style() : 0;
+ QStyle *style = parent ? parent->style() : nullptr;
int userVSpacing = q->verticalSpacing();
int userHSpacing = wrapAllRows ? 0 : q->horizontalSpacing();
@@ -367,9 +364,9 @@ void QFormLayoutPrivate::updateSizes()
QSizePolicy::ControlTypes fldtoptypes =
QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType);
if (label && lbltop)
- label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);
+ label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent);
if (field && fldtop)
- field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);
+ field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent);
} else {
// Side by side.. we have to also consider the spacings to empty cells, which can strangely be more than
// non empty cells..
@@ -383,21 +380,21 @@ void QFormLayoutPrivate::updateSizes()
// To be compatible to QGridLayout, we have to compare solitary labels & fields with both predecessors
if (label) {
if (!field) {
- int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);
- int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, 0, parent);
+ int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent);
+ int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, nullptr, parent);
label->vSpace = qMax(lblspacing, fldspacing);
} else
- label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent);
+ label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent);
}
if (field) {
// check spacing against both the previous label and field
if (!label) {
- int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, 0, parent);
- int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);
+ int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, nullptr, parent);
+ int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent);
field->vSpace = qMax(lblspacing, fldspacing);
} else
- field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent);
+ field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent);
}
}
}
@@ -406,7 +403,7 @@ void QFormLayoutPrivate::updateSizes()
// hard-coded the left and right control types so that all the rows have the same
// inter-column spacing (otherwise the right column isn't always left aligned)
if (userHSpacing < 0 && !wrapAllRows && (label || !field->fullRow) && field)
- field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, parent);
+ field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, nullptr, parent);
}
// Now update our min/sizehint widths
@@ -481,7 +478,6 @@ void QFormLayoutPrivate::recalcHFW(int w)
} else {
hfw_width = w;
hfw_height = qMin(QLAYOUTSIZE_MAX, h);
- hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh);
}
}
@@ -598,13 +594,13 @@ static inline int spacingHelper(QWidget* parent, QStyle *style, int userVSpacing
QSizePolicy::ControlTypes(item1 ? item1->controlTypes() : QSizePolicy::DefaultType);
int spacing2 = 0;
- spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, 0, parent);
+ spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, nullptr, parent);
// At most of one of item2 and prevItem2 will be nonnull
if (item2)
- spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, 0, parent);
+ spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, nullptr, parent);
else if (prevItem2)
- spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, 0, parent);
+ spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, nullptr, parent);
spacing = qMax(spacing, spacing2);
}
@@ -652,7 +648,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width)
vLayouts.clear();
vLayouts.resize((2 * rr) + 2); // a max, some may be unused
- QStyle *style = 0;
+ QStyle *style = nullptr;
int userVSpacing = q->verticalSpacing();
@@ -680,8 +676,8 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width)
maxLabelWidth = width;
}
- QFormLayoutItem *prevItem1 = 0;
- QFormLayoutItem *prevItem2 = 0;
+ QFormLayoutItem *prevItem1 = nullptr;
+ QFormLayoutItem *prevItem2 = nullptr;
bool prevRowSplit = false;
for (int i = 0; i < rr; ++i) {
@@ -715,13 +711,13 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width)
initLayoutStruct(vLayouts[vidx], label);
if (vidx > 1)
- vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, 0, prevItem1, prevItem2);
+ vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, nullptr, prevItem1, prevItem2);
label->vLayoutIndex = vidx;
label->sideBySide = false;
prevItem1 = label;
- prevItem2 = 0;
+ prevItem2 = nullptr;
if (vLayouts[vidx].stretch > 0)
addTopBottomStretch = false;
@@ -733,13 +729,13 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width)
initLayoutStruct(vLayouts[vidx], field);
if (vidx > 1)
- vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, 0, prevItem1, prevItem2);
+ vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, nullptr, prevItem1, prevItem2);
field->vLayoutIndex = vidx;
field->sideBySide = false;
prevItem1 = field;
- prevItem2 = 0;
+ prevItem2 = nullptr;
if (vLayouts[vidx].stretch > 0)
addTopBottomStretch = false;
@@ -762,7 +758,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width)
if (label->expandingDirections() & Qt::Vertical)
expanding = true;
- label->sideBySide = (field != 0);
+ label->sideBySide = (field != nullptr);
label->vLayoutIndex = vidx;
stretch1 = label->vStretch();
}
@@ -794,7 +790,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width)
prevItem2 = field;
} else {
prevItem1 = field;
- prevItem2 = 0;
+ prevItem2 = nullptr;
}
prevRowSplit = false;
@@ -995,12 +991,12 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem)
{
Q_Q(QFormLayout);
if (!newitem)
- return 0;
+ return nullptr;
const int storageIndex = storageIndexFromLayoutItem(m_matrix, m_things.value(index));
if (Q_UNLIKELY(storageIndex == -1)) {
// ### Qt6 - fix warning too when this class becomes public
qWarning("QFormLayoutPrivate::replaceAt: Invalid index %d", index);
- return 0;
+ return nullptr;
}
int row, col;
@@ -1196,7 +1192,7 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem)
\sa QWidget::setLayout()
*/
QFormLayout::QFormLayout(QWidget *parent)
- : QLayout(*new QFormLayoutPrivate, 0, parent)
+ : QLayout(*new QFormLayoutPrivate, nullptr, parent)
{
}
@@ -1332,7 +1328,7 @@ void QFormLayout::insertRow(int row, const QString &labelText, QWidget *field)
if (field && !d->checkWidget(field))
return;
- QLabel *label = 0;
+ QLabel *label = nullptr;
if (!labelText.isEmpty()) {
label = new QLabel(labelText);
#ifndef QT_NO_SHORTCUT
@@ -1354,7 +1350,7 @@ void QFormLayout::insertRow(int row, const QString &labelText, QLayout *field)
if (field && !d->checkLayout(field))
return;
- insertRow(row, labelText.isEmpty() ? 0 : new QLabel(labelText), field);
+ insertRow(row, labelText.isEmpty() ? nullptr : new QLabel(labelText), field);
}
/*!
@@ -1657,7 +1653,7 @@ QLayoutItem *QFormLayout::itemAt(int index) const
Q_D(const QFormLayout);
if (QFormLayoutItem *formItem = d->m_things.value(index))
return formItem->item;
- return 0;
+ return nullptr;
}
/*!
@@ -1670,7 +1666,7 @@ QLayoutItem *QFormLayout::takeAt(int index)
const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index));
if (Q_UNLIKELY(storageIndex == -1)) {
qWarning("QFormLayout::takeAt: Invalid index %d", index);
- return 0;
+ return nullptr;
}
int row, col;
@@ -1696,7 +1692,7 @@ Qt::Orientations QFormLayout::expandingDirections() const
QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d);
e->updateSizes();
- Qt::Orientations o = 0;
+ Qt::Orientations o;
if (e->expandHorizontal)
o = Qt::Horizontal;
if (e->expandVertical)
@@ -1835,7 +1831,7 @@ QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const
{
Q_D(const QFormLayout);
if (uint(row) >= uint(d->m_matrix.rowCount()))
- return 0;
+ return nullptr;
switch (role) {
case SpanningRole:
if (QFormLayoutItem *item = d->m_matrix(row, 1))
@@ -1848,7 +1844,7 @@ QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const
return item->item;
break;
}
- return 0;
+ return nullptr;
}
/*!
@@ -1932,7 +1928,7 @@ QWidget *QFormLayout::labelForField(QWidget *field) const
if (QFormLayoutItem *label = d->m_matrix(row, LabelRole))
return label->widget();
}
- return 0;
+ return nullptr;
}
/*!
@@ -1951,7 +1947,7 @@ QWidget *QFormLayout::labelForField(QLayout *field) const
if (QFormLayoutItem *label = d->m_matrix(row, LabelRole))
return label->widget();
}
- return 0;
+ return nullptr;
}
/*!
@@ -2326,7 +2322,7 @@ void QFormLayout::resetRowWrapPolicy()
void QFormLayout::resetFormAlignment()
{
Q_D(QFormLayout);
- d->formAlignment = 0;
+ d->formAlignment = { };
}
/*!
@@ -2336,7 +2332,7 @@ void QFormLayout::resetFormAlignment()
void QFormLayout::resetLabelAlignment()
{
Q_D(QFormLayout);
- d->labelAlignment = 0;
+ d->labelAlignment = { };
}
#if 0
diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp
index fc715687c6..84dbed7043 100644
--- a/src/widgets/kernel/qgesture.cpp
+++ b/src/widgets/kernel/qgesture.cpp
@@ -879,7 +879,7 @@ int QTapAndHoldGesturePrivate::Timeout = 700; // in ms
Creates new QGestureEvent containing a list of \a gestures.
*/
QGestureEvent::QGestureEvent(const QList<QGesture *> &gestures)
- : QEvent(QEvent::Gesture), m_gestures(gestures), m_widget(0)
+ : QEvent(QEvent::Gesture), m_gestures(gestures), m_widget(nullptr)
{
}
@@ -907,7 +907,7 @@ QGesture *QGestureEvent::gesture(Qt::GestureType type) const
for (int i = 0; i < m_gestures.size(); ++i)
if (m_gestures.at(i)->gestureType() == type)
return m_gestures.at(i);
- return 0;
+ return nullptr;
}
/*!
diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h
index cbf8d60892..057302bda1 100644
--- a/src/widgets/kernel/qgesture_p.h
+++ b/src/widgets/kernel/qgesture_p.h
@@ -111,8 +111,7 @@ class QPinchGesturePrivate : public QGesturePrivate
public:
QPinchGesturePrivate()
- : totalChangeFlags(nullptr), changeFlags(nullptr),
- totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
+ : totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0),
isNewSequence(true)
{
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index d0c6b882b5..541519245e 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -105,11 +105,10 @@ QGestureManager::QGestureManager(QObject *parent)
QGestureManager::~QGestureManager()
{
qDeleteAll(m_recognizers);
- foreach (QGestureRecognizer *recognizer, m_obsoleteGestures.keys()) {
- qDeleteAll(m_obsoleteGestures.value(recognizer));
- delete recognizer;
+ for (auto it = m_obsoleteGestures.cbegin(), end = m_obsoleteGestures.cend(); it != end; ++it) {
+ qDeleteAll(it.value());
+ delete it.key();
}
- m_obsoleteGestures.clear();
}
Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer)
@@ -188,7 +187,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni
// from the destructor.
if (object->isWidgetType()) {
if (static_cast<QWidget *>(object)->d_func()->data.in_destructor)
- return 0;
+ return nullptr;
} else if (QGesture *g = qobject_cast<QGesture *>(object)) {
return g;
#if QT_CONFIG(graphicsview)
@@ -196,7 +195,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni
Q_ASSERT(qobject_cast<QGraphicsObject *>(object));
QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(object);
if (graphicsObject->QGraphicsItem::d_func()->inDestructor)
- return 0;
+ return nullptr;
#endif
}
@@ -210,7 +209,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni
Q_ASSERT(recognizer);
QGesture *state = recognizer->create(object);
if (!state)
- return 0;
+ return nullptr;
state->setParent(this);
if (state->gestureType() == Qt::CustomGesture) {
// if the recognizer didn't fill in the gesture type, then this
@@ -454,13 +453,13 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original)
// sort them per target widget by cherry picking from almostCanceledGestures and delivering
QSet<QGesture *> almostCanceledGestures = cancelledGestures;
while (!almostCanceledGestures.isEmpty()) {
- QWidget *target = 0;
+ QWidget *target = nullptr;
QSet<QGesture*> gestures;
iter = almostCanceledGestures.begin();
// sort per target widget
while (iter != almostCanceledGestures.end()) {
QWidget *widget = m_gestureTargets.value(*iter);
- if (target == 0)
+ if (target == nullptr)
target = widget;
if (target == widget) {
gestures << *iter;
@@ -508,7 +507,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)
}
}
// find all gesture contexts for the widget tree
- w = w->isWindow() ? 0 : w->parentWidget();
+ w = w->isWindow() ? nullptr : w->parentWidget();
while (w)
{
for (ContextIterator it = w->d_func()->gestureContext.constBegin(),
@@ -587,7 +586,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
// sort gestures by types
foreach (QGesture *gesture, gestures) {
- QWidget *receiver = m_gestureTargets.value(gesture, 0);
+ QWidget *receiver = m_gestureTargets.value(gesture, nullptr);
Q_ASSERT(receiver);
if (receiver)
gestureByTypes[gesture->gestureType()].insert(receiver, gesture);
@@ -611,7 +610,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
}
}
if (w->isWindow()) {
- w = 0;
+ w = nullptr;
break;
}
w = w->parentWidget();
@@ -637,7 +636,7 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures,
for (QSet<QGesture *>::const_iterator it = gestures.begin(),
e = gestures.end(); it != e; ++it) {
QGesture *gesture = *it;
- QWidget *target = m_gestureTargets.value(gesture, 0);
+ QWidget *target = m_gestureTargets.value(gesture, nullptr);
if (!target) {
// the gesture has just started and doesn't have a target yet.
Q_ASSERT(gesture->state() == Qt::GestureStarted);
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 4f2b505e32..b4ac263c2b 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -84,7 +84,7 @@ public:
Qt::Alignment alignment() const { return item_->alignment(); }
QLayoutItem *item() { return item_; }
void setItem(QLayoutItem *newitem) { item_ = newitem; }
- QLayoutItem *takeItem() { QLayoutItem *i = item_; item_ = 0; return i; }
+ QLayoutItem *takeItem() { QLayoutItem *i = item_; item_ = nullptr; return i; }
int hStretch() { return item_->widget() ?
item_->widget()->sizePolicy().horizontalStretch() : 0; }
@@ -152,7 +152,7 @@ public:
if (index < things.count())
return things.at(index)->item();
else
- return 0;
+ return nullptr;
}
inline QLayoutItem *takeAt(int index) {
Q_Q(QGridLayout);
@@ -162,19 +162,19 @@ public:
if (QLayout *l = item->layout()) {
// sanity check in case the user passed something weird to QObject::setParent()
if (l->parent() == q)
- l->setParent(0);
+ l->setParent(nullptr);
}
delete b;
return item;
}
}
- return 0;
+ return nullptr;
}
QLayoutItem* replaceAt(int index, QLayoutItem *newitem) override
{
if (!newitem)
- return 0;
- QLayoutItem *item = 0;
+ return nullptr;
+ QLayoutItem *item = nullptr;
QGridBox *b = things.value(index);
if (b) {
item = b->takeItem();
@@ -342,7 +342,7 @@ QGridLayoutPrivate::QGridLayoutPrivate()
setDirty();
rr = cc = 0;
nextR = nextC = 0;
- hfwData = 0;
+ hfwData = nullptr;
hReversed = false;
vReversed = false;
horizontalSpacing = -1;
@@ -429,7 +429,7 @@ int QGridLayoutPrivate::minimumHeightForWidth(int w, int hSpacing, int vSpacing)
if (!has_hfw)
return -1;
int top, bottom;
- effectiveMargins(0, &top, 0, &bottom);
+ effectiveMargins(nullptr, &top, nullptr, &bottom);
return hfw_minheight + top + bottom;
}
@@ -521,7 +521,7 @@ void QGridLayoutPrivate::setSize(int r, int c)
if (hfwData && (int)hfwData->size() < r) {
delete hfwData;
- hfwData = 0;
+ hfwData = nullptr;
hfw_width = -1;
}
rr = r;
@@ -710,14 +710,14 @@ void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain,
qSwap(numRows, numColumns);
}
- QStyle *style = 0;
+ QStyle *style = nullptr;
if (fixedSpacing < 0) {
if (QWidget *parentWidget = q->parentWidget())
style = parentWidget->style();
}
for (int c = 0; c < numColumns; ++c) {
- QGridBox *previousBox = 0;
+ QGridBox *previousBox = nullptr;
int previousRow = -1; // previous *non-empty* row
for (int r = 0; r < numRows; ++r) {
@@ -741,7 +741,7 @@ void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain,
if (style)
spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2,
- orientation, 0, q->parentWidget());
+ orientation, nullptr, q->parentWidget());
} else {
if (orientation == Qt::Vertical) {
QGridBox *sibling = vReversed ? previousBox : box;
@@ -1075,7 +1075,7 @@ QRect QGridLayoutPrivate::cellRect(int row, int col) const
new items are inserted.
*/
QGridLayout::QGridLayout(QWidget *parent)
- : QLayout(*new QGridLayoutPrivate, 0, parent)
+ : QLayout(*new QGridLayoutPrivate, nullptr, parent)
{
Q_D(QGridLayout);
d->expand(1, 1);
@@ -1089,7 +1089,7 @@ QGridLayout::QGridLayout(QWidget *parent)
will not be performed before this is inserted into another layout.
*/
QGridLayout::QGridLayout()
- : QLayout(*new QGridLayoutPrivate, 0, 0)
+ : QLayout(*new QGridLayoutPrivate, nullptr, nullptr)
{
Q_D(QGridLayout);
d->expand(1, 1);
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 3ce81a390b..d4ff9083f1 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -130,7 +130,7 @@ QLayout::QLayout(QWidget *parent)
management will work.
*/
QLayout::QLayout()
- : QObject(*new QLayoutPrivate, 0)
+ : QObject(*new QLayoutPrivate, nullptr)
{
}
@@ -149,14 +149,14 @@ QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w)
" already has a layout",
qUtf16Printable(QObject::objectName()), w->metaObject()->className(),
qUtf16Printable(w->objectName()));
- setParent(0);
+ setParent(nullptr);
} else {
d->topLevel = true;
w->d_func()->layout = this;
QT_TRY {
invalidate();
} QT_CATCH(...) {
- w->d_func()->layout = 0;
+ w->d_func()->layout = nullptr;
QT_RETHROW;
}
}
@@ -166,7 +166,7 @@ QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w)
QLayoutPrivate::QLayoutPrivate()
: QObjectPrivate(), insideSpacing(-1), userLeftMargin(-1), userTopMargin(-1), userRightMargin(-1),
userBottomMargin(-1), topLevel(false), enabled(true), activated(true), autoNewChild(false),
- constraint(QLayout::SetDefaultConstraint), menubar(0)
+ constraint(QLayout::SetDefaultConstraint), menubar(nullptr)
{
}
@@ -181,7 +181,7 @@ void QLayoutPrivate::getMargin(int *result, int userMargin, QStyle::PixelMetric
} else if (!topLevel) {
*result = 0;
} else if (QWidget *pw = q->parentWidget()) {
- *result = pw->style()->pixelMetric(pm, 0, pw);
+ *result = pw->style()->pixelMetric(pm, nullptr, pw);
} else {
*result = 0;
}
@@ -189,8 +189,8 @@ void QLayoutPrivate::getMargin(int *result, int userMargin, QStyle::PixelMetric
// Static item factory functions that allow for hooking things in Designer
-QLayoutPrivate::QWidgetItemFactoryMethod QLayoutPrivate::widgetItemFactoryMethod = 0;
-QLayoutPrivate::QSpacerItemFactoryMethod QLayoutPrivate::spacerItemFactoryMethod = 0;
+QLayoutPrivate::QWidgetItemFactoryMethod QLayoutPrivate::widgetItemFactoryMethod = nullptr;
+QLayoutPrivate::QSpacerItemFactoryMethod QLayoutPrivate::spacerItemFactoryMethod = nullptr;
QWidgetItem *QLayoutPrivate::createWidgetItem(const QLayout *layout, QWidget *widget)
{
@@ -583,18 +583,18 @@ static bool removeWidgetRecursively(QLayoutItem *li, QObject *w)
}
-void QLayoutPrivate::doResize(const QSize &r)
+void QLayoutPrivate::doResize()
{
Q_Q(QLayout);
- int mbh = menuBarHeightForWidth(menubar, r.width());
QWidget *mw = q->parentWidget();
QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect();
+ const int mbh = menuBarHeightForWidth(menubar, rect.width());
const int mbTop = rect.top();
rect.setTop(mbTop + mbh);
q->setGeometry(rect);
#if QT_CONFIG(menubar)
if (menubar)
- menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
+ menubar->setGeometry(rect.left(), mbTop, rect.width(), mbh);
#endif
}
@@ -613,12 +613,10 @@ void QLayout::widgetEvent(QEvent *e)
switch (e->type()) {
case QEvent::Resize:
- if (d->activated) {
- QResizeEvent *r = (QResizeEvent *)e;
- d->doResize(r->size());
- } else {
+ if (d->activated)
+ d->doResize();
+ else
activate();
- }
break;
case QEvent::ChildRemoved:
{
@@ -626,7 +624,7 @@ void QLayout::widgetEvent(QEvent *e)
if (c->child()->isWidgetType()) {
#if QT_CONFIG(menubar)
if (c->child() == d->menubar)
- d->menubar = 0;
+ d->menubar = nullptr;
#endif
removeWidgetRecursively(this, c->child());
}
@@ -766,7 +764,7 @@ QLayout::~QLayout()
{
Q_D(QLayout);
if (d->topLevel && parent() && parent()->isWidgetType() && parentWidget()->layout() == this)
- parentWidget()->d_func()->layout = 0;
+ parentWidget()->d_func()->layout = nullptr;
else if (QLayout *parentLayout = qobject_cast<QLayout *>(parent()))
parentLayout->removeItem(this);
}
@@ -921,7 +919,7 @@ void QLayout::addChildWidget(QWidget *w)
qWarning("QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent",
w->metaObject()->className(), qUtf16Printable(w->objectName()));
#endif
- pw = 0;
+ pw = nullptr;
}
bool needShow = mw && mw->isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide));
if (!pw && mw)
@@ -1116,7 +1114,7 @@ bool QLayout::activate()
break;
}
- d->doResize(mw->size());
+ d->doResize();
if (md->extra) {
md->extra->explicitMinSize = explMin;
@@ -1155,12 +1153,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
{
Q_D(QLayout);
if (!from || !to)
- return 0;
+ return nullptr;
if (from == to) // Do not return a QLayoutItem for \a from, since ownership still
return nullptr; // belongs to the layout (since nothing was changed)
int index = -1;
- QLayoutItem *item = 0;
+ QLayoutItem *item = nullptr;
for (int u = 0; u < count(); ++u) {
item = itemAt(u);
if (!item)
@@ -1178,7 +1176,7 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
}
}
if (index == -1)
- return 0;
+ return nullptr;
addChildWidget(to);
QLayoutItem *newitem = new QWidgetItem(to);
@@ -1339,7 +1337,7 @@ QRect QLayout::alignmentRect(const QRect &r) const
returned by QLayoutItems that have an alignment.
*/
QLayout *that = const_cast<QLayout *>(this);
- that->setAlignment(0);
+ that->setAlignment({ });
QSize ms = that->maximumSize();
that->setAlignment(a);
diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h
index 8e1d773355..2b19af48be 100644
--- a/src/widgets/kernel/qlayout_p.h
+++ b/src/widgets/kernel/qlayout_p.h
@@ -73,7 +73,7 @@ public:
QLayoutPrivate();
void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const;
- void doResize(const QSize &);
+ void doResize();
void reparentChildWidgets(QWidget *mw);
bool checkWidget(QWidget *widget) const;
bool checkLayout(QLayout *otherLayout) const;
diff --git a/src/widgets/kernel/qlayoutengine.cpp b/src/widgets/kernel/qlayoutengine.cpp
index 19a47075a6..83bbd69b55 100644
--- a/src/widgets/kernel/qlayoutengine.cpp
+++ b/src/widgets/kernel/qlayoutengine.cpp
@@ -376,7 +376,11 @@ Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSize
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i)
{
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWidget *w = const_cast<QWidgetItem *>(i)->widget();
+#else
+ QWidget *w = i->widget();
+#endif
return qSmartMinSize(w->sizeHint(), w->minimumSizeHint(),
w->minimumSize(), w->maximumSize(),
w->sizePolicy());
@@ -414,8 +418,11 @@ Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint,
Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align)
{
- QWidget *w = const_cast<QWidgetItem*>(i)->widget();
-
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QWidget *w = const_cast<QWidgetItem *>(i)->widget();
+#else
+ QWidget *w = i->widget();
+#endif
return qSmartMaxSize(w->sizeHint().expandedTo(w->minimumSizeHint()), w->minimumSize(), w->maximumSize(),
w->sizePolicy(), align);
}
@@ -433,7 +440,7 @@ Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm
return -1;
} else if (parent->isWidgetType()) {
QWidget *pw = static_cast<QWidget *>(parent);
- return pw->style()->pixelMetric(pm, 0, pw);
+ return pw->style()->pixelMetric(pm, nullptr, pw);
} else {
return static_cast<QLayout *>(parent)->spacing();
}
diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h
index 948c2424e6..2999bae646 100644
--- a/src/widgets/kernel/qlayoutengine_p.h
+++ b/src/widgets/kernel/qlayoutengine_p.h
@@ -105,9 +105,9 @@ Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i);
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidget *w);
Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint,
const QSize &minSize, const QSize &maxSize,
- const QSizePolicy &sizePolicy, Qt::Alignment align = nullptr);
-Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = nullptr);
-Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = nullptr);
+ const QSizePolicy &sizePolicy, Qt::Alignment align = { });
+Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = { });
+Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = { });
Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm);
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 0aab0bb06d..af5750771d 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -291,14 +291,12 @@ void QSpacerItem::changeSize(int w, int h, QSizePolicy::Policy hPolicy,
/*!
Destructor.
*/
-QWidgetItem::~QWidgetItem() {}
+QWidgetItem::~QWidgetItem() = default;
/*!
Destroys the QLayoutItem.
*/
-QLayoutItem::~QLayoutItem()
-{
-}
+QLayoutItem::~QLayoutItem() = default;
/*!
Invalidates any cached information in this layout item.
@@ -362,7 +360,11 @@ QSpacerItem * QSpacerItem::spacerItem()
\sa layout(), spacerItem()
*/
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWidget *QLayoutItem::widget()
+#else
+QWidget *QLayoutItem::widget() const
+#endif
{
return nullptr;
}
@@ -370,7 +372,11 @@ QWidget *QLayoutItem::widget()
/*!
Returns the widget managed by this item.
*/
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWidget *QWidgetItem::widget()
+#else
+QWidget *QWidgetItem::widget() const
+#endif
{
return wid;
}
@@ -591,7 +597,7 @@ Qt::Orientations QSpacerItem::expandingDirections() const
Qt::Orientations QWidgetItem::expandingDirections() const
{
if (isEmpty())
- return Qt::Orientations(0);
+ return {};
Qt::Orientations e = wid->sizePolicy().expandingDirections();
/*
@@ -772,7 +778,7 @@ QWidgetItemV2::QWidgetItemV2(QWidget *widget)
q_cachedMaximumSize(Dirty, Dirty),
q_firstCachedHfw(0),
q_hfwCacheSize(0),
- d(0)
+ d(nullptr)
{
QWidgetPrivate *wd = wid->d_func();
if (!wd->widgetItem)
@@ -784,7 +790,7 @@ QWidgetItemV2::~QWidgetItemV2()
if (wid) {
auto *wd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(wid));
if (wd->widgetItem == this)
- wd->widgetItem = 0;
+ wd->widgetItem = nullptr;
}
}
diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h
index 059ff2d470..8553e20adc 100644
--- a/src/widgets/kernel/qlayoutitem.h
+++ b/src/widgets/kernel/qlayoutitem.h
@@ -74,7 +74,11 @@ public:
virtual int minimumHeightForWidth(int) const;
virtual void invalidate();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
virtual QWidget *widget();
+#else
+ virtual QWidget *widget() const;
+#endif
virtual QLayout *layout();
virtual QSpacerItem *spacerItem();
@@ -133,7 +137,11 @@ public:
bool isEmpty() const override;
void setGeometry(const QRect&) override;
QRect geometry() const override;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWidget *widget() override;
+#else
+ QWidget *widget() const override;
+#endif
bool hasHeightForWidth() const override;
int heightForWidth(int) const override;
diff --git a/src/widgets/kernel/qmacgesturerecognizer.cpp b/src/widgets/kernel/qmacgesturerecognizer.cpp
index d39b93e320..aac115a2cf 100644
--- a/src/widgets/kernel/qmacgesturerecognizer.cpp
+++ b/src/widgets/kernel/qmacgesturerecognizer.cpp
@@ -149,8 +149,8 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e
void QMacPinchGestureRecognizer::reset(QGesture *gesture)
{
QPinchGesture *g = static_cast<QPinchGesture *>(gesture);
- g->setChangeFlags(0);
- g->setTotalChangeFlags(0);
+ g->setChangeFlags({});
+ g->setTotalChangeFlags({});
g->setScaleFactor(1.0f);
g->setTotalScaleFactor(1.0f);
g->setLastScaleFactor(1.0f);
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index d244162ba3..9b4955320b 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -555,16 +555,16 @@ class QOpenGLWidgetPrivate : public QWidgetPrivate
Q_DECLARE_PUBLIC(QOpenGLWidget)
public:
QOpenGLWidgetPrivate()
- : context(0),
- fbo(0),
- resolvedFbo(0),
- surface(0),
+ : context(nullptr),
+ fbo(nullptr),
+ resolvedFbo(nullptr),
+ surface(nullptr),
initialized(false),
fakeHidden(false),
inBackingStorePaint(false),
hasBeenComposed(false),
flushPending(false),
- paintDevice(0),
+ paintDevice(nullptr),
updateBehavior(QOpenGLWidget::NoPartialUpdate),
requestedSamples(0),
inPaintGL(false),
@@ -704,11 +704,11 @@ void QOpenGLWidgetPrivate::reset()
q->makeCurrent();
delete paintDevice;
- paintDevice = 0;
+ paintDevice = nullptr;
delete fbo;
- fbo = 0;
+ fbo = nullptr;
delete resolvedFbo;
- resolvedFbo = 0;
+ resolvedFbo = nullptr;
if (initialized)
q->doneCurrent();
@@ -717,9 +717,9 @@ void QOpenGLWidgetPrivate::reset()
// the context's aboutToBeDestroyed() may still call makeCurrent()
// to perform some cleanup.
delete context;
- context = 0;
+ context = nullptr;
delete surface;
- surface = 0;
+ surface = nullptr;
initialized = fakeHidden = inBackingStorePaint = false;
}
@@ -732,9 +732,9 @@ void QOpenGLWidgetPrivate::recreateFbo()
context->makeCurrent(surface);
delete fbo;
- fbo = 0;
+ fbo = nullptr;
delete resolvedFbo;
- resolvedFbo = 0;
+ resolvedFbo = nullptr;
int samples = requestedSamples;
QOpenGLExtensions *extfuncs = static_cast<QOpenGLExtensions *>(context->functions());
@@ -1421,7 +1421,7 @@ QPaintEngine *QOpenGLWidget::paintEngine() const
return QWidget::paintEngine();
if (!d->initialized)
- return 0;
+ return nullptr;
return d->paintDevice->paintEngine();
}
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index eec65c8625..039699a004 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -419,6 +419,76 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
\sa activated()
*/
+/*!
+ \fn template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor.
+*/
+/*!
+ \fn template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context, Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor.
+
+ The \a functor can be a pointer to a member function of the \a context object.
+
+ If the \a context object is destroyed, the \a functor will not be called.
+*/
+/*!
+ \fn template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor and
+ \l{QShortcut::activatedAmbiguously()}{activatedAmbiguously()}
+ signal to the \a FunctorAmbiguous.
+
+ The \a functor and \a FunctorAmbiguous can be a pointer to a member
+ function of the \a context object.
+
+ If the \a context object is destroyed, the \a functor and
+ \a FunctorAmbiguous will not be called.
+*/
+/*!
+ \fn template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ const QObject *context2, FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ \since 5.15
+ \overload
+
+ This is a QShortcut convenience constructor which connects the shortcut's
+ \l{QShortcut::activated()}{activated()} signal to the \a functor and
+ \l{QShortcut::activatedAmbiguously()}{activatedAmbiguously()}
+ signal to the \a FunctorAmbiguous.
+
+ The \a functor can be a pointer to a member function of the
+ \a context1 object.
+ The \a FunctorAmbiguous can be a pointer to a member function of the
+ \a context2 object.
+
+ If the \a context1 object is destroyed, the \a functor will not be called.
+ If the \a context2 object is destroyed, the \a FunctorAmbiguous
+ will not be called.
+*/
+
/*
\internal
Private data accessed through d-pointer.
@@ -475,17 +545,17 @@ QShortcut::QShortcut(QWidget *parent)
match the \a key sequence. Depending on the ambiguity of the
event, the shortcut will call the \a member function, or the \a
ambiguousMember function, if the key press was in the shortcut's
- \a context.
+ \a shortcutContext.
*/
QShortcut::QShortcut(const QKeySequence &key, QWidget *parent,
const char *member, const char *ambiguousMember,
- Qt::ShortcutContext context)
+ Qt::ShortcutContext shortcutContext)
: QShortcut(parent)
{
QAPP_CHECK("QShortcut");
Q_D(QShortcut);
- d->sc_context = context;
+ d->sc_context = shortcutContext;
d->sc_sequence = key;
d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
if (member)
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h
index 6dcf4971b2..4f9c5ba0f7 100644
--- a/src/widgets/kernel/qshortcut.h
+++ b/src/widgets/kernel/qshortcut.h
@@ -61,9 +61,65 @@ class Q_WIDGETS_EXPORT QShortcut : public QObject
Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext)
public:
explicit QShortcut(QWidget *parent);
- QShortcut(const QKeySequence& key, QWidget *parent,
+ QShortcut(const QKeySequence &key, QWidget *parent,
const char *member = nullptr, const char *ambiguousMember = nullptr,
- Qt::ShortcutContext context = Qt::WindowShortcut);
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+#ifdef Q_CLANG_QDOC
+ template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ template<typename Functor>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context, Functor functor,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ template<typename Functor, typename FunctorAmbiguous>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const QObject *context1, Functor functor,
+ const QObject *context2, FunctorAmbiguous functorAmbiguous,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+#else
+ template<typename Func1>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ Func1 slot1,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, std::move(slot1));
+ }
+ template<class Obj1, typename Func1>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const Obj1 *object1, Func1 slot1,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, object1, std::move(slot1));
+ }
+ template<class Obj1, typename Func1, typename Func2>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const Obj1 *object1, Func1 slot1, Func2 slot2,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, object1, std::move(slot1));
+ connect(this, &QShortcut::activatedAmbiguously, object1, std::move(slot2));
+ }
+ template<class Obj1, typename Func1, class Obj2, typename Func2>
+ QShortcut(const QKeySequence &key, QWidget *parent,
+ const Obj1 *object1, Func1 slot1,
+ const Obj2 *object2, Func2 slot2,
+ Qt::ShortcutContext context = Qt::WindowShortcut)
+ : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
+ {
+ connect(this, &QShortcut::activated, object1, std::move(slot1));
+ connect(this, &QShortcut::activatedAmbiguously, object2, std::move(slot2));
+ }
+#endif
~QShortcut();
void setKey(const QKeySequence& key);
diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp
index 54bf8fe0dc..c4372a9fbc 100644
--- a/src/widgets/kernel/qsizepolicy.cpp
+++ b/src/widgets/kernel/qsizepolicy.cpp
@@ -439,7 +439,7 @@ void QSizePolicy::setControlType(ControlType type) noexcept
*/
QSizePolicy::operator QVariant() const
{
- return QVariant(QVariant::SizePolicy, this);
+ return QVariant(QMetaType::QSizePolicy, this);
}
#ifndef QT_NO_DATASTREAM
diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp
index 0412dc188d..f87fe96cc0 100644
--- a/src/widgets/kernel/qstackedlayout.cpp
+++ b/src/widgets/kernel/qstackedlayout.cpp
@@ -61,11 +61,11 @@ QLayoutItem* QStackedLayoutPrivate::replaceAt(int idx, QLayoutItem *newitem)
{
Q_Q(QStackedLayout);
if (idx < 0 || idx >= list.size() || !newitem)
- return 0;
+ return nullptr;
QWidget *wdg = newitem->widget();
if (Q_UNLIKELY(!wdg)) {
qWarning("QStackedLayout::replaceAt: Only widgets can be added");
- return 0;
+ return nullptr;
}
QLayoutItem *orgitem = list.at(idx);
list.replace(idx, newitem);
@@ -154,7 +154,7 @@ QLayoutItem* QStackedLayoutPrivate::replaceAt(int idx, QLayoutItem *newitem)
\sa addWidget(), insertWidget()
*/
QStackedLayout::QStackedLayout()
- : QLayout(*new QStackedLayoutPrivate, 0, 0)
+ : QLayout(*new QStackedLayoutPrivate, nullptr, nullptr)
{
}
@@ -165,7 +165,7 @@ QStackedLayout::QStackedLayout()
manage the geometry of its children.
*/
QStackedLayout::QStackedLayout(QWidget *parent)
- : QLayout(*new QStackedLayoutPrivate, 0, parent)
+ : QLayout(*new QStackedLayoutPrivate, nullptr, parent)
{
}
@@ -174,7 +174,7 @@ QStackedLayout::QStackedLayout(QWidget *parent)
the given \a parentLayout.
*/
QStackedLayout::QStackedLayout(QLayout *parentLayout)
- : QLayout(*new QStackedLayoutPrivate, parentLayout, 0)
+ : QLayout(*new QStackedLayoutPrivate, parentLayout, nullptr)
{
}
@@ -264,7 +264,7 @@ QLayoutItem *QStackedLayout::takeAt(int index)
{
Q_D(QStackedLayout);
if (index <0 || index >= d->list.size())
- return 0;
+ return nullptr;
QLayoutItem *item = d->list.takeAt(index);
if (index == d->index) {
d->index = -1;
@@ -307,7 +307,7 @@ void QStackedLayout::setCurrentIndex(int index)
parent->setUpdatesEnabled(false);
}
- QPointer<QWidget> fw = parent ? parent->window()->focusWidget() : 0;
+ QPointer<QWidget> fw = parent ? parent->window()->focusWidget() : nullptr;
const bool focusWasOnOldPage = fw && (prev && prev->isAncestorOf(fw));
if (prev) {
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index 8a95b12d89..a5c204d59d 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -183,7 +183,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
}
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- d->changeFlags = 0;
+ d->changeFlags = { };
if (ev->touchPoints().size() == 2) {
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
@@ -256,7 +256,7 @@ void QPinchGestureRecognizer::reset(QGesture *state)
QPinchGesture *pinch = static_cast<QPinchGesture *>(state);
QPinchGesturePrivate *d = pinch->d_func();
- d->totalChangeFlags = d->changeFlags = 0;
+ d->totalChangeFlags = d->changeFlags = { };
d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF();
d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1;
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 1ec3612457..33dd3e59b6 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -154,7 +154,7 @@ public slots:
*/
void styleSheetParentDestroyed() {
setProperty("_q_stylesheet_parent", QVariant());
- styleSheetParent = 0;
+ styleSheetParent = nullptr;
}
private:
@@ -166,11 +166,11 @@ private:
QRect rect;
};
-QTipLabel *QTipLabel::instance = 0;
+QTipLabel *QTipLabel::instance = nullptr;
QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime)
#ifndef QT_NO_STYLE_STYLESHEET
- : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), styleSheetParent(0), widget(0)
+ : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), styleSheetParent(nullptr), widget(nullptr)
#else
: QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), widget(0)
#endif
@@ -181,12 +181,12 @@ QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int mse
setBackgroundRole(QPalette::ToolTipBase);
setPalette(QToolTip::palette());
ensurePolished();
- setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this));
+ setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this));
setFrameStyle(QFrame::NoFrame);
setAlignment(Qt::AlignLeft);
setIndent(1);
qApp->installEventFilter(this);
- setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
+ setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, nullptr, this) / 255.0);
setMouseTracking(true);
fadingOut = false;
reuseTip(text, msecDisplayTime, pos);
@@ -207,7 +207,7 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint
if (styleSheetParent){
disconnect(styleSheetParent, SIGNAL(destroyed()),
QTipLabel::instance, SLOT(styleSheetParentDestroyed()));
- styleSheetParent = 0;
+ styleSheetParent = nullptr;
}
#endif
@@ -281,7 +281,7 @@ void QTipLabel::mouseMoveEvent(QMouseEvent *e)
QTipLabel::~QTipLabel()
{
- instance = 0;
+ instance = nullptr;
}
void QTipLabel::hideTip()
@@ -560,7 +560,7 @@ void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w)
*/
bool QToolTip::isVisible()
{
- return (QTipLabel::instance != 0 && QTipLabel::instance->isVisible());
+ return (QTipLabel::instance != nullptr && QTipLabel::instance->isVisible());
}
/*!
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp
index 228ca4d38a..8a632a395a 100644
--- a/src/widgets/kernel/qwhatsthis.cpp
+++ b/src/widgets/kernel/qwhatsthis.cpp
@@ -163,7 +163,7 @@ private:
QPixmap background;
};
-QWhatsThat *QWhatsThat::instance = 0;
+QWhatsThat *QWhatsThat::instance = nullptr;
// shadowWidth not const, for XP drop-shadow-fu turns it to 0
static int shadowWidth = 6; // also used as '5' and '6' and even '8' below
@@ -193,7 +193,7 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor
setCursor(Qt::ArrowCursor);
#endif
QRect r;
- doc = 0;
+ doc = nullptr;
ensurePolished(); // Ensures style sheet font before size calc
if (Qt::mightBeRichText(text)) {
doc = new QTextDocument();
@@ -229,7 +229,7 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor
QWhatsThat::~QWhatsThat()
{
- instance = 0;
+ instance = nullptr;
if (doc)
delete doc;
}
@@ -383,7 +383,7 @@ void QWhatsThisPrivate::notifyToplevels(QEvent *e)
QCoreApplication::sendEvent(w, e);
}
-QWhatsThisPrivate *QWhatsThisPrivate::instance = 0;
+QWhatsThisPrivate *QWhatsThisPrivate::instance = nullptr;
QWhatsThisPrivate::QWhatsThisPrivate()
: leaveOnMouseRelease(false)
@@ -423,7 +423,7 @@ QWhatsThisPrivate::~QWhatsThisPrivate()
QAccessibleEvent event(this, QAccessible::ContextHelpEnd);
QAccessible::updateAccessibility(&event);
#endif
- instance = 0;
+ instance = nullptr;
}
bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e)
@@ -497,7 +497,7 @@ class QWhatsThisAction: public QAction
Q_OBJECT
public:
- explicit QWhatsThisAction(QObject* parent = 0);
+ explicit QWhatsThisAction(QObject* parent = nullptr);
private slots:
void actionTriggered();
@@ -553,7 +553,7 @@ void QWhatsThis::enterWhatsThisMode()
*/
bool QWhatsThis::inWhatsThisMode()
{
- return (QWhatsThisPrivate::instance != 0);
+ return (QWhatsThisPrivate::instance != nullptr);
}
/*!
@@ -577,7 +577,7 @@ void QWhatsThisPrivate::say(QWidget * widget, const QString &text, int x, int y)
if (text.size() == 0)
return;
// make a fresh widget, and set it up
- QWhatsThat *whatsThat = new QWhatsThat(text, 0, widget);
+ QWhatsThat *whatsThat = new QWhatsThat(text, nullptr, widget);
// okay, now to find a suitable location
int scr = (widget ?
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 8ec7f7e072..f45f1bdc31 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -132,16 +132,16 @@ extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidgetPrivate::QWidgetPrivate(int version)
: QObjectPrivate(version)
- , focus_next(0)
- , focus_prev(0)
- , focus_child(0)
- , layout(0)
- , needsFlush(0)
- , redirectDev(0)
- , widgetItem(0)
- , extraPaintEngine(0)
- , polished(0)
- , graphicsEffect(0)
+ , focus_next(nullptr)
+ , focus_prev(nullptr)
+ , focus_child(nullptr)
+ , layout(nullptr)
+ , needsFlush(nullptr)
+ , redirectDev(nullptr)
+ , widgetItem(nullptr)
+ , extraPaintEngine(nullptr)
+ , polished(nullptr)
+ , graphicsEffect(nullptr)
#if !defined(QT_NO_IM)
, imHints(Qt::ImhNone)
#endif
@@ -159,7 +159,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
, topLayoutItemMargin(0)
, rightLayoutItemMargin(0)
, bottomLayoutItemMargin(0)
- , hd(0)
+ , hd(nullptr)
, size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred)
, fg_role(QPalette::NoRole)
, bg_role(QPalette::NoRole)
@@ -214,7 +214,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
QWidgetPrivate::~QWidgetPrivate()
{
if (widgetItem)
- widgetItem->wid = 0;
+ widgetItem->wid = nullptr;
if (extra)
deleteExtra();
@@ -396,7 +396,7 @@ void QWidget::setAutoFillBackground(bool enabled)
If it is \nullptr (the default), the new widget will be a window.
If not, it will be a child of \e parent, and be constrained by
\e parent's geometry (unless you specify Qt::Window as window flag).
- \li \c{Qt::WindowFlags f = 0} (where available) sets the window flags;
+ \li \c{Qt::WindowFlags f = { }} (where available) sets the window flags;
the default is suitable for almost all widgets, but to get, for
example, a window without a window system frame, you must use
special flags.
@@ -819,8 +819,8 @@ void QWidget::setAutoFillBackground(bool enabled)
*/
-QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid
-QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid
+QWidgetMapper *QWidgetPrivate::mapper = nullptr; // widget with wid
+QWidgetSet *QWidgetPrivate::allWidgets = nullptr; // widgets with no wid
/*****************************************************************************
@@ -890,7 +890,7 @@ struct QWidgetExceptionCleaner
\sa windowFlags
*/
QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
- : QObject(*new QWidgetPrivate, 0), QPaintDevice()
+ : QObject(*new QWidgetPrivate, nullptr), QPaintDevice()
{
QT_TRY {
d_func()->init(parent, f);
@@ -904,7 +904,7 @@ QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
/*! \internal
*/
QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f)
- : QObject(dd, 0), QPaintDevice()
+ : QObject(dd, nullptr), QPaintDevice()
{
Q_D(QWidget);
QT_TRY {
@@ -996,7 +996,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(parentWidget);
targetScreen = sw ? sw->screenNumber() : 0;
- parentWidget = 0;
+ parentWidget = nullptr;
}
q->data = &data;
@@ -1072,7 +1072,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
QCoreApplication::sendEvent(q, &e);
QCoreApplication::postEvent(q, new QEvent(QEvent::PolishRequest));
- extraPaintEngine = 0;
+ extraPaintEngine = nullptr;
}
void QWidgetPrivate::createRecursively()
@@ -1307,9 +1307,9 @@ void QWidgetPrivate::create()
if (nativeParent->windowHandle()) {
if (flags & Qt::Window) {
win->setTransientParent(nativeParent->window()->windowHandle());
- win->setParent(0);
+ win->setParent(nullptr);
} else {
- win->setTransientParent(0);
+ win->setTransientParent(nullptr);
win->setParent(nativeParent->windowHandle());
}
}
@@ -1442,7 +1442,7 @@ QWidget::~QWidget()
// delete layout while we still are a valid widget
delete d->layout;
- d->layout = 0;
+ d->layout = nullptr;
// Remove myself from focus list
Q_ASSERT(d->focus_next->d_func()->focus_prev == this);
@@ -1451,7 +1451,7 @@ QWidget::~QWidget()
if (d->focus_next != this) {
d->focus_next->d_func()->focus_prev = d->focus_prev;
d->focus_prev->d_func()->focus_next = d->focus_next;
- d->focus_next = d->focus_prev = 0;
+ d->focus_next = d->focus_prev = nullptr;
}
@@ -1493,7 +1493,7 @@ QWidget::~QWidget()
}
delete d->needsFlush;
- d->needsFlush = 0;
+ d->needsFlush = nullptr;
// The next 20 lines are duplicated from QObject, but required here
// since QWidget deletes is children itself
@@ -1520,7 +1520,7 @@ QWidget::~QWidget()
if (QAbstractDeclarativeData::destroyed)
QAbstractDeclarativeData::destroyed(d->declarativeData, this);
}
- d->declarativeData = 0; // don't activate again in ~QObject
+ d->declarativeData = nullptr; // don't activate again in ~QObject
d->wasDeleted = false;
}
@@ -1564,7 +1564,7 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
// will have the same windowid (the root window id) as the
// qt_desktopWidget. We should not add the second desktop widget
// to the mapper.
- bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
+ bool userDesktopWidget = qt_desktopWidget != nullptr && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
if (mapper && data.winid && !userDesktopWidget) {
mapper->remove(data.winid);
}
@@ -1589,19 +1589,19 @@ void QWidgetPrivate::createTLExtra()
if (!extra->topextra) {
extra->topextra = qt_make_unique<QTLWExtra>();
QTLWExtra* x = extra->topextra.get();
- x->backingStore = 0;
- x->sharedPainter = 0;
+ x->backingStore = nullptr;
+ x->sharedPainter = nullptr;
x->incw = x->inch = 0;
x->basew = x->baseh = 0;
x->frameStrut.setCoords(0, 0, 0, 0);
x->normalGeometry = QRect(0,0,-1,-1);
- x->savedFlags = 0;
+ x->savedFlags = { };
x->opacity = 255;
x->posIncludesFrame = 0;
x->sizeAdjusted = false;
x->inTopLevelResize = false;
x->embedded = 0;
- x->window = 0;
+ x->window = nullptr;
x->initialScreenIndex = -1;
#ifdef QWIDGET_EXTRA_DEBUG
@@ -1620,9 +1620,9 @@ void QWidgetPrivate::createExtra()
{
if (!extra) { // if not exists
extra = qt_make_unique<QWExtra>();
- extra->glContext = 0;
+ extra->glContext = nullptr;
#if QT_CONFIG(graphicsview)
- extra->proxyWidget = 0;
+ extra->proxyWidget = nullptr;
#endif
extra->minw = 0;
extra->minh = 0;
@@ -1681,7 +1681,7 @@ static void deleteBackingStore(QWidgetPrivate *d)
QTLWExtra *topData = d->topData();
delete topData->backingStore;
- topData->backingStore = 0;
+ topData->backingStore = nullptr;
}
void QWidgetPrivate::deleteTLSysExtra()
@@ -1705,7 +1705,7 @@ void QWidgetPrivate::deleteTLSysExtra()
extra->topextra->window->destroy();
}
delete extra->topextra->window;
- extra->topextra->window = 0;
+ extra->topextra->window = nullptr;
}
}
@@ -1805,7 +1805,7 @@ void QWidgetPrivate::paintOnScreen(const QRegion &rgn)
if (toBePainted.isEmpty())
return; // Nothing to repaint.
- drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, 0);
+ drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, nullptr);
if (Q_UNLIKELY(q->paintingActive()))
qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
@@ -2302,10 +2302,10 @@ void QWidgetPrivate::deactivateWidgetCleanup()
Q_Q(QWidget);
// If this was the active application window, reset it
if (QApplication::activeWindow() == q)
- QApplication::setActiveWindow(0);
+ QApplication::setActiveWindow(nullptr);
// If the is the active mouse press widget, reset it
if (q == qt_button_down)
- qt_button_down = 0;
+ qt_button_down = nullptr;
}
@@ -2563,7 +2563,7 @@ void QWidget::setStyleSheet(const QString& styleSheet)
if (testAttribute(Qt::WA_SetStyle)) {
d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true);
} else {
- d->setStyle_helper(new QStyleSheetStyle(0), true);
+ d->setStyle_helper(new QStyleSheetStyle(nullptr), true);
}
}
@@ -2606,7 +2606,7 @@ QStyle *QWidget::style() const
void QWidget::setStyle(QStyle *style)
{
Q_D(QWidget);
- setAttribute(Qt::WA_SetStyle, style != 0);
+ setAttribute(Qt::WA_SetStyle, style != nullptr);
d->createExtra();
#ifndef QT_NO_STYLE_STYLESHEET
if (QStyleSheetStyle *styleSheetStyle = qt_styleSheet(style)) {
@@ -2686,7 +2686,7 @@ void QWidgetPrivate::inheritStyle()
QStyle *origStyle = proxy ? proxy->base : extraStyle;
QWidget *parent = q->parentWidget();
- QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0;
+ QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : nullptr;
// If we have stylesheet on app or parent has stylesheet style, we need
// to be running a proxy
if (!qApp->styleSheet().isEmpty() || qt_styleSheet(parentStyle)) {
@@ -2709,7 +2709,7 @@ void QWidgetPrivate::inheritStyle()
// In such a case we need to start following the application style (i.e revert
// the propagation behavior of QStyleSheetStyle)
if (!q->testAttribute(Qt::WA_SetStyle))
- origStyle = 0;
+ origStyle = nullptr;
setStyle_helper(origStyle, true);
#endif // QT_NO_STYLE_STYLESHEET
@@ -3085,7 +3085,7 @@ bool QWidget::isEnabledTo(const QWidget *ancestor) const
*/
void QWidget::addAction(QAction *action)
{
- insertAction(0, action);
+ insertAction(nullptr, action);
}
/*!
@@ -3100,7 +3100,7 @@ void QWidget::addActions(QList<QAction*> actions)
#endif
{
for(int i = 0; i < actions.count(); i++)
- insertAction(0, actions.at(i));
+ insertAction(nullptr, actions.at(i));
}
/*!
@@ -3125,7 +3125,7 @@ void QWidget::insertAction(QAction *before, QAction *action)
int pos = d->actions.indexOf(before);
if (pos < 0) {
- before = 0;
+ before = nullptr;
pos = d->actions.size();
}
d->actions.insert(pos, action);
@@ -4606,7 +4606,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
Q_Q(QWidget);
#ifndef QT_NO_STYLE_STYLESHEET
const QStyleSheetStyle* cssStyle;
- cssStyle = extra ? qt_styleSheet(extra->style) : 0;
+ cssStyle = extra ? qt_styleSheet(extra->style) : nullptr;
const bool useStyleSheetPropagationInWidgetStyles =
QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
#endif
@@ -4842,7 +4842,7 @@ void qt_qpa_set_cursor(QWidget *w, bool force)
if (!w->testAttribute(Qt::WA_WState_Created))
return;
- static QPointer<QWidget> lastUnderMouse = 0;
+ static QPointer<QWidget> lastUnderMouse = nullptr;
if (force) {
lastUnderMouse = w;
} else if (lastUnderMouse) {
@@ -5119,7 +5119,7 @@ void QWidget::setGraphicsEffect(QGraphicsEffect *effect)
if (d->graphicsEffect) {
d->invalidateBackingStore(rect());
delete d->graphicsEffect;
- d->graphicsEffect = 0;
+ d->graphicsEffect = nullptr;
}
if (effect) {
@@ -5313,7 +5313,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
setSystemClip(sharedPainter->paintEngine(), 1, QRegion());
sharedPainter->restore();
}
- sourced->context = 0;
+ sourced->context = nullptr;
if (repaintManager)
repaintManager->markNeedsFlush(q, rgn, offset);
@@ -5431,7 +5431,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
if (!sharedPainter)
paintEngine->d_func()->systemRect = QRect();
else
- paintEngine->d_func()->currentClipDevice = 0;
+ paintEngine->d_func()->currentClipDevice = nullptr;
setSystemClip(pdev->paintEngine(), 1, QRegion());
}
@@ -5492,7 +5492,7 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset,
if (paintRegion.isEmpty())
return;
- QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
+ QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : nullptr;
// Use the target's shared painter if set (typically set when doing
// "other->render(widget);" in the widget's paintEvent.
@@ -5553,7 +5553,7 @@ void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectLis
const QPoint &offset, DrawWidgetFlags flags
, QPainter *sharedPainter, QWidgetRepaintManager *repaintManager)
{
- QWidget *w = 0;
+ QWidget *w = nullptr;
QRect boundingRect;
bool dirtyBoundingRect = true;
const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren);
@@ -5847,7 +5847,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg
if (count%2) { // odd number of [*] -> replace last one
int lastIndex = cap.lastIndexOf(placeHolder, index - 1);
if (widget->isWindowModified()
- && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
+ && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, nullptr, widget))
cap.replace(lastIndex, 3, QWidget::tr("*"));
else
cap.remove(lastIndex, 3);
@@ -5957,9 +5957,9 @@ void QWidget::setWindowTitle(const QString &title)
\note On \macos, window icons represent the active document,
and will not be displayed unless a file path has also been
- set using setFilePath.
+ set using setWindowFilePath.
- \sa windowTitle, setFilePath
+ \sa windowTitle, setWindowFilePath
*/
QIcon QWidget::windowIcon() const
{
@@ -6303,7 +6303,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
return;
#if QT_CONFIG(graphicsview)
- QWidget *previousProxyFocus = 0;
+ QWidget *previousProxyFocus = nullptr;
if (const auto &topData = window()->d_func()->extra) {
if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
previousProxyFocus = topData->proxyWidget->widget()->focusWidget();
@@ -6443,12 +6443,12 @@ void QWidgetPrivate::updateFocusChild()
if (q->isHidden()) {
while (w && w->isHidden()) {
w->d_func()->focus_child = q;
- w = w->isWindow() ? 0 : w->parentWidget();
+ w = w->isWindow() ? nullptr : w->parentWidget();
}
} else {
while (w) {
w->d_func()->focus_child = q;
- w = w->isWindow() ? 0 : w->parentWidget();
+ w = w->isWindow() ? nullptr : w->parentWidget();
}
}
@@ -6494,7 +6494,7 @@ void QWidget::clearFocus()
while (w) {
// Just like setFocus(), we update (clear) the focus_child of our parents
if (w->d_func()->focus_child == this)
- w->d_func()->focus_child = 0;
+ w->d_func()->focus_child = nullptr;
w = w->parentWidget();
}
@@ -6515,7 +6515,7 @@ void QWidget::clearFocus()
if (hasFocus()) {
// Update proxy state
- QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
+ QApplicationPrivate::setFocusWidget(nullptr, Qt::OtherFocusReason);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(this, QAccessible::Focus);
QAccessible::updateAccessibility(&event);
@@ -6592,10 +6592,10 @@ bool QWidget::focusNextPrevChild(bool next)
*/
if (wrappingOccurred) {
QWindow *window = windowHandle();
- if (window != 0) {
+ if (window != nullptr) {
QWindowPrivate *winp = qt_window_private(window);
- if (winp->platformWindow != 0) {
+ if (winp->platformWindow != nullptr) {
QFocusEvent event(QEvent::FocusIn, reason);
event.ignore();
winp->platformWindow->windowEvent(&event);
@@ -6673,7 +6673,7 @@ bool QWidget::isActiveWindow() const
}
#endif
- if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) {
+ if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, this)) {
if(tlw->windowType() == Qt::Tool &&
!tlw->isModal() &&
(!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow()))
@@ -6829,9 +6829,9 @@ void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw)
focus_child->clearFocus();
// separate the focus chain into new (children of myself) and old (the rest)
- QWidget *firstOld = 0;
+ QWidget *firstOld = nullptr;
//QWidget *firstNew = q; //invariant
- QWidget *o = 0; // last in the old list
+ QWidget *o = nullptr; // last in the old list
QWidget *n = q; // last in the new list
bool prevWasNew = true;
@@ -7839,7 +7839,7 @@ void QWidgetPrivate::show_helper()
#endif
if (QApplicationPrivate::hidden_focus_widget == q) {
- QApplicationPrivate::hidden_focus_widget = 0;
+ QApplicationPrivate::hidden_focus_widget = nullptr;
q->setFocus(Qt::OtherFocusReason);
}
@@ -7938,7 +7938,7 @@ void QWidgetPrivate::hide_helper()
bool isEmbedded = false;
#if QT_CONFIG(graphicsview)
- isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
+ isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != nullptr;
#else
Q_UNUSED(isEmbedded);
#endif
@@ -8131,7 +8131,7 @@ void QWidgetPrivate::setVisible(bool visible)
QCoreApplication::sendEvent(q, &showToParentEvent);
} else { // hide
if (QApplicationPrivate::hidden_focus_widget == q)
- QApplicationPrivate::hidden_focus_widget = 0;
+ QApplicationPrivate::hidden_focus_widget = nullptr;
// hw: The test on getOpaqueRegion() needs to be more intelligent
// currently it doesn't work if the widget is hidden (the region will
@@ -8841,7 +8841,7 @@ bool QWidget::event(QEvent *event)
case Qt::ActionsContextMenu:
if (d->actions.count()) {
QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(),
- 0, this);
+ nullptr, this);
break;
}
Q_FALLTHROUGH();
@@ -10033,9 +10033,9 @@ QLayout *QWidget::takeLayout()
Q_D(QWidget);
QLayout *l = layout();
if (!l)
- return 0;
- d->layout = 0;
- l->setParent(0);
+ return nullptr;
+ d->layout = nullptr;
+ l->setParent(nullptr);
return l;
}
@@ -10157,10 +10157,10 @@ QWidget *QWidget::childAt(const QPoint &p) const
QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
{
if (children.isEmpty())
- return 0;
+ return nullptr;
if (!pointInsideRectAndMask(p))
- return 0;
+ return nullptr;
return childAtRecursiveHelper(p, ignoreChildrenInDestructor);
}
@@ -10188,7 +10188,7 @@ QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChil
// We have found our target; namely the child at position 'p'.
return child;
}
- return 0;
+ return nullptr;
}
void QWidgetPrivate::updateGeometry_helper(bool forceUpdate)
@@ -10401,7 +10401,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
if (f & Qt::Window) // Frame geometry likely changes, refresh.
d->data.fstrut_dirty = true;
- QWidget *desktopWidget = 0;
+ QWidget *desktopWidget = nullptr;
if (parent && parent->windowType() == Qt::Desktop)
desktopWidget = parent;
bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
@@ -10429,7 +10429,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
d->setParent_sys(parent, f);
if (desktopWidget)
- parent = 0;
+ parent = nullptr;
#ifndef QT_NO_OPENGL
if (d->textureChildSeen && parent) {
@@ -10543,7 +10543,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
// programmer specified desktop widget
const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(newparent);
targetScreen = sw ? sw->screenNumber() : 0;
- newparent = 0;
+ newparent = nullptr;
}
setWinId(0);
@@ -10553,19 +10553,19 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
if (q->windowHandle()) {
q->windowHandle()->setFlags(f);
QWidget *parentWithWindow =
- newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0;
+ newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : nullptr;
if (parentWithWindow) {
QWidget *topLevel = parentWithWindow->window();
if ((f & Qt::Window) && topLevel && topLevel->windowHandle()) {
q->windowHandle()->setTransientParent(topLevel->windowHandle());
- q->windowHandle()->setParent(0);
+ q->windowHandle()->setParent(nullptr);
} else {
- q->windowHandle()->setTransientParent(0);
+ q->windowHandle()->setTransientParent(nullptr);
q->windowHandle()->setParent(parentWithWindow->windowHandle());
}
} else {
- q->windowHandle()->setTransientParent(0);
- q->windowHandle()->setParent(0);
+ q->windowHandle()->setTransientParent(nullptr);
+ q->windowHandle()->setParent(nullptr);
}
}
}
@@ -10596,7 +10596,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
continue;
QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow);
- QWidget *childWidget = childWW ? childWW->widget() : 0;
+ QWidget *childWidget = childWW ? childWW->widget() : nullptr;
if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow)))
childWindow->setParent(newParentWindow);
}
@@ -12002,7 +12002,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const
return 0;
#else
if (!extra || !extra->topextra || !extra->topextra->window)
- return 0;
+ return nullptr;
if (!extra->topextra->shareContext) {
auto ctx = qt_make_unique<QOpenGLContext>();
@@ -12061,7 +12061,7 @@ QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const
if (d->extra) {
return d->extra->proxyWidget;
}
- return 0;
+ return nullptr;
}
#endif
@@ -12122,7 +12122,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
qApp->d_func()->closePopup(this);
if (this == QApplicationPrivate::active_window)
- QApplication::setActiveWindow(0);
+ QApplication::setActiveWindow(nullptr);
if (QWidget::mouseGrabber() == this)
releaseMouse();
if (QWidget::keyboardGrabber() == this)
@@ -12186,7 +12186,7 @@ QPaintEngine *QWidget::paintEngine() const
const_cast<QWidgetPrivate *>(d_func())->noPaintOnScreen = 1;
#endif
- return 0; //##### @@@
+ return nullptr; //##### @@@
}
// Do not call QWindow::mapToGlobal() until QPlatformWindow is properly showing.
@@ -12273,10 +12273,10 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const
return t.transform.inverted().map(windowLocal);
}
-QWidget *qt_pressGrab = 0;
-QWidget *qt_mouseGrb = 0;
+QWidget *qt_pressGrab = nullptr;
+QWidget *qt_mouseGrb = nullptr;
static bool mouseGrabWithCursor = false;
-static QWidget *keyboardGrb = 0;
+static QWidget *keyboardGrb = nullptr;
static inline QWindow *grabberWindow(const QWidget *w)
{
@@ -12288,7 +12288,7 @@ static inline QWindow *grabberWindow(const QWidget *w)
}
#ifndef QT_NO_CURSOR
-static void grabMouseForWidget(QWidget *widget, const QCursor *cursor = 0)
+static void grabMouseForWidget(QWidget *widget, const QCursor *cursor = nullptr)
#else
static void grabMouseForWidget(QWidget *widget)
#endif
@@ -12308,7 +12308,7 @@ static void grabMouseForWidget(QWidget *widget)
}
qt_mouseGrb = widget;
- qt_pressGrab = 0;
+ qt_pressGrab = nullptr;
}
static void releaseMouseGrabOfWidget(QWidget *widget)
@@ -12324,7 +12324,7 @@ static void releaseMouseGrabOfWidget(QWidget *widget)
window->setMouseGrabEnabled(false);
}
}
- qt_mouseGrb = 0;
+ qt_mouseGrb = nullptr;
}
/*!
@@ -12453,7 +12453,7 @@ void QWidget::releaseKeyboard()
if (keyboardGrb == this) {
if (QWindow *window = grabberWindow(this))
window->setKeyboardGrabEnabled(false);
- keyboardGrb = 0;
+ keyboardGrb = nullptr;
}
}
@@ -12530,8 +12530,8 @@ void QWidget::activateWindow()
*/
int QWidget::metric(PaintDeviceMetric m) const
{
- QWindow *topLevelWindow = 0;
- QScreen *screen = 0;
+ QWindow *topLevelWindow = nullptr;
+ QScreen *screen = nullptr;
if (QWidget *topLevel = window()) {
topLevelWindow = topLevel->windowHandle();
if (topLevelWindow)
@@ -12617,14 +12617,14 @@ QPainter *QWidget::sharedPainter() const
{
// Someone sent a paint event directly to the widget
if (!d_func()->redirectDev)
- return 0;
+ return nullptr;
QPainter *sp = d_func()->sharedPainter();
if (!sp || !sp->isActive())
- return 0;
+ return nullptr;
if (sp->paintEngine()->paintDevice() != d_func()->redirectDev)
- return 0;
+ return nullptr;
return sp;
}
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 83a6e6d4b3..415a738eb4 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -175,11 +175,11 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
Q_PROPERTY(QSize sizeHint READ sizeHint)
Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)
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) // deprecated
- Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
- Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
+ Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged)
+ Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged)
+ Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged) // deprecated
+ Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity)
+ Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified)
#ifndef QT_NO_TOOLTIP
Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
Q_PROPERTY(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration)
@@ -201,7 +201,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
#endif
Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)
- Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow)
+ Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath)
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
public:
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 698928b0b0..6915782cb3 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -420,7 +420,7 @@ public:
void setVisible(bool);
void setEnabled_helper(bool);
- static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
+ static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = nullptr);
void updateFrameStrut();
QRect frameStrut() const;
@@ -592,7 +592,7 @@ public:
Q_Q(QWidget);
return q->testAttribute(Qt::WA_AlwaysStackOnTop)
? QPlatformTextureList::StacksOnTop
- : QPlatformTextureList::Flags(nullptr);
+ : QPlatformTextureList::Flags();
}
virtual QImage grabFramebuffer() { return QImage(); }
virtual void beginBackingStorePainting() { }
diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp
index 6eebaca42c..9649e51b92 100644
--- a/src/widgets/kernel/qwidgetaction.cpp
+++ b/src/widgets/kernel/qwidgetaction.cpp
@@ -146,7 +146,7 @@ void QWidgetAction::setDefaultWidget(QWidget *widget)
setVisible(!(widget->isHidden() && widget->testAttribute(Qt::WA_WState_ExplicitShowHide)));
d->defaultWidget->hide();
- d->defaultWidget->setParent(0);
+ d->defaultWidget->setParent(nullptr);
d->defaultWidgetInUse = false;
if (!isEnabled())
d->defaultWidget->setEnabled(false);
@@ -177,7 +177,7 @@ QWidget *QWidgetAction::requestWidget(QWidget *parent)
QWidget *w = createWidget(parent);
if (!w) {
if (d->defaultWidgetInUse || !d->defaultWidget)
- return 0;
+ return nullptr;
d->defaultWidget->setParent(parent);
d->defaultWidgetInUse = true;
return d->defaultWidget;
@@ -203,7 +203,7 @@ void QWidgetAction::releaseWidget(QWidget *widget)
if (widget == d->defaultWidget) {
d->defaultWidget->hide();
- d->defaultWidget->setParent(0);
+ d->defaultWidget->setParent(nullptr);
d->defaultWidgetInUse = false;
return;
}
@@ -251,7 +251,7 @@ bool QWidgetAction::eventFilter(QObject *obj, QEvent *event)
QWidget *QWidgetAction::createWidget(QWidget *parent)
{
Q_UNUSED(parent)
- return 0;
+ return nullptr;
}
/*!
diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp
index c3211e275f..135a1527ac 100644
--- a/src/widgets/kernel/qwidgetrepaintmanager.cpp
+++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp
@@ -695,7 +695,7 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget)
return qt_dummy_platformTextureList();
}
- return 0;
+ return nullptr;
}
#else
@@ -788,7 +788,7 @@ bool QWidgetRepaintManager::syncAllowed()
QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
if (textureListWatcher && !textureListWatcher->isLocked()) {
textureListWatcher->deleteLater();
- textureListWatcher = 0;
+ textureListWatcher = nullptr;
} else if (!tlwExtra->widgetTextures.empty()) {
bool skipSync = false;
for (const auto &tl : tlwExtra->widgetTextures) {
@@ -822,7 +822,7 @@ void QWidgetRepaintManager::paintAndFlush()
if (hasStaticContents() && !store->size().isEmpty() ) {
// Repaint existing dirty area and newly visible area.
const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
- const QRegion staticRegion(staticContents(0, clipRect));
+ const QRegion staticRegion(staticContents(nullptr, clipRect));
QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
newVisible -= staticRegion;
dirty += newVisible;
@@ -1008,13 +1008,13 @@ void QWidgetRepaintManager::paintAndFlush()
QPoint offset;
if (w != tlw)
offset += w->mapTo(tlw, QPoint());
- wd->drawWidget(store->paintDevice(), toBePainted, offset, flags, 0, this);
+ wd->drawWidget(store->paintDevice(), toBePainted, offset, flags, nullptr, this);
}
// Paint the rest with composition.
if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
- tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, 0, this);
+ tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
}
store->endPaint();
@@ -1108,7 +1108,7 @@ void QWidgetRepaintManager::flush()
for (QWidget *w : qExchange(needsFlushWidgets, {})) {
QWidgetPrivate *wd = w->d_func();
Q_ASSERT(wd->needsFlush);
- QPlatformTextureList *widgetTexturesForNative = wd->textureChildSeen ? widgetTexturesFor(tlw, w) : 0;
+ QPlatformTextureList *widgetTexturesForNative = wd->textureChildSeen ? widgetTexturesFor(tlw, w) : nullptr;
flush(w, *wd->needsFlush, widgetTexturesForNative);
*wd->needsFlush = QRegion();
}
@@ -1284,7 +1284,7 @@ QRegion QWidgetRepaintManager::staticContents(QWidget *parent, const QRect &with
wd->clipToEffectiveMask(visible);
if (visible.isEmpty())
continue;
- wd->subtractOpaqueSiblings(visible, 0, /*alsoNonOpaque=*/true);
+ wd->subtractOpaqueSiblings(visible, nullptr, /*alsoNonOpaque=*/true);
visible.translate(offset);
region += visible;
@@ -1331,7 +1331,7 @@ void QWidgetPrivate::invalidateBackingStore_resizeHelper(const QPoint &oldPos, c
if (!staticContents || graphicsEffect) {
QRegion staticChildren;
- QWidgetRepaintManager *bs = 0;
+ QWidgetRepaintManager *bs = nullptr;
if (offset.isNull() && (bs = maybeRepaintManager()))
staticChildren = bs->staticContents(q, oldWidgetRect);
const bool hasStaticChildren = !staticChildren.isEmpty();
diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp
index 02b4ea20a7..edb166e8d5 100644
--- a/src/widgets/kernel/qwidgetsvariant.cpp
+++ b/src/widgets/kernel/qwidgetsvariant.cpp
@@ -51,12 +51,12 @@ namespace {
static void construct(QVariant::Private *x, const void *copy)
{
switch (x->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
v_construct<QSizePolicy>(x, copy);
break;
default:
qWarning("Trying to construct an instance of an invalid type, type id: %i", x->type);
- x->type = QVariant::Invalid;
+ x->type = QMetaType::UnknownType;
return;
}
x->is_null = !copy;
@@ -65,7 +65,7 @@ static void construct(QVariant::Private *x, const void *copy)
static void clear(QVariant::Private *d)
{
switch (d->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
v_clear<QSizePolicy>(d);
break;
default:
@@ -73,7 +73,7 @@ static void clear(QVariant::Private *d)
return;
}
- d->type = QVariant::Invalid;
+ d->type = QMetaType::UnknownType;
d->is_null = true;
d->is_shared = false;
}
@@ -88,7 +88,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
{
Q_ASSERT(a->type == b->type);
switch(a->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
default:
Q_ASSERT(false);
@@ -111,7 +111,7 @@ static void streamDebug(QDebug dbg, const QVariant &v)
{
QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
switch (d->type) {
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
dbg.nospace() << *v_cast<QSizePolicy>(d);
break;
default:
@@ -125,12 +125,12 @@ static const QVariant::Handler widgets_handler = {
clear,
isNull,
#ifndef QT_NO_DATASTREAM
- 0,
- 0,
+ nullptr,
+ nullptr,
#endif
compare,
convert,
- 0,
+ nullptr,
#if !defined(QT_NO_DEBUG_STREAM)
streamDebug
#else
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 596343c52f..904067afda 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -57,10 +57,10 @@ QT_BEGIN_NAMESPACE
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
-Q_WIDGETS_EXPORT QWidget *qt_button_down = 0; // widget got last button-down
+Q_WIDGETS_EXPORT QWidget *qt_button_down = nullptr; // widget got last button-down
// popup control
-QWidget *qt_popup_down = 0; // popup that contains the pressed widget
+QWidget *qt_popup_down = nullptr; // popup that contains the pressed widget
extern int openPopupCount;
bool qt_replay_popup_mouse_event = false;
extern bool qt_try_modal(QWidget *widget, QEvent::Type type);
@@ -156,7 +156,7 @@ QOpenGLContext *QWidgetWindowPrivate::shareContext() const
#endif // opengl
QWidgetWindow::QWidgetWindow(QWidget *widget)
- : QWindow(*new QWidgetWindowPrivate(), 0)
+ : QWindow(*new QWidgetWindowPrivate(), nullptr)
, m_widget(widget)
{
updateObjectName();
@@ -179,7 +179,7 @@ QAccessibleInterface *QWidgetWindow::accessibleRoot() const
{
if (m_widget)
return QAccessible::queryAccessibleInterface(m_widget);
- return 0;
+ return nullptr;
}
#endif
@@ -374,7 +374,7 @@ bool QWidgetWindow::event(QEvent *event)
#endif // QT_NO_CONTEXTMENU
case QEvent::WindowBlocked:
- qt_button_down = 0;
+ qt_button_down = nullptr;
break;
case QEvent::UpdateRequest:
@@ -393,7 +393,7 @@ bool QWidgetWindow::event(QEvent *event)
return QWindow::event(event);
}
-QPointer<QWidget> qt_last_mouse_receiver = 0;
+QPointer<QWidget> qt_last_mouse_receiver = nullptr;
void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
{
@@ -406,7 +406,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
return;
#endif
if (event->type() == QEvent::Leave) {
- QWidget *enter = 0;
+ QWidget *enter = nullptr;
// Check from window system event queue if the next queued enter targets a window
// in the same window hierarchy (e.g. enter a child of this window). If so,
// remove the enter event from queue and handle both in single dispatch.
@@ -484,13 +484,13 @@ QWidget *QWidgetWindow::getFocusWidget(FocusWidgets fw)
void QWidgetWindow::handleFocusInEvent(QFocusEvent *e)
{
- QWidget *focusWidget = 0;
+ QWidget *focusWidget = nullptr;
if (e->reason() == Qt::BacktabFocusReason)
focusWidget = getFocusWidget(LastFocusWidget);
else if (e->reason() == Qt::TabFocusReason)
focusWidget = getFocusWidget(FirstFocusWidget);
- if (focusWidget != 0)
+ if (focusWidget != nullptr)
focusWidget->setFocus();
}
@@ -513,8 +513,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
QWidget *popupChild = activePopupWidget->childAt(mapped);
if (activePopupWidget != qt_popup_down) {
- qt_button_down = 0;
- qt_popup_down = 0;
+ qt_button_down = nullptr;
+ qt_popup_down = nullptr;
}
switch (event->type()) {
@@ -589,7 +589,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
&& qt_replay_popup_mouse_event
&& QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) {
if (m_widget->windowType() != Qt::Popup)
- qt_button_down = 0;
+ qt_button_down = nullptr;
if (event->type() == QEvent::MouseButtonPress) {
// the popup disappeared, replay the mouse press event
QWidget *w = QApplication::widgetAt(event->globalPos());
@@ -636,8 +636,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
#endif
if (releaseAfter) {
- qt_button_down = 0;
- qt_popup_down = 0;
+ qt_button_down = nullptr;
+ qt_popup_down = nullptr;
}
return;
}
@@ -1050,7 +1050,7 @@ bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long
#if QT_CONFIG(tabletevent)
void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
{
- static QPointer<QWidget> qt_tablet_target = 0;
+ static QPointer<QWidget> qt_tablet_target = nullptr;
QWidget *widget = qt_tablet_target;
@@ -1076,7 +1076,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
}
if (event->type() == QEvent::TabletRelease && event->buttons() == Qt::NoButton)
- qt_tablet_target = 0;
+ qt_tablet_target = nullptr;
}
#endif // QT_CONFIG(tabletevent)
@@ -1084,7 +1084,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
void QWidgetWindow::handleGestureEvent(QNativeGestureEvent *e)
{
// copy-pasted code to find correct widget follows:
- QObject *receiver = 0;
+ QObject *receiver = nullptr;
if (QApplicationPrivate::inPopupMode()) {
QWidget *popup = QApplication::activePopupWidget();
QWidget *popupFocusWidget = popup->focusWidget();
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index fd8581edbb..b4d889fdfa 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -58,8 +58,8 @@ public:
Q_DECLARE_PUBLIC(QWindowContainer)
QWindowContainerPrivate()
- : window(0)
- , oldFocusWindow(0)
+ : window(nullptr)
+ , oldFocusWindow(nullptr)
, usesNativeWidgets(false)
{
}
@@ -70,7 +70,7 @@ public:
QWindowContainer *wc = qobject_cast<QWindowContainer *>(w);
if (wc)
return wc->d_func();
- return 0;
+ return nullptr;
}
void updateGeometry() {
@@ -90,7 +90,7 @@ public:
void updateUsesNativeWidgets()
{
- if (window->parent() == 0)
+ if (window->parent() == nullptr)
return;
Q_Q(QWindowContainer);
if (q->internalWinId()) {
@@ -295,7 +295,7 @@ bool QWindowContainer::event(QEvent *e)
case QEvent::ChildRemoved: {
QChildEvent *ce = static_cast<QChildEvent *>(e);
if (ce->child() == d->window)
- d->window = 0;
+ d->window = nullptr;
break;
}
// The only thing we are interested in is making sure our sizes stay
diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h
index c6de168c10..72474077aa 100644
--- a/src/widgets/kernel/qwindowcontainer_p.h
+++ b/src/widgets/kernel/qwindowcontainer_p.h
@@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QWindowContainer : public QWidget
Q_DECLARE_PRIVATE(QWindowContainer)
public:
- explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
+ explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = { });
~QWindowContainer();
QWindow *containedWindow() const;
diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri
index 3b3170beb1..eede987b4c 100644
--- a/src/widgets/kernel/win.pri
+++ b/src/widgets/kernel/win.pri
@@ -1,7 +1,6 @@
# Qt/Windows only configuration file
# --------------------------------------------------------------------
-INCLUDEPATH += ../3rdparty/wintab
!winrt {
LIBS_PRIVATE *= -luxtheme -ldwmapi
QMAKE_USE_PRIVATE += shell32
diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp
index 42691d6b77..b310da5781 100644
--- a/src/widgets/statemachine/qguistatemachine.cpp
+++ b/src/widgets/statemachine/qguistatemachine.cpp
@@ -456,7 +456,7 @@ const QStateMachinePrivate::Handler qt_gui_statemachine_handler = {
cloneEvent
};
-static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = 0;
+static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = nullptr;
void qRegisterGuiStateMachine()
{
qt_guistatemachine_last_handler = QStateMachinePrivate::handler;
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index bc423187d2..eb5399bd4a 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -123,7 +123,7 @@ QT_BEGIN_NAMESPACE
static QWindow *qt_getWindow(const QWidget *widget)
{
- return widget ? widget->window()->windowHandle() : 0;
+ return widget ? widget->window()->windowHandle() : nullptr;
}
/*!
@@ -353,7 +353,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
break; }
case PE_FrameStatusBarItem:
- qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0);
+ qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, nullptr);
break;
case PE_IndicatorHeaderArrow:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
@@ -450,7 +450,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
#endif // QT_CONFIG(tabbar)
case PE_FrameTabWidget:
case PE_FrameWindow:
- qDrawWinPanel(p, opt->rect, opt->palette, false, 0);
+ qDrawWinPanel(p, opt->rect, opt->palette, false, nullptr);
break;
case PE_FrameLineEdit:
proxy()->drawPrimitive(PE_Frame, opt, p, widget);
@@ -493,17 +493,17 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
x -= 2;
if (opt->rect.height() > 4) {
qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
- opt->palette, false, 1, 0);
+ opt->palette, false, 1, nullptr);
qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4,
- opt->palette, false, 1, 0);
+ opt->palette, false, 1, nullptr);
}
} else {
if (opt->rect.width() > 4) {
int y = opt->rect.height() / 3;
qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
- opt->palette, false, 1, 0);
+ opt->palette, false, 1, nullptr);
qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3,
- opt->palette, false, 1, 0);
+ opt->palette, false, 1, nullptr);
}
}
p->restore();
@@ -818,7 +818,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
#if QT_CONFIG(toolbutton)
static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbutton,
- const QRect &rect, QPainter *painter, const QWidget *widget = 0)
+ const QRect &rect, QPainter *painter, const QWidget *widget = nullptr)
{
QStyle::PrimitiveElement pe;
switch (toolbutton->arrowType) {
@@ -1016,7 +1016,7 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int
void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const
{
const QWidget *widget = option->widget;
- const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
+ const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
const bool wrapText = option->features & QStyleOptionViewItem::WrapText;
@@ -1556,7 +1556,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
qint64 maximum = qint64(pb->maximum);
qint64 progress = qint64(pb->progress);
- QMatrix m;
+ QTransform m;
if (vertical) {
rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
@@ -2465,6 +2465,12 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
r = visualRect(opt->direction, opt->rect, r);
}
break;
+ case SE_PushButtonBevel:
+ {
+ r = opt->rect;
+ r = visualRect(opt->direction, opt->rect, r);
+ }
+ break;
case SE_CheckBoxIndicator:
{
int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
@@ -2931,8 +2937,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
case SE_TabBarScrollLeftButton: {
const bool vertical = opt->rect.width() < opt->rect.height();
const Qt::LayoutDirection ld = widget->layoutDirection();
- const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, widget), QApplication::globalStrut().width());
- const int buttonOverlap = proxy()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, widget);
+ const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget), QApplication::globalStrut().width());
+ const int buttonOverlap = proxy()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, nullptr, widget);
r = vertical ? QRect(0, opt->rect.height() - (buttonWidth * 2) + buttonOverlap, opt->rect.width(), buttonWidth)
: QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - (buttonWidth * 2) + buttonOverlap, 0, buttonWidth, opt->rect.height()));
@@ -2940,7 +2946,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
case SE_TabBarScrollRightButton: {
const bool vertical = opt->rect.width() < opt->rect.height();
const Qt::LayoutDirection ld = widget->layoutDirection();
- const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, widget), QApplication::globalStrut().width());
+ const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget), QApplication::globalStrut().width());
r = vertical ? QRect(0, opt->rect.height() - buttonWidth, opt->rect.width(), buttonWidth)
: QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - buttonWidth, 0, buttonWidth, opt->rect.height()));
@@ -3030,8 +3036,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
const QStyleOptionDockWidget *dwOpt
= qstyleoption_cast<const QStyleOptionDockWidget*>(opt);
- bool canClose = dwOpt == 0 ? true : dwOpt->closable;
- bool canFloat = dwOpt == 0 ? false : dwOpt->floatable;
+ bool canClose = dwOpt == nullptr ? true : dwOpt->closable;
+ bool canFloat = dwOpt == nullptr ? false : dwOpt->floatable;
const bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar;
@@ -3134,7 +3140,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false);
if (d->cachedOption) {
delete d->cachedOption;
- d->cachedOption = 0;
+ d->cachedOption = nullptr;
}
d->cachedOption = new QStyleOptionViewItem(*vopt);
}
@@ -5027,8 +5033,9 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_SpinBox:
if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
// Add button + frame widths
+ const qreal dpi = QStyleHelper::dpi(opt);
const bool hasButtons = (vopt->buttonSymbols != QAbstractSpinBox::NoButtons);
- const int buttonWidth = hasButtons ? proxy()->subControlRect(CC_SpinBox, vopt, SC_SpinBoxUp, widget).width() : 0;
+ const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0;
const int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget) : 0;
sz += QSize(buttonWidth + 2*fw, 2*fw);
}
@@ -5143,7 +5150,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
case SH_Table_GridLineColor:
if (opt)
- ret = opt->palette.color(QPalette::Mid).rgb();
+ ret = opt->palette.color(QPalette::Mid).rgba();
else
ret = -1;
break;
diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index 4860dfe4c9..6223a26a54 100644
--- a/src/widgets/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
@@ -122,7 +122,7 @@ public:
mutable QIcon tabBarcloseButtonIcon;
#if QT_CONFIG(tabbar)
- void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
+ virtual void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
#endif
int animationFps;
diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp
index d30b43a679..66729e4dc7 100644
--- a/src/widgets/styles/qdrawutil.cpp
+++ b/src/widgets/styles/qdrawutil.cpp
@@ -214,7 +214,7 @@ void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
specifies the line width for each of the lines; it is not the
total line width. The \a midLineWidth specifies the width of a
middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
+ interior is filled with the \a fill brush unless \a fill is \nullptr.
The rectangle appears sunken if \a sunken is true, otherwise
raised.
@@ -331,7 +331,7 @@ void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
{QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
+ with the \a fill brush unless \a fill is \nullptr.
The panel appears sunken if \a sunken is true, otherwise raised.
@@ -490,7 +490,7 @@ static void qDrawWinShades(QPainter *p,
Draws the Windows-style button specified by the given point (\a x,
\a y}, \a width and \a height using the provided \a painter with a
line width of 2 pixels. The button's interior is filled with the
- \a{fill} brush unless \a fill is 0.
+ \a{fill} brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
@@ -528,7 +528,7 @@ void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
Draws the Windows-style panel specified by the given point(\a x,
\a y), \a width and \a height using the provided \a painter with a
line width of 2 pixels. The button's interior is filled with the
- \a fill brush unless \a fill is 0.
+ \a fill brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors. The panel
appears sunken if \a sunken is true, otherwise raised.
@@ -567,7 +567,7 @@ void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
Draws the plain rectangle beginning at (\a x, \a y) with the given
\a width and \a height, using the specified \a painter, \a lineColor
and \a lineWidth. The rectangle's interior is filled with the \a
- fill brush unless \a fill is 0.
+ fill brush unless \a fill is \nullptr.
\warning This function does not look at QWidget::style() or
QApplication::style(). Use the drawing functions in QStyle to make
@@ -676,7 +676,7 @@ void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
specifies the line width for each of the lines; it is not the
total line width. The \a midLineWidth specifies the width of a
middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
+ interior is filled with the \a fill brush unless \a fill is \nullptr.
The rectangle appears sunken if \a sunken is true, otherwise
raised.
@@ -714,7 +714,7 @@ void qDrawShadeRect(QPainter *p, const QRect &r,
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
{QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
+ with the \a fill brush unless \a fill is \nullptr.
The panel appears sunken if \a sunken is true, otherwise raised.
@@ -746,7 +746,7 @@ void qDrawShadePanel(QPainter *p, const QRect &r,
Draws the Windows-style button at the rectangle specified by \a rect using
the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a{fill} brush unless \a fill is 0.
+ is filled with the \a{fill} brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors (\l
{QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
@@ -774,7 +774,7 @@ void qDrawWinButton(QPainter *p, const QRect &r,
Draws the Windows-style panel at the rectangle specified by \a rect using
the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a fill brush unless \a fill is 0.
+ is filled with the \a fill brush unless \a fill is \nullptr.
The given \a palette specifies the shading colors. The panel
appears sunken if \a sunken is true, otherwise raised.
@@ -804,7 +804,7 @@ void qDrawWinPanel(QPainter *p, const QRect &r,
Draws the plain rectangle specified by \a rect using the given \a painter,
\a lineColor and \a lineWidth. The rectangle's interior is filled with the
- \a fill brush unless \a fill is 0.
+ \a fill brush unless \a fill is \nullptr.
\warning This function does not look at QWidget::style() or
QApplication::style(). Use the drawing functions in QStyle to make
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 1646ec7583..45154ee647 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1590,7 +1590,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
(option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool()))
ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate
- if (!ignoreCheckMark) {
+ if (!ignoreCheckMark || menuItem->state & (State_On | State_Off)) {
// Check, using qreal and QRectF to avoid error accumulation
const qreal boxMargin = dpiScaled(3.5, option);
const qreal boxWidth = checkcol - 2 * boxMargin;
@@ -1601,7 +1601,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
if (checkable) {
if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
// Radio button
- if (checked || sunken) {
+ if (menuItem->state & State_On || checked || sunken) {
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(Qt::NoPen);
@@ -1617,8 +1617,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
QStyleOptionButton box;
box.QStyleOption::operator=(*option);
box.rect = checkRect;
- if (checked)
+ if (checked || menuItem->state & State_On)
box.state |= State_On;
+ else
+ box.state |= State_Off;
proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
}
}
@@ -2411,7 +2413,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
int oldMin = styleObject->property("_q_stylemin").toInt();
int oldMax = styleObject->property("_q_stylemax").toInt();
QRect oldRect = styleObject->property("_q_stylerect").toRect();
- QStyle::State oldState = static_cast<QStyle::State>(styleObject->property("_q_stylestate").value<QStyle::State::Int>());
+ QStyle::State oldState = static_cast<QStyle::State>(qvariant_cast<QStyle::State::Int>(styleObject->property("_q_stylestate")));
uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt();
// a scrollbar is transient when the scrollbar itself and
@@ -3684,7 +3686,7 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW
return 0;
case SH_Table_GridLineColor:
- return option ? option->palette.window().color().darker(120).rgb() : 0;
+ return option ? option->palette.window().color().darker(120).rgba() : 0;
case SH_MessageBox_TextInteractionFlags:
return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse;
diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp
index 5739678932..ecad637957 100644
--- a/src/widgets/styles/qproxystyle.cpp
+++ b/src/widgets/styles/qproxystyle.cpp
@@ -90,7 +90,7 @@ void QProxyStylePrivate::ensureBaseStyle() const
if (qstrcmp(baseStyle->metaObject()->className(),
q->metaObject()->className()) == 0) {
delete baseStyle;
- baseStyle = 0;
+ baseStyle = nullptr;
}
}
}
@@ -162,7 +162,7 @@ QStyle *QProxyStyle::baseStyle() const
Ownership of \a style is transferred to QProxyStyle.
- If style is zero, a desktop-dependant style will be
+ If style is \nullptr, a desktop-dependent style will be
assigned automatically.
*/
void QProxyStyle::setBaseStyle(QStyle *style)
@@ -403,7 +403,7 @@ QIcon QProxyStyle::standardIcon(StandardPixmap standardIcon,
orientation specifies whether the controls are laid out side by side
or stacked vertically. The \a option parameter can be used to pass
extra information about the parent widget. The \a widget parameter
- is optional and can also be used if \a option is 0.
+ is optional and can also be used if \a option is \nullptr.
The default implementation returns -1.
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 6cbed34c3a..987465efae 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1012,6 +1012,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SE_PushButtonFocusRect Area for the focus rect (usually
larger than the contents rect).
\value SE_PushButtonLayoutItem Area that counts for the parent layout.
+ \value SE_PushButtonBevel Area used for the bevel of the button.
\value SE_CheckBoxIndicator Area for the state indicator (e.g., check mark).
\value SE_CheckBoxContents Area for the label (text or pixmap).
@@ -1120,6 +1121,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\header \li Sub Element \li QStyleOption Subclass
\row \li \l SE_PushButtonContents \li \l QStyleOptionButton
\row \li \l SE_PushButtonFocusRect \li \l QStyleOptionButton
+ \row \li \l SE_PushButtonBevel \li \l QStyleOptionButton
\row \li \l SE_CheckBoxIndicator \li \l QStyleOptionButton
\row \li \l SE_CheckBoxContents \li \l QStyleOptionButton
\row \li \l SE_CheckBoxFocusRect \li \l QStyleOptionButton
@@ -1835,7 +1837,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SH_LineEdit_PasswordMaskDelay Determines the delay before visible character is masked
with password character, in milliseconds. This enum value was added in Qt 5.4.
- \value SH_Table_GridLineColor The RGB value of the grid for a table.
+ \value SH_Table_GridLineColor The RGBA value of the grid for a table.
\value SH_UnderlineShortcut Whether shortcuts are underlined.
@@ -2362,14 +2364,14 @@ QPalette QStyle::standardPalette() const
\fn int QStyle::layoutSpacing(QSizePolicy::ControlType control1,
QSizePolicy::ControlType control2, Qt::Orientation orientation,
- const QStyleOption *option = 0, const QWidget *widget = 0) const
+ const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const
Returns the spacing that should be used between \a control1 and
\a control2 in a layout. \a orientation specifies whether the
controls are laid out side by side or stacked vertically. The \a
option parameter can be used to pass extra information about the
parent widget. The \a widget parameter is optional and can also
- be used if \a option is 0.
+ be used if \a option is \nullptr.
This function is called by the layout system. It is used only if
PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
@@ -2386,7 +2388,7 @@ QPalette QStyle::standardPalette() const
controls are laid out side by side or stacked vertically. The \a
option parameter can be used to pass extra information about the
parent widget. The \a widget parameter is optional and can also
- be used if \a option is 0.
+ be used if \a option is \nullptr.
\a controls1 and \a controls2 are OR-combination of zero or more
\l{QSizePolicy::ControlTypes}{control types}.
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index ee234457f5..04628e6ef9 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -361,6 +361,8 @@ public:
SE_TabBarScrollRightButton,
SE_TabBarTearIndicatorRight,
+ SE_PushButtonBevel,
+
// do not add any values below/greater than this
SE_CustomBase = 0xf0000000
};
diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp
index b0ce5e52cf..2c4f6f83a1 100644
--- a/src/widgets/styles/qstylefactory.cpp
+++ b/src/widgets/styles/qstylefactory.cpp
@@ -88,7 +88,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
*/
QStyle *QStyleFactory::create(const QString& key)
{
- QStyle *ret = 0;
+ QStyle *ret = nullptr;
QString style = key.toLower();
#if QT_CONFIG(style_windows)
if (style == QLatin1String("windows"))
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 9477ca86da..61a59b03c1 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -132,7 +132,7 @@ bool isInstanceOf(QObject *obj, QAccessible::Role role)
bool hasAncestor(QObject *obj, QAccessible::Role role)
{
bool found = false;
- QObject *parent = obj ? obj->parent() : 0;
+ QObject *parent = obj ? obj->parent() : nullptr;
while (parent && !found) {
if (isInstanceOf(parent, role))
found = true;
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index be33069c07..95232dd97b 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -151,7 +151,7 @@ QT_BEGIN_NAMESPACE
QStyleOption::QStyleOption(int version, int type)
: version(version), type(type), state(QStyle::State_None),
- direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0)
+ direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()), styleObject(nullptr)
{
}
@@ -1470,6 +1470,22 @@ QStyleOptionTab::QStyleOptionTab(int version)
The default value is QSize(-1, -1), i.e. an invalid size;
*/
+/*!
+ Constructs a QStyleOptionTabV4 object, initializing the members
+ variables to their default values.
+ */
+
+QStyleOptionTabV4::QStyleOptionTabV4() : QStyleOptionTab(QStyleOptionTabV4::Version)
+{
+}
+
+/*!
+ \variable QStyleOptionTabV4::tabIndex
+ \brief the index for the tab being represented.
+
+ The default value is -1, i.e. a tab not on a tabbar;
+ */
+
#endif // QT_CONFIG(tabbar)
/*!
@@ -2909,7 +2925,7 @@ QStyleOptionRubberBand::QStyleOptionRubberBand(int version)
*/
QStyleOptionTitleBar::QStyleOptionTitleBar()
- : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0), titleBarFlags(0)
+ : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0)
{
}
@@ -2954,7 +2970,7 @@ QStyleOptionTitleBar::QStyleOptionTitleBar()
\internal
*/
QStyleOptionTitleBar::QStyleOptionTitleBar(int version)
- : QStyleOptionComplex(version, SO_TitleBar), titleBarState(0), titleBarFlags(0)
+ : QStyleOptionComplex(version, SO_TitleBar), titleBarState(0)
{
}
@@ -3085,7 +3101,7 @@ QStyleOptionViewItem::QStyleOptionViewItem()
: QStyleOption(Version, SO_ViewItem),
displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
textElideMode(Qt::ElideMiddle), decorationPosition(Left),
- showDecorationSelected(false), features(None), widget(0),
+ showDecorationSelected(false), features(None), widget(nullptr),
checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
{
}
@@ -3097,7 +3113,7 @@ QStyleOptionViewItem::QStyleOptionViewItem(int version)
: QStyleOption(version, SO_ViewItem),
displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft),
textElideMode(Qt::ElideMiddle), decorationPosition(Left),
- showDecorationSelected(false), features(None), widget(0),
+ showDecorationSelected(false), features(None), widget(nullptr),
checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid)
{
}
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 7f5edf4279..a8ce3b465e 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -296,6 +296,14 @@ protected:
QStyleOptionTab(int version);
};
+class Q_WIDGETS_EXPORT QStyleOptionTabV4 : public QStyleOptionTab
+{
+public:
+ enum StyleOptionVersion { Version = 4 };
+ QStyleOptionTabV4();
+ int tabIndex = -1;
+};
+
Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV2;
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index c694e9db97..1e032b237a 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -133,7 +133,7 @@ public:
};
-static QStyleSheetStyleCaches *styleSheetCaches = 0;
+static QStyleSheetStyleCaches *styleSheetCaches = nullptr;
/* RECURSION_GUARD:
* the QStyleSheetStyle is a proxy. If used with others proxy style, we may end up with something like:
@@ -144,16 +144,16 @@ static QStyleSheetStyleCaches *styleSheetCaches = 0;
* The first instance of QStyleSheetStyle will set globalStyleSheetStyle to itself. The second one
* will notice the globalStyleSheetStyle is not istelf and call its base style directly.
*/
-static const QStyleSheetStyle *globalStyleSheetStyle = 0;
+static const QStyleSheetStyle *globalStyleSheetStyle = nullptr;
class QStyleSheetStyleRecursionGuard
{
public:
QStyleSheetStyleRecursionGuard(const QStyleSheetStyle *that)
- : guarded(globalStyleSheetStyle == 0)
+ : guarded(globalStyleSheetStyle == nullptr)
{
if (guarded) globalStyleSheetStyle = that;
}
- ~QStyleSheetStyleRecursionGuard() { if (guarded) globalStyleSheetStyle = 0; }
+ ~QStyleSheetStyleRecursionGuard() { if (guarded) globalStyleSheetStyle = nullptr; }
bool guarded;
};
#define RECURSION_GUARD(RETURN) \
@@ -371,7 +371,7 @@ struct QStyleSheetBackgroundData : public QSharedData
struct QStyleSheetBorderData : public QSharedData
{
- QStyleSheetBorderData() : bi(0)
+ QStyleSheetBorderData() : bi(nullptr)
{
for (int i = 0; i < 4; i++) {
borders[i] = 0;
@@ -379,7 +379,7 @@ struct QStyleSheetBorderData : public QSharedData
}
}
- QStyleSheetBorderData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r) : bi(0)
+ QStyleSheetBorderData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r) : bi(nullptr)
{
for (int i = 0; i < 4; i++) {
borders[i] = b[i];
@@ -396,7 +396,7 @@ struct QStyleSheetBorderData : public QSharedData
const QStyleSheetBorderImageData *borderImage() const
{ return bi; }
- bool hasBorderImage() const { return bi!=0; }
+ bool hasBorderImage() const { return bi!=nullptr; }
QSharedDataPointer<QStyleSheetBorderImageData> bi;
@@ -413,7 +413,7 @@ struct QStyleSheetBorderData : public QSharedData
if (!radii[i].isEmpty())
return false;
}
- if (bi != 0 && bi->pixmap.hasAlpha())
+ if (bi != nullptr && bi->pixmap.hasAlpha())
return false;
return true;
}
@@ -479,7 +479,7 @@ struct QStyleSheetGeometryData : public QSharedData
struct QStyleSheetPositionData : public QSharedData
{
- QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = 0)
+ QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = { })
: left(l), top(t), bottom(b), right(r), origin(o), position(p), mode(m), textAlignment(a) { }
int left, top, bottom, right;
@@ -502,7 +502,7 @@ struct QStyleSheetImageData : public QSharedData
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() : features(0), hasFont(false), pal(nullptr), b(nullptr), bg(nullptr), bd(nullptr), ou(nullptr), geo(nullptr), p(nullptr), img(nullptr), clipset(0) { }
QRenderRule(const QVector<QCss::Declaration> &, const QObject *);
QRect borderRect(const QRect &r) const;
@@ -534,21 +534,22 @@ public:
const QStyleSheetOutlineData *outline() const { return ou; }
const QStyleSheetGeometryData *geometry() const { return geo; }
const QStyleSheetPositionData *position() const { return p; }
+ const QStyleSheetImageData *icon() const { return iconPtr; }
bool hasModification() const;
- bool hasPalette() const { return pal != 0; }
- bool hasBackground() const { return bg != 0 && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); }
+ bool hasPalette() const { return pal != nullptr; }
+ bool hasBackground() const { return bg != nullptr && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); }
bool hasGradientBackground() const { return bg && bg->brush.style() >= Qt::LinearGradientPattern
&& bg->brush.style() <= Qt::ConicalGradientPattern; }
bool hasNativeBorder() const {
- return bd == 0
+ return bd == nullptr
|| (!bd->hasBorderImage() && bd->styles[0] == BorderStyle_Native);
}
bool hasNativeOutline() const {
- return (ou == 0
+ return (ou == nullptr
|| (!ou->hasBorderImage() && ou->styles[0] == BorderStyle_Native));
}
@@ -562,13 +563,14 @@ public:
return features & StyleFeature_BackgroundColor;
}
- bool hasBox() const { return b != 0; }
- bool hasBorder() const { return bd != 0; }
- bool hasOutline() const { return ou != 0; }
- bool hasPosition() const { return p != 0; }
- bool hasGeometry() const { return geo != 0; }
+ bool hasBox() const { return b != nullptr; }
+ bool hasBorder() const { return bd != nullptr; }
+ bool hasOutline() const { return ou != nullptr; }
+ bool hasPosition() const { return p != nullptr; }
+ bool hasGeometry() const { return geo != nullptr; }
bool hasDrawable() const { return !hasNativeBorder() || hasBackground() || hasImage(); }
- bool hasImage() const { return img != 0; }
+ bool hasImage() const { return img != nullptr; }
+ bool hasIcon() const { return iconPtr != nullptr; }
QSize minimumContentsSize() const
{ return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); }
@@ -628,6 +630,7 @@ public:
QSharedDataPointer<QStyleSheetGeometryData> geo;
QSharedDataPointer<QStyleSheetPositionData> p;
QSharedDataPointer<QStyleSheetImageData> img;
+ QSharedDataPointer<QStyleSheetImageData> iconPtr;
int clipset;
QPainterPath clipPath;
@@ -907,7 +910,7 @@ static QStyle::StandardPixmap subControlIcon(int pe)
}
QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject *object)
-: features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0)
+: features(0), hasFont(false), pal(nullptr), b(nullptr), bg(nullptr), bd(nullptr), ou(nullptr), geo(nullptr), p(nullptr), img(nullptr), clipset(0)
{
QPalette palette = QGuiApplication::palette(); // ###: ideally widget's palette
ValueExtractor v(declarations, palette);
@@ -919,9 +922,9 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject
int left = 0, top = 0, right = 0, bottom = 0;
Origin origin = Origin_Unknown;
- Qt::Alignment position = 0;
+ Qt::Alignment position;
QCss::PositionMode mode = PositionMode_Unknown;
- Qt::Alignment textAlignment = 0;
+ Qt::Alignment textAlignment;
if (v.extractPosition(&left, &top, &right, &bottom, &origin, &position, &mode, &textAlignment))
p = new QStyleSheetPositionData(left, top, right, bottom, origin, position, mode, textAlignment);
@@ -969,11 +972,16 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject
if (v.extractPalette(&fg, &sfg, &sbg, &abg))
pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg);
- QIcon icon;
+ QIcon imgIcon;
alignment = Qt::AlignCenter;
+ QSize imgSize;
+ if (v.extractImage(&imgIcon, &alignment, &imgSize))
+ img = new QStyleSheetImageData(imgIcon, alignment, imgSize);
+
+ QIcon icon;
QSize size;
- if (v.extractImage(&icon, &alignment, &size))
- img = new QStyleSheetImageData(icon, alignment, size);
+ if (v.extractIcon(&icon, &size))
+ iconPtr = new QStyleSheetImageData(icon, Qt::AlignCenter, size);
int adj = -255;
hasFont = v.extractFont(&font, &adj);
@@ -1126,11 +1134,11 @@ QSize QRenderRule::boxSize(const QSize &cs, int flags) const
void QRenderRule::fixupBorder(int nativeWidth)
{
- if (bd == 0)
+ if (bd == nullptr)
return;
if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) {
- bd->bi = 0;
+ bd->bi = nullptr;
// ignore the color, border of edges that have none border-style
QBrush color = pal ? pal->foreground : QBrush();
const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid()
@@ -1507,7 +1515,7 @@ public:
do {
result += QString::fromLatin1(metaObject->className()).replace(QLatin1Char(':'), QLatin1Char('-'));
metaObject = metaObject->superClass();
- } while (metaObject != 0);
+ } while (metaObject != nullptr);
return result;
}
QString attribute(NodePtr node, const QString& name) const override
@@ -1531,7 +1539,7 @@ public:
return className;
} else if (name == QLatin1String("style")) {
QWidget *w = qobject_cast<QWidget *>(obj);
- QStyleSheetStyle *proxy = w ? qt_styleSheet(w->style()) : 0;
+ QStyleSheetStyle *proxy = w ? qt_styleSheet(w->style()) : nullptr;
if (proxy) {
QString styleName = QString::fromLatin1(proxy->baseStyle()->metaObject()->className());
cache[name] = styleName;
@@ -1539,11 +1547,10 @@ public:
}
}
}
- QString valueStr;
- if(value.type() == QVariant::StringList || value.type() == QVariant::List)
- valueStr = value.toStringList().join(QLatin1Char(' '));
- else
- valueStr = value.toString();
+ QString valueStr = (value.userType() == QMetaType::QStringList
+ || value.userType() == QMetaType::QVariantList)
+ ? value.toStringList().join(QLatin1Char(' '))
+ : value.toString();
cache[name] = valueStr;
return valueStr;
}
@@ -1567,7 +1574,7 @@ public:
if (uc == e && !*c)
return true;
metaObject = metaObject->superClass();
- } while (metaObject != 0);
+ } while (metaObject != nullptr);
return false;
}
bool hasAttributes(NodePtr) const override
@@ -1575,11 +1582,11 @@ public:
QStringList nodeIds(NodePtr node) const override
{ return isNullNode(node) ? QStringList() : QStringList(OBJECT_PTR(node)->objectName()); }
bool isNullNode(NodePtr node) const override
- { return node.ptr == 0; }
+ { return node.ptr == nullptr; }
NodePtr parentNode(NodePtr node) const override
- { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentObject(OBJECT_PTR(node)); return n; }
+ { NodePtr n; n.ptr = isNullNode(node) ? nullptr : parentObject(OBJECT_PTR(node)); return n; }
NodePtr previousSiblingNode(NodePtr) const override
- { NodePtr n; n.ptr = 0; return n; }
+ { NodePtr n; n.ptr = nullptr; return n; }
NodePtr duplicateNode(NodePtr node) const override
{ return node; }
void freeNode(NodePtr) const override
@@ -1692,22 +1699,22 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
#if QT_CONFIG(spinbox)
if (qobject_cast<const QAbstractSpinBox *>(w))
- return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w);
+ return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, nullptr, w);
#endif
#if QT_CONFIG(combobox)
if (qobject_cast<const QComboBox *>(w))
- return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w);
+ return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, nullptr, w);
#endif
#if QT_CONFIG(menu)
if (qobject_cast<const QMenu *>(w))
- return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w);
+ return base->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, w);
#endif
#if QT_CONFIG(menubar)
if (qobject_cast<const QMenuBar *>(w))
- return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w);
+ return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, w);
#endif
#ifndef QT_NO_FRAME
if (const QFrame *frame = qobject_cast<const QFrame *>(w)) {
@@ -1717,9 +1724,9 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
#endif
if (qstrcmp(w->metaObject()->className(), "QTipLabel") == 0)
- return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, w);
+ return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, w);
- return base->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, w);
+ return base->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, w);
}
static quint64 pseudoClass(QStyle::State state)
@@ -2223,7 +2230,7 @@ static Qt::Alignment defaultPosition(int pe)
return Qt::AlignRight | Qt::AlignVCenter;
default:
- return 0;
+ return { };
}
}
@@ -2235,21 +2242,21 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec
case PseudoElement_Indicator:
case PseudoElement_MenuCheckMark:
if (sz.width() == -1)
- sz.setWidth(base->pixelMetric(PM_IndicatorWidth, 0, w));
+ sz.setWidth(base->pixelMetric(PM_IndicatorWidth, nullptr, w));
if (sz.height() == -1)
- sz.setHeight(base->pixelMetric(PM_IndicatorHeight, 0, w));
+ sz.setHeight(base->pixelMetric(PM_IndicatorHeight, nullptr, w));
break;
case PseudoElement_ExclusiveIndicator:
case PseudoElement_GroupBoxIndicator:
if (sz.width() == -1)
- sz.setWidth(base->pixelMetric(PM_ExclusiveIndicatorWidth, 0, w));
+ sz.setWidth(base->pixelMetric(PM_ExclusiveIndicatorWidth, nullptr, w));
if (sz.height() == -1)
- sz.setHeight(base->pixelMetric(PM_ExclusiveIndicatorHeight, 0, w));
+ sz.setHeight(base->pixelMetric(PM_ExclusiveIndicatorHeight, nullptr, w));
break;
case PseudoElement_PushButtonMenuIndicator: {
- int pm = base->pixelMetric(PM_MenuButtonIndicator, 0, w);
+ int pm = base->pixelMetric(PM_MenuButtonIndicator, nullptr, w);
if (sz.width() == -1)
sz.setWidth(pm);
if (sz.height() == -1)
@@ -2283,12 +2290,12 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec
case PseudoElement_ToolButtonMenu:
if (sz.width() == -1)
- sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, 0, w));
+ sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, nullptr, w));
break;
case PseudoElement_HeaderViewUpArrow:
case PseudoElement_HeaderViewDownArrow: {
- int pm = base->pixelMetric(PM_HeaderMargin, 0, w);
+ int pm = base->pixelMetric(PM_HeaderMargin, nullptr, w);
if (sz.width() == -1)
sz.setWidth(pm);
if (sz.height() == 1)
@@ -2301,7 +2308,7 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec
case PseudoElement_ScrollBarAddLine:
case PseudoElement_ScrollBarSubLine:
case PseudoElement_ScrollBarSlider: {
- int pm = pixelMetric(QStyle::PM_ScrollBarExtent, 0, w);
+ int pm = pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, w);
if (sz.width() == -1)
sz.setWidth(pm);
if (sz.height() == -1)
@@ -2311,7 +2318,7 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec
case PseudoElement_DockWidgetCloseButton:
case PseudoElement_DockWidgetFloatButton: {
- int iconSize = pixelMetric(PM_SmallIconSize, 0, w);
+ int iconSize = pixelMetric(PM_SmallIconSize, nullptr, w);
return QSize(iconSize, iconSize);
}
@@ -2603,16 +2610,16 @@ void QStyleSheetStyle::setProperties(QWidget *w)
QVariant v;
const QVariant value = w->property(property.toLatin1());
- switch (value.type()) {
- case QVariant::Icon: v = decl.iconValue(); break;
- case QVariant::Image: v = QImage(decl.uriValue()); break;
- case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break;
- case QVariant::Rect: v = decl.rectValue(); break;
- case QVariant::Size: v = decl.sizeValue(); break;
- case QVariant::Color: v = decl.colorValue(); break;
- case QVariant::Brush: v = decl.brushValue(); break;
+ switch (value.userType()) {
+ case QMetaType::QIcon: v = decl.iconValue(); break;
+ case QMetaType::QImage: v = QImage(decl.uriValue()); break;
+ case QMetaType::QPixmap: v = QPixmap(decl.uriValue()); break;
+ case QMetaType::QRect: v = decl.rectValue(); break;
+ case QMetaType::QSize: v = decl.sizeValue(); break;
+ case QMetaType::QColor: v = decl.colorValue(); break;
+ case QMetaType::QBrush: v = decl.brushValue(); break;
#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break;
+ case QMetaType::QKeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break;
#endif
default: v = decl.d->values.at(0).variant; break;
}
@@ -2948,7 +2955,7 @@ void QStyleSheetStyle::unpolish(QWidget *w)
setGeometry(w);
w->setAttribute(Qt::WA_StyleSheetTarget, false);
w->setAttribute(Qt::WA_StyleSheet, false);
- QObject::disconnect(w, 0, this, 0);
+ QObject::disconnect(w, nullptr, this, nullptr);
#if QT_CONFIG(scrollarea)
if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
@@ -3334,7 +3341,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
layout = subControlLayout(QLatin1String("mNX"));
QStyleOptionComplex optCopy(*opt);
- optCopy.subControls = 0;
+ optCopy.subControls = { };
for (int i = 0; i < layout.count(); i++) {
int layoutButton = layout[i].toInt();
if (layoutButton < PseudoElement_MdiCloseButton
@@ -3388,7 +3395,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
tb->icon.paint(p, ir);
} else {
int iconSize = pixelMetric(PM_SmallIconSize, tb, w);
- pm = standardIcon(SP_TitleBarMenuButton, 0, w).pixmap(iconSize, iconSize);
+ pm = standardIcon(SP_TitleBarMenuButton, nullptr, w).pixmap(iconSize, iconSize);
drawItemPixmap(p, ir, Qt::AlignCenter, pm);
}
}
@@ -3400,9 +3407,9 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
QSize sz = subSubRule.contentsRect(ir).size();
if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool)
- pm = standardIcon(SP_DockWidgetCloseButton, 0, w).pixmap(sz);
+ pm = standardIcon(SP_DockWidgetCloseButton, nullptr, w).pixmap(sz);
else
- pm = standardIcon(SP_TitleBarCloseButton, 0, w).pixmap(sz);
+ pm = standardIcon(SP_TitleBarCloseButton, nullptr, w).pixmap(sz);
drawItemPixmap(p, ir, Qt::AlignCenter, pm);
}
@@ -3423,7 +3430,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
continue;
QRenderRule subSubRule = renderRule(w, opt, pe);
subSubRule.drawRule(p, ir);
- pm = standardIcon(subControlIcon(pe), 0, w).pixmap(subSubRule.contentsRect(ir).size());
+ pm = standardIcon(subControlIcon(pe), nullptr, w).pixmap(subSubRule.contentsRect(ir).size());
drawItemPixmap(p, ir, Qt::AlignCenter, pm);
}
@@ -3523,15 +3530,25 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (rule.hasFont)
p->setFont(rule.font.resolve(p->font()));
- if (rule.hasPosition() && rule.position()->textAlignment != 0) {
- Qt::Alignment textAlignment = rule.position()->textAlignment;
- QRect textRect = button->rect;
+ if (rule.hasPosition() || rule.hasIcon()) {
uint tf = Qt::TextShowMnemonic;
+ QRect textRect = button->rect;
+
+ const uint horizontalAlignMask = Qt::AlignHCenter | Qt::AlignLeft | Qt::AlignRight;
const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft;
- tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
- if (!styleHint(SH_UnderlineShortcut, button, w))
- tf |= Qt::TextHideMnemonic;
- if (!button->icon.isNull()) {
+
+ if (rule.hasPosition() && rule.position()->textAlignment != 0) {
+ Qt::Alignment textAlignment = rule.position()->textAlignment;
+ tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
+ tf |= (textAlignment & horizontalAlignMask) ? (textAlignment & horizontalAlignMask) : Qt::AlignHCenter;
+ if (!styleHint(SH_UnderlineShortcut, button, w))
+ tf |= Qt::TextHideMnemonic;
+ } else {
+ tf |= Qt::AlignVCenter | Qt::AlignHCenter;
+ }
+
+ QIcon icon = rule.hasIcon() ? rule.icon()->icon : button->icon;
+ if (!icon.isNull()) {
//Group both icon and text
QRect iconRect;
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
@@ -3541,7 +3558,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (button->state & State_On)
state = QIcon::On;
- QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
+ QPixmap pixmap = icon.pixmap(button->iconSize, mode, state);
int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
int labelWidth = pixmapWidth;
@@ -3552,10 +3569,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
labelWidth += (textWidth + iconSpacing);
//Determine label alignment:
- if (textAlignment & Qt::AlignLeft) { /*left*/
+ if (tf & Qt::AlignLeft) { /*left*/
iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2,
pixmapWidth, pixmapHeight);
- } else if (textAlignment & Qt::AlignHCenter) { /* center */
+ } else if (tf & Qt::AlignHCenter) { /* center */
iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
textRect.y() + (textRect.height() - labelHeight) / 2,
pixmapWidth, pixmapHeight);
@@ -3567,7 +3584,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
iconRect = visualRect(button->direction, textRect, iconRect);
- tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
+ // Left align, adjust the text-rect according to the icon instead
+ tf &= ~horizontalAlignMask;
+ tf |= Qt::AlignLeft;
if (button->direction == Qt::RightToLeft)
textRect.setRight(iconRect.left() - iconSpacing);
@@ -3578,9 +3597,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
pixelMetric(PM_ButtonShiftVertical, opt, w));
p->drawPixmap(iconRect, pixmap);
- } else {
- tf |= textAlignment;
}
+
if (button->state & (State_On | State_Sunken))
textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
pixelMetric(PM_ButtonShiftVertical, opt, w));
@@ -4228,7 +4246,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
}
r = subRule.contentsRect(r);
- Qt::Alignment alignment = 0;
+ Qt::Alignment alignment;
if (subRule.hasPosition())
alignment = subRule.position()->textAlignment;
if (alignment == 0)
@@ -4266,7 +4284,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (pe1 != PseudoElement_None) {
QRenderRule subRule = renderRule(w, opt, pe1);
- if (subRule.bg != 0 || subRule.hasDrawable()) {
+ if (subRule.bg != nullptr || subRule.hasDrawable()) {
//We test subRule.bg directly because hasBackground() would return false for background:none.
//But we still don't want the default drawning in that case (example for QScrollBar::add-page) (task 198926)
subRule.drawRule(p, opt->rect);
@@ -4629,7 +4647,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
}
if (baseStyle()->property("_q_styleSheetRealCloseButton").toBool())
- baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant(QVariant::Invalid));
+ baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant());
}
QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap,
@@ -5074,7 +5092,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
case CT_GroupBox:
case CT_LineEdit:
#if QT_CONFIG(spinbox)
- if (qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0))
+ if (qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : nullptr))
return csz; // we only care about the size hint of the line edit
#endif
if (rule.hasBox() || !rule.hasNativeBorder()) {
@@ -5715,7 +5733,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove);
if (!subRule.hasDrawable())
break;
- subRule.img = 0;
+ subRule.img = nullptr;
QRect gr = positionRect(w, rule, subRule, PseudoElement_SliderGroove, opt->rect, opt->direction);
switch (sc) {
case SC_SliderGroove:
@@ -5725,8 +5743,8 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
QRect cr = subRule.contentsRect(gr);
QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderHandle);
int len = horizontal ? subRule2.size().width() : subRule2.size().height();
- subRule2.img = 0;
- subRule2.geo = 0;
+ subRule2.img = nullptr;
+ subRule2.geo = nullptr;
cr = positionRect(w, subRule2, PseudoElement_SliderHandle, cr, opt->direction);
int thickness = horizontal ? cr.height() : cr.width();
int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
@@ -5834,7 +5852,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
QRect ir = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator,
opt, w);
ir = visualRect(opt->direction, opt->rect, ir);
- int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, 0, w);
+ int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, nullptr, w);
QRect cr = rule.contentsRect(opt->rect);
ir.setRect(ir.left() + ir.width() + spacing, cr.y(),
cr.width() - ir.width() - spacing, cr.height());
@@ -5991,6 +6009,16 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
case SE_TabBarTabRightButton: {
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
if (subRule.hasBox() || !subRule.hasNativeBorder()) {
+ if (se == SE_TabBarTabText) {
+ if (const QStyleOptionTabV4 *tab = qstyleoption_cast<const QStyleOptionTabV4 *>(opt)) {
+ const QTabBar *bar = qobject_cast<const QTabBar *>(w);
+ const QRect optRect = bar && tab->tabIndex != -1 ? bar->tabRect(tab->tabIndex) : opt->rect;
+ const QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, optRect, opt->direction);
+ QStyleOptionTabV4 tabCopy(*tab);
+ tabCopy.rect = subRule.contentsRect(r);
+ return ParentStyle::subElementRect(se, &tabCopy, w);
+ }
+ }
return ParentStyle::subElementRect(se, opt, w);
}
break;
@@ -6099,7 +6127,7 @@ void QStyleSheetStyle::saveWidgetFont(QWidget* w, const QFont& font) const
void QStyleSheetStyle::clearWidgetFont(QWidget* w) const
{
- w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid));
+ w->setProperty("_q_styleSheetWidgetFont", QVariant());
}
// Polish palette that should be used for a particular widget, with particular states
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 4f8cc56e05..8eb24d7557 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -84,6 +84,7 @@
#include <qpa/qplatformscreen.h>
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
+#include <qpa/qplatformnativeinterface.h>
#include <private/qwidget_p.h>
#include <private/qstylehelper_p.h>
@@ -127,6 +128,22 @@ qreal QWindowsStylePrivate::appDevicePixelRatio()
return qApp->devicePixelRatio();
}
+bool QWindowsStylePrivate::isDarkMode()
+{
+ bool result = false;
+#ifdef Q_OS_WIN
+ // Windows only: Return whether dark mode style support is desired and
+ // dark mode is in effect.
+ if (auto ni = QGuiApplication::platformNativeInterface()) {
+ const QVariant darkModeStyleP = ni->property("darkModeStyle");
+ result = darkModeStyleP.type() == QVariant::Bool
+ && darkModeStyleP.value<bool>()
+ && ni->property("darkMode").value<bool>();
+ }
+#endif
+ return result;
+}
+
// Returns \c true if the toplevel parent of \a widget has seen the Alt-key
bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const
{
@@ -1675,7 +1692,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
const bool vertical = pb->orientation == Qt::Vertical;
const bool inverted = pb->invertedAppearance;
- QMatrix m;
+ QTransform m;
if (vertical) {
rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
m.rotate(90);
diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h
index 4f6ffcefc2..a25f5c4166 100644
--- a/src/widgets/styles/qwindowsstyle_p_p.h
+++ b/src/widgets/styles/qwindowsstyle_p_p.h
@@ -74,6 +74,7 @@ public:
static qreal devicePixelRatio(const QWidget *widget = nullptr)
{ return widget ? widget->devicePixelRatioF() : QWindowsStylePrivate::appDevicePixelRatio(); }
static qreal nativeMetricScaleFactor(const QWidget *widget = nullptr);
+ static bool isDarkMode();
bool hasSeenAlt(const QWidget *widget) const;
bool altDown() const { return alt_down; }
diff --git a/src/widgets/util/qcolormap.cpp b/src/widgets/util/qcolormap.cpp
index 6dacc97261..57e61690e9 100644
--- a/src/widgets/util/qcolormap.cpp
+++ b/src/widgets/util/qcolormap.cpp
@@ -59,7 +59,7 @@ public:
int numcolors;
};
-static QColormapPrivate *screenMap = 0;
+static QColormapPrivate *screenMap = nullptr;
void QColormap::initialize()
{
@@ -83,7 +83,7 @@ void QColormap::initialize()
void QColormap::cleanup()
{
delete screenMap;
- screenMap = 0;
+ screenMap = nullptr;
}
QColormap QColormap::instance(int /*screen*/)
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 7b69eff30c..72fa557790 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -473,7 +473,7 @@ QMatchData QCompletionEngine::filterHistory()
if (curParts.count() <= 1 || c->proxy->showAll || !source)
return QMatchData();
-#if QT_CONFIG(dirmodel)
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
const bool isDirModel = (qobject_cast<QDirModel *>(source) != nullptr);
#else
const bool isDirModel = false;
@@ -903,7 +903,7 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted)
QModelIndex si = proxy->mapToSource(index);
si = si.sibling(si.row(), column); // for clicked()
completion = q->pathFromIndex(si);
-#if QT_CONFIG(dirmodel)
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
// add a trailing separator in inline
if (mode == QCompleter::InlineCompletion) {
if (qobject_cast<QDirModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
@@ -1125,7 +1125,7 @@ void QCompleter::setModel(QAbstractItemModel *model)
setPopup(d->popup); // set the model and make new connections
if (oldModel && oldModel->QObject::parent() == this)
delete oldModel;
-#if QT_CONFIG(dirmodel)
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
if (qobject_cast<QDirModel *>(model)) {
#if defined(Q_OS_WIN)
setCaseSensitivity(Qt::CaseInsensitive);
@@ -1262,7 +1262,7 @@ Qt::MatchFlags QCompleter::filterMode() const
void QCompleter::setPopup(QAbstractItemView *popup)
{
Q_D(QCompleter);
- Q_ASSERT(popup != 0);
+ Q_ASSERT(popup != nullptr);
if (d->popup) {
QObject::disconnect(d->popup->selectionModel(), nullptr, this, nullptr);
QObject::disconnect(d->popup, nullptr, this, nullptr);
@@ -1846,7 +1846,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const
return QString();
bool isDirModel = false;
bool isFsModel = false;
-#if QT_CONFIG(dirmodel)
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != nullptr;
#endif
#if QT_CONFIG(filesystemmodel)
@@ -1895,7 +1895,7 @@ QStringList QCompleter::splitPath(const QString& path) const
{
bool isDirModel = false;
bool isFsModel = false;
-#if QT_CONFIG(dirmodel)
+#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15)
Q_D(const QCompleter);
isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != nullptr;
#endif
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 14a30ce7cf..064be873b9 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -114,19 +114,19 @@ static QMouseEvent *copyMouseEvent(QEvent *e)
}
#endif // QT_CONFIG(graphicsview)
default:
- return 0;
+ return nullptr;
}
}
class PressDelayHandler : public QObject
{
private:
- PressDelayHandler(QObject *parent = 0)
+ PressDelayHandler(QObject *parent = nullptr)
: QObject(parent)
, pressDelayTimer(0)
, sendingEvent(false)
, mouseButton(Qt::NoButton)
- , mouseTarget(0)
+ , mouseTarget(nullptr)
, mouseEventSource(Qt::MouseEventNotSynthesized)
{ }
@@ -138,7 +138,7 @@ public:
static PressDelayHandler *instance()
{
- static PressDelayHandler *inst = 0;
+ static PressDelayHandler *inst = nullptr;
if (!inst)
inst = new PressDelayHandler(QCoreApplication::instance());
return inst;
@@ -192,10 +192,10 @@ public:
result = true; // consume this event
} else if (mouseTarget && scrollerIsActive) {
// we grabbed the mouse expicitly when the scroller became active, so undo that now
- sendMouseEvent(0, UngrabMouseBefore);
+ sendMouseEvent(nullptr, UngrabMouseBefore);
}
- pressDelayEvent.reset(0);
- mouseTarget = 0;
+ pressDelayEvent.reset(nullptr);
+ mouseTarget = nullptr;
return result;
}
@@ -208,9 +208,9 @@ public:
killTimer(pressDelayTimer);
pressDelayTimer = 0;
}
- pressDelayEvent.reset(0);
+ pressDelayEvent.reset(nullptr);
}
- mouseTarget = 0;
+ mouseTarget = nullptr;
}
void scrollerBecameActive()
@@ -222,8 +222,8 @@ public:
killTimer(pressDelayTimer);
pressDelayTimer = 0;
}
- pressDelayEvent.reset(0);
- mouseTarget = 0;
+ pressDelayEvent.reset(nullptr);
+ mouseTarget = nullptr;
} else if (mouseTarget) {
// we did send a press, so we need to fake a release now
@@ -261,7 +261,7 @@ protected:
qFGDebug() << "QFG: timer event: re-sending mouse press to " << mouseTarget;
sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore);
}
- pressDelayEvent.reset(0);
+ pressDelayEvent.reset(nullptr);
if (pressDelayTimer) {
killTimer(pressDelayTimer);
@@ -276,7 +276,7 @@ protected:
sendingEvent = true;
#if QT_CONFIG(graphicsview)
- QGraphicsItem *grabber = 0;
+ QGraphicsItem *grabber = nullptr;
if (mouseTarget->parentWidget()) {
if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) {
if (gv->scene())
@@ -350,7 +350,7 @@ QFlickGesture::QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject
{
d_func()->q_ptr = this;
d_func()->receiver = receiver;
- d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : 0;
+ d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : nullptr;
d_func()->button = button;
}
@@ -358,7 +358,7 @@ QFlickGesture::~QFlickGesture()
{ }
QFlickGesturePrivate::QFlickGesturePrivate()
- : receiverScroller(0), button(Qt::NoButton), macIgnoreWheel(false)
+ : receiverScroller(nullptr), button(Qt::NoButton), macIgnoreWheel(false)
{ }
@@ -420,11 +420,11 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
return Ignore;
}
- const QMouseEvent *me = 0;
+ const QMouseEvent *me = nullptr;
#if QT_CONFIG(graphicsview)
- const QGraphicsSceneMouseEvent *gsme = 0;
+ const QGraphicsSceneMouseEvent *gsme = nullptr;
#endif
- const QTouchEvent *te = 0;
+ const QTouchEvent *te = nullptr;
QPoint globalPos;
// qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button;
@@ -610,7 +610,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
}
// depending on the scroller state return the gesture state
- Result result(0);
+ Result result;
bool scrollerIsActive = (scroller->state() == QScroller::Dragging ||
scroller->state() == QScroller::Scrolling);
diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index df05bbf71c..fec373d45c 100644
--- a/src/widgets/util/qscroller.cpp
+++ b/src/widgets/util/qscroller.cpp
@@ -300,7 +300,7 @@ QScroller *QScroller::scroller(QObject *target)
{
if (!target) {
qWarning("QScroller::scroller() was called with a null target.");
- return 0;
+ return nullptr;
}
if (qt_allScrollers()->contains(target))
@@ -476,7 +476,7 @@ void QScroller::ungrabGesture(QObject *target)
QGestureRecognizer::unregisterRecognizer(sp->recognizerType);
// do not delete the recognizer. The QGestureManager is doing this.
- sp->recognizer = 0;
+ sp->recognizer = nullptr;
}
#endif // QT_NO_GESTURES
@@ -502,7 +502,7 @@ QScroller::~QScroller()
#ifndef QT_NO_GESTURES
QGestureRecognizer::unregisterRecognizer(d->recognizerType);
// do not delete the recognizer. The QGestureManager is doing this.
- d->recognizer = 0;
+ d->recognizer = nullptr;
#endif
qt_allScrollers()->remove(d->target);
qt_activeScrollers()->removeOne(this);
@@ -879,7 +879,7 @@ void QScroller::setSnapPositionsY(qreal first, qreal interval)
QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
: target(_target)
#ifndef QT_NO_GESTURES
- , recognizer(0)
+ , recognizer(nullptr)
, recognizerType(Qt::CustomGesture)
#endif
, state(QScroller::Inactive)
@@ -900,7 +900,7 @@ QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
void QScrollerPrivate::init()
{
- setDpiFromWidget(0);
+ setDpiFromWidget(nullptr);
monotonicTimer.start();
}
diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp
index df6b899fe4..be763f182e 100644
--- a/src/widgets/util/qscrollerproperties.cpp
+++ b/src/widgets/util/qscrollerproperties.cpp
@@ -46,8 +46,8 @@
QT_BEGIN_NAMESPACE
-static QScrollerPropertiesPrivate *userDefaults = 0;
-static QScrollerPropertiesPrivate *systemDefaults = 0;
+static QScrollerPropertiesPrivate *userDefaults = nullptr;
+static QScrollerPropertiesPrivate *systemDefaults = nullptr;
QScrollerPropertiesPrivate *QScrollerPropertiesPrivate::defaults()
{
@@ -200,7 +200,7 @@ void QScrollerProperties::setDefaultScrollerProperties(const QScrollerProperties
void QScrollerProperties::unsetDefaultScrollerProperties()
{
delete userDefaults;
- userDefaults = 0;
+ userDefaults = nullptr;
}
/*!
@@ -261,9 +261,9 @@ void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &v
case OvershootDragDistanceFactor: d->overshootDragDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
case OvershootScrollDistanceFactor: d->overshootScrollDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
case OvershootScrollTime: d->overshootScrollTime = value.toReal(); break;
- case HorizontalOvershootPolicy: d->hOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
- case VerticalOvershootPolicy: d->vOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
- case FrameRate: d->frameRate = value.value<QScrollerProperties::FrameRates>(); break;
+ case HorizontalOvershootPolicy: d->hOvershootPolicy = qvariant_cast<QScrollerProperties::OvershootPolicy>(value); break;
+ case VerticalOvershootPolicy: d->vOvershootPolicy = qvariant_cast<QScrollerProperties::OvershootPolicy>(value); break;
+ case FrameRate: d->frameRate = qvariant_cast<QScrollerProperties::FrameRates>(value); break;
case ScrollMetricCount: break;
}
}
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index fd18888870..ee52139913 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -367,8 +367,6 @@ bool QSystemTrayIcon::event(QEvent *e)
This signal is emitted when the message displayed using showMessage()
was clicked by the user.
- Currently this signal is not sent on \macos.
-
\note We follow Microsoft Windows behavior, so the
signal is also emitted when the user clicks on a tray icon with
a balloon message displayed.
@@ -455,7 +453,7 @@ void QSystemTrayIconPrivate::_q_emitActivated(QPlatformSystemTrayIcon::Activatio
}
//////////////////////////////////////////////////////////////////////
-static QBalloonTip *theSolitaryBalloonTip = 0;
+static QBalloonTip *theSolitaryBalloonTip = nullptr;
void QBalloonTip::showBalloon(const QIcon &icon, const QString &title,
const QString &message, QSystemTrayIcon *trayIcon,
@@ -477,7 +475,7 @@ void QBalloonTip::hideBalloon()
return;
theSolitaryBalloonTip->hide();
delete theSolitaryBalloonTip;
- theSolitaryBalloonTip = 0;
+ theSolitaryBalloonTip = nullptr;
}
void QBalloonTip::updateBalloonPosition(const QPoint& pos)
@@ -495,7 +493,7 @@ bool QBalloonTip::isBalloonVisible()
QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
const QString &message, QSystemTrayIcon *ti)
- : QWidget(0, Qt::ToolTip),
+ : QWidget(nullptr, Qt::ToolTip),
trayIcon(ti),
timerId(-1),
showArrow(true)
@@ -585,7 +583,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
QBalloonTip::~QBalloonTip()
{
- theSolitaryBalloonTip = 0;
+ theSolitaryBalloonTip = nullptr;
}
void QBalloonTip::paintEvent(QPaintEvent *)
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 0c7bb94a91..86c11f98ed 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -97,7 +97,7 @@ private:
};
QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn)
- : QWidget(0, Qt::Window | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint)
+ : QWidget(nullptr, Qt::Window | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint)
, q(qIn)
{
setObjectName(QStringLiteral("QSystemTrayIconSys"));
@@ -218,7 +218,7 @@ private:
////////////////////////////////////////////////////////////////////////////
QSystemTrayIconPrivate::QSystemTrayIconPrivate()
- : sys(0),
+ : sys(nullptr),
qpa_sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon()),
visible(false),
trayWatcher(nullptr)
diff --git a/src/widgets/util/qundogroup.cpp b/src/widgets/util/qundogroup.cpp
index 9bd63d4232..ae439743bc 100644
--- a/src/widgets/util/qundogroup.cpp
+++ b/src/widgets/util/qundogroup.cpp
@@ -47,7 +47,7 @@ class QUndoGroupPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QUndoGroup)
public:
- QUndoGroupPrivate() : active(0) {}
+ QUndoGroupPrivate() : active(nullptr) {}
QUndoStack *active;
QList<QUndoStack*> stack_list;
@@ -113,7 +113,7 @@ QUndoGroup::~QUndoGroup()
QList<QUndoStack *>::iterator it = d->stack_list.begin();
QList<QUndoStack *>::iterator end = d->stack_list.end();
while (it != end) {
- (*it)->d_func()->group = 0;
+ (*it)->d_func()->group = nullptr;
++it;
}
}
@@ -154,8 +154,8 @@ void QUndoGroup::removeStack(QUndoStack *stack)
if (d->stack_list.removeAll(stack) == 0)
return;
if (stack == d->active)
- setActiveStack(0);
- stack->d_func()->group = 0;
+ setActiveStack(nullptr);
+ stack->d_func()->group = nullptr;
}
/*!
@@ -190,7 +190,7 @@ void QUndoGroup::setActiveStack(QUndoStack *stack)
if (d->active == stack)
return;
- if (d->active != 0) {
+ if (d->active != nullptr) {
disconnect(d->active, SIGNAL(canUndoChanged(bool)),
this, SIGNAL(canUndoChanged(bool)));
disconnect(d->active, SIGNAL(undoTextChanged(QString)),
@@ -207,7 +207,7 @@ void QUndoGroup::setActiveStack(QUndoStack *stack)
d->active = stack;
- if (d->active == 0) {
+ if (d->active == nullptr) {
emit canUndoChanged(false);
emit undoTextChanged(QString());
emit canRedoChanged(false);
@@ -265,7 +265,7 @@ QUndoStack *QUndoGroup::activeStack() const
void QUndoGroup::undo()
{
Q_D(QUndoGroup);
- if (d->active != 0)
+ if (d->active != nullptr)
d->active->undo();
}
@@ -282,7 +282,7 @@ void QUndoGroup::undo()
void QUndoGroup::redo()
{
Q_D(QUndoGroup);
- if (d->active != 0)
+ if (d->active != nullptr)
d->active->redo();
}
@@ -298,7 +298,7 @@ void QUndoGroup::redo()
bool QUndoGroup::canUndo() const
{
Q_D(const QUndoGroup);
- return d->active != 0 && d->active->canUndo();
+ return d->active != nullptr && d->active->canUndo();
}
/*!
@@ -313,7 +313,7 @@ bool QUndoGroup::canUndo() const
bool QUndoGroup::canRedo() const
{
Q_D(const QUndoGroup);
- return d->active != 0 && d->active->canRedo();
+ return d->active != nullptr && d->active->canRedo();
}
/*!
@@ -328,7 +328,7 @@ bool QUndoGroup::canRedo() const
QString QUndoGroup::undoText() const
{
Q_D(const QUndoGroup);
- return d->active == 0 ? QString() : d->active->undoText();
+ return d->active == nullptr ? QString() : d->active->undoText();
}
/*!
@@ -343,7 +343,7 @@ QString QUndoGroup::undoText() const
QString QUndoGroup::redoText() const
{
Q_D(const QUndoGroup);
- return d->active == 0 ? QString() : d->active->redoText();
+ return d->active == nullptr ? QString() : d->active->redoText();
}
/*!
@@ -358,7 +358,7 @@ QString QUndoGroup::redoText() const
bool QUndoGroup::isClean() const
{
Q_D(const QUndoGroup);
- return d->active == 0 || d->active->isClean();
+ return d->active == nullptr || d->active->isClean();
}
#ifndef QT_NO_ACTION
diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp
index 8788c42252..f188b8298a 100644
--- a/src/widgets/util/qundostack.cpp
+++ b/src/widgets/util/qundostack.cpp
@@ -128,7 +128,7 @@ QUndoCommand::QUndoCommand(const QString &text, QUndoCommand *parent)
QUndoCommand::QUndoCommand(QUndoCommand *parent)
{
d = new QUndoCommandPrivate;
- if (parent != 0)
+ if (parent != nullptr)
parent->d->child_list.append(this);
}
@@ -336,7 +336,7 @@ int QUndoCommand::childCount() const
const QUndoCommand *QUndoCommand::child(int index) const
{
if (index < 0 || index >= d->child_list.count())
- return 0;
+ return nullptr;
return d->child_list.at(index);
}
@@ -559,7 +559,7 @@ QUndoStack::~QUndoStack()
{
#if QT_CONFIG(undogroup)
Q_D(QUndoStack);
- if (d->group != 0)
+ if (d->group != nullptr)
d->group->removeStack(this);
#endif
clear();
@@ -640,7 +640,7 @@ void QUndoStack::push(QUndoCommand *cmd)
bool macro = !d->macro_stack.isEmpty();
- QUndoCommand *cur = 0;
+ QUndoCommand *cur = nullptr;
if (macro) {
QUndoCommand *macro_cmd = d->macro_stack.constLast();
if (!macro_cmd->d->child_list.isEmpty())
@@ -654,7 +654,7 @@ void QUndoStack::push(QUndoCommand *cmd)
d->clean_index = -1; // we've deleted the clean state
}
- bool try_merge = cur != 0
+ bool try_merge = cur != nullptr
&& cur->id() != -1
&& cur->id() == cmd->id()
&& (macro || d->index != d->clean_index);
@@ -1225,7 +1225,7 @@ const QUndoCommand *QUndoStack::command(int index) const
Q_D(const QUndoStack);
if (index < 0 || index >= d->command_list.count())
- return 0;
+ return nullptr;
return d->command_list.at(index);
}
@@ -1305,11 +1305,11 @@ void QUndoStack::setActive(bool active)
#else
Q_D(QUndoStack);
- if (d->group != 0) {
+ if (d->group != nullptr) {
if (active)
d->group->setActiveStack(this);
else if (d->group->activeStack() == this)
- d->group->setActiveStack(0);
+ d->group->setActiveStack(nullptr);
}
#endif
}
@@ -1320,7 +1320,7 @@ bool QUndoStack::isActive() const
return true;
#else
Q_D(const QUndoStack);
- return d->group == 0 || d->group->activeStack() == this;
+ return d->group == nullptr || d->group->activeStack() == this;
#endif
}
diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp
index f59d87fb9d..a39276a2b8 100644
--- a/src/widgets/util/qundoview.cpp
+++ b/src/widgets/util/qundoview.cpp
@@ -54,7 +54,7 @@ class QUndoModel : public QAbstractItemModel
{
Q_OBJECT
public:
- QUndoModel(QObject *parent = 0);
+ QUndoModel(QObject *parent = nullptr);
QUndoStack *stack() const;
@@ -92,7 +92,7 @@ private:
QUndoModel::QUndoModel(QObject *parent)
: QAbstractItemModel(parent)
{
- m_stack = 0;
+ m_stack = nullptr;
m_sel_model = new QItemSelectionModel(this, this);
connect(m_sel_model, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(setStackCurrentIndex(QModelIndex)));
@@ -114,13 +114,13 @@ void QUndoModel::setStack(QUndoStack *stack)
if (m_stack == stack)
return;
- if (m_stack != 0) {
+ if (m_stack != nullptr) {
disconnect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged()));
disconnect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged()));
disconnect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*)));
}
m_stack = stack;
- if (m_stack != 0) {
+ if (m_stack != nullptr) {
connect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged()));
connect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged()));
connect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*)));
@@ -133,7 +133,7 @@ void QUndoModel::stackDestroyed(QObject *obj)
{
if (obj != m_stack)
return;
- m_stack = 0;
+ m_stack = nullptr;
stackChanged();
}
@@ -147,7 +147,7 @@ void QUndoModel::stackChanged()
void QUndoModel::setStackCurrentIndex(const QModelIndex &index)
{
- if (m_stack == 0)
+ if (m_stack == nullptr)
return;
if (index == selectedIndex())
@@ -161,12 +161,12 @@ void QUndoModel::setStackCurrentIndex(const QModelIndex &index)
QModelIndex QUndoModel::selectedIndex() const
{
- return m_stack == 0 ? QModelIndex() : createIndex(m_stack->index(), 0);
+ return m_stack == nullptr ? QModelIndex() : createIndex(m_stack->index(), 0);
}
QModelIndex QUndoModel::index(int row, int column, const QModelIndex &parent) const
{
- if (m_stack == 0)
+ if (m_stack == nullptr)
return QModelIndex();
if (parent.isValid())
@@ -188,7 +188,7 @@ QModelIndex QUndoModel::parent(const QModelIndex&) const
int QUndoModel::rowCount(const QModelIndex &parent) const
{
- if (m_stack == 0)
+ if (m_stack == nullptr)
return 0;
if (parent.isValid())
@@ -204,7 +204,7 @@ int QUndoModel::columnCount(const QModelIndex&) const
QVariant QUndoModel::data(const QModelIndex &index, int role) const
{
- if (m_stack == 0)
+ if (m_stack == nullptr)
return QVariant();
if (index.column() != 0)
@@ -274,9 +274,9 @@ class QUndoViewPrivate : public QListViewPrivate
public:
QUndoViewPrivate() :
#if QT_CONFIG(undogroup)
- group(0),
+ group(nullptr),
#endif
- model(0) {}
+ model(nullptr) {}
#if QT_CONFIG(undogroup)
QPointer<QUndoGroup> group;
@@ -358,8 +358,8 @@ QUndoStack *QUndoView::stack() const
}
/*!
- Sets the stack displayed by this view to \a stack. If \a stack is 0, the view
- will be empty.
+ Sets the stack displayed by this view to \a stack. If \a stack is \nullptr,
+ the view will be empty.
If the view was previously looking at a QUndoGroup, the group is set to \nullptr.
@@ -370,7 +370,7 @@ void QUndoView::setStack(QUndoStack *stack)
{
Q_D(QUndoView);
#if QT_CONFIG(undogroup)
- setGroup(0);
+ setGroup(nullptr);
#endif
d->model->setStack(stack);
}
@@ -378,10 +378,10 @@ void QUndoView::setStack(QUndoStack *stack)
#if QT_CONFIG(undogroup)
/*!
- Sets the group displayed by this view to \a group. If \a group is 0, the view will
- be empty.
+ Sets the group displayed by this view to \a group. If \a group is \nullptr,
+ the view will be empty.
- The view will update itself autmiatically whenever the active stack of the group changes.
+ The view will update itself automatically whenever the active stack of the group changes.
\sa group(), setStack()
*/
@@ -393,19 +393,19 @@ void QUndoView::setGroup(QUndoGroup *group)
if (d->group == group)
return;
- if (d->group != 0) {
+ if (d->group != nullptr) {
disconnect(d->group, SIGNAL(activeStackChanged(QUndoStack*)),
d->model, SLOT(setStack(QUndoStack*)));
}
d->group = group;
- if (d->group != 0) {
+ if (d->group != nullptr) {
connect(d->group, SIGNAL(activeStackChanged(QUndoStack*)),
d->model, SLOT(setStack(QUndoStack*)));
d->model->setStack(d->group->activeStack());
} else {
- d->model->setStack(0);
+ d->model->setStack(nullptr);
}
}
diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro
index 6f807e1696..2d5ba05d40 100644
--- a/src/widgets/widgets.pro
+++ b/src/widgets/widgets.pro
@@ -45,3 +45,5 @@ testcocoon {
MODULE_PLUGIN_TYPES += \
styles
load(qt_module)
+
+CONFIG += metatypes install_metatypes
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index d956d2ba23..7961d0a21b 100644
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -177,7 +177,7 @@ QAbstractButtonPrivate::QAbstractButtonPrivate(QSizePolicy::ControlType type)
checkable(false), checked(false), autoRepeat(false), autoExclusive(false),
down(false), blockRefresh(false), pressed(false),
#if QT_CONFIG(buttongroup)
- group(0),
+ group(nullptr),
#endif
autoRepeatDelay(AUTO_REPEAT_DELAY),
autoRepeatInterval(AUTO_REPEAT_INTERVAL),
@@ -217,14 +217,14 @@ QAbstractButton *QAbstractButtonPrivate::queryCheckedButton() const
Q_Q(const QAbstractButton);
QList<QAbstractButton *> buttonList = queryButtonList();
if (!autoExclusive || buttonList.count() == 1) // no group
- return 0;
+ return nullptr;
for (int i = 0; i < buttonList.count(); ++i) {
QAbstractButton *b = buttonList.at(i);
if (b->d_func()->checked && b != q)
return b;
}
- return checked ? const_cast<QAbstractButton *>(q) : 0;
+ return checked ? const_cast<QAbstractButton *>(q) : nullptr;
}
void QAbstractButtonPrivate::notifyChecked()
@@ -257,7 +257,7 @@ void QAbstractButtonPrivate::moveFocus(int key)
if (!fb || !buttonList.contains(fb))
return;
- QAbstractButton *candidate = 0;
+ QAbstractButton *candidate = nullptr;
int bestScore = -1;
QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));
QPoint goal = target.center();
@@ -415,8 +415,13 @@ void QAbstractButtonPrivate::emitClicked()
emit q->clicked(checked);
#if QT_CONFIG(buttongroup)
if (guard && group) {
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit group->buttonClicked(group->id(q));
if (guard && group)
+QT_WARNING_POP
+#endif
emit group->buttonClicked(q);
}
#endif
@@ -429,8 +434,13 @@ void QAbstractButtonPrivate::emitPressed()
emit q->pressed();
#if QT_CONFIG(buttongroup)
if (guard && group) {
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit group->buttonPressed(group->id(q));
if (guard && group)
+QT_WARNING_POP
+#endif
emit group->buttonPressed(q);
}
#endif
@@ -443,8 +453,13 @@ void QAbstractButtonPrivate::emitReleased()
emit q->released();
#if QT_CONFIG(buttongroup)
if (guard && group) {
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit group->buttonReleased(group->id(q));
if (guard && group)
+QT_WARNING_POP
+#endif
emit group->buttonReleased(q);
}
#endif
@@ -457,8 +472,13 @@ void QAbstractButtonPrivate::emitToggled(bool checked)
emit q->toggled(checked);
#if QT_CONFIG(buttongroup)
if (guard && group) {
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit group->buttonToggled(group->id(q), checked);
if (guard && group)
+QT_WARNING_POP
+#endif
emit group->buttonToggled(q, checked);
}
#endif
@@ -468,7 +488,7 @@ void QAbstractButtonPrivate::emitToggled(bool checked)
Constructs an abstract button with a \a parent.
*/
QAbstractButton::QAbstractButton(QWidget *parent)
- : QWidget(*new QAbstractButtonPrivate, parent, 0)
+ : QWidget(*new QAbstractButtonPrivate, parent, { })
{
Q_D(QAbstractButton);
d->init();
@@ -490,7 +510,7 @@ QAbstractButton::QAbstractButton(QWidget *parent)
/*! \internal
*/
QAbstractButton::QAbstractButton(QAbstractButtonPrivate &dd, QWidget *parent)
- : QWidget(dd, parent, 0)
+ : QWidget(dd, parent, { })
{
Q_D(QAbstractButton);
d->init();
@@ -1272,7 +1292,7 @@ QSize QAbstractButton::iconSize() const
Q_D(const QAbstractButton);
if (d->iconSize.isValid())
return d->iconSize;
- int e = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this);
+ int e = style()->pixelMetric(QStyle::PM_ButtonIconSize, nullptr, this);
return QSize(e, e);
}
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h
index e8dee142f2..50c94654f3 100644
--- a/src/widgets/widgets/qabstractbutton.h
+++ b/src/widgets/widgets/qabstractbutton.h
@@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QAbstractButton : public QWidget
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
#endif
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled USER true)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive)
Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay)
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index d2372a7be9..257cffda62 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -161,10 +161,10 @@ QT_BEGIN_NAMESPACE
*/
QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
- :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
+ :hbar(nullptr), vbar(nullptr), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored),
- viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),
- xoffset(0), yoffset(0), viewportFilter(0)
+ viewport(nullptr), cornerWidget(nullptr), left(0), top(0), right(0), bottom(0),
+ xoffset(0), yoffset(0), viewportFilter(nullptr)
{
}
@@ -329,12 +329,12 @@ void QAbstractScrollAreaPrivate::layoutChildren()
void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrollbar, bool *needVerticalScrollbar)
{
Q_Q(QAbstractScrollArea);
- bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar);
+ bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, hbar);
bool needh = *needHorizontalScrollbar || ((hbarpolicy != Qt::ScrollBarAlwaysOff) && ((hbarpolicy == Qt::ScrollBarAlwaysOn && !htransient)
|| ((hbarpolicy == Qt::ScrollBarAsNeeded || htransient)
&& hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty())));
- bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar);
+ bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, vbar);
bool needv = *needVerticalScrollbar || ((vbarpolicy != Qt::ScrollBarAlwaysOff) && ((vbarpolicy == Qt::ScrollBarAlwaysOn && !vtransient)
|| ((vbarpolicy == Qt::ScrollBarAsNeeded || vtransient)
&& vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty())));
@@ -352,7 +352,7 @@ void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrol
const QRect widgetRect = q->rect();
- const bool hasCornerWidget = (cornerWidget != 0);
+ const bool hasCornerWidget = (cornerWidget != nullptr);
QPoint cornerOffset((needv && vscrollOverlap == 0) ? vsbExt : 0, (needh && hscrollOverlap == 0) ? hsbExt : 0);
QRect controlsRect;
@@ -512,8 +512,8 @@ QAbstractScrollArea::~QAbstractScrollArea()
Sets the viewport to be the given \a widget.
The QAbstractScrollArea will take ownership of the given \a widget.
- If \a widget is 0, QAbstractScrollArea will assign a new QWidget instance
- for the viewport.
+ If \a widget is \nullptr, QAbstractScrollArea will assign a new QWidget
+ instance for the viewport.
\sa viewport()
*/
@@ -720,7 +720,7 @@ QWidget *QAbstractScrollArea::cornerWidget() const
You will probably also want to set at least one of the scroll bar
modes to \c AlwaysOn.
- Passing 0 shows no widget in the corner.
+ Passing \nullptr shows no widget in the corner.
Any previous corner widget is hidden.
@@ -794,7 +794,7 @@ void QAbstractScrollArea::addScrollBarWidget(QWidget *widget, Qt::Alignment alig
{
Q_D(QAbstractScrollArea);
- if (widget == 0)
+ if (widget == nullptr)
return;
const Qt::Orientation scrollBarOrientation
@@ -894,8 +894,8 @@ bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e)
if (d->hbarpolicy == Qt::ScrollBarAsNeeded && d->vbarpolicy == Qt::ScrollBarAsNeeded) {
QScrollBar *sbar = static_cast<QScrollBar*>(o);
QScrollBar *sibling = sbar == d->hbar ? d->vbar : d->hbar;
- if (sbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sbar) &&
- sibling->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sibling))
+ if (sbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, sbar) &&
+ sibling->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, sibling))
d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave);
}
}
@@ -1389,10 +1389,10 @@ bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )
void QAbstractScrollAreaPrivate::flashScrollBars()
{
- bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar);
+ bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, hbar);
if ((hbarpolicy != Qt::ScrollBarAlwaysOff) && (hbarpolicy == Qt::ScrollBarAsNeeded || htransient))
hbar->d_func()->flash();
- bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar);
+ bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, vbar);
if ((vbarpolicy != Qt::ScrollBarAlwaysOff) && (vbarpolicy == Qt::ScrollBarAsNeeded || vtransient))
vbar->d_func()->flash();
}
diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp
index dc325ab871..a0611565b8 100644
--- a/src/widgets/widgets/qabstractslider.cpp
+++ b/src/widgets/widgets/qabstractslider.cpp
@@ -273,13 +273,13 @@ void QAbstractSliderPrivate::setSteps(int single, int page)
\l value of 0.
*/
QAbstractSlider::QAbstractSlider(QWidget *parent)
- :QWidget(*new QAbstractSliderPrivate, parent, 0)
+ :QWidget(*new QAbstractSliderPrivate, parent, { })
{
}
/*! \internal */
QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent)
- :QWidget(dd, parent, 0)
+ :QWidget(dd, parent, { })
{
}
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index fc19e0793e..04176ab5e2 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -147,7 +147,7 @@ QT_BEGIN_NAMESPACE
*/
QAbstractSpinBox::QAbstractSpinBox(QWidget *parent)
- : QWidget(*new QAbstractSpinBoxPrivate, parent, 0)
+ : QWidget(*new QAbstractSpinBoxPrivate, parent, { })
{
Q_D(QAbstractSpinBox);
d->init();
@@ -157,7 +157,7 @@ QAbstractSpinBox::QAbstractSpinBox(QWidget *parent)
\internal
*/
QAbstractSpinBox::QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent)
- : QWidget(dd, parent, 0)
+ : QWidget(dd, parent, { })
{
Q_D(QAbstractSpinBox);
d->init();
@@ -570,7 +570,7 @@ void QAbstractSpinBox::clear()
QAbstractSpinBox::StepEnabled QAbstractSpinBox::stepEnabled() const
{
Q_D(const QAbstractSpinBox);
- if (d->readOnly || d->type == QVariant::Invalid)
+ if (d->readOnly || d->type == QMetaType::UnknownType)
return StepNone;
if (d->wrapping)
return StepEnabled(StepUpEnabled | StepDownEnabled);
@@ -723,7 +723,7 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit)
d->edit->setFocusProxy(this);
d->edit->setAcceptDrops(false);
- if (d->type != QVariant::Invalid) {
+ if (d->type != QMetaType::UnknownType) {
connect(d->edit, SIGNAL(textChanged(QString)),
this, SLOT(_q_editorTextChanged(QString)));
connect(d->edit, SIGNAL(cursorPositionChanged(int,int)),
@@ -848,9 +848,9 @@ void QAbstractSpinBox::changeEvent(QEvent *event)
switch (event->type()) {
case QEvent::StyleChange:
- d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, 0, this);
+ d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, nullptr, this);
d->spinClickThresholdTimerInterval =
- style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, 0, this);
+ style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, nullptr, this);
if (d->edit)
d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this));
d->stepModifier = static_cast<Qt::KeyboardModifier>(style()->styleHint(QStyle::SH_SpinBox_StepModifier, nullptr, this));
@@ -1043,7 +1043,7 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event)
steps *= 10;
if (!up)
steps *= -1;
- if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) {
+ if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, nullptr, this)) {
d->buttonState = (Keyboard | (up ? Up : Down));
}
if (d->spinClickTimerId == -1)
@@ -1421,14 +1421,14 @@ void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event)
*/
QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate()
- : edit(0), type(QVariant::Invalid), spinClickTimerId(-1),
+ : edit(nullptr), type(QMetaType::UnknownType), spinClickTimerId(-1),
spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1),
effectiveSpinRepeatRate(1), buttonState(None), cachedText(QLatin1String("\x01")),
cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false),
ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true),
cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue),
stepModifier(Qt::ControlModifier), acceleration(0), hoverControl(QStyle::SC_None),
- buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(0), showGroupSeparator(0),
+ buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(nullptr), showGroupSeparator(0),
wheelDeltaRemainder(0)
{
}
@@ -1805,7 +1805,7 @@ void QAbstractSpinBoxPrivate::setValue(const QVariant &val, EmitPolicy ep,
void QAbstractSpinBoxPrivate::updateEdit()
{
Q_Q(QAbstractSpinBox);
- if (type == QVariant::Invalid)
+ if (type == QMetaType::UnknownType)
return;
const QString newText = specialValue() ? specialValueText : prefix + textFromValue(value) + suffix;
if (newText == edit->displayText() || cleared)
@@ -1865,8 +1865,8 @@ QVariant QAbstractSpinBoxPrivate::getZeroVariant() const
{
QVariant ret;
switch (type) {
- case QVariant::Int: ret = QVariant((int)0); break;
- case QVariant::Double: ret = QVariant((double)0.0); break;
+ case QMetaType::Int: ret = QVariant(0); break;
+ case QMetaType::Double: ret = QVariant(0.0); break;
default: break;
}
return ret;
@@ -1913,7 +1913,7 @@ QVariant QAbstractSpinBoxPrivate::valueFromText(const QString &) const
void QAbstractSpinBoxPrivate::interpret(EmitPolicy ep)
{
Q_Q(QAbstractSpinBox);
- if (type == QVariant::Invalid || cleared)
+ if (type == QMetaType::UnknownType || cleared)
return;
QVariant v = getZeroVariant();
@@ -2013,11 +2013,11 @@ void QSpinBoxValidator::fixup(QString &input) const
QVariant operator+(const QVariant &arg1, const QVariant &arg2)
{
QVariant ret;
- if (Q_UNLIKELY(arg1.type() != arg2.type()))
+ if (Q_UNLIKELY(arg1.userType() != arg2.userType()))
qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)",
arg1.typeName(), arg2.typeName(), __FILE__, __LINE__);
- switch (arg1.type()) {
- case QVariant::Int: {
+ switch (arg1.userType()) {
+ case QMetaType::Int: {
const int int1 = arg1.toInt();
const int int2 = arg2.toInt();
if (int1 > 0 && (int2 >= INT_MAX - int1)) {
@@ -2031,9 +2031,9 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2)
}
break;
}
- case QVariant::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break;
+ case QMetaType::Double: ret = QVariant(arg1.toDouble() + arg2.toDouble()); break;
#if QT_CONFIG(datetimeparser)
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QDateTime a2 = arg2.toDateTime();
QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATE_MIN.daysTo(a2.date()));
a1.setTime(a1.time().addMSecs(a2.time().msecsSinceStartOfDay()));
@@ -2055,13 +2055,13 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2)
QVariant operator-(const QVariant &arg1, const QVariant &arg2)
{
QVariant ret;
- if (Q_UNLIKELY(arg1.type() != arg2.type()))
+ if (Q_UNLIKELY(arg1.userType() != arg2.userType()))
qWarning("QAbstractSpinBox: Internal error: Different types (%s vs %s) (%s:%d)",
arg1.typeName(), arg2.typeName(), __FILE__, __LINE__);
- switch (arg1.type()) {
- case QVariant::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break;
- case QVariant::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break;
- case QVariant::DateTime: {
+ switch (arg1.userType()) {
+ case QMetaType::Int: ret = QVariant(arg1.toInt() - arg2.toInt()); break;
+ case QMetaType::Double: ret = QVariant(arg1.toDouble() - arg2.toDouble()); break;
+ case QMetaType::QDateTime: {
QDateTime a1 = arg1.toDateTime();
QDateTime a2 = arg2.toDateTime();
int days = a2.daysTo(a1);
@@ -2090,13 +2090,13 @@ QVariant operator*(const QVariant &arg1, double multiplier)
{
QVariant ret;
- switch (arg1.type()) {
- case QVariant::Int:
+ switch (arg1.userType()) {
+ case QMetaType::Int:
ret = static_cast<int>(qBound<double>(INT_MIN, arg1.toInt() * multiplier, INT_MAX));
break;
- case QVariant::Double: ret = QVariant(arg1.toDouble() * multiplier); break;
+ case QMetaType::Double: ret = QVariant(arg1.toDouble() * multiplier); break;
#if QT_CONFIG(datetimeparser)
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
double days = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDateTime().date()) * multiplier;
const qint64 daysInt = qint64(days);
days -= daysInt;
@@ -2119,17 +2119,17 @@ double operator/(const QVariant &arg1, const QVariant &arg2)
double a1 = 0;
double a2 = 0;
- switch (arg1.type()) {
- case QVariant::Int:
+ switch (arg1.userType()) {
+ case QMetaType::Int:
a1 = (double)arg1.toInt();
a2 = (double)arg2.toInt();
break;
- case QVariant::Double:
+ case QMetaType::Double:
a1 = arg1.toDouble();
a2 = arg2.toDouble();
break;
#if QT_CONFIG(datetimeparser)
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
a1 = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDate());
a2 = QDATETIMEEDIT_DATE_MIN.daysTo(arg2.toDate());
a1 += arg1.toDateTime().time().msecsSinceStartOfDay() / (36e5 * 24);
@@ -2144,9 +2144,9 @@ double operator/(const QVariant &arg1, const QVariant &arg2)
int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant &arg2)
{
- switch (arg2.type()) {
- case QVariant::Date:
- Q_ASSERT_X(arg1.type() == QVariant::Date, "QAbstractSpinBoxPrivate::variantCompare",
+ switch (arg2.userType()) {
+ case QMetaType::QDate:
+ Q_ASSERT_X(arg1.userType() == QMetaType::QDate, "QAbstractSpinBoxPrivate::variantCompare",
qPrintable(QString::fromLatin1("Internal error 1 (%1)").
arg(QString::fromLatin1(arg1.typeName()))));
if (arg1.toDate() == arg2.toDate()) {
@@ -2156,8 +2156,8 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Time:
- Q_ASSERT_X(arg1.type() == QVariant::Time, "QAbstractSpinBoxPrivate::variantCompare",
+ case QMetaType::QTime:
+ Q_ASSERT_X(arg1.userType() == QMetaType::QTime, "QAbstractSpinBoxPrivate::variantCompare",
qPrintable(QString::fromLatin1("Internal error 2 (%1)").
arg(QString::fromLatin1(arg1.typeName()))));
if (arg1.toTime() == arg2.toTime()) {
@@ -2169,7 +2169,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
}
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
if (arg1.toDateTime() == arg2.toDateTime()) {
return 0;
} else if (arg1.toDateTime() < arg2.toDateTime()) {
@@ -2177,7 +2177,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Int:
+ case QMetaType::Int:
if (arg1.toInt() == arg2.toInt()) {
return 0;
} else if (arg1.toInt() < arg2.toInt()) {
@@ -2185,7 +2185,7 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Double:
+ case QMetaType::Double:
if (arg1.toDouble() == arg2.toDouble()) {
return 0;
} else if (arg1.toDouble() < arg2.toDouble()) {
@@ -2193,8 +2193,8 @@ int QAbstractSpinBoxPrivate::variantCompare(const QVariant &arg1, const QVariant
} else {
return 1;
}
- case QVariant::Invalid:
- if (arg2.type() == QVariant::Invalid)
+ case QMetaType::UnknownType:
+ if (arg2.userType() == QMetaType::UnknownType)
return 0;
Q_FALLTHROUGH();
default:
diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h
index ad169fde19..63b19c7317 100644
--- a/src/widgets/widgets/qabstractspinbox_p.h
+++ b/src/widgets/widgets/qabstractspinbox_p.h
@@ -127,7 +127,7 @@ public:
QLineEdit *edit;
QString prefix, suffix, specialValueText;
QVariant value, minimum, maximum, singleStep;
- QVariant::Type type;
+ QMetaType::Type type;
int spinClickTimerId, spinClickTimerInterval, spinClickThresholdTimerId, spinClickThresholdTimerInterval;
int effectiveSpinRepeatRate;
uint buttonState;
diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp
index 669faa92c7..9162029cdb 100644
--- a/src/widgets/widgets/qbuttongroup.cpp
+++ b/src/widgets/widgets/qbuttongroup.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
void QButtonGroupPrivate::detectCheckedButton()
{
QAbstractButton *previous = checkedButton;
- checkedButton = 0;
+ checkedButton = nullptr;
if (exclusive)
return;
for (int i = 0; i < buttonList.count(); i++) {
@@ -119,7 +119,7 @@ QButtonGroup::~QButtonGroup()
{
Q_D(QButtonGroup);
for (int i = 0; i < d->buttonList.count(); ++i)
- d->buttonList.at(i)->d_func()->group = 0;
+ d->buttonList.at(i)->d_func()->group = nullptr;
}
/*!
@@ -164,6 +164,7 @@ void QButtonGroup::setExclusive(bool exclusive)
/*!
\fn void QButtonGroup::buttonClicked(int id)
+ \obsolete
This signal is emitted when a button with the given \a id is
clicked.
@@ -183,6 +184,7 @@ void QButtonGroup::setExclusive(bool exclusive)
/*!
\fn void QButtonGroup::buttonPressed(int id)
\since 4.2
+ \obsolete
This signal is emitted when a button with the given \a id is
pressed down.
@@ -202,6 +204,7 @@ void QButtonGroup::setExclusive(bool exclusive)
/*!
\fn void QButtonGroup::buttonReleased(int id)
\since 4.2
+ \obsolete
This signal is emitted when a button with the given \a id is
released.
@@ -222,6 +225,7 @@ void QButtonGroup::setExclusive(bool exclusive)
/*!
\fn void QButtonGroup::buttonToggled(int id, bool checked)
\since 5.2
+ \obsolete
This signal is emitted when a button with the given \a id is toggled.
\a checked is true if the button is checked, or false if the button is unchecked.
@@ -273,7 +277,7 @@ void QButtonGroup::removeButton(QAbstractButton *button)
d->detectCheckedButton();
}
if (button->d_func()->group == this) {
- button->d_func()->group = 0;
+ button->d_func()->group = nullptr;
d->buttonList.removeAll(button);
d->mapping.remove(button);
}
diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h
index fec94ccb3e..2989dcb4ba 100644
--- a/src/widgets/widgets/qbuttongroup.h
+++ b/src/widgets/widgets/qbuttongroup.h
@@ -78,13 +78,19 @@ public:
Q_SIGNALS:
void buttonClicked(QAbstractButton *);
- void buttonClicked(int);
void buttonPressed(QAbstractButton *);
- void buttonPressed(int);
void buttonReleased(QAbstractButton *);
- void buttonReleased(int);
void buttonToggled(QAbstractButton *, bool);
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonClicked(QAbstractButton *) instead")
+ void buttonClicked(int);
+ QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonPressed(QAbstractButton *) instead")
+ void buttonPressed(int);
+ QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonReleased(QAbstractButton *) instead")
+ void buttonReleased(int);
+ QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonToggled(QAbstractButton *, bool) instead")
void buttonToggled(int, bool);
+#endif
private:
Q_DISABLE_COPY(QButtonGroup)
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 8593001f8b..fe1133c6c7 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -559,7 +559,7 @@ void QCalendarDateValidator::setFormat(const QString &format)
separator += nextChar;
quoting = false;
} else {
- QCalendarDateSectionValidator *validator = 0;
+ QCalendarDateSectionValidator *validator = nullptr;
if (nextChar == QLatin1Char('d')) {
offset = qMin(4, countRepeat(format, pos));
validator = &m_dayValidator;
@@ -640,9 +640,9 @@ class QCalendarTextNavigator: public QObject
{
Q_OBJECT
public:
- QCalendarTextNavigator(QObject *parent = 0)
- : QObject(parent), m_dateText(0), m_dateFrame(0), m_dateValidator(0),
- m_widget(0), m_editDelay(1500), m_date(QDate::currentDate()) {}
+ QCalendarTextNavigator(QObject *parent = nullptr)
+ : QObject(parent), m_dateText(nullptr), m_dateFrame(nullptr), m_dateValidator(nullptr),
+ m_widget(nullptr), m_editDelay(1500), m_date(QDate::currentDate()) {}
QWidget *widget() const;
void setWidget(QWidget *widget);
@@ -752,9 +752,9 @@ void QCalendarTextNavigator::removeDateLabel()
m_dateFrame->hide();
m_dateFrame->deleteLater();
delete m_dateValidator;
- m_dateFrame = 0;
- m_dateText = 0;
- m_dateValidator = 0;
+ m_dateFrame = nullptr;
+ m_dateText = nullptr;
+ m_dateValidator = nullptr;
}
bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e)
@@ -858,7 +858,7 @@ class QCalendarModel : public QAbstractTableModel
{
Q_OBJECT
public:
- QCalendarModel(QObject *parent = 0);
+ QCalendarModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &) const override
{ return RowCount + m_firstRow; }
@@ -951,7 +951,7 @@ class QCalendarView : public QTableView
{
Q_OBJECT
public:
- QCalendarView(QWidget *parent = 0);
+ QCalendarView(QWidget *parent = nullptr);
void internalUpdate() { updateGeometries(); }
void setReadOnly(bool enable);
@@ -1207,9 +1207,9 @@ Qt::ItemFlags QCalendarModel::flags(const QModelIndex &index) const
if (!date.isValid())
return QAbstractTableModel::flags(index);
if (date < m_minimumDate)
- return 0;
+ return { };
if (date > m_maximumDate)
- return 0;
+ return { };
return QAbstractTableModel::flags(index);
}
@@ -1599,7 +1599,7 @@ class QCalendarDelegate : public QItemDelegate
{
Q_OBJECT
public:
- QCalendarDelegate(QCalendarWidgetPrivate *w, QObject *parent = 0)
+ QCalendarDelegate(QCalendarWidgetPrivate *w, QObject *parent = nullptr)
: QItemDelegate(parent), calendarWidgetPrivate(w)
{ }
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,
@@ -1734,11 +1734,11 @@ void QCalendarDelegate::paintCell(QPainter *painter, const QRect &rect, QDate da
QCalendarWidgetPrivate::QCalendarWidgetPrivate()
: QWidgetPrivate()
{
- m_model = 0;
- m_view = 0;
- m_delegate = 0;
- m_selection = 0;
- m_navigator = 0;
+ m_model = nullptr;
+ m_view = nullptr;
+ m_delegate = nullptr;
+ m_selection = nullptr;
+ m_navigator = nullptr;
m_dateEditEnabled = false;
navBarVisible = true;
oldFocusPolicy = Qt::StrongFocus;
@@ -1748,7 +1748,7 @@ void QCalendarWidgetPrivate::setNavigatorEnabled(bool enable)
{
Q_Q(QCalendarWidget);
- bool navigatorEnabled = (m_navigator->widget() != 0);
+ bool navigatorEnabled = (m_navigator->widget() != nullptr);
if (enable == navigatorEnabled)
return;
@@ -1760,7 +1760,7 @@ void QCalendarWidgetPrivate::setNavigatorEnabled(bool enable)
q, SLOT(_q_editingFinished()));
m_view->installEventFilter(m_navigator);
} else {
- m_navigator->setWidget(0);
+ m_navigator->setWidget(nullptr);
q->disconnect(m_navigator, SIGNAL(dateChanged(QDate)),
q, SLOT(_q_slotChangeDate(QDate)));
q->disconnect(m_navigator, SIGNAL(editingFinished()),
@@ -1847,8 +1847,8 @@ void QCalendarWidgetPrivate::createNavigationBar(QWidget *widget)
void QCalendarWidgetPrivate::updateButtonIcons()
{
Q_Q(QCalendarWidget);
- prevMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, 0, q));
- nextMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowLeft : QStyle::SP_ArrowRight, 0, q));
+ prevMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, nullptr, q));
+ nextMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowLeft : QStyle::SP_ArrowRight, nullptr, q));
}
void QCalendarWidgetPrivate::updateMonthMenu()
@@ -2135,7 +2135,7 @@ void QCalendarWidgetPrivate::_q_editingFinished()
\sa setCurrentPage()
*/
QCalendarWidget::QCalendarWidget(QWidget *parent)
- : QWidget(*new QCalendarWidgetPrivate, parent, 0)
+ : QWidget(*new QCalendarWidgetPrivate, parent, { })
{
Q_D(QCalendarWidget);
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 9a0e969e1c..95c2bea3fe 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -91,30 +91,11 @@ QT_BEGIN_NAMESPACE
QComboBoxPrivate::QComboBoxPrivate()
: QWidgetPrivate(),
- model(0),
- lineEdit(0),
- container(0),
- insertPolicy(QComboBox::InsertAtBottom),
- sizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow),
- minimumContentsLength(0),
shownOnce(false),
autoCompletion(true),
duplicatesEnabled(false),
frame(true),
- maxVisibleItems(10),
- maxCount(INT_MAX),
- modelColumn(0),
- inserting(false),
- arrowState(QStyle::State_None),
- hoverControl(QStyle::SC_None),
- autoCompletionCaseSensitivity(Qt::CaseInsensitive),
- indexBeforeChange(-1)
-#ifdef Q_OS_MAC
- , m_platformMenu(0)
-#endif
-#if QT_CONFIG(completer)
- , completer(0)
-#endif
+ inserting(false)
{
}
@@ -148,18 +129,26 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
if (option.state & QStyle::State_Selected)
menuOption.state |= QStyle::State_Selected;
menuOption.checkType = QStyleOptionMenuItem::NonExclusive;
- menuOption.checked = mCombo->currentIndex() == index.row();
+ // a valid checkstate means that the model has checkable items
+ const QVariant checkState = index.data(Qt::CheckStateRole);
+ if (!checkState.isValid()) {
+ menuOption.checked = mCombo->currentIndex() == index.row();
+ } else {
+ menuOption.checked = qvariant_cast<int>(checkState) == Qt::Checked;
+ menuOption.state |= qvariant_cast<int>(checkState) == Qt::Checked
+ ? QStyle::State_On : QStyle::State_Off;
+ }
if (QComboBoxDelegate::isSeparator(index))
menuOption.menuItemType = QStyleOptionMenuItem::Separator;
else
menuOption.menuItemType = QStyleOptionMenuItem::Normal;
QVariant variant = index.model()->data(index, Qt::DecorationRole);
- switch (variant.type()) {
- case QVariant::Icon:
+ switch (variant.userType()) {
+ case QMetaType::QIcon:
menuOption.icon = qvariant_cast<QIcon>(variant);
break;
- case QVariant::Color: {
+ case QMetaType::QColor: {
static QPixmap pixmap(option.decorationSize);
pixmap.fill(qvariant_cast<QColor>(variant));
menuOption.icon = pixmap;
@@ -183,7 +172,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
// that order, also override the font for the popup menu.
QVariant fontRoleData = index.data(Qt::FontRole);
if (fontRoleData.isValid()) {
- menuOption.font = fontRoleData.value<QFont>();
+ menuOption.font = qvariant_cast<QFont>(fontRoleData);
} else if (mCombo->testAttribute(Qt::WA_SetFont)
|| mCombo->testAttribute(Qt::WA_MacSmallSize)
|| mCombo->testAttribute(Qt::WA_MacMiniSize)
@@ -198,6 +187,55 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
return menuOption;
}
+bool QComboMenuDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
+ const QStyleOptionViewItem &option, const QModelIndex &index)
+{
+ Q_ASSERT(event);
+ Q_ASSERT(model);
+
+ // make sure that the item is checkable
+ Qt::ItemFlags flags = model->flags(index);
+ if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled)
+ || !(flags & Qt::ItemIsEnabled))
+ return false;
+
+ // make sure that we have a check state
+ const QVariant checkState = index.data(Qt::CheckStateRole);
+ if (!checkState.isValid())
+ return false;
+
+ // make sure that we have the right event type
+ if ((event->type() == QEvent::MouseButtonRelease)
+ || (event->type() == QEvent::MouseButtonDblClick)
+ || (event->type() == QEvent::MouseButtonPress)) {
+ QMouseEvent *me = static_cast<QMouseEvent*>(event);
+ if (me->button() != Qt::LeftButton)
+ return false;
+
+ if ((event->type() == QEvent::MouseButtonPress)
+ || (event->type() == QEvent::MouseButtonDblClick)) {
+ pressedIndex = index.row();
+ return false;
+ }
+
+ if (index.row() != pressedIndex)
+ return false;
+ pressedIndex = -1;
+
+ } else if (event->type() == QEvent::KeyPress) {
+ if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space
+ && static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)
+ return false;
+ } else {
+ return false;
+ }
+
+ // we don't support user-tristate items in QComboBox (not implemented in any style)
+ Qt::CheckState newState = (static_cast<Qt::CheckState>(checkState.toInt()) == Qt::Checked)
+ ? Qt::Unchecked : Qt::Checked;
+ return model->setData(index, newState, Qt::CheckStateRole);
+}
+
#if QT_CONFIG(completer)
void QComboBoxPrivate::_q_completerActivated(const QModelIndex &index)
{
@@ -255,8 +293,7 @@ void QComboBoxPrivate::_q_modelReset()
lineEdit->setText(QString());
updateLineEditGeometry();
}
- if (currentIndex.row() != indexBeforeChange)
- _q_emitCurrentIndexChanged(currentIndex);
+ trySetValidIndex();
modelChanged();
q->update();
}
@@ -266,6 +303,25 @@ void QComboBoxPrivate::_q_modelDestroyed()
model = QAbstractItemModelPrivate::staticEmptyModel();
}
+void QComboBoxPrivate::trySetValidIndex()
+{
+ Q_Q(QComboBox);
+ bool currentReset = false;
+
+ const int rowCount = q->count();
+ for (int pos = 0; pos < rowCount; ++pos) {
+ const QModelIndex idx(model->index(pos, modelColumn, root));
+ if (idx.flags() & Qt::ItemIsEnabled) {
+ setCurrentIndex(idx);
+ currentReset = true;
+ break;
+ }
+ }
+
+ if (!currentReset)
+ setCurrentIndex(QModelIndex());
+}
+
QRect QComboBoxPrivate::popupGeometry(int screen) const
{
return QStylePrivate::useFullScreenForPopup()
@@ -368,6 +424,8 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
}
if (minimumContentsLength > 0)
sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.horizontalAdvance(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0)));
+ if (!placeholderText.isEmpty())
+ sh.setWidth(qMax(sh.width(), fm.boundingRect(placeholderText).width()));
// height
@@ -445,12 +503,8 @@ void QComboBoxPrivateContainer::paintEvent(QPaintEvent *e)
QFrame::paintEvent(e);
}
-void QComboBoxPrivateContainer::leaveEvent(QEvent *)
-{
-}
-
QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView, QComboBox *parent)
- : QFrame(parent, Qt::Popup), combo(parent), view(0), top(0), bottom(0), maybeIgnoreMouseButtonRelease(false)
+ : QFrame(parent, Qt::Popup), combo(parent)
{
// we need the combobox and itemview
Q_ASSERT(parent);
@@ -555,7 +609,7 @@ void QComboBoxPrivateContainer::updateScrollers()
*/
void QComboBoxPrivateContainer::viewDestroyed()
{
- view = 0;
+ view = nullptr;
setItemView(new QComboBoxListView());
}
@@ -589,7 +643,7 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
if (isAncestorOf(view))
delete view;
- view = 0;
+ view = nullptr;
}
// setup the item view
@@ -929,7 +983,7 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
model QStandardItemModel.
*/
QComboBox::QComboBox(QWidget *parent)
- : QWidget(*new QComboBoxPrivate(), parent, 0)
+ : QWidget(*new QComboBoxPrivate(), parent, { })
{
Q_D(QComboBox);
d->init();
@@ -939,7 +993,7 @@ QComboBox::QComboBox(QWidget *parent)
\internal
*/
QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent)
- : QWidget(dd, parent, 0)
+ : QWidget(dd, parent, { })
{
Q_D(QComboBox);
d->init();
@@ -1110,8 +1164,9 @@ void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int
q->updateGeometry();
}
- // set current index if combo was previously empty
- if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid()) {
+ // set current index if combo was previously empty and there is no placeholderText
+ if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid() &&
+ placeholderText.isEmpty()) {
q->setCurrentIndex(0);
// need to emit changed if model updated index "silently"
} else if (currentIndex.row() != indexBeforeChange) {
@@ -1214,10 +1269,9 @@ void QComboBox::initStyleOption(QStyleOptionComboBox *option) const
} else {
option->activeSubControls = d->hoverControl;
}
- if (d->currentIndex.isValid()) {
- option->currentText = currentText();
+ option->currentText = currentText();
+ if (d->currentIndex.isValid())
option->currentIcon = d->itemIcon(d->currentIndex);
- }
option->iconSize = iconSize();
if (d->container && d->container->isVisible())
option->state |= QStyle::State_On;
@@ -1566,7 +1620,7 @@ void QComboBox::setAutoCompletion(bool enable)
d->lineEdit->setCompleter(d->completer);
d->completer->setWidget(this);
} else {
- d->lineEdit->setCompleter(0);
+ d->lineEdit->setCompleter(nullptr);
}
}
@@ -1755,7 +1809,7 @@ QSize QComboBox::iconSize() const
if (d->iconSize.isValid())
return d->iconSize;
- int iconWidth = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
+ int iconWidth = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
return QSize(iconWidth, iconWidth);
}
@@ -1772,6 +1826,45 @@ void QComboBox::setIconSize(const QSize &size)
}
/*!
+ \property QComboBox::placeholderText
+ \brief Sets a \a placeholderText text shown when no valid index is set
+
+ The \a placeholderText will be shown when an invalid index is set. The
+ text is not accessible in the dropdown list. When this function is called
+ before items are added the placeholder text will be shown, otherwise you
+ have to call setCurrentIndex(-1) programmatically if you want to show the
+ placeholder text.
+ Set an empty placeholder text to reset the setting.
+
+ When the QComboBox is editable, use QLineEdit::setPlaceholderText()
+ instead.
+
+ \since 5.15
+*/
+void QComboBox::setPlaceholderText(const QString &placeholderText)
+{
+ Q_D(QComboBox);
+ if (placeholderText == d->placeholderText)
+ return;
+
+ d->placeholderText = placeholderText;
+ if (currentIndex() == -1) {
+ if (d->placeholderText.isEmpty() && currentIndex() == -1)
+ setCurrentIndex(0);
+ else
+ update();
+ } else {
+ updateGeometry();
+ }
+}
+
+QString QComboBox::placeholderText() const
+{
+ Q_D(const QComboBox);
+ return d->placeholderText;
+}
+
+/*!
\property QComboBox::editable
\brief whether the combo box can be edited by the user
@@ -1786,7 +1879,7 @@ void QComboBox::setIconSize(const QSize &size)
bool QComboBox::isEditable() const
{
Q_D(const QComboBox);
- return d->lineEdit != 0;
+ return d->lineEdit != nullptr;
}
/*! \internal
@@ -1813,7 +1906,7 @@ void QComboBoxPrivate::updateDelegate(bool force)
QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const
{
QVariant decoration = model->data(index, Qt::DecorationRole);
- if (decoration.type() == QVariant::Pixmap)
+ if (decoration.userType() == QMetaType::QPixmap)
return QIcon(qvariant_cast<QPixmap>(decoration));
else
return qvariant_cast<QIcon>(decoration);
@@ -1842,7 +1935,7 @@ void QComboBox::setEditable(bool editable)
setAttribute(Qt::WA_InputMethodEnabled, false);
d->lineEdit->hide();
d->lineEdit->deleteLater();
- d->lineEdit = 0;
+ d->lineEdit = nullptr;
}
d->updateDelegate();
@@ -1891,6 +1984,8 @@ void QComboBox::setLineEdit(QLineEdit *edit)
d->lineEdit->setFocusProxy(this);
d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
#if QT_DEPRECATED_SINCE(5, 13)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
#if QT_CONFIG(completer)
setAutoCompletion(d->autoCompletion);
@@ -1907,6 +2002,7 @@ void QComboBox::setLineEdit(QLineEdit *edit)
}
#endif
#endif
+QT_WARNING_POP
#endif
setAttribute(Qt::WA_InputMethodEnabled);
@@ -1955,7 +2051,7 @@ void QComboBox::setValidator(const QValidator *v)
const QValidator *QComboBox::validator() const
{
Q_D(const QComboBox);
- return d->lineEdit ? d->lineEdit->validator() : 0;
+ return d->lineEdit ? d->lineEdit->validator() : nullptr;
}
#endif // QT_NO_VALIDATOR
@@ -1966,7 +2062,7 @@ const QValidator *QComboBox::validator() const
\since 4.2
Sets the \a completer to use instead of the current completer.
- If \a completer is 0, auto completion is disabled.
+ If \a completer is \nullptr, auto completion is disabled.
By default, for an editable combo box, a QCompleter that
performs case insensitive inline completion is automatically created.
@@ -1999,7 +2095,7 @@ void QComboBox::setCompleter(QCompleter *c)
QCompleter *QComboBox::completer() const
{
Q_D(const QComboBox);
- return d->lineEdit ? d->lineEdit->completer() : 0;
+ return d->lineEdit ? d->lineEdit->completer() : nullptr;
}
#endif // QT_CONFIG(completer)
@@ -2122,20 +2218,7 @@ void QComboBox::setModel(QAbstractItemModel *model)
setRootModelIndex(QModelIndex());
- bool currentReset = false;
-
- const int rowCount = count();
- for (int pos=0; pos < rowCount; pos++) {
- if (d->model->index(pos, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled) {
- setCurrentIndex(pos);
- currentReset = true;
- break;
- }
- }
-
- if (!currentReset)
- setCurrentIndex(-1);
-
+ d->trySetValidIndex();
d->modelChanged();
}
@@ -2249,7 +2332,7 @@ QString QComboBox::currentText() const
else if (d->currentIndex.isValid())
return d->itemText(d->currentIndex);
else
- return QString();
+ return d->placeholderText;
}
/*!
@@ -2886,7 +2969,7 @@ void QComboBox::hidePopup()
QSignalBlocker containerBlocker(d->container);
// Flash selected/triggered item (if any).
if (style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)) {
- QItemSelectionModel *selectionModel = view() ? view()->selectionModel() : 0;
+ QItemSelectionModel *selectionModel = view() ? view()->selectionModel() : nullptr;
if (selectionModel && selectionModel->hasSelection()) {
QEventLoop eventLoop;
const QItemSelection selection = selectionModel->selection();
@@ -3079,6 +3162,9 @@ void QComboBox::paintEvent(QPaintEvent *)
initStyleOption(&opt);
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
+ if (currentIndex() < 0)
+ opt.palette.setBrush(QPalette::ButtonText, opt.palette.brush(QPalette::ButtonText).color().lighter());
+
// draw the icon and text
painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
}
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index 286772c091..4f89d7f542 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -71,6 +71,7 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget
Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+ Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
#if QT_CONFIG(completer)
#if QT_DEPRECATED_SINCE(5, 13)
@@ -148,6 +149,9 @@ public:
QSize iconSize() const;
void setIconSize(const QSize &size);
+ void setPlaceholderText(const QString &placeholderText);
+ QString placeholderText() const;
+
bool isEditable() const;
void setEditable(bool editable);
void setLineEdit(QLineEdit *edit);
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 5967776a61..3e78e756a6 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -79,7 +79,6 @@ QT_REQUIRE_CONFIG(combobox);
QT_BEGIN_NAMESPACE
-class QAction;
class QPlatformMenu;
class QComboBoxListView : public QListView
@@ -131,9 +130,6 @@ private:
QComboBox *combo;
};
-
-class QStandardItemModel;
-
class Q_AUTOTEST_EXPORT QComboBoxPrivateScroller : public QWidget
{
Q_OBJECT
@@ -212,7 +208,7 @@ Q_SIGNALS:
private:
QAbstractSlider::SliderAction sliderAction;
QBasicTimer timer;
- bool fast;
+ bool fast = false;
};
class Q_WIDGETS_EXPORT QComboBoxPrivateContainer : public QFrame
@@ -246,7 +242,6 @@ protected:
void showEvent(QShowEvent *e) override;
void hideEvent(QHideEvent *e) override;
void timerEvent(QTimerEvent *timerEvent) override;
- void leaveEvent(QEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
QStyleOptionComboBox comboStyleOption() const;
@@ -257,20 +252,23 @@ Q_SIGNALS:
private:
QComboBox *combo;
- QAbstractItemView *view;
- QComboBoxPrivateScroller *top;
- QComboBoxPrivateScroller *bottom;
- bool maybeIgnoreMouseButtonRelease;
+ QAbstractItemView *view = nullptr;
+ QComboBoxPrivateScroller *top = nullptr;
+ QComboBoxPrivateScroller *bottom = nullptr;
QElapsedTimer popupTimer;
+ bool maybeIgnoreMouseButtonRelease = false;
friend class QComboBox;
friend class QComboBoxPrivate;
};
class Q_AUTOTEST_EXPORT QComboMenuDelegate : public QAbstractItemDelegate
-{ Q_OBJECT
+{
+ Q_OBJECT
public:
- QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {}
+ QComboMenuDelegate(QObject *parent, QComboBox *cmb)
+ : QAbstractItemDelegate(parent), mCombo(cmb), pressedIndex(-1)
+ {}
protected:
void paint(QPainter *painter,
@@ -286,11 +284,14 @@ protected:
return mCombo->style()->sizeFromContents(
QStyle::CT_MenuItem, &opt, option.rect.size(), mCombo);
}
+ bool editorEvent(QEvent *event, QAbstractItemModel *model,
+ const QStyleOptionViewItem &option, const QModelIndex &index) override;
private:
QStyleOptionMenuItem getStyleOption(const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QComboBox *mCombo;
+ int pressedIndex;
};
// ### Qt6: QStyledItemDelegate ?
@@ -355,8 +356,8 @@ public:
void _q_complete();
void _q_itemSelected(const QModelIndex &item);
bool contains(const QString &text, int role);
- void emitActivated(const QModelIndex&);
- void _q_emitHighlighted(const QModelIndex&);
+ void emitActivated(const QModelIndex &index);
+ void _q_emitHighlighted(const QModelIndex &index);
void _q_emitCurrentIndexChanged(const QModelIndex &index);
void _q_modelDestroyed();
void _q_modelReset();
@@ -366,10 +367,11 @@ public:
void _q_resetButton();
void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void _q_updateIndexBeforeChange();
- void _q_rowsInserted(const QModelIndex & parent, int start, int end);
- void _q_rowsRemoved(const QModelIndex & parent, int start, int end);
+ void _q_rowsInserted(const QModelIndex &parent, int start, int end);
+ void _q_rowsRemoved(const QModelIndex &parent, int start, int end);
void updateArrow(QStyle::StateFlag state);
bool updateHoverControl(const QPoint &pos);
+ void trySetValidIndex();
QRect popupGeometry(int screen = -1) const;
QStyle::SubControl newHoverControl(const QPoint &pos);
int computeWidthHint() const;
@@ -402,39 +404,38 @@ public:
};
#endif
- QAbstractItemModel *model;
- QLineEdit *lineEdit;
- QComboBoxPrivateContainer *container;
- QComboBox::InsertPolicy insertPolicy;
- QComboBox::SizeAdjustPolicy sizeAdjustPolicy;
- int minimumContentsLength;
- QSize iconSize;
- uint shownOnce : 1;
- uint autoCompletion : 1;
- uint duplicatesEnabled : 1;
- uint frame : 1;
- uint padding : 26;
- int maxVisibleItems;
- int maxCount;
- int modelColumn;
- bool inserting;
- mutable QSize minimumSizeHint;
- mutable QSize sizeHint;
- QStyle::StateFlag arrowState;
- QStyle::SubControl hoverControl;
- QRect hoverRect;
- QPersistentModelIndex currentIndex;
- QPersistentModelIndex root;
- Qt::CaseSensitivity autoCompletionCaseSensitivity;
- int indexBeforeChange;
+ QAbstractItemModel *model = nullptr;
+ QLineEdit *lineEdit = nullptr;
+ QComboBoxPrivateContainer *container = nullptr;
#ifdef Q_OS_MAC
- QPlatformMenu *m_platformMenu;
+ QPlatformMenu *m_platformMenu = nullptr;
#endif
#if QT_CONFIG(completer)
QPointer<QCompleter> completer;
#endif
- static QPalette viewContainerPalette(QComboBox *cmb)
- { return cmb->d_func()->viewContainer()->palette(); }
+ QPersistentModelIndex currentIndex;
+ QPersistentModelIndex root;
+ QString placeholderText;
+ QRect hoverRect;
+ QSize iconSize;
+ mutable QSize minimumSizeHint;
+ mutable QSize sizeHint;
+ QComboBox::InsertPolicy insertPolicy = QComboBox::InsertAtBottom;
+ QComboBox::SizeAdjustPolicy sizeAdjustPolicy = QComboBox::AdjustToContentsOnFirstShow;
+ QStyle::StateFlag arrowState = QStyle::State_None;
+ QStyle::SubControl hoverControl = QStyle::SC_None;
+ Qt::CaseSensitivity autoCompletionCaseSensitivity = Qt::CaseInsensitive;
+ int minimumContentsLength = 0;
+ int indexBeforeChange = -1;
+ int maxVisibleItems = 10;
+ int maxCount = std::numeric_limits<int>::max();
+ int modelColumn = 0;
+ int placeholderIndex = -1;
+ bool shownOnce : 1;
+ bool autoCompletion : 1;
+ bool duplicatesEnabled : 1;
+ bool frame : 1;
+ bool inserting : 1;
};
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index 64795d7ccb..63d5ae268e 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -195,11 +195,19 @@ QDateTimeEdit::QDateTimeEdit(const QTime &time, QWidget *parent)
d->init(time.isValid() ? time : QDATETIMEEDIT_TIME_MIN);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*!
\internal
*/
-
QDateTimeEdit::QDateTimeEdit(const QVariant &var, QVariant::Type parserType, QWidget *parent)
+ : QDateTimeEdit(var, QMetaType::Type(parserType), parent)
+{ }
+/*!
+ \internal
+*/
+#endif
+
+QDateTimeEdit::QDateTimeEdit(const QVariant &var, QMetaType::Type parserType, QWidget *parent)
: QAbstractSpinBox(*new QDateTimeEditPrivate, parent)
{
Q_D(QDateTimeEdit);
@@ -794,7 +802,7 @@ QCalendarWidget *QDateTimeEdit::calendarWidget() const
{
Q_D(const QDateTimeEdit);
if (!d->calendarPopup || !(d->sections & QDateTimeParser::DateSectionMask))
- return 0;
+ return nullptr;
if (!d->monthCalendar) {
const_cast<QDateTimeEditPrivate*>(d)->initCalendarPopup();
}
@@ -1251,7 +1259,7 @@ void QDateTimeEdit::focusInEvent(QFocusEvent *event)
{
Q_D(QDateTimeEdit);
QAbstractSpinBox::focusInEvent(event);
- QString *frm = 0;
+ QString *frm = nullptr;
const int oldPos = d->edit->cursorPosition();
if (!d->formatExplicitlySet) {
if (d->displayFormat == d->defaultTimeFormat) {
@@ -1446,12 +1454,12 @@ QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const
{
Q_D(const QDateTimeEdit);
if (d->readOnly)
- return StepEnabled(0);
+ return {};
if (d->specialValue()) {
- return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled));
+ return (d->minimum == d->maximum ? StepEnabled{} : StepEnabled(StepUpEnabled));
}
- QAbstractSpinBox::StepEnabled ret = 0;
+ QAbstractSpinBox::StepEnabled ret = { };
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
@@ -1486,7 +1494,7 @@ QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const
switch (d->sectionType(d->currentSectionIndex)) {
case QDateTimeParser::NoSection:
case QDateTimeParser::FirstSection:
- case QDateTimeParser::LastSection: return 0;
+ case QDateTimeParser::LastSection: return { };
default: break;
}
if (d->wrapping)
@@ -1564,7 +1572,7 @@ void QDateTimeEdit::mousePressEvent(QMouseEvent *event)
QTimeEdit::QTimeEdit(QWidget *parent)
- : QDateTimeEdit(QDATETIMEEDIT_TIME_MIN, QVariant::Time, parent)
+ : QDateTimeEdit(QDATETIMEEDIT_TIME_MIN, QMetaType::QTime, parent)
{
connect(this, &QTimeEdit::timeChanged, this, &QTimeEdit::userTimeChanged);
}
@@ -1575,7 +1583,7 @@ QTimeEdit::QTimeEdit(QWidget *parent)
*/
QTimeEdit::QTimeEdit(const QTime &time, QWidget *parent)
- : QDateTimeEdit(time, QVariant::Time, parent)
+ : QDateTimeEdit(time, QMetaType::QTime, parent)
{
connect(this, &QTimeEdit::timeChanged, this, &QTimeEdit::userTimeChanged);
}
@@ -1634,7 +1642,7 @@ QTimeEdit::~QTimeEdit()
*/
QDateEdit::QDateEdit(QWidget *parent)
- : QDateTimeEdit(QDATETIMEEDIT_DATE_INITIAL, QVariant::Date, parent)
+ : QDateTimeEdit(QDATETIMEEDIT_DATE_INITIAL, QMetaType::QDate, parent)
{
connect(this, &QDateEdit::dateChanged, this, &QDateEdit::userDateChanged);
}
@@ -1645,7 +1653,7 @@ QDateEdit::QDateEdit(QWidget *parent)
*/
QDateEdit::QDateEdit(const QDate &date, QWidget *parent)
- : QDateTimeEdit(date, QVariant::Date, parent)
+ : QDateTimeEdit(date, QMetaType::QDate, parent)
{
connect(this, &QDateEdit::dateChanged, this, &QDateEdit::userDateChanged);
}
@@ -1682,24 +1690,23 @@ QDateEdit::~QDateEdit()
QDateTimeEditPrivate::QDateTimeEditPrivate()
- : QDateTimeParser(QVariant::DateTime, QDateTimeParser::DateTimeEdit, QCalendar())
+ : QDateTimeParser(QMetaType::QDateTime, QDateTimeParser::DateTimeEdit, QCalendar())
{
hasHadFocus = false;
formatExplicitlySet = false;
cacheGuard = false;
fixday = true;
- type = QVariant::DateTime;
- sections = 0;
+ type = QMetaType::QDateTime;
+ sections = { };
cachedDay = -1;
currentSectionIndex = FirstSectionIndex;
first.pos = 0;
- sections = 0;
calendarPopup = false;
minimum = QDATETIMEEDIT_COMPAT_DATE_MIN.startOfDay();
maximum = QDATETIMEEDIT_DATE_MAX.endOfDay();
arrowState = QStyle::State_None;
- monthCalendar = 0;
+ monthCalendar = nullptr;
readLocaleSettings();
#ifdef QT_KEYPAD_NAVIGATION
@@ -2286,7 +2293,7 @@ QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic(QDateTimeParser::Se
QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::Sections s)
{
- QDateTimeEdit::Sections ret = 0;
+ QDateTimeEdit::Sections ret;
if (s & QDateTimeParser::MSecSection)
ret |= QDateTimeEdit::MSecSection;
if (s & QDateTimeParser::SecondSection)
@@ -2431,22 +2438,22 @@ void QDateTimeEdit::initStyleOption(QStyleOptionSpinBox *option) const
void QDateTimeEditPrivate::init(const QVariant &var)
{
Q_Q(QDateTimeEdit);
- switch (var.type()) {
- case QVariant::Date:
+ switch (var.userType()) {
+ case QMetaType::QDate:
value = var.toDate().startOfDay();
updateTimeSpec();
q->setDisplayFormat(defaultDateFormat);
if (sectionNodes.isEmpty()) // ### safeguard for broken locale
q->setDisplayFormat(QLatin1String("dd/MM/yyyy"));
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
value = var;
updateTimeSpec();
q->setDisplayFormat(defaultDateTimeFormat);
if (sectionNodes.isEmpty()) // ### safeguard for broken locale
q->setDisplayFormat(QLatin1String("dd/MM/yyyy hh:mm:ss"));
break;
- case QVariant::Time:
+ case QMetaType::QTime:
value = QDateTime(QDATETIMEEDIT_DATE_INITIAL, var.toTime());
updateTimeSpec();
q->setDisplayFormat(defaultTimeFormat);
@@ -2525,7 +2532,7 @@ void QDateTimeEditPrivate::updateEditFieldGeometry()
QVariant QDateTimeEditPrivate::getZeroVariant() const
{
- Q_ASSERT(type == QVariant::DateTime);
+ Q_ASSERT(type == QMetaType::QDateTime);
return QDateTime(QDATETIMEEDIT_DATE_INITIAL, QTime(), spec);
}
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
index 03994675ae..8905ad4a9c 100644
--- a/src/widgets/widgets/qdatetimeedit.h
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -195,7 +195,10 @@ protected:
void paintEvent(QPaintEvent *event) override;
void initStyleOption(QStyleOptionSpinBox *option) const;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = nullptr);
+#endif
+ QDateTimeEdit(const QVariant &val, QMetaType::Type parserType, QWidget *parent = nullptr);
private:
Q_DECLARE_PRIVATE(QDateTimeEdit)
Q_DISABLE_COPY(QDateTimeEdit)
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 7dba6df15c..28c4f59d0d 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -178,15 +178,15 @@ public:
};
QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient)
- : orientation(orient), buttonLayout(0), internalRemove(false), center(false)
+ : orientation(orient), buttonLayout(nullptr), internalRemove(false), center(false)
{
}
void QDialogButtonBoxPrivate::initLayout()
{
Q_Q(QDialogButtonBox);
- layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q));
- bool createNewLayout = buttonLayout == 0
+ layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, nullptr, q));
+ bool createNewLayout = buttonLayout == nullptr
|| (orientation == Qt::Horizontal && qobject_cast<QVBoxLayout *>(buttonLayout) != 0)
|| (orientation == Qt::Vertical && qobject_cast<QHBoxLayout *>(buttonLayout) != 0);
if (createNewLayout) {
@@ -329,8 +329,8 @@ void QDialogButtonBoxPrivate::layoutButtons()
++currentLayout;
}
- QWidget *lastWidget = 0;
- q->setFocusProxy(0);
+ QWidget *lastWidget = nullptr;
+ q->setFocusProxy(nullptr);
for (int i = 0; i < buttonLayout->count(); ++i) {
QLayoutItem *item = buttonLayout->itemAt(i);
if (QWidget *widget = item->widget()) {
@@ -408,13 +408,13 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut
icon = QStyle::SP_RestoreDefaultsButton;
break;
case QDialogButtonBox::NoButton:
- return 0;
+ return nullptr;
;
}
QPushButton *button = new QPushButton(QGuiApplicationPrivate::platformTheme()->standardButtonText(sbutton), q);
QStyle *style = q->style();
- if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0)
- button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
+ if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, nullptr, q) && icon != 0)
+ button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), nullptr, q));
if (style != QApplication::style()) // Propagate style
button->setStyle(style);
standardButtonHash.insert(button, sbutton);
@@ -482,7 +482,7 @@ QDialogButtonBox::QDialogButtonBox(QWidget *parent)
\sa orientation, addButton()
*/
QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
+ : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, { })
{
d_func()->initLayout();
}
@@ -699,7 +699,7 @@ QList<QAbstractButton *> QDialogButtonBox::buttons() const
/*!
Returns the button role for the specified \a button. This function returns
- \l InvalidRole if \a button is 0 or has not been added to the button box.
+ \l InvalidRole if \a button is \nullptr or has not been added to the button box.
\sa buttons(), addButton()
*/
@@ -744,7 +744,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button)
}
}
if (!d->internalRemove)
- button->setParent(0);
+ button->setParent(nullptr);
}
/*!
@@ -782,7 +782,7 @@ QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role)
Q_D(QDialogButtonBox);
if (Q_UNLIKELY(role <= InvalidRole || role >= NRoles)) {
qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
- return 0;
+ return nullptr;
}
QPushButton *button = new QPushButton(text, this);
d->addButton(button, role);
@@ -964,7 +964,7 @@ bool QDialogButtonBox::event(QEvent *event)
QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole];
QPushButton *firstAcceptButton = acceptRoleList.isEmpty() ? 0 : qobject_cast<QPushButton *>(acceptRoleList.at(0));
bool hasDefault = false;
- QWidget *dialog = 0;
+ QWidget *dialog = nullptr;
QWidget *p = this;
while (p && !p->isWindow()) {
p = p->parentWidget();
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 5900326087..87f4519dd6 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -85,27 +85,27 @@ QPlaceHolderItem::QPlaceHolderItem(QWidget *w)
*/
QDockAreaLayoutItem::QDockAreaLayoutItem(QLayoutItem *_widgetItem)
- : widgetItem(_widgetItem), subinfo(0), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)
+ : widgetItem(_widgetItem), subinfo(nullptr), placeHolderItem(nullptr), pos(0), size(-1), flags(NoFlags)
{
}
QDockAreaLayoutItem::QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo)
- : widgetItem(0), subinfo(_subinfo), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)
+ : widgetItem(nullptr), subinfo(_subinfo), placeHolderItem(nullptr), pos(0), size(-1), flags(NoFlags)
{
}
QDockAreaLayoutItem::QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem)
- : widgetItem(0), subinfo(0), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags)
+ : widgetItem(nullptr), subinfo(nullptr), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags)
{
}
QDockAreaLayoutItem::QDockAreaLayoutItem(const QDockAreaLayoutItem &other)
- : widgetItem(other.widgetItem), subinfo(0), placeHolderItem(0), pos(other.pos),
+ : widgetItem(other.widgetItem), subinfo(nullptr), placeHolderItem(nullptr), pos(other.pos),
size(other.size), flags(other.flags)
{
- if (other.subinfo != 0)
+ if (other.subinfo != nullptr)
subinfo = new QDockAreaLayoutInfo(*other.subinfo);
- else if (other.placeHolderItem != 0)
+ else if (other.placeHolderItem != nullptr)
placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);
}
@@ -117,16 +117,16 @@ QDockAreaLayoutItem::~QDockAreaLayoutItem()
bool QDockAreaLayoutItem::skip() const
{
- if (placeHolderItem != 0)
+ if (placeHolderItem != nullptr)
return true;
if (flags & GapItem)
return false;
- if (widgetItem != 0)
+ if (widgetItem != nullptr)
return widgetItem->isEmpty();
- if (subinfo != 0) {
+ if (subinfo != nullptr) {
for (int i = 0; i < subinfo->item_list.count(); ++i) {
if (!subinfo->item_list.at(i).skip())
return false;
@@ -140,7 +140,7 @@ QSize QDockAreaLayoutItem::minimumSize() const
{
if (widgetItem)
return widgetItem->minimumSize().grownBy(widgetItem->widget()->contentsMargins());
- if (subinfo != 0)
+ if (subinfo != nullptr)
return subinfo->minimumSize();
return QSize(0, 0);
}
@@ -149,7 +149,7 @@ QSize QDockAreaLayoutItem::maximumSize() const
{
if (widgetItem)
return widgetItem->maximumSize().grownBy(widgetItem->widget()->contentsMargins());
- if (subinfo != 0)
+ if (subinfo != nullptr)
return subinfo->maximumSize();
return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
}
@@ -161,22 +161,22 @@ bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const
bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const
{
- if ((flags & GapItem) || placeHolderItem != 0)
+ if ((flags & GapItem) || placeHolderItem != nullptr)
return false;
- if (widgetItem != 0)
+ if (widgetItem != nullptr)
return ((widgetItem->expandingDirections() & o) == o);
- if (subinfo != 0)
+ if (subinfo != nullptr)
return subinfo->expansive(o);
return false;
}
QSize QDockAreaLayoutItem::sizeHint() const
{
- if (placeHolderItem != 0)
+ if (placeHolderItem != nullptr)
return QSize(0, 0);
if (widgetItem)
return widgetItem->sizeHint().grownBy(widgetItem->widget()->contentsMargins());
- if (subinfo != 0)
+ if (subinfo != nullptr)
return subinfo->sizeHint();
return QSize(-1, -1);
}
@@ -185,14 +185,14 @@ QDockAreaLayoutItem
&QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other)
{
widgetItem = other.widgetItem;
- if (other.subinfo == 0)
- subinfo = 0;
+ if (other.subinfo == nullptr)
+ subinfo = nullptr;
else
subinfo = new QDockAreaLayoutInfo(*other.subinfo);
delete placeHolderItem;
- if (other.placeHolderItem == 0)
- placeHolderItem = 0;
+ if (other.placeHolderItem == nullptr)
+ placeHolderItem = nullptr;
else
placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);
@@ -210,7 +210,7 @@ QDockAreaLayoutItem
#if QT_CONFIG(tabbar)
static quintptr tabId(const QDockAreaLayoutItem &item)
{
- if (item.widgetItem == 0)
+ if (item.widgetItem == nullptr)
return 0;
return reinterpret_cast<quintptr>(item.widgetItem->widget());
}
@@ -219,9 +219,9 @@ static quintptr tabId(const QDockAreaLayoutItem &item)
static const int zero = 0;
QDockAreaLayoutInfo::QDockAreaLayoutInfo()
- : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
+ : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(nullptr)
#if QT_CONFIG(tabbar)
- , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
+ , tabbed(false), tabBar(nullptr), tabBarShape(QTabBar::RoundedSouth)
#endif
{
}
@@ -231,7 +231,7 @@ QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPositio
QMainWindow *window)
: sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
#if QT_CONFIG(tabbar)
- , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
+ , tabbed(false), tabBar(nullptr), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
#endif
{
#if !QT_CONFIG(tabbar)
@@ -250,7 +250,7 @@ void QDockAreaLayoutInfo::clear()
rect = QRect();
#if QT_CONFIG(tabbar)
tabbed = false;
- tabBar = 0;
+ tabBar = nullptr;
#endif
}
@@ -403,7 +403,7 @@ QSize QDockAreaLayoutInfo::sizeHint() const
int a = 0, b = 0;
int min_perp = 0;
int max_perp = QWIDGETSIZE_MAX;
- const QDockAreaLayoutItem *previous = 0;
+ const QDockAreaLayoutItem *previous = nullptr;
for (int i = 0; i < item_list.size(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
if (item.skip())
@@ -552,7 +552,7 @@ void QDockAreaLayoutInfo::fitItems()
int max_size = realMaxSize(*this);
int last_index = -1;
- const QDockAreaLayoutItem *previous = 0;
+ const QDockAreaLayoutItem *previous = nullptr;
for (int i = 0; i < item_list.size(); ++i) {
QDockAreaLayoutItem &item = item_list[i];
if (item.skip())
@@ -633,7 +633,7 @@ void QDockAreaLayoutInfo::fitItems()
item.size = ls.size;
item.pos = ls.pos;
- if (item.subinfo != 0) {
+ if (item.subinfo != nullptr) {
item.subinfo->rect = itemRect(i);
item.subinfo->fitItems();
}
@@ -771,7 +771,7 @@ QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos,
if (item.pos + item.size < pos)
continue;
- if (item.subinfo != 0
+ if (item.subinfo != nullptr
#if QT_CONFIG(tabbar)
&& !item.subinfo->tabbed
#endif
@@ -967,7 +967,7 @@ int QDockAreaLayoutInfo::separatorMove(int index, int delta)
const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
item.size = ls.size - separatorSpace;
item.pos = ls.pos;
- if (item.subinfo != 0) {
+ if (item.subinfo != nullptr) {
item.subinfo->rect = itemRect(i);
item.subinfo->fitItems();
}
@@ -979,7 +979,7 @@ int QDockAreaLayoutInfo::separatorMove(int index, int delta)
void QDockAreaLayoutInfo::unnest(int index)
{
QDockAreaLayoutItem &item = item_list[index];
- if (item.subinfo == 0)
+ if (item.subinfo == nullptr)
return;
if (item.subinfo->item_list.count() > 1)
return;
@@ -988,14 +988,14 @@ void QDockAreaLayoutInfo::unnest(int index)
item_list.removeAt(index);
} else if (item.subinfo->item_list.count() == 1) {
QDockAreaLayoutItem &child = item.subinfo->item_list.first();
- if (child.widgetItem != 0) {
+ if (child.widgetItem != nullptr) {
item.widgetItem = child.widgetItem;
delete item.subinfo;
- item.subinfo = 0;
- } else if (child.subinfo != 0) {
+ item.subinfo = nullptr;
+ } else if (child.subinfo != nullptr) {
QDockAreaLayoutInfo *tmp = item.subinfo;
item.subinfo = child.subinfo;
- child.subinfo = 0;
+ child.subinfo = nullptr;
tmp->item_list.clear();
delete tmp;
}
@@ -1009,7 +1009,7 @@ void QDockAreaLayoutInfo::remove(const QList<int> &path)
if (path.count() > 1) {
const int index = path.first();
QDockAreaLayoutItem &item = item_list[index];
- Q_ASSERT(item.subinfo != 0);
+ Q_ASSERT(item.subinfo != nullptr);
item.subinfo->remove(path.mid(1));
unnest(index);
} else {
@@ -1028,13 +1028,13 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)
if (path.count() > 1) {
QDockAreaLayoutItem &item = item_list[index];
- Q_ASSERT(item.subinfo != 0);
+ Q_ASSERT(item.subinfo != nullptr);
return item.subinfo->plug(path.mid(1));
}
QDockAreaLayoutItem &item = item_list[index];
- Q_ASSERT(item.widgetItem != 0);
+ Q_ASSERT(item.widgetItem != nullptr);
Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem);
item.flags &= ~QDockAreaLayoutItem::GapItem;
return item.widgetItem;
@@ -1047,7 +1047,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
const int index = path.first();
if (path.count() > 1) {
QDockAreaLayoutItem &item = item_list[index];
- Q_ASSERT(item.subinfo != 0);
+ Q_ASSERT(item.subinfo != nullptr);
return item.subinfo->unplug(path.mid(1));
}
@@ -1078,7 +1078,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
quintptr QDockAreaLayoutInfo::currentTabId() const
{
- if (!tabbed || tabBar == 0)
+ if (!tabbed || tabBar == nullptr)
return 0;
int index = tabBar->currentIndex();
@@ -1095,7 +1095,7 @@ void QDockAreaLayoutInfo::setCurrentTab(QWidget *widget)
void QDockAreaLayoutInfo::setCurrentTabId(quintptr id)
{
- if (!tabbed || tabBar == 0)
+ if (!tabbed || tabBar == nullptr)
return;
for (int i = 0; i < tabBar->count(); ++i) {
@@ -1114,7 +1114,7 @@ static QRect dockedGeometry(QWidget *widget)
QDockWidgetLayout *layout
= qobject_cast<QDockWidgetLayout*>(widget->layout());
- if(layout != 0 && layout->nativeWindowDeco())
+ if (layout && layout->nativeWindowDeco())
titleHeight = layout->titleHeight();
QRect result = widget->geometry();
@@ -1138,7 +1138,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
if (path.count() > 1) {
QDockAreaLayoutItem &item = item_list[index];
- if (item.subinfo == 0
+ if (item.subinfo == nullptr
#if QT_CONFIG(tabbar)
|| (item.subinfo->tabbed && !insert_tabbed)
#endif
@@ -1149,7 +1149,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
QDockAreaLayoutInfo *subinfo = item.subinfo;
QLayoutItem *widgetItem = item.widgetItem;
QPlaceHolderItem *placeHolderItem = item.placeHolderItem;
- QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
+ QRect r = subinfo == nullptr ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
#if !QT_CONFIG(tabbar)
@@ -1160,11 +1160,11 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid
//item become a new top-level
item.subinfo = new_info;
- item.widgetItem = 0;
- item.placeHolderItem = 0;
+ item.widgetItem = nullptr;
+ item.placeHolderItem = nullptr;
QDockAreaLayoutItem new_item
- = widgetItem == 0
+ = widgetItem == nullptr
? QDockAreaLayoutItem(subinfo)
: widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem);
new_item.size = pick(opposite, r.size());
@@ -1265,16 +1265,16 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget)
return this;
#endif
- if (item.widgetItem != 0 && item.widgetItem->widget() == widget)
+ if (item.widgetItem != nullptr && item.widgetItem->widget() == widget)
return this;
- if (item.subinfo != 0) {
+ if (item.subinfo != nullptr) {
if (QDockAreaLayoutInfo *result = item.subinfo->info(widget))
return result;
}
}
- return 0;
+ return nullptr;
}
QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path)
@@ -1284,7 +1284,7 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path)
index = -index - 1;
if (index >= item_list.count())
return this;
- if (path.count() == 1 || item_list[index].subinfo == 0)
+ if (path.count() == 1 || item_list[index].subinfo == nullptr)
return this;
return item_list[index].subinfo->info(path.mid(1));
}
@@ -1341,7 +1341,7 @@ QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const
const int index = path.first();
if (path.count() > 1) {
const QDockAreaLayoutItem &item = item_list.at(index);
- Q_ASSERT(item.subinfo != 0);
+ Q_ASSERT(item.subinfo != nullptr);
return item.subinfo->itemRect(path.mid(1));
}
@@ -1374,7 +1374,7 @@ QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const
const int index = path.first();
if (path.count() > 1) {
const QDockAreaLayoutItem &item = item_list.at(index);
- Q_ASSERT(item.subinfo != 0);
+ Q_ASSERT(item.subinfo != nullptr);
return item.subinfo->separatorRect(path.mid(1));
}
return separatorRect(index);
@@ -1395,7 +1395,7 @@ QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const
continue;
if (item.pos + item.size > pos) {
- if (item.subinfo != 0) {
+ if (item.subinfo != nullptr) {
QList<int> result = item.subinfo->findSeparator(_pos);
if (!result.isEmpty()) {
result.prepend(i);
@@ -1428,7 +1428,7 @@ QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) co
for (int i = 0; i < item_list.size(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.subinfo != 0) {
+ if (item.subinfo != nullptr) {
QList<int> result = item.subinfo->indexOfPlaceHolder(objectName);
if (!result.isEmpty()) {
result.prepend(i);
@@ -1437,7 +1437,7 @@ QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) co
continue;
}
- if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) {
+ if (item.placeHolderItem != nullptr && item.placeHolderItem->objectName == objectName) {
QList<int> result;
result << i;
return result;
@@ -1452,10 +1452,10 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const
for (int i = 0; i < item_list.size(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.placeHolderItem != 0)
+ if (item.placeHolderItem != nullptr)
continue;
- if (item.subinfo != 0) {
+ if (item.subinfo != nullptr) {
QList<int> result = item.subinfo->indexOf(widget);
if (!result.isEmpty()) {
result.prepend(i);
@@ -1477,7 +1477,7 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const
QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const
{
QMainWindowLayout *result = qt_mainwindow_layout(mainWindow);
- Q_ASSERT(result != 0);
+ Q_ASSERT(result != nullptr);
return result;
}
@@ -1536,7 +1536,7 @@ QDockWidget *QDockAreaLayoutInfo::apply(bool animate)
if (item.flags & QDockAreaLayoutItem::GapItem)
continue;
- if (item.subinfo != 0) {
+ if (item.subinfo != nullptr) {
item.subinfo->apply(animate);
continue;
}
@@ -1681,7 +1681,7 @@ void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)
= new QDockAreaLayoutInfo(sep, dockPos, o, tabBarShape, mainWindow);
item_list[index].subinfo = new_info;
new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem));
- item_list[index].widgetItem = 0;
+ item_list[index].widgetItem = nullptr;
new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem));
new_info->tabbed = true;
new_info->updateTabBar();
@@ -1703,7 +1703,7 @@ void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation,
= new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow);
item_list[index].subinfo = new_info;
new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem));
- item_list[index].widgetItem = 0;
+ item_list[index].widgetItem = nullptr;
new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem));
}
}
@@ -1714,7 +1714,7 @@ QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path)
const int index = path.first();
if (path.count() > 1) {
const QDockAreaLayoutItem &item = item_list[index];
- Q_ASSERT(item.subinfo != 0);
+ Q_ASSERT(item.subinfo != nullptr);
return item.subinfo->item(path.mid(1));
}
return item_list[index];
@@ -1724,7 +1724,7 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const
{
for (int i = 0; i < item_list.count(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.placeHolderItem != 0)
+ if (item.placeHolderItem != nullptr)
continue;
if (item.subinfo) {
if (QLayoutItem *ret = item.subinfo->itemAt(x, index))
@@ -1734,14 +1734,14 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const
return item.widgetItem;
}
}
- return 0;
+ return nullptr;
}
QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index)
{
for (int i = 0; i < item_list.count(); ++i) {
QDockAreaLayoutItem &item = item_list[i];
- if (item.placeHolderItem != 0)
+ if (item.placeHolderItem != nullptr)
continue;
else if (item.subinfo) {
if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) {
@@ -1752,14 +1752,14 @@ QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index)
if ((*x)++ == index) {
item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget());
QLayoutItem *ret = item.widgetItem;
- item.widgetItem = 0;
+ item.widgetItem = nullptr;
if (item.size != -1)
item.flags |= QDockAreaLayoutItem::KeepSize;
return ret;
}
}
}
- return 0;
+ return nullptr;
}
void QDockAreaLayoutInfo::deleteAllLayoutItems()
@@ -1770,7 +1770,7 @@ void QDockAreaLayoutInfo::deleteAllLayoutItems()
item.subinfo->deleteAllLayoutItems();
} else {
delete item.widgetItem;
- item.widgetItem = 0;
+ item.widgetItem = nullptr;
}
}
}
@@ -1801,7 +1801,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
for (int i = 0; i < item_list.count(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.widgetItem != 0) {
+ if (item.widgetItem != nullptr) {
stream << (uchar) WidgetMarker;
QWidget *w = item.widgetItem->widget();
QString name = w->objectName();
@@ -1825,7 +1825,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
stream << item.pos << item.size << pick(o, item.minimumSize())
<< pick(o, item.maximumSize());
}
- } else if (item.placeHolderItem != 0) {
+ } else if (item.placeHolderItem != nullptr) {
stream << (uchar) WidgetMarker;
stream << item.placeHolderItem->objectName;
uchar flags = 0;
@@ -1840,7 +1840,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
} else {
stream << item.pos << item.size << (int)0 << (int)0;
}
- } else if (item.subinfo != 0) {
+ } else if (item.subinfo != nullptr) {
stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize());
item.subinfo->saveState(stream);
}
@@ -1894,7 +1894,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
continue;
}
- QDockWidget *widget = 0;
+ QDockWidget *widget = nullptr;
for (int j = 0; j < widgets.count(); ++j) {
if (widgets.at(j)->objectName() == name) {
widget = widgets.takeAt(j);
@@ -1902,7 +1902,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*>
}
}
- if (widget == 0) {
+ if (widget == nullptr) {
QPlaceHolderItem *placeHolder = new QPlaceHolderItem;
QDockAreaLayoutItem item(placeHolder);
@@ -2081,7 +2081,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
- if (that->tabBar == 0) {
+ if (that->tabBar == nullptr) {
that->tabBar = mainWindowLayout()->getTabBar();
that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape));
that->tabBar->setDrawBase(true);
@@ -2101,7 +2101,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const
gap = true;
continue;
}
- if (item.widgetItem == 0)
+ if (item.widgetItem == nullptr)
continue;
QDockWidget *dw = qobject_cast<QDockWidget*>(item.widgetItem->widget());
@@ -2155,12 +2155,12 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape)
if (shape == tabBarShape)
return;
tabBarShape = shape;
- if (tabBar != 0)
+ if (tabBar != nullptr)
tabBar->setShape(static_cast<QTabBar::Shape>(shape));
for (int i = 0; i < item_list.count(); ++i) {
QDockAreaLayoutItem &item = item_list[i];
- if (item.subinfo != 0)
+ if (item.subinfo != nullptr)
item.subinfo->setTabBarShape(shape);
}
}
@@ -2192,7 +2192,7 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const
for (int i = 0; i < item_list.count(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.subinfo != 0)
+ if (item.subinfo != nullptr)
result += item.subinfo->usedTabBars();
}
@@ -2212,7 +2212,7 @@ QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const
for (int i = 0; i < item_list.count(); ++i) {
const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.subinfo != 0)
+ if (item.subinfo != nullptr)
result += item.subinfo->usedSeparatorWidgets();
}
@@ -2277,7 +2277,7 @@ void QDockAreaLayoutInfo::moveTab(int from, int to)
QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true)
{
mainWindow = win;
- sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win);
+ sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, win);
#if QT_CONFIG(tabbar)
const int tabShape = QTabBar::RoundedSouth;
#else
@@ -2291,7 +2291,7 @@ QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true)
= QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);
docks[QInternal::BottomDock]
= QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
- centralWidgetItem = 0;
+ centralWidgetItem = nullptr;
corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea;
@@ -2491,7 +2491,7 @@ QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget)
return result;
}
- return 0;
+ return nullptr;
}
QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path)
@@ -2623,7 +2623,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
QSize center_hint(0, 0);
QSize center_min(0, 0);
QSize center_max(0, 0);
- const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
+ const bool have_central = centralWidgetItem != nullptr && !centralWidgetItem->isEmpty();
if (have_central) {
center_hint = centralWidgetRect.size();
if (!center_hint.isValid())
@@ -2670,7 +2670,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
- if (_ver_struct_list != 0) {
+ if (_ver_struct_list != nullptr) {
QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;
ver_struct_list.resize(3);
@@ -2732,7 +2732,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
ver_struct_list[1].maximumSize = QWIDGETSIZE_MAX;
}
- if (_hor_struct_list != 0) {
+ if (_hor_struct_list != nullptr) {
QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list;
hor_struct_list.resize(3);
@@ -2803,7 +2803,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
if (!docks[QInternal::TopDock].isEmpty()) {
QRect r = docks[QInternal::TopDock].rect;
- if (hor_struct_list != 0) {
+ if (hor_struct_list != nullptr) {
r.setLeft(corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea
|| docks[QInternal::LeftDock].isEmpty()
? rect.left() : hor_struct_list->at(1).pos);
@@ -2811,7 +2811,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
|| docks[QInternal::RightDock].isEmpty()
? rect.right() : hor_struct_list->at(2).pos - sep - 1);
}
- if (ver_struct_list != 0) {
+ if (ver_struct_list != nullptr) {
r.setTop(rect.top());
r.setBottom(ver_struct_list->at(1).pos - sep - 1);
}
@@ -2823,7 +2823,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
if (!docks[QInternal::BottomDock].isEmpty()) {
QRect r = docks[QInternal::BottomDock].rect;
- if (hor_struct_list != 0) {
+ if (hor_struct_list != nullptr) {
r.setLeft(corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea
|| docks[QInternal::LeftDock].isEmpty()
? rect.left() : hor_struct_list->at(1).pos);
@@ -2831,7 +2831,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
|| docks[QInternal::RightDock].isEmpty()
? rect.right() : hor_struct_list->at(2).pos - sep - 1);
}
- if (ver_struct_list != 0) {
+ if (ver_struct_list != nullptr) {
r.setTop(ver_struct_list->at(2).pos);
r.setBottom(rect.bottom());
}
@@ -2843,11 +2843,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
if (!docks[QInternal::LeftDock].isEmpty()) {
QRect r = docks[QInternal::LeftDock].rect;
- if (hor_struct_list != 0) {
+ if (hor_struct_list != nullptr) {
r.setLeft(rect.left());
r.setRight(hor_struct_list->at(1).pos - sep - 1);
}
- if (ver_struct_list != 0) {
+ if (ver_struct_list != nullptr) {
r.setTop(corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea
|| docks[QInternal::TopDock].isEmpty()
? rect.top() : ver_struct_list->at(1).pos);
@@ -2863,11 +2863,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
if (!docks[QInternal::RightDock].isEmpty()) {
QRect r = docks[QInternal::RightDock].rect;
- if (hor_struct_list != 0) {
+ if (hor_struct_list != nullptr) {
r.setLeft(hor_struct_list->at(2).pos);
r.setRight(rect.right());
}
- if (ver_struct_list != 0) {
+ if (ver_struct_list != nullptr) {
r.setTop(corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea
|| docks[QInternal::TopDock].isEmpty()
? rect.top() : ver_struct_list->at(1).pos);
@@ -2881,11 +2881,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
// center ---------------------------------------------------
- if (hor_struct_list != 0) {
+ if (hor_struct_list != nullptr) {
centralWidgetRect.setLeft(hor_struct_list->at(1).pos);
centralWidgetRect.setWidth(hor_struct_list->at(1).size);
}
- if (ver_struct_list != 0) {
+ if (ver_struct_list != nullptr) {
centralWidgetRect.setTop(ver_struct_list->at(1).pos);
centralWidgetRect.setHeight(ver_struct_list->at(1).size);
}
@@ -2919,7 +2919,7 @@ QSize QDockAreaLayout::sizeHint() const
int top_sep = 0;
int bottom_sep = 0;
- if (centralWidgetItem != 0) {
+ if (centralWidgetItem != nullptr) {
left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
@@ -2930,7 +2930,7 @@ QSize QDockAreaLayout::sizeHint() const
QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0);
QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep);
QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep);
- QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->sizeHint();
+ QSize center = centralWidgetItem == nullptr ? QSize(0, 0) : centralWidgetItem->sizeHint();
int row1 = top.width();
int row2 = left.width() + center.width() + right.width();
@@ -2969,7 +2969,7 @@ QSize QDockAreaLayout::minimumSize() const
int top_sep = 0;
int bottom_sep = 0;
- if (centralWidgetItem != 0) {
+ if (centralWidgetItem != nullptr) {
left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
@@ -2980,7 +2980,7 @@ QSize QDockAreaLayout::minimumSize() const
QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0);
QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep);
QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep);
- QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->minimumSize();
+ QSize center = centralWidgetItem == nullptr ? QSize(0, 0) : centralWidgetItem->minimumSize();
int row1 = top.width();
int row2 = left.width() + center.width() + right.width();
@@ -3040,7 +3040,7 @@ QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)
bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
{
- QDockAreaLayoutItem *item = 0;
+ QDockAreaLayoutItem *item = nullptr;
const auto groups =
mainWindow->findChildren<QDockWidgetGroupWindow *>(QString(), Qt::FindDirectChildrenOnly);
for (QDockWidgetGroupWindow *dwgw : groups) {
@@ -3059,7 +3059,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
}
QPlaceHolderItem *placeHolder = item->placeHolderItem;
- Q_ASSERT(placeHolder != 0);
+ Q_ASSERT(placeHolder != nullptr);
item->widgetItem = new QDockWidgetItem(dockWidget);
@@ -3069,7 +3069,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
}
dockWidget->setVisible(!placeHolder->hidden);
- item->placeHolderItem = 0;
+ item->placeHolderItem = nullptr;
delete placeHolder;
return true;
@@ -3116,7 +3116,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
return;
QDockAreaLayoutInfo *info = this->info(path);
- Q_ASSERT(info != 0);
+ Q_ASSERT(info != nullptr);
info->tab(path.last(), new QDockWidgetItem(second));
removePlaceHolder(second->objectName());
@@ -3181,7 +3181,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after,
return;
QDockAreaLayoutInfo *info = this->info(path);
- Q_ASSERT(info != 0);
+ Q_ASSERT(info != nullptr);
info->split(path.last(), orientation, new QDockWidgetItem(dockWidget));
removePlaceHolder(dockWidget->objectName());
@@ -3193,7 +3193,7 @@ void QDockAreaLayout::apply(bool animate)
for (int i = 0; i < QInternal::DockCount; ++i)
docks[i].apply(animate);
- if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) {
+ if (centralWidgetItem != nullptr && !centralWidgetItem->isEmpty()) {
widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect,
animate);
}
@@ -3255,9 +3255,9 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or
QVector<QLayoutStruct> list;
if (index == QInternal::LeftDock || index == QInternal::RightDock)
- getGrid(0, &list);
+ getGrid(nullptr, &list);
else
- getGrid(&list, 0);
+ getGrid(&list, nullptr);
int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock
? 0 : 1;
@@ -3271,9 +3271,9 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or
fallbackToSizeHints = false;
if (index == QInternal::LeftDock || index == QInternal::RightDock)
- setGrid(0, &list);
+ setGrid(nullptr, &list);
else
- setGrid(&list, 0);
+ setGrid(&list, nullptr);
apply(false);
@@ -3330,7 +3330,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const
QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const
{
- Q_ASSERT(x != 0);
+ Q_ASSERT(x != nullptr);
for (int i = 0; i < QInternal::DockCount; ++i) {
const QDockAreaLayoutInfo &dock = docks[i];
@@ -3341,12 +3341,12 @@ QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const
if (centralWidgetItem && (*x)++ == index)
return centralWidgetItem;
- return 0;
+ return nullptr;
}
QLayoutItem *QDockAreaLayout::takeAt(int *x, int index)
{
- Q_ASSERT(x != 0);
+ Q_ASSERT(x != nullptr);
for (int i = 0; i < QInternal::DockCount; ++i) {
QDockAreaLayoutInfo &dock = docks[i];
@@ -3356,11 +3356,11 @@ QLayoutItem *QDockAreaLayout::takeAt(int *x, int index)
if (centralWidgetItem && (*x)++ == index) {
QLayoutItem *ret = centralWidgetItem;
- centralWidgetItem = 0;
+ centralWidgetItem = nullptr;
return ret;
}
- return 0;
+ return nullptr;
}
void QDockAreaLayout::deleteAllLayoutItems()
@@ -3399,7 +3399,7 @@ QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const
QRect QDockAreaLayout::gapRect(const QList<int> &path) const
{
const QDockAreaLayoutInfo *info = this->info(path);
- if (info == 0)
+ if (info == nullptr)
return QRect();
int index = path.last();
if (index < 0 || index >= info->item_list.count())
@@ -3419,7 +3419,7 @@ void QDockAreaLayout::keepSize(QDockWidget *w)
void QDockAreaLayout::styleChangedEvent()
{
- sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow);
+ sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, mainWindow);
if (isValid())
fitLayout();
}
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 05ec3aface..1d358c493e 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -197,7 +197,7 @@ QSize QDockWidgetTitleButton::sizeHint() const
{
ensurePolished();
- int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this);
+ int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, nullptr, this);
if (!icon().isNull()) {
const QSize sz = icon().actualSize(dockButtonIconSize());
size += qMax(sz.width(), sz.height());
@@ -226,7 +226,7 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
opt.init(this);
opt.state |= QStyle::State_AutoRaise;
- if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this))
+ if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, nullptr, this))
{
if (isEnabled() && underMouse() && !isChecked() && !isDown())
opt.state |= QStyle::State_Raised;
@@ -238,8 +238,8 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
}
opt.icon = icon();
- opt.subControls = 0;
- opt.activeSubControls = 0;
+ opt.subControls = { };
+ opt.activeSubControls = { };
opt.features = QStyleOptionToolButton::None;
opt.arrowType = Qt::NoArrow;
opt.iconSize = dockButtonIconSize();
@@ -311,12 +311,12 @@ QLayoutItem *QDockWidgetLayout::itemAt(int index) const
int cnt = 0;
for (int i = 0; i < item_list.count(); ++i) {
QLayoutItem *item = item_list.at(i);
- if (item == 0)
+ if (item == nullptr)
continue;
if (index == cnt++)
return item;
}
- return 0;
+ return nullptr;
}
QLayoutItem *QDockWidgetLayout::takeAt(int index)
@@ -324,7 +324,7 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index)
int j = 0;
for (int i = 0; i < item_list.count(); ++i) {
QLayoutItem *item = item_list.at(i);
- if (item == 0)
+ if (item == nullptr)
continue;
if (index == j) {
item_list[i] = 0;
@@ -333,7 +333,7 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index)
}
++j;
}
- return 0;
+ return nullptr;
}
int QDockWidgetLayout::count() const
@@ -362,7 +362,7 @@ QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) co
const bool nativeDeco = nativeWindowDeco(floating);
int fw = floating && !nativeDeco
- ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, w)
+ ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, w)
: 0;
const int th = titleHeight();
@@ -394,7 +394,7 @@ QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) co
uint explicitMin = 0;
uint explicitMax = 0;
- if (w->d_func()->extra != 0) {
+ if (w->d_func()->extra != nullptr) {
explicitMin = w->d_func()->extra->explicitMinSize;
explicitMax = w->d_func()->extra->explicitMaxSize;
}
@@ -448,7 +448,7 @@ QSize QDockWidgetLayout::minimumSize() const
QWidget *QDockWidgetLayout::widgetForRole(Role r) const
{
QLayoutItem *item = item_list.at(r);
- return item == 0 ? 0 : item->widget();
+ return item == nullptr ? nullptr : item->widget();
}
QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const
@@ -459,12 +459,12 @@ QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const
void QDockWidgetLayout::setWidgetForRole(Role r, QWidget *w)
{
QWidget *old = widgetForRole(r);
- if (old != 0) {
+ if (old != nullptr) {
old->hide();
removeWidget(old);
}
- if (w != 0) {
+ if (w != nullptr) {
addChildWidget(w);
item_list[r] = new QWidgetItemV2(w);
w->show();
@@ -505,8 +505,8 @@ int QDockWidgetLayout::minimumTitleWidth() const
int titleHeight = this->titleHeight();
- int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
- int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
+ int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, nullptr, q);
+ int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, q);
return pick(verticalTitleBar, closeSize)
+ pick(verticalTitleBar, floatSize)
@@ -531,7 +531,7 @@ int QDockWidgetLayout::titleHeight() const
perp(verticalTitleBar, floatSize));
QFontMetrics titleFontMetrics = q->fontMetrics();
- int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
+ int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, nullptr, q);
return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
}
@@ -543,7 +543,7 @@ void QDockWidgetLayout::setGeometry(const QRect &geometry)
bool nativeDeco = nativeWindowDeco();
int fw = q->isFloating() && !nativeDeco
- ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q)
+ ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, q)
: 0;
if (nativeDeco) {
@@ -730,7 +730,7 @@ void QDockWidgetPrivate::updateButtons()
QStyleOptionDockWidget opt;
q->initStyleOption(&opt);
- bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
+ bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != nullptr;
bool nativeDeco = dwLayout->nativeWindowDeco();
bool hideButtons = nativeDeco || customTitleBar;
@@ -777,18 +777,18 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
{
Q_Q(QDockWidget);
- if (state != 0)
+ if (state != nullptr)
return;
QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
- Q_ASSERT(layout != 0);
- if (layout->pluggingWidget != 0) // the main window is animating a docking operation
+ Q_ASSERT(layout != nullptr);
+ if (layout->pluggingWidget != nullptr) // the main window is animating a docking operation
return;
state = new QDockWidgetPrivate::DragState;
state->pressPos = pos;
state->dragging = false;
- state->widgetItem = 0;
+ state->widgetItem = nullptr;
state->ownWidgetItem = false;
state->nca = nca;
state->ctrlDrag = false;
@@ -804,14 +804,14 @@ void QDockWidgetPrivate::startDrag(bool group)
{
Q_Q(QDockWidget);
- if (state == 0 || state->dragging)
+ if (state == nullptr || state->dragging)
return;
QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
- Q_ASSERT(layout != 0);
+ Q_ASSERT(layout != nullptr);
state->widgetItem = layout->unplug(q, group);
- if (state->widgetItem == 0) {
+ if (state->widgetItem == nullptr) {
/* 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
@@ -838,7 +838,7 @@ void QDockWidgetPrivate::startDrag(bool group)
void QDockWidgetPrivate::endDrag(bool abort)
{
Q_Q(QDockWidget);
- Q_ASSERT(state != 0);
+ Q_ASSERT(state != nullptr);
q->releaseMouse();
@@ -881,7 +881,7 @@ void QDockWidgetPrivate::endDrag(bool abort)
}
}
delete state;
- state = 0;
+ state = nullptr;
}
void QDockWidgetPrivate::setResizerActive(bool active)
@@ -900,7 +900,7 @@ bool QDockWidgetPrivate::isAnimating() const
Q_Q(const QDockWidget);
QMainWindowLayout *mainWinLayout = qt_mainwindow_layout_from_dock(q);
- if (mainWinLayout == 0)
+ if (mainWinLayout == nullptr)
return false;
return (const void*)mainWinLayout->pluggingWidget == (const void*)q;
@@ -925,7 +925,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
// is not (but allow moving if the window is floating)
(!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
(qobject_cast<QMainWindow*>(parent) == 0 && !floatingTab) ||
- isAnimating() || state != 0) {
+ isAnimating() || state != nullptr) {
return false;
}
@@ -972,7 +972,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
if (!dwlayout->nativeWindowDeco()) {
if (!state->dragging
- && mwlayout->pluggingWidget == 0
+ && mwlayout->pluggingWidget == nullptr
&& (event->pos() - state->pressPos).manhattanLength()
> QApplication::startDragDistance()) {
startDrag();
@@ -1019,7 +1019,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
{
Q_Q(QDockWidget);
- int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
+ int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, q);
QWidget *tl = q->topLevelWidget();
QRect geo = tl->geometry();
@@ -1035,21 +1035,21 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
case QEvent::NonClientAreaMouseButtonPress:
if (!titleRect.contains(event->globalPos()))
break;
- if (state != 0)
+ if (state != nullptr)
break;
if (qobject_cast<QMainWindow*>(parent) == 0 && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
break;
if (isAnimating())
break;
initDrag(event->pos(), true);
- if (state == 0)
+ if (state == nullptr)
break;
state->ctrlDrag = (event->modifiers() & Qt::ControlModifier) ||
(!hasFeature(this, QDockWidget::DockWidgetMovable) && q->isFloating());
startDrag();
break;
case QEvent::NonClientAreaMouseMove:
- if (state == 0 || !state->dragging)
+ if (state == nullptr || !state->dragging)
break;
#ifndef Q_OS_MAC
@@ -1085,7 +1085,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
{
Q_Q(QDockWidget);
- if (state == 0 || !state->dragging || !state->nca)
+ if (state == nullptr || !state->dragging || !state->nca)
return;
if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
@@ -1098,7 +1098,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
return;
QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
- Q_ASSERT(layout != 0);
+ Q_ASSERT(layout != nullptr);
QPoint globalMousePos = event->pos() + state->pressPos;
layout->hover(state->widgetItem, globalMousePos);
@@ -1384,7 +1384,7 @@ void QDockWidget::setFloating(bool floating)
Q_D(QDockWidget);
// the initial click of a double-click may have started a drag...
- if (d->state != 0)
+ if (d->state != nullptr)
d->endDrag(true);
QRect r = d->undockedGeometry;
@@ -1479,7 +1479,7 @@ void QDockWidget::paintEvent(QPaintEvent *event)
QDockWidgetLayout *layout
= qobject_cast<QDockWidgetLayout*>(this->layout());
- bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
+ bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != nullptr;
bool nativeDeco = layout->nativeWindowDeco();
if (!nativeDeco && !customTitleBar) {
@@ -1516,7 +1516,7 @@ bool QDockWidget::event(QEvent *event)
switch (event->type()) {
#ifndef QT_NO_ACTION
case QEvent::Hide:
- if (layout != 0)
+ if (layout != nullptr)
layout->keepSize(this);
d->toggleViewAction->setChecked(false);
emit visibilityChanged(false);
@@ -1542,12 +1542,12 @@ bool QDockWidget::event(QEvent *event)
break;
case QEvent::ZOrderChange: {
bool onTop = false;
- if (win != 0) {
+ if (win != nullptr) {
const QObjectList &siblings = win->children();
onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
}
#if QT_CONFIG(tabbar)
- if (!isFloating() && layout != 0 && onTop)
+ if (!isFloating() && layout != nullptr && onTop)
layout->raise(this);
#endif
break;
@@ -1591,7 +1591,7 @@ bool QDockWidget::event(QEvent *event)
break;
case QEvent::Resize:
// if the mainwindow is plugging us, we don't want to update undocked geometry
- if (isFloating() && layout != 0 && layout->pluggingWidget != this)
+ if (isFloating() && layout != nullptr && layout->pluggingWidget != this)
d->undockedGeometry = geometry();
// Usually the window won't get resized while it's being moved, but it can happen,
@@ -1609,11 +1609,14 @@ bool QDockWidget::event(QEvent *event)
#ifndef QT_NO_ACTION
/*!
- Returns a checkable action that can be used to show or close this
- dock widget.
+ Returns a checkable action that can be added to menus and toolbars so that
+ the user can show or close this dock widget.
The action's text is set to the dock widget's window title.
+ \note The action can not be used to programmatically show or hide the dock
+ widget. Use the \l visible property for that.
+
\sa QAction::text, QWidget::windowTitle
*/
QAction * QDockWidget::toggleViewAction() const
@@ -1671,8 +1674,8 @@ QAction * QDockWidget::toggleViewAction() const
\since 4.3
Sets an arbitrary \a widget as the dock widget's title bar. If \a widget
- is 0, any custom title bar widget previously set on the dock widget is
- removed, but not deleted, and the default title bar will be used
+ is \nullptr, any custom title bar widget previously set on the dock widget
+ is removed, but not deleted, and the default title bar will be used
instead.
If a title bar widget is set, QDockWidget will not use native window
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index bc6ac86c45..e663ec4c2d 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -201,7 +201,11 @@ inline QLayoutItem *QDockWidgetItem::dockWidgetChildItem() const
inline QDockWidgetLayout *QDockWidgetItem::dockWidgetLayout() const
{
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWidget *w = const_cast<QDockWidgetItem*>(this)->widget();
+#else
+ QWidget *w = widget();
+#endif
if (w != nullptr)
return qobject_cast<QDockWidgetLayout*>(w->layout());
return nullptr;
diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp
index 7069ef0368..ee4095cb36 100644
--- a/src/widgets/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
@@ -65,7 +65,7 @@ class QAlphaWidget: public QWidget, private QEffects
{
Q_OBJECT
public:
- QAlphaWidget(QWidget* w, Qt::WindowFlags f = 0);
+ QAlphaWidget(QWidget* w, Qt::WindowFlags f = { });
~QAlphaWidget();
void run(int time);
@@ -93,7 +93,7 @@ private:
QElapsedTimer checkTime;
};
-static QAlphaWidget* q_blend = 0;
+static QAlphaWidget* q_blend = nullptr;
/*
Constructs a QAlphaWidget.
@@ -285,7 +285,7 @@ void QAlphaWidget::render()
lower();
}
}
- q_blend = 0;
+ q_blend = nullptr;
deleteLater();
} else {
alphaBlend();
@@ -377,13 +377,13 @@ private:
QPixmap pm;
};
-static QRollEffect* q_roll = 0;
+static QRollEffect* q_roll = nullptr;
/*
Construct a QRollEffect widget.
*/
QRollEffect::QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient)
- : QWidget(0, f), orientation(orient)
+ : QWidget(nullptr, f), orientation(orient)
{
#ifndef Q_OS_WIN
setEnabled(false);
@@ -550,7 +550,7 @@ void QRollEffect::scroll()
lower();
}
}
- q_roll = 0;
+ q_roll = nullptr;
deleteLater();
}
}
@@ -563,7 +563,7 @@ void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time)
{
if (q_roll) {
q_roll->deleteLater();
- q_roll = 0;
+ q_roll = nullptr;
}
if (!w)
@@ -585,7 +585,7 @@ void qFadeEffect(QWidget* w, int time)
{
if (q_blend) {
q_blend->deleteLater();
- q_blend = 0;
+ q_blend = nullptr;
}
if (!w)
diff --git a/src/widgets/widgets/qfocusframe.cpp b/src/widgets/widgets/qfocusframe.cpp
index 0992becdf0..4d64c24db3 100644
--- a/src/widgets/widgets/qfocusframe.cpp
+++ b/src/widgets/widgets/qfocusframe.cpp
@@ -55,8 +55,8 @@ class QFocusFramePrivate : public QWidgetPrivate
bool showFrameAboveWidget;
public:
QFocusFramePrivate() {
- widget = 0;
- frameParent = 0;
+ widget = nullptr;
+ frameParent = nullptr;
sendChildEvents = false;
showFrameAboveWidget = false;
}
@@ -154,12 +154,12 @@ void QFocusFrame::initStyleOption(QStyleOption *option) const
*/
QFocusFrame::QFocusFrame(QWidget *parent)
- : QWidget(*new QFocusFramePrivate, parent, 0)
+ : QWidget(*new QFocusFramePrivate, parent, { })
{
setAttribute(Qt::WA_TransparentForMouseEvents);
setFocusPolicy(Qt::NoFocus);
setAttribute(Qt::WA_NoChildEventsForParent, true);
- setAttribute(Qt::WA_AcceptDrops, style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this));
+ setAttribute(Qt::WA_AcceptDrops, style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, nullptr, this));
}
/*!
@@ -184,7 +184,7 @@ QFocusFrame::setWidget(QWidget *widget)
{
Q_D(QFocusFrame);
- if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this))
+ if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, nullptr, this))
d->showFrameAboveWidget = true;
else
d->showFrameAboveWidget = false;
@@ -205,7 +205,7 @@ QFocusFrame::setWidget(QWidget *widget)
d->widget = widget;
d->widget->installEventFilter(this);
QWidget *p = widget->parentWidget();
- QWidget *prev = 0;
+ QWidget *prev = nullptr;
if (d->showFrameAboveWidget) {
// Find the right parent for the focus frame.
while (p) {
@@ -231,7 +231,7 @@ QFocusFrame::setWidget(QWidget *widget)
}
d->update();
} else {
- d->widget = 0;
+ d->widget = nullptr;
hide();
}
}
@@ -290,7 +290,7 @@ QFocusFrame::eventFilter(QObject *o, QEvent *e)
case QEvent::ParentChange:
if (d->showFrameAboveWidget) {
QWidget *w = d->widget;
- setWidget(0);
+ setWidget(nullptr);
setWidget(w);
} else {
d->update();
@@ -304,13 +304,13 @@ QFocusFrame::eventFilter(QObject *o, QEvent *e)
setPalette(d->widget->palette());
break;
case QEvent::ZOrderChange:
- if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this))
+ if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, nullptr, this))
raise();
else
stackUnder(d->widget);
break;
case QEvent::Destroy:
- setWidget(0);
+ setWidget(nullptr);
break;
default:
break;
diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp
index eec794562a..048fe42948 100644
--- a/src/widgets/widgets/qgroupbox.cpp
+++ b/src/widgets/widgets/qgroupbox.cpp
@@ -178,7 +178,7 @@ void QGroupBoxPrivate::click()
*/
QGroupBox::QGroupBox(QWidget *parent)
- : QWidget(*new QGroupBoxPrivate, parent, 0)
+ : QWidget(*new QGroupBoxPrivate, parent, { })
{
Q_D(QGroupBox);
d->init();
@@ -424,8 +424,8 @@ void QGroupBoxPrivate::_q_fixFocus(Qt::FocusReason reason)
Q_Q(QGroupBox);
QWidget *fw = q->focusWidget();
if (!fw || fw == q) {
- QWidget * best = 0;
- QWidget * candidate = 0;
+ QWidget * best = nullptr;
+ QWidget * candidate = nullptr;
QWidget * w = q;
while ((w = w->nextInFocusChain()) != q) {
if (q->isAncestorOf(w) && (w->focusPolicy() & Qt::TabFocus) == Qt::TabFocus && w->isVisibleTo(q)) {
diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h
index deaeba4656..bd8394b43b 100644
--- a/src/widgets/widgets/qgroupbox.h
+++ b/src/widgets/widgets/qgroupbox.h
@@ -57,7 +57,7 @@ class Q_WIDGETS_EXPORT QGroupBox : public QWidget
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled USER true)
public:
explicit QGroupBox(QWidget *parent = nullptr);
explicit QGroupBox(const QString &title, QWidget *parent = nullptr);
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp
index 6f2a6b2d5a..b63b0b4d72 100644
--- a/src/widgets/widgets/qkeysequenceedit.cpp
+++ b/src/widgets/widgets/qkeysequenceedit.cpp
@@ -131,7 +131,7 @@ void QKeySequenceEditPrivate::finishEditing()
Constructs a QKeySequenceEdit widget with the given \a parent.
*/
QKeySequenceEdit::QKeySequenceEdit(QWidget *parent)
- : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, 0)
+ : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, { })
{
}
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 77d117775a..2490df58f2 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -188,8 +188,13 @@ QLabelPrivate::~QLabelPrivate()
*/
#ifndef QT_NO_PICTURE
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
- Returns the label's picture or nullptr if the label doesn't have a
+ \deprecated
+
+ New code should use the other overload which returns QPicture by-value.
+
+ This function returns the label's picture or \c nullptr if the label doesn't have a
picture.
*/
@@ -198,6 +203,37 @@ const QPicture *QLabel::picture() const
Q_D(const QLabel);
return d->picture;
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+/*!
+ \since 5.15
+ Returns the label's picture.
+
+ Previously, Qt provided a version of \c picture() which returned the picture
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QPicture *picPtr = label->picture();
+ QPicture picVal = label->picture(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
+ macro, then you can omit \c Qt::ReturnByValue as shown below:
+
+ \code
+ QPicture picVal = label->picture();
+ \endcode
+*/
+
+QPicture QLabel::picture(Qt::ReturnByValue_t) const
+{
+ Q_D(const QLabel);
+ if (d->picture)
+ return *(d->picture);
+ return QPicture();
+}
#endif
@@ -352,9 +388,27 @@ void QLabel::clear()
/*!
\property QLabel::pixmap
- \brief the label's pixmap
+ \brief the label's pixmap.
- If no pixmap has been set this will return nullptr.
+ Previously, Qt provided a version of \c pixmap() which returned the pixmap
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QPixmap *pixmapPtr = label->pixmap();
+ QPixmap pixmapVal = label->pixmap(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
+ macro, then you can omit \c Qt::ReturnByValue as shown below:
+
+ \code
+ QPixmap pixmapVal = label->pixmap();
+ \endcode
+
+ If no pixmap has been set, the deprecated getter function will return
+ \c nullptr.
Setting the pixmap clears any previous content. The buddy
shortcut, if any, is disabled.
@@ -373,11 +427,29 @@ void QLabel::setPixmap(const QPixmap &pixmap)
d->updateLabel();
}
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \deprecated
+
+ New code should use the other overload which returns QPixmap by-value.
+*/
const QPixmap *QLabel::pixmap() const
{
Q_D(const QLabel);
return d->pixmap;
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+/*!
+ \since 5.15
+*/
+QPixmap QLabel::pixmap(Qt::ReturnByValue_t) const
+{
+ Q_D(const QLabel);
+ if (d->pixmap)
+ return *(d->pixmap);
+ return QPixmap();
+}
#ifndef QT_NO_PICTURE
/*!
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 2f5db5a7d3..288022a71e 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -72,9 +72,25 @@ public:
~QLabel();
QString text() const;
- const QPixmap *pixmap() const;
+
+#if QT_DEPRECATED_SINCE(5,15)
+ QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPixmap by-value")
+ const QPixmap *pixmap() const; // ### Qt 7: Remove function
+
+ QPixmap pixmap(Qt::ReturnByValue_t) const;
+#else
+ QPixmap pixmap(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
+#endif // QT_DEPRECATED_SINCE(5,15)
+
#ifndef QT_NO_PICTURE
- const QPicture *picture() const;
+# if QT_DEPRECATED_SINCE(5,15)
+ QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPicture by-value")
+ const QPicture *picture() const; // ### Qt 7: Remove function
+
+ QPicture picture(Qt::ReturnByValue_t) const;
+# else
+ QPicture picture(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
+# endif // QT_DEPRECATED_SINCE(5,15)
#endif
#if QT_CONFIG(movie)
QMovie *movie() const;
diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp
index 282714843c..3ddada4514 100644
--- a/src/widgets/widgets/qlcdnumber.cpp
+++ b/src/widgets/widgets/qlcdnumber.cpp
@@ -51,7 +51,7 @@ class QLCDNumberPrivate : public QFramePrivate
public:
void init();
void internalSetString(const QString& s);
- void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true);
+ void drawString(const QString& s, QPainter &, QBitArray * = nullptr, bool = true);
//void drawString(const QString &, QPainter &, QBitArray * = 0) const;
void drawDigit(const QPoint &, QPainter &, int, char, char = ' ');
void drawSegment(const QPoint &, char, QPainter &, int, bool = false);
@@ -212,7 +212,7 @@ static QString double2string(double num, int base, int ndigits, bool *oflow)
*oflow = true;
return s;
}
- s = int2string((int)num, base, ndigits, 0);
+ s = int2string((int)num, base, ndigits, nullptr);
} else { // decimal base
int nd = ndigits;
do {
@@ -706,7 +706,7 @@ void QLCDNumber::paintEvent(QPaintEvent *)
if (d->smallPoint)
d->drawString(d->digitStr, p, &d->points, false);
else
- d->drawString(d->digitStr, p, 0, false);
+ d->drawString(d->digitStr, p, nullptr, false);
}
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 658315028a..19a95be0ff 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -274,7 +274,7 @@ QLineEdit::QLineEdit(QWidget* parent)
\sa text(), setMaxLength()
*/
QLineEdit::QLineEdit(const QString& contents, QWidget* parent)
- : QWidget(*new QLineEditPrivate, parent, 0)
+ : QWidget(*new QLineEditPrivate, parent, { })
{
Q_D(QLineEdit);
d->init(contents);
@@ -446,7 +446,7 @@ void QLineEdit::addAction(QAction *action, ActionPosition position)
{
Q_D(QLineEdit);
QWidget::addAction(action);
- d->addAction(action, 0, position);
+ d->addAction(action, nullptr, position);
}
/*!
@@ -640,15 +640,15 @@ void QLineEdit::setCompleter(QCompleter *c)
if (c == d->control->completer())
return;
if (d->control->completer()) {
- disconnect(d->control->completer(), 0, this, 0);
- d->control->completer()->setWidget(0);
+ disconnect(d->control->completer(), nullptr, this, nullptr);
+ d->control->completer()->setWidget(nullptr);
if (d->control->completer()->parent() == this)
delete d->control->completer();
}
d->control->setCompleter(c);
if (!c)
return;
- if (c->widget() == 0)
+ if (c->widget() == nullptr)
c->setWidget(this);
if (hasFocus()) {
QObject::connect(d->control->completer(), SIGNAL(activated(QString)),
@@ -683,7 +683,7 @@ QSize QLineEdit::sizeHint() const
Q_D(const QLineEdit);
ensurePolished();
QFontMetrics fm(font());
- const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
+ const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
const QMargins tm = d->effectiveTextMargins();
int h = qMax(fm.height(), qMax(14, iconSize - 2)) + 2 * QLineEditPrivate::verticalMargin
+ tm.top() + tm.bottom()
@@ -1214,8 +1214,8 @@ QMargins QLineEdit::textMargins() const
\row \li \c a \li ASCII alphabetic character permitted but not required.
\row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9.
\row \li \c n \li ASCII alphanumeric character permitted but not required.
- \row \li \c X \li Any character required.
- \row \li \c x \li Any character permitted but not required.
+ \row \li \c X \li Any non-blank character required.
+ \row \li \c x \li Any non-blank character permitted but not required.
\row \li \c 9 \li ASCII digit required. 0-9.
\row \li \c 0 \li ASCII digit permitted but not required.
\row \li \c D \li ASCII digit required. 1-9.
@@ -1951,7 +1951,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e)
#endif
#if QT_CONFIG(completer)
if (d->control->completer()) {
- QObject::disconnect(d->control->completer(), 0, this, 0);
+ QObject::disconnect(d->control->completer(), nullptr, this, nullptr);
}
#endif
QWidget::focusOutEvent(e);
@@ -2190,7 +2190,7 @@ QMenu *QLineEdit::createStandardContextMenu()
Q_D(QLineEdit);
QMenu *popup = new QMenu(this);
popup->setObjectName(QLatin1String("qt_edit_menu"));
- QAction *action = 0;
+ QAction *action = nullptr;
if (!isReadOnly()) {
action = popup->addAction(QLineEdit::tr("&Undo") + ACCEL_KEY(QKeySequence::Undo));
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index d2b5f87906..feb34ef403 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -487,7 +487,7 @@ QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters()
{
Q_Q(const QLineEdit);
SideWidgetParameters result;
- result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
+ result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q);
result.margin = result.iconSize / 4;
result.widgetWidth = result.iconSize + 6;
result.widgetHeight = result.iconSize + 2;
@@ -566,12 +566,12 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
{
Q_Q(QLineEdit);
if (!newAction)
- return 0;
+ return nullptr;
if (!hasSideWidgets()) { // initial setup.
QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString)));
lastTextSize = q->text().size();
}
- QWidget *w = 0;
+ QWidget *w = nullptr;
// Store flags about QWidgetAction here since removeAction() may be called from ~QAction,
// in which a qobject_cast<> no longer works.
#if QT_CONFIG(action)
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index a11fea6bbe..5ae402b992 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -151,7 +151,7 @@ public:
};
QLineEditPrivate()
- : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0),
+ : control(nullptr), frame(1), contextMenuEnabled(1), cursorVisible(0),
dragEnabled(0), clickCausedFocus(0), edited(0), hscroll(0), vscroll(0),
alignment(Qt::AlignLeading | Qt::AlignVCenter),
textMargins{0, 0, 0, 0},
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index 88baf0410b..f261314c64 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -138,7 +138,7 @@ QMacCocoaViewContainerPrivate::~QMacCocoaViewContainerPrivate()
*/
QMacCocoaViewContainer::QMacCocoaViewContainer(NSView *view, QWidget *parent)
- : QWidget(*new QMacCocoaViewContainerPrivate, parent, 0)
+ : QWidget(*new QMacCocoaViewContainerPrivate, parent, {})
{
// Ensures that we have a QWindow, even if we're not a top level widget
setAttribute(Qt::WA_NativeWindow);
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index e3dbe763e5..4f94b81b19 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -78,7 +78,7 @@ class QMainWindowPrivate : public QWidgetPrivate
Q_DECLARE_PUBLIC(QMainWindow)
public:
inline QMainWindowPrivate()
- : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly)
+ : layout(nullptr), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly)
#ifdef Q_OS_OSX
, useUnifiedToolBar(false)
#endif
@@ -94,7 +94,7 @@ public:
static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow)
{
- return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0);
+ return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(nullptr);
}
};
@@ -152,10 +152,10 @@ void QMainWindowPrivate::init()
topLayout->addItem(layout, 1, 1);
#else
- layout = new QMainWindowLayout(q, 0);
+ layout = new QMainWindowLayout(q, nullptr);
#endif
- const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
+ const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, q);
iconSize = QSize(metric, metric);
q->setAttribute(Qt::WA_Hover);
}
@@ -452,7 +452,7 @@ void QMainWindow::setIconSize(const QSize &iconSize)
Q_D(QMainWindow);
QSize sz = iconSize;
if (!sz.isValid()) {
- const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);
+ const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, this);
sz = QSize(metric, metric);
}
if (d->iconSize != sz) {
@@ -652,8 +652,8 @@ QWidget *QMainWindow::takeCentralWidget()
Q_D(QMainWindow);
QWidget *oldcentralwidget = d->layout->centralWidget();
if (oldcentralwidget) {
- oldcentralwidget->setParent(0);
- d->layout->setCentralWidget(0);
+ oldcentralwidget->setParent(nullptr);
+ d->layout->setCentralWidget(nullptr);
}
return oldcentralwidget;
}
@@ -1480,7 +1480,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event)
QMenu *QMainWindow::createPopupMenu()
{
Q_D(QMainWindow);
- QMenu *menu = 0;
+ QMenu *menu = nullptr;
#if QT_CONFIG(dockwidget)
QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>();
if (dockwidgets.size()) {
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 0fb3a86cf8..30562d8270 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -101,14 +101,14 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayoutItem &item, QStri
<< " gap:" << (item.flags & QDockAreaLayoutItem::GapItem)
<< " keepSize:" << (item.flags & QDockAreaLayoutItem::KeepSize) << '\n';
indent += QLatin1String(" ");
- if (item.widgetItem != 0) {
+ if (item.widgetItem != nullptr) {
qout << indent << "widget: "
<< item.widgetItem->widget()->metaObject()->className()
<< " \"" << item.widgetItem->widget()->windowTitle() << "\"\n";
- } else if (item.subinfo != 0) {
+ } else if (item.subinfo != nullptr) {
qout << indent << "subinfo:\n";
dumpLayout(qout, *item.subinfo, indent + QLatin1String(" "));
- } else if (item.placeHolderItem != 0) {
+ } else if (item.placeHolderItem != nullptr) {
QRect r = item.placeHolderItem->topLevelRect;
qout << indent << "placeHolder: "
<< "pos: " << item.pos << " size:" << item.size
@@ -272,7 +272,7 @@ public:
int frameWidth() const
{
return nativeWindowDeco() ? 0 :
- parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget());
+ parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, parentWidget());
}
QDockWidgetGroupWindow *groupWindow() const
@@ -727,7 +727,7 @@ void QMainWindowLayoutState::deleteCentralWidgetItem()
{
#if QT_CONFIG(dockwidget)
delete dockAreaLayout.centralWidgetItem;
- dockAreaLayout.centralWidgetItem = 0;
+ dockAreaLayout.centralWidgetItem = nullptr;
#else
delete centralWidgetItem;
centralWidgetItem = 0;
@@ -749,7 +749,7 @@ QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const
return centralWidgetItem;
#endif
- return 0;
+ return nullptr;
}
QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x)
@@ -770,7 +770,7 @@ QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x)
}
#endif
- return 0;
+ return nullptr;
}
QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const
@@ -803,7 +803,7 @@ QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const
bool QMainWindowLayoutState::contains(QWidget *widget) const
{
#if QT_CONFIG(dockwidget)
- if (dockAreaLayout.centralWidgetItem != 0 && dockAreaLayout.centralWidgetItem->widget() == widget)
+ if (dockAreaLayout.centralWidgetItem != nullptr && dockAreaLayout.centralWidgetItem->widget() == widget)
return true;
if (!dockAreaLayout.indexOf(widget).isEmpty())
return true;
@@ -821,11 +821,11 @@ bool QMainWindowLayoutState::contains(QWidget *widget) const
void QMainWindowLayoutState::setCentralWidget(QWidget *widget)
{
- QLayoutItem *item = 0;
+ QLayoutItem *item = nullptr;
//make sure we remove the widget
deleteCentralWidgetItem();
- if (widget != 0)
+ if (widget != nullptr)
item = new QWidgetItemV2(widget);
#if QT_CONFIG(dockwidget)
@@ -837,7 +837,7 @@ void QMainWindowLayoutState::setCentralWidget(QWidget *widget)
QWidget *QMainWindowLayoutState::centralWidget() const
{
- QLayoutItem *item = 0;
+ QLayoutItem *item = nullptr;
#if QT_CONFIG(dockwidget)
item = dockAreaLayout.centralWidgetItem;
@@ -845,9 +845,9 @@ QWidget *QMainWindowLayoutState::centralWidget() const
item = centralWidgetItem;
#endif
- if (item != 0)
+ if (item != nullptr)
return item->widget();
- return 0;
+ return nullptr;
}
QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
@@ -978,7 +978,7 @@ QLayoutItem *QMainWindowLayoutState::item(const QList<int> &path)
return dockAreaLayout.item(path.mid(1)).widgetItem;
#endif // QT_CONFIG(dockwidget)
- return 0;
+ return nullptr;
}
QRect QMainWindowLayoutState::itemRect(const QList<int> &path) const
@@ -1029,7 +1029,7 @@ QLayoutItem *QMainWindowLayoutState::plug(const QList<int> &path)
return dockAreaLayout.plug(path.mid(1));
#endif // QT_CONFIG(dockwidget)
- return 0;
+ return nullptr;
}
QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowLayoutState *other)
@@ -1040,7 +1040,7 @@ QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowL
Q_UNUSED(other);
#else
if (i == 0)
- return toolBarAreaLayout.unplug(path.mid(1), other ? &other->toolBarAreaLayout : 0);
+ return toolBarAreaLayout.unplug(path.mid(1), other ? &other->toolBarAreaLayout : nullptr);
#endif
#if QT_CONFIG(dockwidget)
@@ -1048,7 +1048,7 @@ QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowL
return dockAreaLayout.unplug(path.mid(1));
#endif // QT_CONFIG(dockwidget)
- return 0;
+ return nullptr;
}
void QMainWindowLayoutState::saveState(QDataStream &stream) const
@@ -1198,7 +1198,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
continue;
}
QDockAreaLayoutInfo *info = dockAreaLayout.info(oldPath);
- if (info == 0) {
+ if (info == nullptr) {
continue;
}
info->item_list.append(QDockAreaLayoutItem(new QDockWidgetItem(w)));
@@ -1249,7 +1249,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
if (oldPath.isEmpty()) {
continue;
}
- toolBarAreaLayout.docks[oldPath.at(0)].insertToolBar(0, w);
+ toolBarAreaLayout.docks[oldPath.at(0)].insertToolBar(nullptr, w);
}
}
}
@@ -1755,7 +1755,7 @@ void QMainWindowTabBar::mouseReleaseEvent(QMouseEvent *e)
if (dockPriv->state && dockPriv->state->dragging) {
dockPriv->endDrag();
}
- draggingDock = 0;
+ draggingDock = nullptr;
}
QTabBar::mouseReleaseEvent(e);
}
@@ -1780,7 +1780,7 @@ bool QMainWindowTabBar::event(QEvent *e)
QTabBar *QMainWindowLayout::getTabBar()
{
- QTabBar *result = 0;
+ QTabBar *result = nullptr;
if (!unusedTabBars.isEmpty()) {
result = unusedTabBars.takeLast();
} else {
@@ -1800,7 +1800,7 @@ QTabBar *QMainWindowLayout::getTabBar()
// Allocates a new separator widget if needed
QWidget *QMainWindowLayout::getSeparatorWidget()
{
- QWidget *result = 0;
+ QWidget *result = nullptr;
if (!unusedSeparatorWidgets.isEmpty()) {
result = unusedSeparatorWidgets.takeLast();
} else {
@@ -1829,16 +1829,16 @@ QDockAreaLayoutInfo *QMainWindowLayout::dockInfo(QWidget *widget)
if (info)
return info;
}
- return 0;
+ return nullptr;
}
void QMainWindowLayout::tabChanged()
{
QTabBar *tb = qobject_cast<QTabBar*>(sender());
- if (tb == 0)
+ if (tb == nullptr)
return;
QDockAreaLayoutInfo *info = dockInfo(tb);
- if (info == 0)
+ if (info == nullptr)
return;
QDockWidget *activated = info->apply(false);
@@ -1866,7 +1866,7 @@ void QMainWindowLayout::tabMoved(int from, int to)
void QMainWindowLayout::raise(QDockWidget *widget)
{
QDockAreaLayoutInfo *info = dockInfo(widget);
- if (info == 0)
+ if (info == nullptr)
return;
if (!info->tabbed)
return;
@@ -1897,7 +1897,7 @@ QLayoutItem *QMainWindowLayout::itemAt(int index) const
if (statusbar && x++ == index)
return statusbar;
- return 0;
+ return nullptr;
}
QLayoutItem *QMainWindowLayout::takeAt(int index)
@@ -1909,7 +1909,7 @@ QLayoutItem *QMainWindowLayout::takeAt(int index)
if (QWidget *w = ret->widget()) {
widgetAnimator.abort(w);
if (w == pluggingWidget)
- pluggingWidget = 0;
+ pluggingWidget = nullptr;
}
if (savedState.isValid() ) {
@@ -1934,11 +1934,11 @@ QLayoutItem *QMainWindowLayout::takeAt(int index)
if (statusbar && x++ == index) {
QLayoutItem *ret = statusbar;
- statusbar = 0;
+ statusbar = nullptr;
return ret;
}
- return 0;
+ return nullptr;
}
void QMainWindowLayout::setGeometry(const QRect &_r)
@@ -2033,7 +2033,7 @@ static void fixToolBarOrientation(QLayoutItem *item, int dockPos)
{
#if QT_CONFIG(toolbar)
QToolBar *toolBar = qobject_cast<QToolBar*>(item->widget());
- if (toolBar == 0)
+ if (toolBar == nullptr)
return;
QRect oldGeo = toolBar->geometry();
@@ -2146,7 +2146,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
if (layout->nativeWindowDeco()) {
globalRect.adjust(0, layout->titleHeight(), 0, 0);
} else {
- int fw = widget->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, widget);
+ int fw = widget->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, widget);
globalRect.adjust(-fw, -fw, fw, fw);
}
}
@@ -2214,7 +2214,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
QDockAreaLayoutItem &item = dstParentInfo->item_list[idx];
Q_ASSERT(item.widgetItem->widget() == dwgw);
delete item.widgetItem;
- item.widgetItem = 0;
+ item.widgetItem = nullptr;
item.subinfo = new QDockAreaLayoutInfo(std::move(*srcInfo));
*srcInfo = QDockAreaLayoutInfo();
item.subinfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data()
@@ -2238,7 +2238,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
savedState.clear();
currentGapPos.clear();
- pluggingWidget = 0;
+ pluggingWidget = nullptr;
#if QT_CONFIG(dockwidget)
setCurrentHoveredFloat(nullptr);
#endif
@@ -2283,16 +2283,16 @@ void QMainWindowLayout::restore(bool keepSavedState)
if (!keepSavedState)
savedState.clear();
currentGapPos.clear();
- pluggingWidget = 0;
+ pluggingWidget = nullptr;
updateGapIndicator();
}
QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout)
- : QLayout(parentLayout ? static_cast<QWidget *>(0) : mainwindow)
+ : QLayout(parentLayout ? static_cast<QWidget *>(nullptr) : mainwindow)
, layoutState(mainwindow)
, savedState(mainwindow)
, dockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks)
- , statusbar(0)
+ , statusbar(nullptr)
#if QT_CONFIG(dockwidget)
#if QT_CONFIG(tabbar)
, _documentMode(false)
@@ -2303,14 +2303,14 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay
#endif
#endif // QT_CONFIG(dockwidget)
, widgetAnimator(this)
- , pluggingWidget(0)
+ , pluggingWidget(nullptr)
{
if (parentLayout)
setParent(parentLayout);
#if QT_CONFIG(dockwidget)
#if QT_CONFIG(tabbar)
- sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainwindow);
+ sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, mainwindow);
#endif
#if QT_CONFIG(tabwidget)
@@ -2318,7 +2318,7 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay
tabPositions[i] = QTabWidget::South;
#endif
#endif // QT_CONFIG(dockwidget)
- pluggingWidget = 0;
+ pluggingWidget = nullptr;
setObjectName(mainwindow->objectName() + QLatin1String("_layout"));
}
@@ -2354,7 +2354,7 @@ void QMainWindowLayout::setStatusBar(QStatusBar *sb)
if (sb)
addChildWidget(sb);
delete statusbar;
- statusbar = sb ? new QWidgetItemV2(sb) : 0;
+ statusbar = sb ? new QWidgetItemV2(sb) : nullptr;
invalidate();
}
#endif // QT_CONFIG(statusbar)
@@ -2366,7 +2366,7 @@ QWidget *QMainWindowLayout::centralWidget() const
void QMainWindowLayout::setCentralWidget(QWidget *widget)
{
- if (widget != 0)
+ if (widget != nullptr)
addChildWidget(widget);
layoutState.setCentralWidget(widget);
if (savedState.isValid()) {
@@ -2453,7 +2453,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
#endif
QList<int> path = layoutState.indexOf(widget);
if (path.isEmpty())
- return 0;
+ return nullptr;
QLayoutItem *item = layoutState.item(path);
if (widget->isWindow())
@@ -2561,7 +2561,7 @@ static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w)
void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
{
if (!parentWidget()->isVisible() || parentWidget()->isMinimized()
- || pluggingWidget != 0 || widgetItem == 0)
+ || pluggingWidget != nullptr || widgetItem == nullptr)
return;
QWidget *widget = widgetItem->widget();
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index f882908708..d4f0bd4517 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -338,7 +338,7 @@ class QDockWidgetGroupWindow : public QWidget
{
Q_OBJECT
public:
- explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr)
+ explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = { })
: QWidget(parent, f) {}
QDockAreaLayoutInfo *layoutInfo() const;
#if QT_CONFIG(tabbar)
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index 6e3de1b1ff..da6eb47372 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -103,8 +103,8 @@
\fn void QMdiArea::subWindowActivated(QMdiSubWindow *window)
QMdiArea emits this signal after \a window has been activated. When \a
- window is 0, QMdiArea has just deactivated its last active window, and
- there are no active windows on the workspace.
+ window is \nullptr, QMdiArea has just deactivated its last active window,
+ and there are no active windows on the workspace.
\sa QMdiArea::activeSubWindow()
*/
@@ -245,7 +245,7 @@ static inline bool useScrollBar(const QRect &childrenRect, const QSize &maxViewp
static inline QMdiArea *mdiAreaParent(QWidget *widget)
{
if (!widget)
- return 0;
+ return nullptr;
QWidget *parent = widget->parentWidget();
while (parent) {
@@ -253,7 +253,7 @@ static inline QMdiArea *mdiAreaParent(QWidget *widget)
return area;
parent = parent->parentWidget();
}
- return 0;
+ return nullptr;
}
#if QT_CONFIG(tabwidget)
@@ -352,7 +352,7 @@ void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) c
int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0));
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1)
- + widgets.at(0)->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, 0, widgets.at(0));
+ + widgets.at(0)->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widgets.at(0));
const int n = widgets.size();
const int nrows = qMax((domain.height() - (topOffset + bottomOffset)) / dy, 1);
@@ -648,7 +648,7 @@ void QMdiAreaTabBar::contextMenuEvent(QContextMenuEvent *event)
QMdiSubWindow *QMdiAreaTabBar::subWindowFromIndex(int index) const
{
if (index < 0 || index >= count())
- return 0;
+ return nullptr;
QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parentWidget());
Q_ASSERT(mdiArea);
@@ -667,15 +667,15 @@ QMdiSubWindow *QMdiAreaTabBar::subWindowFromIndex(int index) const
\internal
*/
QMdiAreaPrivate::QMdiAreaPrivate()
- : cascader(0),
- regularTiler(0),
- iconTiler(0),
- placer(0),
+ : cascader(nullptr),
+ regularTiler(nullptr),
+ iconTiler(nullptr),
+ placer(nullptr),
#if QT_CONFIG(rubberband)
- rubberBand(0),
+ rubberBand(nullptr),
#endif
#if QT_CONFIG(tabbar)
- tabBar(0),
+ tabBar(nullptr),
#endif
activationOrder(QMdiArea::CreationOrder),
viewMode(QMdiArea::SubWindowView),
@@ -1070,7 +1070,7 @@ void QMdiAreaPrivate::emitWindowActivated(QMdiSubWindow *activeWindow)
Q_ASSERT(aboutToBecomeActive == activeWindow);
active = activeWindow;
- aboutToBecomeActive = 0;
+ aboutToBecomeActive = nullptr;
Q_ASSERT(active->d_func()->isActive);
#if QT_CONFIG(tabbar)
@@ -1093,20 +1093,20 @@ void QMdiAreaPrivate::resetActiveWindow(QMdiSubWindow *deactivatedWindow)
if (deactivatedWindow) {
if (deactivatedWindow != active)
return;
- active = 0;
+ active = nullptr;
if ((aboutToBecomeActive || isActivated || lastWindowAboutToBeDestroyed())
&& !isExplicitlyDeactivated(deactivatedWindow) && !q->window()->isMinimized()) {
return;
}
- emit q->subWindowActivated(0);
+ emit q->subWindowActivated(nullptr);
return;
}
if (aboutToBecomeActive)
return;
- active = 0;
- emit q->subWindowActivated(0);
+ active = nullptr;
+ emit q->subWindowActivated(nullptr);
}
/*!
@@ -1171,7 +1171,7 @@ void QMdiAreaPrivate::updateScrollBars()
QSize hbarExtent = hbar->sizeHint();
QSize vbarExtent = vbar->sizeHint();
- if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) {
+ if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q)) {
const int doubleFrameWidth = frameWidth * 2;
if (hbarpolicy == Qt::ScrollBarAlwaysOn)
maxSize.rheight() -= doubleFrameWidth;
@@ -1232,7 +1232,7 @@ void QMdiAreaPrivate::internalRaise(QMdiSubWindow *mdiChild) const
if (!sanityCheck(mdiChild, "QMdiArea::internalRaise") || childWindows.size() < 2)
return;
- QMdiSubWindow *stackUnderChild = 0;
+ QMdiSubWindow *stackUnderChild = nullptr;
if (!windowStaysOnTop(mdiChild)) {
const auto children = viewport->children(); // take a copy, as raising/stacking under changes the order
for (QObject *object : children) {
@@ -1282,8 +1282,8 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in
minAreaHeight += hbar->height();
if (vbar->isVisible())
minAreaWidth += vbar->width();
- if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) {
- const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q);
+ if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q)) {
+ const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, q);
minAreaWidth += 2 * frame;
minAreaHeight += 2 * frame;
}
@@ -1427,7 +1427,7 @@ void QMdiAreaPrivate::disconnectSubWindow(QObject *subWindow)
return;
Q_Q(QMdiArea);
- QObject::disconnect(subWindow, 0, q, 0);
+ QObject::disconnect(subWindow, nullptr, q, nullptr);
subWindow->removeEventFilter(q);
}
@@ -1438,11 +1438,11 @@ QMdiSubWindow *QMdiAreaPrivate::nextVisibleSubWindow(int increaseFactor, QMdiAre
int removedIndex, int fromIndex) const
{
if (childWindows.isEmpty())
- return 0;
+ return nullptr;
Q_Q(const QMdiArea);
const QList<QMdiSubWindow *> subWindows = q->subWindowList(order);
- QMdiSubWindow *current = 0;
+ QMdiSubWindow *current = nullptr;
if (removedIndex < 0) {
if (fromIndex >= 0 && fromIndex < subWindows.size())
@@ -1482,7 +1482,7 @@ QMdiSubWindow *QMdiAreaPrivate::nextVisibleSubWindow(int increaseFactor, QMdiAre
if (!subWindows.at(index)->isHidden())
return subWindows.at(index);
- return 0;
+ return nullptr;
}
/*!
@@ -1603,7 +1603,7 @@ void QMdiAreaPrivate::setViewMode(QMdiArea::ViewMode mode)
{ // SubWindowView
#if QT_CONFIG(tabbar)
delete tabBar;
- tabBar = 0;
+ tabBar = nullptr;
#endif // QT_CONFIG(tabbar)
viewMode = mode;
@@ -1704,7 +1704,7 @@ QMdiArea::QMdiArea(QWidget *parent)
setFrameStyle(QFrame::NoFrame);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setViewport(0);
+ setViewport(nullptr);
setFocusPolicy(Qt::NoFocus);
QApplication::instance()->installEventFilter(this);
}
@@ -1716,16 +1716,16 @@ QMdiArea::~QMdiArea()
{
Q_D(QMdiArea);
delete d->cascader;
- d->cascader = 0;
+ d->cascader = nullptr;
delete d->regularTiler;
- d->regularTiler = 0;
+ d->regularTiler = nullptr;
delete d->iconTiler;
- d->iconTiler = 0;
+ d->iconTiler = nullptr;
delete d->placer;
- d->placer = 0;
+ d->placer = nullptr;
}
/*!
@@ -1760,8 +1760,8 @@ QSize QMdiArea::sizeHint() const
QSize QMdiArea::minimumSizeHint() const
{
Q_D(const QMdiArea);
- QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this),
- style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, this));
+ QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, nullptr, this),
+ style()->pixelMetric(QStyle::PM_TitleBarHeight, nullptr, this));
size = size.expandedTo(QAbstractScrollArea::minimumSizeHint());
if (!d->scrollBarsEnabled()) {
for (QMdiSubWindow *child : d->childWindows) {
@@ -1965,7 +1965,7 @@ QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFla
{
if (Q_UNLIKELY(!widget)) {
qWarning("QMdiArea::addSubWindow: null pointer to widget");
- return 0;
+ return nullptr;
}
Q_D(QMdiArea);
@@ -2027,7 +2027,7 @@ void QMdiArea::removeSubWindow(QWidget *widget)
d->childWindows.removeAll(child);
d->indicesToActivatedChildren.removeAll(index);
d->updateActiveWindow(index, d->active == child);
- child->setParent(0);
+ child->setParent(nullptr);
return;
}
@@ -2036,7 +2036,7 @@ void QMdiArea::removeSubWindow(QWidget *widget)
if (!sanityCheck(child, "QMdiArea::removeSubWindow"))
continue;
if (child->widget() == widget) {
- child->setWidget(0);
+ child->setWidget(nullptr);
Q_ASSERT(!child->widget());
found = true;
break;
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index d58a1d06db..84568c35db 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -253,7 +253,7 @@ static inline ControlElement<T> *ptr(QWidget *widget)
&& strcmp(widget->metaObject()->className(), T::staticMetaObject.className()) == 0) {
return static_cast<ControlElement<T> *>(widget);
}
- return 0;
+ return nullptr;
}
QString QMdiSubWindowPrivate::originalWindowTitle()
@@ -364,7 +364,7 @@ class ControlLabel : public QWidget
{
Q_OBJECT
public:
- ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0);
+ ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = nullptr);
QSize sizeHint() const override;
@@ -481,8 +481,8 @@ void ControlLabel::updateWindowIcon()
{
QIcon menuIcon = windowIcon();
if (menuIcon.isNull())
- menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget());
- const int iconSize = style()->pixelMetric(QStyle::PM_TitleBarButtonIconSize, 0, parentWidget());
+ menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, nullptr, parentWidget());
+ const int iconSize = style()->pixelMetric(QStyle::PM_TitleBarButtonIconSize, nullptr, parentWidget());
label = menuIcon.pixmap(iconSize);
update();
}
@@ -496,7 +496,7 @@ class ControllerWidget : public QWidget
{
Q_OBJECT
public:
- ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0);
+ ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = nullptr);
QSize sizeHint() const override;
void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible);
inline bool hasVisibleControls() const
@@ -542,7 +542,7 @@ ControllerWidget::ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent)
activeControl(QStyle::SC_None),
hoverControl(QStyle::SC_None),
visibleControls(QStyle::SC_None),
- mdiArea(0)
+ mdiArea(nullptr)
{
if (subWindow->parentWidget())
mdiArea = qobject_cast<QMdiArea *>(subWindow->parentWidget()->parentWidget());
@@ -697,10 +697,10 @@ void ControllerWidget::initStyleOption(QStyleOptionComplex *option) const
*/
ControlContainer::ControlContainer(QMdiSubWindow *mdiChild)
: QObject(mdiChild),
- previousLeft(0),
- previousRight(0),
+ previousLeft(nullptr),
+ previousRight(nullptr),
#if QT_CONFIG(menubar)
- m_menuBar(0),
+ m_menuBar(nullptr),
#endif
mdiChild(mdiChild)
{
@@ -725,9 +725,9 @@ ControlContainer::~ControlContainer()
removeButtonsFromMenuBar();
#endif
delete m_menuLabel;
- m_menuLabel = 0;
+ m_menuLabel = nullptr;
delete m_controllerWidget;
- m_controllerWidget = 0;
+ m_controllerWidget = nullptr;
}
#if QT_CONFIG(menubar)
@@ -741,12 +741,12 @@ QMenuBar *QMdiSubWindowPrivate::menuBar() const
#else
Q_Q(const QMdiSubWindow);
if (!q->isMaximized() || drawTitleBarWhenMaximized() || isChildOfTabbedQMdiArea(q))
- return 0;
+ return nullptr;
if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window()))
return mainWindow->menuBar();
- return 0;
+ return nullptr;
#endif
}
@@ -790,50 +790,50 @@ void ControlContainer::removeButtonsFromMenuBar(QMenuBar *menuBar)
{
if (menuBar && menuBar != m_menuBar) {
// m_menubar was deleted while sub-window was maximized
- previousRight = 0;
- previousLeft = 0;
+ previousRight = nullptr;
+ previousLeft = nullptr;
m_menuBar = menuBar;
}
if (!m_menuBar || !mdiChild || qt_widget_private(mdiChild->window())->data.in_destructor)
return;
- QMdiSubWindow *child = 0;
+ QMdiSubWindow *child = nullptr;
if (m_controllerWidget) {
QWidget *currentRight = m_menuBar->cornerWidget(Qt::TopRightCorner);
if (currentRight == m_controllerWidget) {
if (ControlElement<ControllerWidget> *ce = ptr<ControllerWidget>(previousRight)) {
if (!ce->mdiChild || !ce->mdiChild->isMaximized())
- previousRight = 0;
+ previousRight = nullptr;
else
child = ce->mdiChild;
}
m_menuBar->setCornerWidget(previousRight, Qt::TopRightCorner);
if (previousRight) {
previousRight->show();
- previousRight = 0;
+ previousRight = nullptr;
}
}
m_controllerWidget->hide();
- m_controllerWidget->setParent(0);
+ m_controllerWidget->setParent(nullptr);
}
if (m_menuLabel) {
QWidget *currentLeft = m_menuBar->cornerWidget(Qt::TopLeftCorner);
if (currentLeft == m_menuLabel) {
if (ControlElement<ControlLabel> *ce = ptr<ControlLabel>(previousLeft)) {
if (!ce->mdiChild || !ce->mdiChild->isMaximized())
- previousLeft = 0;
+ previousLeft = nullptr;
else if (!child)
child = mdiChild;
}
m_menuBar->setCornerWidget(previousLeft, Qt::TopLeftCorner);
if (previousLeft) {
previousLeft->show();
- previousLeft = 0;
+ previousLeft = nullptr;
}
}
m_menuLabel->hide();
- m_menuLabel->setParent(0);
+ m_menuLabel->setParent(nullptr);
}
m_menuBar->update();
if (child)
@@ -854,14 +854,14 @@ void ControlContainer::updateWindowIcon(const QIcon &windowIcon)
\internal
*/
QMdiSubWindowPrivate::QMdiSubWindowPrivate()
- : baseWidget(0),
- restoreFocusWidget(0),
- controlContainer(0),
+ : baseWidget(nullptr),
+ restoreFocusWidget(nullptr),
+ controlContainer(nullptr),
#if QT_CONFIG(sizegrip)
- sizeGrip(0),
+ sizeGrip(nullptr),
#endif
#if QT_CONFIG(rubberband)
- rubberBand(0),
+ rubberBand(nullptr),
#endif
userMinimumSize(0,0),
resizeEnabled(true),
@@ -926,7 +926,7 @@ void QMdiSubWindowPrivate::_q_enterInteractiveMode()
pressPos = QPoint(q->width() / 2, titleBarHeight() - 1);
} else if (actions[ResizeAction] && actions[ResizeAction] == action) {
currentOperation = q->isLeftToRight() ? BottomRightResize : BottomLeftResize;
- int offset = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q) / 2;
+ int offset = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q) / 2;
int x = q->isLeftToRight() ? q->width() - offset : offset;
pressPos = QPoint(x, q->height() - offset);
} else {
@@ -1009,8 +1009,8 @@ void QMdiSubWindowPrivate::removeBaseWidget()
lastChildWindowTitle.clear();
// QTBUG-47993: parent widget can be reset before this call
if (baseWidget->parentWidget() == q)
- baseWidget->setParent(0);
- baseWidget = 0;
+ baseWidget->setParent(nullptr);
+ baseWidget = nullptr;
isWidgetHiddenByUs = false;
}
@@ -1047,19 +1047,19 @@ void QMdiSubWindowPrivate::createSystemMenu()
systemMenu->installEventFilter(q);
const QStyle *style = q->style();
addToSystemMenu(RestoreAction, QMdiSubWindow::tr("&Restore"), SLOT(showNormal()));
- actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, 0, q));
+ actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, nullptr, q));
actions[RestoreAction]->setEnabled(false);
addToSystemMenu(MoveAction, QMdiSubWindow::tr("&Move"), SLOT(_q_enterInteractiveMode()));
addToSystemMenu(ResizeAction, QMdiSubWindow::tr("&Size"), SLOT(_q_enterInteractiveMode()));
addToSystemMenu(MinimizeAction, QMdiSubWindow::tr("Mi&nimize"), SLOT(showMinimized()));
- actions[MinimizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMinButton, 0, q));
+ actions[MinimizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMinButton, nullptr, q));
addToSystemMenu(MaximizeAction, QMdiSubWindow::tr("Ma&ximize"), SLOT(showMaximized()));
- actions[MaximizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMaxButton, 0, q));
+ actions[MaximizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMaxButton, nullptr, q));
addToSystemMenu(StayOnTopAction, QMdiSubWindow::tr("Stay on &Top"), SLOT(_q_updateStaysOnTopHint()));
actions[StayOnTopAction]->setCheckable(true);
systemMenu->addSeparator();
addToSystemMenu(CloseAction, QMdiSubWindow::tr("&Close"), SLOT(close()));
- actions[CloseAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarCloseButton, 0, q));
+ actions[CloseAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarCloseButton, nullptr, q));
#if !defined(QT_NO_SHORTCUT)
actions[CloseAction]->setShortcuts(QKeySequence::Close);
#endif
@@ -1461,7 +1461,7 @@ void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus)
ensureWindowState(Qt::WindowActive);
}
- int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q);
+ int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q);
int titleBarHeight = this->titleBarHeight();
QRegion windowDecoration = QRegion(0, 0, q->width(), q->height());
windowDecoration -= QRegion(frameWidth, titleBarHeight, q->width() - 2 * frameWidth,
@@ -1543,7 +1543,7 @@ QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const
int width = q->width();
int height = q->height();
int titleBarHeight = this->titleBarHeight();
- int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q);
+ int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q);
int cornerConst = titleBarHeight - frameWidth;
int titleBarConst = 2 * titleBarHeight;
@@ -1738,7 +1738,7 @@ void QMdiSubWindowPrivate::sizeParameters(int *margin, int *minWidth) const
if (q->isMaximized() && !drawTitleBarWhenMaximized())
*margin = 0;
else
- *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q);
+ *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q);
QStyleOptionTitleBar opt = this->titleBarOptions();
int tempWidth = 0;
@@ -1767,7 +1767,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const
if (isChildOfTabbedQMdiArea(q))
return false;
- if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q))
+ if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, nullptr, q))
return true;
#if !QT_CONFIG(menubar) || !QT_CONFIG(mainwindow)
Q_UNUSED(isChildOfQMdiSubWindow);
@@ -1833,7 +1833,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar()
if (!controlContainer || isChildOfTabbedQMdiArea(q))
return;
- QMenuBar *currentMenuBar = 0;
+ QMenuBar *currentMenuBar = nullptr;
#if QT_CONFIG(mainwindow)
if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window())) {
// NB! We can't use menuBar() here because that one will actually create
@@ -1863,7 +1863,7 @@ void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild)
return;
}
- QWidget *titleWidget = 0;
+ QWidget *titleWidget = nullptr;
if (isRequestFromChild)
titleWidget = baseWidget;
else
@@ -2131,7 +2131,7 @@ QSize QMdiSubWindowPrivate::iconSize() const
Q_Q(const QMdiSubWindow);
if (!parent || q->windowFlags() & Qt::FramelessWindowHint)
return QSize(-1, -1);
- return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight());
+ return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, nullptr, q), titleBarHeight());
}
#if QT_CONFIG(sizegrip)
@@ -2212,7 +2212,7 @@ void QMdiSubWindowPrivate::updateInternalWindowTitle()
\sa QMdiArea::addSubWindow()
*/
QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags)
- : QWidget(*new QMdiSubWindowPrivate, parent, 0)
+ : QWidget(*new QMdiSubWindowPrivate, parent, { })
{
Q_D(QMdiSubWindow);
#if QT_CONFIG(menu)
@@ -2233,7 +2233,7 @@ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags)
// We don't want the menu icon by default on mac.
#ifndef Q_OS_MAC
if (windowIcon().isNull())
- d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this);
+ d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, nullptr, this);
else
d->menuIcon = windowIcon();
#endif
@@ -2340,7 +2340,7 @@ QWidget *QMdiSubWindow::maximizedButtonsWidget() const
&& !isChildOfTabbedQMdiArea(this)) {
return d->controlContainer->controllerWidget();
}
- return 0;
+ return nullptr;
}
/*!
@@ -2353,7 +2353,7 @@ QWidget *QMdiSubWindow::maximizedSystemMenuIconWidget() const
&& !isChildOfTabbedQMdiArea(this)) {
return d->controlContainer->systemMenuLabel();
}
- return 0;
+ return nullptr;
}
/*!
@@ -2476,7 +2476,7 @@ void QMdiSubWindow::setSystemMenu(QMenu *systemMenu)
if (d->systemMenu) {
delete d->systemMenu;
- d->systemMenu = 0;
+ d->systemMenu = nullptr;
}
if (!systemMenu)
@@ -2860,7 +2860,7 @@ bool QMdiSubWindow::event(QEvent *event)
case QEvent::WindowIconChange:
d->menuIcon = windowIcon();
if (d->menuIcon.isNull())
- d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this);
+ d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, nullptr, this);
if (d->controlContainer)
d->controlContainer->updateWindowIcon(d->menuIcon);
if (!maximizedSystemMenuIconWidget())
@@ -3135,7 +3135,7 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent)
if (isMinimized() && !d->hasBorder(d->cachedStyleOptions))
return;
- frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this);
+ frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, this);
// ### Ensure that we do not require setting the cliprect for 4.4
if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions))
@@ -3510,7 +3510,7 @@ QSize QMdiSubWindow::minimumSizeHint() const
if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this)))
sizeGripHeight = d->sizeGrip->height();
else if (parent() && isMacStyle(style()) && !d->sizeGrip)
- sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this);
+ sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, nullptr, this);
minHeight = qMax(minHeight, decorationHeight + sizeGripHeight);
#endif
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 57ef7905d9..701035fc32 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -83,7 +83,7 @@
QT_BEGIN_NAMESPACE
-QMenu *QMenuPrivate::mouseDown = 0;
+QMenu *QMenuPrivate::mouseDown = nullptr;
/* QMenu code */
// internal class used for the torn off popup
@@ -96,7 +96,7 @@ class QTornOffMenu : public QMenu
public:
QTornOffMenuPrivate(QMenu *p) : causedMenu(p), initialized(false) {
tornoff = 1;
- causedPopup.widget = 0;
+ causedPopup.widget = nullptr;
causedPopup.action = p->d_func()->causedPopup.action;
causedStack = p->d_func()->calcCausedStack();
}
@@ -106,11 +106,11 @@ class QTornOffMenu : public QMenu
QSize size = menuSize;
const QPoint p = (!initialized) ? causedMenu->pos() : q->pos();
QRect screen = popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
- const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q);
- const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, q);
+ const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, q);
+ const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, nullptr, q);
if (scroll && (size.height() > screen.height() - titleBarHeight || size.width() > screen.width())) {
- const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
- const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuHMargin, 0, q);
+ const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q);
+ const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, q);
scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
size.setWidth(qMin(actionRects.at(getLastVisibleAction()).right() + fw + hmargin + rightmargin + 1, screen.width()));
size.setHeight(screen.height() - desktopFrame * 2 - titleBarHeight);
@@ -202,15 +202,15 @@ void QMenuPrivate::init()
if (!tornPopup.isNull())
tornPopup->updateWindowTitle();
});
- q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, q));
- if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)) {
+ q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, nullptr, q));
+ if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, nullptr, q)) {
scroll = new QMenuPrivate::QMenuScroller;
scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
}
sloppyState.initialize(q);
delayState.initialize(q);
- mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, q);
+ mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, nullptr, q);
}
QPlatformMenu *QMenuPrivate::createPlatformMenu()
@@ -262,7 +262,7 @@ void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenu
item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));
} else {
QStyleOption opt;
- item->setIconSize(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0));
+ item->setIconSize(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, nullptr));
}
} else {
item->setIcon(QIcon());
@@ -283,7 +283,7 @@ void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenu
action->menu()->setPlatformMenu(platformMenu->createSubMenu());
item->setMenu(action->menu()->platformMenu());
} else {
- item->setMenu(0);
+ item->setMenu(nullptr);
}
}
@@ -304,7 +304,7 @@ QPlatformMenuItem * QMenuPrivate::insertActionInPlatformMenu(const QAction *acti
int QMenuPrivate::scrollerHeight() const
{
Q_Q(const QMenu);
- return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
+ return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, nullptr, q));
}
// Windows and KDE allow menus to cover the taskbar, while GNOME and macOS
@@ -541,9 +541,9 @@ void QMenuPrivate::hideUpToMenuBar()
while(caused) {
#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
- mb->d_func()->setCurrentAction(0);
+ mb->d_func()->setCurrentAction(nullptr);
mb->d_func()->setKeyboardMode(false);
- caused = 0;
+ caused = nullptr;
} else
#endif
if (QMenu *m = qobject_cast<QMenu*>(caused)) {
@@ -551,12 +551,12 @@ void QMenuPrivate::hideUpToMenuBar()
if (!m->d_func()->tornoff)
hideMenu(m);
if (!fadeMenus) // Mac doesn't clear the action until after hidden.
- m->d_func()->setCurrentAction(0);
- } else { caused = 0;
+ m->d_func()->setCurrentAction(nullptr);
+ } else { caused = nullptr;
}
}
}
- setCurrentAction(0);
+ setCurrentAction(nullptr);
}
void QMenuPrivate::hideMenu(QMenu *menu)
@@ -573,7 +573,7 @@ void QMenuPrivate::hideMenu(QMenu *menu)
QEventLoop eventLoop;
QAction *activeAction = currentAction;
- menu->setActiveAction(0);
+ menu->setActiveAction(nullptr);
QTimer::singleShot(60, &eventLoop, SLOT(quit()));
eventLoop.exec();
@@ -587,10 +587,10 @@ void QMenuPrivate::hideMenu(QMenu *menu)
blocker.unblock();
#endif // QT_CONFIG(effects)
if (activeMenu == menu)
- activeMenu = 0;
- menu->d_func()->causedPopup.action = 0;
+ activeMenu = nullptr;
+ menu->d_func()->causedPopup.action = nullptr;
menu->close();
- menu->d_func()->causedPopup.widget = 0;
+ menu->d_func()->causedPopup.widget = nullptr;
}
void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst)
@@ -617,7 +617,7 @@ void QMenuPrivate::setSyncAction()
Q_Q(QMenu);
QAction *current = currentAction;
if(current && (!current->isEnabled() || current->menu() || current->isSeparator()))
- current = 0;
+ current = nullptr;
for(QWidget *caused = q; caused;) {
if (QMenu *m = qobject_cast<QMenu*>(caused)) {
caused = m->d_func()->causedPopup.widget;
@@ -645,7 +645,7 @@ void QMenuPrivate::setFirstActionActive()
}
QAction *act = actions.at(i);
if (!act->isSeparator() &&
- (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
+ (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q)
|| act->isEnabled())) {
setCurrentAction(act);
break;
@@ -661,7 +661,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
if (action
&& (action->isSeparator()
- || (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q))))
+ || (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q))))
action = nullptr;
// Reselect the currently active action in case mouse moved over other menu items when
@@ -718,8 +718,8 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
if (popup == -1) {
#if QT_CONFIG(effects)
// kill any running effect
- qFadeEffect(0);
- qScrollEffect(0);
+ qFadeEffect(nullptr);
+ qScrollEffect(nullptr);
#endif
hideMenu(hideActiveMenu);
} else if (!currentAction || !currentAction->menu()) {
@@ -869,13 +869,13 @@ QWidget *QMenuPrivate::topCausedWidget() const
QAction *QMenuPrivate::actionAt(QPoint p) const
{
if (!rect().contains(p)) //sanity check
- return 0;
+ return nullptr;
for(int i = 0; i < actionRects.count(); i++) {
if (actionRects.at(i).contains(p))
return actions.at(i);
}
- return 0;
+ return nullptr;
}
void QMenuPrivate::setOverrideMenuAction(QAction *a)
@@ -978,7 +978,7 @@ QMenuPrivate::ScrollerTearOffItem::ScrollerTearOffItem(QMenuPrivate::ScrollerTea
: QWidget(parent, f), menuPrivate(mPrivate), scrollType(type)
{
if (parent)
- setMouseTracking(parent->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, parent));
+ setMouseTracking(parent->style()->styleHint(QStyle::SH_Menu_MouseTracking, nullptr, parent));
}
void QMenuPrivate::ScrollerTearOffItem::paintEvent(QPaintEvent *e)
@@ -993,7 +993,7 @@ void QMenuPrivate::ScrollerTearOffItem::paintEvent(QPaintEvent *e)
menuPrivate->drawScroller(&p, scrollType, QRect(0, 0, width(), menuPrivate->scrollerHeight()));
//paint the tear off
if (scrollType == QMenuPrivate::ScrollerTearOffItem::ScrollUp) {
- QRect rect(0, 0, width(), parent->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, parent));
+ QRect rect(0, 0, width(), parent->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, parent));
if (menuPrivate->scroll && menuPrivate->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
rect.translate(0, menuPrivate->scrollerHeight());
menuPrivate->drawTearOff(&p, rect);
@@ -1068,8 +1068,8 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc
int newOffset = 0;
const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
- const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q);
- const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
+ const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, q);
+ const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q);
if (location == QMenuScroller::ScrollTop) {
for(int i = 0, saccum = 0; i < actions.count(); i++) {
@@ -1110,7 +1110,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc
if (!(newScrollFlags & QMenuScroller::ScrollDown) && (scroll->scrollFlags & QMenuScroller::ScrollDown)) {
newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin - topmargin - bottommargin; //last item at bottom
if (tearoff)
- newOffset -= q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q);
+ newOffset -= q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, q);
}
if (!(newScrollFlags & QMenuScroller::ScrollUp) && (scroll->scrollFlags & QMenuScroller::ScrollUp)) {
@@ -1121,7 +1121,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc
newOffset -= vmargin;
QRect screen = popupGeometry();
- const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q);
+ const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, q);
if (q->height() < screen.height()-(desktopFrame*2)-1) {
QRect geom = q->geometry();
if (newOffset > scroll->scrollOffset && (scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollUp)) { //scroll up
@@ -1183,7 +1183,7 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool activ
if (actionRects.at(i).isNull())
continue;
if (!act->isSeparator() &&
- (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
+ (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q)
|| act->isEnabled())) {
if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)
scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active);
@@ -1198,7 +1198,7 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool activ
if (actionRects.at(i).isNull())
continue;
if (!act->isSeparator() &&
- (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)
+ (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q)
|| act->isEnabled())) {
if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active);
@@ -1219,8 +1219,8 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool pag
updateActionRects();
const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0;
const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0;
- const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q);
- const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
+ const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, q);
+ const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q);
const int offset = topScroll ? topScroll-vmargin : 0;
if (direction == QMenuScroller::ScrollUp) {
for(int i = 0, saccum = 0; i < actions.count(); i++) {
@@ -1301,7 +1301,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
tearRect.translate(0, scrollerHeight());
q->update(tearRect);
if (tearRect.contains(pos) && hasMouseMoved(e->globalPos())) {
- setCurrentAction(0);
+ setCurrentAction(nullptr);
tearoffHighlighted = 1;
if (e->type() == QEvent::MouseButtonRelease) {
if (!tornPopup)
@@ -1320,7 +1320,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
for(QWidget *caused = causedPopup.widget; caused;) {
bool passOnEvent = false;
- QWidget *next_widget = 0;
+ QWidget *next_widget = nullptr;
QPoint cpos = caused->mapFromGlobal(e->globalPos());
#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
@@ -1441,7 +1441,7 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e
#endif
action->showStatusText(topCausedWidget());
} else {
- actionAboutToTrigger = 0;
+ actionAboutToTrigger = nullptr;
}
}
@@ -2260,7 +2260,7 @@ QAction *QMenu::actionAt(const QPoint &pt) const
{
if (QAction *ret = d_func()->actionAt(pt))
return ret;
- return 0;
+ return nullptr;
}
/*!
@@ -2319,76 +2319,86 @@ QSize QMenu::sizeHint() const
void QMenu::popup(const QPoint &p, QAction *atAction)
{
Q_D(QMenu);
- if (d->scroll) { // reset scroll state from last popup
- if (d->scroll->scrollOffset)
- d->itemsDirty = 1; // sizeHint will be incorrect if there is previous scroll
- d->scroll->scrollOffset = 0;
- d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
+ d->popup(p, atAction);
+}
+
+void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction positionFunction)
+{
+ Q_Q(QMenu);
+ if (scroll) { // reset scroll state from last popup
+ if (scroll->scrollOffset)
+ itemsDirty = 1; // sizeHint will be incorrect if there is previous scroll
+ scroll->scrollOffset = 0;
+ scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
}
- d->tearoffHighlighted = 0;
- d->motions = 0;
- d->doChildEffects = true;
- d->updateLayoutDirection();
+ tearoffHighlighted = 0;
+ motions = 0;
+ doChildEffects = true;
+ updateLayoutDirection();
// Ensure that we get correct sizeHints by placing this window on the correct screen.
// However if the QMenu was constructed with a QDesktopScreenWidget as its parent,
// then initialScreenIndex was set, so we should respect that for the lifetime of this menu.
// Use d->popupScreen to remember, because initialScreenIndex will be reset after the first showing.
// However if eventLoop exists, then exec() already did this by calling createWinId(); so leave it alone. (QTBUG-76162)
- if (!d->eventLoop) {
- const int screenIndex = d->topData()->initialScreenIndex;
+ if (!eventLoop) {
+ const int screenIndex = topData()->initialScreenIndex;
if (screenIndex >= 0)
- d->popupScreen = screenIndex;
- if (auto s = QGuiApplication::screens().value(d->popupScreen)) {
- if (d->setScreen(s))
- d->itemsDirty = true;
- } else if (d->setScreenForPoint(p)) {
- d->itemsDirty = true;
+ popupScreen = screenIndex;
+ if (auto s = QGuiApplication::screens().value(popupScreen)) {
+ if (setScreen(s))
+ itemsDirty = true;
+ } else if (setScreenForPoint(p)) {
+ itemsDirty = true;
}
}
- const bool contextMenu = d->isContextMenu();
- if (d->lastContextMenu != contextMenu) {
- d->itemsDirty = true;
- d->lastContextMenu = contextMenu;
+ const bool contextMenu = isContextMenu();
+ if (lastContextMenu != contextMenu) {
+ itemsDirty = true;
+ lastContextMenu = contextMenu;
}
#if QT_CONFIG(menubar)
// if this menu is part of a chain attached to a QMenuBar, set the
// _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type
- setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0);
+ q->setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(topCausedWidget()) != nullptr);
#endif
- ensurePolished(); // Get the right font
- emit aboutToShow();
- const bool actionListChanged = d->itemsDirty;
+ q->ensurePolished(); // Get the right font
+ emit q->aboutToShow();
+ const bool actionListChanged = itemsDirty;
QRect screen;
#if QT_CONFIG(graphicsview)
- bool isEmbedded = !bypassGraphicsProxyWidget(this) && QMenuPrivate::nearestGraphicsProxyWidget(this);
+ bool isEmbedded = !bypassGraphicsProxyWidget(q) && QMenuPrivate::nearestGraphicsProxyWidget(q);
if (isEmbedded)
- screen = d->popupGeometry();
+ screen = popupGeometry();
else
#endif
- screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
- d->updateActionRects(screen);
+ screen = popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
+ updateActionRects(screen);
QPoint pos;
- QPushButton *causedButton = qobject_cast<QPushButton*>(d->causedPopup.widget);
+ QPushButton *causedButton = qobject_cast<QPushButton*>(causedPopup.widget);
if (actionListChanged && causedButton)
pos = QPushButtonPrivate::get(causedButton)->adjustedMenuPosition();
else
pos = p;
- const QSize menuSizeHint(sizeHint());
+ const QSize menuSizeHint(q->sizeHint());
QSize size = menuSizeHint;
- const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this);
- bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen);
+
+ if (positionFunction)
+ pos = positionFunction(menuSizeHint);
+
+ const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, q);
+ bool adjustToDesktop = !q->window()->testAttribute(Qt::WA_DontShowOnScreen);
// if the screens have very different geometries and the menu is too big, we have to recalculate
if ((size.height() > screen.height() || size.width() > screen.width()) ||
// Layout is not right, we might be able to save horizontal space
- (d->ncols >1 && size.height() < screen.height())) {
+ (ncols >1 && size.height() < screen.height())) {
size.setWidth(qMin(menuSizeHint.width(), screen.width() - desktopFrame * 2));
size.setHeight(qMin(menuSizeHint.height(), screen.height() - desktopFrame * 2));
adjustToDesktop = true;
@@ -2397,61 +2407,61 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
#ifdef QT_KEYPAD_NAVIGATION
if (!atAction && QApplicationPrivate::keypadNavigationEnabled()) {
// Try to have one item activated
- if (d->defaultAction && d->defaultAction->isEnabled()) {
- atAction = d->defaultAction;
+ if (defaultAction && defaultAction->isEnabled()) {
+ atAction = defaultAction;
// TODO: This works for first level menus, not yet sub menus
} else {
- for (QAction *action : qAsConst(d->actions))
+ for (QAction *action : qAsConst(actions))
if (action->isEnabled()) {
atAction = action;
break;
}
}
- d->currentAction = atAction;
+ currentAction = atAction;
}
#endif
- if (d->ncols > 1) {
+ if (ncols > 1) {
pos.setY(screen.top() + desktopFrame);
} else if (atAction) {
- for (int i = 0, above_height = 0; i < d->actions.count(); i++) {
- QAction *action = d->actions.at(i);
+ for (int i = 0, above_height = 0; i < actions.count(); i++) {
+ QAction *action = actions.at(i);
if (action == atAction) {
int newY = pos.y() - above_height;
- if (d->scroll && newY < desktopFrame) {
- d->scroll->scrollFlags = d->scroll->scrollFlags
+ if (scroll && newY < desktopFrame) {
+ scroll->scrollFlags = scroll->scrollFlags
| QMenuPrivate::QMenuScroller::ScrollUp;
- d->scroll->scrollOffset = newY;
+ scroll->scrollOffset = newY;
newY = desktopFrame;
}
pos.setY(newY);
- if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
- && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) {
- int below_height = above_height + d->scroll->scrollOffset;
- for (int i2 = i; i2 < d->actionRects.count(); i2++)
- below_height += d->actionRects.at(i2).height();
+ if (scroll && scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
+ && !q->style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, nullptr, q)) {
+ int below_height = above_height + scroll->scrollOffset;
+ for (int i2 = i; i2 < actionRects.count(); i2++)
+ below_height += actionRects.at(i2).height();
size.setHeight(below_height);
}
break;
} else {
- above_height += d->actionRects.at(i).height();
+ above_height += actionRects.at(i).height();
}
}
}
QPoint mouse = QCursor::pos();
- d->mousePopupPos = mouse;
- const bool snapToMouse = !d->causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
+ mousePopupPos = mouse;
+ const bool snapToMouse = !causedPopup.widget && (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
if (adjustToDesktop) {
// handle popup falling "off screen"
- if (isRightToLeft()) {
+ if (q->isRightToLeft()) {
if (snapToMouse) // position flowing left from the mouse
pos.setX(mouse.x() - size.width());
#if QT_CONFIG(menubar)
// if the menu is in a menubar or is a submenu, it should be right-aligned
- if (qobject_cast<QMenuBar*>(d->causedPopup.widget) || qobject_cast<QMenu*>(d->causedPopup.widget))
+ if (qobject_cast<QMenuBar*>(causedPopup.widget) || qobject_cast<QMenu*>(causedPopup.widget))
pos.rx() -= size.width();
#endif // QT_CONFIG(menubar)
@@ -2475,8 +2485,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (pos.y() < screen.top() + desktopFrame)
pos.setY(screen.top() + desktopFrame);
if (pos.y() + menuSizeHint.height() - 1 > screen.bottom() - desktopFrame) {
- if (d->scroll) {
- d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
+ if (scroll) {
+ scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
int y = qMax(screen.y(),pos.y());
size.setHeight(screen.bottom() - (desktopFrame * 2) - y);
} else {
@@ -2485,13 +2495,13 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
}
}
- const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
- QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget);
+ const int subMenuOffset = q->style()->pixelMetric(QStyle::PM_SubMenuOverlap, nullptr, q);
+ QMenu *caused = qobject_cast<QMenu*>(causedPopup.widget);
if (caused && caused->geometry().width() + menuSizeHint.width() + subMenuOffset < screen.width()) {
QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction));
const QPoint actionTopLeft = caused->mapToGlobal(parentActionRect.topLeft());
parentActionRect.moveTopLeft(actionTopLeft);
- if (isRightToLeft()) {
+ if (q->isRightToLeft()) {
if ((pos.x() + menuSizeHint.width() > parentActionRect.left() - subMenuOffset)
&& (pos.x() < parentActionRect.right()))
{
@@ -2513,61 +2523,61 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
}
}
- setGeometry(QRect(pos, size));
+ q->setGeometry(QRect(pos, size));
#if QT_CONFIG(effects)
- int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
+ int hGuess = q->isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
int vGuess = QEffects::DownScroll;
- if (isRightToLeft()) {
+ if (q->isRightToLeft()) {
if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x()))
+ (qobject_cast<QMenu*>(causedPopup.widget) && pos.x() + size.width() / 2 > causedPopup.widget->x()))
hGuess = QEffects::RightScroll;
} else {
if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x()))
+ (qobject_cast<QMenu*>(causedPopup.widget) && pos.x() + size.width() / 2 < causedPopup.widget->x()))
hGuess = QEffects::LeftScroll;
}
#if QT_CONFIG(menubar)
if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
- (qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
- pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
+ (qobject_cast<QMenuBar*>(causedPopup.widget) &&
+ pos.y() + size.width() / 2 < causedPopup.widget->mapToGlobal(causedPopup.widget->pos()).y()))
vGuess = QEffects::UpScroll;
#endif
if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) {
bool doChildEffects = true;
#if QT_CONFIG(menubar)
- if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) {
+ if (QMenuBar *mb = qobject_cast<QMenuBar*>(causedPopup.widget)) {
doChildEffects = mb->d_func()->doChildEffects;
mb->d_func()->doChildEffects = false;
} else
#endif
- if (QMenu *m = qobject_cast<QMenu*>(d->causedPopup.widget)) {
+ if (QMenu *m = qobject_cast<QMenu*>(causedPopup.widget)) {
doChildEffects = m->d_func()->doChildEffects;
m->d_func()->doChildEffects = false;
}
if (doChildEffects) {
if (QApplication::isEffectEnabled(Qt::UI_FadeMenu))
- qFadeEffect(this);
- else if (d->causedPopup.widget)
- qScrollEffect(this, qobject_cast<QMenu*>(d->causedPopup.widget) ? hGuess : vGuess);
+ qFadeEffect(q);
+ else if (causedPopup.widget)
+ qScrollEffect(q, qobject_cast<QMenu*>(causedPopup.widget) ? hGuess : vGuess);
else
- qScrollEffect(this, hGuess | vGuess);
+ qScrollEffect(q, hGuess | vGuess);
} else {
// kill any running effect
- qFadeEffect(0);
- qScrollEffect(0);
+ qFadeEffect(nullptr);
+ qScrollEffect(nullptr);
- show();
+ q->show();
}
} else
#endif
{
- show();
+ q->show();
}
#ifndef QT_NO_ACCESSIBILITY
- QAccessibleEvent event(this, QAccessible::PopupMenuStart);
+ QAccessibleEvent event(q, QAccessible::PopupMenuStart);
QAccessible::updateAccessibility(&event);
#endif
}
@@ -2633,20 +2643,26 @@ QAction *QMenu::exec()
QAction *QMenu::exec(const QPoint &p, QAction *action)
{
Q_D(QMenu);
- ensurePolished();
- createWinId();
- QEventLoop eventLoop;
- d->eventLoop = &eventLoop;
- popup(p, action);
-
- QPointer<QObject> guard = this;
- (void) eventLoop.exec();
+ return d->exec(p, action);
+}
+
+QAction *QMenuPrivate::exec(const QPoint &p, QAction *action, PositionFunction positionFunction)
+{
+ Q_Q(QMenu);
+ q->ensurePolished();
+ q->createWinId();
+ QEventLoop evtLoop;
+ eventLoop = &evtLoop;
+ popup(p, action, positionFunction);
+
+ QPointer<QObject> guard = q;
+ (void) evtLoop.exec();
if (guard.isNull())
return nullptr;
- action = d->syncAction;
- d->syncAction = nullptr;
- d->eventLoop = nullptr;
+ action = syncAction;
+ syncAction = nullptr;
+ eventLoop = nullptr;
return action;
}
@@ -2692,22 +2708,22 @@ void QMenu::hideEvent(QHideEvent *)
emit aboutToHide();
if (d->eventLoop)
d->eventLoop->exit();
- d->setCurrentAction(0);
+ d->setCurrentAction(nullptr);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(this, QAccessible::PopupMenuEnd);
QAccessible::updateAccessibility(&event);
#endif
#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget))
- mb->d_func()->setCurrentAction(0);
+ mb->d_func()->setCurrentAction(nullptr);
#endif
if (QMenuPrivate::mouseDown == this)
QMenuPrivate::mouseDown = nullptr;
d->hasHadMouse = false;
if (d->activeMenu)
d->hideMenu(d->activeMenu);
- d->causedPopup.widget = 0;
- d->causedPopup.action = 0;
+ d->causedPopup.widget = nullptr;
+ d->causedPopup.action = nullptr;
if (d->scroll)
d->scroll->scrollTimer.stop(); //make sure the timer stops
}
@@ -2731,9 +2747,9 @@ void QMenu::paintEvent(QPaintEvent *e)
style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this);
//calculate the scroll up / down rect
- const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);
- const int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin,0, this);
- const int vmargin = style()->pixelMetric(QStyle::PM_MenuVMargin, 0, this);
+ const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, this);
+ const int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin,nullptr, this);
+ const int vmargin = style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, this);
QRect scrollUpRect, scrollDownRect;
const int leftmargin = fw + hmargin + d->leftmargin;
@@ -2753,7 +2769,7 @@ void QMenu::paintEvent(QPaintEvent *e)
QRect tearOffRect;
if (d->tearoff) {
tearOffRect.setRect(leftmargin, topmargin, contentWidth,
- style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this));
+ style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, this));
if (d->scroll && d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
tearOffRect.translate(0, d->scrollerHeight());
}
@@ -2873,7 +2889,7 @@ void QMenu::mousePressEvent(QMouseEvent *e)
&& QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos()))
setAttribute(Qt::WA_NoMouseReplay);
if (d->eventLoop) // synchronous operation
- d->syncAction = 0;
+ d->syncAction = nullptr;
d->hideUpToMenuBar();
return;
}
@@ -2923,12 +2939,12 @@ void QMenu::changeEvent(QEvent *e)
if (e->type() == QEvent::StyleChange || e->type() == QEvent::FontChange ||
e->type() == QEvent::LayoutDirectionChange) {
d->itemsDirty = 1;
- setMouseTracking(style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, this));
+ setMouseTracking(style()->styleHint(QStyle::SH_Menu_MouseTracking, nullptr, this));
if (isVisible())
resize(sizeHint());
- if (!style()->styleHint(QStyle::SH_Menu_Scrollable, 0, this)) {
+ if (!style()->styleHint(QStyle::SH_Menu_Scrollable, nullptr, this)) {
delete d->scroll;
- d->scroll = 0;
+ d->scroll = nullptr;
} else if (!d->scroll) {
d->scroll = new QMenuPrivate::QMenuScroller;
d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
@@ -3097,7 +3113,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
case Qt::Key_Up:
case Qt::Key_Down: {
key_consumed = true;
- QAction *nextAction = 0;
+ QAction *nextAction = nullptr;
QMenuPrivate::QMenuScroller::ScrollLocation scroll_loc = QMenuPrivate::QMenuScroller::ScrollStay;
if (!d->currentAction) {
if(key == Qt::Key_Down) {
@@ -3106,7 +3122,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
if (d->actionRects.at(i).isNull())
continue;
if (!act->isSeparator() &&
- (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
+ (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this)
|| act->isEnabled())) {
nextAction = act;
break;
@@ -3118,7 +3134,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
if (d->actionRects.at(i).isNull())
continue;
if (!act->isSeparator() &&
- (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)
+ (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this)
|| act->isEnabled())) {
nextAction = act;
break;
@@ -3132,7 +3148,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
if (key == Qt::Key_Up) {
for(int next_i = i-1; true; next_i--) {
if (next_i == -1) {
- if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this))
+ if (!style()->styleHint(QStyle::SH_Menu_SelectionWrap, nullptr, this))
break;
if (d->scroll)
scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
@@ -3145,13 +3161,13 @@ void QMenu::keyPressEvent(QKeyEvent *e)
continue;
if (next->isSeparator() ||
(!next->isEnabled() &&
- !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)))
+ !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this)))
continue;
nextAction = next;
if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)) {
int topVisible = d->scrollerHeight();
if (d->tearoff)
- topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
+ topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, this);
if (((y + d->scroll->scrollOffset) - topVisible) <= d->actionRects.at(next_i).height())
scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
}
@@ -3163,7 +3179,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
y += d->actionRects.at(i).height();
for(int next_i = i+1; true; next_i++) {
if (next_i == d->actionRects.count()) {
- if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this))
+ if (!style()->styleHint(QStyle::SH_Menu_SelectionWrap, nullptr, this))
break;
if (d->scroll)
scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop;
@@ -3176,7 +3192,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
continue;
if (next->isSeparator() ||
(!next->isEnabled() &&
- !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this)))
+ !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this)))
continue;
nextAction = next;
if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)) {
@@ -3184,7 +3200,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)
bottomVisible -= d->scrollerHeight();
if (d->tearoff)
- bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this);
+ bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, this);
if ((y + d->scroll->scrollOffset + d->actionRects.at(next_i).height()) > bottomVisible)
scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom;
}
@@ -3214,7 +3230,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
Q_FALLTHROUGH();
case Qt::Key_Left: {
if (d->currentAction && !d->scroll) {
- QAction *nextAction = 0;
+ QAction *nextAction = nullptr;
if (key == Qt::Key_Left) {
QRect actionR = d->actionRect(d->currentAction);
for(int x = actionR.left()-1; !nextAction && x >= 0; x--)
@@ -3243,7 +3259,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
break;
key_consumed = true;
- if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this))
+ if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this))
{
d->hideMenu(this);
#if QT_CONFIG(menubar)
@@ -3255,7 +3271,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
break;
case Qt::Key_Space:
- if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this))
+ if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, nullptr, this))
break;
// for motif, fall through
Q_FALLTHROUGH();
@@ -3321,8 +3337,8 @@ void QMenu::keyPressEvent(QKeyEvent *e)
if ((!e->modifiers() || e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ShiftModifier) &&
e->text().length()==1) {
bool activateAction = false;
- QAction *nextAction = 0;
- if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, 0, this) && !e->modifiers()) {
+ QAction *nextAction = nullptr;
+ if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, nullptr, this) && !e->modifiers()) {
int best_match_count = 0;
d->searchBufferTimer.start(2000, this);
d->searchBuffer += e->text();
@@ -3345,7 +3361,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
#ifndef QT_NO_SHORTCUT
else {
int clashCount = 0;
- QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;
+ QAction *first = nullptr, *currentSelected = nullptr, *firstAfterCurrent = nullptr;
QChar c = e->text().at(0).toUpper();
for(int i = 0; i < d->actions.size(); ++i) {
if (d->actionRects.at(i).isNull())
@@ -3434,7 +3450,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
QMenuPrivate::mouseDown = this;
if (d->activeMenu)
- d->activeMenu->d_func()->setCurrentAction(0);
+ d->activeMenu->d_func()->setCurrentAction(nullptr);
QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction);
if (sloppyEventResult == QMenuSloppyState::EventShouldBePropagated) {
@@ -3464,7 +3480,7 @@ void QMenu::leaveEvent(QEvent *)
Q_D(QMenu);
d->hasReceievedEnter = false;
if (!d->activeMenu && d->currentAction)
- setActiveAction(0);
+ setActiveAction(nullptr);
}
/*!
@@ -3527,7 +3543,7 @@ void QMenu::actionEvent(QActionEvent *e)
} else if (e->type() == QEvent::ActionRemoved) {
e->action()->disconnect(this);
if (e->action() == d->currentAction)
- d->currentAction = 0;
+ d->currentAction = nullptr;
if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) {
if (QWidget *widget = d->widgetItems.value(wa)) {
#ifdef Q_OS_OSX
@@ -3603,7 +3619,7 @@ void QMenu::internalDelayedPopup()
#endif
screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(pos()));
- int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
+ int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, nullptr, this);
const QRect actionRect(d->actionRect(d->currentAction));
QPoint subMenuPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top())));
if (subMenuPos.x() > screen.right())
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index efbbc099a1..02fe9f31a1 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -64,6 +64,8 @@
#include <qpa/qplatformmenu.h>
+#include <functional>
+
QT_REQUIRE_CONFIG(menu);
QT_BEGIN_NAMESPACE
@@ -302,6 +304,8 @@ class QMenuPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QMenu)
public:
+ using PositionFunction = std::function<QPoint(const QSize &)>;
+
QMenuPrivate() :
itemsDirty(false),
hasCheckableItems(false),
@@ -351,6 +355,8 @@ public:
QRect popupGeometry(int screen) const;
bool useFullScreenForPopup() const;
int getLastVisibleAction() const;
+ void popup(const QPoint &p, QAction *atAction, PositionFunction positionFunction = {});
+ QAction *exec(const QPoint &p, QAction *action, PositionFunction positionFunction = {});
//selection
static QMenu *mouseDown;
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 7a751597bc..ccd91ebee1 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -90,7 +90,7 @@ QMenuBarExtension::QMenuBarExtension(QWidget *parent)
#if QT_CONFIG(menu)
setPopupMode(QToolButton::InstantPopup);
#endif
- setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget()));
+ setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, nullptr, parentWidget()));
}
void QMenuBarExtension::paintEvent(QPaintEvent *)
@@ -106,7 +106,7 @@ void QMenuBarExtension::paintEvent(QPaintEvent *)
QSize QMenuBarExtension::sizeHint() const
{
- int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, 0, parentWidget());
+ int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, nullptr, parentWidget());
return QSize(ext, ext);
}
@@ -120,14 +120,14 @@ QAction *QMenuBarPrivate::actionAt(QPoint p) const
if(actionRect(actions.at(i)).contains(p))
return actions.at(i);
}
- return 0;
+ return nullptr;
}
QRect QMenuBarPrivate::menuRect(bool extVisible) const
{
Q_Q(const QMenuBar);
- int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
+ int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
QRect result = q->rect();
result.adjust(hmargin, 0, -hmargin, 0);
@@ -167,13 +167,13 @@ void QMenuBarPrivate::updateGeometries()
Q_Q(QMenuBar);
if(!itemsDirty)
return;
- int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2);
+ int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q)*2);
int q_start = -1;
if(leftWidget || rightWidget) {
- int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q)
- + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
- int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q)
- + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
+ int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q)
+ + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
+ int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q)
+ + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
if (leftWidget && leftWidget->isVisible()) {
QSize sz = leftWidget->sizeHint();
q_width -= sz.width();
@@ -198,7 +198,7 @@ void QMenuBarPrivate::updateGeometries()
}
#endif
calcActionRects(q_width, q_start);
- currentAction = 0;
+ currentAction = nullptr;
#ifndef QT_NO_SHORTCUT
if(itemsDirty) {
for(int j = 0; j < shortcutIndexMap.size(); ++j)
@@ -246,7 +246,7 @@ void QMenuBarPrivate::updateGeometries()
pop->clear();
pop->addActions(hiddenActions);
- int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q);
+ int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q);
int x = q->isRightToLeft()
? menuRect.left() - extension->sizeHint().width() + 1
: menuRect.right();
@@ -285,8 +285,8 @@ void QMenuBarPrivate::focusFirstAction()
void QMenuBarPrivate::setKeyboardMode(bool b)
{
Q_Q(QMenuBar);
- if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) {
- setCurrentAction(0);
+ if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, q)) {
+ setCurrentAction(nullptr);
return;
}
keyboardState = b;
@@ -298,11 +298,11 @@ void QMenuBarPrivate::setKeyboardMode(bool b)
q->setFocus(Qt::MenuBarFocusReason);
} else {
if(!popupState)
- setCurrentAction(0);
+ setCurrentAction(nullptr);
if(keyboardFocusWidget) {
if (QApplication::focusWidget() == q)
keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason);
- keyboardFocusWidget = 0;
+ keyboardFocusWidget = nullptr;
}
}
q->update();
@@ -324,15 +324,10 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1)));
QSize popup_size = activeMenu->sizeHint();
//we put the popup menu on the screen containing the bottom-center of the action rect
- QScreen *popupScreen = q->window()->windowHandle()->screen();
- QPoint bottomMiddlePos = pos + QPoint(adjustedActionRect.width() / 2, 0);
- const auto &siblings = popupScreen->virtualSiblings();
- for (QScreen *sibling : siblings) {
- if (sibling->geometry().contains(bottomMiddlePos)) {
- popupScreen = sibling;
- break;
- }
- }
+ QScreen *menubarScreen = q->window()->windowHandle()->screen();
+ QScreen *popupScreen = menubarScreen->virtualSiblingAt(pos + QPoint(adjustedActionRect.width() / 2, 0));
+ if (!popupScreen)
+ popupScreen = menubarScreen;
QRect screenRect = popupScreen->geometry();
pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
const bool fitUp = (pos.y() - popup_size.height() >= screenRect.top());
@@ -377,9 +372,9 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat
doChildEffects = (popup && !activeMenu);
Q_Q(QMenuBar);
- QWidget *fw = 0;
+ QWidget *fw = nullptr;
if(QMenu *menu = activeMenu) {
- activeMenu = 0;
+ activeMenu = nullptr;
if (popup) {
fw = q->window()->focusWidget();
q->setFocus(Qt::NoFocusReason);
@@ -424,14 +419,14 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
const QStyle *style = q->style();
- const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q);
+ const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, nullptr, q);
int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0;
//calculate size
const QFontMetrics fm = q->fontMetrics();
- const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q),
- vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q),
- icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
+ const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q),
+ vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q),
+ icone = style->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q);
for(int i = 0; i < actions.count(); i++) {
QAction *action = actions.at(i);
if(!action->isVisible())
@@ -441,7 +436,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
//calc what I think the size is..
if(action->isSeparator()) {
- if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q))
+ if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, nullptr, q))
separator = i;
continue; //we don't really position these!
} else {
@@ -475,7 +470,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
}
//calculate position
- const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q);
+ const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q);
int x = fw + ((start == -1) ? hmargin : start) + itemSpacing;
int y = fw + vmargin;
for(int i = 0; i < actions.count(); i++) {
@@ -708,7 +703,7 @@ void QMenuBarPrivate::init()
q->hide();
q->setBackgroundRole(QPalette::Button);
handleReparent();
- q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));
+ q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, nullptr, q));
extension = new QMenuBarExtension(q);
extension->setFocusPolicy(Qt::NoFocus);
@@ -720,7 +715,7 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c
{
Q_Q(const QMenuBar);
const_cast<QMenuBarPrivate*>(this)->updateGeometries();
- bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q);
+ bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q);
const int start = (_start == -1 && increment == -1) ? actions.count() : _start;
const int end = increment == -1 ? 0 : actions.count() - 1;
@@ -734,13 +729,13 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c
if (_start != -1) //let's try from the beginning or the end
return getNextAction(-1, increment);
- return 0;
+ return nullptr;
}
/*!
Constructs a menu bar with parent \a parent.
*/
-QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0)
+QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, { })
{
Q_D(QMenuBar);
d->init();
@@ -754,7 +749,7 @@ QMenuBar::~QMenuBar()
{
Q_D(QMenuBar);
delete d->platformMenuBar;
- d->platformMenuBar = 0;
+ d->platformMenuBar = nullptr;
}
/*!
@@ -1007,7 +1002,7 @@ void QMenuBar::paintEvent(QPaintEvent *e)
style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this);
}
//draw border
- if(int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)) {
+ if (int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this)) {
QRegion borderReg;
borderReg += QRect(0, 0, fw, height()); //left
borderReg += QRect(width()-fw, 0, fw, height()); //right
@@ -1060,7 +1055,7 @@ void QMenuBar::mousePressEvent(QMouseEvent *e)
QAction *action = d->actionAt(e->pos());
if (!action || !d->isVisible(action) || !action->isEnabled()) {
- d->setCurrentAction(0);
+ d->setCurrentAction(nullptr);
#if QT_CONFIG(whatsthis)
if (QWhatsThis::inWhatsThisMode())
QWhatsThis::showText(e->globalPos(), d->whatsThis, this);
@@ -1070,7 +1065,7 @@ void QMenuBar::mousePressEvent(QMouseEvent *e)
if(d->currentAction == action && d->popupState) {
if(QMenu *menu = d->activeMenu) {
- d->activeMenu = 0;
+ d->activeMenu = nullptr;
menu->setAttribute(Qt::WA_NoMouseReplay);
menu->hide();
}
@@ -1130,7 +1125,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
case Qt::Key_Enter:
case Qt::Key_Space:
case Qt::Key_Return: {
- if(!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) || !d->currentAction)
+ if (!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this) || !d->currentAction)
break;
if(d->currentAction->menu()) {
d->popupAction(d->currentAction, true);
@@ -1159,7 +1154,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
#ifndef QT_NO_SHORTCUT
if (!key_consumed && e->matches(QKeySequence::Cancel)) {
- d->setCurrentAction(0);
+ d->setCurrentAction(nullptr);
d->setKeyboardMode(false);
key_consumed = true;
}
@@ -1169,7 +1164,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
(!e->modifiers() ||
(e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().length()==1 && !d->popupState) {
int clashCount = 0;
- QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;
+ QAction *first = nullptr, *currentSelected = nullptr, *firstAfterCurrent = nullptr;
{
const QChar c = e->text().at(0).toUpper();
for(int i = 0; i < d->actions.size(); ++i) {
@@ -1193,7 +1188,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
}
}
}
- QAction *next_action = 0;
+ QAction *next_action = nullptr;
if(clashCount >= 1) {
if(clashCount == 1 || !d->currentAction || (currentSelected && !firstAfterCurrent))
next_action = first;
@@ -1239,14 +1234,14 @@ void QMenuBar::leaveEvent(QEvent *)
{
Q_D(QMenuBar);
if((!hasFocus() && !d->popupState) ||
- (d->currentAction && d->currentAction->menu() == 0))
- d->setCurrentAction(0);
+ (d->currentAction && d->currentAction->menu() == nullptr))
+ d->setCurrentAction(nullptr);
}
QPlatformMenu *QMenuBarPrivate::getPlatformMenu(const QAction *action)
{
if (!action || !action->menu())
- return 0;
+ return nullptr;
QPlatformMenu *platformMenu = action->menu()->platformMenu();
if (!platformMenu && platformMenuBar) {
@@ -1359,7 +1354,7 @@ void QMenuBar::focusOutEvent(QFocusEvent *)
{
Q_D(QMenuBar);
if(!d->popupState) {
- d->setCurrentAction(0);
+ d->setCurrentAction(nullptr);
d->setKeyboardMode(false);
}
}
@@ -1372,7 +1367,7 @@ void QMenuBar::timerEvent (QTimerEvent *e)
Q_D(QMenuBar);
if (e->timerId() == d->autoReleaseTimer.timerId()) {
d->autoReleaseTimer.stop();
- d->setCurrentAction(0);
+ d->setCurrentAction(nullptr);
}
QWidget::timerEvent(e);
}
@@ -1426,7 +1421,7 @@ void QMenuBarPrivate::handleReparent()
newWindow->createWinId();
platformMenuBar->handleReparent(newWindow->windowHandle());
} else {
- platformMenuBar->handleReparent(0);
+ platformMenuBar->handleReparent(nullptr);
}
}
}
@@ -1439,7 +1434,7 @@ void QMenuBar::changeEvent(QEvent *e)
Q_D(QMenuBar);
if(e->type() == QEvent::StyleChange) {
d->itemsDirty = true;
- setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this));
+ setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, nullptr, this));
if(parentWidget())
resize(parentWidget()->width(), heightForWidth(parentWidget()->width()));
d->updateGeometries();
@@ -1548,7 +1543,7 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event)
d->platformMenuBar->handleReparent(handle);
}
- if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) {
+ if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this)) {
if (d->altPressed) {
switch (event->type()) {
case QEvent::KeyPress:
@@ -1624,10 +1619,10 @@ QSize QMenuBar::minimumSizeHint() const
ensurePolished();
QSize ret(0, 0);
const_cast<QMenuBarPrivate*>(d)->updateGeometries();
- const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
- const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
- int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
- int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
+ const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, this);
+ const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this);
+ int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this);
+ int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this);
if(as_gui_menubar) {
int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width();
d->calcActionRects(w - (2 * fw), 0);
@@ -1676,10 +1671,10 @@ QSize QMenuBar::sizeHint() const
ensurePolished();
QSize ret(0, 0);
const_cast<QMenuBarPrivate*>(d)->updateGeometries();
- const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this);
- const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
- int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
- int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
+ const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, this);
+ const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this);
+ int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this);
+ int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this);
if(as_gui_menubar) {
const int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width();
d->calcActionRects(w - (2 * fw), 0);
@@ -1728,9 +1723,9 @@ int QMenuBar::heightForWidth(int) const
const_cast<QMenuBarPrivate*>(d)->updateGeometries();
int height = 0;
- const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this);
- int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
- int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
+ const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this);
+ int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this);
+ int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this);
if(as_gui_menubar) {
for (int i = 0; i < d->actionRects.count(); ++i)
height = qMax(height, d->actionRects.at(i).height());
@@ -1776,7 +1771,7 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id)
activateAction(act, QAction::Trigger);
//100 is the same as the default value in QPushButton::animateClick
autoReleaseTimer.start(100, q);
- } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) {
+ } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, q)) {
// When we open a menu using a shortcut, we should end up in keyboard state
setKeyboardMode(true);
}
@@ -1842,7 +1837,7 @@ void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner)
QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const
{
Q_D(const QMenuBar);
- QWidget *w = 0;
+ QWidget *w = nullptr;
switch(corner) {
case Qt::TopLeftCorner:
w = d->leftWidget;
@@ -1881,7 +1876,7 @@ void QMenuBar::setNativeMenuBar(bool nativeMenuBar)
if (nativeMenuBar != bool(d->platformMenuBar)) {
if (!nativeMenuBar) {
delete d->platformMenuBar;
- d->platformMenuBar = 0;
+ d->platformMenuBar = nullptr;
} else {
if (!d->platformMenuBar)
d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 7e9e0fabe9..87e8af1382 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -81,7 +81,7 @@ class QPlainTextDocumentLayoutPrivate : public QAbstractTextDocumentLayoutPrivat
Q_DECLARE_PUBLIC(QPlainTextDocumentLayout)
public:
QPlainTextDocumentLayoutPrivate() {
- mainViewPrivate = 0;
+ mainViewPrivate = nullptr;
width = 0;
maximumWidth = 0;
maximumWidthBlockNumber = 0;
@@ -755,7 +755,7 @@ void QPlainTextEditPrivate::updateViewport()
}
QPlainTextEditPrivate::QPlainTextEditPrivate()
- : control(0),
+ : control(nullptr),
tabChangesFocus(false),
lineWrap(QPlainTextEdit::WidgetWidth),
wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere),
@@ -1303,7 +1303,7 @@ QPlainTextEdit::~QPlainTextEdit()
Q_D(QPlainTextEdit);
if (d->documentLayoutPtr) {
if (d->documentLayoutPtr->priv()->mainViewPrivate == d)
- d->documentLayoutPtr->priv()->mainViewPrivate = 0;
+ d->documentLayoutPtr->priv()->mainViewPrivate = nullptr;
}
}
@@ -1322,7 +1322,7 @@ QPlainTextEdit::~QPlainTextEdit()
void QPlainTextEdit::setDocument(QTextDocument *document)
{
Q_D(QPlainTextEdit);
- QPlainTextDocumentLayout *documentLayout = 0;
+ QPlainTextDocumentLayout *documentLayout = nullptr;
if (!document) {
document = new QTextDocument(d->control);
@@ -1892,7 +1892,7 @@ void QPlainTextEditPrivate::relayoutDocument()
int width = viewport->width();
- if (documentLayout->priv()->mainViewPrivate == 0
+ if (documentLayout->priv()->mainViewPrivate == nullptr
|| documentLayout->priv()->mainViewPrivate == this
|| width > documentLayout->textWidth()) {
documentLayout->priv()->mainViewPrivate = this;
@@ -2250,17 +2250,17 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant a
}
const QPointF offset = contentOffset();
- switch (argument.type()) {
- case QVariant::RectF:
+ switch (argument.userType()) {
+ case QMetaType::QRectF:
argument = argument.toRectF().translated(-offset);
break;
- case QVariant::PointF:
+ case QMetaType::QPointF:
argument = argument.toPointF() - offset;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
argument = argument.toRect().translated(-offset.toPoint());
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
argument = argument.toPoint() - offset;
break;
default:
@@ -2268,14 +2268,14 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant a
}
const QVariant v = d->control->inputMethodQuery(query, argument);
- switch (v.type()) {
- case QVariant::RectF:
+ switch (v.userType()) {
+ case QMetaType::QRectF:
return v.toRectF().translated(offset);
- case QVariant::PointF:
+ case QMetaType::QPointF:
return v.toPointF() + offset;
- case QVariant::Rect:
+ case QMetaType::QRect:
return v.toRect().translated(offset.toPoint());
- case QVariant::Point:
+ case QMetaType::QPoint:
return v.toPoint() + offset.toPoint();
default:
break;
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index 56253b8e44..04241fda09 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -234,7 +234,7 @@ bool QProgressBarPrivate::repaintRequired() const
*/
QProgressBar::QProgressBar(QWidget *parent)
- : QWidget(*(new QProgressBarPrivate), parent, 0)
+ : QWidget(*(new QProgressBarPrivate), parent, { })
{
d_func()->init();
}
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index f48b5706f7..3d075bf92f 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -297,7 +297,7 @@ QDialog *QPushButtonPrivate::dialogParent() const
if (const QDialog *dialog = qobject_cast<const QDialog *>(p))
return const_cast<QDialog *>(dialog);
}
- return 0;
+ return nullptr;
}
#endif
@@ -353,7 +353,7 @@ bool QPushButton::autoDefault() const
{
Q_D(const QPushButton);
if(d->autoDefault == QPushButtonPrivate::Auto)
- return ( d->dialogParent() != 0 );
+ return ( d->dialogParent() != nullptr );
return d->autoDefault;
}
@@ -496,7 +496,7 @@ void QPushButton::focusOutEvent(QFocusEvent *e)
#if QT_CONFIG(dialog)
QDialog *dlg = qobject_cast<QDialog*>(window());
if (dlg)
- dlg->d_func()->setDefault(0);
+ dlg->d_func()->setDefault(nullptr);
else
d->defaultButton = false;
#endif
@@ -509,6 +509,17 @@ void QPushButton::focusOutEvent(QFocusEvent *e)
#endif
}
+/*!
+ \reimp
+*/
+bool QPushButton::hitButton(const QPoint &pos) const
+{
+ QStyleOptionButton option;
+ initStyleOption(&option);
+ const QRect bevel = style()->subElementRect(QStyle::SE_PushButtonBevel, &option, this);
+ return bevel.contains(pos);
+}
+
#if QT_CONFIG(menu)
/*!
Associates the popup menu \a menu with this push button. This
diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h
index b02ba63d07..283dfe2c61 100644
--- a/src/widgets/widgets/qpushbutton.h
+++ b/src/widgets/widgets/qpushbutton.h
@@ -94,6 +94,7 @@ protected:
void focusInEvent(QFocusEvent *) override;
void focusOutEvent(QFocusEvent *) override;
void initStyleOption(QStyleOptionButton *option) const;
+ bool hitButton(const QPoint &pos) const override;
QPushButton(QPushButtonPrivate &dd, QWidget* parent = nullptr);
public:
diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp
index c36ec98f9a..f7a4f8e446 100644
--- a/src/widgets/widgets/qscrollarea.cpp
+++ b/src/widgets/widgets/qscrollarea.cpp
@@ -259,7 +259,7 @@ void QScrollArea::setWidget(QWidget *widget)
return;
delete d->widget;
- d->widget = 0;
+ d->widget = nullptr;
d->hbar->setValue(0);
d->vbar->setValue(0);
if (widget->parentWidget() != d->viewport)
@@ -285,9 +285,9 @@ QWidget *QScrollArea::takeWidget()
{
Q_D(QScrollArea);
QWidget *w = d->widget;
- d->widget = 0;
+ d->widget = nullptr;
if (w)
- w->setParent(0);
+ w->setParent(nullptr);
return w;
}
diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h
index 2bdf9ed596..26335285a4 100644
--- a/src/widgets/widgets/qscrollarea_p.h
+++ b/src/widgets/widgets/qscrollarea_p.h
@@ -65,7 +65,7 @@ class QScrollAreaPrivate: public QAbstractScrollAreaPrivate
Q_DECLARE_PUBLIC(QScrollArea)
public:
- QScrollAreaPrivate(): resizable(false), alignment(nullptr){}
+ QScrollAreaPrivate(): resizable(false) {}
void updateScrollBars();
void updateWidgetPosition();
QPointer<QWidget> widget;
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index 4606f57fb8..2ce1d50c86 100644
--- a/src/widgets/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
@@ -224,7 +224,7 @@ void QScrollBarPrivate::setTransient(bool value)
if (transient != value) {
transient = value;
if (q->isVisible()) {
- if (q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q))
+ if (q->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, q))
q->update();
} else if (!transient) {
q->show();
@@ -235,7 +235,7 @@ void QScrollBarPrivate::setTransient(bool value)
void QScrollBarPrivate::flash()
{
Q_Q(QScrollBar);
- if (!flashed && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)) {
+ if (!flashed && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, q)) {
flashed = true;
if (!q->isVisible())
q->show();
@@ -319,7 +319,7 @@ void QScrollBar::initStyleOption(QStyleOptionSlider *option) const
option->upsideDown = d->invertedAppearance;
if (d->orientation == Qt::Horizontal)
option->state |= QStyle::State_Horizontal;
- if ((d->flashed || !d->transient) && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this))
+ if ((d->flashed || !d->transient) && style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this))
option->state |= QStyle::State_On;
}
@@ -376,7 +376,7 @@ void QScrollBarPrivate::init()
invertedControls = true;
pressedControl = hoverControl = QStyle::SC_None;
pointerOutsidePressedControl = false;
- transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q);
+ transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, q);
flashed = false;
flashTimer = 0;
q->setFocusPolicy(Qt::NoFocus);
@@ -392,7 +392,7 @@ void QScrollBarPrivate::init()
/*! \reimp */
void QScrollBar::contextMenuEvent(QContextMenuEvent *event)
{
- if (!style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, this)) {
+ if (!style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, nullptr, this)) {
QAbstractSlider::contextMenuEvent(event);
return ;
}
@@ -412,7 +412,7 @@ void QScrollBar::contextMenuEvent(QContextMenuEvent *event)
QAction *actScrollDn = menu->addAction(horiz ? tr("Scroll right") : tr("Scroll down"));
QAction *actionSelected = menu->exec(event->globalPos());
delete menu;
- if (actionSelected == 0)
+ if (actionSelected == nullptr)
/* do nothing */ ;
else if (actionSelected == actScrollHere)
setValue(d_func()->pixelPosToRangeValue(horiz ? event->pos().x() : event->pos().y()));
@@ -472,11 +472,11 @@ bool QScrollBar::event(QEvent *event)
d_func()->updateHoverControl(he->pos());
break;
case QEvent::StyleChange:
- d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this));
+ d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this));
break;
case QEvent::Timer:
if (static_cast<QTimerEvent *>(event)->timerId() == d->flashTimer) {
- if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)) {
+ if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this)) {
d->flashed = false;
update();
}
@@ -551,7 +551,7 @@ void QScrollBar::mousePressEvent(QMouseEvent *e)
d->stopRepeatAction();
bool midButtonAbsPos = style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition,
- 0, this);
+ nullptr, this);
QStyleOptionSlider opt;
initStyleOption(&opt);
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
index 835af9c7b8..95a4beeb57 100644
--- a/src/widgets/widgets/qsizegrip.cpp
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -128,7 +128,7 @@ QSizeGripPrivate::QSizeGripPrivate()
: dxMax(0)
, dyMax(0)
, gotMousePress(false)
- , tlw(0)
+ , tlw(nullptr)
, m_platformSizeGrip(false)
{
}
@@ -195,7 +195,7 @@ Qt::Corner QSizeGripPrivate::corner() const
parent.
*/
QSizeGrip::QSizeGrip(QWidget * parent)
- : QWidget(*new QSizeGripPrivate, parent, 0)
+ : QWidget(*new QSizeGripPrivate, parent, { })
{
Q_D(QSizeGrip);
d->init();
@@ -260,6 +260,17 @@ void QSizeGrip::paintEvent(QPaintEvent *event)
parameter.
*/
+static Qt::Edges edgesFromCorner(Qt::Corner corner)
+{
+ switch (corner) {
+ case Qt::TopLeftCorner: return Qt::TopEdge | Qt::LeftEdge;
+ case Qt::TopRightCorner: return Qt::TopEdge | Qt::RightEdge;
+ case Qt::BottomLeftCorner: return Qt::BottomEdge | Qt::LeftEdge;
+ case Qt::BottomRightCorner: return Qt::BottomEdge | Qt::RightEdge;
+ }
+ return Qt::Edges{};
+}
+
void QSizeGrip::mousePressEvent(QMouseEvent * e)
{
if (e->button() != Qt::LeftButton) {
@@ -281,8 +292,9 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
&& !tlw->testAttribute(Qt::WA_DontShowOnScreen)
&& !tlw->hasHeightForWidth()) {
QPlatformWindow *platformWindow = tlw->windowHandle()->handle();
- const QPoint topLevelPos = mapTo(tlw, e->pos());
- d->m_platformSizeGrip = platformWindow && platformWindow->startSystemResize(topLevelPos, d->m_corner);
+ const Qt::Edges edges = edgesFromCorner(d->m_corner);
+ if (!QGuiApplication::platformName().contains(QStringLiteral("xcb"))) // ### FIXME QTBUG-69716
+ d->m_platformSizeGrip = platformWindow && platformWindow->startSystemResize(edges);
}
if (d->m_platformSizeGrip)
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index ae4394dc97..cbd600ec6c 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -1081,7 +1081,7 @@ QSpinBoxPrivate::QSpinBoxPrivate()
value = minimum;
displayIntegerBase = 10;
singleStep = QVariant((int)1);
- type = QVariant::Int;
+ type = QMetaType::Int;
}
/*!
@@ -1238,7 +1238,7 @@ QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate()
value = minimum;
singleStep = QVariant(1.0);
decimals = 2;
- type = QVariant::Double;
+ type = QMetaType::Double;
}
/*!
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index e39ef6d1cd..70f05033ea 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -123,6 +123,11 @@ public:
wish to do your own drawing you can get a pointer to the pixmap
used in the splash screen with pixmap(). Alternatively, you can
subclass QSplashScreen and reimplement drawContents().
+
+ In case of having multiple screens, it is also possible to show the
+ splash screen on a different screen than the primary one. For example:
+
+ \snippet qsplashscreen/main.cpp 2
*/
/*!
@@ -132,13 +137,30 @@ public:
perhaps Qt::WindowStaysOnTopHint.
*/
QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
- : QWidget(*(new QSplashScreenPrivate()), 0, Qt::SplashScreen | Qt::FramelessWindowHint | f)
+ : QWidget(*(new QSplashScreenPrivate()), nullptr, Qt::SplashScreen | Qt::FramelessWindowHint | f)
{
setPixmap(pixmap); // Does an implicit repaint
}
/*!
\overload
+ \since 5.15
+
+ This function allows you to specify the screen for your splashscreen. The
+ typical use for this constructor is if you have multiple screens and
+ prefer to have the splash screen on a different screen than your primary
+ one. In that case pass the proper \a screen.
+*/
+QSplashScreen::QSplashScreen(QScreen *screen, const QPixmap &pixmap, Qt::WindowFlags f)
+ : QWidget(*(new QSplashScreenPrivate()), nullptr, Qt::SplashScreen | Qt::FramelessWindowHint | f)
+{
+ d_func()->setPixmap(pixmap, screen);
+}
+
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
+ \obsolete
This function allows you to specify a parent for your splashscreen. The
typical use for this constructor is if you have a multiple screens and
@@ -152,6 +174,7 @@ QSplashScreen::QSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowF
// is still 0 here due to QWidget's special handling.
d_func()->setPixmap(pixmap, QSplashScreenPrivate::screenFor(parent));
}
+#endif
/*!
Destructor.
@@ -248,14 +271,14 @@ inline static bool waitForWindowExposed(QWindow *window, int timeout = 1000)
if (remaining <= 0)
break;
QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
#if defined(Q_OS_WINRT)
WaitForSingleObjectEx(GetCurrentThread(), TimeOutMs, false);
#elif defined(Q_OS_WIN)
Sleep(uint(TimeOutMs));
#else
struct timespec ts = { TimeOutMs / 1000, (TimeOutMs % 1000) * 1000 * 1000 };
- nanosleep(&ts, NULL);
+ nanosleep(&ts, nullptr);
#endif
}
return window->isExposed();
@@ -286,26 +309,35 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap)
}
// In setPixmap(), resize and try to position on a screen according to:
-// 1) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on
+// 1) If the screen for the given widget is available, use that
+// 2) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on
// QSplashScreen(QWidget *, QPixmap).
-// 2) If a widget with associated QWindow is found, use that
-// 3) When nothing can be found, try to center it over the cursor
+// 3) If a widget with associated QWindow is found, use that
+// 4) When nothing can be found, try to center it over the cursor
+#if QT_DEPRECATED_SINCE(5, 15)
static inline int screenNumberOf(const QDesktopScreenWidget *dsw)
{
auto desktopWidgetPrivate =
static_cast<QDesktopWidgetPrivate *>(qt_widget_private(QApplication::desktop()));
return desktopWidgetPrivate->screens.indexOf(const_cast<QDesktopScreenWidget *>(dsw));
}
+#endif
const QScreen *QSplashScreenPrivate::screenFor(const QWidget *w)
{
+ if (w && w->screen())
+ return w->screen();
+
for (const QWidget *p = w; p !=nullptr ; p = p->parentWidget()) {
+#if QT_DEPRECATED_SINCE(5, 15)
if (auto dsw = qobject_cast<const QDesktopScreenWidget *>(p))
return QGuiApplication::screens().value(screenNumberOf(dsw));
+#endif
if (QWindow *window = p->windowHandle())
return window->screen();
}
+
#if QT_CONFIG(cursor)
// Note: We could rely on QPlatformWindow::initialGeometry() to center it
// over the cursor, but not all platforms (namely Android) use that.
diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h
index 8bdf4e7749..1877493fcf 100644
--- a/src/widgets/widgets/qsplashscreen.h
+++ b/src/widgets/widgets/qsplashscreen.h
@@ -55,7 +55,11 @@ class Q_WIDGETS_EXPORT QSplashScreen : public QWidget
Q_OBJECT
public:
explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
+ QSplashScreen(QScreen *screen, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X_5_15("Use the constructor taking a QScreen *")
QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
+#endif
virtual ~QSplashScreen();
void setPixmap(const QPixmap &pixmap);
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index e7a4889996..090aa5cc8b 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -119,7 +119,7 @@ QSplitterPrivate::~QSplitterPrivate()
\a parent.
*/
QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
- : QWidget(*new QSplitterHandlePrivate, parent, 0)
+ : QWidget(*new QSplitterHandlePrivate, parent, { })
{
Q_D(QSplitterHandle);
d->s = parent;
@@ -1494,7 +1494,7 @@ int QSplitter::closestLegalPosition(int pos, int index)
bool QSplitter::opaqueResize() const
{
Q_D(const QSplitter);
- return d->opaqueResizeSet ? d->opaque : style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this);
+ return d->opaqueResizeSet ? d->opaque : style()->styleHint(QStyle::SH_Splitter_OpaqueResize, nullptr, this);
}
@@ -1639,7 +1639,7 @@ int QSplitter::handleWidth() const
if (d->handleWidth >= 0) {
return d->handleWidth;
} else {
- return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
+ return style()->pixelMetric(QStyle::PM_SplitterWidth, nullptr, this);
}
}
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index f863964c58..a565d4ab4c 100644
--- a/src/widgets/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
@@ -49,7 +49,7 @@ class QStackedWidgetPrivate : public QFramePrivate
{
Q_DECLARE_PUBLIC(QStackedWidget)
public:
- QStackedWidgetPrivate():layout(0){}
+ QStackedWidgetPrivate():layout(nullptr){}
QStackedLayout *layout;
bool blockChildAdd;
};
diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp
index 39f0f11daf..4a1fef8b65 100644
--- a/src/widgets/widgets/qstatusbar.cpp
+++ b/src/widgets/widgets/qstatusbar.cpp
@@ -226,14 +226,14 @@ QRect QStatusBarPrivate::messageRect() const
\sa setSizeGripEnabled()
*/
QStatusBar::QStatusBar(QWidget * parent)
- : QWidget(*new QStatusBarPrivate, parent, 0)
+ : QWidget(*new QStatusBarPrivate, parent, { })
{
Q_D(QStatusBar);
- d->box = 0;
- d->timer = 0;
+ d->box = nullptr;
+ d->timer = nullptr;
#if QT_CONFIG(sizegrip)
- d->resizer = 0;
+ d->resizer = nullptr;
setSizeGripEnabled(true); // causes reformat()
#else
reformat();
@@ -451,7 +451,7 @@ void QStatusBar::setSizeGripEnabled(bool enabled)
d->showSizeGrip = true;
} else {
delete d->resizer;
- d->resizer = 0;
+ d->resizer = nullptr;
d->showSizeGrip = false;
}
reformat();
@@ -497,7 +497,7 @@ void QStatusBar::reformat()
int i;
QStatusBarPrivate::SBItem* item;
- for (i=0,item=0; i<d->items.size(); ++i) {
+ for (i=0,item=nullptr; i<d->items.size(); ++i) {
item = d->items.at(i);
if (!item || item->p)
break;
@@ -508,7 +508,7 @@ void QStatusBar::reformat()
l->addStretch(0);
- for (item=0; i<d->items.size(); ++i) {
+ for (item=nullptr; i<d->items.size(); ++i) {
item = d->items.at(i);
if (!item)
break;
@@ -556,7 +556,7 @@ void QStatusBar::showMessage(const QString &message, int timeout)
d->timer->start(timeout);
} else if (d->timer) {
delete d->timer;
- d->timer = 0;
+ d->timer = nullptr;
}
if (d->tempItem == message)
return;
@@ -578,7 +578,7 @@ void QStatusBar::clearMessage()
return;
if (d->timer) {
qDeleteInEventHandler(d->timer);
- d->timer = 0;
+ d->timer = nullptr;
}
d->tempItem.clear();
hideOrShow();
@@ -617,7 +617,7 @@ void QStatusBar::hideOrShow()
Q_D(QStatusBar);
bool haveMessage = !d->tempItem.isEmpty();
- QStatusBarPrivate::SBItem* item = 0;
+ QStatusBarPrivate::SBItem* item = nullptr;
for (int i=0; i<d->items.size(); ++i) {
item = d->items.at(i);
if (!item || item->p)
@@ -711,7 +711,7 @@ bool QStatusBar::event(QEvent *e)
// Calculate new strut height and call reformat() if it has changed
int maxH = fontMetrics().height();
- QStatusBarPrivate::SBItem* item = 0;
+ QStatusBarPrivate::SBItem* item = nullptr;
for (int i=0; i<d->items.size(); ++i) {
item = d->items.at(i);
if (!item)
@@ -731,7 +731,7 @@ bool QStatusBar::event(QEvent *e)
update();
}
if (e->type() == QEvent::ChildRemoved) {
- QStatusBarPrivate::SBItem* item = 0;
+ QStatusBarPrivate::SBItem* item = nullptr;
for (int i=0; i<d->items.size(); ++i) {
item = d->items.at(i);
if (!item)
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 7e1794efef..df480629da 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -76,7 +76,7 @@ class CloseButton : public QAbstractButton
Q_OBJECT
public:
- explicit CloseButton(QWidget *parent = 0);
+ explicit CloseButton(QWidget *parent = nullptr);
QSize sizeHint() const override;
QSize minimumSizeHint() const override
@@ -207,8 +207,8 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex)
else
option->selectedPosition = QStyleOptionTab::NotAdjacent;
- const bool paintBeginning = (tabIndex == 0) || (dragInProgress && tabIndex == pressedIndex + 1);
- const bool paintEnd = (tabIndex == totalTabs - 1) || (dragInProgress && tabIndex == pressedIndex - 1);
+ const bool paintBeginning = (tabIndex == firstVisible) || (dragInProgress && tabIndex == pressedIndex + 1);
+ const bool paintEnd = (tabIndex == lastVisible) || (dragInProgress && tabIndex == pressedIndex - 1);
if (paintBeginning) {
if (paintEnd)
option->position = QStyleOptionTab::OnlyOneTab;
@@ -229,6 +229,8 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex)
option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
}
#endif
+ if (QStyleOptionTabV4 *optv4 = qstyleoption_cast<QStyleOptionTabV4 *>(option))
+ optv4->tabIndex = tabIndex;
}
/*!
@@ -424,18 +426,18 @@ void QTabBarPrivate::init()
rightB->setAccessibleName(QTabBar::tr("Scroll Right"));
#endif
q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
- elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, q));
- useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, q);
+ elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, nullptr, q));
+ useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, nullptr, q);
}
QTabBarPrivate::Tab *QTabBarPrivate::at(int index)
{
- return validIndex(index)?&tabList[index]:0;
+ return validIndex(index)?&tabList[index]:nullptr;
}
const QTabBarPrivate::Tab *QTabBarPrivate::at(int index) const
{
- return validIndex(index)?&tabList[index]:0;
+ return validIndex(index)?&tabList[index]:nullptr;
}
int QTabBarPrivate::indexAtPos(const QPoint &p) const
@@ -459,8 +461,9 @@ void QTabBarPrivate::layoutTabs()
int i;
bool vertTabs = verticalTabs(shape);
int tabChainIndex = 0;
+ int hiddenTabs = 0;
- Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q));
+ Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, nullptr, q));
QVector<QLayoutStruct> tabChain(tabList.count() + 2);
// We put an empty item at the front and back and set its expansive attribute
@@ -484,7 +487,11 @@ void QTabBarPrivate::layoutTabs()
int minx = 0;
int x = 0;
int maxHeight = 0;
- for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) {
+ for (i = 0; i < tabList.count(); ++i) {
+ if (!tabList.at(i).visible) {
+ ++hiddenTabs;
+ continue;
+ }
QSize sz = q->tabSizeHint(i);
tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height());
x += sz.width();
@@ -500,6 +507,7 @@ void QTabBarPrivate::layoutTabs()
if (!expanding)
tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
+ ++tabChainIndex;
}
last = minx;
@@ -509,7 +517,11 @@ void QTabBarPrivate::layoutTabs()
int miny = 0;
int y = 0;
int maxWidth = 0;
- for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) {
+ for (i = 0; i < tabList.count(); ++i) {
+ if (!tabList.at(i).visible) {
+ ++hiddenTabs;
+ continue;
+ }
QSize sz = q->tabSizeHint(i);
tabList[i].maxRect = QRect(0, y, sz.width(), sz.height());
y += sz.height();
@@ -525,6 +537,7 @@ void QTabBarPrivate::layoutTabs()
if (!expanding)
tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint;
+ ++tabChainIndex;
}
last = miny;
@@ -538,14 +551,20 @@ void QTabBarPrivate::layoutTabs()
&& (tabAlignment != Qt::AlignRight)
&& (tabAlignment != Qt::AlignJustify);
tabChain[tabChainIndex].empty = true;
- Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.
+ Q_ASSERT(tabChainIndex == tabChain.count() - 1 - hiddenTabs); // add an assert just to make sure.
// Do the calculation
qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0);
// Use the results
+ hiddenTabs = 0;
for (i = 0; i < tabList.count(); ++i) {
- const QLayoutStruct &lstruct = tabChain.at(i + 1);
+ if (!tabList.at(i).visible) {
+ tabList[i].rect = QRect();
+ ++hiddenTabs;
+ continue;
+ }
+ const QLayoutStruct &lstruct = tabChain.at(i + 1 - hiddenTabs);
if (!vertTabs)
tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent);
else
@@ -611,7 +630,7 @@ QRect QTabBarPrivate::normalizedScrollRect(int index)
// tab bar itself is in a different orientation.
Q_Q(QTabBar);
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
q->initStyleOption(&opt, currentIndex);
opt.rect = q->rect();
@@ -740,7 +759,7 @@ void QTabBarPrivate::layoutTab(int index)
if (!(tab.leftWidget || tab.rightWidget))
return;
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
q->initStyleOption(&opt, index);
if (tab.leftWidget) {
QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);
@@ -787,7 +806,7 @@ void QTabBarPrivate::_q_closeTab()
Q_Q(QTabBar);
QObject *object = q->sender();
int tabToClose = -1;
- QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, q);
+ QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, q);
for (int i = 0; i < tabList.count(); ++i) {
if (closeSide == QTabBar::LeftSide) {
if (tabList.at(i).leftWidget == object) {
@@ -859,7 +878,7 @@ void QTabBarPrivate::refresh()
Creates a new tab bar with the given \a parent.
*/
QTabBar::QTabBar(QWidget* parent)
- :QWidget(*new QTabBarPrivate, parent, 0)
+ :QWidget(*new QTabBarPrivate, parent, { })
{
Q_D(QTabBar);
d->init();
@@ -975,16 +994,20 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
#ifndef QT_NO_SHORTCUT
d->tabList[index].shortcutId = grabShortcut(QKeySequence::mnemonic(text));
#endif
+ d->firstVisible = qMax(qMin(index, d->firstVisible), 0);
+ d->lastVisible = qMax(index, d->lastVisible);
d->refresh();
if (d->tabList.count() == 1)
setCurrentIndex(index);
- else if (index <= d->currentIndex)
+ else if (index <= d->currentIndex) {
++d->currentIndex;
+ ++d->lastVisible;
+ }
if (d->closeButtonOnTabs) {
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
initStyleOption(&opt, index);
- ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);
+ ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this);
QAbstractButton *closeButton = new CloseButton(this);
connect(closeButton, SIGNAL(clicked()), this, SLOT(_q_closeTab()));
setTabButton(index, closeSide, closeButton);
@@ -1019,12 +1042,12 @@ void QTabBar::removeTab(int index)
if (d->tabList[index].leftWidget) {
d->tabList[index].leftWidget->hide();
d->tabList[index].leftWidget->deleteLater();
- d->tabList[index].leftWidget = 0;
+ d->tabList[index].leftWidget = nullptr;
}
if (d->tabList[index].rightWidget) {
d->tabList[index].rightWidget->hide();
d->tabList[index].rightWidget->deleteLater();
- d->tabList[index].rightWidget = 0;
+ d->tabList[index].rightWidget = nullptr;
}
int newIndex = d->tabList[index].lastTab;
@@ -1035,6 +1058,9 @@ void QTabBar::removeTab(int index)
if (d->tabList[i].lastTab > index)
--d->tabList[i].lastTab;
}
+
+ d->calculateFirstLastVisible(index, false, true);
+
if (index == d->currentIndex) {
// The current tab is going away, in order to make sure
// we emit that "current has changed", we need to reset this
@@ -1045,16 +1071,14 @@ void QTabBar::removeTab(int index)
case SelectPreviousTab:
if (newIndex > index)
newIndex--;
- if (d->validIndex(newIndex))
+ if (d->validIndex(newIndex) && d->tabList.at(newIndex).visible)
break;
Q_FALLTHROUGH();
case SelectRightTab:
- newIndex = index;
- if (newIndex >= d->tabList.size())
- newIndex = d->tabList.size() - 1;
+ newIndex = qBound(d->firstVisible, index, d->lastVisible);
break;
case SelectLeftTab:
- newIndex = index - 1;
+ newIndex = qBound(d->firstVisible, index-1, d->lastVisible);
if (newIndex < 0)
newIndex = 0;
break;
@@ -1118,9 +1142,52 @@ void QTabBar::setTabEnabled(int index, bool enabled)
#endif
update();
if (!enabled && index == d->currentIndex)
- setCurrentIndex(d->validIndex(index+1)?index+1:0);
- else if (enabled && !d->validIndex(d->currentIndex))
- setCurrentIndex(index);
+ setCurrentIndex(d->selectNewCurrentIndexFrom(index+1));
+ else if (enabled && !isTabVisible(d->currentIndex))
+ setCurrentIndex(d->selectNewCurrentIndexFrom(index));
+ }
+}
+
+
+/*!
+ Returns true if the tab at position \a index is visible; otherwise
+ returns false.
+ \since 5.15
+*/
+bool QTabBar::isTabVisible(int index) const
+{
+ Q_D(const QTabBar);
+ if (d->validIndex(index))
+ return d->tabList.at(index).visible;
+ return false;
+}
+
+/*!
+ If \a visible is true, make the tab at position \a index visible,
+ otherwise make it hidden.
+ \since 5.15
+*/
+void QTabBar::setTabVisible(int index, bool visible)
+{
+ Q_D(QTabBar);
+ if (QTabBarPrivate::Tab *tab = d->at(index)) {
+ d->layoutDirty = (visible != tab->visible);
+ if (!d->layoutDirty)
+ return;
+ tab->visible = visible;
+ if (tab->leftWidget)
+ tab->leftWidget->setVisible(visible);
+ if (tab->rightWidget)
+ tab->rightWidget->setVisible(visible);
+#ifndef QT_NO_SHORTCUT
+ setShortcutEnabled(tab->shortcutId, visible);
+#endif
+ d->calculateFirstLastVisible(index, visible, false);
+ if (!visible && index == d->currentIndex) {
+ const int newindex = d->selectNewCurrentIndexFrom(index+1);
+ setCurrentIndex(newindex);
+ }
+ update();
}
}
@@ -1291,7 +1358,7 @@ QVariant QTabBar::tabData(int index) const
/*!
Returns the visual rectangle of the tab at position \a
- index, or a null rectangle if \a index is out of range.
+ index, or a null rectangle if \a index is hidden, or out of range.
*/
QRect QTabBar::tabRect(int index) const
{
@@ -1299,6 +1366,8 @@ QRect QTabBar::tabRect(int index) const
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
if (d->layoutDirty)
const_cast<QTabBarPrivate*>(d)->layoutTabs();
+ if (!tab->visible)
+ return QRect();
QRect r = tab->rect;
if (verticalTabs(d->shape))
r.translate(0, -d->scrollOffset);
@@ -1395,7 +1464,7 @@ QSize QTabBar::iconSize() const
Q_D(const QTabBar);
if (d->iconSize.isValid())
return d->iconSize;
- int iconExtent = style()->pixelMetric(QStyle::PM_TabBarIconSize, 0, this);
+ int iconExtent = style()->pixelMetric(QStyle::PM_TabBarIconSize, nullptr, this);
return QSize(iconExtent, iconExtent);
}
@@ -1429,8 +1498,10 @@ QSize QTabBar::sizeHint() const
if (d->layoutDirty)
const_cast<QTabBarPrivate*>(d)->layoutTabs();
QRect r;
- for (int i = 0; i < d->tabList.count(); ++i)
- r = r.united(d->tabList.at(i).maxRect);
+ for (int i = 0; i < d->tabList.count(); ++i) {
+ if (d->tabList.at(i).visible)
+ r = r.united(d->tabList.at(i).maxRect);
+ }
QSize sz = QApplication::globalStrut();
return r.size().expandedTo(sz);
}
@@ -1444,8 +1515,10 @@ QSize QTabBar::minimumSizeHint() const
const_cast<QTabBarPrivate*>(d)->layoutTabs();
if (!d->useScrollButtons) {
QRect r;
- for (int i = 0; i < d->tabList.count(); ++i)
- r = r.united(d->tabList.at(i).minRect);
+ for (int i = 0; i < d->tabList.count(); ++i) {
+ if (d->tabList.at(i).visible)
+ r = r.united(d->tabList.at(i).minRect);
+ }
return r.size().expandedTo(QApplication::globalStrut());
}
if (verticalTabs(d->shape))
@@ -1503,7 +1576,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)) {
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
d->initBasicStyleOption(&opt, index);
opt.text = d->tabList.at(index).text;
QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize;
@@ -1746,7 +1819,9 @@ void QTabBar::paintEvent(QPaintEvent *)
p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
for (int i = 0; i < d->tabList.count(); ++i) {
- QStyleOptionTab tab;
+ if (!d->at(i)->visible)
+ continue;
+ QStyleOptionTabV4 tab;
initStyleOption(&tab, i);
if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) {
if (vertical) {
@@ -1786,7 +1861,7 @@ void QTabBar::paintEvent(QPaintEvent *)
// Draw the selected tab last to get it "on top"
if (selected >= 0) {
- QStyleOptionTab tab;
+ QStyleOptionTabV4 tab;
initStyleOption(&tab, selected);
if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) {
if (vertical)
@@ -1797,7 +1872,7 @@ void QTabBar::paintEvent(QPaintEvent *)
if (!d->dragInProgress)
p.drawControl(QStyle::CE_TabBarTab, tab);
else {
- int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this);
+ int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, nullptr, this);
if (verticalTabs(d->shape))
d->movingTab->setGeometry(tab.rect.adjusted(0, -taboverlap, 0, taboverlap));
else
@@ -1820,6 +1895,65 @@ void QTabBar::paintEvent(QPaintEvent *)
}
/*
+ When index changes visibility, we have to find first & last visible indexes.
+ If remove is set, we force both
+ */
+void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool remove)
+{
+ if (visible) {
+ firstVisible = qMin(index, firstVisible);
+ lastVisible = qMax(index, lastVisible);
+ } else {
+ if (remove || (index == firstVisible)) {
+ firstVisible = -1;
+ for (int i = 0; i < tabList.count(); ++i) {
+ if (tabList.at(i).visible) {
+ firstVisible = i;
+ break;
+ }
+ }
+ if (firstVisible < 0)
+ firstVisible = 0;
+ }
+ if (remove || (index == lastVisible)) {
+ lastVisible = -1;
+ for (int i = tabList.count() - 1; i >= 0; --i) {
+ if (tabList.at(i).visible) {
+ lastVisible = i;
+ break;
+ }
+ }
+ }
+ }
+}
+
+/*
+ Selects the new current index starting at "fromIndex". If "fromIndex" is visible we're done.
+ Else it tries any index AFTER fromIndex, then any BEFORE fromIndex and, if everything fails,
+ it returns -1 indicating that no index is available
+ */
+int QTabBarPrivate::selectNewCurrentIndexFrom(int fromIndex)
+{
+ int newindex = -1;
+ for (int i = fromIndex; i < tabList.count(); ++i) {
+ if (at(i)->visible && at(i)->enabled) {
+ newindex = i;
+ break;
+ }
+ }
+ if (newindex < 0) {
+ for (int i = fromIndex-1; i > -1; --i) {
+ if (at(i)->visible && at(i)->enabled) {
+ newindex = i;
+ break;
+ }
+ }
+ }
+
+ return newindex;
+}
+
+/*
Given that index at position from moved to position to where return where index goes.
*/
int QTabBarPrivate::calculateNewPosition(int from, int to, int index) const
@@ -2065,7 +2199,7 @@ void QTabBarPrivate::setupMovableTab()
if (!movingTab)
movingTab = new QMovableTabWidget(q);
- int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);
+ int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, nullptr ,q);
QRect grabRect = q->tabRect(pressedIndex);
if (verticalTabs(shape))
grabRect.adjust(0, -taboverlap, 0, taboverlap);
@@ -2077,7 +2211,7 @@ void QTabBarPrivate::setupMovableTab()
grabImage.fill(Qt::transparent);
QStylePainter p(&grabImage, q);
- QStyleOptionTab tab;
+ QStyleOptionTabV4 tab;
q->initStyleOption(&tab, pressedIndex);
tab.position = QStyleOptionTab::OnlyOneTab;
if (verticalTabs(shape))
@@ -2221,9 +2355,9 @@ void QTabBar::changeEvent(QEvent *event)
switch (event->type()) {
case QEvent::StyleChange:
if (!d->elideModeSetByUser)
- d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
+ d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, nullptr, this));
if (!d->useScrollButtonsSetByUser)
- d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
+ d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, nullptr, this);
Q_FALLTHROUGH();
case QEvent::FontChange:
d->textSizes.clear();
@@ -2333,16 +2467,16 @@ void QTabBar::setTabsClosable(bool closable)
if (d->closeButtonOnTabs == closable)
return;
d->closeButtonOnTabs = closable;
- ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);
+ ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this);
if (!closable) {
for (int i = 0; i < d->tabList.count(); ++i) {
if (closeSide == LeftSide && d->tabList[i].leftWidget) {
d->tabList[i].leftWidget->deleteLater();
- d->tabList[i].leftWidget = 0;
+ d->tabList[i].leftWidget = nullptr;
}
if (closeSide == RightSide && d->tabList[i].rightWidget) {
d->tabList[i].rightWidget->deleteLater();
- d->tabList[i].rightWidget = 0;
+ d->tabList[i].rightWidget = nullptr;
}
}
} else {
@@ -2637,8 +2771,8 @@ CloseButton::CloseButton(QWidget *parent)
QSize CloseButton::sizeHint() const
{
ensurePolished();
- int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this);
- int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this);
+ int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, nullptr, this);
+ int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, nullptr, this);
return QSize(width, height);
}
@@ -2671,7 +2805,7 @@ void CloseButton::paintEvent(QPaintEvent *)
if (const QTabBar *tb = qobject_cast<const QTabBar *>(parent())) {
int index = tb->currentIndex();
- QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb);
+ QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, tb);
if (tb->tabButton(index, position) == this)
opt.state |= QStyle::State_Selected;
}
diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h
index fc619355f0..c49c12f38c 100644
--- a/src/widgets/widgets/qtabbar.h
+++ b/src/widgets/widgets/qtabbar.h
@@ -105,6 +105,9 @@ public:
bool isTabEnabled(int index) const;
void setTabEnabled(int index, bool);
+ bool isTabVisible(int index) const;
+ void setTabVisible(int index, bool);
+
QString tabText(int index) const;
void setTabText(int index, const QString &text);
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index 5552c43548..ac4cbd32a8 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -88,7 +88,7 @@ class Q_WIDGETS_EXPORT QTabBarPrivate : public QWidgetPrivate
Q_DECLARE_PUBLIC(QTabBar)
public:
QTabBarPrivate()
- :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false),
+ :currentIndex(-1), pressedIndex(-1), firstVisible(0), lastVisible(-1), shape(QTabBar::RoundedNorth), layoutDirty(false),
drawBase(true), scrollOffset(0), hoverIndex(-1), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false),
selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false),
dragInProgress(false), documentMode(false), autoHide(false), changeCurrentOnDrag(false),
@@ -97,6 +97,8 @@ public:
int currentIndex;
int pressedIndex;
+ int firstVisible;
+ int lastVisible;
QTabBar::Shape shape;
bool layoutDirty;
bool drawBase;
@@ -104,14 +106,15 @@ public:
struct Tab {
inline Tab(const QIcon &ico, const QString &txt)
- : enabled(true) , shortcutId(0), text(txt), icon(ico),
- leftWidget(0), rightWidget(0), lastTab(-1), dragOffset(0)
+ : enabled(true) , visible(true), shortcutId(0), text(txt), icon(ico),
+ leftWidget(nullptr), rightWidget(nullptr), lastTab(-1), dragOffset(0)
#if QT_CONFIG(animation)
- , animation(0)
+ , animation(nullptr)
#endif // animation
{}
bool operator==(const Tab &other) const { return &other == this; }
bool enabled;
+ bool visible;
int shortcutId;
QString text;
#ifndef QT_NO_TOOLTIP
@@ -170,6 +173,8 @@ public:
QList<Tab> tabList;
mutable QHash<QString, QSize> textSizes;
+ void calculateFirstLastVisible(int index, bool visible, bool remove);
+ int selectNewCurrentIndexFrom(int currentIndex);
int calculateNewPosition(int from, int to, int index) const;
void slide(int from, int to);
void init();
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index 4d7b39ae01..a19dacda52 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -215,9 +215,9 @@ public:
};
QTabWidgetPrivate::QTabWidgetPrivate()
- : tabs(0), stack(0), dirty(true),
+ : tabs(nullptr), stack(nullptr), dirty(true),
pos(QTabWidget::North), shape(QTabWidget::Rounded),
- leftCornerWidget(0), rightCornerWidget(0)
+ leftCornerWidget(nullptr), rightCornerWidget(nullptr)
{}
QTabWidgetPrivate::~QTabWidgetPrivate()
@@ -249,7 +249,7 @@ void QTabWidgetPrivate::init()
q->setFocusPolicy(Qt::TabFocus);
q->setFocusProxy(tabs);
q->setTabPosition(static_cast<QTabWidget::TabPosition> (q->style()->styleHint(
- QStyle::SH_TabWidget_DefaultTabPosition, 0, q )));
+ QStyle::SH_TabWidget_DefaultTabPosition, nullptr, q )));
}
@@ -280,7 +280,7 @@ void QTabWidgetPrivate::initBasicStyleOption(QStyleOptionTabWidgetFrame *option)
if (q->documentMode())
option->lineWidth = 0;
else
- option->lineWidth = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q);
+ option->lineWidth = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, q);
switch (pos) {
case QTabWidget::North:
@@ -319,7 +319,7 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const
Q_D(const QTabWidget);
d->initBasicStyleOption(option);
- int exth = style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0, this);
+ int exth = style()->pixelMetric(QStyle::PM_TabBarBaseHeight, nullptr, this);
QSize t(0, d->stack->frameWidth());
if (d->tabs->isVisibleTo(const_cast<QTabWidget *>(this))) {
t = d->tabs->sizeHint();
@@ -359,7 +359,7 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const
Constructs a tabbed widget with parent \a parent.
*/
QTabWidget::QTabWidget(QWidget *parent)
- : QWidget(*new QTabWidgetPrivate, parent, 0)
+ : QWidget(*new QTabWidgetPrivate, parent, { })
{
Q_D(QTabWidget);
d->init();
@@ -544,8 +544,8 @@ bool QTabWidget::isTabEnabled(int index) const
}
/*!
- If \a enable is true, the page at position \a index is enabled; otherwise the page at position \a index is
- disabled. The page's tab is redrawn appropriately.
+ If \a enable is true, the page at position \a index is enabled; otherwise the page at
+ position \a index is disabled. The page's tab is redrawn appropriately.
QTabWidget uses QWidget::setEnabled() internally, rather than
keeping a separate flag.
@@ -566,6 +566,44 @@ void QTabWidget::setTabEnabled(int index, bool enable)
}
/*!
+ Returns true if the page at position \a index is visible; otherwise returns false.
+
+ \sa setTabVisible()
+ \since 5.15
+*/
+
+bool QTabWidget::isTabVisible(int index) const
+{
+ Q_D(const QTabWidget);
+ return d->tabs->isTabVisible(index);
+}
+
+/*!
+ If \a visible is true, the page at position \a index is visible; otherwise the page at
+ position \a index is hidden. The page's tab is redrawn appropriately.
+
+ \sa isTabVisible()
+ \since 5.15
+*/
+
+void QTabWidget::setTabVisible(int index, bool visible)
+{
+ Q_D(QTabWidget);
+ QWidget *widget = d->stack->widget(index);
+ bool currentVisible = d->tabs->isTabVisible(d->tabs->currentIndex());
+ d->tabs->setTabVisible(index, visible);
+ if (!visible) {
+ if (widget)
+ widget->setVisible(false);
+ } else if (!currentVisible) {
+ setCurrentIndex(index);
+ if (widget)
+ widget->setVisible(true);
+ }
+ setUpLayout();
+}
+
+/*!
\fn void QTabWidget::setCornerWidget(QWidget *widget, Qt::Corner corner)
Sets the given \a widget to be shown in the specified \a corner of the
@@ -574,7 +612,7 @@ void QTabWidget::setTabEnabled(int index, bool enable)
Only the horizontal element of the \a corner will be used.
- Passing 0 shows no widget in the corner.
+ Passing \nullptr shows no widget in the corner.
Any previously set corner widget is hidden.
@@ -848,7 +886,13 @@ QSize QTabWidget::sizeHint() const
QTabWidget *that = const_cast<QTabWidget*>(this);
that->setUpLayout(true);
}
- QSize s(d->stack->sizeHint());
+ QSize s;
+ for (int i=0; i< d->stack->count(); ++i) {
+ if (const QWidget* w = d->stack->widget(i)) {
+ if (d->tabs->isTabVisible(i))
+ s = s.expandedTo(w->sizeHint());
+ }
+ }
QSize t;
if (!d->isAutoHidden()) {
t = d->tabs->sizeHint();
diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h
index f55e71488b..e6b3f93303 100644
--- a/src/widgets/widgets/qtabwidget.h
+++ b/src/widgets/widgets/qtabwidget.h
@@ -82,6 +82,9 @@ public:
bool isTabEnabled(int index) const;
void setTabEnabled(int index, bool);
+ bool isTabVisible(int index) const;
+ void setTabVisible(int index, bool);
+
QString tabText(int index) const;
void setTabText(int index, const QString &);
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index d0ccd435b3..78fde94fad 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -152,6 +152,16 @@ public:
QTextCursor prevFocus;
int lastKeypadScrollValue;
#endif
+ void emitHighlighted(const QUrl &url)
+ {
+ Q_Q(QTextBrowser);
+ emit q->highlighted(url);
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ emit q->highlighted(url.toString());
+#endif
+ }
};
Q_DECLARE_TYPEINFO(QTextBrowserPrivate::HistoryEntry, Q_MOVABLE_TYPE);
@@ -256,24 +266,20 @@ void QTextBrowserPrivate::_q_activateAnchor(const QString &href)
void QTextBrowserPrivate::_q_highlightLink(const QString &anchor)
{
- Q_Q(QTextBrowser);
if (anchor.isEmpty()) {
#ifndef QT_NO_CURSOR
if (viewport->cursor().shape() != Qt::PointingHandCursor)
oldCursor = viewport->cursor();
viewport->setCursor(oldCursor);
#endif
- emit q->highlighted(QUrl());
- emit q->highlighted(QString());
+ emitHighlighted(QUrl());
} else {
#ifndef QT_NO_CURSOR
viewport->setCursor(Qt::PointingHandCursor);
#endif
const QUrl url = resolveUrl(anchor);
- emit q->highlighted(url);
- // convenience to ease connecting to QStatusBar::showMessage(const QString &)
- emit q->highlighted(url.toString());
+ emitHighlighted(url);
}
}
@@ -310,9 +316,9 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType
if (url.isValid()
&& (newUrlWithoutFragment != currentUrlWithoutFragment || forceLoadOnSourceChange)) {
QVariant data = q->loadResource(type, resolveUrl(url));
- if (data.type() == QVariant::String) {
+ if (data.userType() == QMetaType::QString) {
txt = data.toString();
- } else if (data.type() == QVariant::ByteArray) {
+ } else if (data.userType() == QMetaType::QByteArray) {
if (type == QTextDocument::HtmlResource) {
#if QT_CONFIG(textcodec)
QByteArray ba = data.toByteArray();
@@ -383,8 +389,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url, QTextDocument::ResourceType
}
#ifdef QT_KEYPAD_NAVIGATION
lastKeypadScrollValue = vbar->value();
- emit q->highlighted(QUrl());
- emit q->highlighted(QString());
+ emitHighlighted(QUrl());
#endif
#ifndef QT_NO_CURSOR
@@ -559,8 +564,7 @@ void QTextBrowserPrivate::keypadMove(bool next)
// Ensure that the new selection is highlighted.
const QString href = control->anchorAtCursor();
QUrl url = resolveUrl(href);
- emit q->highlighted(url);
- emit q->highlighted(url.toString());
+ emitHighlighted(url);
} else {
// Scroll
vbar->setValue(scrollYOffset);
@@ -575,8 +579,7 @@ void QTextBrowserPrivate::keypadMove(bool next)
hbar->setValue(savedXOffset);
vbar->setValue(scrollYOffset);
- emit q->highlighted(QUrl());
- emit q->highlighted(QString());
+ emitHighlighted(QUrl());
}
}
#endif
@@ -619,8 +622,7 @@ void QTextBrowserPrivate::restoreHistoryEntry(const HistoryEntry &entry)
Q_Q(QTextBrowser);
const QString href = prevFocus.charFormat().anchorHref();
QUrl url = resolveUrl(href);
- emit q->highlighted(url);
- emit q->highlighted(url.toString());
+ emitHighlighted(url);
#endif
}
@@ -927,6 +929,7 @@ void QTextBrowser::doSetSource(const QUrl &url, QTextDocument::ResourceType type
/*! \fn void QTextBrowser::highlighted(const QString &link)
\overload
+ \obsolete
Convenience signal that allows connecting to a slot
that takes just a QString, like for example QStatusBar's
@@ -1127,8 +1130,7 @@ bool QTextBrowser::focusNextPrevChild(bool next)
if (d->prevFocus != d->control->textCursor() && d->control->textCursor().hasSelection()) {
const QString href = d->control->anchorAtCursor();
QUrl url = d->resolveUrl(href);
- emit highlighted(url);
- emit highlighted(url.toString());
+ emitHighlighted(url);
}
d->prevFocus = d->control->textCursor();
#endif
@@ -1136,8 +1138,7 @@ bool QTextBrowser::focusNextPrevChild(bool next)
} else {
#ifdef QT_KEYPAD_NAVIGATION
// We assume we have no highlight now.
- emit highlighted(QUrl());
- emit highlighted(QString());
+ emitHighlighted(QUrl());
#endif
}
return QTextEdit::focusNextPrevChild(next);
diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h
index 33e5b3980c..4b3ec491ee 100644
--- a/src/widgets/widgets/qtextbrowser.h
+++ b/src/widgets/widgets/qtextbrowser.h
@@ -107,7 +107,10 @@ Q_SIGNALS:
void historyChanged();
void sourceChanged(const QUrl &);
void highlighted(const QUrl &);
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X_5_15("Use QTextBrowser::highlighted(QUrl) instead")
void highlighted(const QString &);
+#endif
void anchorClicked(const QUrl &);
protected:
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index ed6ffaee44..8ddda78f7d 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -117,7 +117,7 @@ public:
};
QTextEditPrivate::QTextEditPrivate()
- : control(0),
+ : control(nullptr),
autoFormatting(QTextEdit::AutoNone), tabChangesFocus(false),
lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0),
wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), clickCausedFocus(0),
@@ -1503,7 +1503,7 @@ void QTextEdit::resizeEvent(QResizeEvent *e)
QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
if (!doc->pageSize().isNull()
- && alignmentProperty.type() == QVariant::Bool
+ && alignmentProperty.userType() == QMetaType::Bool
&& !alignmentProperty.toBool()) {
d->_q_adjustScrollbars();
@@ -1548,7 +1548,7 @@ void QTextEditPrivate::relayoutDocument()
width = lineWrapColumnOrWidth;
else if (lineWrap == QTextEdit::NoWrap) {
QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
- if (alignmentProperty.type() == QVariant::Bool && !alignmentProperty.toBool()) {
+ if (alignmentProperty.userType() == QMetaType::Bool && !alignmentProperty.toBool()) {
width = 0;
}
@@ -1836,17 +1836,17 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argume
}
const QPointF offset(-d->horizontalOffset(), -d->verticalOffset());
- switch (argument.type()) {
- case QVariant::RectF:
+ switch (argument.userType()) {
+ case QMetaType::QRectF:
argument = argument.toRectF().translated(-offset);
break;
- case QVariant::PointF:
+ case QMetaType::QPointF:
argument = argument.toPointF() - offset;
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
argument = argument.toRect().translated(-offset.toPoint());
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
argument = argument.toPoint() - offset;
break;
default:
@@ -1854,14 +1854,14 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argume
}
const QVariant v = d->control->inputMethodQuery(query, argument);
- switch (v.type()) {
- case QVariant::RectF:
+ switch (v.userType()) {
+ case QMetaType::QRectF:
return v.toRectF().translated(offset);
- case QVariant::PointF:
+ case QMetaType::QPointF:
return v.toPointF() + offset;
- case QVariant::Rect:
+ case QMetaType::QRect:
return v.toRect().translated(offset.toPoint());
- case QVariant::Point:
+ case QMetaType::QPoint:
return v.toPoint() + offset.toPoint();
default:
break;
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index 58e9c4fd87..b4e90c7d71 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -91,7 +91,7 @@ void QToolBarPrivate::init()
q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar);
QStyle *style = q->style();
- int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
+ int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, q);
iconSize = QSize(e, e);
layout = new QToolBarLayout(q);
@@ -99,7 +99,7 @@ void QToolBarPrivate::init()
toggleViewAction = new QAction(q);
toggleViewAction->setCheckable(true);
- q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q ));
+ q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, nullptr, q ));
QObject::connect(toggleViewAction, SIGNAL(triggered(bool)), q, SLOT(_q_toggleView(bool)));
}
@@ -173,21 +173,21 @@ void QToolBarPrivate::initDrag(const QPoint &pos)
{
Q_Q(QToolBar);
- if (state != 0)
+ if (state != nullptr)
return;
QMainWindow *win = qobject_cast<QMainWindow*>(parent);
- Q_ASSERT(win != 0);
+ Q_ASSERT(win != nullptr);
QMainWindowLayout *layout = qt_mainwindow_layout(win);
- Q_ASSERT(layout != 0);
- if (layout->pluggingWidget != 0) // the main window is animating a docking operation
+ Q_ASSERT(layout != nullptr);
+ if (layout->pluggingWidget != nullptr) // the main window is animating a docking operation
return;
state = new DragState;
state->pressPos = pos;
state->dragging = false;
state->moving = false;
- state->widgetItem = 0;
+ state->widgetItem = nullptr;
if (q->isRightToLeft())
state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y());
@@ -197,19 +197,19 @@ void QToolBarPrivate::startDrag(bool moving)
{
Q_Q(QToolBar);
- Q_ASSERT(state != 0);
+ Q_ASSERT(state != nullptr);
if ((moving && state->moving) || state->dragging)
return;
QMainWindow *win = qobject_cast<QMainWindow*>(parent);
- Q_ASSERT(win != 0);
+ Q_ASSERT(win != nullptr);
QMainWindowLayout *layout = qt_mainwindow_layout(win);
- Q_ASSERT(layout != 0);
+ Q_ASSERT(layout != nullptr);
if (!moving) {
state->widgetItem = layout->unplug(q);
- Q_ASSERT(state->widgetItem != 0);
+ Q_ASSERT(state->widgetItem != nullptr);
}
state->dragging = !moving;
state->moving = moving;
@@ -218,13 +218,13 @@ void QToolBarPrivate::startDrag(bool moving)
void QToolBarPrivate::endDrag()
{
Q_Q(QToolBar);
- Q_ASSERT(state != 0);
+ Q_ASSERT(state != nullptr);
q->releaseMouse();
if (state->dragging) {
QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
- Q_ASSERT(layout != 0);
+ Q_ASSERT(layout != nullptr);
if (!layout->plug(state->widgetItem)) {
if (q->isFloatable()) {
@@ -239,7 +239,7 @@ void QToolBarPrivate::endDrag()
}
delete state;
- state = 0;
+ state = nullptr;
}
bool QToolBarPrivate::mousePressEvent(QMouseEvent *event)
@@ -278,7 +278,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event)
bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*)
{
- if (state != 0) {
+ if (state != nullptr) {
endDrag();
return true;
} else {
@@ -310,13 +310,13 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
}
QMainWindow *win = qobject_cast<QMainWindow*>(parent);
- if (win == 0)
+ if (win == nullptr)
return true;
QMainWindowLayout *layout = qt_mainwindow_layout(win);
- Q_ASSERT(layout != 0);
+ Q_ASSERT(layout != nullptr);
- if (layout->pluggingWidget == 0
+ if (layout->pluggingWidget == nullptr
&& (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) {
const bool wasDragging = state->dragging;
const bool moving = !q->isWindow() && (orientation == Qt::Vertical ?
@@ -503,7 +503,7 @@ void QToolBarPrivate::plug(const QRect &r)
Constructs a QToolBar with the given \a parent.
*/
QToolBar::QToolBar(QWidget *parent)
- : QWidget(*new QToolBarPrivate, parent, 0)
+ : QWidget(*new QToolBarPrivate, parent, { })
{
Q_D(QToolBar);
d->init();
@@ -673,16 +673,16 @@ void QToolBar::setIconSize(const QSize &iconSize)
if (mw && mw->layout()) {
QLayout *layout = mw->layout();
int i = 0;
- QLayoutItem *item = 0;
+ QLayoutItem *item = nullptr;
do {
item = layout->itemAt(i++);
if (item && (item->widget() == this))
sz = mw->iconSize();
- } while (!sz.isValid() && item != 0);
+ } while (!sz.isValid() && item != nullptr);
}
}
if (!sz.isValid()) {
- const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);
+ const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, this);
sz = QSize(metric, metric);
}
if (d->iconSize != sz) {
@@ -945,7 +945,7 @@ QAction *QToolBar::actionAt(const QPoint &p) const
QWidget *widget = childAt(p);
int index = d->layout->indexOf(widget);
if (index == -1)
- return 0;
+ return nullptr;
QLayoutItem *item = d->layout->itemAt(index);
return static_cast<QToolBarItem*>(item)->action;
}
@@ -966,7 +966,7 @@ void QToolBar::actionEvent(QActionEvent *event)
switch (event->type()) {
case QEvent::ActionAdded: {
- Q_ASSERT_X(widgetAction == 0 || d->layout->indexOf(widgetAction) == -1,
+ Q_ASSERT_X(widgetAction == nullptr || d->layout->indexOf(widgetAction) == -1,
"QToolBar", "widgets cannot be inserted multiple times");
// reparent the action to this toolbar if it has been created
@@ -974,7 +974,7 @@ void QToolBar::actionEvent(QActionEvent *event)
// preserve Qt 4.1.x behavior. The widget is already
// reparented to us due to the createWidget call inside
// createItem()
- if (widgetAction != 0 && widgetAction->d_func()->autoCreated)
+ if (widgetAction != nullptr && widgetAction->d_func()->autoCreated)
widgetAction->setParent(this);
int index = d->layout->count();
@@ -1059,18 +1059,18 @@ void QToolBar::paintEvent(QPaintEvent *)
*/
static bool waitForPopup(QToolBar *tb, QWidget *popup)
{
- if (popup == 0 || popup->isHidden())
+ if (popup == nullptr || popup->isHidden())
return false;
QWidget *w = popup;
- while (w != 0) {
+ while (w != nullptr) {
if (w == tb)
return true;
w = w->parentWidget();
}
QMenu *menu = qobject_cast<QMenu*>(popup);
- if (menu == 0)
+ if (menu == nullptr)
return false;
QAction *action = menu->menuAction();
@@ -1161,7 +1161,7 @@ bool QToolBar::event(QEvent *event)
return true;
break;
case QEvent::Leave:
- if (d->state != 0 && d->state->dragging) {
+ if (d->state != nullptr && d->state->dragging) {
#ifdef Q_OS_WIN
// This is a workaround for loosing the mouse on Vista.
QPoint pos = QCursor::pos();
@@ -1213,7 +1213,7 @@ QWidget *QToolBar::widgetForAction(QAction *action) const
int index = d->layout->indexOf(action);
if (index == -1)
- return 0;
+ return nullptr;
return d->layout->itemAt(index)->widget();
}
@@ -1233,7 +1233,7 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const
option->initFrom(this);
if (orientation() == Qt::Horizontal)
option->state |= QStyle::State_Horizontal;
- option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this);
+ option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, nullptr, this);
option->features = d->layout->movable()
? QStyleOptionToolBar::Movable
: QStyleOptionToolBar::None;
@@ -1247,7 +1247,7 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const
return;
QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);
- Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()",
+ Q_ASSERT_X(layout != nullptr, "QToolBar::initStyleOption()",
"QMainWindow->layout() != QMainWindowLayout");
layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this));
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index 0c434e8d1d..6aaf59cafd 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -59,15 +59,9 @@ class Q_WIDGETS_EXPORT QToolBar : public QWidget
{
Q_OBJECT
- Q_PROPERTY(bool movable READ isMovable WRITE setMovable
- DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
- NOTIFY movableChanged)
- Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas
- DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
- NOTIFY allowedAreasChanged)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation
- DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) == 0)
- NOTIFY orientationChanged)
+ Q_PROPERTY(bool movable READ isMovable WRITE setMovable NOTIFY movableChanged)
+ Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas NOTIFY allowedAreasChanged)
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle
NOTIFY toolButtonStyleChanged)
diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index adc329131c..493c094cc1 100644
--- a/src/widgets/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
@@ -91,7 +91,7 @@ bool QToolBarAreaLayoutItem::skip() const
{
if (gap)
return false;
- return widgetItem == 0 || widgetItem->isEmpty();
+ return widgetItem == nullptr || widgetItem->isEmpty();
}
/******************************************************************************
@@ -302,7 +302,7 @@ QLayoutItem *QToolBarAreaLayoutInfo::insertToolBar(QToolBar *before, QToolBar *t
void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item)
{
- if (before == 0) {
+ if (before == nullptr) {
if (lines.isEmpty())
lines.append(QToolBarAreaLayoutLine(o));
lines.last().toolBarItems.append(item);
@@ -330,7 +330,7 @@ void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar)
QToolBarAreaLayoutItem &item = line.toolBarItems[k];
if (item.widgetItem->widget() == toolBar) {
delete item.widgetItem;
- item.widgetItem = 0;
+ item.widgetItem = nullptr;
line.toolBarItems.removeAt(k);
if (line.toolBarItems.isEmpty() && j < lines.count() - 1)
@@ -344,7 +344,7 @@ void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar)
void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before)
{
- if (before == 0) {
+ if (before == nullptr) {
if (!lines.isEmpty() && lines.constLast().toolBarItems.isEmpty())
return;
lines.append(QToolBarAreaLayoutLine(o));
@@ -729,7 +729,7 @@ QRect QToolBarAreaLayout::rectHint(const QRect &r) const
QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const
{
- Q_ASSERT(x != 0);
+ Q_ASSERT(x != nullptr);
for (int i = 0; i < QInternal::DockCount; ++i) {
const QToolBarAreaLayoutInfo &dock = docks[i];
@@ -744,12 +744,12 @@ QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const
}
}
- return 0;
+ return nullptr;
}
QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index)
{
- Q_ASSERT(x != 0);
+ Q_ASSERT(x != nullptr);
for (int i = 0; i < QInternal::DockCount; ++i) {
QToolBarAreaLayoutInfo &dock = docks[i];
@@ -768,7 +768,7 @@ QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index)
}
}
- return 0;
+ return nullptr;
}
void QToolBarAreaLayout::deleteAllLayoutItems()
@@ -783,7 +783,7 @@ void QToolBarAreaLayout::deleteAllLayoutItems()
QToolBarAreaLayoutItem &item = line.toolBarItems[k];
if (!item.gap)
delete item.widgetItem;
- item.widgetItem = 0;
+ item.widgetItem = nullptr;
}
}
}
@@ -811,7 +811,7 @@ QLayoutItem *QToolBarAreaLayout::insertToolBar(QToolBar *before, QToolBar *toolB
{
QInternal::DockPosition pos = findToolBar(before);
if (pos == QInternal::DockCount)
- return 0;
+ return nullptr;
return docks[pos].insertToolBar(before, toolBar);
}
@@ -826,7 +826,7 @@ void QToolBarAreaLayout::removeToolBar(QToolBar *toolBar)
QLayoutItem *QToolBarAreaLayout::addToolBar(QInternal::DockPosition pos, QToolBar *toolBar)
{
- return docks[pos].insertToolBar(0, toolBar);
+ return docks[pos].insertToolBar(nullptr, toolBar);
}
void QToolBarAreaLayout::insertToolBarBreak(QToolBar *before)
@@ -847,7 +847,7 @@ void QToolBarAreaLayout::removeToolBarBreak(QToolBar *before)
void QToolBarAreaLayout::addToolBarBreak(QInternal::DockPosition pos)
{
- docks[pos].insertToolBarBreak(0);
+ docks[pos].insertToolBarBreak(nullptr);
}
void QToolBarAreaLayout::moveToolBar(QToolBar *toolbar, int p)
@@ -878,7 +878,7 @@ void QToolBarAreaLayout::insertItem(QToolBar *before, QLayoutItem *item)
void QToolBarAreaLayout::apply(bool animate)
{
QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow);
- Q_ASSERT(layout != 0);
+ Q_ASSERT(layout != nullptr);
Qt::LayoutDirection dir = mainWindow->layoutDirection();
@@ -1117,13 +1117,13 @@ QToolBarAreaLayoutItem *QToolBarAreaLayout::item(const QList<int> &path)
Q_ASSERT(path.count() == 3);
if (path.at(0) < 0 || path.at(0) >= QInternal::DockCount)
- return 0;
+ return nullptr;
QToolBarAreaLayoutInfo &info = docks[path.at(0)];
if (path.at(1) < 0 || path.at(1) >= info.lines.count())
- return 0;
+ return nullptr;
QToolBarAreaLayoutLine &line = info.lines[path.at(1)];
if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.count())
- return 0;
+ return nullptr;
return &(line.toolBarItems[path.at(2)]);
}
@@ -1143,10 +1143,10 @@ QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path)
QToolBarAreaLayoutItem *item = this->item(path);
if (Q_UNLIKELY(!item)) {
qWarning() << "No item at" << path;
- return 0;
+ return nullptr;
}
Q_ASSERT(item->gap);
- Q_ASSERT(item->widgetItem != 0);
+ Q_ASSERT(item->widgetItem != nullptr);
item->gap = false;
return item->widgetItem;
}
@@ -1352,14 +1352,14 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
rect = unpackRect(geom0, geom1, &floating);
}
- QToolBar *toolBar = 0;
+ QToolBar *toolBar = nullptr;
for (int x = 0; x < toolBars.count(); ++x) {
if (toolBars.at(x)->objectName() == objectName) {
toolBar = toolBars.takeAt(x);
break;
}
}
- if (toolBar == 0) {
+ if (toolBar == nullptr) {
continue;
}
diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index 92094a38fb..d77ba3c13e 100644
--- a/src/widgets/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
@@ -69,13 +69,13 @@ extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
*/
QToolBarItem::QToolBarItem(QWidget *widget)
- : QWidgetItem(widget), action(0), customWidget(false)
+ : QWidgetItem(widget), action(nullptr), customWidget(false)
{
}
bool QToolBarItem::isEmpty() const
{
- return action == 0 || !action->isVisible();
+ return action == nullptr || !action->isVisible();
}
/******************************************************************************
@@ -84,7 +84,7 @@ bool QToolBarItem::isEmpty() const
QToolBarLayout::QToolBarLayout(QWidget *parent)
: QLayout(parent), expanded(false), animating(false), dirty(true),
- expanding(false), empty(true), expandFlag(false), popupMenu(0)
+ expanding(false), empty(true), expandFlag(false), popupMenu(nullptr)
{
QToolBar *tb = qobject_cast<QToolBar*>(parent);
if (!tb)
@@ -132,15 +132,15 @@ bool QToolBarLayout::hasExpandFlag() const
void QToolBarLayout::setUsePopupMenu(bool set)
{
- if (!dirty && ((popupMenu == 0) == set))
+ if (!dirty && ((popupMenu == nullptr) == set))
invalidate();
if (!set) {
QObject::connect(extension, SIGNAL(clicked(bool)),
this, SLOT(setExpanded(bool)), Qt::UniqueConnection);
extension->setPopupMode(QToolButton::DelayedPopup);
- extension->setMenu(0);
+ extension->setMenu(nullptr);
delete popupMenu;
- popupMenu = 0;
+ popupMenu = nullptr;
} else {
QObject::disconnect(extension, SIGNAL(clicked(bool)),
this, SLOT(setExpanded(bool)));
@@ -169,21 +169,21 @@ void QToolBarLayout::addItem(QLayoutItem*)
QLayoutItem *QToolBarLayout::itemAt(int index) const
{
if (index < 0 || index >= items.count())
- return 0;
+ return nullptr;
return items.at(index);
}
QLayoutItem *QToolBarLayout::takeAt(int index)
{
if (index < 0 || index >= items.count())
- return 0;
+ return nullptr;
QToolBarItem *item = items.takeAt(index);
if (popupMenu)
popupMenu->removeAction(item->action);
QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action);
- if (widgetAction != 0 && item->customWidget) {
+ if (widgetAction != nullptr && item->customWidget) {
widgetAction->releaseWidget(item->widget());
} else {
// destroy the QToolButton/QToolBarSeparator
@@ -240,9 +240,9 @@ Qt::Orientations QToolBarLayout::expandingDirections() const
updateGeomArray();
QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
if (!tb)
- return Qt::Orientations(0);
+ return {};
Qt::Orientation o = tb->orientation();
- return expanding ? Qt::Orientations(o) : Qt::Orientations(0);
+ return expanding ? Qt::Orientations(o) : Qt::Orientations{};
}
bool QToolBarLayout::movable() const
@@ -251,7 +251,7 @@ bool QToolBarLayout::movable() const
if (!tb)
return false;
QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget());
- return tb->isMovable() && win != 0;
+ return tb->isMovable() && win != nullptr;
}
void QToolBarLayout::updateGeomArray() const
@@ -343,7 +343,7 @@ void QToolBarLayout::updateGeomArray() const
static bool defaultWidgetAction(QToolBarItem *item)
{
QWidgetAction *a = qobject_cast<QWidgetAction*>(item->action);
- return a != 0 && a->defaultWidget() == item->widget();
+ return a != nullptr && a->defaultWidget() == item->widget();
}
void QToolBarLayout::updateMacBorderMetrics()
@@ -570,7 +570,7 @@ bool QToolBarLayout::layoutActions(const QSize &size)
// widgets into the menu. If only custom widget actions are chopped off, the popup menu
// is empty. So we show the little extension button to show something is chopped off,
// but we make it disabled.
- extension->setEnabled(popupMenu == 0 || !extensionMenuContainsOnlyWidgetActions);
+ extension->setEnabled(popupMenu == nullptr || !extensionMenuContainsOnlyWidgetActions);
// we have to do the show/hide here, because it triggers more calls to setGeometry :(
for (int i = 0; i < showWidgets.count(); ++i)
@@ -617,7 +617,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
++rows; // we want to expand to at least two rows
int space = total_w/rows + spacing + extensionExtent;
space = qMax(space, min_w - pick(o, margins) - handleExtent);
- if (win != 0)
+ if (win != nullptr)
space = qMin(space, pick(o, win->size()) - pick(o, margins) - handleExtent);
int w = 0;
@@ -653,7 +653,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
w += pick(Qt::Horizontal, margins) + handleExtent + spacing + extensionExtent;
w = qMax(w, min_w);
- if (win != 0)
+ if (win != nullptr)
w = qMin(w, pick(o, win->size()));
h += pick(Qt::Vertical, margins) - spacing; //there is no spacing before the first row
@@ -712,14 +712,14 @@ QToolBarItem *QToolBarLayout::createItem(QAction *action)
{
bool customWidget = false;
bool standardButtonWidget = false;
- QWidget *widget = 0;
+ QWidget *widget = nullptr;
QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
if (!tb)
- return (QToolBarItem *)0;
+ return (QToolBarItem *)nullptr;
if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action)) {
widget = widgetAction->requestWidget(tb);
- if (widget != 0) {
+ if (widget != nullptr) {
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect);
customWidget = true;
}
diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp
index 4d7f543a99..4767394842 100644
--- a/src/widgets/widgets/qtoolbox.cpp
+++ b/src/widgets/widgets/qtoolbox.cpp
@@ -111,7 +111,7 @@ public:
typedef std::vector<std::unique_ptr<Page>> PageList;
inline QToolBoxPrivate()
- : currentPage(0)
+ : currentPage(nullptr)
{
}
void _q_buttonClicked();
@@ -157,7 +157,7 @@ const QToolBoxPrivate::Page *QToolBoxPrivate::page(int index) const
void QToolBoxPrivate::updateTabs()
{
- QToolBoxButton *lastButton = currentPage ? currentPage->button : 0;
+ QToolBoxButton *lastButton = currentPage ? currentPage->button : nullptr;
bool after = false;
int index = 0;
for (const auto &page : pageList) {
@@ -184,7 +184,7 @@ QSize QToolBoxButton::sizeHint() const
{
QSize iconSize(8, 8);
if (!icon().isNull()) {
- int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() /* QToolBox */);
+ int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, parentWidget() /* QToolBox */);
iconSize += QSize(icone + 2, icone);
}
QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8);
@@ -197,7 +197,7 @@ QSize QToolBoxButton::minimumSizeHint() const
{
if (icon().isNull())
return QSize();
- int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() /* QToolBox */);
+ int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, parentWidget() /* QToolBox */);
return QSize(icone + 8, icone + 8);
}
@@ -378,7 +378,7 @@ int QToolBox::insertItem(int index, QWidget *widget, const QIcon &icon, const QS
QWidget *current = d->currentPage->widget;
int oldindex = indexOf(current);
if (index <= oldindex) {
- d->currentPage = 0; // trigger change
+ d->currentPage = nullptr; // trigger change
setCurrentIndex(oldindex);
}
}
@@ -472,10 +472,10 @@ void QToolBoxPrivate::_q_widgetDestroyed(QObject *object)
pageList.erase(std::remove_if(pageList.begin(), pageList.end(), pageEquals(c)), pageList.end());
if (pageList.empty()) {
- currentPage = 0;
+ currentPage = nullptr;
emit q->currentChanged(-1);
} else if (removeCurrent) {
- currentPage = 0;
+ currentPage = nullptr;
q->setCurrentIndex(0);
}
}
@@ -562,7 +562,7 @@ QWidget *QToolBox::widget(int index) const
int QToolBox::indexOf(QWidget *widget) const
{
Q_D(const QToolBox);
- const QToolBoxPrivate::Page *c = (widget ? d->page(widget) : 0);
+ const QToolBoxPrivate::Page *c = (widget ? d->page(widget) : nullptr);
if (!c)
return -1;
const auto it = std::find_if(d->pageList.cbegin(), d->pageList.cend(), pageEquals(c));
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index b00b219386..314c6ab40c 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -202,7 +202,7 @@ QToolButton::QToolButton(QWidget * parent)
void QToolButtonPrivate::init()
{
Q_Q(QToolButton);
- defaultAction = 0;
+ defaultAction = nullptr;
#if QT_CONFIG(toolbar)
if (qobject_cast<QToolBar*>(parent))
autoRaise = true;
@@ -227,7 +227,7 @@ void QToolButtonPrivate::init()
#endif
setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem);
- delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, q);
+ delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, nullptr, q);
}
/*!
@@ -477,10 +477,10 @@ void QToolButton::actionEvent(QActionEvent *event)
break;
case QEvent::ActionRemoved:
if (d->defaultAction == action)
- d->defaultAction = 0;
+ d->defaultAction = nullptr;
#if QT_CONFIG(menu)
if (action == d->menuAction)
- d->menuAction = 0;
+ d->menuAction = nullptr;
#endif
action->disconnect(this);
break;
@@ -583,7 +583,7 @@ void QToolButton::changeEvent(QEvent *e)
|| e->type() == QEvent::MacSizeChange
#endif
) {
- d->delay = style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, this);
+ d->delay = style()->styleHint(QStyle::SH_ToolButton_PopupDelay, nullptr, this);
d->setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem);
}
#endif
@@ -649,7 +649,7 @@ void QToolButton::setMenu(QMenu* menu)
{
Q_D(QToolButton);
- if (d->menuAction == (menu ? menu->menuAction() : 0))
+ if (d->menuAction == (menu ? menu->menuAction() : nullptr))
return;
if (d->menuAction)
@@ -659,7 +659,7 @@ void QToolButton::setMenu(QMenu* menu)
d->menuAction = menu->menuAction();
addAction(d->menuAction);
} else {
- d->menuAction = 0;
+ d->menuAction = nullptr;
}
// changing the menu set may change the size hint, so reset it
@@ -723,38 +723,12 @@ void QToolButtonPrivate::_q_buttonReleased()
popupTimer.stop();
}
-void QToolButtonPrivate::popupTimerDone()
+static QPoint positionMenu(const QToolButton *q, bool horizontal,
+ const QSize &sh)
{
- Q_Q(QToolButton);
- popupTimer.stop();
- if (!menuButtonDown && !down)
- return;
-
- menuButtonDown = true;
- QPointer<QMenu> actualMenu;
- bool mustDeleteActualMenu = false;
- if(menuAction) {
- actualMenu = menuAction->menu();
- } else if (defaultAction && defaultAction->menu()) {
- actualMenu = defaultAction->menu();
- } else {
- actualMenu = new QMenu(q);
- mustDeleteActualMenu = true;
- for(int i = 0; i < actions.size(); i++)
- actualMenu->addAction(actions.at(i));
- }
- repeat = q->autoRepeat();
- q->setAutoRepeat(false);
- bool horizontal = true;
-#if QT_CONFIG(toolbar)
- QToolBar *tb = qobject_cast<QToolBar*>(parent);
- if (tb && tb->orientation() == Qt::Vertical)
- horizontal = false;
-#endif
QPoint p;
const QRect rect = q->rect(); // Find screen via point in case of QGraphicsProxyWidget.
QRect screen = QDesktopWidgetPrivate::availableGeometry(q->mapToGlobal(rect.center()));
- QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
if (horizontal) {
if (q->isRightToLeft()) {
if (q->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.bottom()) {
@@ -788,6 +762,37 @@ void QToolButtonPrivate::popupTimerDone()
}
p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width()));
p.ry() += 1;
+ return p;
+}
+
+void QToolButtonPrivate::popupTimerDone()
+{
+ Q_Q(QToolButton);
+ popupTimer.stop();
+ if (!menuButtonDown && !down)
+ return;
+
+ menuButtonDown = true;
+ QPointer<QMenu> actualMenu;
+ bool mustDeleteActualMenu = false;
+ if (menuAction) {
+ actualMenu = menuAction->menu();
+ } else if (defaultAction && defaultAction->menu()) {
+ actualMenu = defaultAction->menu();
+ } else {
+ actualMenu = new QMenu(q);
+ mustDeleteActualMenu = true;
+ for (int i = 0; i < actions.size(); i++)
+ actualMenu->addAction(actions.at(i));
+ }
+ repeat = q->autoRepeat();
+ q->setAutoRepeat(false);
+ bool horizontal = true;
+#if QT_CONFIG(toolbar)
+ QToolBar *tb = qobject_cast<QToolBar*>(parent);
+ if (tb && tb->orientation() == Qt::Vertical)
+ horizontal = false;
+#endif
QPointer<QToolButton> that = q;
actualMenu->setNoReplayFor(q);
if (!mustDeleteActualMenu) //only if action are not in this widget
@@ -796,7 +801,11 @@ void QToolButtonPrivate::popupTimerDone()
actualMenu->d_func()->causedPopup.widget = q;
actualMenu->d_func()->causedPopup.action = defaultAction;
actionsCopy = q->actions(); //(the list of action may be modified in slots)
- actualMenu->exec(p);
+
+ // QTBUG-78966, Delay positioning until after aboutToShow().
+ auto positionFunction = [q, horizontal](const QSize &sizeHint) {
+ return positionMenu(q, horizontal, sizeHint); };
+ actualMenu->d_func()->exec({}, nullptr, positionFunction);
if (!that)
return;
diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp
index 486d65d92c..cec6ba1dea 100644
--- a/src/widgets/widgets/qwidgetanimator.cpp
+++ b/src/widgets/widgets/qwidgetanimator.cpp
@@ -99,7 +99,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo
#if QT_CONFIG(animation)
//If the QStyle has animations, animate
- if (const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, widget)) {
+ if (const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, widget)) {
AnimationMap::const_iterator it = m_animation_map.constFind(widget);
if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry)
return;
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 9cdae4f28f..9dd61c2c6a 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -964,7 +964,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
if (maskFields.isEmpty() || delimiter == 0) {
if (m_maskData) {
delete [] m_maskData;
- m_maskData = 0;
+ m_maskData = nullptr;
m_maxLength = 32767;
internalSetText(QString(), -1, false);
}
@@ -1090,7 +1090,7 @@ bool QWidgetLineControl::isValidInput(QChar key, QChar mask) const
return true;
break;
case 'X':
- if (key.isPrint())
+ if (key.isPrint() && key != m_blank)
return true;
break;
case 'x':
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 83e2315c36..edd4885450 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -125,7 +125,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor)
}
QWidgetTextControlPrivate::QWidgetTextControlPrivate()
- : doc(0), cursorOn(false), cursorVisible(false), cursorIsFocusIndicator(false),
+ : doc(nullptr), cursorOn(false), cursorVisible(false), cursorIsFocusIndicator(false),
#ifndef Q_OS_ANDROID
interactionFlags(Qt::TextEditorInteraction),
#else
@@ -683,7 +683,7 @@ void QWidgetTextControlPrivate::_q_contentsChanged(int from, int charsRemoved, i
// always report the right number of removed chars, but in lack of the real string use spaces
QString oldText = QString(charsRemoved, QLatin1Char(' '));
- QAccessibleEvent *ev = 0;
+ QAccessibleEvent *ev = nullptr;
if (charsRemoved == 0) {
ev = new QAccessibleTextInsertEvent(q->parent(), from, newText);
} else if (charsAdded == 0) {
@@ -906,12 +906,12 @@ void QWidgetTextControl::setDocument(QTextDocument *document)
d->doc->disconnect(this);
d->doc->documentLayout()->disconnect(this);
- d->doc->documentLayout()->setPaintDevice(0);
+ d->doc->documentLayout()->setPaintDevice(nullptr);
if (d->doc->parent() == this)
delete d->doc;
- d->doc = 0;
+ d->doc = nullptr;
d->setContent(Qt::RichText, QString(), document);
}
@@ -992,12 +992,12 @@ void QWidgetTextControl::selectAll()
void QWidgetTextControl::processEvent(QEvent *e, const QPointF &coordinateOffset, QWidget *contextWidget)
{
- QMatrix m;
- m.translate(coordinateOffset.x(), coordinateOffset.y());
- processEvent(e, m, contextWidget);
+ QTransform t;
+ t.translate(coordinateOffset.x(), coordinateOffset.y());
+ processEvent(e, t, contextWidget);
}
-void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget)
+void QWidgetTextControl::processEvent(QEvent *e, const QTransform &transform, QWidget *contextWidget)
{
Q_D(QWidgetTextControl);
if (d->interactionFlags == Qt::NoTextInteraction) {
@@ -1038,22 +1038,22 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget
break;
case QEvent::MouseButtonPress: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ d->mousePressEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(),
ev->buttons(), ev->globalPos());
break; }
case QEvent::MouseMove: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ d->mouseMoveEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(),
ev->buttons(), ev->globalPos());
break; }
case QEvent::MouseButtonRelease: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ d->mouseReleaseEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(),
ev->buttons(), ev->globalPos());
break; }
case QEvent::MouseButtonDblClick: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ d->mouseDoubleClickEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(),
ev->buttons(), ev->globalPos());
break; }
case QEvent::InputMethod:
@@ -1062,7 +1062,7 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget
#ifndef QT_NO_CONTEXTMENU
case QEvent::ContextMenu: {
QContextMenuEvent *ev = static_cast<QContextMenuEvent *>(e);
- d->contextMenuEvent(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
+ d->contextMenuEvent(ev->globalPos(), transform.map(ev->pos()), contextWidget);
break; }
#endif // QT_NO_CONTEXTMENU
case QEvent::FocusIn:
@@ -1077,7 +1077,7 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget
#ifndef QT_NO_TOOLTIP
case QEvent::ToolTip: {
QHelpEvent *ev = static_cast<QHelpEvent *>(e);
- d->showToolTip(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
+ d->showToolTip(ev->globalPos(), transform.map(ev->pos()), contextWidget);
break;
}
#endif // QT_NO_TOOLTIP
@@ -1094,13 +1094,13 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget
break;
case QEvent::DragMove: {
QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e);
- if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
+ if (d->dragMoveEvent(e, ev->mimeData(), transform.map(ev->pos())))
ev->acceptProposedAction();
break;
}
case QEvent::Drop: {
QDropEvent *ev = static_cast<QDropEvent *>(e);
- if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
+ if (d->dropEvent(ev->mimeData(), transform.map(ev->pos()), ev->dropAction(), ev->source()))
ev->acceptProposedAction();
break;
}
@@ -1109,32 +1109,32 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget
#if QT_CONFIG(graphicsview)
case QEvent::GraphicsSceneMousePress: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ d->mousePressEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(),
ev->screenPos());
break; }
case QEvent::GraphicsSceneMouseMove: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ d->mouseMoveEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(),
ev->screenPos());
break; }
case QEvent::GraphicsSceneMouseRelease: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ d->mouseReleaseEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(),
ev->screenPos());
break; }
case QEvent::GraphicsSceneMouseDoubleClick: {
QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ d->mouseDoubleClickEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(),
ev->screenPos());
break; }
case QEvent::GraphicsSceneContextMenu: {
QGraphicsSceneContextMenuEvent *ev = static_cast<QGraphicsSceneContextMenuEvent *>(e);
- d->contextMenuEvent(ev->screenPos(), matrix.map(ev->pos()), contextWidget);
+ d->contextMenuEvent(ev->screenPos(), transform.map(ev->pos()), contextWidget);
break; }
case QEvent::GraphicsSceneHoverMove: {
QGraphicsSceneHoverEvent *ev = static_cast<QGraphicsSceneHoverEvent *>(e);
- d->mouseMoveEvent(ev, Qt::NoButton, matrix.map(ev->pos()), ev->modifiers(),Qt::NoButton,
+ d->mouseMoveEvent(ev, Qt::NoButton, transform.map(ev->pos()), ev->modifiers(),Qt::NoButton,
ev->screenPos());
break; }
@@ -1148,12 +1148,12 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget
break;
case QEvent::GraphicsSceneDragMove: {
QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
- if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
+ if (d->dragMoveEvent(e, ev->mimeData(), transform.map(ev->pos())))
ev->acceptProposedAction();
break; }
case QEvent::GraphicsSceneDrop: {
QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
- if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
+ if (d->dropEvent(ev->mimeData(), transform.map(ev->pos()), ev->dropAction(), ev->source()))
ev->accept();
break; }
#endif // QT_CONFIG(graphicsview)
@@ -2308,7 +2308,7 @@ QMenu *QWidgetTextControl::createStandardContextMenu(const QPointF &pos, QWidget
d->linkToCopy = anchorAt(pos);
if (d->linkToCopy.isEmpty() && !showTextSelectionActions)
- return 0;
+ return nullptr;
QMenu *menu = new QMenu(parent);
QAction *a;
@@ -2662,7 +2662,7 @@ void QWidgetTextControl::print(QPagedPaintDevice *printer) const
Q_D(const QWidgetTextControl);
if (!printer)
return;
- QTextDocument *tempDoc = 0;
+ QTextDocument *tempDoc = nullptr;
const QTextDocument *doc = d->doc;
if (QPagedPaintDevicePrivate::get(printer)->printSelectionOnly) {
if (!d->cursor.hasSelection())
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index 59bf5466e6..c445ecaf80 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -116,12 +116,12 @@ public:
void setCurrentCharFormat(const QTextCharFormat &format);
QTextCharFormat currentCharFormat() const;
- bool find(const QString &exp, QTextDocument::FindFlags options = nullptr);
+ bool find(const QString &exp, QTextDocument::FindFlags options = { });
#ifndef QT_NO_REGEXP
- bool find(const QRegExp &exp, QTextDocument::FindFlags options = nullptr);
+ bool find(const QRegExp &exp, QTextDocument::FindFlags options = { });
#endif
#if QT_CONFIG(regularexpression)
- bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = nullptr);
+ bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = { });
#endif
QString toPlainText() const;
@@ -252,7 +252,7 @@ public:
QPalette palette() const;
void setPalette(const QPalette &pal);
- virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = nullptr);
+ virtual void processEvent(QEvent *e, const QTransform &transform, QWidget *contextWidget = nullptr);
void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = nullptr);
// control methods