• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • 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   EntityTreeModel *q_ptr;
00066 
00067   enum RetrieveDepth {
00068     Base,
00069     Recursive
00070   };
00071 
00072   void init( ChangeRecorder *monitor );
00073 
00074   void fetchCollections( const Collection &collection, CollectionFetchJob::Type = CollectionFetchJob::FirstLevel );
00075   void fetchItems( const Collection &collection );
00076   void collectionsFetched( const Akonadi::Collection::List& );
00077   void collectionListFetched( const Akonadi::Collection::List& );
00078   void itemsFetched( const Akonadi::Item::List& );
00079 
00080   void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& );
00081   void monitoredCollectionRemoved( const Akonadi::Collection& );
00082   void monitoredCollectionChanged( const Akonadi::Collection& );
00083   void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id, const Akonadi::CollectionStatistics& );
00084   void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& );
00085   void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& );
00086   void monitoredItemRemoved( const Akonadi::Item& );
00087   void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& );
00088   void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& );
00089 
00090   void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& );
00091   void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& );
00092 
00093   void monitoredMimeTypeChanged( const QString &mimeType, bool monitored );
00094   void monitoredCollectionsChanged( const Akonadi::Collection &colllection, bool monitored );
00095 
00096   Collection::List getParentCollections( const Item &item ) const;
00097   Collection getParentCollection( const Collection &collection ) const;
00098   Entity::Id childAt( Collection::Id, int position, bool *ok ) const;
00099   Item getItem( Item::Id id ) const;
00100   void removeChildEntities( Collection::Id collectionId );
00101   void retrieveAncestors( const Akonadi::Collection& collection );
00102   void ancestorsFetched( const Akonadi::Collection::List& collectionList );
00103   void insertCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent );
00104   void insertPendingCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent, QMutableListIterator<Collection> &it );
00105 
00106   void beginResetModel();
00107   void endResetModel();
00108   void fillModel();
00109 
00110   ItemFetchJob* getItemFetchJob( const Collection &parent, const ItemFetchScope &scope ) const;
00111   ItemFetchJob* getItemFetchJob( const Item &item, const ItemFetchScope &scope ) const;
00112   void runItemFetchJob( ItemFetchJob* itemFetchJob, const Collection &parent ) const;
00113 
00114   QHash<Collection::Id, Collection> m_collections;
00115   QHash<Entity::Id, Item> m_items;
00116   QHash<Collection::Id, QList<Node*> > m_childEntities;
00117   QSet<Collection::Id> m_populatedCols;
00118 
00119   QList<Entity::Id> m_pendingCutItems;
00120   QList<Entity::Id> m_pendingCutCollections;
00121   mutable QSet<Collection::Id> m_pendingCollectionRetrieveJobs;
00122 
00123   ChangeRecorder *m_monitor;
00124   Collection m_rootCollection;
00125   Node *m_rootNode;
00126   QString m_rootCollectionDisplayName;
00127   QStringList m_mimeTypeFilter;
00128   MimeTypeChecker m_mimeChecker;
00129   EntityTreeModel::CollectionFetchStrategy m_collectionFetchStrategy;
00130   EntityTreeModel::ItemPopulationStrategy m_itemPopulation;
00131   bool m_includeUnsubscribed;
00132   bool m_includeStatistics;
00133   bool m_showRootCollection;
00134 
00135   void rootCollectionFetched( const Collection::List &list );
00136   void startFirstListJob();
00137 
00138   void serverStarted();
00139 
00140   void fetchJobDone( KJob *job );
00141   void updateJobDone( KJob *job );
00142   void pasteJobDone( KJob *job );
00143 
00147   template<Node::Type Type>
00148   int indexOf( const QList<Node*> &nodes, Entity::Id id ) const
00149   {
00150     int i = 0;
00151     foreach ( const Node *node, nodes ) {
00152       if ( node->id == id && node->type == Type )
00153       {
00154         return i;
00155       }
00156       i++;
00157     }
00158 
00159     return -1;
00160   }
00161 
00166   static QByteArray FetchCollectionId() {
00167     return "FetchCollectionId";
00168   }
00169 
00170   Session *m_session;
00171 
00172   Q_DECLARE_PUBLIC( EntityTreeModel )
00173 
00174   void fetchTopLevelCollections() const;
00175   void topLevelCollectionsFetched( const Akonadi::Collection::List& collectionList );
00176 
00180   bool isHidden( const Entity &entity ) const;
00181 
00182   bool m_showSystemEntities;
00183 
00184   void ref( Collection::Id id );
00185   void deref( Collection::Id id );
00186 
00190   bool shouldPurge( Collection::Id id );
00191 
00195   void purgeItems( Collection::Id id );
00196 
00204   QList<Node*>::iterator removeItems( QList<Node*>::iterator it, QList<Node*>::iterator end,
00205                                       int *pos, const Collection &col );
00206 
00214   QList<Node*>::iterator skipCollections( QList<Node*>::iterator it, QList<Node*>::iterator end, int *pos );
00215 
00219   void dataChanged( const QModelIndex &top, const QModelIndex &bottom );
00220 
00224   QModelIndex indexForCollection( const Collection &collection ) const;
00225 
00229   QModelIndexList indexesForItem( const Item &item ) const;
00230 
00234   Collection collectionForId( Collection::Id id ) const;
00235 
00239   Item itemForId( Item::Id id ) const;
00240 
00241   bool canFetchMore( const QModelIndex & parent ) const;
00242 };
00243 
00244 }
00245 
00246 #endif
00247 

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
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • 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.1
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