• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

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 
00361     enum FetchState {
00362       IdleState,                              
00363       FetchingState                           
00364       // TODO: Change states for reporting of fetching payload parts of items.
00365     };
00366 
00370     enum HeaderGroup {
00371       EntityTreeHeaders,      
00372       CollectionTreeHeaders,  
00373       ItemListHeaders,        
00374       UserHeaders = 10,       
00375       EndHeaderGroup = 32     
00376       // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32
00377     };
00378 
00385     explicit EntityTreeModel( ChangeRecorder *monitor, QObject *parent = 0 );
00386 
00390     virtual ~EntityTreeModel();
00391 
00395     enum ItemPopulationStrategy {
00396       NoItemPopulation,    
00397       ImmediatePopulation, 
00398       LazyPopulation       
00399     };
00400 
00409     void setShowSystemEntities( bool show );
00410 
00414     bool systemEntitiesShown() const;
00415 
00416 
00422     bool includeUnsubscribed() const;
00423 
00434     void setIncludeUnsubscribed( bool show );
00435 
00436 
00440     void setItemPopulationStrategy( ItemPopulationStrategy strategy );
00441 
00445     ItemPopulationStrategy itemPopulationStrategy() const;
00446 
00452     void setIncludeRootCollection( bool include );
00453 
00457     bool includeRootCollection() const;
00458 
00466     void setRootCollectionDisplayName( const QString &name );
00467 
00471     QString rootCollectionDisplayName() const;
00472 
00476     enum CollectionFetchStrategy {
00477       FetchNoCollections,               
00478       FetchFirstLevelChildCollections,  
00479       FetchCollectionsRecursive,        
00480       InvisibleCollectionFetch          
00481     };
00482 
00486     void setCollectionFetchStrategy( CollectionFetchStrategy strategy );
00487 
00491     CollectionFetchStrategy collectionFetchStrategy() const;
00492 
00493     virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
00494     virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
00495 
00496     virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00497     virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00498 
00499     virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
00500     virtual QStringList mimeTypes() const;
00501 
00502     virtual Qt::DropActions supportedDropActions() const;
00503     virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
00504     virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
00505     virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
00506 
00507     virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00508     virtual QModelIndex parent( const QModelIndex & index ) const;
00509 
00510     // TODO: Review the implementations of these. I think they could be better.
00511     virtual bool canFetchMore( const QModelIndex & parent ) const;
00512     virtual void fetchMore( const QModelIndex & parent );
00513     virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
00514 
00518     virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const;
00519 
00551     static QModelIndex modelIndexForCollection( const QAbstractItemModel *model, const Collection &collection );
00552 
00560     static QModelIndexList modelIndexesForItem( const QAbstractItemModel *model, const Item &item );
00561 
00562   protected:
00567     void clearAndReset();
00568 
00572     virtual QVariant entityData( const Item &item, int column, int role = Qt::DisplayRole ) const;
00573 
00577     virtual QVariant entityData( const Collection &collection, int column, int role = Qt::DisplayRole ) const;
00578 
00583     virtual QVariant entityHeaderData( int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup ) const;
00584 
00585     virtual int entityColumnCount( HeaderGroup headerGroup ) const;
00586 
00590     virtual bool entityMatch( const Item &item, const QVariant &value, Qt::MatchFlags flags ) const;
00591 
00595     virtual bool entityMatch( const Collection &collection, const QVariant &value, Qt::MatchFlags flags ) const;
00596 
00597 protected:
00598     //@cond PRIVATE
00599     Q_DECLARE_PRIVATE( EntityTreeModel )
00600     EntityTreeModelPrivate * d_ptr;
00601     EntityTreeModel( ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 );
00602     //@endcond
00603 
00604 private:
00605   //@cond PRIVATE
00606     // Make these private, they shouldn't be called by applications
00607     virtual bool insertRows( int , int, const QModelIndex& = QModelIndex() );
00608     virtual bool insertColumns( int, int, const QModelIndex& = QModelIndex() );
00609     virtual bool removeColumns( int, int, const QModelIndex& = QModelIndex() );
00610     virtual bool removeRows( int, int, const QModelIndex & = QModelIndex() );
00611 
00612     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id,
00613                                                                          const Akonadi::CollectionStatistics& ) )
00614 
00615     Q_PRIVATE_SLOT( d_func(), void rootCollectionFetched(Akonadi::Collection::List) )
00616     Q_PRIVATE_SLOT( d_func(), void startFirstListJob() )
00617     Q_PRIVATE_SLOT( d_func(), void serverStarted() )
00618 
00619     // TODO: Can I merge these into one jobResult slot?
00620     Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) )
00621     Q_PRIVATE_SLOT( d_func(), void pasteJobDone( KJob *job ) )
00622     Q_PRIVATE_SLOT( d_func(), void updateJobDone( KJob *job ) )
00623     Q_PRIVATE_SLOT( d_func(), void firstFetchJobDone( KJob *job ) )
00624 
00625     Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) )
00626     Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) )
00627     Q_PRIVATE_SLOT( d_func(), void firstCollectionsFetched( Akonadi::Collection::List ) )
00628     Q_PRIVATE_SLOT( d_func(), void collectionListFetched( Akonadi::Collection::List ) )
00629     Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( Akonadi::Collection::List ) )
00630     Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) )
00631 
00632     Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) )
00633     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionsChanged( const Akonadi::Collection&, bool ) )
00634 
00635     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) )
00636     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionRemoved( const Akonadi::Collection& ) )
00637     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionChanged( const Akonadi::Collection& ) )
00638     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&,
00639                                                              const Akonadi::Collection&) )
00640     Q_PRIVATE_SLOT( d_func(), void collectionSubscribed( const Akonadi::Collection&, const Akonadi::Collection& ) )
00641     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionUnsubscribed( const Akonadi::Collection& ) )
00642 
00643     Q_PRIVATE_SLOT( d_func(), void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& ) )
00644     Q_PRIVATE_SLOT( d_func(), void monitoredItemRemoved( const Akonadi::Item& ) )
00645     Q_PRIVATE_SLOT( d_func(), void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
00646     Q_PRIVATE_SLOT( d_func(), void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&,
00647                                                        const Akonadi::Collection& ) )
00648 
00649     Q_PRIVATE_SLOT( d_func(), void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& ) )
00650     Q_PRIVATE_SLOT( d_func(), void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) )
00651     Q_PRIVATE_SLOT( d_func(), void changeFetchState( const Akonadi::Collection & ) )
00652 
00653     Q_PRIVATE_SLOT( d_func(), void agentInstanceAdvancedStatusChanged( const QString&, const QVariantMap& ) )
00654     //@endcond
00655 };
00656 
00657 } // namespace
00658 
00659 #endif

akonadi

Skip menu "akonadi"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • 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
Generated for KDE-PIM Libraries by doxygen 1.7.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal