• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.13.3 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 
34 namespace Akonadi
35 {
36 class ItemFetchJob;
37 class ChangeRecorder;
38 class AgentInstance;
39 }
40 
41 struct Node
42 {
43  Akonadi::Entity::Id id;
44  Akonadi::Entity::Id parent;
45 
46  enum Type
47  {
48  Item,
49  Collection
50  };
51 
52  int type;
53 };
54 
55 namespace Akonadi
56 {
60 class AKONADI_TESTS_EXPORT EntityTreeModelPrivate
61 {
62 public:
63 
64  explicit EntityTreeModelPrivate( EntityTreeModel *parent );
65  ~EntityTreeModelPrivate();
66  EntityTreeModel * const q_ptr;
67 
68  enum RetrieveDepth {
69  Base,
70  Recursive
71  };
72 
73  enum ListingOrder
74  {
75  NotFirstListing,
76  FirstListing
77  };
78 
79  void init( ChangeRecorder *monitor );
80 
81  void fetchCollections( const Collection &collection, CollectionFetchJob::Type = CollectionFetchJob::FirstLevel, ListingOrder = NotFirstListing );
82  void fetchItems( const Collection &collection );
83  void collectionsFetched( const Akonadi::Collection::List& );
84  void allCollectionsFetched( const Akonadi::Collection::List& );
85  void firstCollectionsFetched( const Akonadi::Collection::List& );
86  void collectionListFetched( const Akonadi::Collection::List& );
87  void itemsFetched( KJob* );
88  void itemsFetched( const Akonadi::Item::List &items );
89  void itemsFetched( const Collection::Id collectionId, const Akonadi::Item::List &items );
90 
91  void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& );
92  void monitoredCollectionRemoved( const Akonadi::Collection& );
93  void monitoredCollectionChanged( const Akonadi::Collection& );
94  void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id, const Akonadi::CollectionStatistics& );
95  void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& );
96 
97  void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& );
98  void monitoredCollectionUnsubscribed( const Akonadi::Collection& );
99 
100  void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& );
101  void monitoredItemRemoved( const Akonadi::Item& );
102  void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& );
103  void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& );
104 
105  void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& );
106  void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& );
107 
108  void monitoredMimeTypeChanged( const QString &mimeType, bool monitored );
109  void monitoredCollectionsChanged( const Akonadi::Collection &collection, bool monitored );
110  void monitoredItemsChanged( const Akonadi::Item &item, bool monitored );
111  void monitoredResourcesChanged( const QByteArray &resource, bool monitored );
112 
113  Collection::List getParentCollections( const Item &item ) const;
114  void removeChildEntities( Collection::Id collectionId );
115 
119  QStringList childCollectionNames( const Collection &collection ) const;
120 
124  void retrieveAncestors( const Akonadi::Collection& collection );
125  void ancestorsFetched( const Akonadi::Collection::List& collectionList );
126  void insertCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent );
127  void insertPendingCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent, QMutableListIterator<Collection> &it );
128 
129  void beginResetModel();
130  void endResetModel();
135  void fillModel();
136 
137  ItemFetchJob* getItemFetchJob( const Collection &parent, const ItemFetchScope &scope ) const;
138  ItemFetchJob* getItemFetchJob( const Item &item, const ItemFetchScope &scope ) const;
139  void runItemFetchJob( ItemFetchJob* itemFetchJob, const Collection &parent ) const;
140  void changeFetchState( const Collection &parent );
141  void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& );
142  void agentInstanceRemoved( const Akonadi::AgentInstance &instace );
143 
144  QHash<Collection::Id, Collection> m_collections;
145  QHash<Entity::Id, Item> m_items;
146  QHash<Collection::Id, QList<Node*> > m_childEntities;
147  QSet<Collection::Id> m_populatedCols;
148  QSet<Collection::Id> m_collectionsWithoutItems;
149 
150  QVector<Entity::Id> m_pendingCutItems;
151  QVector<Entity::Id> m_pendingCutCollections;
152  mutable QSet<Collection::Id> m_pendingCollectionRetrieveJobs;
153 
154  ChangeRecorder *m_monitor;
155  Collection m_rootCollection;
156  Node *m_rootNode;
157  QString m_rootCollectionDisplayName;
158  QStringList m_mimeTypeFilter;
159  MimeTypeChecker m_mimeChecker;
160  EntityTreeModel::CollectionFetchStrategy m_collectionFetchStrategy;
161  EntityTreeModel::ItemPopulationStrategy m_itemPopulation;
162  bool m_includeUnsubscribed;
163  bool m_includeStatistics;
164  bool m_showRootCollection;
165  bool m_collectionTreeFetched;
166  QHash<Collection::Id, uint> m_collectionSyncProgress;
167 
178  void startFirstListJob();
179 
180  void serverStarted();
181 
182  void monitoredItemsRetrieved( KJob* job );
183  void firstFetchJobDone( KJob *job );
184  void rootFetchJobDone( KJob *job );
185  void fetchJobDone( KJob *job );
186  void updateJobDone( KJob *job );
187  void pasteJobDone( KJob *job );
188 
192  template<Node::Type Type>
193  int indexOf( const QList<Node*> &nodes, Entity::Id id ) const
194  {
195  int i = 0;
196  foreach ( const Node *node, nodes ) {
197  if ( node->id == id && node->type == Type )
198  {
199  return i;
200  }
201  i++;
202  }
203 
204  return -1;
205  }
206 
211  static QByteArray FetchCollectionId() {
212  return "FetchCollectionId";
213  }
214 
215  Session *m_session;
216 
217  Q_DECLARE_PUBLIC( EntityTreeModel )
218 
219  void fetchTopLevelCollections() const;
220  void topLevelCollectionsFetched( const Akonadi::Collection::List& collectionList );
221 
225  bool isHidden( const Entity &entity, Node::Type type ) const;
226 
227  template<typename T>
228  bool isHidden( const T &entity ) const;
229 
230  bool m_showSystemEntities;
231 
232  void ref( Collection::Id id );
233  void deref( Collection::Id id );
234 
240  bool isMonitored( Collection::Id id );
241 
247  bool isBuffered( Collection::Id id );
248 
252  bool shouldPurge( Collection::Id id );
253 
257  void purgeItems( Collection::Id id );
258 
266  QList<Node*>::iterator removeItems( QList<Node*>::iterator it, QList<Node*>::iterator end,
267  int *pos, const Collection &col );
268 
276  QList<Node*>::iterator skipCollections( QList<Node*>::iterator it, QList<Node*>::iterator end, int *pos );
277 
281  void dataChanged( const QModelIndex &top, const QModelIndex &bottom );
282 
286  QModelIndex indexForCollection( const Collection &collection ) const;
287 
291  QModelIndexList indexesForItem( const Item &item ) const;
292 
296  Collection collectionForId( Collection::Id id ) const;
297 
301  Item itemForId( Item::Id id ) const;
302 
303  bool canFetchMore( const QModelIndex & parent ) const;
304 
312  bool shouldBePartOfModel( const Collection &collection ) const;
313 };
314 
315 }
316 
317 #endif
318 
Akonadi::CollectionStatistics
Provides statistics information of a Collection.
Definition: collectionstatistics.h:69
Akonadi::CollectionFetchJob::Type
Type
Describes the type of fetch depth.
Definition: collectionfetchjob.h:61
Akonadi::EntityTreeModel::ItemPopulationStrategy
ItemPopulationStrategy
Describes how the model should populated its items.
Definition: entitytreemodel.h:406
Akonadi::CollectionFetchJob::FirstLevel
Only list direct sub-collections of the base collection.
Definition: collectionfetchjob.h:63
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:193
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
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:109
Akonadi::EntityTreeModelPrivate::FetchCollectionId
static QByteArray FetchCollectionId()
The id of the collection which starts an item fetch job.
Definition: entitytreemodel_p.h:211
Akonadi::Session
A communication session with the Akonadi storage.
Definition: session.h:59
Akonadi::ItemFetchScope
Specifies which parts of an item should be fetched from the Akonadi storage.
Definition: itemfetchscope.h:68
Akonadi::Entity
The base class for Item and Collection.
Definition: entity.h:59
Akonadi::EntityTreeModel
A model for collections and items together.
Definition: entitytreemodel.h:317
Akonadi::ItemFetchJob
Job that fetches items from the Akonadi storage.
Definition: itemfetchjob.h:82
Akonadi::EntityTreeModelPrivate
Definition: entitytreemodel_p.h:60
Akonadi::AgentInstance
A representation of an agent instance.
Definition: agentinstance.h:62
Akonadi::EntityTreeModel::CollectionFetchStrategy
CollectionFetchStrategy
Describes what collections shall be fetched by and represent in the model.
Definition: entitytreemodel.h:484
Akonadi::Collection::List
QList< Collection > List
Describes a list of collections.
Definition: collection.h:81
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Mon Jul 21 2014 08:03:52 by doxygen 1.8.6 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
  • Modules
  • Related Pages

kdepimlibs-4.13.3 API Reference

Skip menu "kdepimlibs-4.13.3 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