akonadi
collectionmodel_p.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AKONADI_COLLECTIONMODEL_P_H
00021 #define AKONADI_COLLECTIONMODEL_P_H
00022
00023 #include "collection.h"
00024
00025 #include <klocale.h>
00026
00027 #include <QtCore/QHash>
00028 #include <QtCore/QList>
00029 #include <QtCore/QModelIndex>
00030 #include <QtCore/QStringList>
00031
00032 class KJob;
00033
00034 namespace Akonadi {
00035
00036
00037 class CollectionModel;
00038 class CollectionStatistics;
00039 class Monitor;
00040 class Session;
00041
00045 class CollectionModelPrivate
00046 {
00047 public:
00048 Q_DECLARE_PUBLIC( CollectionModel )
00049 CollectionModelPrivate( CollectionModel *parent )
00050 : q_ptr( parent ), fetchStatistics( false ), unsubscribed( false ),
00051 headerContent( i18nc( "@title:column, name of a thing", "Name" ) )
00052 {
00053 }
00054
00055 virtual ~CollectionModelPrivate() {}
00056
00057 CollectionModel *q_ptr;
00058 QHash<Collection::Id, Collection> collections;
00059 QHash<Collection::Id, QList<Collection::Id> > childCollections;
00060
00061 QHash<Collection::Id, Collection> m_newCollections;
00062 QHash< Collection::Id, QList< Collection::Id > > m_newChildCollections;
00063
00064 Monitor *monitor;
00065 Session *session;
00066 QStringList mimeTypes;
00067 bool fetchStatistics;
00068 bool unsubscribed;
00069 QString headerContent;
00070
00071 void init();
00072 void startFirstListJob();
00073 void collectionRemoved( const Akonadi::Collection& );
00074 void collectionChanged( const Akonadi::Collection& );
00075 void updateDone( KJob* );
00076 void collectionStatisticsChanged( Collection::Id, const Akonadi::CollectionStatistics& );
00077 void listDone( KJob* );
00078 void editDone( KJob* );
00079 void dropResult( KJob* );
00080 void collectionsChanged( const Akonadi::Collection::List &cols );
00081
00082 QModelIndex indexForId( Collection::Id id, int column = 0 ) const;
00083 bool removeRowFromModel( int row, const QModelIndex & parent = QModelIndex() );
00084 bool supportsContentType( const QModelIndex &index, const QStringList &contentTypes );
00085
00086 private:
00087 void updateSupportedMimeTypes( Collection col )
00088 {
00089 QStringList l = col.contentMimeTypes();
00090 for ( QStringList::ConstIterator it = l.constBegin(); it != l.constEnd(); ++it ) {
00091 if ( (*it) == Collection::mimeType() )
00092 continue;
00093 if ( !mimeTypes.contains( *it ) )
00094 mimeTypes << *it;
00095 }
00096 }
00097 };
00098
00099 }
00100
00101 #endif