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 class KJob; 00031 00032 namespace Akonadi { 00033 00034 class EntityTreeModel; 00035 00065 class AKONADI_EXPORT FavoriteCollectionsModel : public Akonadi::SelectionProxyModel 00066 { 00067 Q_OBJECT 00068 00069 public: 00079 FavoriteCollectionsModel( QAbstractItemModel *model, const KConfigGroup &group, QObject *parent = 0 ); 00080 00084 virtual ~FavoriteCollectionsModel(); 00085 00090 Collection::List collections() const; 00091 00114 QList<Collection::Id> collectionIds() const; 00115 00119 QString favoriteLabel( const Akonadi::Collection & col ); 00120 00121 virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; 00122 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); 00123 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 00124 virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent); 00125 virtual QStringList mimeTypes() const; 00126 virtual Qt::ItemFlags flags(const QModelIndex& index) const; 00127 00128 public Q_SLOTS: 00132 void setCollections( const Collection::List &collections ); 00133 00137 void addCollection( const Collection &collection ); 00138 00142 void removeCollection( const Collection &collection ); 00143 00148 void setFavoriteLabel( const Collection &collection, const QString &label ); 00149 00150 private Q_SLOTS: 00151 void pasteJobDone( KJob *job ); 00152 00153 private: 00154 //@cond PRIVATE 00155 using KSelectionProxyModel::setSourceModel; 00156 00157 class Private; 00158 Private* const d; 00159 00160 Q_PRIVATE_SLOT( d, void clearAndUpdateSelection() ) 00161 Q_PRIVATE_SLOT( d, void updateSelection() ) 00162 //@endcond 00163 }; 00164 00165 } 00166 00167 #endif