• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • 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 
00308 class AKONADI_EXPORT EntityTreeModel : public QAbstractItemModel
00309 {
00310   Q_OBJECT
00311 
00312   public:
00316     enum Roles {
00317       //sebsauer, 2009-05-07; to be able here to keep the akonadi_next EntityTreeModel compatible with
00318       //the akonadi_old ItemModel and CollectionModel, we need to use the same int-values for
00319       //ItemRole, ItemIdRole and MimeTypeRole like the Akonadi::ItemModel is using and the same
00320       //CollectionIdRole and CollectionRole like the Akonadi::CollectionModel is using.
00321       ItemIdRole = Qt::UserRole + 1,          
00322       ItemRole = Qt::UserRole + 2,            
00323       MimeTypeRole = Qt::UserRole + 3,        
00324 
00325       CollectionIdRole = Qt::UserRole + 10,   
00326       CollectionRole = Qt::UserRole + 11,     
00327 
00328       RemoteIdRole,                           
00329       CollectionChildOrderRole,               
00330       AmazingCompletionRole,                  
00331       ParentCollectionRole,                   
00332       ColumnCountRole,                        
00333       LoadedPartsRole,                        
00334       AvailablePartsRole,                     
00335       SessionRole,                            
00336       CollectionRefRole,                      
00337       CollectionDerefRole,                    
00338       PendingCutRole,                         
00339       EntityUrlRole,                          
00340       UnreadCountRole,                        
00341       FetchStateRole,                         
00342       UserRole = Qt::UserRole + 500,          
00343       TerminalUserRole = 2000,                
00344       EndRole = 65535
00345     };
00346 
00351     enum FetchState {
00352       IdleState,                              
00353       FetchingState                           
00354       // TODO: Change states for reporting of fetching payload parts of items.
00355     };
00356 
00360     enum HeaderGroup {
00361       EntityTreeHeaders,      
00362       CollectionTreeHeaders,  
00363       ItemListHeaders,        
00364       UserHeaders = 10,       
00365       EndHeaderGroup = 32     
00366       // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32
00367     };
00368 
00375     explicit EntityTreeModel( ChangeRecorder *monitor, QObject *parent = 0 );
00376 
00380     virtual ~EntityTreeModel();
00381 
00385     enum ItemPopulationStrategy {
00386       NoItemPopulation,    
00387       ImmediatePopulation, 
00388       LazyPopulation       
00389     };
00390 
00399     void setShowSystemEntities( bool show );
00400 
00404     bool systemEntitiesShown() const;
00405 
00406 
00412     bool includeUnsubscribed() const;
00413 
00420     void setIncludeUnsubscribed( bool show );
00421 
00422 
00426     void setItemPopulationStrategy( ItemPopulationStrategy strategy );
00427 
00431     ItemPopulationStrategy itemPopulationStrategy() const;
00432 
00438     void setIncludeRootCollection( bool include );
00439 
00443     bool includeRootCollection() const;
00444 
00452     void setRootCollectionDisplayName( const QString &name );
00453 
00457     QString rootCollectionDisplayName() const;
00458 
00462     enum CollectionFetchStrategy {
00463       FetchNoCollections,               
00464       FetchFirstLevelChildCollections,  
00465       FetchCollectionsRecursive,        
00466       InvisibleCollectionFetch          
00467     };
00468 
00472     void setCollectionFetchStrategy( CollectionFetchStrategy strategy );
00473 
00477     CollectionFetchStrategy collectionFetchStrategy() const;
00478 
00479     virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
00480     virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
00481 
00482     virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00483     virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00484 
00485     virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
00486     virtual QStringList mimeTypes() const;
00487 
00488     virtual Qt::DropActions supportedDropActions() const;
00489     virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
00490     virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
00491     virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
00492 
00493     virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00494     virtual QModelIndex parent( const QModelIndex & index ) const;
00495 
00496     // TODO: Review the implementations of these. I think they could be better.
00497     virtual bool canFetchMore( const QModelIndex & parent ) const;
00498     virtual void fetchMore( const QModelIndex & parent );
00499     virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
00500 
00504     virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const;
00505 
00537     static QModelIndex modelIndexForCollection( const QAbstractItemModel *model, const Collection &collection );
00538 
00546     static QModelIndexList modelIndexesForItem( const QAbstractItemModel *model, const Item &item );
00547 
00548   protected:
00553     void clearAndReset();
00554 
00558     virtual QVariant entityData( const Item &item, int column, int role = Qt::DisplayRole ) const;
00559 
00563     virtual QVariant entityData( const Collection &collection, int column, int role = Qt::DisplayRole ) const;
00564 
00569     virtual QVariant entityHeaderData( int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup ) const;
00570 
00571     virtual int entityColumnCount( HeaderGroup headerGroup ) const;
00572 
00576     virtual bool entityMatch( const Item &item, const QVariant &value, Qt::MatchFlags flags ) const;
00577 
00581     virtual bool entityMatch( const Collection &collection, const QVariant &value, Qt::MatchFlags flags ) const;
00582 
00583 protected:
00584     //@cond PRIVATE
00585     Q_DECLARE_PRIVATE( EntityTreeModel )
00586     EntityTreeModelPrivate * d_ptr;
00587     EntityTreeModel( ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 );
00588     //@endcond
00589 
00590 private:
00591   //@cond PRIVATE
00592     // Make these private, they shouldn't be called by applications
00593     virtual bool insertRows( int , int, const QModelIndex& = QModelIndex() );
00594     virtual bool insertColumns( int, int, const QModelIndex& = QModelIndex() );
00595     virtual bool removeColumns( int, int, const QModelIndex& = QModelIndex() );
00596     virtual bool removeRows( int, int, const QModelIndex & = QModelIndex() );
00597 
00598     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id,
00599                                                                          const Akonadi::CollectionStatistics& ) )
00600 
00601     Q_PRIVATE_SLOT( d_func(), void rootCollectionFetched(Akonadi::Collection::List) )
00602     Q_PRIVATE_SLOT( d_func(), void startFirstListJob() )
00603     Q_PRIVATE_SLOT( d_func(), void serverStarted() )
00604 
00605     // TODO: Can I merge these into one jobResult slot?
00606     Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) )
00607     Q_PRIVATE_SLOT( d_func(), void pasteJobDone( KJob *job ) )
00608     Q_PRIVATE_SLOT( d_func(), void updateJobDone( KJob *job ) )
00609 
00610     Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) )
00611     Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) )
00612     Q_PRIVATE_SLOT( d_func(), void collectionListFetched( Akonadi::Collection::List ) )
00613     Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( Akonadi::Collection::List ) )
00614     Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) )
00615 
00616     Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) )
00617     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionsChanged( const Akonadi::Collection&, bool ) )
00618 
00619     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) )
00620     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionRemoved( const Akonadi::Collection& ) )
00621     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionChanged( const Akonadi::Collection& ) )
00622     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&,
00623                                                              const Akonadi::Collection&) )
00624 
00625     Q_PRIVATE_SLOT( d_func(), void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& ) )
00626     Q_PRIVATE_SLOT( d_func(), void monitoredItemRemoved( const Akonadi::Item& ) )
00627     Q_PRIVATE_SLOT( d_func(), void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
00628     Q_PRIVATE_SLOT( d_func(), void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&,
00629                                                        const Akonadi::Collection& ) )
00630 
00631     Q_PRIVATE_SLOT( d_func(), void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& ) )
00632     Q_PRIVATE_SLOT( d_func(), void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) )
00633     //@endcond
00634 };
00635 
00636 } // namespace
00637 
00638 #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
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • 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.1
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