Akonadi
trashrestorejob.cpp
46 // Called after initial fetch of items, issues fetch of target collection or removes attributes for in place restore
66 if (!q->hasSubjobs() || (q->subjobs().contains(static_cast<KJob *>(q->sender())) && q->subjobs().size() == 1)) {
80 if (list.isEmpty() || !list.first().isValid() || list.first().hasAttribute<Akonadi::EntityDeletedAttribute>()) { // target collection is invalid/not
86 q->setErrorText(i18n("Could not find restore collection and restore resource is not available"));
94 auto resRootFetch = new CollectionFetchJob(Collection::root(), CollectionFetchJob::FirstLevel, q);
110 // We know where to move the entity, so remove the attributes and move them to the right location
116 // store removed attribute if destination collection is valid or the item doesn't have a restore collection
117 // TODO only remove the attribute if the move job was successful (although it is unlikely that it fails since we already fetched the collection)
129 auto collectionFetchJob = new CollectionFetchJob(mCollection, CollectionFetchJob::Recursive, q);
133 q->connect(collectionFetchJob, &CollectionFetchJob::collectionsReceived, q, [this](const auto &cols) {
162 // If the restore collection is invalid we restore the item in place, so we don't need to know its restore resource => we can put those cases in the
164 restoreCollections[item.attribute<Akonadi::EntityDeletedAttribute>()->restoreCollection()].append(item);
171 const QString restoreResource = first.attribute<Akonadi::EntityDeletedAttribute>()->restoreResource();
189 fetchJob->setProperty("Items", it.key().id()); // to find the items in restore collections again
212 const QString restoreResource = mCollection.attribute<Akonadi::EntityDeletedAttribute>()->restoreResource();
213 Collection targetCollection = mCollection.attribute<EntityDeletedAttribute>()->restoreCollection();
218 auto collectionFetchJob = new CollectionFetchJob(mCollection, CollectionFetchJob::Recursive, q);
222 q->connect(collectionFetchJob, &CollectionFetchJob::collectionsReceived, q, [this](const auto &cols) {
Job that fetches collections from the Akonadi storage.
Definition collectionfetchjob.h:39
@ FirstLevel
Only list direct sub-collections of the base collection.
Definition collectionfetchjob.h:48
void collectionsReceived(const Akonadi::Collection::List &collections)
This signal is emitted whenever the job has received collections.
Job that modifies a collection in the Akonadi storage.
Definition collectionmodifyjob.h:62
Job that moves a collection in the Akonadi storage to a new parent collection.
Definition collectionmovejob.h:36
bool hasAttribute(const QByteArray &name) const
Returns true if the collection has an attribute of the given type name, false otherwise.
Definition collection.cpp:161
Collection parentCollection() const
Returns the parent collection of this object.
Definition collection.cpp:195
void removeAttribute(const QByteArray &name)
Removes and deletes the attribute of the given type name.
Definition collection.cpp:156
Attribute * attribute(const QByteArray &name)
Returns the attribute of the given type name if available, 0 otherwise.
Definition collection.cpp:176
An Attribute that marks that an entity was marked as deleted.
Definition entitydeletedattribute.h:35
void itemsReceived(const Akonadi::Item::List &items)
This signal is emitted whenever new items have been fetched completely.
Job that modifies an existing item in the Akonadi storage.
Definition itemmodifyjob.h:82
Job that moves an item into a different collection in the Akonadi storage.
Definition itemmovejob.h:35
Collection parentCollection() const
Returns the parent collection of this object.
Definition item.cpp:161
TrashRestoreJob(const Item &item, QObject *parent=nullptr)
All items need to be from the same resource.
Definition trashrestorejob.cpp:286
void doStart() override
This method must be reimplemented in the concrete jobs.
Definition trashrestorejob.cpp:323
void setTargetCollection(const Collection &collection)
Sets the target collection, where the item is moved to.
Definition trashrestorejob.cpp:311
void setErrorText(const QString &errorText)
virtual QString errorString() const
void emitResult()
int error() const
void result(KJob *job)
void setError(int errorCode)
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
KIOCORE_EXPORT QStringList list(const QString &fileClass)
T & first()
bool isEmpty() const const
qsizetype size() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const
bool isValid() const const
int toInt(bool *ok) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.