Move QStandardItem/QStandardItemModel to QtGui
The dependencies on QFont, QBrush, QIcon are all in QtGui, so there's little sense to still have these classes in QtWidgets. This also copies and pastes a version of QWidgetItemData as QStandardItemData inside qstandarditemmodel_p.h. Change-Id: Ibafc5a30748e7ce0b54753309ae6dc4a797fc20e Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
This commit is contained in:
parent
f4f0c8b99b
commit
dba22bc036
@ -28,6 +28,7 @@ include(util/util.pri)
|
||||
include(math3d/math3d.pri)
|
||||
include(opengl/opengl.pri)
|
||||
include(animation/animation.pri)
|
||||
include(itemmodels/itemmodels.pri)
|
||||
|
||||
QMAKE_LIBS += $$QMAKE_LIBS_GUI
|
||||
|
||||
|
6
src/gui/itemmodels/itemmodels.pri
Normal file
6
src/gui/itemmodels/itemmodels.pri
Normal file
@ -0,0 +1,6 @@
|
||||
HEADERS += \
|
||||
itemmodels/qstandarditemmodel.h \
|
||||
itemmodels/qstandarditemmodel_p.h \
|
||||
|
||||
SOURCES += \
|
||||
itemmodels/qstandarditemmodel.cpp \
|
@ -189,14 +189,14 @@ void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles)
|
||||
Q_Q(QStandardItem);
|
||||
|
||||
//let's build the vector of new values
|
||||
QVector<QWidgetItemData> newValues;
|
||||
QVector<QStandardItemData> newValues;
|
||||
QMap<int, QVariant>::const_iterator it;
|
||||
for (it = roles.begin(); it != roles.end(); ++it) {
|
||||
QVariant value = it.value();
|
||||
if (value.isValid()) {
|
||||
int role = it.key();
|
||||
role = (role == Qt::EditRole) ? Qt::DisplayRole : role;
|
||||
QWidgetItemData wid(role,it.value());
|
||||
QStandardItemData wid(role,it.value());
|
||||
newValues.append(wid);
|
||||
}
|
||||
}
|
||||
@ -214,7 +214,7 @@ void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles)
|
||||
const QMap<int, QVariant> QStandardItemPrivate::itemData() const
|
||||
{
|
||||
QMap<int, QVariant> result;
|
||||
QVector<QWidgetItemData>::const_iterator it;
|
||||
QVector<QStandardItemData>::const_iterator it;
|
||||
for (it = values.begin(); it != values.end(); ++it)
|
||||
result.insert((*it).role, (*it).value);
|
||||
return result;
|
||||
@ -614,7 +614,7 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent,
|
||||
QStandardItemModel class.
|
||||
\since 4.2
|
||||
\ingroup model-view
|
||||
\inmodule QtWidgets
|
||||
\inmodule QtGui
|
||||
|
||||
Items usually contain text, icons, or checkboxes.
|
||||
|
||||
@ -812,7 +812,7 @@ void QStandardItem::setData(const QVariant &value, int role)
|
||||
{
|
||||
Q_D(QStandardItem);
|
||||
role = (role == Qt::EditRole) ? Qt::DisplayRole : role;
|
||||
QVector<QWidgetItemData>::iterator it;
|
||||
QVector<QStandardItemData>::iterator it;
|
||||
for (it = d->values.begin(); it != d->values.end(); ++it) {
|
||||
if ((*it).role == role) {
|
||||
if (value.isValid()) {
|
||||
@ -827,7 +827,7 @@ void QStandardItem::setData(const QVariant &value, int role)
|
||||
return;
|
||||
}
|
||||
}
|
||||
d->values.append(QWidgetItemData(role, value));
|
||||
d->values.append(QStandardItemData(role, value));
|
||||
if (d->model)
|
||||
d->model->d_func()->itemChanged(this);
|
||||
}
|
||||
@ -843,7 +843,7 @@ QVariant QStandardItem::data(int role) const
|
||||
{
|
||||
Q_D(const QStandardItem);
|
||||
role = (role == Qt::EditRole) ? Qt::DisplayRole : role;
|
||||
QVector<QWidgetItemData>::const_iterator it;
|
||||
QVector<QStandardItemData>::const_iterator it;
|
||||
for (it = d->values.begin(); it != d->values.end(); ++it) {
|
||||
if ((*it).role == role)
|
||||
return (*it).value;
|
||||
@ -1954,7 +1954,7 @@ QDataStream &operator<<(QDataStream &out, const QStandardItem &item)
|
||||
\class QStandardItemModel
|
||||
\brief The QStandardItemModel class provides a generic model for storing custom data.
|
||||
\ingroup model-view
|
||||
\inmodule QtWidgets
|
||||
\inmodule QtGui
|
||||
|
||||
QStandardItemModel can be used as a repository for standard Qt
|
||||
data types. It is one of the \l {Model/View Classes} and is part
|
@ -62,7 +62,7 @@ template <class T> class QList;
|
||||
class QStandardItemModel;
|
||||
|
||||
class QStandardItemPrivate;
|
||||
class Q_WIDGETS_EXPORT QStandardItem
|
||||
class Q_GUI_EXPORT QStandardItem
|
||||
{
|
||||
public:
|
||||
QStandardItem();
|
||||
@ -314,7 +314,7 @@ inline void QStandardItem::appendRow(QStandardItem *aitem)
|
||||
|
||||
class QStandardItemModelPrivate;
|
||||
|
||||
class Q_WIDGETS_EXPORT QStandardItemModel : public QAbstractItemModel
|
||||
class Q_GUI_EXPORT QStandardItemModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
|
||||
@ -444,8 +444,8 @@ inline bool QStandardItemModel::insertColumn(int acolumn, const QModelIndex &apa
|
||||
{ return QAbstractItemModel::insertColumn(acolumn, aparent); }
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &in, QStandardItem &item);
|
||||
Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &out, const QStandardItem &item);
|
||||
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QStandardItem &item);
|
||||
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QStandardItem &item);
|
||||
#endif
|
||||
|
||||
#endif // QT_NO_STANDARDITEMMODEL
|
@ -57,7 +57,6 @@
|
||||
|
||||
#ifndef QT_NO_STANDARDITEMMODEL
|
||||
|
||||
#include <private/qwidgetitemdata_p.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtCore/qstack.h>
|
||||
@ -66,6 +65,34 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QStandardItemData
|
||||
{
|
||||
public:
|
||||
inline QStandardItemData() : role(-1) {}
|
||||
inline QStandardItemData(int r, QVariant v) : role(r), value(v) {}
|
||||
int role;
|
||||
QVariant value;
|
||||
inline bool operator==(const QStandardItemData &other) const { return role == other.role && value == other.value; }
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
|
||||
inline QDataStream &operator>>(QDataStream &in, QStandardItemData &data)
|
||||
{
|
||||
in >> data.role;
|
||||
in >> data.value;
|
||||
return in;
|
||||
}
|
||||
|
||||
inline QDataStream &operator<<(QDataStream &out, const QStandardItemData &data)
|
||||
{
|
||||
out << data.role;
|
||||
out << data.value;
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // QT_NO_DATASTREAM
|
||||
|
||||
class QStandardItemPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QStandardItem)
|
||||
@ -126,7 +153,7 @@ public:
|
||||
|
||||
QStandardItemModel *model;
|
||||
QStandardItem *parent;
|
||||
QVector<QWidgetItemData> values;
|
||||
QVector<QStandardItemData> values;
|
||||
QVector<QStandardItem*> children;
|
||||
int rows;
|
||||
int columns;
|
@ -25,8 +25,6 @@ HEADERS += \
|
||||
itemviews/qproxymodel_p.h \
|
||||
itemviews/qitemeditorfactory.h \
|
||||
itemviews/qitemeditorfactory_p.h \
|
||||
itemviews/qstandarditemmodel.h \
|
||||
itemviews/qstandarditemmodel_p.h \
|
||||
itemviews/qtreewidgetitemiterator.h \
|
||||
itemviews/qdatawidgetmapper.h \
|
||||
itemviews/qfileiconprovider.h \
|
||||
@ -50,7 +48,6 @@ SOURCES += \
|
||||
itemviews/qtreewidget.cpp \
|
||||
itemviews/qproxymodel.cpp \
|
||||
itemviews/qitemeditorfactory.cpp \
|
||||
itemviews/qstandarditemmodel.cpp \
|
||||
itemviews/qtreewidgetitemiterator.cpp \
|
||||
itemviews/qdatawidgetmapper.cpp \
|
||||
itemviews/qfileiconprovider.cpp \
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "QtWidgets/qabstractslider.h"
|
||||
#include "QtWidgets/qapplication.h"
|
||||
#include "QtWidgets/qitemdelegate.h"
|
||||
#include "QtWidgets/qstandarditemmodel.h"
|
||||
#include "QtGui/qstandarditemmodel.h"
|
||||
#include "QtWidgets/qlineedit.h"
|
||||
#include "QtWidgets/qlistview.h"
|
||||
#include "QtGui/qpainter.h"
|
||||
|
@ -93,7 +93,11 @@
|
||||
"qplatformmenu_qpa.h" => "qpa/qplatformmenu.h",
|
||||
"QPlatformMenu" => "qpa/qplatformmenu.h",
|
||||
"QPlatformMenuAction" => "qpa/qplatformmenu.h",
|
||||
"QPlatformMenuBar" => "qpa/qplatformmenu.h"
|
||||
"QPlatformMenuBar" => "qpa/qplatformmenu.h",
|
||||
"QStandardItem" => "QtGui/QStandardItem",
|
||||
"QStandardItemModel" => "QtGui/QStandardItemModel",
|
||||
"qstandarditem.h" => "QtGui/qstandarditem.h",
|
||||
"qstandarditemmodel.h" => "QtGui/qstandarditemmodel.h"
|
||||
},
|
||||
"QtPrintSupport" => {
|
||||
"qplatformprintersupport_qpa.h" => "qpa/qplatformprintersupport.h",
|
||||
|
@ -4,6 +4,6 @@ TARGET = tst_qidentityproxymodel
|
||||
|
||||
mtdir = ../../../other/modeltest
|
||||
INCLUDEPATH += $$PWD/$${mtdir}
|
||||
QT += widgets testlib
|
||||
QT += testlib
|
||||
SOURCES += tst_qidentityproxymodel.cpp $${mtdir}/dynamictreemodel.cpp $${mtdir}/modeltest.cpp
|
||||
HEADERS += $${mtdir}/dynamictreemodel.h $${mtdir}/modeltest.h
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtWidgets/QStandardItemModel>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
|
||||
#include "dynamictreemodel.h"
|
||||
#include "qidentityproxymodel.h"
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "modeltest.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtWidgets/QStandardItem>
|
||||
#include <QtGui/QStandardItem>
|
||||
#include <QtWidgets/QTreeView>
|
||||
#include <QtWidgets/QTableView>
|
||||
|
||||
|
@ -7,3 +7,4 @@ SUBDIRS=\
|
||||
qopengl \
|
||||
text \
|
||||
util \
|
||||
itemmodels \
|
||||
|
4
tests/auto/gui/itemmodels/itemmodels.pro
Normal file
4
tests/auto/gui/itemmodels/itemmodels.pro
Normal file
@ -0,0 +1,4 @@
|
||||
TEMPLATE=subdirs
|
||||
SUBDIRS= \
|
||||
qstandarditem \
|
||||
qstandarditemmodel \
|
@ -1,7 +1,7 @@
|
||||
CONFIG += testcase
|
||||
CONFIG += parallel_test
|
||||
TARGET = tst_qstandarditem
|
||||
QT += widgets testlib
|
||||
QT += gui testlib
|
||||
SOURCES += tst_qstandarditem.cpp
|
||||
|
||||
|
@ -11,8 +11,6 @@ SUBDIRS=\
|
||||
qitemview \
|
||||
qlistview \
|
||||
qlistwidget \
|
||||
qstandarditem \
|
||||
qstandarditemmodel \
|
||||
qtableview \
|
||||
qtablewidget \
|
||||
qtreeview \
|
||||
|
Loading…
Reference in New Issue
Block a user