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

akonadi

  • akonadi
entitytreemodel.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 AKONADI_ENTITYTREEMODEL_H
21 #define AKONADI_ENTITYTREEMODEL_H
22 
23 #include "akonadi_export.h"
24 
25 #include <akonadi/collection.h>
26 #include <akonadi/collectionfetchscope.h>
27 #include <akonadi/item.h>
28 
29 #include <QtCore/QAbstractItemModel>
30 #include <QtCore/QStringList>
31 
32 namespace Akonadi
33 {
34 
35 class ChangeRecorder;
36 class CollectionStatistics;
37 class Item;
38 class ItemFetchScope;
39 class Monitor;
40 class Session;
41 
42 class EntityTreeModelPrivate;
43 
318 class AKONADI_EXPORT EntityTreeModel : public QAbstractItemModel
319 {
320  Q_OBJECT
321 
322 public:
326  enum Roles {
327  //sebsauer, 2009-05-07; to be able here to keep the akonadi_next EntityTreeModel compatible with
328  //the akonadi_old ItemModel and CollectionModel, we need to use the same int-values for
329  //ItemRole, ItemIdRole and MimeTypeRole like the Akonadi::ItemModel is using and the same
330  //CollectionIdRole and CollectionRole like the Akonadi::CollectionModel is using.
331  ItemIdRole = Qt::UserRole + 1,
332  ItemRole = Qt::UserRole + 2,
333  MimeTypeRole = Qt::UserRole + 3,
334 
335  CollectionIdRole = Qt::UserRole + 10,
336  CollectionRole = Qt::UserRole + 11,
337 
338  RemoteIdRole,
339  CollectionChildOrderRole,
340  AmazingCompletionRole,
341  ParentCollectionRole,
342  ColumnCountRole,
343  LoadedPartsRole,
344  AvailablePartsRole,
345  SessionRole,
346  CollectionRefRole,
347  CollectionDerefRole,
348  PendingCutRole,
349  EntityUrlRole,
350  UnreadCountRole,
351  FetchStateRole,
352  CollectionSyncProgressRole,
353  IsPopulatedRole,
354  UserRole = Qt::UserRole + 500,
355  TerminalUserRole = 2000,
356  EndRole = 65535
357  };
358 
373  enum FetchState {
374  IdleState,
375  FetchingState
376  // TODO: Change states for reporting of fetching payload parts of items.
377  };
378 
382  enum HeaderGroup {
383  EntityTreeHeaders,
384  CollectionTreeHeaders,
385  ItemListHeaders,
386  UserHeaders = 10,
387  EndHeaderGroup = 32
388  // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32
389  };
390 
397  explicit EntityTreeModel(ChangeRecorder *monitor, QObject *parent = 0);
398 
402  virtual ~EntityTreeModel();
403 
407  enum ItemPopulationStrategy {
408  NoItemPopulation,
409  ImmediatePopulation,
410  LazyPopulation
411  };
412 
420  void setShowSystemEntities(bool show);
421 
425  bool systemEntitiesShown() const;
426 
433  AKONADI_DEPRECATED bool includeUnsubscribed() const;
434 
446  AKONADI_DEPRECATED void setIncludeUnsubscribed(bool show);
447 
453  Akonadi::CollectionFetchScope::ListFilter listFilter() const;
454 
460  void setListFilter(Akonadi::CollectionFetchScope::ListFilter filter);
461 
467  void setCollectionsMonitored(const Akonadi::Collection::List &collections);
468 
476  void setCollectionMonitored(const Akonadi::Collection &col, bool monitored = true);
477 
485  void setCollectionReferenced(const Akonadi::Collection &col, bool referenced = true);
486 
490  void setItemPopulationStrategy(ItemPopulationStrategy strategy);
491 
495  ItemPopulationStrategy itemPopulationStrategy() const;
496 
502  void setIncludeRootCollection(bool include);
503 
507  bool includeRootCollection() const;
508 
516  void setRootCollectionDisplayName(const QString &name);
517 
521  QString rootCollectionDisplayName() const;
522 
526  enum CollectionFetchStrategy {
527  FetchNoCollections,
528  FetchFirstLevelChildCollections,
529  FetchCollectionsRecursive,
530  InvisibleCollectionFetch
531  };
532 
536  void setCollectionFetchStrategy(CollectionFetchStrategy strategy);
537 
541  CollectionFetchStrategy collectionFetchStrategy() const;
542 
543  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
544  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
545 
546  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
547  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
548 
549  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
550  virtual QStringList mimeTypes() const;
551 
552  virtual Qt::DropActions supportedDropActions() const;
553  virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
554  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
555  virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
556 
557  virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
558  virtual QModelIndex parent(const QModelIndex &index) const;
559 
560  // TODO: Review the implementations of these. I think they could be better.
561  virtual bool canFetchMore(const QModelIndex &parent) const;
562  virtual void fetchMore(const QModelIndex &parent);
563  virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
564 
571  bool isCollectionTreeFetched() const;
572 
579  bool isCollectionPopulated(Akonadi::Collection::Id) const;
580 
590  bool isFullyPopulated() const;
591 
595  virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const;
596 
627  static QModelIndex modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection);
628 
637  static QModelIndexList modelIndexesForItem(const QAbstractItemModel *model, const Item &item);
638 
639 Q_SIGNALS:
647  void collectionTreeFetched(const Akonadi::Collection::List &collections);
648 
656  void collectionPopulated(Akonadi::Collection::Id collectionId);
665  void collectionFetched(int collectionId);
666 
667 protected:
672  void clearAndReset();
673 
677  virtual QVariant entityData(const Item &item, int column, int role = Qt::DisplayRole) const;
678 
682  virtual QVariant entityData(const Collection &collection, int column, int role = Qt::DisplayRole) const;
683 
688  virtual QVariant entityHeaderData(int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup) const;
689 
690  virtual int entityColumnCount(HeaderGroup headerGroup) const;
691 
695  virtual bool entityMatch(const Item &item, const QVariant &value, Qt::MatchFlags flags) const;
696 
700  virtual bool entityMatch(const Collection &collection, const QVariant &value, Qt::MatchFlags flags) const;
701 
702 protected:
703  //@cond PRIVATE
704  Q_DECLARE_PRIVATE(EntityTreeModel)
705  EntityTreeModelPrivate *d_ptr;
706  EntityTreeModel(ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject *parent = 0);
707  //@endcond
708 
709 private:
710  //@cond PRIVATE
711  // Make these private, they shouldn't be called by applications
712  virtual bool insertRows(int , int, const QModelIndex& = QModelIndex());
713  virtual bool insertColumns(int, int, const QModelIndex& = QModelIndex());
714  virtual bool removeColumns(int, int, const QModelIndex& = QModelIndex());
715  virtual bool removeRows(int, int, const QModelIndex& = QModelIndex());
716 
717  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionStatisticsChanged(Akonadi::Collection::Id,
718  const Akonadi::CollectionStatistics &))
719 
720  Q_PRIVATE_SLOT(d_func(), void startFirstListJob())
721  Q_PRIVATE_SLOT(d_func(), void serverStarted())
722 
723  Q_PRIVATE_SLOT(d_func(), void itemFetchJobDone(KJob *job))
724  Q_PRIVATE_SLOT(d_func(), void collectionFetchJobDone(KJob *job))
725  Q_PRIVATE_SLOT(d_func(), void rootFetchJobDone(KJob *job))
726  Q_PRIVATE_SLOT(d_func(), void pasteJobDone(KJob *job))
727  Q_PRIVATE_SLOT(d_func(), void updateJobDone(KJob *job))
728  Q_PRIVATE_SLOT(d_func(), void finalCollectionFetchJobDone(KJob *job))
729 
730  Q_PRIVATE_SLOT(d_func(), void itemsFetched(Akonadi::Item::List))
731  Q_PRIVATE_SLOT(d_func(), void collectionsFetched(Akonadi::Collection::List))
732  Q_PRIVATE_SLOT(d_func(), void collectionListFetched(Akonadi::Collection::List))
733  Q_PRIVATE_SLOT(d_func(), void topLevelCollectionsFetched(Akonadi::Collection::List))
734  Q_PRIVATE_SLOT(d_func(), void ancestorsFetched(Akonadi::Collection::List))
735 
736  Q_PRIVATE_SLOT(d_func(), void monitoredMimeTypeChanged(const QString &, bool))
737  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionsChanged(const Akonadi::Collection &, bool))
738  Q_PRIVATE_SLOT(d_func(), void monitoredItemsChanged(const Akonadi::Item &, bool))
739  Q_PRIVATE_SLOT(d_func(), void monitoredResourcesChanged(const QByteArray &, bool))
740 
741  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionAdded(const Akonadi::Collection &, const Akonadi::Collection &))
742  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionRemoved(const Akonadi::Collection &))
743  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionChanged(const Akonadi::Collection &))
744  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionMoved(const Akonadi::Collection &, const Akonadi::Collection &,
745  const Akonadi::Collection &))
746 
747  Q_PRIVATE_SLOT(d_func(), void monitoredItemAdded(const Akonadi::Item &, const Akonadi::Collection &))
748  Q_PRIVATE_SLOT(d_func(), void monitoredItemRemoved(const Akonadi::Item &))
749  Q_PRIVATE_SLOT(d_func(), void monitoredItemChanged(const Akonadi::Item &, const QSet<QByteArray> &))
750  Q_PRIVATE_SLOT(d_func(), void monitoredItemMoved(const Akonadi::Item &, const Akonadi::Collection &,
751  const Akonadi::Collection &))
752 
753  Q_PRIVATE_SLOT(d_func(), void monitoredItemLinked(const Akonadi::Item &, const Akonadi::Collection &))
754  Q_PRIVATE_SLOT(d_func(), void monitoredItemUnlinked(const Akonadi::Item &, const Akonadi::Collection &))
755  Q_PRIVATE_SLOT(d_func(), void changeFetchState(const Akonadi::Collection &))
756 
757  Q_PRIVATE_SLOT(d_func(), void agentInstanceRemoved(Akonadi::AgentInstance))
758  Q_PRIVATE_SLOT(d_func(), void monitoredItemsRetrieved(KJob *job))
759  //@endcond
760 };
761 
762 } // namespace
763 
764 #endif
Akonadi::EntityTreeModel::LoadedPartsRole
Parts available in the model for the item.
Definition: entitytreemodel.h:343
Akonadi::EntityTreeModel::UnreadCountRole
Returns the number of unread items in a collection.
Definition: entitytreemodel.h:350
Akonadi::EntityTreeModel::EntityTreeHeaders
Header information for a tree with collections and items.
Definition: entitytreemodel.h:383
Akonadi::EntityTreeModel::CollectionRefRole
Definition: entitytreemodel.h:346
Akonadi::CollectionStatistics
Provides statistics information of a Collection.
Definition: collectionstatistics.h:69
Akonadi::EntityTreeModel::FetchStateRole
Returns the FetchState of a particular item.
Definition: entitytreemodel.h:351
Akonadi::EntityTreeModel::ItemPopulationStrategy
ItemPopulationStrategy
Describes how the model should populated its items.
Definition: entitytreemodel.h:407
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::EntityTreeModel::NoItemPopulation
Do not include items in the model.
Definition: entitytreemodel.h:408
Akonadi::EntityTreeModel::FetchCollectionsRecursive
Fetches collections in the root collection recursively. This is the default.
Definition: entitytreemodel.h:529
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition: entity.h:65
Akonadi::EntityTreeModel::FetchFirstLevelChildCollections
Fetches first level collections in the root collection.
Definition: entitytreemodel.h:528
Akonadi::EntityTreeModel::IdleState
There is no fetch of items in this collection in progress.
Definition: entitytreemodel.h:374
Akonadi::EntityTreeModel::CollectionSyncProgressRole
Returns the progress of synchronization in percent for a particular collection.
Definition: entitytreemodel.h:352
Akonadi::EntityTreeModel::CollectionTreeHeaders
Header information for a collection-only tree.
Definition: entitytreemodel.h:384
Akonadi::CollectionFetchScope::ListFilter
ListFilter
Describes the list filter.
Definition: collectionfetchscope.h:132
Akonadi::EntityTreeModel::HeaderGroup
HeaderGroup
Describes what header information the model shall return.
Definition: entitytreemodel.h:382
Akonadi::EntityTreeModel::IsPopulatedRole
Returns whether a Collection has been populated, i.e. whether its items have been fetched...
Definition: entitytreemodel.h:353
Akonadi::EntityTreeModel::AmazingCompletionRole
Role used to implement amazing completion.
Definition: entitytreemodel.h:340
Akonadi::EntityTreeModel::ParentCollectionRole
The parent collection of the entity.
Definition: entitytreemodel.h:341
Akonadi::EntityTreeModel::RemoteIdRole
The remoteId of the entity.
Definition: entitytreemodel.h:338
Akonadi::EntityTreeModel::ImmediatePopulation
Retrieve items immediately when their parent is in the model. This is the default.
Definition: entitytreemodel.h:409
Akonadi::EntityTreeModel::FetchNoCollections
Fetches nothing. This creates an empty model.
Definition: entitytreemodel.h:527
Akonadi::EntityTreeModel::ItemListHeaders
Header information for a list of items.
Definition: entitytreemodel.h:385
Akonadi::EntityTreeModel::AvailablePartsRole
Parts available in the Akonadi server for the item.
Definition: entitytreemodel.h:344
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
Akonadi::EntityTreeModel
A model for collections and items together.
Definition: entitytreemodel.h:318
Akonadi::EntityTreeModel::PendingCutRole
Definition: entitytreemodel.h:348
Akonadi::EntityTreeModel::ColumnCountRole
Definition: entitytreemodel.h:342
Akonadi::EntityTreeModel::Roles
Roles
Describes the roles for items.
Definition: entitytreemodel.h:326
Akonadi::EntityTreeModelPrivate
Definition: entitytreemodel_p.h:59
Akonadi::AgentInstance
A representation of an agent instance.
Definition: agentinstance.h:62
Akonadi::EntityTreeModel::FetchState
FetchState
Describes the state of fetch jobs related to particular collections.
Definition: entitytreemodel.h:373
Akonadi::EntityTreeModel::CollectionChildOrderRole
Ordered list of child items if available.
Definition: entitytreemodel.h:339
Akonadi::EntityTreeModel::EntityUrlRole
The akonadi:/ Url of the entity as a string. Item urls will contain the mimetype. ...
Definition: entitytreemodel.h:349
Akonadi::EntityTreeModel::CollectionFetchStrategy
CollectionFetchStrategy
Describes what collections shall be fetched by and represent in the model.
Definition: entitytreemodel.h:526
Akonadi::EntityTreeModel::SessionRole
Definition: entitytreemodel.h:345
Akonadi::Collection::List
QList< Collection > List
Describes a list of collections.
Definition: collection.h:81
Akonadi::EntityTreeModel::CollectionDerefRole
Definition: entitytreemodel.h:347
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Sun Apr 26 2015 12:45:18 by doxygen 1.8.9.1 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.14.7 API Reference

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