From fe0a6e57a045b9db7ad812025ed65a6ba011c68d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 20 Aug 2012 12:30:45 +0200 Subject: Remove QProxyModel from qtbase. A copy is placed in uihelpers for anyone who might be using it. Change-Id: I175f7bc5dcbf25a910d28bfd8985579866392938 Reviewed-by: Lars Knoll --- dist/changes-5.0.0 | 4 + src/corelib/itemmodels/qabstractitemmodel.h | 1 - src/tools/uic/qclass_lib_map.h | 1 - src/widgets/doc/src/modelview.qdoc | 2 +- src/widgets/itemviews/itemviews.pri | 3 - src/widgets/itemviews/qproxymodel.cpp | 549 ---------------------------- src/widgets/itemviews/qproxymodel.h | 142 ------- src/widgets/itemviews/qproxymodel_p.h | 100 ----- 8 files changed, 5 insertions(+), 797 deletions(-) delete mode 100644 src/widgets/itemviews/qproxymodel.cpp delete mode 100644 src/widgets/itemviews/qproxymodel.h delete mode 100644 src/widgets/itemviews/qproxymodel_p.h diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 791e538922..852e6c5b42 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -483,6 +483,10 @@ QtWidgets * QAbstractItemView and derived classes only emit the clicked() signal on left click now, instead of on all mouse clicks. +* QProxyModel has been removed. It is deprecated since early Qt 4 versions and replaced + by QAbstractProxyModel and related classes. A copy of QProxyModel is available + in the UiHelpers library. + QtNetwork --------- * QHostAddress::isLoopback() API added. Returns true if the address is diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 26d4cb53d1..37d8ee6bab 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -58,7 +58,6 @@ class QPersistentModelIndex; class Q_CORE_EXPORT QModelIndex { friend class QAbstractItemModel; - friend class QProxyModel; public: inline QModelIndex() : r(-1), c(-1), p(0), m(0) {} // compiler-generated copy/move ctors/assignment operators are fine! diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index 99995f67b6..0f812d84a2 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -692,7 +692,6 @@ QT_CLASS_LIB(QItemSelection, QtWidgets, qitemselectionmodel.h) QT_CLASS_LIB(QListView, QtWidgets, qlistview.h) QT_CLASS_LIB(QListWidgetItem, QtWidgets, qlistwidget.h) QT_CLASS_LIB(QListWidget, QtWidgets, qlistwidget.h) -QT_CLASS_LIB(QProxyModel, QtWidgets, qproxymodel.h) QT_CLASS_LIB(QSortFilterProxyModel, QtWidgets, qsortfilterproxymodel.h) QT_CLASS_LIB(QStandardItem, QtWidgets, qstandarditemmodel.h) QT_CLASS_LIB(QStandardItemModel, QtWidgets, qstandarditemmodel.h) diff --git a/src/widgets/doc/src/modelview.qdoc b/src/widgets/doc/src/modelview.qdoc index 97432b4df4..4ce53f937b 100644 --- a/src/widgets/doc/src/modelview.qdoc +++ b/src/widgets/doc/src/modelview.qdoc @@ -692,7 +692,7 @@ \row \li Address Book with sorting \li - \li QProxyModel + \li QSortfilterProxyModel \li Introducing sort and filter capabilities \li Book2, Chapter 8.5 \row diff --git a/src/widgets/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri index fa44b0b997..0bc0309271 100644 --- a/src/widgets/itemviews/itemviews.pri +++ b/src/widgets/itemviews/itemviews.pri @@ -21,8 +21,6 @@ HEADERS += \ itemviews/qtreewidget.h \ itemviews/qtreewidget_p.h \ itemviews/qwidgetitemdata_p.h \ - itemviews/qproxymodel.h \ - itemviews/qproxymodel_p.h \ itemviews/qitemeditorfactory.h \ itemviews/qitemeditorfactory_p.h \ itemviews/qtreewidgetitemiterator.h \ @@ -46,7 +44,6 @@ SOURCES += \ itemviews/qlistwidget.cpp \ itemviews/qtablewidget.cpp \ itemviews/qtreewidget.cpp \ - itemviews/qproxymodel.cpp \ itemviews/qitemeditorfactory.cpp \ itemviews/qtreewidgetitemiterator.cpp \ itemviews/qdatawidgetmapper.cpp \ diff --git a/src/widgets/itemviews/qproxymodel.cpp b/src/widgets/itemviews/qproxymodel.cpp deleted file mode 100644 index 655fef9900..0000000000 --- a/src/widgets/itemviews/qproxymodel.cpp +++ /dev/null @@ -1,549 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qproxymodel.h" - -#ifndef QT_NO_PROXYMODEL -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QProxyModel - \obsolete - \brief The QProxyModel class provides support for processing data - passed between another model and a view. - - \ingroup model-view - \inmodule QtWidgets - - If you want to do filtering and sorting, see QSortFilterProxyModel. - - Proxy models provide a standard model interface that can be used to - manipulate the data retrieved through an underlying model. They can be used to - perform operations such as sorting and filtering on the data obtained without - changing the contents of the model. - - Just as with subclasses of QAbstractItemView, QProxyModel provides the setModel() - function that is used to specify the model to be acted on by the proxy. - Views can be connected to either the underlying model or the proxy model with - \l QAbstractItemView::setModel(). - - Since views rely on the information provided in model indexes to identify - items of data from models, and to position these items in some visual - representation, proxy models must create their own model indexes instead of - supplying model indexes from their underlying models. - - \sa {Model/View Programming}, QAbstractItemModel - -*/ - -/*! - Constructs a proxy model with the given \a parent. -*/ - -QProxyModel::QProxyModel(QObject *parent) - : QAbstractItemModel(*new QProxyModelPrivate, parent) -{ - Q_D(QProxyModel); - setModel(&d->empty); -} - -/*! - \internal -*/ -QProxyModel::QProxyModel(QProxyModelPrivate &dd, QObject *parent) - : QAbstractItemModel(dd, parent) -{ - Q_D(QProxyModel); - setModel(&d->empty); -} - -/*! - Destroys the proxy model. -*/ -QProxyModel::~QProxyModel() -{ -} - -/*! - Sets the given \a model to be processed by the proxy model. -*/ -void QProxyModel::setModel(QAbstractItemModel *model) -{ - Q_D(QProxyModel); - if (d->model && d->model != &d->empty) - disconnectFromModel(d->model); - if (model) { - d->model = model; - connectToModel(model); - } else { - d->model = &d->empty; - } -} - -/*! - Returns the model that contains the data that is available through the - proxy model. -*/ -QAbstractItemModel *QProxyModel::model() const -{ - Q_D(const QProxyModel); - return d->model; -} - -/*! - Returns the model index with the given \a row, \a column, and \a parent. - - \sa QAbstractItemModel::index() -*/ -QModelIndex QProxyModel::index(int row, int column, const QModelIndex &parent) const -{ - Q_D(const QProxyModel); - return setProxyModel(d->model->index(row, column, setSourceModel(parent))); -} - -/*! - Returns the model index that corresponds to the parent of the given \a child - index. -*/ -QModelIndex QProxyModel::parent(const QModelIndex &child) const -{ - Q_D(const QProxyModel); - return setProxyModel(d->model->parent(setSourceModel(child))); -} - -/*! - Returns the number of rows for the given \a parent. - - \sa QAbstractItemModel::rowCount() -*/ -int QProxyModel::rowCount(const QModelIndex &parent) const -{ - Q_D(const QProxyModel); - return d->model->rowCount(setSourceModel(parent)); -} - -/*! - Returns the number of columns for the given \a parent. - - \sa QAbstractItemModel::columnCount() -*/ -int QProxyModel::columnCount(const QModelIndex &parent) const -{ - Q_D(const QProxyModel); - return d->model->columnCount(setSourceModel(parent)); -} - -/*! - Returns true if the item corresponding to the \a parent index has child - items; otherwise returns false. - - \sa QAbstractItemModel::hasChildren() -*/ -bool QProxyModel::hasChildren(const QModelIndex &parent) const -{ - Q_D(const QProxyModel); - return d->model->hasChildren(setSourceModel(parent)); -} - -/*! - Returns the data stored in the item with the given \a index under the - specified \a role. -*/ -QVariant QProxyModel::data(const QModelIndex &index, int role) const -{ - Q_D(const QProxyModel); - return d->model->data(setSourceModel(index), role); -} - -/*! - Sets the \a role data for the item at \a index to \a value. - Returns true if successful; otherwise returns false. - - The base class implementation returns false. This function and - data() must be reimplemented for editable models. - - \sa data(), itemData(), QAbstractItemModel::setData() -*/ -bool QProxyModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - Q_D(const QProxyModel); - return d->model->setData(setSourceModel(index), value, role); -} - -/*! - Returns the data stored in the \a section of the header with specified - \a orientation under the given \a role. -*/ -QVariant QProxyModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_D(const QProxyModel); - return d->model->headerData(section, orientation, role); -} - -/*! - Sets the \a role data in the \a section of the header with the specified - \a orientation to the \a value given. - - \sa QAbstractItemModel::setHeaderData() -*/ -bool QProxyModel::setHeaderData(int section, Qt::Orientation orientation, - const QVariant &value, int role) -{ - Q_D(const QProxyModel); - return d->model->setHeaderData(section, orientation, value, role); -} - -/*! - Returns a list of MIME types that are supported by the model. -*/ -QStringList QProxyModel::mimeTypes() const -{ - Q_D(const QProxyModel); - return d->model->mimeTypes(); -} - -/*! - Returns MIME data for the specified \a indexes in the model. -*/ -QMimeData *QProxyModel::mimeData(const QModelIndexList &indexes) const -{ - Q_D(const QProxyModel); - QModelIndexList lst; - for (int i = 0; i < indexes.count(); ++i) - lst.append(setSourceModel(indexes.at(i))); - return d->model->mimeData(lst); -} - -/*! - Returns true if the model accepts the \a data dropped onto an attached - view for the specified \a action; otherwise returns false. - - The \a parent, \a row, and \a column details can be used to control - which MIME types are acceptable to different parts of a model when - received via the drag and drop system. -*/ -bool QProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) -{ - Q_D(const QProxyModel); - return d->model->dropMimeData(data, action, row, column, setSourceModel(parent)); -} - -/*! - Returns the drop actions that are supported by the model; this is - a combination of the individual actions defined in \l Qt::DropActions. - - The selection of drop actions provided by the model will influence the - behavior of the component that started the drag and drop operation. - - \sa \l{dnd.html}{Drag and Drop} -*/ -Qt::DropActions QProxyModel::supportedDropActions() const -{ - Q_D(const QProxyModel); - return d->model->supportedDropActions(); -} - -/*! - Inserts \a count rows into the model, creating new items as children of - the given \a parent. The new rows are inserted before the \a row - specified. If the \a parent item has no children, a single column is - created to contain the required number of rows. - - Returns true if the rows were successfully inserted; otherwise - returns false. - - \sa QAbstractItemModel::insertRows() -*/ -bool QProxyModel::insertRows(int row, int count, const QModelIndex &parent) -{ - Q_D(const QProxyModel); - return d->model->insertRows(row, count, setSourceModel(parent)); -} - -/*! - Inserts \a count columns into the model, creating new items as children of - the given \a parent. The new columns are inserted before the \a column - specified. If the \a parent item has no children, a single row is created - to contain the required number of columns. - - Returns true if the columns were successfully inserted; otherwise - returns false. - - \sa QAbstractItemModel::insertColumns() -*/ -bool QProxyModel::insertColumns(int column, int count, const QModelIndex &parent) -{ - Q_D(const QProxyModel); - return d->model->insertColumns(column, count, setSourceModel(parent)); -} - -/*! - Fetches more child items of the given \a parent. This function is used by views - to tell the model that they can display more data than the model has provided. - - \sa QAbstractItemModel::fetchMore() -*/ -void QProxyModel::fetchMore(const QModelIndex &parent) -{ - Q_D(const QProxyModel); - d->model->fetchMore(parent); -} - -/*! - Returns the item flags for the given \a index. -*/ -Qt::ItemFlags QProxyModel::flags(const QModelIndex &index) const -{ - Q_D(const QProxyModel); - return d->model->flags(setSourceModel(index)); -} - -/*! - Sorts the child items in the specified \a column according to the sort - order defined by \a order. - - \sa QAbstractItemModel::sort() -*/ -void QProxyModel::sort(int column, Qt::SortOrder order) -{ - Q_D(QProxyModel); - d->model->sort(column, order); -} - -/*! - Returns a list of model indexes that each contain the given \a value for - the \a role specified. The search begins at the \a start index and is - performed according to the specified \a flags. The search continues until - the number of matching data items equals \a hits, the last row is reached, - or the search reaches \a start again, depending on whether \c MatchWrap is - specified in \a flags. - - \sa QAbstractItemModel::match() -*/ -QModelIndexList QProxyModel::match(const QModelIndex &start, - int role, const QVariant &value, - int hits, Qt::MatchFlags flags) const -{ - Q_D(const QProxyModel); - return d->model->match(start, role, value, hits, flags); -} - -/*! - Returns the size of the item that corresponds to the specified \a index. -*/ -QSize QProxyModel::span(const QModelIndex &index) const -{ - Q_D(const QProxyModel); - return d->model->span(setSourceModel(index)); -} - -/*! - */ -bool QProxyModel::submit() -{ - Q_D(QProxyModel); - return d->model->submit(); -} - -/*! - */ -void QProxyModel::revert() -{ - Q_D(QProxyModel); - d->model->revert(); -} - -/*! - \internal - Change the model pointer in the given \a source_index to point to the proxy model. - */ -QModelIndex QProxyModel::setProxyModel(const QModelIndex &source_index) const -{ - QModelIndex proxy_index = source_index; - if (proxy_index.isValid()) - proxy_index.m = this; - return proxy_index; -} - -/*! - \internal - Change the model pointer in the given \a proxy_index to point to the source model. - */ -QModelIndex QProxyModel::setSourceModel(const QModelIndex &proxy_index) const -{ - Q_D(const QProxyModel); - QModelIndex source_index = proxy_index; - source_index.m = d->model; - return source_index; -} - -/*! - \internal - Connect to all the signals emitted by given \a model. -*/ -void QProxyModel::connectToModel(const QAbstractItemModel *model) const -{ - connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); - connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - this, SIGNAL(headerDataChanged(Qt::Orientation,int,int))); // signal to signal - connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int))); - connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int))); - connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))); - connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int))); - connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))); - connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int))); - connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))); - connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int))); - connect(model, SIGNAL(modelReset()), this, SIGNAL(modelReset())); // signal to signal - connect(model, SIGNAL(layoutAboutToBeChanged()), this, SIGNAL(layoutAboutToBeChanged())); // signal to signal - connect(model, SIGNAL(layoutChanged()), this, SIGNAL(layoutChanged())); // signal to signal -} - -/*! - \internal - Disconnect from all the signals emitted by the given \a model. - */ -void QProxyModel::disconnectFromModel(const QAbstractItemModel *model) const -{ - disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); - disconnect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), - this, SIGNAL(headerDataChanged(Qt::Orientation,int,int))); // signal to signal - disconnect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int))); - disconnect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(rowsInserted(QModelIndex,int,int))); - disconnect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))); - disconnect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int))); - disconnect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))); - disconnect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int))); - disconnect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))); - disconnect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), - this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int))); - disconnect(model, SIGNAL(modelReset()), this, SIGNAL(modelReset())); // signal to signal - disconnect(model, SIGNAL(layoutAboutToBeChanged()), this, SIGNAL(layoutAboutToBeChanged())); // signal to signal - disconnect(model, SIGNAL(layoutChanged()), this, SIGNAL(layoutChanged())); // signal to signal -} - -/*! - \fn QObject *QProxyModel::parent() const - \internal -*/ - -void QProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &tl,const QModelIndex &br) -{ - Q_Q(QProxyModel); - emit q->dataChanged(q->setProxyModel(tl), q->setProxyModel(br)); -} - -void QProxyModelPrivate::_q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int first ,int last) -{ - Q_Q(QProxyModel); - q->beginInsertRows(q->setProxyModel(parent), first, last); -} - -void QProxyModelPrivate::_q_sourceRowsInserted(const QModelIndex &, int, int) -{ - Q_Q(QProxyModel); - q->endInsertRows(); -} - -void QProxyModelPrivate::_q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last) -{ - Q_Q(QProxyModel); - q->beginRemoveRows(q->setProxyModel(parent), first, last); -} - -void QProxyModelPrivate::_q_sourceRowsRemoved(const QModelIndex &, int, int) -{ - Q_Q(QProxyModel); - q->endRemoveRows(); -} - -void QProxyModelPrivate::_q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int first, int last) -{ - Q_Q(QProxyModel); - q->beginInsertColumns(q->setProxyModel(parent), first, last); -} - -void QProxyModelPrivate::_q_sourceColumnsInserted(const QModelIndex &, int, int) -{ - Q_Q(QProxyModel); - q->endInsertColumns(); -} - -void QProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int first, int last) -{ - Q_Q(QProxyModel); - q->beginRemoveColumns(q->setProxyModel(parent), first, last); -} - - -void QProxyModelPrivate::_q_sourceColumnsRemoved(const QModelIndex &, int, int) -{ - Q_Q(QProxyModel); - q->endRemoveColumns(); -} - -QT_END_NAMESPACE - -#include "moc_qproxymodel.cpp" - -#endif // QT_NO_PROXYMODEL diff --git a/src/widgets/itemviews/qproxymodel.h b/src/widgets/itemviews/qproxymodel.h deleted file mode 100644 index c043573ee9..0000000000 --- a/src/widgets/itemviews/qproxymodel.h +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPROXYMODEL_H -#define QPROXYMODEL_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_PROXYMODEL - -class QProxyModelPrivate; - -class Q_WIDGETS_EXPORT QProxyModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - explicit QProxyModel(QObject *parent = 0); - ~QProxyModel(); - - virtual void setModel(QAbstractItemModel *model); - QAbstractItemModel *model() const; - - // implementing model interface - - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &child) const; - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - bool hasChildren(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, - int role = Qt::EditRole); - - QStringList mimeTypes() const; - QMimeData *mimeData(const QModelIndexList &indexes) const; - bool dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent); - Qt::DropActions supportedDropActions() const; - - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); - bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()); - - void fetchMore(const QModelIndex &parent); - Qt::ItemFlags flags(const QModelIndex &index) const; - - void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); - - QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, - int hits = 1, Qt::MatchFlags flags = - Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const; - - QSize span(const QModelIndex &index) const; - - bool submit(); - void revert(); - -#ifdef Q_NO_USING_KEYWORD - inline QObject *parent() const { return QObject::parent(); } -#else - using QObject::parent; -#endif - -protected: - QProxyModel(QProxyModelPrivate &, QObject *parent = 0); - - QModelIndex setProxyModel(const QModelIndex &source_index) const; - QModelIndex setSourceModel(const QModelIndex &proxy_index) const; - - void connectToModel(const QAbstractItemModel *model) const; - void disconnectFromModel(const QAbstractItemModel *model) const; - -private: - Q_DECLARE_PRIVATE(QProxyModel) - Q_DISABLE_COPY(QProxyModel) - - Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex&,const QModelIndex&)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex&,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex&,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex&,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(const QModelIndex&,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(const QModelIndex&,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(const QModelIndex&,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(const QModelIndex&,int,int)) - Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(const QModelIndex&,int,int)) -}; - -#endif // QT_NO_PROXYMODEL - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPROXYMODEL_H diff --git a/src/widgets/itemviews/qproxymodel_p.h b/src/widgets/itemviews/qproxymodel_p.h deleted file mode 100644 index fbac2ca613..0000000000 --- a/src/widgets/itemviews/qproxymodel_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPROXYMODEL_P_H -#define QPROXYMODEL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of QAbstractItemModel*. This header file may change from version -// to version without notice, or even be removed. -// -// We mean it. -// -// - -#include "QtCore/qabstractitemmodel.h" -#include "private/qabstractitemmodel_p.h" - -#ifndef QT_NO_PROXYMODEL - -QT_BEGIN_NAMESPACE - -class QEmptyModel : public QAbstractItemModel -{ -public: - explicit QEmptyModel(QObject *parent = 0) : QAbstractItemModel(parent) {} - QModelIndex index(int, int, const QModelIndex &) const { return QModelIndex(); } - QModelIndex parent(const QModelIndex &) const { return QModelIndex(); } - int rowCount(const QModelIndex &) const { return 0; } - int columnCount(const QModelIndex &) const { return 0; } - bool hasChildren(const QModelIndex &) const { return false; } - QVariant data(const QModelIndex &, int) const { return QVariant(); } -}; - -class QProxyModelPrivate : private QAbstractItemModelPrivate -{ - Q_DECLARE_PUBLIC(QProxyModel) - -public: - void _q_sourceDataChanged(const QModelIndex &tl,const QModelIndex &br); - void _q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int first ,int last); - void _q_sourceRowsInserted(const QModelIndex &parent, int first ,int last); - void _q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last); - void _q_sourceRowsRemoved(const QModelIndex &parent, int first, int last); - void _q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int first, int last); - void _q_sourceColumnsInserted(const QModelIndex &parent, int first, int last); - void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int first, int last); - void _q_sourceColumnsRemoved(const QModelIndex &parent, int first, int last); - - QProxyModelPrivate() : QAbstractItemModelPrivate(), model(0) {} - QAbstractItemModel *model; - QEmptyModel empty; -}; - -QT_END_NAMESPACE - -#endif // QT_NO_PROXYMODEL - -#endif // QPROXYMODEL_P_H -- cgit v1.2.3