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();
Job that modifies a collection in the Akonadi storage.
Definition collectionmodifyjob.h:62
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
A model that lists a set of favorite collections.
Definition favoritecollectionsmodel.h:53
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
Helper for checking MIME types of Collections and Items.
Definition mimetypechecker.h:97
void setWantedMimeTypes(const QStringList &mimeTypes)
Sets the list of wanted MIME types this instance checks against.
Definition mimetypechecker.cpp:49
void writeEntry(const char *key, const char *value, WriteConfigFlags pFlags=Normal)
KConfig * config()
QString readEntry(const char *key, const char *aDefault=nullptr) const
bool sync() override
virtual QString errorString() const
int error() const
void result(KJob *job)
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()
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()
void rowsInserted(const QModelIndex &parent, int first, int last)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const=0
sourceModel
bool contains(const Key &key) const const
bool remove(const Key &key)
void append(QList< T > &&value)
bool contains(const AT &value) const const
qsizetype count() const const
qsizetype removeAll(const AT &t)
void reserve(qsizetype size)
qsizetype size() const const
virtual bool hasFormat(const QString &mimeType) const const
QList< QUrl > urls() 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
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
bool contains(const QSet< T > &other) const const
bool remove(const T &value)
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-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.