• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • 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 }
00040 
00041 struct Node
00042 {
00043   Akonadi::Entity::Id id;
00044   Akonadi::Entity::Id parent;
00045 
00046   enum Type
00047   {
00048     Item,
00049     Collection
00050   };
00051 
00052   int type;
00053 };
00054 
00055 namespace Akonadi
00056 {
00060 class AKONADI_TESTS_EXPORT EntityTreeModelPrivate
00061 {
00062 public:
00063 
00064   EntityTreeModelPrivate( EntityTreeModel *parent );
00065   ~EntityTreeModelPrivate();
00066   EntityTreeModel *q_ptr;
00067 
00068   enum RetrieveDepth {
00069     Base,
00070     Recursive
00071   };
00072 
00073   enum ListingOrder
00074   {
00075     NotFirstListing,
00076     FirstListing
00077   };
00078 
00079   void init( ChangeRecorder *monitor );
00080 
00081   void fetchCollections( const Collection &collection, CollectionFetchJob::Type = CollectionFetchJob::FirstLevel, ListingOrder = NotFirstListing );
00082   void fetchItems( const Collection &collection );
00083   void collectionsFetched( const Akonadi::Collection::List& );
00084   void firstCollectionsFetched( const Akonadi::Collection::List& );
00085   void collectionListFetched( const Akonadi::Collection::List& );
00086   void itemsFetched( const Akonadi::Item::List& );
00087 
00088   void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& );
00089   void monitoredCollectionRemoved( const Akonadi::Collection& );
00090   void monitoredCollectionChanged( const Akonadi::Collection& );
00091   void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id, const Akonadi::CollectionStatistics& );
00092   void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& );
00093 
00094   void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& );
00095   void monitoredCollectionUnsubscribed( const Akonadi::Collection& );
00096 
00097   void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& );
00098   void monitoredItemRemoved( const Akonadi::Item& );
00099   void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& );
00100   void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& );
00101 
00102   void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& );
00103   void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& );
00104 
00105   void monitoredMimeTypeChanged( const QString &mimeType, bool monitored );
00106   void monitoredCollectionsChanged( const Akonadi::Collection &colllection, bool monitored );
00107 
00108   Collection::List getParentCollections( const Item &item ) const;
00109   Collection getParentCollection( const Collection &collection ) const;
00110   Entity::Id childAt( Collection::Id, int position, bool *ok ) const;
00111   Item getItem( Item::Id id ) const;
00112   void removeChildEntities( Collection::Id collectionId );
00113   void retrieveAncestors( const Akonadi::Collection& collection );
00114   void ancestorsFetched( const Akonadi::Collection::List& collectionList );
00115   void insertCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent );
00116   void insertPendingCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent, QMutableListIterator<Collection> &it );
00117 
00118   void beginResetModel();
00119   void endResetModel();
00120   void fillModel();
00121 
00122   ItemFetchJob* getItemFetchJob( const Collection &parent, const ItemFetchScope &scope ) const;
00123   ItemFetchJob* getItemFetchJob( const Item &item, const ItemFetchScope &scope ) const;
00124   void runItemFetchJob( ItemFetchJob* itemFetchJob, const Collection &parent ) const;
00125   void changeFetchState( const Collection &parent );
00126   void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& );
00127 
00128   QHash<Collection::Id, Collection> m_collections;
00129   QHash<Entity::Id, Item> m_items;
00130   QHash<Collection::Id, QList<Node*> > m_childEntities;
00131   QSet<Collection::Id> m_populatedCols;
00132 
00133   QVector<Entity::Id> m_pendingCutItems;
00134   QVector<Entity::Id> m_pendingCutCollections;
00135   mutable QSet<Collection::Id> m_pendingCollectionRetrieveJobs;
00136 
00137   ChangeRecorder *m_monitor;
00138   Collection m_rootCollection;
00139   Node *m_rootNode;
00140   QString m_rootCollectionDisplayName;
00141   QStringList m_mimeTypeFilter;
00142   MimeTypeChecker m_mimeChecker;
00143   EntityTreeModel::CollectionFetchStrategy m_collectionFetchStrategy;
00144   EntityTreeModel::ItemPopulationStrategy m_itemPopulation;
00145   bool m_includeUnsubscribed;
00146   bool m_includeStatistics;
00147   bool m_showRootCollection;
00148   QHash<Collection::Id, uint> m_collectionSyncProgress;
00149 
00150   void rootCollectionFetched( const Collection::List &list );
00151   void startFirstListJob();
00152 
00153   void serverStarted();
00154 
00155   void firstFetchJobDone( KJob *job );
00156   void fetchJobDone( KJob *job );
00157   void updateJobDone( KJob *job );
00158   void pasteJobDone( KJob *job );
00159 
00163   template<Node::Type Type>
00164   int indexOf( const QList<Node*> &nodes, Entity::Id id ) const
00165   {
00166     int i = 0;
00167     foreach ( const Node *node, nodes ) {
00168       if ( node->id == id && node->type == Type )
00169       {
00170         return i;
00171       }
00172       i++;
00173     }
00174 
00175     return -1;
00176   }
00177 
00182   static QByteArray FetchCollectionId() {
00183     return "FetchCollectionId";
00184   }
00185 
00186   Session *m_session;
00187 
00188   Q_DECLARE_PUBLIC( EntityTreeModel )
00189 
00190   void fetchTopLevelCollections() const;
00191   void topLevelCollectionsFetched( const Akonadi::Collection::List& collectionList );
00192 
00196   bool isHidden( const Entity &entity ) const;
00197 
00198   bool m_showSystemEntities;
00199 
00200   void ref( Collection::Id id );
00201   void deref( Collection::Id id );
00202 
00206   bool shouldPurge( Collection::Id id );
00207 
00211   void purgeItems( Collection::Id id );
00212 
00220   QList<Node*>::iterator removeItems( QList<Node*>::iterator it, QList<Node*>::iterator end,
00221                                       int *pos, const Collection &col );
00222 
00230   QList<Node*>::iterator skipCollections( QList<Node*>::iterator it, QList<Node*>::iterator end, int *pos );
00231 
00235   void dataChanged( const QModelIndex &top, const QModelIndex &bottom );
00236 
00240   QModelIndex indexForCollection( const Collection &collection ) const;
00241 
00245   QModelIndexList indexesForItem( const Item &item ) const;
00246 
00250   Collection collectionForId( Collection::Id id ) const;
00251 
00255   Item itemForId( Item::Id id ) const;
00256 
00257   bool canFetchMore( const QModelIndex & parent ) const;
00258 };
00259 
00260 }
00261 
00262 #endif
00263 

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • 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
Generated for KDE-PIM Libraries by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal