1 /***************************************************************************
2 * Copyright (C) 2007 by Tobias Koenig <tokoe@kde.org> *
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>
17 * A proxy model, which filters out all pages except the
20 class PageFilterProxyModel
: public QSortFilterProxyModel
26 * Creates a new page filter proxy model.
28 * @param parent The parent object.
30 PageFilterProxyModel( QObject
*parent
= 0 );
33 * Reimplemented from QSortFilterProxy.
35 virtual bool filterAcceptsRow( int, const QModelIndex
& ) const;
39 * Sets whether the proxy model shall filter
42 void groupByCurrentPage( bool value
);
45 * Sets the current page.
47 void setCurrentPage( int page
);
50 bool mGroupByCurrentPage
;
55 * A proxy model which either groups the annotations by
56 * pages or shows them all as list.
58 class PageGroupProxyModel
: public QAbstractProxyModel
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
);
83 * Sets whether the proxy model shall group
84 * the annotations by page.
86 void groupByPage( bool value
);
89 void rebuildIndexes();
93 QList
<QModelIndex
> mIndexes
;
94 QList
<QPair
< QModelIndex
, QList
<QModelIndex
> > > mTreeIndexes
;
98 * A proxy model which groups the annotations by author.
100 class AuthorGroupProxyModel
: public QAbstractProxyModel
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;
132 * Sets whether the proxy model shall group
133 * the annotations by author.
135 void groupByAuthor( bool value
);
138 void rebuildIndexes();