monitor.h
00001 /* 00002 Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org> 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_MONITOR_H 00021 #define AKONADI_MONITOR_H 00022 00023 #include <akonadi/collection.h> 00024 #include <akonadi/item.h> 00025 00026 #include <QtCore/QObject> 00027 00028 namespace Akonadi { 00029 00030 class CollectionFetchScope; 00031 class CollectionStatistics; 00032 class Item; 00033 class ItemFetchScope; 00034 class MonitorPrivate; 00035 class Session; 00036 00072 class AKONADI_EXPORT Monitor : public QObject 00073 { 00074 Q_OBJECT 00075 00076 public: 00082 explicit Monitor( QObject *parent = 0 ); 00083 00087 virtual ~Monitor(); 00088 00104 void setCollectionMonitored( const Collection &collection, bool monitored = true ); 00105 00115 void setItemMonitored( const Item &item, bool monitored = true ); 00116 00128 void setResourceMonitored( const QByteArray &resource, bool monitored = true ); 00129 00143 void setMimeTypeMonitored( const QString &mimetype, bool monitored = true ); 00144 00151 void setAllMonitored( bool monitored = true ); 00152 00159 void ignoreSession( Session *session ); 00160 00166 void fetchCollection( bool enable ); 00167 00174 void fetchCollectionStatistics( bool enable ); 00175 00186 void setItemFetchScope( const ItemFetchScope &fetchScope ); 00187 00188 00213 void fetchChangedOnly( bool enable ); 00214 00227 ItemFetchScope &itemFetchScope(); 00228 00240 void setCollectionFetchScope( const CollectionFetchScope &fetchScope ); 00241 00255 CollectionFetchScope &collectionFetchScope(); 00256 00262 Collection::List collectionsMonitored() const; 00263 00271 KDE_DEPRECATED QList<Item::Id> itemsMonitored() const; 00272 00280 QVector<Item::Id> itemsMonitoredEx() const; 00281 00287 QStringList mimeTypesMonitored() const; 00288 00294 QList<QByteArray> resourcesMonitored() const; 00295 00301 bool isAllMonitored() const; 00302 00309 void setSession( Akonadi::Session *session ); 00310 00316 Session* session() const; 00317 00318 Q_SIGNALS: 00325 void itemChanged( const Akonadi::Item &item, const QSet<QByteArray> &partIdentifiers ); 00326 00334 void itemMoved( const Akonadi::Item &item, const Akonadi::Collection &collectionSource, 00335 const Akonadi::Collection &collectionDestination ); 00336 00343 void itemAdded( const Akonadi::Item &item, const Akonadi::Collection &collection ); 00344 00353 void itemRemoved( const Akonadi::Item &item ); 00354 00362 void itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection ); 00363 00371 void itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection ); 00372 00379 void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent ); 00380 00386 void collectionChanged( const Akonadi::Collection &collection ); 00387 00396 void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &attributeNames ); 00397 00407 void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &destination ); 00408 00414 void collectionRemoved( const Akonadi::Collection &collection ); 00415 00426 void collectionSubscribed( const Akonadi::Collection& collection, const Akonadi::Collection &parent ); 00427 00435 void collectionUnsubscribed( const Akonadi::Collection& collection ); 00436 00445 void collectionStatisticsChanged( Akonadi::Collection::Id id, 00446 const Akonadi::CollectionStatistics &statistics ); 00447 00455 void collectionMonitored( const Akonadi::Collection &collection, bool monitored ); 00456 00464 void itemMonitored( const Akonadi::Item &item, bool monitored ); 00465 00473 void resourceMonitored( const QByteArray &identifier, bool monitored ); 00474 00482 void mimeTypeMonitored( const QString &mimeType, bool monitored ); 00483 00490 void allMonitored( bool monitored ); 00491 00492 protected: 00493 //@cond PRIVATE 00494 friend class EntityTreeModel; 00495 friend class EntityTreeModelPrivate; 00496 MonitorPrivate *d_ptr; 00497 explicit Monitor( MonitorPrivate *d, QObject *parent = 0 ); 00498 //@endcond 00499 00500 private: 00501 Q_DECLARE_PRIVATE( Monitor ) 00502 00503 //@cond PRIVATE 00504 Q_PRIVATE_SLOT( d_ptr, void slotSessionDestroyed( QObject* ) ) 00505 Q_PRIVATE_SLOT( d_ptr, void slotStatisticsChangedFinished( KJob* ) ) 00506 Q_PRIVATE_SLOT( d_ptr, void slotFlushRecentlyChangedCollections() ) 00507 Q_PRIVATE_SLOT( d_ptr, void slotNotify( const Akonadi::NotificationMessage::List& ) ) 00508 Q_PRIVATE_SLOT( d_ptr, void dataAvailable() ) 00509 Q_PRIVATE_SLOT( d_ptr, void serverStateChanged( Akonadi::ServerManager::State ) ) 00510 Q_PRIVATE_SLOT( d_ptr, void invalidateCollectionCache( qint64 ) ) 00511 Q_PRIVATE_SLOT( d_ptr, void invalidateItemCache( qint64 ) ) 00512 00513 friend class ResourceBasePrivate; 00514 //@endcond 00515 }; 00516 00517 } 00518 00519 #endif