• Skip to content
  • Skip to link menu
KDE 4.4 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 
00026 #include <akonadi/collectionfetchjob.h>
00027 #include <akonadi/itemfetchscope.h>
00028 #include <akonadi/mimetypechecker.h>
00029 
00030 #include "entitytreemodel.h"
00031 
00032 #include "akonadiprivate_export.h"
00033 
00034 namespace Akonadi
00035 {
00036 class ItemFetchJob;
00037 class ChangeRecorder;
00038 }
00039 
00040 struct Node
00041 {
00042   Akonadi::Entity::Id id;
00043   Akonadi::Entity::Id parent;
00044 
00045   enum Type
00046   {
00047     Item,
00048     Collection
00049   };
00050 
00051   int type;
00052 };
00053 
00054 namespace Akonadi
00055 {
00059 class AKONADI_TESTS_EXPORT EntityTreeModelPrivate
00060 {
00061 public:
00062 
00063   EntityTreeModelPrivate( EntityTreeModel *parent );
00064   EntityTreeModel *q_ptr;
00065 
00066 //   void collectionStatisticsChanged( Collection::Id, const Akonadi::CollectionStatistics& );
00067 
00068   enum RetrieveDepth {
00069     Base,
00070     Recursive
00071   };
00072 
00073   void init( ChangeRecorder *monitor );
00074 
00075   void fetchCollections( const Collection &collection, CollectionFetchJob::Type = CollectionFetchJob::FirstLevel );
00076   void fetchItems( const Collection &collection );
00077   void collectionsFetched( const Akonadi::Collection::List& );
00078 //   void resourceTopCollectionsFetched( const Akonadi::Collection::List& );
00079   void itemsFetched( const Akonadi::Item::List& );
00080 
00081   void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& );
00082   void monitoredCollectionRemoved( const Akonadi::Collection& );
00083   void monitoredCollectionChanged( const Akonadi::Collection& );
00084   void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id, const Akonadi::CollectionStatistics& );
00085   void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, const Akonadi::Collection& );
00086   void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& );
00087   void monitoredItemRemoved( const Akonadi::Item& );
00088   void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& );
00089   void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&, const Akonadi::Collection& );
00090 
00091   void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& );
00092   void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& );
00093 
00094   void monitoredMimeTypeChanged( const QString &mimeType, bool monitored );
00095 
00096   Collection getParentCollection( Entity::Id id ) const;
00097   Collection::List getParentCollections( const Item &item ) const;
00098   Collection getParentCollection( const Collection &collection ) const;
00099   Entity::Id childAt( Collection::Id, int position, bool *ok ) const;
00100   int indexOf( Collection::Id parent, Collection::Id id ) const;
00101   Item getItem( Item::Id id ) const;
00102   void removeChildEntities( Collection::Id collectionId );
00103   void retrieveAncestors( const Akonadi::Collection& collection );
00104   void ancestorsFetched( const Akonadi::Collection::List& collectionList );
00105   void insertCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent );
00106   void insertPendingCollection( const Akonadi::Collection &collection, const Akonadi::Collection& parent, QMutableListIterator<Collection> &it );
00107 
00108   void beginResetModel();
00109   void endResetModel();
00110   void fillModel();
00111 
00112   ItemFetchJob* getItemFetchJob( const Collection &parent, const ItemFetchScope &scope ) const;
00113   ItemFetchJob* getItemFetchJob( const Item &item, const ItemFetchScope &scope ) const;
00114   void runItemFetchJob( ItemFetchJob* itemFetchJob, const Collection &parent ) const;
00115 
00116   QHash<Collection::Id, Collection> m_collections;
00117   QHash<Entity::Id, Item> m_items;
00118   QHash<Collection::Id, QList<Node*> > m_childEntities;
00119   QSet<Collection::Id> m_populatedCols;
00120 
00121   QList<Entity::Id> m_pendingCutItems;
00122   QList<Entity::Id> m_pendingCutCollections;
00123 
00124   ChangeRecorder *m_monitor;
00125   Collection m_rootCollection;
00126   Node *m_rootNode;
00127   QString m_rootCollectionDisplayName;
00128   QStringList m_mimeTypeFilter;
00129   MimeTypeChecker m_mimeChecker;
00130   EntityTreeModel::CollectionFetchStrategy m_collectionFetchStrategy;
00131   EntityTreeModel::ItemPopulationStrategy m_itemPopulation;
00132   bool m_includeUnsubscribed;
00133   bool m_includeStatistics;
00134   bool m_showRootCollection;
00135 
00136   void rootCollectionFetched( const Collection::List &list );
00137   void startFirstListJob();
00138 
00139   void fetchJobDone( KJob *job );
00140   void updateJobDone( KJob *job );
00141   void pasteJobDone( KJob *job );
00142 
00146   int indexOf( const QList<Node*> &list, Entity::Id id ) const;
00147 
00152   static QByteArray ItemFetchCollectionId() {
00153     return "ItemFetchCollectionId";
00154   }
00155 
00156   Session *m_session;
00157 
00158   Q_DECLARE_PUBLIC( EntityTreeModel )
00159 
00160   void fetchTopLevelCollections() const;
00161   void topLevelCollectionsFetched( const Akonadi::Collection::List& collectionList );
00162 
00166   bool isHidden( const Entity &entity ) const;
00167 
00168   bool m_showSystemEntities;
00169 
00170   void ref( Collection::Id id );
00171   void deref( Collection::Id id );
00172 
00176   bool shouldPurge( Collection::Id id );
00177 
00181   void purgeItems( Collection::Id id );
00182 
00190   QList<Node*>::iterator removeItems( QList<Node*>::iterator it, QList<Node*>::iterator end,
00191                                       int *pos, const Collection &col );
00192 
00200   QList<Node*>::iterator skipCollections( QList<Node*>::iterator it, QList<Node*>::iterator end, int *pos );
00201 
00205   void dataChanged( const QModelIndex &top, const QModelIndex &bottom );
00206 
00210   QModelIndex indexForCollection( const Collection &collection ) const;
00211 
00215   QModelIndexList indexesForItem( const Item &item ) const;
00216 
00220   Collection collectionForId( Collection::Id id ) const;
00221 
00225   Item itemForId( Item::Id id ) const;
00226 };
00227 
00228 }
00229 
00230 #endif
00231 

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.6.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