00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QSORTFILTERPROXYMODEL_H
00043 #define QSORTFILTERPROXYMODEL_H
00044
00045 #include <QtGui/qabstractproxymodel.h>
00046
00047 #ifndef QT_NO_SORTFILTERPROXYMODEL
00048
00049 #include <QtCore/qregexp.h>
00050
00051 QT_BEGIN_HEADER
00052
00053 QT_BEGIN_NAMESPACE
00054
00055 QT_MODULE(Gui)
00056
00057 class QSortFilterProxyModelPrivate;
00058 class QSortFilterProxyModelLessThan;
00059 class QSortFilterProxyModelGreaterThan;
00060
00061 class Q_GUI_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
00062 {
00063 friend class QSortFilterProxyModelLessThan;
00064 friend class QSortFilterProxyModelGreaterThan;
00065
00066 Q_OBJECT
00067 Q_PROPERTY(QRegExp filterRegExp READ filterRegExp WRITE setFilterRegExp)
00068 Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
00069 Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
00070 Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity)
00071 Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity)
00072 Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware)
00073 Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
00074 Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
00075
00076 public:
00077 QSortFilterProxyModel(QObject *parent = 0);
00078 ~QSortFilterProxyModel();
00079
00080 void setSourceModel(QAbstractItemModel *sourceModel);
00081
00082 QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
00083 QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
00084
00085 QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const;
00086 QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const;
00087
00088 QRegExp filterRegExp() const;
00089 void setFilterRegExp(const QRegExp ®Exp);
00090
00091 int filterKeyColumn() const;
00092 void setFilterKeyColumn(int column);
00093
00094 Qt::CaseSensitivity filterCaseSensitivity() const;
00095 void setFilterCaseSensitivity(Qt::CaseSensitivity cs);
00096
00097 Qt::CaseSensitivity sortCaseSensitivity() const;
00098 void setSortCaseSensitivity(Qt::CaseSensitivity cs);
00099
00100 bool isSortLocaleAware() const;
00101 void setSortLocaleAware(bool on);
00102
00103 int sortColumn() const;
00104 Qt::SortOrder sortOrder() const;
00105
00106 bool dynamicSortFilter() const;
00107 void setDynamicSortFilter(bool enable);
00108
00109 int sortRole() const;
00110 void setSortRole(int role);
00111
00112 int filterRole() const;
00113 void setFilterRole(int role);
00114
00115 public Q_SLOTS:
00116 void setFilterRegExp(const QString &pattern);
00117 void setFilterWildcard(const QString &pattern);
00118 void setFilterFixedString(const QString &pattern);
00119 void clear();
00120 void invalidate();
00121
00122 protected:
00123 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
00124 virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
00125 virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
00126
00127 void filterChanged();
00128 void invalidateFilter();
00129
00130 public:
00131 #ifdef Q_NO_USING_KEYWORD
00132 inline QObject *parent() const { return QObject::parent(); }
00133 #else
00134 using QObject::parent;
00135 #endif
00136
00137 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00138 QModelIndex parent(const QModelIndex &child) const;
00139
00140 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00141 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00142 bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
00143
00144 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00145 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00146
00147 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00148 bool setHeaderData(int section, Qt::Orientation orientation,
00149 const QVariant &value, int role = Qt::EditRole);
00150
00151 QMimeData *mimeData(const QModelIndexList &indexes) const;
00152 bool dropMimeData(const QMimeData *data, Qt::DropAction action,
00153 int row, int column, const QModelIndex &parent);
00154
00155 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
00156 bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
00157 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
00158 bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
00159
00160 void fetchMore(const QModelIndex &parent);
00161 bool canFetchMore(const QModelIndex &parent) const;
00162 Qt::ItemFlags flags(const QModelIndex &index) const;
00163
00164 QModelIndex buddy(const QModelIndex &index) const;
00165 QModelIndexList match(const QModelIndex &start, int role,
00166 const QVariant &value, int hits = 1,
00167 Qt::MatchFlags flags =
00168 Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
00169 QSize span(const QModelIndex &index) const;
00170 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
00171
00172 QStringList mimeTypes() const;
00173 Qt::DropActions supportedDropActions() const;
00174 private:
00175 Q_DECLARE_PRIVATE(QSortFilterProxyModel)
00176 Q_DISABLE_COPY(QSortFilterProxyModel)
00177
00178 Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right))
00179 Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end))
00180 Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset())
00181 Q_PRIVATE_SLOT(d_func(), void _q_sourceReset())
00182 Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
00183 Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
00184 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
00185 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex &source_parent, int start, int end))
00186 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
00187 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(const QModelIndex &source_parent, int start, int end))
00188 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
00189 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(const QModelIndex &source_parent, int start, int end))
00190 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
00191 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(const QModelIndex &source_parent, int start, int end))
00192 };
00193
00194 QT_END_NAMESPACE
00195
00196 QT_END_HEADER
00197
00198 #endif // QT_NO_SORTFILTERPROXYMODEL
00199
00200 #endif // QSORTFILTERPROXYMODEL_H