• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.4 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 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  QHash<Collection::Id, uint> m_collectionSyncProgress;
166 
177  void startFirstListJob();
178 
179  void serverStarted();
180 
181  void monitoredItemsRetrieved( KJob* job );
182  void firstFetchJobDone( KJob *job );
183  void rootFetchJobDone( KJob *job );
184  void fetchJobDone( KJob *job );
185  void updateJobDone( KJob *job );
186  void pasteJobDone( KJob *job );
187 
191  template<Node::Type Type>
192  int indexOf( const QList<Node*> &nodes, Entity::Id id ) const
193  {
194  int i = 0;
195  foreach ( const Node *node, nodes ) {
196  if ( node->id == id && node->type == Type )
197  {
198  return i;
199  }
200  i++;
201  }
202 
203  return -1;
204  }
205 
210  static QByteArray FetchCollectionId() {
211  return "FetchCollectionId";
212  }
213 
214  Session *m_session;
215 
216  Q_DECLARE_PUBLIC( EntityTreeModel )
217 
218  void fetchTopLevelCollections() const;
219  void topLevelCollectionsFetched( const Akonadi::Collection::List& collectionList );
220 
224  bool isHidden( const Entity &entity, Node::Type type ) const;
225 
226  template<typename T>
227  bool isHidden( const T &entity ) const;
228 
229  bool m_showSystemEntities;
230 
231  void ref( Collection::Id id );
232  void deref( Collection::Id id );
233 
237  bool shouldPurge( Collection::Id id );
238 
242  void purgeItems( Collection::Id id );
243 
251  QList<Node*>::iterator removeItems( QList<Node*>::iterator it, QList<Node*>::iterator end,
252  int *pos, const Collection &col );
253 
261  QList<Node*>::iterator skipCollections( QList<Node*>::iterator it, QList<Node*>::iterator end, int *pos );
262 
266  void dataChanged( const QModelIndex &top, const QModelIndex &bottom );
267 
271  QModelIndex indexForCollection( const Collection &collection ) const;
272 
276  QModelIndexList indexesForItem( const Item &item ) const;
277 
281  Collection collectionForId( Collection::Id id ) const;
282 
286  Item itemForId( Item::Id id ) const;
287 
288  bool canFetchMore( const QModelIndex & parent ) const;
289 };
290 
291 }
292 
293 #endif
294 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Dec 10 2012 13:48:09 by doxygen 1.8.1.2 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.9.4 API Reference

Skip menu "kdepimlibs-4.9.4 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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