1 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
2 
3    This file is part of the Trojita Qt IMAP e-mail client,
4    http://trojita.flaska.net/
5 
6    This program is free software; you can redistribute it and/or
7    modify it under the terms of the GNU General Public License as
8    published by the Free Software Foundation; either version 2 of
9    the License or (at your option) version 3 or any later version
10    accepted by the membership of KDE e.V. (or its successor approved
11    by the membership of KDE e.V.), which shall act as a proxy
12    defined in Section 14 of version 3 of the license.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef MODELWATCHER_H
23 #define MODELWATCHER_H
24 
25 #include <QModelIndex>
26 #include <QAbstractItemModel>
27 
28 namespace Imap
29 {
30 
31 namespace Mailbox
32 {
33 
34 class ModelWatcher : public QObject
35 {
36     Q_OBJECT
37     bool m_ignoreData;
38 public:
QObject(parent)39     ModelWatcher(QObject *parent=0): QObject(parent), m_ignoreData(false) {};
40     void setModel(QAbstractItemModel *model);
setIgnoreData(const bool ignore)41     void setIgnoreData(const bool ignore) { m_ignoreData = ignore; }
42 
43 private slots:
44     void columnsAboutToBeInserted(const QModelIndex &, int, int);
45     void columnsAboutToBeRemoved(const QModelIndex &, int, int);
46     void columnsInserted(const QModelIndex &, int, int);
47     void columnsRemoved(const QModelIndex &, int, int);
48     void dataChanged(const QModelIndex &, const QModelIndex &);
49     void headerDataChanged(Qt::Orientation, int, int);
50     void layoutAboutToBeChanged();
51     void layoutChanged();
52     void modelAboutToBeReset();
53     void modelReset();
54     void rowsAboutToBeInserted(const QModelIndex &, int, int);
55     void rowsAboutToBeRemoved(const QModelIndex &, int, int);
56     void rowsInserted(const QModelIndex &, int, int);
57     void rowsRemoved(const QModelIndex &, int, int);
58     void rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
59                             const QModelIndex &destinationParent, int destinationRow);
60     void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
61     void columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
62                                const QModelIndex &destinationParent, int destinationColumn);
63     void columnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column);
64 };
65 
66 }
67 
68 }
69 
70 #endif // MODELWATCHER_H
71