• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.1 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/item.h>
27 
28 #include <QtCore/QAbstractItemModel>
29 #include <QtCore/QStringList>
30 
31 namespace Akonadi
32 {
33 
34 class ChangeRecorder;
35 class CollectionStatistics;
36 class Item;
37 class ItemFetchScope;
38 class Monitor;
39 class Session;
40 
41 class EntityTreeModelPrivate;
42 
317 class AKONADI_EXPORT EntityTreeModel : public QAbstractItemModel
318 {
319  Q_OBJECT
320 
321  public:
325  enum Roles {
326  //sebsauer, 2009-05-07; to be able here to keep the akonadi_next EntityTreeModel compatible with
327  //the akonadi_old ItemModel and CollectionModel, we need to use the same int-values for
328  //ItemRole, ItemIdRole and MimeTypeRole like the Akonadi::ItemModel is using and the same
329  //CollectionIdRole and CollectionRole like the Akonadi::CollectionModel is using.
330  ItemIdRole = Qt::UserRole + 1,
331  ItemRole = Qt::UserRole + 2,
332  MimeTypeRole = Qt::UserRole + 3,
333 
334  CollectionIdRole = Qt::UserRole + 10,
335  CollectionRole = Qt::UserRole + 11,
336 
337  RemoteIdRole,
338  CollectionChildOrderRole,
339  AmazingCompletionRole,
340  ParentCollectionRole,
341  ColumnCountRole,
342  LoadedPartsRole,
343  AvailablePartsRole,
344  SessionRole,
345  CollectionRefRole,
346  CollectionDerefRole,
347  PendingCutRole,
348  EntityUrlRole,
349  UnreadCountRole,
350  FetchStateRole,
351  CollectionSyncProgressRole,
352  UserRole = Qt::UserRole + 500,
353  TerminalUserRole = 2000,
354  EndRole = 65535
355  };
356 
371  enum FetchState {
372  IdleState,
373  FetchingState
374  // TODO: Change states for reporting of fetching payload parts of items.
375  };
376 
380  enum HeaderGroup {
381  EntityTreeHeaders,
382  CollectionTreeHeaders,
383  ItemListHeaders,
384  UserHeaders = 10,
385  EndHeaderGroup = 32
386  // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32
387  };
388 
395  explicit EntityTreeModel( ChangeRecorder *monitor, QObject *parent = 0 );
396 
400  virtual ~EntityTreeModel();
401 
405  enum ItemPopulationStrategy {
406  NoItemPopulation,
407  ImmediatePopulation,
408  LazyPopulation
409  };
410 
419  void setShowSystemEntities( bool show );
420 
424  bool systemEntitiesShown() const;
425 
426 
432  bool includeUnsubscribed() const;
433 
444  void setIncludeUnsubscribed( bool show );
445 
446 
450  void setItemPopulationStrategy( ItemPopulationStrategy strategy );
451 
455  ItemPopulationStrategy itemPopulationStrategy() const;
456 
462  void setIncludeRootCollection( bool include );
463 
467  bool includeRootCollection() const;
468 
476  void setRootCollectionDisplayName( const QString &name );
477 
481  QString rootCollectionDisplayName() const;
482 
486  enum CollectionFetchStrategy {
487  FetchNoCollections,
488  FetchFirstLevelChildCollections,
489  FetchCollectionsRecursive,
490  InvisibleCollectionFetch
491  };
492 
496  void setCollectionFetchStrategy( CollectionFetchStrategy strategy );
497 
501  CollectionFetchStrategy collectionFetchStrategy() const;
502 
503  virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
504  virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
505 
506  virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
507  virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
508 
509  virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
510  virtual QStringList mimeTypes() const;
511 
512  virtual Qt::DropActions supportedDropActions() const;
513  virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
514  virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
515  virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
516 
517  virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
518  virtual QModelIndex parent( const QModelIndex & index ) const;
519 
520  // TODO: Review the implementations of these. I think they could be better.
521  virtual bool canFetchMore( const QModelIndex & parent ) const;
522  virtual void fetchMore( const QModelIndex & parent );
523  virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
524 
528  virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const;
529 
561  static QModelIndex modelIndexForCollection( const QAbstractItemModel *model, const Collection &collection );
562 
570  static QModelIndexList modelIndexesForItem( const QAbstractItemModel *model, const Item &item );
571 
572  protected:
577  void clearAndReset();
578 
582  virtual QVariant entityData( const Item &item, int column, int role = Qt::DisplayRole ) const;
583 
587  virtual QVariant entityData( const Collection &collection, int column, int role = Qt::DisplayRole ) const;
588 
593  virtual QVariant entityHeaderData( int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup ) const;
594 
595  virtual int entityColumnCount( HeaderGroup headerGroup ) const;
596 
600  virtual bool entityMatch( const Item &item, const QVariant &value, Qt::MatchFlags flags ) const;
601 
605  virtual bool entityMatch( const Collection &collection, const QVariant &value, Qt::MatchFlags flags ) const;
606 
607 protected:
608  //@cond PRIVATE
609  Q_DECLARE_PRIVATE( EntityTreeModel )
610  EntityTreeModelPrivate * d_ptr;
611  EntityTreeModel( ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 );
612  //@endcond
613 
614 private:
615  //@cond PRIVATE
616  // Make these private, they shouldn't be called by applications
617  virtual bool insertRows( int , int, const QModelIndex& = QModelIndex() );
618  virtual bool insertColumns( int, int, const QModelIndex& = QModelIndex() );
619  virtual bool removeColumns( int, int, const QModelIndex& = QModelIndex() );
620  virtual bool removeRows( int, int, const QModelIndex & = QModelIndex() );
621 
622  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id,
623  const Akonadi::CollectionStatistics& ) )
624 
625  Q_PRIVATE_SLOT( d_func(), void startFirstListJob() )
626  Q_PRIVATE_SLOT( d_func(), void serverStarted() )
627 
628  Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) )
629  Q_PRIVATE_SLOT( d_func(), void rootFetchJobDone( KJob *job ) )
630  Q_PRIVATE_SLOT( d_func(), void pasteJobDone( KJob *job ) )
631  Q_PRIVATE_SLOT( d_func(), void updateJobDone( KJob *job ) )
632  Q_PRIVATE_SLOT( d_func(), void firstFetchJobDone( KJob *job ) )
633 
634  Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) )
635  Q_PRIVATE_SLOT( d_func(), void itemsFetched( KJob* ) )
636  Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) )
637  Q_PRIVATE_SLOT( d_func(), void firstCollectionsFetched( Akonadi::Collection::List ) )
638  Q_PRIVATE_SLOT( d_func(), void collectionListFetched( Akonadi::Collection::List ) )
639  Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( Akonadi::Collection::List ) )
640  Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) )
641 
642  Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) )
643  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionsChanged( const Akonadi::Collection&, bool ) )
644  Q_PRIVATE_SLOT( d_func(), void monitoredItemsChanged( const Akonadi::Item&, bool ) )
645  Q_PRIVATE_SLOT( d_func(), void monitoredResourcesChanged( const QByteArray&, bool ) )
646 
647  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) )
648  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionRemoved( const Akonadi::Collection& ) )
649  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionChanged( const Akonadi::Collection& ) )
650  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&,
651  const Akonadi::Collection&) )
652  Q_PRIVATE_SLOT( d_func(), void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& ) )
653  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionUnsubscribed( const Akonadi::Collection& ) )
654 
655  Q_PRIVATE_SLOT( d_func(), void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& ) )
656  Q_PRIVATE_SLOT( d_func(), void monitoredItemRemoved( const Akonadi::Item& ) )
657  Q_PRIVATE_SLOT( d_func(), void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
658  Q_PRIVATE_SLOT( d_func(), void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&,
659  const Akonadi::Collection& ) )
660 
661  Q_PRIVATE_SLOT( d_func(), void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& ) )
662  Q_PRIVATE_SLOT( d_func(), void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) )
663  Q_PRIVATE_SLOT( d_func(), void changeFetchState( const Akonadi::Collection & ) )
664 
665  Q_PRIVATE_SLOT( d_func(), void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& ) )
666  Q_PRIVATE_SLOT( d_func(), void agentInstanceRemoved( Akonadi::AgentInstance ) )
667  Q_PRIVATE_SLOT( d_func(), void monitoredItemsRetrieved(KJob* job) )
668  //@endcond
669 };
670 
671 } // namespace
672 
673 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Sep 24 2012 09:06:26 by doxygen 1.8.1.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.9.1 API Reference

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