SVN_SILENT made messages (.desktop file)
[kdegraphics.git] / okular / ui / annotationproxymodels.h
blobe29da0d135334919f90c9bc426694e7c73bdfe09
1 /***************************************************************************
2 * Copyright (C) 2007 by Tobias Koenig <tokoe@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef ANNOTATIONPROXYMODEL_H
11 #define ANNOTATIONPROXYMODEL_H
13 #include <QtGui/QSortFilterProxyModel>
14 #include <QtCore/QPair>
16 /**
17 * A proxy model, which filters out all pages except the
18 * current one.
20 class PageFilterProxyModel : public QSortFilterProxyModel
22 Q_OBJECT
24 public:
25 /**
26 * Creates a new page filter proxy model.
28 * @param parent The parent object.
30 PageFilterProxyModel( QObject *parent = 0 );
32 /**
33 * Reimplemented from QSortFilterProxy.
35 virtual bool filterAcceptsRow( int, const QModelIndex& ) const;
37 public Q_SLOTS:
38 /**
39 * Sets whether the proxy model shall filter
40 * by current page.
42 void groupByCurrentPage( bool value );
44 /**
45 * Sets the current page.
47 void setCurrentPage( int page );
49 private:
50 bool mGroupByCurrentPage;
51 int mCurrentPage;
54 /**
55 * A proxy model which either groups the annotations by
56 * pages or shows them all as list.
58 class PageGroupProxyModel : public QAbstractProxyModel
60 Q_OBJECT
62 public:
63 /**
64 * Creates a new page group proxy model.
66 * @param parent The parent object.
68 PageGroupProxyModel( QObject *parent = 0 );
70 virtual int columnCount( const QModelIndex &parentIndex ) const;
71 virtual int rowCount( const QModelIndex &parentIndex ) const;
73 virtual QModelIndex index( int row, int column, const QModelIndex &parentIndex = QModelIndex() ) const;
74 virtual QModelIndex parent( const QModelIndex &index ) const;
76 virtual QModelIndex mapFromSource( const QModelIndex &sourceIndex ) const;
77 virtual QModelIndex mapToSource( const QModelIndex &proxyIndex ) const;
79 virtual void setSourceModel( QAbstractItemModel *model );
81 public Q_SLOTS:
82 /**
83 * Sets whether the proxy model shall group
84 * the annotations by page.
86 void groupByPage( bool value );
88 private Q_SLOTS:
89 void rebuildIndexes();
91 private:
92 bool mGroupByPage;
93 QList<QModelIndex> mIndexes;
94 QList<QPair< QModelIndex, QList<QModelIndex> > > mTreeIndexes;
97 /**
98 * A proxy model which groups the annotations by author.
100 class AuthorGroupProxyModel : public QAbstractProxyModel
102 Q_OBJECT
104 public:
106 * Creates a new author group proxy model.
108 * @param parent The parent object.
110 AuthorGroupProxyModel( QObject *parent = 0 );
111 ~AuthorGroupProxyModel();
113 virtual int columnCount( const QModelIndex &parentIndex ) const;
114 virtual int rowCount( const QModelIndex &parentIndex ) const;
116 virtual QModelIndex index( int row, int column, const QModelIndex &parentIndex = QModelIndex() ) const;
117 virtual QModelIndex parent( const QModelIndex &index ) const;
119 virtual QModelIndex mapFromSource( const QModelIndex &sourceIndex ) const;
120 virtual QModelIndex mapToSource( const QModelIndex &proxyIndex ) const;
122 virtual void setSourceModel( QAbstractItemModel *model );
124 virtual QItemSelection mapSelectionToSource(const QItemSelection &selection) const;
125 virtual QItemSelection mapSelectionFromSource(const QItemSelection &selection) const;
126 QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const;
127 QMap<int, QVariant> itemData(const QModelIndex &index) const;
128 Qt::ItemFlags flags(const QModelIndex &index) const;
130 public Q_SLOTS:
132 * Sets whether the proxy model shall group
133 * the annotations by author.
135 void groupByAuthor( bool value );
137 private Q_SLOTS:
138 void rebuildIndexes();
140 private:
141 class Private;
142 Private* const d;
145 #endif