• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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
32namespace Akonadi
33{
34
35class ChangeRecorder;
36class CollectionStatistics;
37class Item;
38class ItemFetchScope;
39class Monitor;
40class Session;
41
42class EntityTreeModelPrivate;
43
318class AKONADI_EXPORT EntityTreeModel : public QAbstractItemModel
319{
320 Q_OBJECT
321
322public:
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
640Q_SIGNALS:
648 void collectionTreeFetched(const Akonadi::Collection::List &collections);
649
657 void collectionPopulated(Akonadi::Collection::Id collectionId);
666 void collectionFetched(int collectionId);
667
668protected:
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
703protected:
704 //@cond PRIVATE
705 Q_DECLARE_PRIVATE(EntityTreeModel)
706 EntityTreeModelPrivate *d_ptr;
707 EntityTreeModel(ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject *parent = 0);
708 //@endcond
709
710private:
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
Akonadi::AgentInstance
A representation of an agent instance.
Definition: agentinstance.h:63
Akonadi::ChangeRecorder
Records and replays change notification.
Definition: changerecorder.h:48
Akonadi::CollectionFetchScope::ListFilter
ListFilter
Describes the list filter.
Definition: collectionfetchscope.h:132
Akonadi::CollectionStatistics
Provides statistics information of a Collection.
Definition: collectionstatistics.h:70
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:76
Akonadi::Collection::List
QList< Collection > List
Describes a list of collections.
Definition: collection.h:81
Akonadi::EntityTreeModelPrivate
Definition: entitytreemodel_p.h:60
Akonadi::EntityTreeModel
A model for collections and items together.
Definition: entitytreemodel.h:319
Akonadi::EntityTreeModel::ItemPopulationStrategy
ItemPopulationStrategy
Describes how the model should populated its items.
Definition: entitytreemodel.h:408
Akonadi::EntityTreeModel::ImmediatePopulation
@ ImmediatePopulation
Retrieve items immediately when their parent is in the model. This is the default.
Definition: entitytreemodel.h:410
Akonadi::EntityTreeModel::NoItemPopulation
@ NoItemPopulation
Do not include items in the model.
Definition: entitytreemodel.h:409
Akonadi::EntityTreeModel::collectionTreeFetched
void collectionTreeFetched(const Akonadi::Collection::List &collections)
Signal emitted when the collection tree has been fetched for the first time.
Akonadi::EntityTreeModel::FetchState
FetchState
Describes the state of fetch jobs related to particular collections.
Definition: entitytreemodel.h:374
Akonadi::EntityTreeModel::IdleState
@ IdleState
There is no fetch of items in this collection in progress.
Definition: entitytreemodel.h:375
Akonadi::EntityTreeModel::HeaderGroup
HeaderGroup
Describes what header information the model shall return.
Definition: entitytreemodel.h:383
Akonadi::EntityTreeModel::CollectionTreeHeaders
@ CollectionTreeHeaders
Header information for a collection-only tree.
Definition: entitytreemodel.h:385
Akonadi::EntityTreeModel::ItemListHeaders
@ ItemListHeaders
Header information for a list of items.
Definition: entitytreemodel.h:386
Akonadi::EntityTreeModel::EntityTreeHeaders
@ EntityTreeHeaders
Header information for a tree with collections and items.
Definition: entitytreemodel.h:384
Akonadi::EntityTreeModel::collectionFetched
void collectionFetched(int collectionId)
Emitted once a collection has been fetched for the very first time.
Akonadi::EntityTreeModel::CollectionFetchStrategy
CollectionFetchStrategy
Describes what collections shall be fetched by and represent in the model.
Definition: entitytreemodel.h:527
Akonadi::EntityTreeModel::FetchNoCollections
@ FetchNoCollections
Fetches nothing. This creates an empty model.
Definition: entitytreemodel.h:528
Akonadi::EntityTreeModel::FetchFirstLevelChildCollections
@ FetchFirstLevelChildCollections
Fetches first level collections in the root collection.
Definition: entitytreemodel.h:529
Akonadi::EntityTreeModel::FetchCollectionsRecursive
@ FetchCollectionsRecursive
Fetches collections in the root collection recursively. This is the default.
Definition: entitytreemodel.h:530
Akonadi::EntityTreeModel::collectionPopulated
void collectionPopulated(Akonadi::Collection::Id collectionId)
Signal emitted when a collection has been populated, i.e.
Akonadi::EntityTreeModel::Roles
Roles
Describes the roles for items.
Definition: entitytreemodel.h:326
Akonadi::EntityTreeModel::AvailablePartsRole
@ AvailablePartsRole
Parts available in the Akonadi server for the item.
Definition: entitytreemodel.h:344
Akonadi::EntityTreeModel::ParentCollectionRole
@ ParentCollectionRole
The parent collection of the entity.
Definition: entitytreemodel.h:341
Akonadi::EntityTreeModel::LoadedPartsRole
@ LoadedPartsRole
Parts available in the model for the item.
Definition: entitytreemodel.h:343
Akonadi::EntityTreeModel::CollectionDerefRole
@ CollectionDerefRole
Definition: entitytreemodel.h:347
Akonadi::EntityTreeModel::RemoteIdRole
@ RemoteIdRole
The remoteId of the entity.
Definition: entitytreemodel.h:338
Akonadi::EntityTreeModel::SessionRole
@ SessionRole
Definition: entitytreemodel.h:345
Akonadi::EntityTreeModel::OriginalCollectionNameRole
@ OriginalCollectionNameRole
Returns original name for collection.
Definition: entitytreemodel.h:354
Akonadi::EntityTreeModel::AmazingCompletionRole
@ AmazingCompletionRole
Role used to implement amazing completion.
Definition: entitytreemodel.h:340
Akonadi::EntityTreeModel::CollectionSyncProgressRole
@ CollectionSyncProgressRole
Returns the progress of synchronization in percent for a particular collection.
Definition: entitytreemodel.h:352
Akonadi::EntityTreeModel::EntityUrlRole
@ EntityUrlRole
The akonadi:/ Url of the entity as a string. Item urls will contain the mimetype.
Definition: entitytreemodel.h:349
Akonadi::EntityTreeModel::PendingCutRole
@ PendingCutRole
Definition: entitytreemodel.h:348
Akonadi::EntityTreeModel::UnreadCountRole
@ UnreadCountRole
Returns the number of unread items in a collection.
Definition: entitytreemodel.h:350
Akonadi::EntityTreeModel::CollectionRefRole
@ CollectionRefRole
Definition: entitytreemodel.h:346
Akonadi::EntityTreeModel::IsPopulatedRole
@ IsPopulatedRole
Returns whether a Collection has been populated, i.e. whether its items have been fetched.
Definition: entitytreemodel.h:353
Akonadi::EntityTreeModel::CollectionChildOrderRole
@ CollectionChildOrderRole
Ordered list of child items if available.
Definition: entitytreemodel.h:339
Akonadi::EntityTreeModel::FetchStateRole
@ FetchStateRole
Returns the FetchState of a particular item.
Definition: entitytreemodel.h:351
Akonadi::EntityTreeModel::ColumnCountRole
@ ColumnCountRole
Definition: entitytreemodel.h:342
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition: entity.h:65
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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.10 API Reference

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