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));
221 const QList<Collection::Id> collections = configGroup.readEntry("FavoriteCollectionIds", QList<qint64>());
255 * We use KSelectionProxyModel in order to make a flat list of selected folders from the folder tree.
258 * but don't work since we then get a filtered tree, not a flat list. Stacking a KDescendantsProxyModel
259 * on top would likely remove explicitly selected parents when one of their child is selected too.
262FavoriteCollectionsModel::FavoriteCollectionsModel(QAbstractItemModel *source, const KConfigGroup &group, QObject *parent)
277 connect(source, &QAbstractItemModel::rowsInserted, this, [this](const QModelIndex &parent, int begin, int end) {
280 connect(source, &QAbstractItemModel::dataChanged, this, [this](const QModelIndex &tl, const QModelIndex &br) {
310 const QModelIndex idx = EntityTreeModel::modelIndexForCollection(sourceModel(), Collection(colId));
311 const auto collection = sourceModel()->data(idx, EntityTreeModel::CollectionRole).value<Collection>();
322void Akonadi::FavoriteCollectionsModel::setFavoriteLabel(const Collection &collection, const QString &label)
342 const Collection::Id collectionId = sourceModel()->data(sourceIndex, EntityTreeModel::CollectionIdRole).toLongLong();
350bool FavoriteCollectionsModel::setData(const QModelIndex &index, const QVariant &value, int role)
358 const auto collection = sourceModel()->data(sourceIndex, EntityTreeModel::CollectionRole).value<Collection>();
373QString Akonadi::FavoriteCollectionsModel::defaultFavoriteLabel(const Akonadi::Collection &collection)
379 const auto colIdx = EntityTreeModel::modelIndexForCollection(sourceModel(), Collection(collection.id()));
395QVariant FavoriteCollectionsModel::headerData(int section, Qt::Orientation orientation, int role) const
404bool FavoriteCollectionsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
413 const auto destCollection = sourceModel()->data(sourceIndex, EntityTreeModel::CollectionRole).value<Collection>();
431 qCDebug(AKONADICORE_LOG) << "unwanted item" << mimeChecker.wantedMimeTypes() << item.mimeType();
static Collection fromUrl(const QUrl &url)
Creates a collection from the given url.
Definition collection.cpp:267
static QModelIndex modelIndexForCollection(const QAbstractItemModel *model, const Collection &collection)
Returns a QModelIndex in model which points to collection.
Definition entitytreemodel.cpp:1069
AKONADICORE_DEPRECATED Collection::List collections() const
Returns the list of favorite collections.
Definition favoritecollectionsmodel.cpp:305
QString favoriteLabel(const Akonadi::Collection &col)
Return associate label for collection.
Definition favoritecollectionsmodel.cpp:365
void addCollection(const Akonadi::Collection &collection)
Adds a collection to the list of favorite collections.
Definition favoritecollectionsmodel.cpp:293
~FavoriteCollectionsModel() override
Destroys the favorite collections model.
FavoriteCollectionsModel(QAbstractItemModel *model, const KConfigGroup &group, QObject *parent=nullptr)
Creates a new favorite collections model.
Definition favoritecollectionsmodel.cpp:262
QList< Collection::Id > collectionIds() const
Returns the list of ids of favorite collections set on the FavoriteCollectionsModel.
Definition favoritecollectionsmodel.cpp:317
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:322
void setCollections(const Akonadi::Collection::List &collections)
Sets the collections as favorite collections.
Definition favoritecollectionsmodel.cpp:287
void removeCollection(const Akonadi::Collection &collection)
Removes a collection from the list of favorite collections.
Definition favoritecollectionsmodel.cpp:299
virtual QString errorString() const
int error() const
void result(KJob *job)
KSelectionProxyModel()
void setFilterBehavior(FilterBehavior behavior)
void setSourceModel(QAbstractItemModel *sourceModel) override
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
const QList< QKeySequence > & end()
QAbstractItemModel(QObject *parent)
virtual QVariant data(const QModelIndex &index, int role) const const=0
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
virtual Qt::ItemFlags flags(const QModelIndex &index) const const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const const
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
void layoutChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
virtual QStringList mimeTypes() const const
void modelReset()
virtual QModelIndex parent(const QModelIndex &index) const const=0
void rowsInserted(const QModelIndex &parent, int first, int last)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const const=0
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const=0
sourceModel
void append(QList< T > &&value)
qsizetype count() const const
qsizetype removeAll(const AT &t)
void reserve(qsizetype size)
qsizetype size() const const
int column() const const
QVariant data(int role) const const
bool isValid() const const
QModelIndex parent() const const
int row() const const
QModelIndex sibling(int row, int column) const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QChar * data()
bool isEmpty() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
DropAction
DisplayRole
typedef ItemFlags
Orientation
QString toString() const const
T value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:57 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:57 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.