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 
00088     Collection::List collections() const;
00089 
00093     QString favoriteLabel( const Akonadi::Collection & col );
00094 
00095     virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00096     virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00097 
00098   public Q_SLOTS:
00102     void setCollections( const Collection::List &collections );
00103 
00107     void addCollection( const Collection &collection );
00108 
00112     void removeCollection( const Collection &collection );
00113 
00118     void setFavoriteLabel( const Collection &collection, const QString &label );
00119 
00120   private:
00121     //@cond PRIVATE
00122     using KSelectionProxyModel::setSourceModel;
00123 
00124     class Private;
00125     Private* const d;
00126 
00127     Q_PRIVATE_SLOT( d, void clearAndUpdateSelection() )
00128     Q_PRIVATE_SLOT( d, void updateSelection() )
00129     //@endcond
00130 };
00131 
00132 }
00133 
00134 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys