summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sql/models/qsqlrelationaldelegate.h55
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.cpp4
-rw-r--r--src/widgets/widgets/qcombobox_p.h19
3 files changed, 38 insertions, 40 deletions
diff --git a/src/sql/models/qsqlrelationaldelegate.h b/src/sql/models/qsqlrelationaldelegate.h
index 189fc876fd..130c82868e 100644
--- a/src/sql/models/qsqlrelationaldelegate.h
+++ b/src/sql/models/qsqlrelationaldelegate.h
@@ -46,7 +46,7 @@ QT_REQUIRE_CONFIG(sqlmodel);
#ifdef QT_WIDGETS_LIB
-#include <QtWidgets/qitemdelegate.h>
+#include <QtWidgets/qstyleditemdelegate.h>
#if QT_CONFIG(listview)
#include <QtWidgets/qlistview.h>
#endif
@@ -58,8 +58,7 @@ QT_REQUIRE_CONFIG(sqlmodel);
#include <QtCore/qmetaobject.h>
QT_BEGIN_NAMESPACE
-// ### Qt6: QStyledItemDelegate
-class QSqlRelationalDelegate: public QItemDelegate
+class QSqlRelationalDelegate : public QStyledItemDelegate
{
static int fieldIndex(const QSqlTableModel *const model,
const QSqlDriver *const driver,
@@ -73,31 +72,31 @@ class QSqlRelationalDelegate: public QItemDelegate
public:
-explicit QSqlRelationalDelegate(QObject *aParent = nullptr)
- : QItemDelegate(aParent)
-{}
+ explicit QSqlRelationalDelegate(QObject *aParent = nullptr)
+ : QStyledItemDelegate(aParent)
+ {}
-~QSqlRelationalDelegate()
-{}
+ ~QSqlRelationalDelegate()
+ {}
-QWidget *createEditor(QWidget *aParent,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const override
-{
- const QSqlRelationalTableModel *sqlModel = qobject_cast<const QSqlRelationalTableModel *>(index.model());
- QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : nullptr;
- if (!childModel)
- return QItemDelegate::createEditor(aParent, option, index);
- const QSqlDriver *const driver = childModel->database().driver();
-
- QComboBox *combo = new QComboBox(aParent);
- combo->setModel(childModel);
- combo->setModelColumn(fieldIndex(childModel, driver,
- sqlModel->relation(index.column()).displayColumn()));
- combo->installEventFilter(const_cast<QSqlRelationalDelegate *>(this));
-
- return combo;
-}
+ QWidget *createEditor(QWidget *aParent,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override
+ {
+ const QSqlRelationalTableModel *sqlModel = qobject_cast<const QSqlRelationalTableModel *>(index.model());
+ QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : nullptr;
+ if (!childModel)
+ return QStyledItemDelegate::createEditor(aParent, option, index);
+ const QSqlDriver *const driver = childModel->database().driver();
+
+ QComboBox *combo = new QComboBox(aParent);
+ combo->setModel(childModel);
+ combo->setModelColumn(fieldIndex(childModel, driver,
+ sqlModel->relation(index.column()).displayColumn()));
+ combo->installEventFilter(const_cast<QSqlRelationalDelegate *>(this));
+
+ return combo;
+ }
void setEditorData(QWidget *editor, const QModelIndex &index) const override
{
@@ -117,7 +116,7 @@ QWidget *createEditor(QWidget *aParent,
return;
}
}
- QItemDelegate::setEditorData(editor, index);
+ QStyledItemDelegate::setEditorData(editor, index);
}
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
@@ -129,7 +128,7 @@ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex
QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : nullptr;
QComboBox *combo = qobject_cast<QComboBox *>(editor);
if (!sqlModel || !childModel || !combo) {
- QItemDelegate::setModelData(editor, model, index);
+ QStyledItemDelegate::setModelData(editor, model, index);
return;
}
const QSqlDriver *const driver = childModel->database().driver();
diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp
index 403ea33c0b..0f6e36cc6a 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.cpp
+++ b/src/widgets/itemviews/qdatawidgetmapper.cpp
@@ -43,6 +43,7 @@
#include "qitemdelegate.h"
#include "qmetaobject.h"
#include "qwidget.h"
+#include "qstyleditemdelegate.h"
#include "private/qobject_p.h"
#include "private/qabstractitemmodel_p.h"
@@ -326,8 +327,7 @@ void QDataWidgetMapperPrivate::_q_modelDestroyed()
QDataWidgetMapper::QDataWidgetMapper(QObject *parent)
: QObject(*new QDataWidgetMapperPrivate, parent)
{
- // ### Qt6: QStyledItemDelegate
- setItemDelegate(new QItemDelegate(this));
+ setItemDelegate(new QStyledItemDelegate(this));
}
/*!
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index a7e7af64a1..16ded8f1a4 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -56,7 +56,7 @@
#include "QtWidgets/qabstractslider.h"
#include "QtWidgets/qapplication.h"
-#include "QtWidgets/qitemdelegate.h"
+#include "QtWidgets/qstyleditemdelegate.h"
#include "QtGui/qstandarditemmodel.h"
#include "QtWidgets/qlineedit.h"
#include "QtWidgets/qlistview.h"
@@ -293,14 +293,13 @@ private:
int pressedIndex;
};
-// ### Qt6: QStyledItemDelegate ?
-// Note that this class is intentionally not using QStyledItemDelegate
-// Vista does not use the new theme for combo boxes and there might
-// be other side effects from using the new class
-class Q_AUTOTEST_EXPORT QComboBoxDelegate : public QItemDelegate
-{ Q_OBJECT
+class Q_AUTOTEST_EXPORT QComboBoxDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
public:
- QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
+ QComboBoxDelegate(QObject *parent, QComboBox *cmb)
+ : QStyledItemDelegate(parent), mCombo(cmb)
+ {}
static bool isSeparator(const QModelIndex &index) {
return index.data(Qt::AccessibleDescriptionRole).toString() == QLatin1String("separator");
@@ -324,7 +323,7 @@ protected:
opt.rect = rect;
mCombo->style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, painter, mCombo);
} else {
- QItemDelegate::paint(painter, option, index);
+ QStyledItemDelegate::paint(painter, option, index);
}
}
@@ -334,7 +333,7 @@ protected:
int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, mCombo);
return QSize(pm, pm);
}
- return QItemDelegate::sizeHint(option, index);
+ return QStyledItemDelegate::sizeHint(option, index);
}
private:
QComboBox *mCombo;