• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 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  IsPopulatedRole,
353  UserRole = Qt::UserRole + 500,
354  TerminalUserRole = 2000,
355  EndRole = 65535
356  };
357 
372  enum FetchState {
373  IdleState,
374  FetchingState
375  // TODO: Change states for reporting of fetching payload parts of items.
376  };
377 
381  enum HeaderGroup {
382  EntityTreeHeaders,
383  CollectionTreeHeaders,
384  ItemListHeaders,
385  UserHeaders = 10,
386  EndHeaderGroup = 32
387  // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32
388  };
389 
396  explicit EntityTreeModel( ChangeRecorder *monitor, QObject *parent = 0 );
397 
401  virtual ~EntityTreeModel();
402 
406  enum ItemPopulationStrategy {
407  NoItemPopulation,
408  ImmediatePopulation,
409  LazyPopulation
410  };
411 
420  void setShowSystemEntities( bool show );
421 
425  bool systemEntitiesShown() const;
426 
427 
433  bool includeUnsubscribed() const;
434 
445  void setIncludeUnsubscribed( bool show );
446 
447 
451  void setItemPopulationStrategy( ItemPopulationStrategy strategy );
452 
456  ItemPopulationStrategy itemPopulationStrategy() const;
457 
463  void setIncludeRootCollection( bool include );
464 
468  bool includeRootCollection() const;
469 
477  void setRootCollectionDisplayName( const QString &name );
478 
482  QString rootCollectionDisplayName() const;
483 
487  enum CollectionFetchStrategy {
488  FetchNoCollections,
489  FetchFirstLevelChildCollections,
490  FetchCollectionsRecursive,
491  InvisibleCollectionFetch
492  };
493 
497  void setCollectionFetchStrategy( CollectionFetchStrategy strategy );
498 
502  CollectionFetchStrategy collectionFetchStrategy() const;
503 
504  virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
505  virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
506 
507  virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
508  virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
509 
510  virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
511  virtual QStringList mimeTypes() const;
512 
513  virtual Qt::DropActions supportedDropActions() const;
514  virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
515  virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
516  virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
517 
518  virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
519  virtual QModelIndex parent( const QModelIndex & index ) const;
520 
521  // TODO: Review the implementations of these. I think they could be better.
522  virtual bool canFetchMore( const QModelIndex & parent ) const;
523  virtual void fetchMore( const QModelIndex & parent );
524  virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
525 
532  bool isCollectionTreeFetched() const;
533 
537  virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const;
538 
570  static QModelIndex modelIndexForCollection( const QAbstractItemModel *model, const Collection &collection );
571 
579  static QModelIndexList modelIndexesForItem( const QAbstractItemModel *model, const Item &item );
580 
581  Q_SIGNALS:
589  void collectionTreeFetched( const Akonadi::Collection::List &collections );
590 
598  void collectionPopulated( Akonadi::Collection::Id collectionId );
606  void collectionFetched(int collectionId);
607 
608  protected:
613  void clearAndReset();
614 
618  virtual QVariant entityData( const Item &item, int column, int role = Qt::DisplayRole ) const;
619 
623  virtual QVariant entityData( const Collection &collection, int column, int role = Qt::DisplayRole ) const;
624 
629  virtual QVariant entityHeaderData( int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup ) const;
630 
631  virtual int entityColumnCount( HeaderGroup headerGroup ) const;
632 
636  virtual bool entityMatch( const Item &item, const QVariant &value, Qt::MatchFlags flags ) const;
637 
641  virtual bool entityMatch( const Collection &collection, const QVariant &value, Qt::MatchFlags flags ) const;
642 
643 protected:
644  //@cond PRIVATE
645  Q_DECLARE_PRIVATE( EntityTreeModel )
646  EntityTreeModelPrivate * d_ptr;
647  EntityTreeModel( ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 );
648  //@endcond
649 
650 private:
651  //@cond PRIVATE
652  // Make these private, they shouldn't be called by applications
653  virtual bool insertRows( int , int, const QModelIndex& = QModelIndex() );
654  virtual bool insertColumns( int, int, const QModelIndex& = QModelIndex() );
655  virtual bool removeColumns( int, int, const QModelIndex& = QModelIndex() );
656  virtual bool removeRows( int, int, const QModelIndex & = QModelIndex() );
657 
658  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id,
659  const Akonadi::CollectionStatistics& ) )
660 
661  Q_PRIVATE_SLOT( d_func(), void startFirstListJob() )
662  Q_PRIVATE_SLOT( d_func(), void serverStarted() )
663 
664  Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) )
665  Q_PRIVATE_SLOT( d_func(), void rootFetchJobDone( KJob *job ) )
666  Q_PRIVATE_SLOT( d_func(), void pasteJobDone( KJob *job ) )
667  Q_PRIVATE_SLOT( d_func(), void updateJobDone( KJob *job ) )
668  Q_PRIVATE_SLOT( d_func(), void firstFetchJobDone( KJob *job ) )
669 
670  Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) )
671  Q_PRIVATE_SLOT( d_func(), void itemsFetched( KJob* ) )
672  Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) )
673  Q_PRIVATE_SLOT( d_func(), void allCollectionsFetched( Akonadi::Collection::List ) )
674  Q_PRIVATE_SLOT( d_func(), void firstCollectionsFetched( Akonadi::Collection::List ) )
675  Q_PRIVATE_SLOT( d_func(), void collectionListFetched( Akonadi::Collection::List ) )
676  Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( Akonadi::Collection::List ) )
677  Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) )
678 
679  Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) )
680  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionsChanged( const Akonadi::Collection&, bool ) )
681  Q_PRIVATE_SLOT( d_func(), void monitoredItemsChanged( const Akonadi::Item&, bool ) )
682  Q_PRIVATE_SLOT( d_func(), void monitoredResourcesChanged( const QByteArray&, bool ) )
683 
684  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) )
685  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionRemoved( const Akonadi::Collection& ) )
686  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionChanged( const Akonadi::Collection& ) )
687  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&,
688  const Akonadi::Collection&) )
689  Q_PRIVATE_SLOT( d_func(), void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& ) )
690  Q_PRIVATE_SLOT( d_func(), void monitoredCollectionUnsubscribed( const Akonadi::Collection& ) )
691 
692  Q_PRIVATE_SLOT( d_func(), void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& ) )
693  Q_PRIVATE_SLOT( d_func(), void monitoredItemRemoved( const Akonadi::Item& ) )
694  Q_PRIVATE_SLOT( d_func(), void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
695  Q_PRIVATE_SLOT( d_func(), void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&,
696  const Akonadi::Collection& ) )
697 
698  Q_PRIVATE_SLOT( d_func(), void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& ) )
699  Q_PRIVATE_SLOT( d_func(), void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) )
700  Q_PRIVATE_SLOT( d_func(), void changeFetchState( const Akonadi::Collection & ) )
701 
702  Q_PRIVATE_SLOT( d_func(), void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& ) )
703  Q_PRIVATE_SLOT( d_func(), void agentInstanceRemoved( Akonadi::AgentInstance ) )
704  Q_PRIVATE_SLOT( d_func(), void monitoredItemsRetrieved(KJob* job) )
705  //@endcond
706 };
707 
708 } // namespace
709 
710 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:36 by doxygen 1.8.3.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.10.5 API Reference

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