• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 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 #include <QTime>
26 
27 #include <akonadi/collectionfetchjob.h>
28 #include <akonadi/itemfetchscope.h>
29 #include <akonadi/mimetypechecker.h>
30 
31 #include "entitytreemodel.h"
32 
33 #include "akonadiprivate_export.h"
34 
35 namespace Akonadi
36 {
37 class ItemFetchJob;
38 class ChangeRecorder;
39 class AgentInstance;
40 }
41 
42 struct Node
43 {
44  Akonadi::Entity::Id id;
45  Akonadi::Entity::Id parent;
46 
47  enum Type
48  {
49  Item,
50  Collection
51  };
52 
53  int type;
54 };
55 
56 namespace Akonadi
57 {
61 class AKONADI_TESTS_EXPORT EntityTreeModelPrivate
62 {
63 public:
64 
65  EntityTreeModelPrivate( EntityTreeModel *parent );
66  ~EntityTreeModelPrivate();
67  EntityTreeModel * const q_ptr;
68 
69  enum RetrieveDepth {
70  Base,
71  Recursive
72  };
73 
74  enum ListingOrder
75  {
76  NotFirstListing,
77  FirstListing
78  };
79 
80  void init( ChangeRecorder *monitor );
81 
82  void fetchCollections( const Collection &collection, CollectionFetchJob::Type = CollectionFetchJob::FirstLevel, ListingOrder = NotFirstListing );
83  void fetchItems( const Collection &collection );
84  void collectionsFetched( const Akonadi::Collection::List& );
85  void allCollectionsFetched( const Akonadi::Collection::List& );
86  void firstCollectionsFetched( const Akonadi::Collection::List& );
87  void collectionListFetched( const Akonadi::Collection::List& );
88  void itemsFetched( KJob* );
89  void itemsFetched( const Akonadi::Item::List &items );
90  void itemsFetched( const Collection::Id collectionId, const Akonadi::Item::List &items );
91 
92  void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& );
93  void monitoredCollectionRemoved( const Akonadi::Collection& );
94  void monitoredCollectionChanged( const Akonadi::Collection& );
95  void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id, const Akonadi::CollectionStatistics& );
96  void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& );
97 
98  void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& );
99  void monitoredCollectionUnsubscribed( const Akonadi::Collection& );
100 
101  void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& );
102  void monitoredItemRemoved( const Akonadi::Item& );
103  void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& );
104  void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& );
105 
106  void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& );
107  void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& );
108 
109  void monitoredMimeTypeChanged( const QString &mimeType, bool monitored );
110  void monitoredCollectionsChanged( const Akonadi::Collection &collection, bool monitored );
111  void monitoredItemsChanged( const Akonadi::Item &item, bool monitored );
112  void monitoredResourcesChanged( const QByteArray &resource, bool monitored );
113 
114  Collection::List getParentCollections( const Item &item ) const;
115  void removeChildEntities( Collection::Id collectionId );
116 
120  QStringList childCollectionNames( const Collection &collection ) const;
121 
125  void retrieveAncestors( const Akonadi::Collection& collection );
126  void ancestorsFetched( const Akonadi::Collection::List& collectionList );
127  void insertCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent );
128  void insertPendingCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent, QMutableListIterator<Collection> &it );
129 
130  void beginResetModel();
131  void endResetModel();
136  void fillModel();
137 
138  ItemFetchJob* getItemFetchJob( const Collection &parent, const ItemFetchScope &scope ) const;
139  ItemFetchJob* getItemFetchJob( const Item &item, const ItemFetchScope &scope ) const;
140  void runItemFetchJob( ItemFetchJob* itemFetchJob, const Collection &parent ) const;
141  void changeFetchState( const Collection &parent );
142  void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& );
143  void agentInstanceRemoved( const Akonadi::AgentInstance &instace );
144 
145  QHash<Collection::Id, Collection> m_collections;
146  QHash<Entity::Id, Item> m_items;
147  QHash<Collection::Id, QList<Node*> > m_childEntities;
148  QSet<Collection::Id> m_populatedCols;
149  QSet<Collection::Id> m_collectionsWithoutItems;
150 
151  QVector<Entity::Id> m_pendingCutItems;
152  QVector<Entity::Id> m_pendingCutCollections;
153  mutable QSet<Collection::Id> m_pendingCollectionRetrieveJobs;
154 
155  ChangeRecorder *m_monitor;
156  Collection m_rootCollection;
157  Node *m_rootNode;
158  QString m_rootCollectionDisplayName;
159  QStringList m_mimeTypeFilter;
160  MimeTypeChecker m_mimeChecker;
161  EntityTreeModel::CollectionFetchStrategy m_collectionFetchStrategy;
162  EntityTreeModel::ItemPopulationStrategy m_itemPopulation;
163  bool m_includeUnsubscribed;
164  bool m_includeStatistics;
165  bool m_showRootCollection;
166  bool m_collectionTreeFetched;
167  QHash<Collection::Id, uint> m_collectionSyncProgress;
168 
179  void startFirstListJob();
180 
181  void serverStarted();
182 
183  void monitoredItemsRetrieved( KJob* job );
184  void firstFetchJobDone( KJob *job );
185  void rootFetchJobDone( KJob *job );
186  void fetchJobDone( KJob *job );
187  void updateJobDone( KJob *job );
188  void pasteJobDone( KJob *job );
189 
193  template<Node::Type Type>
194  int indexOf( const QList<Node*> &nodes, Entity::Id id ) const
195  {
196  int i = 0;
197  foreach ( const Node *node, nodes ) {
198  if ( node->id == id && node->type == Type )
199  {
200  return i;
201  }
202  i++;
203  }
204 
205  return -1;
206  }
207 
212  static QByteArray FetchCollectionId() {
213  return "FetchCollectionId";
214  }
215 
216  Session *m_session;
217 
218  Q_DECLARE_PUBLIC( EntityTreeModel )
219 
220  void fetchTopLevelCollections() const;
221  void topLevelCollectionsFetched( const Akonadi::Collection::List& collectionList );
222 
226  bool isHidden( const Entity &entity, Node::Type type ) const;
227 
228  template<typename T>
229  bool isHidden( const T &entity ) const;
230 
231  bool m_showSystemEntities;
232 
233  void ref( Collection::Id id );
234  void deref( Collection::Id id );
235 
239  bool shouldPurge( Collection::Id id );
240 
244  void purgeItems( Collection::Id id );
245 
253  QList<Node*>::iterator removeItems( QList<Node*>::iterator it, QList<Node*>::iterator end,
254  int *pos, const Collection &col );
255 
263  QList<Node*>::iterator skipCollections( QList<Node*>::iterator it, QList<Node*>::iterator end, int *pos );
264 
268  void dataChanged( const QModelIndex &top, const QModelIndex &bottom );
269 
273  QModelIndex indexForCollection( const Collection &collection ) const;
274 
278  QModelIndexList indexesForItem( const Item &item ) const;
279 
283  Collection collectionForId( Collection::Id id ) const;
284 
288  Item itemForId( Item::Id id ) const;
289 
290  bool canFetchMore( const QModelIndex & parent ) const;
291 };
292 
293 }
294 
295 #endif
296 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:36 by doxygen 1.8.3.1 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.10.5 API Reference

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