Qt 4.8
qidentityproxymodel.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 
43 #ifndef QIDENTITYPROXYMODEL_H
44 #define QIDENTITYPROXYMODEL_H
45 
46 #include <QtGui/qabstractproxymodel.h>
47 
48 #ifndef QT_NO_IDENTITYPROXYMODEL
49 
51 
53 
54 QT_MODULE(Gui)
55 
57 
59 {
60  Q_OBJECT
61 public:
62  explicit QIdentityProxyModel(QObject* parent = 0);
64 
65  int columnCount(const QModelIndex& parent = QModelIndex()) const;
66  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
67  QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
68  QModelIndex mapToSource(const QModelIndex& proxyIndex) const;
69  QModelIndex parent(const QModelIndex& child) const;
70  int rowCount(const QModelIndex& parent = QModelIndex()) const;
71  bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
72 
74  QItemSelection mapSelectionToSource(const QItemSelection& selection) const;
75  QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
76  void setSourceModel(QAbstractItemModel* sourceModel);
77 
78  bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
79  bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
80  bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
81  bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
82 
83 protected:
85 
86 private:
89 
90  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(QModelIndex,int,int))
91  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(QModelIndex,int,int))
92  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))
93  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(QModelIndex,int,int))
94  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
95  Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))
96 
97  Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))
98  Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(QModelIndex,int,int))
99  Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))
100  Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(QModelIndex,int,int))
101  Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
102  Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))
103 
104  Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex))
105  Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last))
106 
107  Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
108  Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
109  Q_PRIVATE_SLOT(d_func(), void _q_sourceModelAboutToBeReset())
110  Q_PRIVATE_SLOT(d_func(), void _q_sourceModelReset())
111 };
112 
114 
116 
117 #endif // QT_NO_IDENTITYPROXYMODEL
118 
119 #endif // QIDENTITYPROXYMODEL_H
120 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
Returns a list of indexes for the items in the column of the start index where data stored under the ...
friend class QIdentityProxyModel
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Handles the data supplied by a drag and drop operation that ended with the given action.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
virtual QItemSelection mapSelectionToSource(const QItemSelection &selection) const
Returns a source selection mapped from the specified proxySelection.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
virtual QItemSelection mapSelectionFromSource(const QItemSelection &selection) const
Returns a proxy selection mapped from the specified sourceSelection.
virtual void setSourceModel(QAbstractItemModel *sourceModel)
Sets the given sourceModel to be processed by the proxy model.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const =0
Reimplement this function to return the model index in the proxy model that corresponds to the source...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
On models that support this, removes count rows starting with the given row under parent parent from ...
static const char * data(const QByteArray &arr)
DropAction
Definition: qnamespace.h:1597
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
virtual bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
On models that support this, inserts count rows into the model before the given row.
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QAbstractItemModel class provides the abstract interface for item model classes.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...
The QItemSelection class manages information about selected items in a model.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QModelIndex class is used to locate data in a data model.
The QIdentityProxyModel class proxies its source model unmodified.
virtual bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
On models that support this, inserts count new columns into the model before the given column...
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
Orientation
Definition: qnamespace.h:174
#define QT_END_HEADER
Definition: qglobal.h:137
virtual bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
On models that support this, removes count columns starting with the given column under parent parent...