summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-10-04 16:34:16 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-10-05 21:08:45 +0200
commit4e8b54eb811f8c6064fd2e937711efe68543087c (patch)
tree28aca92c964de790d7953b22590cd3870d3d67b5
parent9ed25b413ff2e5055ec03fd6e1f8ba5dfcfc499a (diff)
Preparations to deprecate QItemDelegate
QItemDelegate was superseded since Qt4 by QStyledItemDelegate but it took until Qt6.7 to remove the last occurrences in qtbase. - remove unused includes / replace with qabstractitemdelegate.h - replace references in the documentation with QStyledItemDelegate - adjust the examples and tests to use QStyledItemDelegate Pick-to: 6.5 6.6 Change-Id: I246755004ce2d01192a726ca0972106c237df0cc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--examples/network/torrent/mainwindow.cpp6
-rw-r--r--examples/sql/doc/src/sqlwidgetmapper.qdoc8
-rw-r--r--examples/widgets/doc/src/coloreditorfactory.qdoc12
-rw-r--r--examples/widgets/doc/src/combowidgetmapper.qdoc8
-rw-r--r--src/sql/doc/src/sql-programming.qdoc4
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.cpp3
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp1
-rw-r--r--src/widgets/itemviews/qlistwidget_p.h1
-rw-r--r--src/widgets/itemviews/qtableview.cpp2
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp1
-rw-r--r--src/widgets/itemviews/qtreeview.cpp2
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp1
-rw-r--r--src/widgets/widgets/qcombobox.cpp2
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp4
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp1
-rw-r--r--tests/manual/widgets/itemviews/delegate/example.cpp6
-rw-r--r--util/locale_database/testlocales/localewidget.cpp4
18 files changed, 31 insertions, 37 deletions
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 4c898743ba..2b5d0a8757 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -26,17 +26,17 @@ protected:
};
// TorrentViewDelegate is used to draw the progress bars.
-class TorrentViewDelegate : public QItemDelegate
+class TorrentViewDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
- inline TorrentViewDelegate(MainWindow *mainWindow) : QItemDelegate(mainWindow) {}
+ inline TorrentViewDelegate(MainWindow *mainWindow) : QStyledItemDelegate(mainWindow) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index ) const override
{
if (index.column() != 2) {
- QItemDelegate::paint(painter, option, index);
+ QStyledItemDelegate::paint(painter, option, index);
return;
}
diff --git a/examples/sql/doc/src/sqlwidgetmapper.qdoc b/examples/sql/doc/src/sqlwidgetmapper.qdoc
index 7740e50b2e..0764e601c3 100644
--- a/examples/sql/doc/src/sqlwidgetmapper.qdoc
+++ b/examples/sql/doc/src/sqlwidgetmapper.qdoc
@@ -115,7 +115,7 @@
\section1 Delegate Class Definition and Implementation
The delegate we use to mediate interaction between the widget mapper and
- the input widgets is a small QItemDelegate subclass:
+ the input widgets is a small QStyledItemDelegate subclass:
\snippet sqlwidgetmapper/delegate.h Delegate class definition
@@ -126,7 +126,7 @@
Since we only provide an empty implementation of the constructor, we
concentrate on the other two functions.
- The \l{QItemDelegate::}{setEditorData()} implementation takes the data
+ The \l{QStyledItemDelegate::}{setEditorData()} implementation takes the data
referred to by the model index supplied and processes it according to
the presence of a \c currentIndex property in the editor widget:
@@ -138,10 +138,10 @@
values needed for the \c currentIndex property.
As a result, instead of showing "0", "1" or "2" in the combo box, one of
- its predefined set of items is shown. We call QItemDelegate::setEditorData()
+ its predefined set of items is shown. We call QStyledItemDelegate::setEditorData()
for widgets without the \c currentIndex property.
- The \l{QItemDelegate::}{setModelData()} implementation performs the reverse
+ The \l{QStyledItemDelegate::}{setModelData()} implementation performs the reverse
process, taking the value stored in the widget's \c currentIndex property
and storing it back in the model:
diff --git a/examples/widgets/doc/src/coloreditorfactory.qdoc b/examples/widgets/doc/src/coloreditorfactory.qdoc
index bf4a13c9e7..f43a7eb95c 100644
--- a/examples/widgets/doc/src/coloreditorfactory.qdoc
+++ b/examples/widgets/doc/src/coloreditorfactory.qdoc
@@ -7,13 +7,13 @@
\examplecategory {User Interface Components}
\ingroup examples-itemviews
\brief This example shows how to create an editor that can be used by
- a QItemDelegate.
+ a QStyledItemDelegate.
\image coloreditorfactoryimage.png
When editing data in a QListView, QTableView, or QTreeView,
editors are created and displayed by a \l{Delegate
- Classes}{delegate}. QItemDelegate, which is the default delegate
+ Classes}{delegate}. QStyledItemDelegate, which is the default delegate
used by Qt's \l{View Classes}{item views}, uses a
QItemEditorFactory to create editors for it. A unique instance
provided by QItemEditorFactory is by default installed on all
@@ -27,7 +27,7 @@
In this example, we will create an editor (implemented in the \c
ColorListEditor class) that can edit the QColor data type and be
- used by \l{QItemDelegate}s. We do this by creating a new
+ used by \l{QStyledItemDelegate}s. We do this by creating a new
QItemEditorCreatorBase that produces \c ColorListEditors and
register it with a new factory, which we set as the default editor
item factory (the unique factory instance). To test our editor, we
@@ -67,7 +67,7 @@
\snippet itemviews/coloreditorfactory/colorlisteditor.h 0
- QItemDelegate manages the interaction between the editor and
+ QStyledItemDelegate manages the interaction between the editor and
the model, i.e., it retrieves data to edit from the model and
store data from the editor in the model. The data that is edited
by an editor is stored in the editor's user data property, and the
@@ -106,7 +106,7 @@
usually sufficient to provide custom editors. Further
customization is achieved by subclassing QItemEditorFactory
and QItemEditorCreatorBase. It is also possible to subclass
- QItemDelegate if you don't wish to use a factory at all.
+ QStyledItemDelegate if you don't wish to use a factory at all.
Possible suggestions are:
@@ -128,5 +128,5 @@
In this example, we use a standard QVariant data type. You can
also use custom types. In the \l{Star Delegate Example}, we
show how to store a custom data type in a QVariant and paint
- and edit it in a class that inherits QItemDelegate.
+ and edit it in a class that inherits QStyledItemDelegate.
*/
diff --git a/examples/widgets/doc/src/combowidgetmapper.qdoc b/examples/widgets/doc/src/combowidgetmapper.qdoc
index 8a3e285dfe..aae546005c 100644
--- a/examples/widgets/doc/src/combowidgetmapper.qdoc
+++ b/examples/widgets/doc/src/combowidgetmapper.qdoc
@@ -88,7 +88,7 @@
\section1 Delegate Class Definition and Implementation
The delegate we use to mediate interaction between the widget mapper and
- the input widgets is a small QItemDelegate subclass:
+ the input widgets is a small QStyledItemDelegate subclass:
\snippet itemviews/combowidgetmapper/delegate.h Delegate class definition
@@ -99,7 +99,7 @@
Since we only provide an empty implementation of the constructor, we
concentrate on the other two functions.
- The \l{QItemDelegate::}{setEditorData()} implementation takes the data
+ The \l{QStyledItemDelegate::}{setEditorData()} implementation takes the data
referred to by the model index supplied and processes it according to
the presence of a \c currentIndex property in the editor widget:
@@ -111,10 +111,10 @@
values needed for the \c currentIndex property.
As a result, instead of showing "0", "1" or "2" in the combo box, one of
- its predefined set of items is shown. We call QItemDelegate::setEditorData()
+ its predefined set of items is shown. We call QStyledItemDelegate::setEditorData()
for widgets without the \c currentIndex property.
- The \l{QItemDelegate::}{setModelData()} implementation performs the reverse
+ The \l{QStyledItemDelegate::}{setModelData()} implementation performs the reverse
process, taking the value stored in the widget's \c currentIndex property
and storing it back in the model:
diff --git a/src/sql/doc/src/sql-programming.qdoc b/src/sql/doc/src/sql-programming.qdoc
index 3dfd005516..a7f87fe73f 100644
--- a/src/sql/doc/src/sql-programming.qdoc
+++ b/src/sql/doc/src/sql-programming.qdoc
@@ -496,11 +496,11 @@
submitted.
The items in the view are rendered using a delegate. The default
- delegate, QItemDelegate, handles the most common data types (\c
+ delegate, QStyledItemDelegate, handles the most common data types (\c
int, QString, QImage, etc.). The delegate is also responsible for
providing editor widgets (e.g., a combobox) when the user starts
editing an item in the view. You can create your own delegates by
- subclassing QAbstractItemDelegate or QItemDelegate. See
+ subclassing QAbstractItemDelegate or QStyledItemDelegate. See
\l{Model/View Programming} for more information.
QSqlTableModel is optimized to operate on a single table at a
diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp
index 06d59b34a0..0b43707b02 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.cpp
+++ b/src/widgets/itemviews/qdatawidgetmapper.cpp
@@ -4,7 +4,6 @@
#include "qdatawidgetmapper.h"
#include "qabstractitemmodel.h"
-#include "qitemdelegate.h"
#include "qmetaobject.h"
#include "qwidget.h"
#include "qstyleditemdelegate.h"
@@ -234,7 +233,7 @@ void QDataWidgetMapperPrivate::modelDestroyed()
instead of the default user property.
It is possible to set an item delegate to support custom widgets. By default,
- a QItemDelegate is used to synchronize the model with the widgets.
+ a QStyledItemDelegate is used to synchronize the model with the widgets.
Let us assume that we have an item model named \c{model} with the following contents:
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 7b164da040..a91902813a 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -3,7 +3,6 @@
#include "qlistwidget.h"
-#include <qitemdelegate.h>
#include <private/qlistview_p.h>
#include <private/qwidgetitemdata_p.h>
#include <private/qlistwidget_p.h>
diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h
index b0f315299e..1007542ddc 100644
--- a/src/widgets/itemviews/qlistwidget_p.h
+++ b/src/widgets/itemviews/qlistwidget_p.h
@@ -18,7 +18,6 @@
#include <QtCore/qabstractitemmodel.h>
#include <QtWidgets/qabstractitemview.h>
#include <QtWidgets/qlistwidget.h>
-#include <qitemdelegate.h>
#include <private/qlistview_p.h>
#include <private/qwidgetitemdata_p.h>
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index eeb0b5ac5a..0c7750750c 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -6,7 +6,7 @@
#include "qtableview.h"
#include <qheaderview.h>
-#include <qitemdelegate.h>
+#include <qabstractitemdelegate.h>
#include <qapplication.h>
#include <qpainter.h>
#include <qstyle.h>
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 91e89fe9d3..6dd812f6fb 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -3,7 +3,6 @@
#include "qtablewidget.h"
-#include <qitemdelegate.h>
#include <qpainter.h>
#include <private/qtablewidget_p.h>
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 38159277d5..c6ed979c13 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -3,7 +3,7 @@
#include "qtreeview.h"
#include <qheaderview.h>
-#include <qitemdelegate.h>
+#include <qabstractitemdelegate.h>
#include <qapplication.h>
#include <qscrollbar.h>
#include <qpainter.h>
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 611bd0c9ce..51e31deffb 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -5,7 +5,6 @@
#include <qheaderview.h>
#include <qpainter.h>
-#include <qitemdelegate.h>
#include <qstack.h>
#include <qdebug.h>
#include <private/qtreewidget_p.h>
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index e26564da08..a9086ec4dc 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -12,7 +12,7 @@
#if QT_CONFIG(tableview)
#include <qtableview.h>
#endif
-#include <qitemdelegate.h>
+#include <qabstractitemdelegate.h>
#include <qmap.h>
#if QT_CONFIG(menu)
#include <qmenu.h>
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index 118e7945df..0083a5ecea 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -3,9 +3,9 @@
#include "qfontcombobox.h"
+#include <qabstractitemdelegate.h>
#include <qaccessible.h>
#include <qstringlistmodel.h>
-#include <qitemdelegate.h>
#include <qlistview.h>
#include <qpainter.h>
#include <qevent.h>
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 23390dc04c..945cf33434 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -13,7 +13,7 @@
#include <qsharedpointer.h>
#include <qfiledialog.h>
#include <qabstractitemdelegate.h>
-#include <qitemdelegate.h>
+#include <qstyleditemdelegate.h>
#include <qlistview.h>
#include <qcombobox.h>
#include <qpushbutton.h>
@@ -806,7 +806,7 @@ void tst_QFiledialog::itemDelegate()
{
QFileDialog fd;
QVERIFY(fd.itemDelegate() != 0);
- QItemDelegate *id = new QItemDelegate(&fd);
+ QStyledItemDelegate *id = new QStyledItemDelegate(&fd);
fd.setItemDelegate(id);
QCOMPARE(fd.itemDelegate(), (QAbstractItemDelegate *)id);
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index a8d3c5fe1e..e0df692ab8 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -11,7 +11,6 @@
#include <qdebug.h>
#include <qfiledialog.h>
#include <qabstractitemdelegate.h>
-#include <qitemdelegate.h>
#include <qlistview.h>
#include <qcombobox.h>
#include <qpushbutton.h>
diff --git a/tests/manual/widgets/itemviews/delegate/example.cpp b/tests/manual/widgets/itemviews/delegate/example.cpp
index 3421b7790b..9df2d87ee8 100644
--- a/tests/manual/widgets/itemviews/delegate/example.cpp
+++ b/tests/manual/widgets/itemviews/delegate/example.cpp
@@ -5,7 +5,7 @@
#include <QApplication>
#include <QTableView>
#include <QStandardItemModel>
-#include <QItemDelegate>
+#include <QStyledItemDelegate>
#include <QDebug>
#include <QComboBox>
@@ -16,10 +16,10 @@ public:
~ExampleEditor() { QApplication::instance()->quit(); }
};
-class ExampleDelegate : public QItemDelegate
+class ExampleDelegate : public QStyledItemDelegate
{
public:
- ExampleDelegate() : QItemDelegate()
+ ExampleDelegate() : QStyledItemDelegate()
{
m_editor = new ExampleEditor(0);
m_combobox = new QComboBox(0);
diff --git a/util/locale_database/testlocales/localewidget.cpp b/util/locale_database/testlocales/localewidget.cpp
index 50b9b81594..c35c3dc1d8 100644
--- a/util/locale_database/testlocales/localewidget.cpp
+++ b/util/locale_database/testlocales/localewidget.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTableView>
#include <QVBoxLayout>
-#include <QItemDelegate>
+#include <QStyledItemDelegate>
#include <QItemEditorFactory>
#include <QDoubleSpinBox>
@@ -38,7 +38,7 @@ LocaleWidget::LocaleWidget(QWidget *parent)
m_model = new LocaleModel(this);
m_view = new QTableView(this);
- QItemDelegate *delegate = qobject_cast<QItemDelegate*>(m_view->itemDelegate());
+ QStyledItemDelegate *delegate = qobject_cast<QStyledItemDelegate*>(m_view->itemDelegate());
Q_ASSERT(delegate != 0);
static EditorFactory editor_factory;
delegate->setItemEditorFactory(&editor_factory);