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

akonadi

entitytreemodel_p.h
00001 /*
00002     Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #ifndef ENTITYTREEMODELPRIVATE_H
00021 #define ENTITYTREEMODELPRIVATE_H
00022 
00023 #include <akonadi/item.h>
00024 #include <KJob>
00025 #include <QTime>
00026 
00027 #include <akonadi/collectionfetchjob.h>
00028 #include <akonadi/itemfetchscope.h>
00029 #include <akonadi/mimetypechecker.h>
00030 
00031 #include "entitytreemodel.h"
00032 
00033 #include "akonadiprivate_export.h"
00034 
00035 namespace Akonadi
00036 {
00037 class ItemFetchJob;
00038 class ChangeRecorder;
00039 class AgentInstance;
00040 }
00041 
00042 struct Node
00043 {
00044   Akonadi::Entity::Id id;
00045   Akonadi::Entity::Id parent;
00046 
00047   enum Type
00048   {
00049     Item,
00050     Collection
00051   };
00052 
00053   int type;
00054 };
00055 
00056 namespace Akonadi
00057 {
00061 class AKONADI_TESTS_EXPORT EntityTreeModelPrivate
00062 {
00063 public:
00064 
00065   EntityTreeModelPrivate( EntityTreeModel *parent );
00066   ~EntityTreeModelPrivate();
00067   EntityTreeModel * const q_ptr;
00068 
00069   enum RetrieveDepth {
00070     Base,
00071     Recursive
00072   };
00073 
00074   enum ListingOrder
00075   {
00076     NotFirstListing,
00077     FirstListing
00078   };
00079 
00080   void init( ChangeRecorder *monitor );
00081 
00082   void fetchCollections( const Collection &collection, CollectionFetchJob::Type = CollectionFetchJob::FirstLevel, ListingOrder = NotFirstListing );
00083   void fetchItems( const Collection &collection );
00084   void collectionsFetched( const Akonadi::Collection::List& );
00085   void firstCollectionsFetched( const Akonadi::Collection::List& );
00086   void collectionListFetched( const Akonadi::Collection::List& );
00087   void itemsFetched( KJob* );
00088   void itemsFetched( const Akonadi::Item::List &items );
00089   void itemsFetched( const Collection::Id collectionId, const Akonadi::Item::List &items );
00090 
00091   void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& );
00092   void monitoredCollectionRemoved( const Akonadi::Collection& );
00093   void monitoredCollectionChanged( const Akonadi::Collection& );
00094   void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id, const Akonadi::CollectionStatistics& );
00095   void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& );
00096 
00097   void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& );
00098   void monitoredCollectionUnsubscribed( const Akonadi::Collection& );
00099 
00100   void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& );
00101   void monitoredItemRemoved( const Akonadi::Item& );
00102   void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& );
00103   void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& );
00104 
00105   void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& );
00106   void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& );
00107 
00108   void monitoredMimeTypeChanged( const QString &mimeType, bool monitored );
00109   void monitoredCollectionsChanged( const Akonadi::Collection &collection, bool monitored );
00110   void monitoredItemsChanged( const Akonadi::Item &item, bool monitored );
00111   void monitoredResourcesChanged( const QByteArray &resource, bool monitored );
00112 
00113   Collection::List getParentCollections( const Item &item ) const;
00114   void removeChildEntities( Collection::Id collectionId );
00115 
00119   QStringList childCollectionNames( const Collection &collection ) const;
00120 
00124   void retrieveAncestors( const Akonadi::Collection& collection );
00125   void ancestorsFetched( const Akonadi::Collection::List& collectionList );
00126   void insertCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent );
00127   void insertPendingCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent, QMutableListIterator<Collection> &it );
00128 
00129   void beginResetModel();
00130   void endResetModel();
00135   void fillModel();
00136 
00137   ItemFetchJob* getItemFetchJob( const Collection &parent, const ItemFetchScope &scope ) const;
00138   ItemFetchJob* getItemFetchJob( const Item &item, const ItemFetchScope &scope ) const;
00139   void runItemFetchJob( ItemFetchJob* itemFetchJob, const Collection &parent ) const;
00140   void changeFetchState( const Collection &parent );
00141   void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& );
00142   void agentInstanceRemoved( const Akonadi::AgentInstance &instace );
00143 
00144   QHash<Collection::Id, Collection> m_collections;
00145   QHash<Entity::Id, Item> m_items;
00146   QHash<Collection::Id, QList<Node*> > m_childEntities;
00147   QSet<Collection::Id> m_populatedCols;
00148   QSet<Collection::Id> m_collectionsWithoutItems;
00149 
00150   QVector<Entity::Id> m_pendingCutItems;
00151   QVector<Entity::Id> m_pendingCutCollections;
00152   mutable QSet<Collection::Id> m_pendingCollectionRetrieveJobs;
00153 
00154   ChangeRecorder *m_monitor;
00155   Collection m_rootCollection;
00156   Node *m_rootNode;
00157   QString m_rootCollectionDisplayName;
00158   QStringList m_mimeTypeFilter;
00159   MimeTypeChecker m_mimeChecker;
00160   EntityTreeModel::CollectionFetchStrategy m_collectionFetchStrategy;
00161   EntityTreeModel::ItemPopulationStrategy m_itemPopulation;
00162   bool m_includeUnsubscribed;
00163   bool m_includeStatistics;
00164   bool m_showRootCollection;
00165   QHash<Collection::Id, uint> m_collectionSyncProgress;
00166 
00177   void startFirstListJob();
00178 
00179   void serverStarted();
00180 
00181   void monitoredItemsRetrieved( KJob* job );
00182   void firstFetchJobDone( KJob *job );
00183   void rootFetchJobDone( KJob *job );
00184   void fetchJobDone( KJob *job );
00185   void updateJobDone( KJob *job );
00186   void pasteJobDone( KJob *job );
00187 
00191   template<Node::Type Type>
00192   int indexOf( const QList<Node*> &nodes, Entity::Id id ) const
00193   {
00194     int i = 0;
00195     foreach ( const Node *node, nodes ) {
00196       if ( node->id == id && node->type == Type )
00197       {
00198         return i;
00199       }
00200       i++;
00201     }
00202 
00203     return -1;
00204   }
00205 
00210   static QByteArray FetchCollectionId() {
00211     return "FetchCollectionId";
00212   }
00213 
00214   Session *m_session;
00215 
00216   Q_DECLARE_PUBLIC( EntityTreeModel )
00217 
00218   void fetchTopLevelCollections() const;
00219   void topLevelCollectionsFetched( const Akonadi::Collection::List& collectionList );
00220 
00224   bool isHidden( const Entity &entity, Node::Type type ) const;
00225 
00226   template<typename T>
00227   bool isHidden( const T &entity ) const;
00228 
00229   bool m_showSystemEntities;
00230 
00231   void ref( Collection::Id id );
00232   void deref( Collection::Id id );
00233 
00237   bool shouldPurge( Collection::Id id );
00238 
00242   void purgeItems( Collection::Id id );
00243 
00251   QList<Node*>::iterator removeItems( QList<Node*>::iterator it, QList<Node*>::iterator end,
00252                                       int *pos, const Collection &col );
00253 
00261   QList<Node*>::iterator skipCollections( QList<Node*>::iterator it, QList<Node*>::iterator end, int *pos );
00262 
00266   void dataChanged( const QModelIndex &top, const QModelIndex &bottom );
00267 
00271   QModelIndex indexForCollection( const Collection &collection ) const;
00272 
00276   QModelIndexList indexesForItem( const Item &item ) const;
00277 
00281   Collection collectionForId( Collection::Id id ) const;
00282 
00286   Item itemForId( Item::Id id ) const;
00287 
00288   bool canFetchMore( const QModelIndex & parent ) const;
00289 };
00290 
00291 }
00292 
00293 #endif
00294 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:22 by doxygen 1.7.5 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.8.5 API Reference

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