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

akonadi

  • sources
  • kde-4.14
  • kdepimlibs
  • 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  OriginalCollectionNameRole,
355  UserRole = Qt::UserRole + 500,
356  TerminalUserRole = 2000,
357  EndRole = 65535
358  };
359 
374  enum FetchState {
375  IdleState,
376  FetchingState
377  // TODO: Change states for reporting of fetching payload parts of items.
378  };
379 
383  enum HeaderGroup {
384  EntityTreeHeaders,
385  CollectionTreeHeaders,
386  ItemListHeaders,
387  UserHeaders = 10,
388  EndHeaderGroup = 32
389  // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32
390  };
391 
398  explicit EntityTreeModel(ChangeRecorder *monitor, QObject *parent = 0);
399 
403  virtual ~EntityTreeModel();
404 
408  enum ItemPopulationStrategy {
409  NoItemPopulation,
410  ImmediatePopulation,
411  LazyPopulation
412  };
413 
421  void setShowSystemEntities(bool show);
422 
426  bool systemEntitiesShown() const;
427 
434  AKONADI_DEPRECATED bool includeUnsubscribed() const;
435 
447  AKONADI_DEPRECATED void setIncludeUnsubscribed(bool show);
448 
454  Akonadi::CollectionFetchScope::ListFilter listFilter() const;
455 
461  void setListFilter(Akonadi::CollectionFetchScope::ListFilter filter);
462 
468  void setCollectionsMonitored(const Akonadi::Collection::List &collections);
469 
477  void setCollectionMonitored(const Akonadi::Collection &col, bool monitored = true);
478 
486  void setCollectionReferenced(const Akonadi::Collection &col, bool referenced = true);
487 
491  void setItemPopulationStrategy(ItemPopulationStrategy strategy);
492 
496  ItemPopulationStrategy itemPopulationStrategy() const;
497 
503  void setIncludeRootCollection(bool include);
504 
508  bool includeRootCollection() const;
509 
517  void setRootCollectionDisplayName(const QString &name);
518 
522  QString rootCollectionDisplayName() const;
523 
527  enum CollectionFetchStrategy {
528  FetchNoCollections,
529  FetchFirstLevelChildCollections,
530  FetchCollectionsRecursive,
531  InvisibleCollectionFetch
532  };
533 
537  void setCollectionFetchStrategy(CollectionFetchStrategy strategy);
538 
542  CollectionFetchStrategy collectionFetchStrategy() const;
543 
544  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
545  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
546 
547  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
548  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
549 
550  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
551  virtual QStringList mimeTypes() const;
552 
553  virtual Qt::DropActions supportedDropActions() const;
554  virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
555  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
556  virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
557 
558  virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
559  virtual QModelIndex parent(const QModelIndex &index) const;
560 
561  // TODO: Review the implementations of these. I think they could be better.
562  virtual bool canFetchMore(const QModelIndex &parent) const;
563  virtual void fetchMore(const QModelIndex &parent);
564  virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
565 
572  bool isCollectionTreeFetched() const;
573 
580  bool isCollectionPopulated(Akonadi::Collection::Id) const;
581 
591  bool isFullyPopulated() const;
592 
596  virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const;
597 
628  static QModelIndex modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection);
629 
638  static QModelIndexList modelIndexesForItem(const QAbstractItemModel *model, const Item &item);
639 
640 Q_SIGNALS:
648  void collectionTreeFetched(const Akonadi::Collection::List &collections);
649 
657  void collectionPopulated(Akonadi::Collection::Id collectionId);
666  void collectionFetched(int collectionId);
667 
668 protected:
673  void clearAndReset();
674 
678  virtual QVariant entityData(const Item &item, int column, int role = Qt::DisplayRole) const;
679 
683  virtual QVariant entityData(const Collection &collection, int column, int role = Qt::DisplayRole) const;
684 
689  virtual QVariant entityHeaderData(int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup) const;
690 
691  virtual int entityColumnCount(HeaderGroup headerGroup) const;
692 
696  virtual bool entityMatch(const Item &item, const QVariant &value, Qt::MatchFlags flags) const;
697 
701  virtual bool entityMatch(const Collection &collection, const QVariant &value, Qt::MatchFlags flags) const;
702 
703 protected:
704  //@cond PRIVATE
705  Q_DECLARE_PRIVATE(EntityTreeModel)
706  EntityTreeModelPrivate *d_ptr;
707  EntityTreeModel(ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject *parent = 0);
708  //@endcond
709 
710 private:
711  //@cond PRIVATE
712  // Make these private, they shouldn't be called by applications
713  virtual bool insertRows(int , int, const QModelIndex& = QModelIndex());
714  virtual bool insertColumns(int, int, const QModelIndex& = QModelIndex());
715  virtual bool removeColumns(int, int, const QModelIndex& = QModelIndex());
716  virtual bool removeRows(int, int, const QModelIndex& = QModelIndex());
717 
718  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionStatisticsChanged(Akonadi::Collection::Id,
719  const Akonadi::CollectionStatistics &))
720 
721  Q_PRIVATE_SLOT(d_func(), void startFirstListJob())
722  Q_PRIVATE_SLOT(d_func(), void serverStarted())
723 
724  Q_PRIVATE_SLOT(d_func(), void itemFetchJobDone(KJob *job))
725  Q_PRIVATE_SLOT(d_func(), void collectionFetchJobDone(KJob *job))
726  Q_PRIVATE_SLOT(d_func(), void rootFetchJobDone(KJob *job))
727  Q_PRIVATE_SLOT(d_func(), void pasteJobDone(KJob *job))
728  Q_PRIVATE_SLOT(d_func(), void updateJobDone(KJob *job))
729  Q_PRIVATE_SLOT(d_func(), void finalCollectionFetchJobDone(KJob *job))
730 
731  Q_PRIVATE_SLOT(d_func(), void itemsFetched(Akonadi::Item::List))
732  Q_PRIVATE_SLOT(d_func(), void collectionsFetched(Akonadi::Collection::List))
733  Q_PRIVATE_SLOT(d_func(), void collectionListFetched(Akonadi::Collection::List))
734  Q_PRIVATE_SLOT(d_func(), void topLevelCollectionsFetched(Akonadi::Collection::List))
735  Q_PRIVATE_SLOT(d_func(), void ancestorsFetched(Akonadi::Collection::List))
736 
737  Q_PRIVATE_SLOT(d_func(), void monitoredMimeTypeChanged(const QString &, bool))
738  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionsChanged(const Akonadi::Collection &, bool))
739  Q_PRIVATE_SLOT(d_func(), void monitoredItemsChanged(const Akonadi::Item &, bool))
740  Q_PRIVATE_SLOT(d_func(), void monitoredResourcesChanged(const QByteArray &, bool))
741 
742  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionAdded(const Akonadi::Collection &, const Akonadi::Collection &))
743  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionRemoved(const Akonadi::Collection &))
744  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionChanged(const Akonadi::Collection &))
745  Q_PRIVATE_SLOT(d_func(), void monitoredCollectionMoved(const Akonadi::Collection &, const Akonadi::Collection &,
746  const Akonadi::Collection &))
747 
748  Q_PRIVATE_SLOT(d_func(), void monitoredItemAdded(const Akonadi::Item &, const Akonadi::Collection &))
749  Q_PRIVATE_SLOT(d_func(), void monitoredItemRemoved(const Akonadi::Item &))
750  Q_PRIVATE_SLOT(d_func(), void monitoredItemChanged(const Akonadi::Item &, const QSet<QByteArray> &))
751  Q_PRIVATE_SLOT(d_func(), void monitoredItemMoved(const Akonadi::Item &, const Akonadi::Collection &,
752  const Akonadi::Collection &))
753 
754  Q_PRIVATE_SLOT(d_func(), void monitoredItemLinked(const Akonadi::Item &, const Akonadi::Collection &))
755  Q_PRIVATE_SLOT(d_func(), void monitoredItemUnlinked(const Akonadi::Item &, const Akonadi::Collection &))
756  Q_PRIVATE_SLOT(d_func(), void changeFetchState(const Akonadi::Collection &))
757 
758  Q_PRIVATE_SLOT(d_func(), void agentInstanceRemoved(Akonadi::AgentInstance))
759  Q_PRIVATE_SLOT(d_func(), void monitoredItemsRetrieved(KJob *job))
760  //@endcond
761 };
762 
763 } // namespace
764 
765 #endif
QModelIndex
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:384
Akonadi::EntityTreeModel::CollectionRefRole
Definition: entitytreemodel.h:346
Akonadi::CollectionStatistics
Provides statistics information of a Collection.
Definition: collectionstatistics.h:69
QByteArray
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:408
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:409
Akonadi::EntityTreeModel::FetchCollectionsRecursive
Fetches collections in the root collection recursively. This is the default.
Definition: entitytreemodel.h:530
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition: entity.h:65
Qt::MatchFlags
typedef MatchFlags
Akonadi::EntityTreeModel::FetchFirstLevelChildCollections
Fetches first level collections in the root collection.
Definition: entitytreemodel.h:529
Akonadi::EntityTreeModel::IdleState
There is no fetch of items in this collection in progress.
Definition: entitytreemodel.h:375
QMimeData
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:385
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:383
Akonadi::EntityTreeModel::IsPopulatedRole
Returns whether a Collection has been populated, i.e. whether its items have been fetched...
Definition: entitytreemodel.h:353
QObject
Akonadi::EntityTreeModel::AmazingCompletionRole
Role used to implement amazing completion.
Definition: entitytreemodel.h:340
QSet
Definition: itemfetchscope.h:29
QString
QList
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
QStringList
Akonadi::EntityTreeModel::ImmediatePopulation
Retrieve items immediately when their parent is in the model. This is the default.
Definition: entitytreemodel.h:410
Akonadi::EntityTreeModel::OriginalCollectionNameRole
Returns original name for collection.
Definition: entitytreemodel.h:354
Akonadi::EntityTreeModel::FetchNoCollections
Fetches nothing. This creates an empty model.
Definition: entitytreemodel.h:528
Akonadi::EntityTreeModel::ItemListHeaders
Header information for a list of items.
Definition: entitytreemodel.h:386
Akonadi::EntityTreeModel::AvailablePartsRole
Parts available in the Akonadi server for the item.
Definition: entitytreemodel.h:344
Qt::DropActions
typedef DropActions
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
QAbstractItemModel
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:374
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:527
Akonadi::EntityTreeModel::SessionRole
Definition: entitytreemodel.h:345
Akonadi::EntityTreeModel::CollectionDerefRole
Definition: entitytreemodel.h:347
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:47
QVariant
Qt::ItemFlags
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:03 by doxygen 1.8.7 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 API Reference

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

Search



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