• Skip to content
  • Skip to link menu
KDE 4.4 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 
00310 class AKONADI_EXPORT EntityTreeModel : public QAbstractItemModel
00311 {
00312   Q_OBJECT
00313 
00314   public:
00318     enum Roles {
00319       //sebsauer, 2009-05-07; to be able here to keep the akonadi_next EntityTreeModel compatible with
00320       //the akonadi_old ItemModel and CollectionModel, we need to use the same int-values for
00321       //ItemRole, ItemIdRole and MimeTypeRole like the Akonadi::ItemModel is using and the same
00322       //CollectionIdRole and CollectionRole like the Akonadi::CollectionModel is using.
00323       ItemIdRole = Qt::UserRole + 1,          
00324       ItemRole = Qt::UserRole + 2,            
00325       MimeTypeRole = Qt::UserRole + 3,        
00326 
00327       CollectionIdRole = Qt::UserRole + 10,   
00328       CollectionRole = Qt::UserRole + 11,     
00329 
00330       RemoteIdRole,                           
00331       CollectionChildOrderRole,               
00332       AmazingCompletionRole,                  
00333       ParentCollectionRole,                   
00334       ColumnCountRole,                        
00335       LoadedPartsRole,                        
00336       AvailablePartsRole,                     
00337       SessionRole,                            
00338       CollectionRefRole,                      
00339       CollectionDerefRole,                    
00340       PendingCutRole,                         
00341       EntityUrlRole,                          
00342       UserRole = Qt::UserRole + 500,          
00343       TerminalUserRole = 2000,                
00344       EndRole = 65535
00345     };
00346 
00347 
00351     enum HeaderGroup {
00352       EntityTreeHeaders,      
00353       CollectionTreeHeaders,  
00354       ItemListHeaders,        
00355       UserHeaders = 10,       
00356       EndHeaderGroup = 32     
00357       // Note that we're splitting up available roles for the header data hack and int(EndRole / TerminalUserRole) == 32
00358     };
00359 
00366     explicit EntityTreeModel( ChangeRecorder *monitor, QObject *parent = 0 );
00367 
00371     virtual ~EntityTreeModel();
00372 
00376     enum ItemPopulationStrategy {
00377       NoItemPopulation,    
00378       ImmediatePopulation, 
00379       LazyPopulation       
00380     };
00381 
00390     void setShowSystemEntities( bool show );
00391 
00395     bool systemEntitiesShown() const;
00396 
00400     void setItemPopulationStrategy( ItemPopulationStrategy strategy );
00401 
00405     ItemPopulationStrategy itemPopulationStrategy() const;
00406 
00412     void setIncludeRootCollection( bool include );
00413 
00417     bool includeRootCollection() const;
00418 
00426     void setRootCollectionDisplayName( const QString &name );
00427 
00431     QString rootCollectionDisplayName() const;
00432 
00436     enum CollectionFetchStrategy {
00437       FetchNoCollections,               
00438       FetchFirstLevelChildCollections,  
00439       FetchCollectionsRecursive         
00440     };
00441 
00445     void setCollectionFetchStrategy( CollectionFetchStrategy strategy );
00446 
00450     CollectionFetchStrategy collectionFetchStrategy() const;
00451 
00452     virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
00453     virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
00454 
00455     virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00456     virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00457 
00458     virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
00459     virtual QStringList mimeTypes() const;
00460 
00461     virtual Qt::DropActions supportedDropActions() const;
00462     virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
00463     virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
00464     virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
00465 
00466     virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00467     virtual QModelIndex parent( const QModelIndex & index ) const;
00468 
00469     // TODO: Review the implementations of these. I think they could be better.
00470     virtual bool canFetchMore( const QModelIndex & parent ) const;
00471     virtual void fetchMore( const QModelIndex & parent );
00472     virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
00473 
00477     virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const;
00478 
00479   protected:
00484     void clearAndReset();
00485 
00489     virtual QVariant entityData( const Item &item, int column, int role = Qt::DisplayRole ) const;
00490 
00494     virtual QVariant entityData( const Collection &collection, int column, int role = Qt::DisplayRole ) const;
00495 
00500     virtual QVariant entityHeaderData( int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup ) const;
00501 
00502     virtual int entityColumnCount( HeaderGroup headerGroup ) const;
00503 
00507     virtual bool entityMatch( const Item &item, const QVariant &value, Qt::MatchFlags flags ) const;
00508 
00512     virtual bool entityMatch( const Collection &collection, const QVariant &value, Qt::MatchFlags flags ) const;
00513 
00514 protected:
00515     //@cond PRIVATE
00516     Q_DECLARE_PRIVATE( EntityTreeModel )
00517     EntityTreeModelPrivate * d_ptr;
00518     EntityTreeModel( ChangeRecorder *monitor, EntityTreeModelPrivate *d, QObject* parent = 0 );
00519     //@endcond
00520 
00521 private:
00522   //@cond PRIVATE
00523     // Make these private, they shouldn't be called by applications
00524     virtual bool insertRows( int , int, const QModelIndex& = QModelIndex() );
00525     virtual bool insertColumns( int, int, const QModelIndex& = QModelIndex() );
00526     virtual bool removeColumns( int, int, const QModelIndex& = QModelIndex() );
00527     virtual bool removeRows( int, int, const QModelIndex & = QModelIndex() );
00528 
00529     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id,
00530                                                                          const Akonadi::CollectionStatistics& ) )
00531 
00532     Q_PRIVATE_SLOT( d_func(), void rootCollectionFetched(Akonadi::Collection::List) )
00533     Q_PRIVATE_SLOT( d_func(), void startFirstListJob() )
00534     // Q_PRIVATE_SLOT( d_func(), void slotModelReset() )
00535 
00536     // TODO: Can I merge these into one jobResult slot?
00537     Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) )
00538     Q_PRIVATE_SLOT( d_func(), void pasteJobDone( KJob *job ) )
00539     Q_PRIVATE_SLOT( d_func(), void updateJobDone( KJob *job ) )
00540 
00541     Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) )
00542     Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) )
00543     Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( Akonadi::Collection::List ) )
00544     Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) )
00545 
00546     Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) )
00547 
00548     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) )
00549     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionRemoved( const Akonadi::Collection& ) )
00550     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionChanged( const Akonadi::Collection& ) )
00551     Q_PRIVATE_SLOT( d_func(), void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&,
00552                                                              const Akonadi::Collection&) )
00553 
00554     Q_PRIVATE_SLOT( d_func(), void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& ) )
00555     Q_PRIVATE_SLOT( d_func(), void monitoredItemRemoved( const Akonadi::Item& ) )
00556     Q_PRIVATE_SLOT( d_func(), void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
00557     Q_PRIVATE_SLOT( d_func(), void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&,
00558                                                        const Akonadi::Collection& ) )
00559 
00560     Q_PRIVATE_SLOT( d_func(), void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& ) )
00561     Q_PRIVATE_SLOT( d_func(), void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) )
00562     //@endcond
00563 };
00564 
00565 } // namespace
00566 
00567 #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.6.2-20100208
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