/usr/include/akonadi/favoritecollectionsmodel.h is in kdepimlibs5-dev 4:4.13.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | /*
Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef AKONADI_FAVORITECOLLECTIONSMODEL_H
#define AKONADI_FAVORITECOLLECTIONSMODEL_H
#include "akonadi_export.h"
#include <akonadi/selectionproxymodel.h>
#include <akonadi/collection.h>
class KConfigGroup;
class KJob;
namespace Akonadi {
class EntityTreeModel;
/**
* @short A model that lists a set of favorite collections.
*
* In some applications you want to provide fast access to a list
* of often used collections (e.g. Inboxes from different email accounts
* in a mail application). Therefor you can use the FavoriteCollectionsModel
* which stores the list of favorite collections in a given configuration
* file.
*
* Example:
*
* @code
*
* using namespace Akonadi;
*
* EntityTreeModel *sourceModel = new EntityTreeModel( ... );
*
* const KConfigGroup group = KGlobal::config()->group( "Favorite Collections" );
*
* FavoriteCollectionsModel *model = new FavoriteCollectionsModel( sourceModel, group, this );
*
* EntityListView *view = new EntityListView( this );
* view->setModel( model );
*
* @endcode
*
* @author Kevin Ottens <ervin@kde.org>
* @since 4.4
*/
//TODO_KDE5: Make this a KRecursiveFilterProxyModel instead of a SelectionProxyModel
class AKONADI_EXPORT FavoriteCollectionsModel : public Akonadi::SelectionProxyModel
{
Q_OBJECT
public:
/**
* Creates a new favorite collections model.
*
* @param model The source model where the favorite collections
* come from.
* @param group The config group that shall be used to save the
* selection of favorite collections.
* @param parent The parent object.
*/
FavoriteCollectionsModel( QAbstractItemModel *model, const KConfigGroup &group, QObject *parent = 0 );
/**
* Destroys the favorite collections model.
*/
virtual ~FavoriteCollectionsModel();
/**
* Returns the list of favorite collections.
* @deprecated Use collectionIds instead.
*/
Collection::List collections() const;
/**
* Returns the list of ids of favorite collections set on the FavoriteCollectionsModel.
*
* Note that if you want Collections with actual data
* you should use something like this instead:
*
* @code
* FavoriteCollectionsModel* favs = getFavsModel();
* Collection::List cols;
* const int rowCount = favs->rowCount();
* for (int row = 0; row < rowcount; ++row) {
* static const int column = 0;
* const QModelIndex index = favs->index(row, column);
* const Collection col = index.data(EntityTreeModel::CollectionRole).value<Collection>();
* cols << col;
* }
* @endcode
*
* Note that due to the asynchronous nature of the model, this method returns collection ids
* of collections which may not be in the model yet. If you want the ids of the collections
* that are actually in the model, use a loop similar to above with the CollectionIdRole.
*/
QList<Collection::Id> collectionIds() const;
/**
* Return associate label for collection
*/
QString favoriteLabel( const Akonadi::Collection & col );
virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
virtual QStringList mimeTypes() const;
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
public Q_SLOTS:
/**
* Sets the @p collections as favorite collections.
*/
void setCollections( const Collection::List &collections );
/**
* Adds a @p collection to the list of favorite collections.
*/
void addCollection( const Collection &collection );
/**
* Removes a @p collection from the list of favorite collections.
*/
void removeCollection( const Collection &collection );
/**
* Sets a custom @p label that will be used when showing the
* favorite @p collection.
*/
void setFavoriteLabel( const Collection &collection, const QString &label );
private Q_SLOTS:
void pasteJobDone( KJob *job );
private:
//@cond PRIVATE
using KSelectionProxyModel::setSourceModel;
class Private;
Private* const d;
Q_PRIVATE_SLOT( d, void reload() )
Q_PRIVATE_SLOT( d, void rowsInserted(QModelIndex,int,int) )
Q_PRIVATE_SLOT( d, void dataChanged(QModelIndex,QModelIndex) )
//@endcond
};
}
#endif
|