Akonadi
favoritecollectionsmodel.cpp
76 // don't clear the selection model here. Otherwise we mess up the users selection as collections get removed and re-inserted.
80 // If a favorite folder was removed then surely it's gone from the selection model, so no need to do anything about that.
111 const QModelIndex index = EntityTreeModel::modelIndexForCollection(q->sourceModel(), Collection(collectionId));
119 const QModelIndex idx = EntityTreeModel::modelIndexForCollection(q->sourceModel(), Collection(collectionId));
131 const QModelIndex index = EntityTreeModel::modelIndexForCollection(q->sourceModel(), Collection(collectionId));
148 const QModelIndex index = EntityTreeModel::modelIndexForCollection(q->sourceModel(), Collection(collectionId));
228 const QList<Collection::Id> collections = configGroup.readEntry("FavoriteCollectionIds", QList<qint64>());
262 * We use KSelectionProxyModel in order to make a flat list of selected folders from the folder tree.
265 * but don't work since we then get a filtered tree, not a flat list. Stacking a KDescendantsProxyModel
266 * on top would likely remove explicitly selected parents when one of their child is selected too.
269 FavoriteCollectionsModel::FavoriteCollectionsModel(QAbstractItemModel *source, const KConfigGroup &group, QObject *parent)
284 connect(source, &QAbstractItemModel::rowsInserted, this, [this](const QModelIndex &parent, int begin, int end) {
287 connect(source, &QAbstractItemModel::dataChanged, this, [this](const QModelIndex &tl, const QModelIndex &br) {
317 const QModelIndex idx = EntityTreeModel::modelIndexForCollection(sourceModel(), Collection(colId));
318 const auto collection = sourceModel()->data(idx, EntityTreeModel::CollectionRole).value<Collection>();
329 void Akonadi::FavoriteCollectionsModel::setFavoriteLabel(const Collection &collection, const QString &label)
349 const Collection::Id collectionId = sourceModel()->data(sourceIndex, EntityTreeModel::CollectionIdRole).toLongLong();
357 bool FavoriteCollectionsModel::setData(const QModelIndex &index, const QVariant &value, int role)
365 const auto collection = sourceModel()->data(sourceIndex, EntityTreeModel::CollectionRole).value<Collection>();
380 QString Akonadi::FavoriteCollectionsModel::defaultFavoriteLabel(const Akonadi::Collection &collection)
386 const auto colIdx = EntityTreeModel::modelIndexForCollection(sourceModel(), Collection(collection.id()));
402 QVariant FavoriteCollectionsModel::headerData(int section, Qt::Orientation orientation, int role) const
411 bool FavoriteCollectionsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
420 const auto destCollection = sourceModel()->data(sourceIndex, EntityTreeModel::CollectionRole).value<Collection>();
438 qCDebug(AKONADICORE_LOG) << "unwanted item" << mimeChecker.wantedMimeTypes() << item.mimeType();
void append(const T &value)
static Collection fromUrl(const QUrl &url)
Creates a collection from the given url.
Definition: collection.cpp:267
FavoriteCollectionsModel(QAbstractItemModel *model, const KConfigGroup &group, QObject *parent=nullptr)
Creates a new favorite collections model.
Definition: favoritecollectionsmodel.cpp:269
DisplayRole
void modelReset()
void removeCollection(const Akonadi::Collection &collection)
Removes a collection from the list of favorite collections.
Definition: favoritecollectionsmodel.cpp:306
Job that modifies a collection in the Akonadi storage.
Definition: collectionmodifyjob.h:67
QAction * deselect(const QObject *recvr, const char *slot, QObject *parent)
virtual QVariant data(const QModelIndex &proxyIndex, int role) const const override
QModelIndex sibling(int row, int column) const const
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const=0
virtual Qt::ItemFlags flags(const QModelIndex &index) const const override
void setWantedMimeTypes(const QStringList &mimeTypes)
Sets the list of wanted MIME types this instance checks against.
Definition: mimetypechecker.cpp:49
void result(KJob *job)
int removeAll(const T &value)
void setSourceModel(QAbstractItemModel *sourceModel) override
int column() const const
const QList< QKeySequence > & reload()
T value() const const
void removeAttribute(const QByteArray &name)
Removes and deletes the attribute of the given type name.
Definition: collection.cpp:156
void layoutChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
KGuiItem remove()
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const const override
void setCollections(const Akonadi::Collection::List &collections)
Sets the collections as favorite collections.
Definition: favoritecollectionsmodel.cpp:294
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void reserve(int alloc)
QList< Collection::Id > collectionIds() const
Returns the list of ids of favorite collections set on the FavoriteCollectionsModel.
Definition: favoritecollectionsmodel.cpp:324
QVariant data(int role) const const
int size() const const
void addAttribute(Attribute *attribute)
Adds an attribute to the collection.
Definition: collection.cpp:151
typedef ItemFlags
QString i18n(const char *text, const TYPE &arg...)
QString favoriteLabel(const Akonadi::Collection &col)
Return associate label for collection.
Definition: favoritecollectionsmodel.cpp:372
void addCollection(const Akonadi::Collection &collection)
Adds a collection to the list of favorite collections.
Definition: favoritecollectionsmodel.cpp:300
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
Orientation
bool isEmpty() const const
Collection parentCollection() const
Returns the parent collection of this object.
Definition: item.cpp:153
KGuiItem add()
AKONADICORE_DEPRECATED Collection::List collections() const
Returns the list of favorite collections.
Definition: favoritecollectionsmodel.cpp:312
void setFavoriteLabel(const Akonadi::Collection &collection, const QString &label)
Sets a custom label that will be used when showing the favorite collection.
Definition: favoritecollectionsmodel.cpp:329
virtual bool hasFormat(const QString &mimeType) const const
bool isValid() const const
void reserve(int size)
int row() const const
virtual QStringList mimeTypes() const const override
QList< QUrl > urls() const const
DropAction
void rowsInserted(const QModelIndex &parent, int first, int last)
void setFilterBehavior(FilterBehavior behavior)
A model that lists a set of favorite collections.
Definition: favoritecollectionsmodel.h:52
Helper for checking MIME types of Collections and Items.
Definition: mimetypechecker.h:96
~FavoriteCollectionsModel() override
Destroys the favorite collections model.
sourceModel
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
int count(const T &value) const const
static QModelIndex modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection)
Returns a QModelIndex in model which points to collection.
Definition: entitytreemodel.cpp:1057
QModelIndex parent() const const
QChar * data()
virtual QString errorString() const
int error() const
QObject * parent() const const
const QList< QKeySequence > & end()
QString toString() const const
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.