• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
entitytreemodel_p.h
1/*
2 Copyright (c) 2008 Stephen Kelly <steveire@gmail.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 ENTITYTREEMODELPRIVATE_H
21#define ENTITYTREEMODELPRIVATE_H
22
23#include <akonadi/item.h>
24#include <KJob>
25
26#include <akonadi/collectionfetchjob.h>
27#include <akonadi/itemfetchscope.h>
28#include <akonadi/mimetypechecker.h>
29
30#include "entitytreemodel.h"
31
32#include "akonadiprivate_export.h"
33
34namespace Akonadi
35{
36class ItemFetchJob;
37class ChangeRecorder;
38class AgentInstance;
39}
40
41struct Node
42{
43 Akonadi::Entity::Id id;
44 Akonadi::Entity::Id parent;
45
46 enum Type {
47 Item,
48 Collection
49 };
50
51 int type;
52};
53
54namespace Akonadi
55{
59class AKONADI_TESTS_EXPORT EntityTreeModelPrivate
60{
61public:
62
63 explicit EntityTreeModelPrivate(EntityTreeModel *parent);
64 ~EntityTreeModelPrivate();
65 EntityTreeModel *const q_ptr;
66
67 enum RetrieveDepth {
68 Base,
69 Recursive
70 };
71
72 void init(ChangeRecorder *monitor);
73
74 void fetchCollections(const Collection &collection, CollectionFetchJob::Type type = CollectionFetchJob::FirstLevel);
75 void fetchCollections(const Collection::List &collections, CollectionFetchJob::Type type = CollectionFetchJob::FirstLevel);
76 void fetchCollections(Akonadi::CollectionFetchJob *job);
77 void fetchItems(const Collection &collection);
78 void collectionsFetched(const Akonadi::Collection::List &);
79 void collectionListFetched(const Akonadi::Collection::List &);
80 void itemsFetched(const Akonadi::Item::List &items);
81 void itemsFetched(const Collection::Id collectionId, const Akonadi::Item::List &items);
82
83 void monitoredCollectionAdded(const Akonadi::Collection &, const Akonadi::Collection &);
84 void monitoredCollectionRemoved(const Akonadi::Collection &);
85 void monitoredCollectionChanged(const Akonadi::Collection &);
86 void monitoredCollectionStatisticsChanged(Akonadi::Collection::Id, const Akonadi::CollectionStatistics &);
87 void monitoredCollectionMoved(const Akonadi::Collection &, const Akonadi::Collection &, const Akonadi::Collection &);
88
89 void monitoredItemAdded(const Akonadi::Item &, const Akonadi::Collection &);
90 void monitoredItemRemoved(const Akonadi::Item &);
91 void monitoredItemChanged(const Akonadi::Item &, const QSet<QByteArray> &);
92 void monitoredItemMoved(const Akonadi::Item &, const Akonadi::Collection &, const Akonadi::Collection &);
93
94 void monitoredItemLinked(const Akonadi::Item &, const Akonadi::Collection &);
95 void monitoredItemUnlinked(const Akonadi::Item &, const Akonadi::Collection &);
96
97 void monitoredMimeTypeChanged(const QString &mimeType, bool monitored);
98 void monitoredCollectionsChanged(const Akonadi::Collection &collection, bool monitored);
99 void monitoredItemsChanged(const Akonadi::Item &item, bool monitored);
100 void monitoredResourcesChanged(const QByteArray &resource, bool monitored);
101
102 Collection::List getParentCollections(const Item &item) const;
103 void removeChildEntities(Collection::Id collectionId);
104
108 QStringList childCollectionNames(const Collection &collection) const;
109
113 void retrieveAncestors(const Akonadi::Collection &collection, bool insertBaseCollection = true);
114 void ancestorsFetched(const Akonadi::Collection::List &collectionList);
115 void insertCollection(const Akonadi::Collection &collection, const Akonadi::Collection &parent);
116 void insertPendingCollection(const Akonadi::Collection &collection, const Akonadi::Collection &parent, QMutableListIterator<Collection> &it);
117
118 void beginResetModel();
119 void endResetModel();
124 void fillModel();
125
126 void changeFetchState(const Collection &parent);
127 void agentInstanceRemoved(const Akonadi::AgentInstance &instace);
128
129 QHash<Collection::Id, Collection> m_collections;
130 QHash<Entity::Id, Item> m_items;
131 QHash<Collection::Id, QList<Node *> > m_childEntities;
132 QSet<Collection::Id> m_populatedCols;
133 QSet<Collection::Id> m_collectionsWithoutItems;
134
135 QVector<Entity::Id> m_pendingCutItems;
136 QVector<Entity::Id> m_pendingCutCollections;
137 mutable QSet<Collection::Id> m_pendingCollectionRetrieveJobs;
138
139 ChangeRecorder *m_monitor;
140 Collection m_rootCollection;
141 Node *m_rootNode;
142 QString m_rootCollectionDisplayName;
143 QStringList m_mimeTypeFilter;
144 MimeTypeChecker m_mimeChecker;
145 EntityTreeModel::CollectionFetchStrategy m_collectionFetchStrategy;
146 EntityTreeModel::ItemPopulationStrategy m_itemPopulation;
147 CollectionFetchScope::ListFilter m_listFilter;
148 bool m_includeStatistics;
149 bool m_showRootCollection;
150 bool m_collectionTreeFetched;
151
162 void startFirstListJob();
163
164 void serverStarted();
165
166 void monitoredItemsRetrieved(KJob *job);
167 void rootFetchJobDone(KJob *job);
168 void collectionFetchJobDone(KJob *job);
169 void itemFetchJobDone(KJob *job);
170 void finalCollectionFetchJobDone(KJob *job);
171 void updateJobDone(KJob *job);
172 void pasteJobDone(KJob *job);
173
177 template<Node::Type Type>
178 int indexOf(const QList<Node *> &nodes, Entity::Id id) const
179 {
180 int i = 0;
181 foreach (const Node *node, nodes) {
182 if (node->id == id && node->type == Type) {
183 return i;
184 }
185 i++;
186 }
187
188 return -1;
189 }
190
195 static QByteArray FetchCollectionId() {
196 return "FetchCollectionId";
197 }
198
199 Session *m_session;
200
201 Q_DECLARE_PUBLIC(EntityTreeModel)
202
203 void fetchTopLevelCollections() const;
204 void topLevelCollectionsFetched(const Akonadi::Collection::List &collectionList);
205
209 bool isHidden(const Entity &entity, Node::Type type) const;
210
211 template<typename T>
212 bool isHidden(const T &entity) const;
213
214 bool m_showSystemEntities;
215
216 void ref(Collection::Id id);
217 void deref(Collection::Id id);
218
224 bool isMonitored(Collection::Id id);
225
231 bool isBuffered(Collection::Id id);
232
236 bool shouldPurge(Collection::Id id);
237
241 void purgeItems(Collection::Id id);
242
250 QList<Node *>::iterator removeItems(QList<Node *>::iterator it, QList<Node *>::iterator end,
251 int *pos, const Collection &col);
252
260 QList<Node *>::iterator skipCollections(QList<Node *>::iterator it, QList<Node *>::iterator end, int *pos);
261
265 void dataChanged(const QModelIndex &top, const QModelIndex &bottom);
266
270 QModelIndex indexForCollection(const Collection &collection) const;
271
275 QModelIndexList indexesForItem(const Item &item) const;
276
277 bool canFetchMore(const QModelIndex &parent) const;
278
286 bool shouldBePartOfModel(const Collection &collection) const;
287 bool hasChildCollection(const Collection &collection) const;
288 bool isAncestorMonitored(const Collection &collection) const;
289};
290
291}
292
293#endif
Akonadi::AgentInstance
A representation of an agent instance.
Definition agentinstance.h:63
Akonadi::ChangeRecorder
Records and replays change notification.
Definition changerecorder.h:48
Akonadi::CollectionFetchJob
Job that fetches collections from the Akonadi storage.
Definition collectionfetchjob.h:54
Akonadi::CollectionFetchJob::Type
Type
Describes the type of fetch depth.
Definition collectionfetchjob.h:61
Akonadi::CollectionFetchScope::ListFilter
ListFilter
Describes the list filter.
Definition collectionfetchscope.h:132
Akonadi::CollectionStatistics
Provides statistics information of a Collection.
Definition collectionstatistics.h:70
Akonadi::Collection
Represents a collection of PIM items.
Definition collection.h:76
Akonadi::Collection::List
QList< Collection > List
Describes a list of collections.
Definition collection.h:81
Akonadi::EntityTreeModelPrivate
Definition entitytreemodel_p.h:60
Akonadi::EntityTreeModelPrivate::skipCollections
QList< Node * >::iterator skipCollections(QList< Node * >::iterator it, QList< Node * >::iterator end, int *pos)
Skips over Collections in m_childEntities up to a maximum of end.
Akonadi::EntityTreeModelPrivate::childCollectionNames
QStringList childCollectionNames(const Collection &collection) const
Returns the list of names of the child collections of collection.
Akonadi::EntityTreeModelPrivate::FetchCollectionId
static QByteArray FetchCollectionId()
The id of the collection which starts an item fetch job.
Definition entitytreemodel_p.h:195
Akonadi::EntityTreeModelPrivate::retrieveAncestors
void retrieveAncestors(const Akonadi::Collection &collection, bool insertBaseCollection=true)
Fetch parent collections and insert this collection and its parents into the node tree.
Akonadi::EntityTreeModelPrivate::dataChanged
void dataChanged(const QModelIndex &top, const QModelIndex &bottom)
Emits the data changed signal for the entire row as in the subclass, instead of just for the first co...
Akonadi::EntityTreeModelPrivate::purgeItems
void purgeItems(Collection::Id id)
Purges the items in the Collection id.
Akonadi::EntityTreeModelPrivate::indexesForItem
QModelIndexList indexesForItem(const Item &item) const
Returns the model indexes for the given item.
Akonadi::EntityTreeModelPrivate::startFirstListJob
void startFirstListJob()
Called after the root collection was fetched by fillModel.
Akonadi::EntityTreeModelPrivate::isMonitored
bool isMonitored(Collection::Id id)
Akonadi::EntityTreeModelPrivate::indexOf
int indexOf(const QList< Node * > &nodes, Entity::Id id) const
Returns the index of the node in list with the id id.
Definition entitytreemodel_p.h:178
Akonadi::EntityTreeModelPrivate::shouldPurge
bool shouldPurge(Collection::Id id)
Akonadi::EntityTreeModelPrivate::indexForCollection
QModelIndex indexForCollection(const Collection &collection) const
Returns the model index for the given collection.
Akonadi::EntityTreeModelPrivate::removeItems
QList< Node * >::iterator removeItems(QList< Node * >::iterator it, QList< Node * >::iterator end, int *pos, const Collection &col)
Removes the items starting from it and up to a maximum of end in Collection col.
Akonadi::EntityTreeModelPrivate::fillModel
void fillModel()
Start function for filling the Model, finds and fetches the root of the node tree Next relevant funct...
Akonadi::EntityTreeModelPrivate::isHidden
bool isHidden(const Entity &entity, Node::Type type) const
Akonadi::EntityTreeModelPrivate::shouldBePartOfModel
bool shouldBePartOfModel(const Collection &collection) const
Returns true if the collection matches all filters and should be part of the model.
Akonadi::EntityTreeModelPrivate::isBuffered
bool isBuffered(Collection::Id id)
Akonadi::EntityTreeModel
A model for collections and items together.
Definition entitytreemodel.h:319
Akonadi::EntityTreeModel::ItemPopulationStrategy
ItemPopulationStrategy
Describes how the model should populated its items.
Definition entitytreemodel.h:408
Akonadi::EntityTreeModel::CollectionFetchStrategy
CollectionFetchStrategy
Describes what collections shall be fetched by and represent in the model.
Definition entitytreemodel.h:527
Akonadi::Entity
The base class for Item and Collection.
Definition entity.h:60
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition entity.h:65
Akonadi::MimeTypeChecker
Helper for checking MIME types of Collections and Items.
Definition mimetypechecker.h:110
Akonadi::Session
A communication session with the Akonadi storage.
Definition session.h:60
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal