Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonadinoterepository.cpp
Show All 18 Lines | 1 | /* This file is part of Zanshin | |||
---|---|---|---|---|---|
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
21 | USA. | 21 | USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | 24 | | |||
25 | #include "akonadinoterepository.h" | 25 | #include "akonadinoterepository.h" | ||
26 | 26 | | |||
27 | #include <KLocalizedString> | ||||
28 | | ||||
27 | #include <AkonadiCore/Item> | 29 | #include <AkonadiCore/Item> | ||
28 | 30 | | |||
29 | #include "akonadicollectionfetchjobinterface.h" | 31 | #include "akonadicollectionfetchjobinterface.h" | ||
30 | #include "akonadiitemfetchjobinterface.h" | 32 | #include "akonadiitemfetchjobinterface.h" | ||
31 | 33 | | |||
32 | #include "utils/compositejob.h" | 34 | #include "utils/compositejob.h" | ||
33 | 35 | | |||
34 | using namespace Akonadi; | 36 | using namespace Akonadi; | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 88 | job->install(fetchCollectionJob->kjob(), [fetchCollectionJob, item, job, this] { | |||
91 | const Akonadi::Collection::List collections = fetchCollectionJob->collections(); | 93 | const Akonadi::Collection::List collections = fetchCollectionJob->collections(); | ||
92 | auto it = std::find_if(collections.constBegin(), collections.constEnd(), | 94 | auto it = std::find_if(collections.constBegin(), collections.constEnd(), | ||
93 | [] (const Akonadi::Collection &c) { | 95 | [] (const Akonadi::Collection &c) { | ||
94 | return (c.rights() & Akonadi::Collection::CanCreateItem) | 96 | return (c.rights() & Akonadi::Collection::CanCreateItem) | ||
95 | && (c.rights() & Akonadi::Collection::CanChangeItem) | 97 | && (c.rights() & Akonadi::Collection::CanChangeItem) | ||
96 | && (c.rights() & Akonadi::Collection::CanDeleteItem); | 98 | && (c.rights() & Akonadi::Collection::CanDeleteItem); | ||
97 | }); | 99 | }); | ||
98 | if (it == collections.constEnd()) { | 100 | if (it == collections.constEnd()) { | ||
99 | job->emitError(tr("Could not find a collection to store the note into!")); | 101 | job->emitError(i18n("Could not find a collection to store the note into!")); | ||
100 | } else { | 102 | } else { | ||
101 | auto col = *it; | 103 | auto col = *it; | ||
102 | Q_ASSERT(col.isValid()); | 104 | Q_ASSERT(col.isValid()); | ||
103 | auto createJob = m_storage->createItem(item, col); | 105 | auto createJob = m_storage->createItem(item, col); | ||
104 | job->addSubjob(createJob); | 106 | job->addSubjob(createJob); | ||
105 | createJob->start(); | 107 | createJob->start(); | ||
106 | } | 108 | } | ||
107 | }); | 109 | }); | ||
108 | return job; | 110 | return job; | ||
109 | } | 111 | } | ||
110 | } | 112 | } |