KDEUI
kselectionproxymodel.h
Go to the documentation of this file.
00001 /* 00002 Copyright (c) 2009 Stephen Kelly <steveire@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #ifndef KSELECTIONPROXYMODEL_H 00021 #define KSELECTIONPROXYMODEL_H 00022 00023 #include <QtGui/QAbstractProxyModel> 00024 00025 #include <kdeui_export.h> 00026 00027 class QItemSelectionModel; 00028 00029 class KSelectionProxyModelPrivate; 00030 00086 class KDEUI_EXPORT KSelectionProxyModel : public QAbstractProxyModel 00087 { 00088 Q_OBJECT 00089 public: 00096 explicit KSelectionProxyModel(QItemSelectionModel *selectionModel, QObject *parent = 0); 00097 00101 virtual ~KSelectionProxyModel(); 00102 00106 virtual void setSourceModel(QAbstractItemModel * sourceModel); 00107 00108 QItemSelectionModel *selectionModel() const; 00109 00110 enum FilterBehavior { 00111 SubTrees, 00112 SubTreeRoots, 00113 SubTreesWithoutRoots, 00114 ExactSelection, 00115 ChildrenOfExactSelection 00116 }; 00117 Q_ENUMS(FilterBehavior) 00118 00119 00233 void setFilterBehavior(FilterBehavior behavior); 00234 FilterBehavior filterBehavior() const; 00235 00236 QModelIndex mapFromSource(const QModelIndex & sourceIndex) const; 00237 QModelIndex mapToSource(const QModelIndex & proxyIndex) const; 00238 00239 QItemSelection mapSelectionFromSource(const QItemSelection& selection) const; 00240 QItemSelection mapSelectionToSource(const QItemSelection& selection) const; 00241 00242 virtual Qt::ItemFlags flags(const QModelIndex &index) const; 00243 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; 00244 virtual int rowCount(const QModelIndex & parent = QModelIndex()) const; 00245 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 00246 00247 virtual QMimeData* mimeData(const QModelIndexList & indexes) const; 00248 virtual QStringList mimeTypes() const; 00249 virtual Qt::DropActions supportedDropActions() const; 00250 virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent); 00251 00252 virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const; 00253 virtual QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; 00254 virtual QModelIndex parent(const QModelIndex&) const; 00255 virtual int columnCount(const QModelIndex& = QModelIndex()) const; 00256 00257 virtual QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, 00258 Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const; 00259 00260 Q_SIGNALS: 00261 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER) 00262 private: // Don't allow subclasses to emit these signals. 00263 #endif 00264 00271 void rootIndexAboutToBeRemoved(const QModelIndex &removeRootIndex); 00272 00279 void rootIndexAdded(const QModelIndex &newIndex); 00280 00286 void rootSelectionAboutToBeRemoved(const QItemSelection &selection); 00287 00293 void rootSelectionAdded(const QItemSelection &selection); 00294 00295 protected: 00296 QList<QPersistentModelIndex> sourceRootIndexes() const; 00297 00298 private: 00299 Q_DECLARE_PRIVATE(KSelectionProxyModel) 00300 //@cond PRIVATE 00301 KSelectionProxyModelPrivate *d_ptr; 00302 00303 Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeInserted(const QModelIndex &, int, int)) 00304 Q_PRIVATE_SLOT(d_func(), void sourceRowsInserted(const QModelIndex &, int, int)) 00305 Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeRemoved(const QModelIndex &, int, int)) 00306 Q_PRIVATE_SLOT(d_func(), void sourceRowsRemoved(const QModelIndex &, int, int)) 00307 Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)) 00308 Q_PRIVATE_SLOT(d_func(), void sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)) 00309 Q_PRIVATE_SLOT(d_func(), void sourceModelAboutToBeReset()) 00310 Q_PRIVATE_SLOT(d_func(), void sourceModelReset()) 00311 Q_PRIVATE_SLOT(d_func(), void sourceLayoutAboutToBeChanged()) 00312 Q_PRIVATE_SLOT(d_func(), void sourceLayoutChanged()) 00313 Q_PRIVATE_SLOT(d_func(), void sourceDataChanged(const QModelIndex &, const QModelIndex &)) 00314 Q_PRIVATE_SLOT(d_func(), void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)) 00315 Q_PRIVATE_SLOT(d_func(), void sourceModelDestroyed()) 00316 00317 //@endcond 00318 00319 }; 00320 00321 #endif
KDE 4.6 API Reference