1 | /* |
2 | Copyright (c) 2006 - 2008 Volker Krause <vkrause@kde.org> |
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_COLLECTIONMODEL_P_H |
21 | #define AKONADI_COLLECTIONMODEL_P_H |
22 | |
23 | #include "collection.h" |
24 | |
25 | #include <klocalizedstring.h> |
26 | |
27 | #include <QtCore/QHash> |
28 | #include <QtCore/QList> |
29 | #include <QtCore/QModelIndex> |
30 | #include <QtCore/QStringList> |
31 | |
32 | class KJob; |
33 | |
34 | namespace Akonadi { |
35 | |
36 | class CollectionModel; |
37 | class CollectionStatistics; |
38 | class Monitor; |
39 | class Session; |
40 | |
41 | /** |
42 | * @internal |
43 | */ |
44 | class CollectionModelPrivate |
45 | { |
46 | public: |
47 | Q_DECLARE_PUBLIC(CollectionModel) |
48 | explicit CollectionModelPrivate(CollectionModel *parent) |
49 | : q_ptr(parent) |
50 | , monitor(0) |
51 | , session(0) |
52 | , fetchStatistics(false) |
53 | , unsubscribed(false) |
54 | , headerContent(i18nc("@title:column, name of a thing" , "Name" )) |
55 | { |
56 | } |
57 | |
58 | virtual ~CollectionModelPrivate() {} |
59 | |
60 | CollectionModel *q_ptr; |
61 | QHash<Collection::Id, Collection> collections; |
62 | QHash<Collection::Id, QVector<Collection::Id> > childCollections; |
63 | |
64 | QHash<Collection::Id, Collection> m_newCollections; |
65 | QHash< Collection::Id, QVector<Collection::Id> > m_newChildCollections; |
66 | |
67 | Monitor *monitor; |
68 | Session *session; |
69 | QStringList mimeTypes; |
70 | bool fetchStatistics; |
71 | bool unsubscribed; |
72 | QString ; |
73 | |
74 | void init(); |
75 | void startFirstListJob(); |
76 | void collectionRemoved(const Akonadi::Collection &); |
77 | void collectionChanged(const Akonadi::Collection &); |
78 | void updateDone(KJob *); |
79 | void collectionStatisticsChanged(Collection::Id, const Akonadi::CollectionStatistics &); |
80 | void listDone(KJob *); |
81 | void editDone(KJob *); |
82 | void dropResult(KJob *); |
83 | void collectionsChanged(const Akonadi::Collection::List &cols); |
84 | |
85 | QModelIndex indexForId(Collection::Id id, int column = 0) const; |
86 | bool removeRowFromModel(int row, const QModelIndex &parent = QModelIndex()); |
87 | bool supportsContentType(const QModelIndex &index, const QStringList &contentTypes); |
88 | |
89 | private: |
90 | void updateSupportedMimeTypes(Collection col) |
91 | { |
92 | const QStringList l = col.contentMimeTypes(); |
93 | QStringList::ConstIterator constEnd(l.constEnd()); |
94 | for (QStringList::ConstIterator it = l.constBegin(); it != constEnd; ++it) { |
95 | if ((*it) == Collection::mimeType()) { |
96 | continue; |
97 | } |
98 | if (!mimeTypes.contains(*it)) { |
99 | mimeTypes << *it; |
100 | } |
101 | } |
102 | } |
103 | }; |
104 | |
105 | } |
106 | |
107 | #endif |
108 | |