akonadi
favoritecollectionsmodel.h
00001 /* 00002 Copyright (c) 2009 Kevin Ottens <ervin@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_FAVORITECOLLECTIONSMODEL_H 00021 #define AKONADI_FAVORITECOLLECTIONSMODEL_H 00022 00023 #include "akonadi_export.h" 00024 00025 #include <akonadi/selectionproxymodel.h> 00026 00027 #include <akonadi/collection.h> 00028 00029 class KConfigGroup; 00030 00031 namespace Akonadi { 00032 00033 class EntityTreeModel; 00034 00064 class AKONADI_EXPORT FavoriteCollectionsModel : public Akonadi::SelectionProxyModel 00065 { 00066 Q_OBJECT 00067 00068 public: 00078 FavoriteCollectionsModel( QAbstractItemModel *model, const KConfigGroup &group, QObject *parent = 0 ); 00079 00083 virtual ~FavoriteCollectionsModel(); 00084 00089 Collection::List collections() const; 00090 00113 QList<Collection::Id> collectionIds() const; 00114 00118 QString favoriteLabel( const Akonadi::Collection & col ); 00119 00120 virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; 00121 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); 00122 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 00123 virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent); 00124 virtual QStringList mimeTypes() const; 00125 virtual Qt::ItemFlags flags(const QModelIndex& index) const; 00126 00127 public Q_SLOTS: 00131 void setCollections( const Collection::List &collections ); 00132 00136 void addCollection( const Collection &collection ); 00137 00141 void removeCollection( const Collection &collection ); 00142 00147 void setFavoriteLabel( const Collection &collection, const QString &label ); 00148 00149 private: 00150 //@cond PRIVATE 00151 using KSelectionProxyModel::setSourceModel; 00152 00153 class Private; 00154 Private* const d; 00155 00156 Q_PRIVATE_SLOT( d, void clearAndUpdateSelection() ) 00157 Q_PRIVATE_SLOT( d, void updateSelection() ) 00158 //@endcond 00159 }; 00160 00161 } 00162 00163 #endif