1/*
2 Copyright (c) 2014 Daniel Vrátil <dvratil@redhat.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef AKONADI_TAGMODEL_H
21#define AKONADI_TAGMODEL_H
22
23#include <QtCore/QModelIndex>
24
25#include "akonadi_export.h"
26#include <akonadi/tag.h>
27
28namespace Akonadi
29{
30
31class Monitor;
32class TagModelPrivate;
33
34class AKONADI_EXPORT TagModel : public QAbstractItemModel
35{
36 Q_OBJECT
37
38public:
39 enum Roles {
40 IdRole = Qt::UserRole + 1,
41 NameRole,
42 TypeRole,
43 GIDRole,
44 ParentRole,
45 TagRole,
46
47 UserRole = Qt::UserRole + 500,
48 TerminalUserRole = 2000,
49 EndRole = 65535
50 };
51
52 explicit TagModel(Monitor *recorder, QObject *parent);
53 virtual ~TagModel();
54
55 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
56 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
57
58 virtual QVariant data(const QModelIndex &index, int role) const;
59 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
60
61 virtual Qt::ItemFlags flags(const QModelIndex &index) const;
62 /*
63 virtual Qt::DropActions supportedDropActions() const;
64 virtual QMimeData* mimeData( const QModelIndexList &indexes ) const;
65 virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
66 */
67
68 virtual QModelIndex parent(const QModelIndex &child) const;
69 virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
70
71protected:
72 Q_DECLARE_PRIVATE(TagModel)
73 TagModelPrivate *d_ptr;
74
75 TagModel(Monitor *recorder, TagModelPrivate *dd, QObject *parent = 0);
76
77private:
78 virtual bool insertRows(int, int, const QModelIndex& = QModelIndex());
79 virtual bool insertColumns(int, int, const QModelIndex& = QModelIndex());
80 virtual bool removeColumns(int, int, const QModelIndex& = QModelIndex());
81 virtual bool removeRows(int, int, const QModelIndex& = QModelIndex());
82
83 Q_PRIVATE_SLOT(d_func(), void tagsFetched(const Akonadi::Tag::List &tags))
84 Q_PRIVATE_SLOT(d_func(), void tagsFetchDone(KJob *job))
85 Q_PRIVATE_SLOT(d_func(), void monitoredTagAdded(const Akonadi::Tag &tag))
86 Q_PRIVATE_SLOT(d_func(), void monitoredTagRemoved(const Akonadi::Tag &tag))
87 Q_PRIVATE_SLOT(d_func(), void monitoredTagChanged(const Akonadi::Tag &tag))
88};
89}
90
91#endif // AKONADI_TAGMODEL_H
92