akonadi
entitytreemodel.h
00001 /* 00002 Copyright (c) 2008 Stephen Kelly <steveire@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #ifndef AKONADI_ENTITYTREEMODEL_H 00021 #define AKONADI_ENTITYTREEMODEL_H 00022 00023 #include "akonadi_export.h" 00024 00025 #include <akonadi/collection.h> 00026 #include <akonadi/item.h> 00027 00028 #include <QtCore/QAbstractItemModel> 00029 #include <QtCore/QStringList> 00030 00031 namespace Akonadi 00032 { 00033 00034 class ChangeRecorder; 00035 class CollectionStatistics; 00036 class Item; 00037 class ItemFetchScope; 00038 class Monitor; 00039 class Session; 00040 00041 class EntityTreeModelPrivate; 00042 00317 class AKONADI_EXPORT EntityTreeModel : public QAbstractItemModel 00318 { 00319 Q_OBJECT 00320 00321 public: 00325 enum Roles { 00326 //sebsauer, 2009-05-07; to be able here to keep the akonadi_next EntityTreeModel compatible with 00327 //the akonadi_old ItemModel and CollectionModel, we need to use the same int-values for 00328 //ItemRole, ItemIdRole and MimeTypeRole like the Akonadi::ItemModel is using and the same 00329 //CollectionIdRole and CollectionRole like the Akonadi::CollectionModel is using. 00330 ItemIdRole = Qt::UserRole + 1, 00331 ItemRole = Qt::UserRole + 2, 00332 MimeTypeRole = Qt::UserRole + 3, 00333 00334 CollectionIdRole = Qt::UserRole + 10, 00335 CollectionRole = Qt::UserRole + 11, 00336 00337 RemoteIdRole, 00338 CollectionChildOrderRole, 00339 AmazingCompletionRole, 00340 ParentCollectionRole, 00341 ColumnCountRole, 00342 LoadedPartsRole, 00343 AvailablePartsRole, 00344 SessionRole, 00345 CollectionRefRole, 00346 CollectionDerefRole, 00347 PendingCutRole, 00348 EntityUrlRole, 00349 UnreadCountRole, 00350 FetchStateRole, 00351 CollectionSyncProgressRole, 00352 UserRole = Qt::UserRole + 500, 00353 TerminalUserRole = 2000, 00354 EndRole = 65535 00355 }; 00356 00371 enum FetchState { 00372 IdleState, 00373 FetchingState 00374 // TODO: Change states for reporting of fetching payload parts of items. 00375 }; 00376 00380 enum HeaderGroup { 00381 EntityTreeHeaders, 00382 CollectionTreeHeaders, 00383 ItemListHeaders, 00384 UserHeaders = 10, 00385 EndHeaderGroup = 32 00386 // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32 00387 }; 00388 00395 explicit EntityTreeModel( ChangeRecorder *monitor, QObject *parent = 0 ); 00396 00400 virtual ~EntityTreeModel(); 00401 00405 enum ItemPopulationStrategy { 00406 NoItemPopulation, 00407 ImmediatePopulation, 00408 LazyPopulation 00409 }; 00410 00419 void setShowSystemEntities( bool show ); 00420 00424 bool systemEntitiesShown() const; 00425 00426 00432 bool includeUnsubscribed() const; 00433 00444 void setIncludeUnsubscribed( bool show ); 00445 00446 00450 void setItemPopulationStrategy( ItemPopulationStrategy strategy ); 00451 00455 ItemPopulationStrategy itemPopulationStrategy() const; 00456 00462 void setIncludeRootCollection( bool include ); 00463 00467 bool includeRootCollection() const; 00468 00476 void setRootCollectionDisplayName( const QString &name ); 00477 00481 QString rootCollectionDisplayName() const; 00482 00486 enum CollectionFetchStrategy { 00487 FetchNoCollections, 00488 FetchFirstLevelChildCollections, 00489 FetchCollectionsRecursive, 00490 InvisibleCollectionFetch 00491 }; 00492 00496 void setCollectionFetchStrategy( CollectionFetchStrategy strategy ); 00497 00501 CollectionFetchStrategy collectionFetchStrategy() const; 00502 00503 virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const; 00504 virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const; 00505 00506 virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; 00507 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 00508 00509 virtual Qt::ItemFlags flags( const QModelIndex &index ) const; 00510 virtual QStringList mimeTypes() const; 00511 00512 virtual Qt::DropActions supportedDropActions() const; 00513 virtual QMimeData *mimeData( const QModelIndexList &indexes ) const; 00514 virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ); 00515 virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); 00516 00517 virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const; 00518 virtual QModelIndex parent( const QModelIndex & index ) const; 00519 00520 // TODO: Review the implementations of these. I think they could be better. 00521 virtual bool canFetchMore( const QModelIndex & parent ) const; 00522 virtual void fetchMore( const QModelIndex & parent ); 00523 virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const; 00524 00528 virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const; 00529 00561 static QModelIndex modelIndexForCollection( const QAbstractItemModel *model, const Collection &collection ); 00562 00570 static QModelIndexList modelIndexesForItem( const QAbstractItemModel *model, const Item &item ); 00571 00572 protected: 00577 void clearAndReset(); 00578 00582 virtual QVariant entityData( const Item &item, int column, int role = Qt::DisplayRole ) const; 00583 00587 virtual QVariant entityData( const Collection &collection, int column, int role = Qt::DisplayRole ) const; 00588 00593 virtual QVariant entityHeaderData( int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup ) const; 00594 00595 virtual int entityColumnCount( HeaderGroup headerGroup ) const; 00596 00600 virtual bool entityMatch( const Item &item, const QVariant &value, Qt::MatchFlags flags ) const; 00601 00605 virtual bool entityMatch( const Collection &collection, const QVariant &value, Qt::MatchFlags flags ) const; 00606 00607 protected: 00608 //@cond PRIVATE 00609 Q_DECLARE_PRIVATE( EntityTreeModel ) 00610 EntityTreeModelPrivate * d_ptr; 00611 EntityTreeModel( ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 ); 00612 //@endcond 00613 00614 private: 00615 //@cond PRIVATE 00616 // Make these private, they shouldn't be called by applications 00617 virtual bool insertRows( int , int, const QModelIndex& = QModelIndex() ); 00618 virtual bool insertColumns( int, int, const QModelIndex& = QModelIndex() ); 00619 virtual bool removeColumns( int, int, const QModelIndex& = QModelIndex() ); 00620 virtual bool removeRows( int, int, const QModelIndex & = QModelIndex() ); 00621 00622 Q_PRIVATE_SLOT( d_func(), void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id, 00623 const Akonadi::CollectionStatistics& ) ) 00624 00625 Q_PRIVATE_SLOT( d_func(), void startFirstListJob() ) 00626 Q_PRIVATE_SLOT( d_func(), void serverStarted() ) 00627 00628 Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) ) 00629 Q_PRIVATE_SLOT( d_func(), void rootFetchJobDone( KJob *job ) ) 00630 Q_PRIVATE_SLOT( d_func(), void pasteJobDone( KJob *job ) ) 00631 Q_PRIVATE_SLOT( d_func(), void updateJobDone( KJob *job ) ) 00632 Q_PRIVATE_SLOT( d_func(), void firstFetchJobDone( KJob *job ) ) 00633 00634 Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) ) 00635 Q_PRIVATE_SLOT( d_func(), void itemsFetched( KJob* ) ) 00636 Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) ) 00637 Q_PRIVATE_SLOT( d_func(), void firstCollectionsFetched( Akonadi::Collection::List ) ) 00638 Q_PRIVATE_SLOT( d_func(), void collectionListFetched( Akonadi::Collection::List ) ) 00639 Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( Akonadi::Collection::List ) ) 00640 Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) ) 00641 00642 Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) ) 00643 Q_PRIVATE_SLOT( d_func(), void monitoredCollectionsChanged( const Akonadi::Collection&, bool ) ) 00644 Q_PRIVATE_SLOT( d_func(), void monitoredItemsChanged( const Akonadi::Item&, bool ) ) 00645 Q_PRIVATE_SLOT( d_func(), void monitoredResourcesChanged( const QByteArray&, bool ) ) 00646 00647 Q_PRIVATE_SLOT( d_func(), void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) ) 00648 Q_PRIVATE_SLOT( d_func(), void monitoredCollectionRemoved( const Akonadi::Collection& ) ) 00649 Q_PRIVATE_SLOT( d_func(), void monitoredCollectionChanged( const Akonadi::Collection& ) ) 00650 Q_PRIVATE_SLOT( d_func(), void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&, 00651 const Akonadi::Collection&) ) 00652 Q_PRIVATE_SLOT( d_func(), void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& ) ) 00653 Q_PRIVATE_SLOT( d_func(), void monitoredCollectionUnsubscribed( const Akonadi::Collection& ) ) 00654 00655 Q_PRIVATE_SLOT( d_func(), void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& ) ) 00656 Q_PRIVATE_SLOT( d_func(), void monitoredItemRemoved( const Akonadi::Item& ) ) 00657 Q_PRIVATE_SLOT( d_func(), void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) ) 00658 Q_PRIVATE_SLOT( d_func(), void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&, 00659 const Akonadi::Collection& ) ) 00660 00661 Q_PRIVATE_SLOT( d_func(), void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& ) ) 00662 Q_PRIVATE_SLOT( d_func(), void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) ) 00663 Q_PRIVATE_SLOT( d_func(), void changeFetchState( const Akonadi::Collection & ) ) 00664 00665 Q_PRIVATE_SLOT( d_func(), void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& ) ) 00666 Q_PRIVATE_SLOT( d_func(), void agentInstanceRemoved( Akonadi::AgentInstance ) ) 00667 Q_PRIVATE_SLOT( d_func(), void monitoredItemsRetrieved(KJob* job) ) 00668 //@endcond 00669 }; 00670 00671 } // namespace 00672 00673 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue May 8 2012 00:00:43 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Tue May 8 2012 00:00:43 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.