diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,6 @@ # frontends add_subdirectory(zanshin) -add_subdirectory(renku) # modules add_subdirectory(akonadi) diff --git a/src/akonadi/CMakeLists.txt b/src/akonadi/CMakeLists.txt --- a/src/akonadi/CMakeLists.txt +++ b/src/akonadi/CMakeLists.txt @@ -13,18 +13,14 @@ akonadilivequeryintegrator.cpp akonadimonitorimpl.cpp akonadimonitorinterface.cpp - akonadinotequeries.cpp - akonadinoterepository.cpp akonadiprojectqueries.cpp akonadiprojectrepository.cpp akonadiserializer.cpp akonadiserializerinterface.cpp akonadistorage.cpp akonadistorageinterface.cpp akonadistoragesettings.cpp akonaditagfetchjobinterface.cpp - akonaditagqueries.cpp - akonaditagrepository.cpp akonaditaskqueries.cpp akonaditaskrepository.cpp akonaditimestampattribute.cpp @@ -34,7 +30,6 @@ target_link_libraries(akonadi KF5::AkonadiCalendar KF5::AkonadiCore - KF5::AkonadiNotes KF5::AkonadiWidgets KF5::Mime KF5::CalendarCore diff --git a/src/akonadi/akonadicache.cpp b/src/akonadi/akonadicache.cpp --- a/src/akonadi/akonadicache.cpp +++ b/src/akonadi/akonadicache.cpp @@ -322,6 +322,5 @@ bool Cache::matchCollection(StorageInterface::FetchContentTypes contentTypes, const Collection &collection) const { return (contentTypes == StorageInterface::AllContent) - || ((contentTypes & StorageInterface::Tasks) && m_serializer->isTaskCollection(collection)) - || ((contentTypes & StorageInterface::Notes) && m_serializer->isNoteCollection(collection)); + || ((contentTypes & StorageInterface::Tasks) && m_serializer->isTaskCollection(collection)); } diff --git a/src/akonadi/akonadiconfigdialog.cpp b/src/akonadi/akonadiconfigdialog.cpp --- a/src/akonadi/akonadiconfigdialog.cpp +++ b/src/akonadi/akonadiconfigdialog.cpp @@ -43,7 +43,6 @@ #include #include -#include using namespace Akonadi; @@ -151,8 +150,6 @@ void ConfigDialog::applyContentTypes(AgentFilterProxyModel *model) { - if (m_types & StorageInterface::Notes) - model->addMimeTypeFilter(NoteUtils::noteMimeType()); if (m_types & StorageInterface::Tasks) model->addMimeTypeFilter(KCalCore::Todo::todoMimeType()); } diff --git a/src/akonadi/akonadilivequeryintegrator.h b/src/akonadi/akonadilivequeryintegrator.h --- a/src/akonadi/akonadilivequeryintegrator.h +++ b/src/akonadi/akonadilivequeryintegrator.h @@ -294,24 +294,6 @@ return m_serializer->representsCollection(output, input); } -template<> -inline Domain::Note::Ptr LiveQueryIntegrator::create(const Item &input) -{ - return m_serializer->createNoteFromItem(input); -} - -template<> -inline void LiveQueryIntegrator::update(const Item &input, Domain::Note::Ptr &output) -{ - m_serializer->updateNoteFromItem(output, input); -} - -template<> -inline bool LiveQueryIntegrator::represents(const Item &input, const Domain::Note::Ptr &output) -{ - return m_serializer->representsItem(output, input); -} - template<> inline Domain::DataSource::Ptr LiveQueryIntegrator::create(const Item &input) { @@ -348,24 +330,6 @@ return m_serializer->representsItem(output, input); } -template<> -inline Domain::Tag::Ptr LiveQueryIntegrator::create(const Tag &input) -{ - return m_serializer->createTagFromAkonadiTag(input); -} - -template<> -inline void LiveQueryIntegrator::update(const Tag &input, Domain::Tag::Ptr &output) -{ - m_serializer->updateTagFromAkonadiTag(output, input); -} - -template<> -inline bool LiveQueryIntegrator::represents(const Tag &input, const Domain::Tag::Ptr &output) -{ - return m_serializer->representsAkonadiTag(output, input); -} - template<> inline Domain::Task::Ptr LiveQueryIntegrator::create(const Item &input) { diff --git a/src/akonadi/akonadimonitorimpl.cpp b/src/akonadi/akonadimonitorimpl.cpp --- a/src/akonadi/akonadimonitorimpl.cpp +++ b/src/akonadi/akonadimonitorimpl.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -50,7 +49,6 @@ m_monitor->setCollectionMonitored(Akonadi::Collection::root()); m_monitor->setMimeTypeMonitored(KCalCore::Todo::todoMimeType()); - m_monitor->setMimeTypeMonitored(NoteUtils::noteMimeType()); auto collectionScope = m_monitor->collectionFetchScope(); collectionScope.setContentMimeTypes(m_monitor->mimeTypesMonitored()); diff --git a/src/akonadi/akonadinotequeries.h b/src/akonadi/akonadinotequeries.h deleted file mode 100644 --- a/src/akonadi/akonadinotequeries.h +++ /dev/null @@ -1,62 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - Copyright 2014 Remi Benoit - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef AKONADI_NOTEQUERIES_H -#define AKONADI_NOTEQUERIES_H - -#include "domain/notequeries.h" - -#include "akonadi/akonadilivequeryhelpers.h" -#include "akonadi/akonadilivequeryintegrator.h" - -namespace Akonadi { - -class NoteQueries : public Domain::NoteQueries -{ -public: - typedef QSharedPointer Ptr; - - typedef Domain::LiveQueryInput ItemInputQuery; - typedef Domain::LiveQueryOutput NoteQueryOutput; - typedef Domain::QueryResultProvider NoteProvider; - typedef Domain::QueryResult NoteResult; - - NoteQueries(const StorageInterface::Ptr &storage, - const SerializerInterface::Ptr &serializer, - const MonitorInterface::Ptr &monitor); - - NoteResult::Ptr findAll() const Q_DECL_OVERRIDE; - NoteResult::Ptr findInbox() const Q_DECL_OVERRIDE; - -private: - SerializerInterface::Ptr m_serializer; - LiveQueryHelpers::Ptr m_helpers; - LiveQueryIntegrator::Ptr m_integrator; - - mutable NoteQueryOutput::Ptr m_findAll; -}; - -} - -#endif // AKONADI_NOTEQUERIES_H diff --git a/src/akonadi/akonadinotequeries.cpp b/src/akonadi/akonadinotequeries.cpp deleted file mode 100644 --- a/src/akonadi/akonadinotequeries.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - Copyright 2014 Remi Benoit - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "akonadinotequeries.h" - -using namespace Akonadi; - -NoteQueries::NoteQueries(const StorageInterface::Ptr &storage, - const SerializerInterface::Ptr &serializer, - const MonitorInterface::Ptr &monitor) - : m_serializer(serializer), - m_helpers(new LiveQueryHelpers(serializer, storage)), - m_integrator(new LiveQueryIntegrator(serializer, monitor)) -{ -} - -NoteQueries::NoteResult::Ptr NoteQueries::findAll() const -{ - auto fetch = m_helpers->fetchItems(StorageInterface::Notes); - auto predicate = [this] (const Item &item) { - return m_serializer->isNoteItem(item); - }; - m_integrator->bind("NoteQueries::findAll", m_findAll, fetch, predicate); - return m_findAll->result(); -} - -NoteQueries::NoteResult::Ptr NoteQueries::findInbox() const -{ - auto fetch = m_helpers->fetchItems(StorageInterface::Notes); - auto predicate = [this] (const Item &item) { - return m_serializer->isNoteItem(item) - && !m_serializer->hasAkonadiTags(item); - }; - m_integrator->bind("NoteQueries::findInbox", m_findAll, fetch, predicate); - return m_findAll->result(); -} diff --git a/src/akonadi/akonadinoterepository.h b/src/akonadi/akonadinoterepository.h deleted file mode 100644 --- a/src/akonadi/akonadinoterepository.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef AKONADI_NOTEREPOSITORY_H -#define AKONADI_NOTEREPOSITORY_H - -#include "domain/noterepository.h" - -#include "akonadi/akonadiserializerinterface.h" -#include "akonadi/akonadistorageinterface.h" - -#include - -namespace Akonadi { - -class NoteRepository : public QObject, public Domain::NoteRepository -{ - Q_OBJECT -public: - typedef QSharedPointer Ptr; - - NoteRepository(const StorageInterface::Ptr &storage, - const SerializerInterface::Ptr &serializer); - - KJob *create(Domain::Note::Ptr note) Q_DECL_OVERRIDE; - KJob *createInTag(Domain::Note::Ptr note, Domain::Tag::Ptr tag) Q_DECL_OVERRIDE; - KJob *update(Domain::Note::Ptr note) Q_DECL_OVERRIDE; - KJob *remove(Domain::Note::Ptr note) Q_DECL_OVERRIDE; - -private: - StorageInterface::Ptr m_storage; - SerializerInterface::Ptr m_serializer; - - KJob *createItem(const Akonadi::Item &item); -}; - -} - -#endif // AKONADI_NOTEREPOSITORY_H diff --git a/src/akonadi/akonadinoterepository.cpp b/src/akonadi/akonadinoterepository.cpp deleted file mode 100644 --- a/src/akonadi/akonadinoterepository.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "akonadinoterepository.h" - -#include - -#include - -#include "akonadicollectionfetchjobinterface.h" -#include "akonadiitemfetchjobinterface.h" - -#include "utils/compositejob.h" - -using namespace Akonadi; -using namespace Utils; - -NoteRepository::NoteRepository(const StorageInterface::Ptr &storage, - const SerializerInterface::Ptr &serializer) - : m_storage(storage), - m_serializer(serializer) -{ -} - -KJob *NoteRepository::create(Domain::Note::Ptr note) -{ - auto item = m_serializer->createItemFromNote(note); - Q_ASSERT(!item.isValid()); - return createItem(item); -} - -KJob *NoteRepository::createInTag(Domain::Note::Ptr note, Domain::Tag::Ptr tag) -{ - Item item = m_serializer->createItemFromNote(note); - Q_ASSERT(!item.isValid()); - - Tag akonadiTag = m_serializer->createAkonadiTagFromTag(tag); - Q_ASSERT(akonadiTag .isValid()); - item.setTag(akonadiTag); - - return createItem(item); -} - -KJob *NoteRepository::update(Domain::Note::Ptr note) -{ - auto item = m_serializer->createItemFromNote(note); - Q_ASSERT(item.isValid()); - return m_storage->updateItem(item); -} - -KJob *NoteRepository::remove(Domain::Note::Ptr note) -{ - auto item = m_serializer->createItemFromNote(note); - return m_storage->removeItem(item); -} - -KJob *NoteRepository::createItem(const Item &item) -{ - const Akonadi::Collection defaultCollection = m_storage->defaultNoteCollection(); - if (defaultCollection.isValid()) { - return m_storage->createItem(item, defaultCollection); - } else { - auto job = new CompositeJob(); - CollectionFetchJobInterface *fetchCollectionJob = m_storage->fetchCollections(Akonadi::Collection::root(), - StorageInterface::Recursive, - StorageInterface::Notes); - job->install(fetchCollectionJob->kjob(), [fetchCollectionJob, item, job, this] { - if (fetchCollectionJob->kjob()->error() != KJob::NoError) - return; - - Q_ASSERT(fetchCollectionJob->collections().size() > 0); - const Akonadi::Collection::List collections = fetchCollectionJob->collections(); - auto it = std::find_if(collections.constBegin(), collections.constEnd(), - [] (const Akonadi::Collection &c) { - return (c.rights() & Akonadi::Collection::CanCreateItem) - && (c.rights() & Akonadi::Collection::CanChangeItem) - && (c.rights() & Akonadi::Collection::CanDeleteItem); - }); - if (it == collections.constEnd()) { - job->emitError(i18n("Could not find a collection to store the note into!")); - } else { - auto col = *it; - Q_ASSERT(col.isValid()); - auto createJob = m_storage->createItem(item, col); - job->addSubjob(createJob); - createJob->start(); - } - }); - return job; - } -} diff --git a/src/akonadi/akonadiprojectrepository.cpp b/src/akonadi/akonadiprojectrepository.cpp --- a/src/akonadi/akonadiprojectrepository.cpp +++ b/src/akonadi/akonadiprojectrepository.cpp @@ -65,8 +65,6 @@ Item childItem; if (auto task = child.objectCast()) childItem = m_serializer->createItemFromTask(task); - else if (auto note = child.objectCast()) - childItem = m_serializer->createItemFromNote(note); Q_ASSERT(childItem.isValid()); auto job = new Utils::CompositeJob(); @@ -123,10 +121,8 @@ { auto job = new Utils::CompositeJob(); const auto task = child.objectCast(); - const auto note = child.objectCast(); const auto childItem = task ? m_serializer->createItemFromTask(task) - : note ? m_serializer->createItemFromNote(note) : Akonadi::Item(); Q_ASSERT(childItem.isValid()); diff --git a/src/akonadi/akonadiserializer.h b/src/akonadi/akonadiserializer.h --- a/src/akonadi/akonadiserializer.h +++ b/src/akonadi/akonadiserializer.h @@ -40,15 +40,13 @@ bool representsCollection(QObjectPtr object, Collection collection) Q_DECL_OVERRIDE; bool representsItem(QObjectPtr object, Item item) Q_DECL_OVERRIDE; - bool representsAkonadiTag(Domain::Tag::Ptr tag, Akonadi::Tag akonadiTag) const Q_DECL_OVERRIDE; QString itemUid(const Item &item) Q_DECL_OVERRIDE; Domain::DataSource::Ptr createDataSourceFromCollection(Akonadi::Collection collection, DataSourceNameScheme naming) Q_DECL_OVERRIDE; void updateDataSourceFromCollection(Domain::DataSource::Ptr dataSource, Akonadi::Collection collection, DataSourceNameScheme naming) Q_DECL_OVERRIDE; virtual Akonadi::Collection createCollectionFromDataSource(Domain::DataSource::Ptr dataSource) Q_DECL_OVERRIDE; virtual bool isSelectedCollection(Akonadi::Collection collection) Q_DECL_OVERRIDE; - virtual bool isNoteCollection(Akonadi::Collection collection) Q_DECL_OVERRIDE; virtual bool isTaskCollection(Akonadi::Collection collection) Q_DECL_OVERRIDE; bool isTaskItem(Akonadi::Item item) Q_DECL_OVERRIDE; @@ -64,11 +62,6 @@ void clearItem(Akonadi::Item *item) Q_DECL_OVERRIDE; Akonadi::Item::List filterDescendantItems(const Akonadi::Item::List &potentialChildren, const Akonadi::Item &ancestorItem) Q_DECL_OVERRIDE; - bool isNoteItem(Akonadi::Item item) Q_DECL_OVERRIDE; - Domain::Note::Ptr createNoteFromItem(Akonadi::Item item) Q_DECL_OVERRIDE; - void updateNoteFromItem(Domain::Note::Ptr note, Akonadi::Item item) Q_DECL_OVERRIDE; - Akonadi::Item createItemFromNote(Domain::Note::Ptr note) Q_DECL_OVERRIDE; - bool isProjectItem(Akonadi::Item item) Q_DECL_OVERRIDE; Domain::Project::Ptr createProjectFromItem(Akonadi::Item item) Q_DECL_OVERRIDE; void updateProjectFromItem(Domain::Project::Ptr project, Akonadi::Item item) Q_DECL_OVERRIDE; @@ -81,17 +74,10 @@ bool isContextTag(const Domain::Context::Ptr &context, const Akonadi::Tag &tag) const Q_DECL_OVERRIDE; bool isContextChild(Domain::Context::Ptr context, Akonadi::Item item) const Q_DECL_OVERRIDE; - Domain::Tag::Ptr createTagFromAkonadiTag(Akonadi::Tag akonadiTag) Q_DECL_OVERRIDE; - void updateTagFromAkonadiTag(Domain::Tag::Ptr tag, Akonadi::Tag akonadiTag) Q_DECL_OVERRIDE; - Akonadi::Tag createAkonadiTagFromTag(Domain::Tag::Ptr tag) Q_DECL_OVERRIDE; - bool isTagChild(Domain::Tag::Ptr tag, Akonadi::Item item) Q_DECL_OVERRIDE; - bool hasContextTags(Akonadi::Item item) const Q_DECL_OVERRIDE; - bool hasAkonadiTags(Akonadi::Item item) const Q_DECL_OVERRIDE; private: bool isContext(const Akonadi::Tag &tag) const; - bool isAkonadiTag(const Akonadi::Tag &tag) const; }; } diff --git a/src/akonadi/akonadiserializer.cpp b/src/akonadi/akonadiserializer.cpp --- a/src/akonadi/akonadiserializer.cpp +++ b/src/akonadi/akonadiserializer.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -60,11 +59,6 @@ return object->property("itemId").toLongLong() == item.id(); } -bool Serializer::representsAkonadiTag(Domain::Tag::Ptr tag, Tag akonadiTag) const -{ - return tag->property("tagId").toLongLong() == akonadiTag.id(); -} - QString Serializer::itemUid(const Item &item) { if (item.hasPayload()) { @@ -104,8 +98,6 @@ const auto mimeTypes = collection.contentMimeTypes(); auto types = Domain::DataSource::ContentTypes(); - if (mimeTypes.contains(NoteUtils::noteMimeType())) - types |= Domain::DataSource::Notes; if (mimeTypes.contains(KCalCore::Todo::todoMimeType())) types |= Domain::DataSource::Tasks; dataSource->setContentTypes(types); @@ -140,20 +132,15 @@ bool Serializer::isSelectedCollection(Collection collection) { - if (!isNoteCollection(collection) && !isTaskCollection(collection)) + if (!isTaskCollection(collection)) return false; if (!collection.hasAttribute()) return true; return collection.attribute()->isSelected(); } -bool Akonadi::Serializer::isNoteCollection(Akonadi::Collection collection) -{ - return collection.contentMimeTypes().contains(NoteUtils::noteMimeType()); -} - bool Akonadi::Serializer::isTaskCollection(Akonadi::Collection collection) { return collection.contentMimeTypes().contains(KCalCore::Todo::todoMimeType()); @@ -323,12 +310,6 @@ if (isTaskItem(item)) { const auto todo = item.payload(); return todo->relatedTo(); - - } else if (isNoteItem(item)) { - const auto message = item.payload(); - const auto relatedHeader = message->headerByType("X-Zanshin-RelatedProjectUid"); - return relatedHeader ? relatedHeader->asUnicodeString() : QString(); - } else { return QString(); } @@ -348,17 +329,6 @@ if (isTaskItem(item)) { auto todo = item.payload(); todo->setRelatedTo(project->property("todoUid").toString()); - - } else if (isNoteItem(item)) { - auto note = item.payload(); - (void)note->removeHeader("X-Zanshin-RelatedProjectUid"); - const QByteArray parentUid = project->property("todoUid").toString().toUtf8(); - if (!parentUid.isEmpty()) { - auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader->from7BitString(parentUid); - note->appendHeader(relatedHeader); - } - note->assemble(); } } @@ -424,63 +394,6 @@ return result; } -bool Serializer::isNoteItem(Item item) -{ - return item.hasPayload(); -} - -Domain::Note::Ptr Serializer::createNoteFromItem(Akonadi::Item item) -{ - if (!isNoteItem(item)) - return Domain::Note::Ptr(); - - Domain::Note::Ptr note = Domain::Note::Ptr::create(); - updateNoteFromItem(note, item); - - return note; -} - -void Serializer::updateNoteFromItem(Domain::Note::Ptr note, Item item) -{ - if (!isNoteItem(item)) - return; - - auto message = item.payload(); - - note->setTitle(message->subject(true)->asUnicodeString()); - note->setText(message->mainBodyPart()->decodedText()); - note->setProperty("itemId", item.id()); - - if (auto relatedHeader = message->headerByType("X-Zanshin-RelatedProjectUid")) { - note->setProperty("relatedUid", relatedHeader->asUnicodeString()); - } else { - note->setProperty("relatedUid", QVariant()); - } -} - -Item Serializer::createItemFromNote(Domain::Note::Ptr note) -{ - NoteUtils::NoteMessageWrapper builder; - builder.setTitle(note->title()); - builder.setText(note->text() + '\n'); // Adding an extra '\n' because KMime always removes it... - - KMime::Message::Ptr message = builder.message(); - - if (!note->property("relatedUid").toString().isEmpty()) { - auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader->from7BitString(note->property("relatedUid").toString().toUtf8()); - message->appendHeader(relatedHeader); - } - - Akonadi::Item item; - if (note->property("itemId").isValid()) { - item.setId(note->property("itemId").value()); - } - item.setMimeType(Akonadi::NoteUtils::noteMimeType()); - item.setPayload(message); - return item; -} - bool Serializer::isProjectItem(Item item) { if (!item.hasPayload()) @@ -586,24 +499,11 @@ std::bind(Utils::mem_fn(&Serializer::isContext), this, _1)); } -bool Serializer::hasAkonadiTags(Item item) const -{ - using namespace std::placeholders; - Tag::List tags = item.tags(); - return std::any_of(tags.constBegin(), tags.constEnd(), - std::bind(Utils::mem_fn(&Serializer::isAkonadiTag), this, _1)); -} - bool Serializer::isContext(const Akonadi::Tag &tag) const { return (tag.type() == Akonadi::SerializerInterface::contextTagType()); } -bool Serializer::isAkonadiTag(const Tag &tag) const -{ - return tag.type() == Akonadi::Tag::PLAIN; -} - bool Serializer::isContextTag(const Domain::Context::Ptr &context, const Akonadi::Tag &tag) const { return (context->property("tagId").value() == tag.id()); @@ -619,47 +519,3 @@ return item.hasTag(tag); } - -Domain::Tag::Ptr Serializer::createTagFromAkonadiTag(Akonadi::Tag akonadiTag) -{ - if (!isAkonadiTag(akonadiTag)) - return Domain::Tag::Ptr(); - - auto tag = Domain::Tag::Ptr::create(); - updateTagFromAkonadiTag(tag, akonadiTag); - return tag; -} - -void Serializer::updateTagFromAkonadiTag(Domain::Tag::Ptr tag, Akonadi::Tag akonadiTag) -{ - if (!isAkonadiTag(akonadiTag)) - return; - - tag->setProperty("tagId", akonadiTag.id()); - tag->setName(akonadiTag.name()); -} - -Akonadi::Tag Serializer::createAkonadiTagFromTag(Domain::Tag::Ptr tag) -{ - auto akonadiTag = Akonadi::Tag(); - akonadiTag.setName(tag->name()); - akonadiTag.setType(Akonadi::Tag::PLAIN); - akonadiTag.setGid(QByteArray(tag->name().toLatin1())); - - const auto tagProperty = tag->property("tagId"); - if (tagProperty.isValid()) - akonadiTag.setId(tagProperty.value()); - - return akonadiTag; -} - -bool Serializer::isTagChild(Domain::Tag::Ptr tag, Akonadi::Item item) -{ - if (!tag->property("tagId").isValid()) - return false; - - auto tagId = tag->property("tagId").value(); - Akonadi::Tag akonadiTag(tagId); - - return item.hasTag(akonadiTag); -} diff --git a/src/akonadi/akonadiserializerinterface.h b/src/akonadi/akonadiserializerinterface.h --- a/src/akonadi/akonadiserializerinterface.h +++ b/src/akonadi/akonadiserializerinterface.h @@ -25,9 +25,7 @@ #define AKONADI_SERIALIZERINTERFACE_H #include "domain/datasource.h" -#include "domain/tag.h" #include "domain/task.h" -#include "domain/note.h" #include "domain/project.h" #include "domain/context.h" @@ -55,15 +53,13 @@ virtual bool representsCollection(QObjectPtr object, Akonadi::Collection collection) = 0; virtual bool representsItem(QObjectPtr object, Akonadi::Item item) = 0; - virtual bool representsAkonadiTag(Domain::Tag::Ptr tag, Akonadi::Tag akonadiTag) const = 0; virtual QString itemUid(const Item &item) = 0; virtual Domain::DataSource::Ptr createDataSourceFromCollection(Akonadi::Collection collection, DataSourceNameScheme naming) = 0; virtual void updateDataSourceFromCollection(Domain::DataSource::Ptr dataSource, Akonadi::Collection collection, DataSourceNameScheme naming) = 0; virtual Akonadi::Collection createCollectionFromDataSource(Domain::DataSource::Ptr dataSource) = 0; virtual bool isSelectedCollection(Akonadi::Collection collection) = 0; - virtual bool isNoteCollection(Akonadi::Collection collection) = 0; virtual bool isTaskCollection(Akonadi::Collection collection) = 0; virtual bool isTaskItem(Akonadi::Item item) = 0; @@ -80,12 +76,6 @@ virtual void clearItem(Akonadi::Item *item) = 0; virtual Akonadi::Item::List filterDescendantItems(const Akonadi::Item::List &potentialChildren, const Akonadi::Item &ancestorItem) = 0; - virtual bool isNoteItem(Akonadi::Item item) = 0; - virtual Domain::Note::Ptr createNoteFromItem(Akonadi::Item item) = 0; - virtual void updateNoteFromItem(Domain::Note::Ptr note, Akonadi::Item item) = 0; - - virtual Akonadi::Item createItemFromNote(Domain::Note::Ptr note) = 0; - Domain::Artifact::Ptr createArtifactFromItem(const Akonadi::Item &item); void updateArtifactFromItem(const Domain::Artifact::Ptr &artifact, const Akonadi::Item &item); @@ -101,13 +91,7 @@ virtual bool isContextTag(const Domain::Context::Ptr &context, const Akonadi::Tag &tag) const = 0; virtual bool isContextChild(Domain::Context::Ptr context, Akonadi::Item item) const = 0; - virtual Domain::Tag::Ptr createTagFromAkonadiTag(Akonadi::Tag tag) = 0; - virtual void updateTagFromAkonadiTag(Domain::Tag::Ptr tag, Akonadi::Tag akonadiTag) = 0; - virtual Akonadi::Tag createAkonadiTagFromTag(Domain::Tag::Ptr tag) = 0; - virtual bool isTagChild(Domain::Tag::Ptr tag, Akonadi::Item item) = 0; - virtual bool hasContextTags(Akonadi::Item item) const = 0; - virtual bool hasAkonadiTags(Akonadi::Item item) const = 0; static QByteArray contextTagType(); }; diff --git a/src/akonadi/akonadiserializerinterface.cpp b/src/akonadi/akonadiserializerinterface.cpp --- a/src/akonadi/akonadiserializerinterface.cpp +++ b/src/akonadi/akonadiserializerinterface.cpp @@ -40,9 +40,6 @@ if (isTaskItem(item)) { auto task = createTaskFromItem(item); return Domain::Artifact::Ptr(task); - } else if (isNoteItem(item)) { - auto note = createNoteFromItem(item); - return Domain::Artifact::Ptr(note); } else { return Domain::Artifact::Ptr(); } @@ -52,8 +49,6 @@ { if (auto task = artifact.dynamicCast()) { updateTaskFromItem(task, item); - } else if (auto note = artifact.dynamicCast()) { - updateNoteFromItem(note, item); } } diff --git a/src/akonadi/akonadistorage.cpp b/src/akonadi/akonadistorage.cpp --- a/src/akonadi/akonadistorage.cpp +++ b/src/akonadi/akonadistorage.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -232,8 +231,6 @@ CollectionFetchJobInterface *Storage::fetchCollections(Collection collection, StorageInterface::FetchDepth depth, FetchContentTypes types) { QStringList contentMimeTypes; - if (types & Notes) - contentMimeTypes << NoteUtils::noteMimeType(); if (types & Tasks) contentMimeTypes << KCalCore::Todo::todoMimeType(); diff --git a/src/akonadi/akonaditagqueries.h b/src/akonadi/akonaditagqueries.h deleted file mode 100644 --- a/src/akonadi/akonaditagqueries.h +++ /dev/null @@ -1,68 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - Copyright 2014 Franck Arrecot - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef AKONADI_TAGQUERIES_H -#define AKONADI_TAGQUERIES_H - -#include "domain/tagqueries.h" - -#include "akonadi/akonadilivequeryhelpers.h" -#include "akonadi/akonadilivequeryintegrator.h" - -namespace Akonadi { - -class TagQueries : public Domain::TagQueries -{ -public: - typedef QSharedPointer Ptr; - - typedef Domain::LiveQueryInput TagInputQuery; - typedef Domain::LiveQueryOutput TagQueryOutput; - typedef Domain::QueryResult TagResult; - typedef Domain::QueryResultProvider TagProvider; - - typedef Domain::LiveQueryInput ItemInputQuery; - typedef Domain::LiveQueryOutput NoteQueryOutput; - typedef Domain::QueryResultProvider NoteProvider; - typedef Domain::QueryResult NoteResult; - - TagQueries(const StorageInterface::Ptr &storage, - const SerializerInterface::Ptr &serializer, - const MonitorInterface::Ptr &monitor); - - TagResult::Ptr findAll() const Q_DECL_OVERRIDE; - NoteResult::Ptr findNotes(Domain::Tag::Ptr tag) const Q_DECL_OVERRIDE; - -private: - SerializerInterface::Ptr m_serializer; - LiveQueryHelpers::Ptr m_helpers; - LiveQueryIntegrator::Ptr m_integrator; - - mutable TagQueryOutput::Ptr m_findAll; - mutable QHash m_findTopLevel; -}; - -} // akonadi namespace - -#endif // AKONADI_TAGQUERIES_H diff --git a/src/akonadi/akonaditagqueries.cpp b/src/akonadi/akonaditagqueries.cpp deleted file mode 100644 --- a/src/akonadi/akonaditagqueries.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "akonaditagqueries.h" - -using namespace Akonadi; - -TagQueries::TagQueries(const StorageInterface::Ptr &storage, const SerializerInterface::Ptr &serializer, const MonitorInterface::Ptr &monitor) - : m_serializer(serializer), - m_helpers(new LiveQueryHelpers(serializer, storage)), - m_integrator(new LiveQueryIntegrator(serializer, monitor)) -{ - m_integrator->addRemoveHandler([this] (const Tag &tag) { - m_findTopLevel.remove(tag.id()); - }); -} - -TagQueries::TagResult::Ptr TagQueries::findAll() const -{ - auto fetch = m_helpers->fetchTags(); - auto predicate = [this] (const Akonadi::Tag &akonadiTag) { - return akonadiTag.type() == Akonadi::Tag::PLAIN; - }; - m_integrator->bind("TagQueries::findAll", m_findAll, fetch, predicate); - return m_findAll->result(); -} - -TagQueries::NoteResult::Ptr TagQueries::findNotes(Domain::Tag::Ptr tag) const -{ - Akonadi::Tag akonadiTag = m_serializer->createAkonadiTagFromTag(tag); - auto &query = m_findTopLevel[akonadiTag.id()]; - auto fetch = m_helpers->fetchItems(akonadiTag); - auto predicate = [this, tag] (const Akonadi::Item &item) { - return m_serializer->isTagChild(tag, item); - }; - m_integrator->bind("TagQueries::findNotes", query, fetch, predicate); - return query->result(); -} diff --git a/src/akonadi/akonaditagrepository.h b/src/akonadi/akonaditagrepository.h deleted file mode 100644 --- a/src/akonadi/akonaditagrepository.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - Copyright 2014 Franck Arrecot - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef AKONADITAGREPOSITORY_H -#define AKONADITAGREPOSITORY_H - -#include "domain/tagrepository.h" - -#include "akonadi/akonadiserializerinterface.h" -#include "akonadi/akonadistorageinterface.h" - -namespace Akonadi { - -class SerializerInterface; -class StorageInterface; - -class TagRepository : public QObject, public Domain::TagRepository -{ - Q_OBJECT -public: - typedef QSharedPointer Ptr; - - TagRepository(const StorageInterface::Ptr &storage, - const SerializerInterface::Ptr &serializer); - - KJob *create(Domain::Tag::Ptr tag) Q_DECL_OVERRIDE; - KJob *remove(Domain::Tag::Ptr tag) Q_DECL_OVERRIDE; - - KJob *associate(Domain::Tag::Ptr parent, Domain::Note::Ptr child) Q_DECL_OVERRIDE; - KJob *dissociate(Domain::Tag::Ptr parent, Domain::Note::Ptr child) Q_DECL_OVERRIDE; - KJob *dissociateAll(Domain::Note::Ptr child) Q_DECL_OVERRIDE; - -private: - StorageInterface::Ptr m_storage; - SerializerInterface::Ptr m_serializer; -}; -} -#endif // AKONADITAGREPOSITORY_H diff --git a/src/akonadi/akonaditagrepository.cpp b/src/akonadi/akonaditagrepository.cpp deleted file mode 100644 --- a/src/akonadi/akonaditagrepository.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - Copyright 2014 Franck Arrecot - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "akonaditagrepository.h" - -#include "akonadiitemfetchjobinterface.h" - -#include "utils/compositejob.h" - -using namespace Akonadi; - - -TagRepository::TagRepository(const StorageInterface::Ptr &storage, - const SerializerInterface::Ptr &serializer) - : m_storage(storage), - m_serializer(serializer) -{ -} - -KJob *TagRepository::create(Domain::Tag::Ptr tag) -{ - auto akonadiTag = m_serializer->createAkonadiTagFromTag(tag); - Q_ASSERT(!akonadiTag.isValid()); - return m_storage->createTag(akonadiTag); -} - -KJob *TagRepository::remove(Domain::Tag::Ptr tag) -{ - auto akonadiTag = m_serializer->createAkonadiTagFromTag(tag); - Q_ASSERT(akonadiTag.isValid()); - return m_storage->removeTag(akonadiTag); -} - -KJob *TagRepository::associate(Domain::Tag::Ptr parent, Domain::Note::Ptr child) -{ - auto akonadiTag = m_serializer->createAkonadiTagFromTag(parent); - Q_ASSERT(akonadiTag.isValid()); - - Item childItem = m_serializer->createItemFromNote(child); - Q_ASSERT(childItem.isValid()); - - auto job = new Utils::CompositeJob(); - ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); - job->install(fetchItemJob->kjob(), [akonadiTag, fetchItemJob, parent, job, this] { - if (fetchItemJob->kjob()->error() != KJob::NoError) - return; - - Q_ASSERT(fetchItemJob->items().size() == 1); - auto childItem = fetchItemJob->items().at(0); - childItem.setTag(akonadiTag); - - auto updateJob = m_storage->updateItem(childItem); - job->addSubjob(updateJob); - updateJob->start(); - }); - return job; -} - -KJob *TagRepository::dissociate(Domain::Tag::Ptr parent, Domain::Note::Ptr child) -{ - Item childItem = m_serializer->createItemFromNote(child); - Q_ASSERT(childItem.isValid()); - - auto job = new Utils::CompositeJob(); - ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); - job->install(fetchItemJob->kjob(), [fetchItemJob, parent, job, this] { - if (fetchItemJob->kjob()->error() != KJob::NoError) - return; - - Q_ASSERT(fetchItemJob->items().size() == 1); - auto childItem = fetchItemJob->items().at(0); - auto tag = m_serializer->createAkonadiTagFromTag(parent); - Q_ASSERT(tag.isValid()); - childItem.clearTag(tag); - - auto updateJob = m_storage->updateItem(childItem); - job->addSubjob(updateJob); - updateJob->start(); - }); - - return job; -} - -KJob *TagRepository::dissociateAll(Domain::Note::Ptr child) -{ - Item childItem; - - childItem = m_serializer->createItemFromNote(child); - Q_ASSERT(childItem.isValid()); - auto job = new Utils::CompositeJob(); - ItemFetchJobInterface *fetchItemJob = m_storage->fetchItem(childItem); - job->install(fetchItemJob->kjob(), [fetchItemJob, job, this] { - if (fetchItemJob->kjob()->error() != KJob::NoError) - return; - - Q_ASSERT(fetchItemJob->items().size() == 1); - auto childItem = fetchItemJob->items().at(0); - foreach (const Tag &tag, childItem.tags()) - childItem.clearTag(tag); - - auto updateJob = m_storage->updateItem(childItem); - job->addSubjob(updateJob); - updateJob->start(); - }); - - return job; -} diff --git a/src/domain/CMakeLists.txt b/src/domain/CMakeLists.txt --- a/src/domain/CMakeLists.txt +++ b/src/domain/CMakeLists.txt @@ -6,18 +6,12 @@ datasource.cpp datasourcequeries.cpp datasourcerepository.cpp - note.cpp - notequeries.cpp - noterepository.cpp project.cpp projectqueries.cpp projectrepository.cpp queryresult.cpp queryresultinterface.cpp queryresultprovider.cpp - tag.cpp - tagqueries.cpp - tagrepository.cpp task.cpp taskqueries.cpp taskrepository.cpp diff --git a/src/domain/note.h b/src/domain/note.h deleted file mode 100644 --- a/src/domain/note.h +++ /dev/null @@ -1,48 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef DOMAIN_NOTE_H -#define DOMAIN_NOTE_H - -#include "artifact.h" - -namespace Domain { - -class Note : public Artifact -{ - Q_OBJECT - -public: - typedef QSharedPointer Ptr; - typedef QList List; - - explicit Note(QObject *parent = Q_NULLPTR); - virtual ~Note(); -}; - -} - -Q_DECLARE_METATYPE(Domain::Note::Ptr) - -#endif // DOMAIN_NOTE_H diff --git a/src/domain/note.cpp b/src/domain/note.cpp deleted file mode 100644 --- a/src/domain/note.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "note.h" - -using namespace Domain; - -Note::Note(QObject *parent) - : Artifact(parent) -{ -} - -Note::~Note() -{ -} diff --git a/src/domain/notequeries.h b/src/domain/notequeries.h deleted file mode 100644 --- a/src/domain/notequeries.h +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef DOMAIN_NOTEQUERIES_H -#define DOMAIN_NOTEQUERIES_H - -#include "note.h" -#include "project.h" -#include "queryresult.h" - -namespace Domain { - -class NoteQueries -{ -public: - typedef QSharedPointer Ptr; - - NoteQueries(); - virtual ~NoteQueries(); - - virtual QueryResult::Ptr findAll() const = 0; - virtual QueryResult::Ptr findInbox() const = 0; -}; - -} - -#endif // DOMAIN_NOTEQUERIES_H diff --git a/src/domain/notequeries.cpp b/src/domain/notequeries.cpp deleted file mode 100644 --- a/src/domain/notequeries.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "notequeries.h" - -using namespace Domain; - -NoteQueries::NoteQueries() -{ -} - -NoteQueries::~NoteQueries() -{ -} - diff --git a/src/domain/noterepository.h b/src/domain/noterepository.h deleted file mode 100644 --- a/src/domain/noterepository.h +++ /dev/null @@ -1,52 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef DOMAIN_NOTEREPOSITORY_H -#define DOMAIN_NOTEREPOSITORY_H - -#include "datasource.h" -#include "note.h" -#include "tag.h" - -class KJob; - -namespace Domain { - -class NoteRepository -{ -public: - typedef QSharedPointer Ptr; - - NoteRepository(); - virtual ~NoteRepository(); - - virtual KJob *create(Note::Ptr task) = 0; - virtual KJob *createInTag(Note::Ptr task, Tag::Ptr tag) = 0; - - virtual KJob *update(Note::Ptr note) = 0; - virtual KJob *remove(Note::Ptr note) = 0; -}; - -} - -#endif // DOMAIN_NOTEREPOSITORY_H diff --git a/src/domain/noterepository.cpp b/src/domain/noterepository.cpp deleted file mode 100644 --- a/src/domain/noterepository.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "noterepository.h" - -using namespace Domain; - -NoteRepository::NoteRepository() -{ -} - -NoteRepository::~NoteRepository() -{ -} - diff --git a/src/domain/tag.h b/src/domain/tag.h deleted file mode 100644 --- a/src/domain/tag.h +++ /dev/null @@ -1,62 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef DOMAIN_TAG_H -#define DOMAIN_TAG_H - -#include -#include -#include - -namespace Domain { - -class Tag : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - -public: - typedef QSharedPointer Ptr; - typedef QList List; - - explicit Tag(QObject *parent = Q_NULLPTR); - virtual ~Tag(); - - QString name() const; - -public slots: - void setName(const QString &name); - -signals: - void nameChanged(const QString &name); - -private: - QString m_name; -}; - -} - -Q_DECLARE_METATYPE(Domain::Tag::Ptr) - -#endif // DOMAIN_TAG_H diff --git a/src/domain/tag.cpp b/src/domain/tag.cpp deleted file mode 100644 --- a/src/domain/tag.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "tag.h" - -using namespace Domain; - -Tag::Tag(QObject *parent) - : QObject(parent) -{ -} - -Tag::~Tag() -{ -} - -QString Tag::name() const -{ - return m_name; -} - -void Tag::setName(const QString &name) -{ - if (m_name == name) - return; - - m_name = name; - emit nameChanged(name); -} diff --git a/src/domain/tagqueries.h b/src/domain/tagqueries.h deleted file mode 100644 --- a/src/domain/tagqueries.h +++ /dev/null @@ -1,48 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef DOMAIN_TAGQUERIES_H -#define DOMAIN_TAGQUERIES_H - -#include "note.h" -#include "queryresult.h" -#include "tag.h" - -namespace Domain { - -class TagQueries -{ -public: - typedef QSharedPointer Ptr; - - TagQueries(); - virtual ~TagQueries(); - - virtual QueryResult::Ptr findAll() const = 0; - - virtual QueryResult::Ptr findNotes(Tag::Ptr tag) const = 0; -}; - -} - -#endif // DOMAIN_TAGQUERIES_H diff --git a/src/domain/tagqueries.cpp b/src/domain/tagqueries.cpp deleted file mode 100644 --- a/src/domain/tagqueries.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "tagqueries.h" - -using namespace Domain; - -TagQueries::TagQueries() -{ -} - -TagQueries::~TagQueries() -{ -} - diff --git a/src/domain/tagrepository.h b/src/domain/tagrepository.h deleted file mode 100644 --- a/src/domain/tagrepository.h +++ /dev/null @@ -1,52 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef DOMAIN_TAGREPOSITORY_H -#define DOMAIN_TAGREPOSITORY_H - -#include "note.h" -#include "tag.h" - -class KJob; - -namespace Domain { - -class TagRepository -{ -public: - typedef QSharedPointer Ptr; - - TagRepository(); - virtual ~TagRepository(); - - virtual KJob *create(Tag::Ptr tag) = 0; - virtual KJob *remove(Tag::Ptr tag) = 0; - - virtual KJob *associate(Tag::Ptr parent, Note::Ptr child) = 0; - virtual KJob *dissociate(Tag::Ptr parent, Note::Ptr child) = 0; - virtual KJob *dissociateAll(Note::Ptr child) = 0; -}; - -} - -#endif // DOMAIN_TAGREPOSITORY_H diff --git a/src/domain/tagrepository.cpp b/src/domain/tagrepository.cpp deleted file mode 100644 --- a/src/domain/tagrepository.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "tagrepository.h" - -using namespace Domain; - -TagRepository::TagRepository() -{ -} - -TagRepository::~TagRepository() -{ -} - diff --git a/src/presentation/CMakeLists.txt b/src/presentation/CMakeLists.txt --- a/src/presentation/CMakeLists.txt +++ b/src/presentation/CMakeLists.txt @@ -2,22 +2,19 @@ applicationmodel.cpp artifacteditormodel.cpp artifactfilterproxymodel.cpp - availablenotepagesmodel.cpp availablepagesmodelinterface.cpp availablepagessortfilterproxymodel.cpp availabletaskpagesmodel.cpp availablesourcesmodel.cpp contextpagemodel.cpp errorhandler.cpp errorhandlingmodelbase.cpp metatypes.cpp - noteinboxpagemodel.cpp pagemodel.cpp projectpagemodel.cpp querytreemodelbase.cpp runningtaskmodelinterface.cpp runningtaskmodel.cpp - tagpagemodel.cpp taskinboxpagemodel.cpp tasklistmodel.cpp taskapplicationmodel.cpp diff --git a/src/presentation/applicationmodel.h b/src/presentation/applicationmodel.h --- a/src/presentation/applicationmodel.h +++ b/src/presentation/applicationmodel.h @@ -29,7 +29,6 @@ #include "domain/datasourcerepository.h" #include "domain/datasourcequeries.h" -#include "domain/noterepository.h" #include "domain/taskrepository.h" #include "presentation/metatypes.h" diff --git a/src/presentation/availablenotepagesmodel.h b/src/presentation/availablenotepagesmodel.h deleted file mode 100644 --- a/src/presentation/availablenotepagesmodel.h +++ /dev/null @@ -1,83 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef PRESENTATION_AVAILABLENOTEPAGESMODEL_H -#define PRESENTATION_AVAILABLENOTEPAGESMODEL_H - -#include "presentation/availablepagesmodelinterface.h" - -#include "domain/notequeries.h" -#include "domain/noterepository.h" -#include "domain/tagqueries.h" -#include "domain/tagrepository.h" - -#include "presentation/metatypes.h" - -namespace Presentation { - -class AvailablePagesSortFilterProxyModel; - -class AvailableNotePagesModel : public AvailablePagesModelInterface -{ - Q_OBJECT -public: - explicit AvailableNotePagesModel(const Domain::NoteQueries::Ptr ¬eQueries, - const Domain::NoteRepository::Ptr ¬eRepository, - const Domain::TagQueries::Ptr &tagQueries, - const Domain::TagRepository::Ptr &tagRepository, - QObject *parent = Q_NULLPTR); - - QAbstractItemModel *pageListModel() Q_DECL_OVERRIDE; - - bool hasProjectPages() const Q_DECL_OVERRIDE; - bool hasContextPages() const Q_DECL_OVERRIDE; - bool hasTagPages() const Q_DECL_OVERRIDE; - - QObject *createPageForIndex(const QModelIndex &index) Q_DECL_OVERRIDE; - - void addProject(const QString &name, const Domain::DataSource::Ptr &source) Q_DECL_OVERRIDE; - void addContext(const QString &name) Q_DECL_OVERRIDE; - void addTag(const QString &name) Q_DECL_OVERRIDE; - void removeItem(const QModelIndex &index) Q_DECL_OVERRIDE; - -private: - QAbstractItemModel *createPageListModel(); - - QAbstractItemModel *m_pageListModel; - Presentation::AvailablePagesSortFilterProxyModel *m_sortProxyModel; - - Domain::NoteQueries::Ptr m_noteQueries; - Domain::NoteRepository::Ptr m_noteRepository; - - Domain::TagQueries::Ptr m_tagQueries; - Domain::TagRepository::Ptr m_tagRepository; - - Domain::QueryResultProvider::Ptr m_rootsProvider; - QObjectPtr m_inboxObject; - QObjectPtr m_tagsObject; -}; - -} - -#endif // PRESENTATION_AVAILABLENOTEPAGESMODEL_H diff --git a/src/presentation/availablenotepagesmodel.cpp b/src/presentation/availablenotepagesmodel.cpp deleted file mode 100644 --- a/src/presentation/availablenotepagesmodel.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "availablenotepagesmodel.h" - -#include -#include - -#include - -#include "presentation/availablepagessortfilterproxymodel.h" -#include "presentation/noteinboxpagemodel.h" -#include "presentation/querytreemodel.h" -#include "presentation/tagpagemodel.h" - -#include "utils/jobhandler.h" - -using namespace Presentation; - -AvailableNotePagesModel::AvailableNotePagesModel(const Domain::NoteQueries::Ptr ¬eQueries, - const Domain::NoteRepository::Ptr ¬eRepository, - const Domain::TagQueries::Ptr &tagQueries, - const Domain::TagRepository::Ptr &tagRepository, - QObject *parent) - : AvailablePagesModelInterface(parent), - m_pageListModel(Q_NULLPTR), - m_sortProxyModel(Q_NULLPTR), - m_noteQueries(noteQueries), - m_noteRepository(noteRepository), - m_tagQueries(tagQueries), - m_tagRepository(tagRepository) -{ -} - -QAbstractItemModel *AvailableNotePagesModel::pageListModel() -{ - if (!m_pageListModel) - m_pageListModel = createPageListModel(); - - if (!m_sortProxyModel) { - m_sortProxyModel = new AvailablePagesSortFilterProxyModel(this); - m_sortProxyModel->setSourceModel(m_pageListModel); - } - - return m_sortProxyModel; -} - -bool AvailableNotePagesModel::hasProjectPages() const -{ - return false; -} - -bool AvailableNotePagesModel::hasContextPages() const -{ - return false; -} - -bool AvailableNotePagesModel::hasTagPages() const -{ - return true; -} - -QObject *AvailableNotePagesModel::createPageForIndex(const QModelIndex &index) -{ - QObjectPtr object = index.data(QueryTreeModelBase::ObjectRole).value(); - - if (object == m_inboxObject) { - auto inboxPageModel = new NoteInboxPageModel(m_noteQueries, - m_noteRepository, - this); - inboxPageModel->setErrorHandler(errorHandler()); - return inboxPageModel; - } else if (auto tag = object.objectCast()) { - auto tagPageModel = new TagPageModel(tag, - m_tagQueries, - m_tagRepository, - m_noteRepository, - this); - tagPageModel->setErrorHandler(errorHandler()); - return tagPageModel; - } - - return Q_NULLPTR; -} - -void AvailableNotePagesModel::addProject(const QString &, const Domain::DataSource::Ptr &) -{ - qFatal("Not supported"); -} - -void AvailableNotePagesModel::addContext(const QString &) -{ - qFatal("Not supported"); -} - -void AvailableNotePagesModel::addTag(const QString &name) -{ - auto tag = Domain::Tag::Ptr::create(); - tag->setName(name); - const auto job = m_tagRepository->create(tag); - installHandler(job, i18n("Cannot add tag %1", name)); -} - -void AvailableNotePagesModel::removeItem(const QModelIndex &index) -{ - QObjectPtr object = index.data(QueryTreeModelBase::ObjectRole).value(); - if (auto tag = object.objectCast()) { - const auto job = m_tagRepository->remove(tag); - installHandler(job, i18n("Cannot remove tag %1", tag->name())); - } else { - Q_ASSERT(false); - } -} - -QAbstractItemModel *AvailableNotePagesModel::createPageListModel() -{ - m_inboxObject = QObjectPtr::create(); - m_inboxObject->setProperty("name", i18n("Inbox")); - m_tagsObject = QObjectPtr::create(); - m_tagsObject->setProperty("name", i18n("Tags")); - - m_rootsProvider = Domain::QueryResultProvider::Ptr::create(); - m_rootsProvider->append(m_inboxObject); - m_rootsProvider->append(m_tagsObject); - - auto query = [this](const QObjectPtr &object) -> Domain::QueryResultInterface::Ptr { - if (!object) - return Domain::QueryResult::create(m_rootsProvider); - else if (object == m_tagsObject) - return Domain::QueryResult::copy(m_tagQueries->findAll()); - else - return Domain::QueryResult::Ptr(); - }; - - auto flags = [this](const QObjectPtr &object) { - const Qt::ItemFlags defaultFlags = Qt::ItemIsSelectable - | Qt::ItemIsEnabled - | Qt::ItemIsEditable - | Qt::ItemIsDropEnabled; - const Qt::ItemFlags immutableNodeFlags = Qt::ItemIsSelectable - | Qt::ItemIsEnabled - | Qt::ItemIsDropEnabled; - const Qt::ItemFlags structureNodeFlags = Qt::NoItemFlags; - - return object.objectCast() ? defaultFlags - : object == m_inboxObject ? immutableNodeFlags - : structureNodeFlags; - }; - - auto data = [this](const QObjectPtr &object, int role, int) -> QVariant { - if (role != Qt::DisplayRole - && role != Qt::EditRole - && role != Qt::DecorationRole - && role != QueryTreeModelBase::IconNameRole) { - return QVariant(); - } - - if (role == Qt::EditRole - && (object == m_inboxObject - || object == m_tagsObject)) { - return QVariant(); - } - - if (role == Qt::DisplayRole || role == Qt::EditRole) { - return object->property("name").toString(); - } else if (role == Qt::DecorationRole || role == QueryTreeModelBase::IconNameRole) { - const QString iconName = (object == m_inboxObject) ? QStringLiteral("mail-folder-inbox") - : (object == m_tagsObject) ? QStringLiteral("folder") - : QStringLiteral("view-pim-tasks"); - - if (role == Qt::DecorationRole) - return QVariant::fromValue(QIcon::fromTheme(iconName)); - else - return iconName; - } else { - return QVariant(); - } - }; - - auto setData = [this](const QObjectPtr &object, const QVariant &, int role) { - if (role != Qt::EditRole) { - return false; - } - - if (object == m_inboxObject - || object == m_tagsObject) { - return false; - } - - if (object.objectCast()) { - return false; // Tag renaming is NOT allowed - } else { - Q_ASSERT(false); - } - - return true; - }; - - auto drop = [this](const QMimeData *mimeData, Qt::DropAction, const QObjectPtr &object) { - if (!mimeData->hasFormat(QStringLiteral("application/x-zanshin-object"))) - return false; - - auto droppedArtifacts = mimeData->property("objects").value(); - if (droppedArtifacts.isEmpty()) - return false; - - if (std::any_of(droppedArtifacts.begin(), droppedArtifacts.end(), - [](const Domain::Artifact::Ptr &droppedArtifact) { - return !droppedArtifact.objectCast(); - })) { - return false; - } - - if (auto tag = object.objectCast()) { - foreach (const auto &droppedArtifact, droppedArtifacts) { - auto note = droppedArtifact.staticCast(); - const auto job = m_tagRepository->associate(tag, note); - installHandler(job, i18n("Cannot tag %1 with %2", note->title(), tag->name())); - } - return true; - } else if (object == m_inboxObject) { - foreach (const auto &droppedArtifact, droppedArtifacts) { - auto note = droppedArtifact.staticCast(); - const auto job = m_tagRepository->dissociateAll(note); - installHandler(job, i18n("Cannot move %1 to Inbox", note->title())); - } - return true; - } - - return false; - }; - - auto drag = [](const QObjectPtrList &) -> QMimeData* { - return Q_NULLPTR; - }; - - return new QueryTreeModel(query, flags, data, setData, drop, drag, nullptr, this); -} diff --git a/src/presentation/noteinboxpagemodel.h b/src/presentation/noteinboxpagemodel.h deleted file mode 100644 --- a/src/presentation/noteinboxpagemodel.h +++ /dev/null @@ -1,56 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef PRESENTATION_NOTEINBOXPAGEMODEL_H -#define PRESENTATION_NOTEINBOXPAGEMODEL_H - -#include "presentation/pagemodel.h" - -#include "domain/notequeries.h" -#include "domain/noterepository.h" - -namespace Presentation { - -class NoteInboxPageModel : public PageModel -{ - Q_OBJECT -public: - explicit NoteInboxPageModel(const Domain::NoteQueries::Ptr ¬eQueries, - const Domain::NoteRepository::Ptr ¬eRepository, - QObject *parent = Q_NULLPTR); - - Domain::Artifact::Ptr addItem(const QString &title, const QModelIndex &parentIndex = QModelIndex()) Q_DECL_OVERRIDE; - void removeItem(const QModelIndex &index) Q_DECL_OVERRIDE; - void promoteItem(const QModelIndex &index) Q_DECL_OVERRIDE; - -private: - QAbstractItemModel *createCentralListModel() Q_DECL_OVERRIDE; - - Domain::NoteQueries::Ptr m_noteQueries; - Domain::NoteRepository::Ptr m_noteRepository; -}; - -} - -#endif // PRESENTATION_NOTEINBOXPAGEMODEL_H diff --git a/src/presentation/noteinboxpagemodel.cpp b/src/presentation/noteinboxpagemodel.cpp deleted file mode 100644 --- a/src/presentation/noteinboxpagemodel.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "noteinboxpagemodel.h" - -#include - -#include - -#include "presentation/querytreemodel.h" - -using namespace Presentation; - -NoteInboxPageModel::NoteInboxPageModel(const Domain::NoteQueries::Ptr ¬eQueries, - const Domain::NoteRepository::Ptr ¬eRepository, - QObject *parent) - : PageModel(parent), - m_noteQueries(noteQueries), - m_noteRepository(noteRepository) -{ -} - -Domain::Artifact::Ptr NoteInboxPageModel::addItem(const QString &title, const QModelIndex &) -{ - auto note = Domain::Note::Ptr::create(); - note->setTitle(title); - const auto job = m_noteRepository->create(note); - installHandler(job, i18n("Cannot add note %1 in Inbox", title)); - - return note; -} - -void NoteInboxPageModel::removeItem(const QModelIndex &index) -{ - QVariant data = index.data(QueryTreeModelBase::ObjectRole); - auto artifact = data.value(); - auto note = artifact.objectCast(); - Q_ASSERT(note); - const auto job = m_noteRepository->remove(note); - installHandler(job, i18n("Cannot remove note %1 from Inbox", note->title())); -} - -void NoteInboxPageModel::promoteItem(const QModelIndex &) -{ - qFatal("Not supported"); -} - -QAbstractItemModel *NoteInboxPageModel::createCentralListModel() -{ - auto query = [this](const Domain::Note::Ptr ¬e) -> Domain::QueryResultInterface::Ptr { - if (!note) - return m_noteQueries->findInbox(); - else - return Domain::QueryResult::Ptr(); - }; - - auto flags = [](const Domain::Note::Ptr &) { - return Qt::ItemIsSelectable - | Qt::ItemIsEnabled - | Qt::ItemIsEditable - | Qt::ItemIsDragEnabled; - }; - - auto data = [](const Domain::Note::Ptr ¬e, int role, int) -> QVariant { - if (role == Qt::DisplayRole || role == Qt::EditRole) { - return note->title(); - } else { - return QVariant(); - } - }; - - auto setData = [this](const Domain::Note::Ptr ¬e, const QVariant &value, int role) { - if (role != Qt::EditRole) { - return false; - } - - const auto currentTitle = note->title(); - note->setTitle(value.toString()); - const auto job = m_noteRepository->update(note); - installHandler(job, i18n("Cannot modify note %1 in Inbox", currentTitle)); - return true; - }; - - auto drop = [](const QMimeData *, Qt::DropAction, const Domain::Artifact::Ptr &) { - return false; - }; - - auto drag = [](const Domain::Note::List ¬es) -> QMimeData* { - if (notes.isEmpty()) - return Q_NULLPTR; - - auto artifacts = Domain::Artifact::List(); - artifacts.reserve(notes.size()); - std::copy(notes.constBegin(), notes.constEnd(), - std::back_inserter(artifacts)); - - auto data = new QMimeData; - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(artifacts)); - return data; - }; - - return new QueryTreeModel(query, flags, data, setData, drop, drag, nullptr, this); -} diff --git a/src/presentation/querytreenode.h b/src/presentation/querytreenode.h --- a/src/presentation/querytreenode.h +++ b/src/presentation/querytreenode.h @@ -28,8 +28,6 @@ #include -// Qt5 TODO, shouldn't be needed anymore, QVariant will do the right thing -#include "domain/note.h" #include "domain/task.h" #include "domain/queryresultinterface.h" @@ -46,12 +44,6 @@ return QVariant::fromValue(object); } - template<> - inline QVariant variantFromValue(const Domain::Note::Ptr &task) - { - return QVariant::fromValue(task.staticCast()); - } - template<> inline QVariant variantFromValue(const Domain::Task::Ptr ¬e) { diff --git a/src/presentation/tagpagemodel.h b/src/presentation/tagpagemodel.h deleted file mode 100644 --- a/src/presentation/tagpagemodel.h +++ /dev/null @@ -1,65 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - Copyright 2014 Franck Arrecot - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef PRESENTATION_TAGPAGEMODEL_H -#define PRESENTATION_TAGPAGEMODEL_H - -#include "presentation/pagemodel.h" - -#include "domain/noterepository.h" -#include "domain/tagqueries.h" -#include "domain/tagrepository.h" -#include "domain/tag.h" - -namespace Presentation { - -class TagPageModel : public PageModel -{ - Q_OBJECT -public: - explicit TagPageModel(const Domain::Tag::Ptr &tag, - const Domain::TagQueries::Ptr &tagQueries, - const Domain::TagRepository::Ptr &tagRepository, - const Domain::NoteRepository::Ptr ¬eRepository, - QObject *parent = Q_NULLPTR); - - Domain::Tag::Ptr tag() const; - - Domain::Artifact::Ptr addItem(const QString &title, const QModelIndex &parentIndex = QModelIndex()) Q_DECL_OVERRIDE; - void removeItem(const QModelIndex &index) Q_DECL_OVERRIDE; - void promoteItem(const QModelIndex &index) Q_DECL_OVERRIDE; - -private: - QAbstractItemModel *createCentralListModel() Q_DECL_OVERRIDE; - - Domain::Tag::Ptr m_tag; - Domain::TagQueries::Ptr m_tagQueries; - Domain::TagRepository::Ptr m_tagRepository; - Domain::NoteRepository::Ptr m_noteRepository; -}; - -} - -#endif // PRESENTATION_TAGPAGEMODEL_H diff --git a/src/presentation/tagpagemodel.cpp b/src/presentation/tagpagemodel.cpp deleted file mode 100644 --- a/src/presentation/tagpagemodel.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens - Copyright 2014 Rémi Benoit - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "tagpagemodel.h" - -#include - -#include - -#include "domain/noterepository.h" -#include "domain/task.h" -#include "domain/tagqueries.h" -#include "domain/tagrepository.h" -#include "domain/taskqueries.h" -#include "domain/taskrepository.h" - -#include "presentation/querytreemodel.h" - -using namespace Presentation; - -TagPageModel::TagPageModel(const Domain::Tag::Ptr &tag, - const Domain::TagQueries::Ptr &tagQueries, - const Domain::TagRepository::Ptr &tagRepository, - const Domain::NoteRepository::Ptr ¬eRepository, - QObject *parent) - : PageModel(parent), - m_tag(tag), - m_tagQueries(tagQueries), - m_tagRepository(tagRepository), - m_noteRepository(noteRepository) -{ - -} - -Domain::Tag::Ptr TagPageModel::tag() const -{ - return m_tag; -} - -Domain::Artifact::Ptr TagPageModel::addItem(const QString &title, const QModelIndex &) -{ - auto note = Domain::Note::Ptr::create(); - note->setTitle(title); - const auto job = m_noteRepository->createInTag(note, m_tag); - installHandler(job, i18n("Cannot add note %1 in tag %2", title, m_tag->name())); - return note; -} - -void TagPageModel::removeItem(const QModelIndex &index) -{ - QVariant data = index.data(QueryTreeModelBase::ObjectRole); - auto artifact = data.value(); - auto note = artifact.objectCast(); - Q_ASSERT(note); - const auto job = m_tagRepository->dissociate(m_tag, note); - installHandler(job, i18n("Cannot remove note %1 from tag %2", note->title(), m_tag->name())); -} - -void TagPageModel::promoteItem(const QModelIndex &) -{ - qFatal("Not supported"); -} - -QAbstractItemModel *TagPageModel::createCentralListModel() -{ - auto query = [this] (const Domain::Note::Ptr ¬e) -> Domain::QueryResultInterface::Ptr { - if (!note) - return m_tagQueries->findNotes(m_tag); - else - return Domain::QueryResult::Ptr(); - }; - - auto flags = [](const Domain::Note::Ptr &) { - return Qt::ItemIsSelectable - | Qt::ItemIsEnabled - | Qt::ItemIsEditable - | Qt::ItemIsDragEnabled; - }; - - auto data = [](const Domain::Note::Ptr ¬e, int role, int) -> QVariant { - if (role != Qt::DisplayRole - && role != Qt::EditRole) { - return QVariant(); - } - - if (role == Qt::DisplayRole || role == Qt::EditRole) { - return note->title(); - } else { - return QVariant(); - } - }; - - auto setData = [this] (const Domain::Note::Ptr ¬e, const QVariant &value, int role) { - if (role != Qt::EditRole) { - return false; - } - - const auto currentTitle = note->title(); - note->setTitle(value.toString()); - const auto job = m_noteRepository->update(note); - installHandler(job, i18n("Cannot modify note %1 in tag %2", currentTitle, m_tag->name())); - return true; - }; - - auto drop = [] (const QMimeData *, Qt::DropAction, const Domain::Note::Ptr &) { - return false; - }; - - auto drag = [] (const Domain::Note::List ¬es) -> QMimeData* { - if (notes.isEmpty()) - return Q_NULLPTR; - - auto draggedArtifacts = Domain::Artifact::List(); - draggedArtifacts.reserve(notes.count()); - std::copy(notes.constBegin(), notes.constEnd(), - std::back_inserter(draggedArtifacts)); - - auto data = new QMimeData; - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(draggedArtifacts)); - return data; - }; - - return new QueryTreeModel(query, flags, data, setData, drop, drag, nullptr, this); -} diff --git a/src/presentation/workdaypagemodel.cpp b/src/presentation/workdaypagemodel.cpp --- a/src/presentation/workdaypagemodel.cpp +++ b/src/presentation/workdaypagemodel.cpp @@ -28,7 +28,6 @@ #include -#include "domain/noterepository.h" #include "domain/taskqueries.h" #include "domain/taskrepository.h" diff --git a/src/renku/CMakeLists.txt b/src/renku/CMakeLists.txt deleted file mode 100644 --- a/src/renku/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory(app) -add_subdirectory(kontact) - diff --git a/src/renku/app/CMakeLists.txt b/src/renku/app/CMakeLists.txt deleted file mode 100644 --- a/src/renku/app/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -set(app_SRCS - aboutdata.cpp - dependencies.cpp - main.cpp -) -ecm_create_qm_loader(app_SRCS zanshin_qt) - -add_executable(renku ${app_SRCS}) -kde_enable_exceptions() -target_link_libraries(renku - akonadi - domain - presentation - scripting - utils - widgets -) - -install(TARGETS renku DESTINATION ${KDE_INSTALL_BINDIR}) -install(PROGRAMS org.kde.renku.desktop DESTINATION ${KDE_INSTALL_APPDIR}) -install(FILES renkuui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/renku) -install(FILES org.kde.renku.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) diff --git a/src/renku/app/aboutdata.h b/src/renku/app/aboutdata.h deleted file mode 100644 --- a/src/renku/app/aboutdata.h +++ /dev/null @@ -1,35 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2011-2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef APP_ABOUTDATA_H -#define APP_ABOUTDATA_H - -#include - -namespace App -{ - KAboutData getAboutData(); -} - -#endif - diff --git a/src/renku/app/aboutdata.cpp b/src/renku/app/aboutdata.cpp deleted file mode 100644 --- a/src/renku/app/aboutdata.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2011-2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "aboutdata.h" -#include "../../appversion.h" -#include -#include - -KAboutData App::getAboutData() -{ - KAboutData about(QStringLiteral("renku"), - i18n("Renku Notes"), QStringLiteral(APPLICATION_VERSION), - i18n("A note taking application which aims at getting your mind like water"), - KAboutLicense::GPL_V3, - i18n("Copyright 2008-2015, Kevin Ottens ")); - - about.addAuthor(i18n("Kevin Ottens"), - i18n("Lead Developer"), - QStringLiteral("ervin@kde.org")); - - about.addAuthor(i18n("Mario Bensi"), - i18n("Developer"), - QStringLiteral("nef@ipsquad.net")); - - about.addAuthor(i18n("Franck Arrecot"), - i18n("Developer"), - QStringLiteral("franck.arrecot@gmail.com")); - - return about; -} - diff --git a/src/renku/app/dependencies.h b/src/renku/app/dependencies.h deleted file mode 100644 --- a/src/renku/app/dependencies.h +++ /dev/null @@ -1,33 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef APP_DEPENDENCIES_H -#define APP_DEPENDENCIES_H - -namespace App -{ - void initializeDependencies(); -} - -#endif - diff --git a/src/renku/app/dependencies.cpp b/src/renku/app/dependencies.cpp deleted file mode 100644 --- a/src/renku/app/dependencies.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "dependencies.h" - -#include "akonadi/akonadidatasourcequeries.h" -#include "akonadi/akonadidatasourcerepository.h" -#include "akonadi/akonadinotequeries.h" -#include "akonadi/akonadinoterepository.h" -#include "akonadi/akonaditagqueries.h" -#include "akonadi/akonaditagrepository.h" - -#include "akonadi/akonadicache.h" -#include "akonadi/akonadicachingstorage.h" -#include "akonadi/akonadimonitorimpl.h" -#include "akonadi/akonadiserializer.h" -#include "akonadi/akonadistorage.h" - -#include "presentation/artifacteditormodel.h" -#include "presentation/availablenotepagesmodel.h" -#include "presentation/availablesourcesmodel.h" - -#include "utils/dependencymanager.h" - -void App::initializeDependencies() -{ - auto &deps = Utils::DependencyManager::globalInstance(); - - deps.add(); - deps.add(); - deps.add(); - deps.add([] (Utils::DependencyManager *deps) { - return new Akonadi::CachingStorage(deps->create(), - Akonadi::StorageInterface::Ptr(new Akonadi::Storage)); - }); - - - deps.add([] (Utils::DependencyManager *deps) { - return new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Notes, - deps->create(), - deps->create(), - deps->create()); - }); - - deps.add([] (Utils::DependencyManager *deps) { - return new Akonadi::DataSourceRepository(Akonadi::StorageInterface::Notes, - deps->create(), - deps->create()); - }); - - deps.add(); - - deps.add(); - - deps.add(); - - deps.add(); - - deps.add([] (Utils::DependencyManager *deps) { - auto model = new Presentation::ArtifactEditorModel; - auto repository = deps->create(); - model->setSaveFunction([repository] (const Domain::Artifact::Ptr &artifact) { - auto note = artifact.objectCast(); - Q_ASSERT(note); - return repository->update(note); - }); - return model; - }); - - deps.add(); - - deps.add(); -} diff --git a/src/renku/app/main.cpp b/src/renku/app/main.cpp deleted file mode 100644 --- a/src/renku/app/main.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "widgets/applicationcomponents.h" -#include "widgets/availablepagesview.h" -#include "widgets/availablesourcesview.h" -#include "widgets/editorview.h" -#include "widgets/pageview.h" - -#include "presentation/applicationmodel.h" - -#include "utils/dependencymanager.h" - -#include "aboutdata.h" -#include "dependencies.h" - -int main(int argc, char **argv) -{ - KLocalizedString::setApplicationDomain("zanshin"); - QApplication app(argc, argv); - App::initializeDependencies(); - - auto aboutData = App::getAboutData(); - QCommandLineParser parser; - KAboutData::setApplicationData(aboutData); - parser.addVersionOption(); - parser.addHelpOption(); - aboutData.setupCommandLine(&parser); - parser.process(app); - aboutData.processCommandLine(&parser); - - auto widget = new QWidget; - auto components = new Widgets::ApplicationComponents(widget); - components->setModel(Presentation::ApplicationModel::Ptr::create()); - - auto layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(components->pageView()); - widget->setLayout(layout); - - auto sourcesDock = new QDockWidget(i18n("Sources")); - sourcesDock->setObjectName(QStringLiteral("sourcesDock")); - sourcesDock->setWidget(components->availableSourcesView()); - - auto pagesDock = new QDockWidget(i18n("Pages")); - pagesDock->setObjectName(QStringLiteral("pagesDock")); - pagesDock->setWidget(components->availablePagesView()); - - auto editorDock = new QDockWidget(i18n("Editor")); - editorDock->setObjectName(QStringLiteral("editorDock")); - editorDock->setWidget(components->editorView()); - - auto window = new KXmlGuiWindow; - window->setCentralWidget(widget); - - window->addDockWidget(Qt::RightDockWidgetArea, editorDock); - window->addDockWidget(Qt::LeftDockWidgetArea, pagesDock); - window->addDockWidget(Qt::LeftDockWidgetArea, sourcesDock); - - auto actions = components->globalActions(); - actions.insert(QStringLiteral("dock_sources"), sourcesDock->toggleViewAction()); - actions.insert(QStringLiteral("dock_pages"), pagesDock->toggleViewAction()); - actions.insert(QStringLiteral("dock_editor"), editorDock->toggleViewAction()); - - auto ac = window->actionCollection(); - ac->addAction(KStandardAction::Quit, window, SLOT(close())); - for (auto it = actions.constBegin(); it != actions.constEnd(); ++it) { - auto shortcut = it.value()->shortcut(); - if (!shortcut.isEmpty()) { - ac->setDefaultShortcut(it.value(), shortcut); - } - ac->addAction(it.key(), it.value()); - } - - window->setupGUI(QSize(1024, 600), - KXmlGuiWindow::ToolBar - | KXmlGuiWindow::Keys - | KXmlGuiWindow::Save - | KXmlGuiWindow::Create); - - delete window->findChild("help_contents"); - delete window->findChild("help_whats_this"); - - window->show(); - - { - auto &deps = Utils::DependencyManager::globalInstance(); - auto repo = deps.create(); - repo->windowNeedsDataBackend(window); - } - - return app.exec(); -} diff --git a/src/renku/app/org.kde.renku.appdata.xml b/src/renku/app/org.kde.renku.appdata.xml deleted file mode 100644 --- a/src/renku/app/org.kde.renku.appdata.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - org.kde.renku.desktop - CC0-1.0 - GPL-3.0+ - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - Renku - xxRenkuxx - Renku - Note Taking Application - Aplicació per prendre notes - Aplicació per prendre notes - Program til at tage noter - Programm zur Notizenerstellung - Note Taking Application - Aplicación para tomar notas - Muistiinpanosovellus - Application de prise de notes - Aplicativo para tomar notas - Aplikasi Pencatatan - Applicazione per prendere delle note - Toepassing voor notities - Aplikacja do robienia notatek - Aplicação de Apontamento de Notas - Aplicativo de notas - Aplikácia na tvorbu poznámok - Anteckningsprogram - Not Alma Uygulaması - Програма для роботи з нотатками - xxNote Taking Applicationxx - 笔记应用程序 - -

- Renku is an efficient and simple application for managing your notes. - It helps you organize the knowledge you accumulate and acts as a personal wiki. - You'll never forget anything anymore, getting your mind like water. -

-

El Renku és una aplicació eficaç i senzilla per a la gestió de les vostres notes. Ajuda a organitzar el coneixement que acumuleu i actua com un wiki personal. Mai oblidareu res més, fa que la vostra ment sigui com l'aigua.

-

El Renku és una aplicació eficaç i senzilla per a la gestió de les vostres notes. Ajuda a organitzar el coneixement que acumuleu i actua com un wiki personal. Mai oblidareu res més, fa que la vostra ment siga com l'aigua.

-

Renku er et effektivt og simpelt program til at håndtere dine noter. Den hjælper dig med at organisere den viden du indsamler og fungere som en personlig wiki. Du vil aldrig glemme noget længere, med tanker som var de vand.

-

Renku is an efficient and simple application for managing your notes. It helps you organize the knowledge you accumulate and acts as a personal wiki. You'll never forget anything anymore, getting your mind like water.

-

Renku es una aplicación sencilla y eficiente para la gestión de notas. Le ayuda a organizar el conocimiento que vaya acumulando y actúa como una wiki personal. Nunca volverá a olvidarse de nada, manteniendo sus pensamientos claros como el agua.

-

Renku on yksinkertainen ja tehokas sovellus muistiinpanojesi hallitsemiseen. Se auttaa sinua järjestämään keräämiäsi tietoja ja toimii henkilökohtaisena wikinä. Et koskaan enää unohda mitään: se toimii kuin vettä vain.

-

Renku est une application simple et efficace de gestion de vos notes. Elle vous aide à organiser les connaissances que vous accumulez, à la manière d'un wiki personnel. Vous n'oublierez plus jamais rien et votre réflexion n'aura jamais été aussi fluide.

-

Renku é un aplicativo eficiente e sinxelo para xestionar notas. Axúdao a organizar o coñecemento que acumula, e actúa como un wiki persoal. Non volverá esquecer nada nunca máis, convertendo a súa mente en auga.

-

Renku adalah aplikasi yang efisien dan sederhana untuk mengelola catatanmu. Ini membantu kamu mengatur pengetahuan yang kamu kumpulkan dan bertindak sebagai wiki pribadi. Kamu tidak akan pernah melupakan apa pun lagi, membuat pikiranmu seperti air yang mengalir.

-

Renku è un'applicazione semplice ed efficiente per la gestione delle tue note. Consente di organizzare la conoscenza che accumuli e agisce come un wiki personale. Non dimenticherai mai più niente, lasciando la tua mente fluida come l'acqua.

-

Renku is een efficiënte en eenvoudige toepassing voor het beheer van uw notities. Het helpt u de verzamelde kennis te organiseren en werkt als een persoonlijke wiki. U zult nooit meer iets vergeten en uw geheugen is geen zeef meer.

-

Renku jest wydajną i prostą aplikacją do zarządzania notatkami. Pomaga uporządkować zbieraną przez ciebie wiedzę i działa jak osobista wikipedia. Nigdy już nie zapomnisz o niczym, twoje myśli staną się jak woda.

-

O Renku é uma aplicação eficiente e simples para gerir as suas notas. Ajuda-o a organizar o conhecimento que acumula e actua como uma Wiki pessoal. Nunca mais se irá esquecer de nada, deixando a sua mente clara como água.

-

Renku é um aplicativo eficiente e simples para gerenciar suas notas. Ajuda-o a organizar o conhecimento acumulado e atua como uma Wiki pessoal. Nunca mais esqueça de nada, deixando sua mente clara como água.

-

Renku je efektívna a jednoduchá aplikácia na spravovanie vašich poznámok. Pomôže vám organizovať vedomosti, ktoré získate a správa sa ako osobné wiki. Už nikdy nič nezabudnete, čím sa vám prečistí myseľ.

-

Renku är ett effektivt och enkelt program för att hantera anteckningar. Det hjälper dig att organisera insamlad kunskap och fungerar som en personlig wiki. Du kommer aldrig att glömma någonting längre, och ditt sinne blir som flödande vatten.

-

Renku, notlarınızı yönetmek için etkili ve basit bir uygulamadır. Biriktirdiğiniz bilgileri düzenlemenize yardımcı olur ve kişisel bir wiki olarak hareket eder. Dikkatinizi toplayabileceksiniz ve artık bir şey unutmayacaksın.

-

Renku — ефективна і проста програма для керування вашими нотатками. Вона допомагає упорядкувати ваші значення і працює як особиста вікіпедія. Вам легше буде усе пам’ятати, ніщо не заважатиме вашим думкам.

-

xxRenku is an efficient and simple application for managing your notes. It helps you organize the knowledge you accumulate and acts as a personal wiki. You'll never forget anything anymore, getting your mind like water.xx

-

Features:

-

Característiques:

-

Característiques:

-

Vlastnosti:

-

Funktioner:

-

Funktionen:

-

Features:

-

Funciones:

-

Ominaisuuksia:

-

Fonctionnalités :

-

Funcionalidades:

-

Fitur:

-

Funzionalità:

-

Mogelijkheden:

-

Możliwości:

-

Funcionalidades:

-

Funcionalidades:

-

Funkcie:

-

Funktioner:

-

Özellikler:

-

Можливості:

-

xxFeatures:xx

-

功能:

-
    -
  • Collects notes
  • -
  • Recull les notes
  • -
  • Recull les notes
  • -
  • Indsamler noter
  • -
  • Notizen sammeln
  • -
  • Collects notes
  • -
  • Recolección de notas
  • -
  • Kokoaa muistiinpanot
  • -
  • Collection de notes
  • -
  • Recoller notas.
  • -
  • Mengumpulkan catatan
  • -
  • Raccoglie note
  • -
  • Verzamelt notities
  • -
  • Zbieranie notatek
  • -
  • Recolhe notas
  • -
  • Coleta notas
  • -
  • Zbiera poznámky
  • -
  • Samlar anteckningar
  • -
  • Notları toplar
  • -
  • Збирання нотаток.
  • -
  • xxCollects notesxx
  • -
  • 收集便笺
  • -
  • Organize notes in topics
  • -
  • Organitza les notes en temes
  • -
  • Organitza les notes en temes
  • -
  • Organiser noter i emner
  • -
  • Ordnen von Notizen nach Themen
  • -
  • Organise notes in topics
  • -
  • Organización de las notas por temas
  • -
  • Järjestää muistiinpanot aiheiksi
  • -
  • Organisation de notes au sein de sujets
  • -
  • Organizar notas por temas.
  • -
  • Mengatur catatan dalam topik
  • -
  • Organizza le note in argomenti
  • -
  • Organiseert notities in onderwerpen
  • -
  • Porządkowanie notatek w tematy
  • -
  • Organiza as notas por tópicos
  • -
  • Organiza as notas em tópicos
  • -
  • Organizuje poznámky v témach
  • -
  • Organisera anteckningar enligt ämne
  • -
  • Notları, başlıklar şeklinde düzenler
  • -
  • Упорядковування нотаток за темами.
  • -
  • xxOrganize notes in topicsxx
  • -
  • 按主题组织便笺
  • -
  • Akonadi-enabled application allowing to get the data from virtually anywhere (local, imap, web service...)
  • -
  • Habilitant les capacitats de l'Akonadi es permet obtenir les dades des de pràcticament qualsevol lloc (local, IMAP, servei web...)
  • -
  • Habilitant les capacitats de l'Akonadi es permet obtindre les dades des de pràcticament qualsevol lloc (local, IMAP, servei web...)
  • -
  • Akonadi-aktiveret program som giver mulighed for at hente data fra næsten hvor som helst (lokalt, imap, webtjeneste...)
  • -
  • Akonadi-enabled application allowing to get the data from virtually anywhere (local, imap, web service...)
  • -
  • Aplicación que usa Akonadi para permitirle obtener datos de cualquier lugar (local, imap, servicio web...)
  • -
  • Akonadiin perustuva sovellus sallii etsiä tietoa käytännössä mistä vain (kiintolevyltä, IMAPista, verkkopalveluista…)
  • -
  • Prise en charge d'Akonadi dans l'application afin de recevoir les données quelle que soit leur source (local, imap, service web, ...)
  • -
  • O aplicativo é compatíbel con Akonadi, e permítelle obter datos de practicamente calquera lugar (local, IMAP, servizos web).
  • -
  • Aplikasi akonadi difungsikan memungkinkan untuk mendapatkan data dari mana pun secara virtual (layanan local, imap, web...)
  • -
  • Applicazione basata su Akonadi che consente di ottenere i dati praticamente ovunque (locale, imap, servizio web...)
  • -
  • In Akonadi opgenomen toepassing waarmee u de gegevens werkelijk overal vandaan kunt halen (lokaal, imap, webservice...)
  • -
  • Program wykorzystuje Akonadi, więc można pobierać dane praktycznie z każdego miejsca (lokalnie, imap, usługa sieciowa...)
  • -
  • Aplicação com suporte para o Akonadi, permitindo-lhe recolher os dados de praticamente todo o lado (local, IMAP, serviço Web...)
  • -
  • Aplicativo com suporte para o Akonadi, permitindo-lhe coletar os dados de praticamente tudo (local, IMAP, serviço Web...)
  • -
  • Aplikácia používajúca Akonadi umožňujúca získanie údajov zdanlivo odvšadiaľ (miestne, imap, webové služby...)
  • -
  • Program med Akonadi-stöd som gör det möjligt att hämta data från i stort sett var som helst (lokalt, IMAP, webbtjänster ...)
  • -
  • Akonadi-etkin uygulama, sanal bir yerden (yerel, imap, web servisi...) veriyi almanıza imkan sağlar
  • -
  • Інтеграція з Akonadi, що надає програмі змогу отримувати дані практично з будь-яких джерел (локальна мережа, imap, інтернет-служба...)
  • -
  • xxAkonadi-enabled application allowing to get the data from virtually anywhere (local, imap, web service...)xx
  • -
-
- http://zanshin.kde.org - https://bugs.kde.org/enter_bug.cgi?format=guided&product=zanshin - KDE - - renku - -
diff --git a/src/renku/app/org.kde.renku.desktop b/src/renku/app/org.kde.renku.desktop deleted file mode 100755 --- a/src/renku/app/org.kde.renku.desktop +++ /dev/null @@ -1,48 +0,0 @@ -[Desktop Entry] -Type=Application -Categories=Qt;KDE;Utility;X-KDE-Utilities-PIM; -Exec=renku -Name=Renku -Name[ca]=Renku -Name[ca@valencia]=Renku -Name[da]=Renku -Name[de]=Renku -Name[en_GB]=Renku -Name[es]=Renku -Name[fi]=Renku -Name[fr]=Renku -Name[gl]=Renku -Name[it]=Renku -Name[nl]=Renku -Name[pl]=Renku -Name[pt]=Renku -Name[pt_BR]=Renku -Name[sk]=Renku -Name[sv]=Renku -Name[tr]=Renku -Name[uk]=Renku -Name[x-test]=xxRenkuxx -Name[zh_CN]=Renku -Icon=zanshin -GenericName=Note Taking Application -GenericName[ca]=Aplicació per prendre notes -GenericName[ca@valencia]=Aplicació per prendre notes -GenericName[da]=Program til at tage noter -GenericName[de]=Programm zur Notizenerstellung -GenericName[en_GB]=Note Taking Application -GenericName[es]=Aplicación para tomar notas -GenericName[fi]=Muistiinpanosovellus -GenericName[fr]=Application de prise de notes -GenericName[gl]=Aplicativo para tomar notas -GenericName[it]=Applicazione per prendere delle note -GenericName[nl]=Toepassing voor notities -GenericName[pl]=Aplikacja do robienia notatek -GenericName[pt]=Aplicação de Apontamentos de Notas -GenericName[pt_BR]=Aplicativo de notas -GenericName[sk]=Aplikácia na tvorbu poznámok -GenericName[sv]=Anteckningsprogram -GenericName[tr]=Not Alma Uygulaması -GenericName[uk]=Програма для роботи з нотатками -GenericName[x-test]=xxNote Taking Applicationxx -GenericName[zh_CN]=笔记应用程序 -X-DBUS-ServiceName=org.kde.renku diff --git a/src/renku/app/renkuui.rc b/src/renku/app/renkuui.rc deleted file mode 100644 --- a/src/renku/app/renkuui.rc +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - &Go - - - - - - - - - - &Panels - - - - - - - - Main Toolbar - - - - - - - - diff --git a/src/renku/kontact/CMakeLists.txt b/src/renku/kontact/CMakeLists.txt deleted file mode 100644 --- a/src/renku/kontact/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -set(part_SRCS - ../app/aboutdata.cpp - ../app/dependencies.cpp - part.cpp -) - -add_library(renku_part MODULE ${part_SRCS}) -kde_enable_exceptions() -target_link_libraries(renku_part - KF5::Parts - akonadi - domain - presentation - scripting - utils - widgets -) - -install(TARGETS renku_part DESTINATION ${KDE_INSTALL_PLUGINDIR}) -install(FILES renku_part.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) - -########################## - -set(kontact_SRCS - kontact_plugin.cpp -) - -add_library(kontact_renkuplugin MODULE ${kontact_SRCS}) -target_link_libraries(kontact_renkuplugin KF5::Parts KF5::KontactInterface) - -install(TARGETS kontact_renkuplugin DESTINATION ${KDE_INSTALL_PLUGINDIR}) -install(FILES renku_plugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/kontact) -install(FILES renku_part.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/renku) - diff --git a/src/renku/kontact/kontact_plugin.h b/src/renku/kontact/kontact_plugin.h deleted file mode 100644 --- a/src/renku/kontact/kontact_plugin.h +++ /dev/null @@ -1,43 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef RENKU_KONTACT_PLUGIN_H -#define RENKU_KONTACT_PLUGIN_H - -#include - -class Plugin : public KontactInterface::Plugin -{ - Q_OBJECT - -public: - Plugin(KontactInterface::Core *core, const QVariantList &); - - int weight() const Q_DECL_OVERRIDE { return 449; } - -protected: - KParts::ReadOnlyPart *createPart() Q_DECL_OVERRIDE; -}; - -#endif - diff --git a/src/renku/kontact/kontact_plugin.cpp b/src/renku/kontact/kontact_plugin.cpp deleted file mode 100644 --- a/src/renku/kontact/kontact_plugin.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "kontact_plugin.h" - -#include - -EXPORT_KONTACT_PLUGIN(Plugin, renku) - -Plugin::Plugin(KontactInterface::Core *core, const QVariantList&) - : KontactInterface::Plugin(core, core, "renku") -{ - setComponentName(QStringLiteral("renku"), QStringLiteral("renku")); -} - -KParts::ReadOnlyPart *Plugin::createPart() -{ - return loadPart(); -} -#include "kontact_plugin.moc" diff --git a/src/renku/kontact/part.h b/src/renku/kontact/part.h deleted file mode 100644 --- a/src/renku/kontact/part.h +++ /dev/null @@ -1,43 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef RENKU_PART_H -#define RENKU_PART_H - -#include -#include - -class Part : public KParts::ReadOnlyPart -{ - Q_OBJECT - -public: - Part(QWidget *parentWidget, QObject *parent, const QVariantList &); - ~Part(); - -protected: - virtual bool openFile() Q_DECL_OVERRIDE; -}; - -#endif - diff --git a/src/renku/kontact/part.cpp b/src/renku/kontact/part.cpp deleted file mode 100644 --- a/src/renku/kontact/part.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* This file is part of Renku Notes - - Copyright 2015 Kevin Ottens - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "part.h" - -#include -#include - -#include -#include -#include -#include - -#include "../app/aboutdata.h" -#include "../app/dependencies.h" - -#include "presentation/applicationmodel.h" - -#include "widgets/applicationcomponents.h" -#include "widgets/availablepagesview.h" -#include "widgets/availablesourcesview.h" -#include "widgets/editorview.h" -#include "widgets/pageview.h" - -#include "utils/dependencymanager.h" - -K_PLUGIN_FACTORY(PartFactory, registerPlugin();) - -Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList &) - : KParts::ReadOnlyPart(parent) -{ - App::initializeDependencies(); - - setComponentName(QStringLiteral("renku"), QStringLiteral("renku")); - - auto splitter = new QSplitter(parentWidget); - auto sidebar = new QSplitter(Qt::Vertical, parentWidget); - - auto components = new Widgets::ApplicationComponents(parentWidget); - components->setModel(Presentation::ApplicationModel::Ptr::create()); - - sidebar->addWidget(components->availablePagesView()); - sidebar->addWidget(components->availableSourcesView()); - - splitter->addWidget(sidebar); - splitter->addWidget(components->pageView()); - splitter->addWidget(components->editorView()); - setWidget(splitter); - - auto actions = QHash(); - actions.unite(components->availableSourcesView()->globalActions()); - actions.unite(components->availablePagesView()->globalActions()); - actions.unite(components->pageView()->globalActions()); - - auto ac = actionCollection(); - for (auto it = actions.constBegin(); it != actions.constEnd(); ++it) { - auto shortcut = it.value()->shortcut(); - if (!shortcut.isEmpty()) { - ac->setDefaultShortcut(it.value(), shortcut); - } - ac->addAction(it.key(), it.value()); - } - - setXMLFile(QStringLiteral("renku_part.rc"), true); -} - -Part::~Part() -{ -} - -bool Part::openFile() -{ - return false; -} -#include "part.moc" diff --git a/src/renku/kontact/renku_part.desktop b/src/renku/kontact/renku_part.desktop deleted file mode 100644 --- a/src/renku/kontact/renku_part.desktop +++ /dev/null @@ -1,27 +0,0 @@ -[Desktop Entry] -Name=Renku Part -Name[ca]=Part del Renku -Name[ca@valencia]=Part del Renku -Name[da]=Renku Part -Name[de]=Renku Part -Name[en_GB]=Renku Part -Name[es]=Parte Renku -Name[fi]=Renku-osa -Name[fr]=Composant Renku -Name[gl]=Parte de Renku -Name[it]=Componente di Renku -Name[nl]=Gedeelte voor Renku -Name[pl]=Moduł Renku -Name[pt]=Componente do Renku -Name[pt_BR]=Componente do Renku -Name[sk]=Časť Renku -Name[sv]=Renku-delprogram -Name[tr]=Renku Kısmı -Name[uk]=Модуль Renku -Name[x-test]=xxRenku Partxx -Name[zh_CN]=Renku 组件 -X-KDE-ServiceTypes=KParts/ReadOnlyPart -X-KDE-Library=renku_part -Type=Service -Icon=knotes - diff --git a/src/renku/kontact/renku_part.rc b/src/renku/kontact/renku_part.rc deleted file mode 100644 --- a/src/renku/kontact/renku_part.rc +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - &Go - - - - - - - - - - Main Toolbar - - - - - - - - diff --git a/src/renku/kontact/renku_plugin.desktop b/src/renku/kontact/renku_plugin.desktop deleted file mode 100644 --- a/src/renku/kontact/renku_plugin.desktop +++ /dev/null @@ -1,61 +0,0 @@ -[Desktop Entry] -Type=Service -Icon=knotes -X-KDE-ServiceTypes=Kontact/Plugin,KPluginInfo - -X-KDE-Library=kontact_renkuplugin -X-KDE-KontactPluginVersion=10 -X-KDE-KontactPartLibraryName=renku_part -X-KDE-KontactPartExecutableName=renku -X-KDE-KontactPartLoadOnStart=false -X-KDE-KontactPluginHasSummary=false - -X-KDE-PluginInfo-Name=kontact_renkuplugin -X-KDE-PluginInfo-Version=0.1 -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true -X-KDE-PluginInfo-AllowEmptySettings=true - -Comment=Kontact Renku Plugin -Comment[ca]=Connector del Renku pel Kontact -Comment[ca@valencia]=Connector del Renku pel Kontact -Comment[da]=Renku-plugin til Kontact -Comment[de]=Renku-Modul für Kontakt -Comment[en_GB]=Kontact Renku Plugin -Comment[es]=Complemento Renku para Kontact -Comment[fi]=Kontactin Renku-osa -Comment[fr]=Module externe Renku pour Kontact -Comment[gl]=Complemento de Renku para Kontact -Comment[it]=Estensione per Kontact di Renku -Comment[nl]=Kontact-plugin voor Renku -Comment[pl]=Wtyczka kontaktów Renku -Comment[pt]='Plugin' do Renku para o Kontact -Comment[pt_BR]=Plugin do Renku para o Kontact -Comment[sk]=Plugin Renku pre Kontact -Comment[sv]=Renku-insticksprogram för Kontact -Comment[tr]=Kontact Renku Eklentisi -Comment[uk]=Додаток Renku до Kontact -Comment[x-test]=xxKontact Renku Pluginxx -Comment[zh_CN]=Kontact Renku 插件 -Name=Notes -Name[ca]=Notes -Name[ca@valencia]=Notes -Name[cs]=Poznámky -Name[da]=Noter -Name[de]=Notizen -Name[en_GB]=Notes -Name[es]=Notas -Name[fi]=Muistiinpanot -Name[fr]=Notes -Name[gl]=Notas -Name[it]=Note -Name[nl]=Notities -Name[pl]=Notatki -Name[pt]=Notas -Name[pt_BR]=Notas -Name[sk]=Poznámky -Name[sv]=Anteckningar -Name[tr]=Notlar -Name[uk]=Нотатки -Name[x-test]=xxNotesxx -Name[zh_CN]=注记 diff --git a/src/widgets/availablepagesview.cpp b/src/widgets/availablepagesview.cpp --- a/src/widgets/availablepagesview.cpp +++ b/src/widgets/availablepagesview.cpp @@ -43,7 +43,6 @@ #include "domain/project.h" #include "domain/context.h" -#include "domain/tag.h" using namespace Widgets; using namespace Presentation; @@ -249,8 +248,7 @@ const auto object = current.data(QueryTreeModelBase::ObjectRole).value(); m_removeAction->setEnabled(object.objectCast() - || object.objectCast() - || object.objectCast()); + || object.objectCast()); } void AvailablePagesView::onAddProjectTriggered() @@ -303,9 +301,6 @@ } else if (Domain::Context::Ptr context = object.objectCast()) { title = i18n("Delete Context"); text = i18n("Do you really want to delete the context '%1'?", context->name()); - } else if (Domain::Tag::Ptr tag = object.objectCast()) { - title = i18n("Delete Tag"); - text = i18n("Do you really want to delete the tag '%1'?", tag->name()); } else { qFatal("Unrecognized object type"); return; diff --git a/src/widgets/itemdelegate.cpp b/src/widgets/itemdelegate.cpp --- a/src/widgets/itemdelegate.cpp +++ b/src/widgets/itemdelegate.cpp @@ -30,7 +30,6 @@ #include -#include "domain/note.h" #include "domain/task.h" #include "presentation/pagemodel.h" #include "presentation/querytreemodelbase.h" @@ -71,9 +70,8 @@ task = artifact.dynamicCast(); } else { task = data.value(); - auto note = data.value(); artifact = task ? task.staticCast() - : note.staticCast(); + : Domain::Artifact::Ptr(); } auto opt = QStyleOptionViewItem(option); diff --git a/tests/features/CMakeLists.txt b/tests/features/CMakeLists.txt --- a/tests/features/CMakeLists.txt +++ b/tests/features/CMakeLists.txt @@ -2,6 +2,5 @@ if(Boost_UNIT_TEST_FRAMEWORK_FOUND) add_subdirectory(zanshin) - add_subdirectory(renku) endif() diff --git a/tests/features/renku/CMakeLists.txt b/tests/features/renku/CMakeLists.txt deleted file mode 100644 --- a/tests/features/renku/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -add_subdirectory(features) - -add_executable(tests-features-renku ../features-run.cpp) -add_test(NAME tests-features-renku COMMAND tests-features-renku) -add_definitions(-DUSER_XMLDATA="${CMAKE_CURRENT_SOURCE_DIR}/../testenv/data/testdata.xml" - -DCUKE_STEPS="${CMAKE_CURRENT_BINARY_DIR}/features/step_definitions/renku-cuke-steps" - -DFEATURES_DIR="${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(tests-features-renku - Qt5::Core - Qt5::Network -) -# Don't run this at the same time as tests-features-zanshin -set_tests_properties(tests-features-renku PROPERTIES RUN_SERIAL TRUE) diff --git a/tests/features/renku/features/CMakeLists.txt b/tests/features/renku/features/CMakeLists.txt deleted file mode 100644 --- a/tests/features/renku/features/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(step_definitions) diff --git a/tests/features/renku/features/datasource/datasource-default-settings.feature b/tests/features/renku/features/datasource/datasource-default-settings.feature deleted file mode 100644 --- a/tests/features/renku/features/datasource/datasource-default-settings.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Default data source - As an advanced user - I can choose the default data source - In order to quickly store notes - - Scenario: Have a default data source for notes - Given I display the available data sources - When the setting key defaultNoteCollection changes to 6 - Then the default data source is "TestData / Private Notes" - - Scenario: Change the default data source for notes - Given I display the available data sources - And the setting key defaultNoteCollection changes to 42 - When the user changes the default data source to "TestData / Private Notes" - Then the setting key defaultNoteCollection is 6 diff --git a/tests/features/renku/features/datasource/datasource-listing.feature b/tests/features/renku/features/datasource/datasource-listing.feature deleted file mode 100644 --- a/tests/features/renku/features/datasource/datasource-listing.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Data sources listing - As an advanced user - I can list sources - In order to list and store notes - - Scenario: All note sources appear in the list - Given I display the available data sources - When I list the items - Then the list is: - | display | icon | - | TestData | folder | - | TestData / Emails | folder | - | TestData / Emails / Notes | folder | - | TestData / Private Notes | folder | diff --git a/tests/features/renku/features/datasource/datasource-selection.feature b/tests/features/renku/features/datasource/datasource-selection.feature deleted file mode 100644 --- a/tests/features/renku/features/datasource/datasource-selection.feature +++ /dev/null @@ -1,24 +0,0 @@ -Feature: Data sources selection - As an advanced user - I can select or deselect sources - In order to see more or less content - - Scenario: Unchecking impacts the inbox - Given I display the "Inbox" page - And there is an item named "TestData / Emails / Notes" in the available data sources - When I uncheck the item - And I look at the central list - And I list the items - Then the list is: - | display | - - Scenario: Checking impacts the inbox - Given I display the "Inbox" page - And there is an item named "TestData / Emails / Notes" in the available data sources - When I check the item - And I look at the central list - And I list the items - Then the list is: - | display | - | A note about nothing interesting | - diff --git a/tests/features/renku/features/editing/adding-note.feature b/tests/features/renku/features/editing/adding-note.feature deleted file mode 100644 --- a/tests/features/renku/features/editing/adding-note.feature +++ /dev/null @@ -1,16 +0,0 @@ -Feature: Adding notes - As a note junkie - I can create note by giving a title - In order to collect ideas while reflecting on my life - - Scenario Outline: Adding a note in a page - Given I display the "" page - And I look at the central list - When I add a "note" named "" - And I list the items - Then the list contains "<title>" - - Examples: - | page | title | - | Inbox | A page of diary | - | Tags / Philosophy | A random note on life | diff --git a/tests/features/renku/features/editing/editing-note.feature b/tests/features/renku/features/editing/editing-note.feature deleted file mode 100644 --- a/tests/features/renku/features/editing/editing-note.feature +++ /dev/null @@ -1,12 +0,0 @@ -Feature: Editing notes - As an organized person - I can edit a previously created note - In order to improve it, logging more ideas - - Scenario: Editing a note text - Given I display the "Inbox" page - And there is an item named "A note about nothing interesting" in the central list - When I open the item in the editor - And I change the editor text to "This is a boring note" - And I open the item in the editor again - Then the editor shows "This is a boring note" as text diff --git a/tests/features/renku/features/editing/removing-note.feature b/tests/features/renku/features/editing/removing-note.feature deleted file mode 100644 --- a/tests/features/renku/features/editing/removing-note.feature +++ /dev/null @@ -1,17 +0,0 @@ -Feature: Removing notes - As a note junkie - I can delete a note so it is removed - In order to clean up the old junk I accumulated - - Scenario Outline: Removing a note from a page - Given I display the "<page>" page - And there is an item named "<title>" in the central list - When I remove the item - And I list the items - Then the list does not contain "<title>" - - Examples: - | page | title | - | Inbox | A note about nothing interesting | - | Tags / Philosophy | A note about philosophy | - diff --git a/tests/features/renku/features/inbox/inbox-display.feature b/tests/features/renku/features/inbox/inbox-display.feature deleted file mode 100644 --- a/tests/features/renku/features/inbox/inbox-display.feature +++ /dev/null @@ -1,12 +0,0 @@ -Feature: Inbox content - As someone collecting notes - I can display the Inbox - In order to see the notes (e.g. any note not associated to tag) - - Scenario: Unorganized notes appear in the inbox - Given I display the "Inbox" page - And I look at the central list - When I list the items - Then the list is: - | display | - | A note about nothing interesting | diff --git a/tests/features/renku/features/pages/pages-display.feature b/tests/features/renku/features/pages/pages-display.feature deleted file mode 100644 --- a/tests/features/renku/features/pages/pages-display.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Available pages content - As someone collecting notes - I can see all the pages available to me - In order to display them and add notes to them - - Scenario: Inbox and tags appear in the list - Given I display the available pages - When I list the items - Then the list is: - | display | icon | - | Inbox | mail-folder-inbox | - | Tags | folder | - | Tags / Philosophy | view-pim-tasks | - | Tags / Physics | view-pim-tasks | - diff --git a/tests/features/renku/features/step_definitions/CMakeLists.txt b/tests/features/renku/features/step_definitions/CMakeLists.txt deleted file mode 100644 --- a/tests/features/renku/features/step_definitions/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -include_directories(${Boost_INCLUDE_DIRS}) -include_directories(${CMAKE_SOURCE_DIR}/3rdparty/cucumber-cpp/include) - -# Because cucumber-cpp exhibits plenty of warnings -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - -set(steps_SRCS - main.cpp - ../../../cuke-steps.cpp - ${CMAKE_SOURCE_DIR}/src/renku/app/dependencies.cpp -) - -add_executable(renku-cuke-steps ${steps_SRCS}) -target_link_libraries(renku-cuke-steps - cucumber-cpp - Threads::Threads - ${Boost_REGEX_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} - Qt5::Test - testlib - akonadi - domain - presentation - scripting - utils -) diff --git a/tests/features/renku/features/step_definitions/cucumber.wire b/tests/features/renku/features/step_definitions/cucumber.wire deleted file mode 100644 --- a/tests/features/renku/features/step_definitions/cucumber.wire +++ /dev/null @@ -1,2 +0,0 @@ -host: localhost -port: 3902 diff --git a/tests/features/renku/features/step_definitions/main.cpp b/tests/features/renku/features/step_definitions/main.cpp deleted file mode 100644 --- a/tests/features/renku/features/step_definitions/main.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* This file is part of Renku - - Copyright 2014-2015 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "renku/app/dependencies.h" - -namespace CukeSteps -{ - void initializeAppDependencies() - { - App::initializeDependencies(); - } -} - diff --git a/tests/features/renku/features/tags/tag-add.feature b/tests/features/renku/features/tags/tag-add.feature deleted file mode 100644 --- a/tests/features/renku/features/tags/tag-add.feature +++ /dev/null @@ -1,17 +0,0 @@ -Feature: Tag creation - As someone using notes - I can create a tag - In order to give them some semantic - - - Scenario: New tags appear in the list - Given I display the available pages - When I add a "tag" named "Optional" - And I list the items - Then the list is: - | display | icon | - | Inbox | mail-folder-inbox | - | Tags | folder | - | Tags / Optional | view-pim-tasks | - | Tags / Philosophy | view-pim-tasks | - | Tags / Physics | view-pim-tasks | diff --git a/tests/features/renku/features/tags/tag-display.feature b/tests/features/renku/features/tags/tag-display.feature deleted file mode 100644 --- a/tests/features/renku/features/tags/tag-display.feature +++ /dev/null @@ -1,12 +0,0 @@ -Feature: Tag content - As someone collecting notes - I can display a tag - In order to see the notes associated to it - - Scenario: Tag notes appear in the corresponding page - Given I display the "Tags / Philosophy" page - And I look at the central list - When I list the items - Then the list is: - | display | - | A note about philosophy | diff --git a/tests/features/renku/features/tags/tag-drag-and-drop.feature b/tests/features/renku/features/tags/tag-drag-and-drop.feature deleted file mode 100644 --- a/tests/features/renku/features/tags/tag-drag-and-drop.feature +++ /dev/null @@ -1,17 +0,0 @@ -Feature: Tag note association - As someone collecting notes - I can associate notes to a tag - In order to describe the notes - - Scenario: Dropping a notes on a tag - Given I display the "Inbox" page - And there is an item named "A note about nothing interesting" in the central list - When I drop the item on "Tags / Physics" in the page list - And I display the "Tags / Physics" page - And I look at the central list - And I list the items - Then the list is: - | display | - | A note about physics | - | A note about nothing interesting | - diff --git a/tests/features/renku/features/tags/tag-note-add.feature b/tests/features/renku/features/tags/tag-note-add.feature deleted file mode 100644 --- a/tests/features/renku/features/tags/tag-note-add.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Note creation from a tag - As someone collecting notes - I can add a note directly associated to a tag - In order to give my note some semantic - - Scenario: Note added from a tag appear in its list - Given I display the "Tags / Physics" page - When I add a "note" named "Studies in fluid mechanics" - And I look at the central list - When I list the items - Then the list is: - | display | - | A note about physics | - | Studies in fluid mechanics | diff --git a/tests/features/renku/features/tags/tag-note-remove.feature b/tests/features/renku/features/tags/tag-note-remove.feature deleted file mode 100644 --- a/tests/features/renku/features/tags/tag-note-remove.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Tag note dissociation - As someone collecting notes - I can delete a note related to a tag - In order to keep my tag meaningful - - Scenario: Removing a note linked to a tag from the central list - Given I display the "Inbox" page - And I look at the central list - Then the list is: - | display | - And I display the "Tags / Philosophy" page - And there is an item named "A note about philosophy" in the central list - When I remove the item - And I look at the central list - Then the list does not contain "A note about philosophy" diff --git a/tests/features/renku/features/tags/tag-note-reset.feature b/tests/features/renku/features/tags/tag-note-reset.feature deleted file mode 100644 --- a/tests/features/renku/features/tags/tag-note-reset.feature +++ /dev/null @@ -1,19 +0,0 @@ -Feature: Tag reset - As someone using notes - I can reset a note from all its tags - In order to maintain the semantic - - Scenario: Resetting a note dissociate it from all its tags - Given I display the "Tags / Physics" page - And there is an item named "A note about physics" in the central list - When I drop the item on "Inbox" in the page list - And I list the items - And the list does not contain "A note about physics" - And I display the "Inbox" page - And I look at the central list - And I list the items - Then the list is: - | display | - | A note about nothing interesting | - | A note about physics | - diff --git a/tests/features/renku/features/tags/tag-remove.feature b/tests/features/renku/features/tags/tag-remove.feature deleted file mode 100644 --- a/tests/features/renku/features/tags/tag-remove.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Tag removal - As someone using notes - I can remove a tag - In order to maintain their semantic - - Scenario: Removed tag disappear from the list - Given I display the available pages - When I remove the page named "Physics" under "Tags" - And I list the items - Then the list is: - | display | icon | - | Inbox | mail-folder-inbox | - | Tags | folder | - | Tags / Philosophy | view-pim-tasks | diff --git a/tests/testlib/CMakeLists.txt b/tests/testlib/CMakeLists.txt --- a/tests/testlib/CMakeLists.txt +++ b/tests/testlib/CMakeLists.txt @@ -9,7 +9,6 @@ akonadistoragetestbase.cpp fakejob.cpp gencollection.cpp - gennote.cpp gentag.cpp gentodo.cpp modeltest.cpp diff --git a/tests/testlib/gennote.h b/tests/testlib/gennote.h deleted file mode 100644 --- a/tests/testlib/gennote.h +++ /dev/null @@ -1,53 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#ifndef TESTLIB_GENNOTE_H -#define TESTLIB_GENNOTE_H - -#include <QObject> - -#include <AkonadiCore/Item> - -namespace Testlib { - -class GenNote -{ -public: - explicit GenNote(const Akonadi::Item &item = Akonadi::Item()); - - operator Akonadi::Item(); - - GenNote &withId(Akonadi::Item::Id id); - GenNote &withParent(Akonadi::Collection::Id id); - GenNote &withTags(const QList<Akonadi::Tag::Id> &ids); - GenNote &withParentUid(const QString &uid); - GenNote &withTitle(const QString &title); - GenNote &withText(const QString &text); - -private: - Akonadi::Item m_item; -}; - -} - -#endif // TESTLIB_GENNOTE_H diff --git a/tests/testlib/gennote.cpp b/tests/testlib/gennote.cpp deleted file mode 100644 --- a/tests/testlib/gennote.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "gennote.h" - -#include <algorithm> - -#include <Akonadi/Notes/NoteUtils> -#include <KMime/Message> - -using namespace Testlib; - -GenNote::GenNote(const Akonadi::Item &item) - : m_item(item) -{ - m_item.setMimeType(Akonadi::NoteUtils::noteMimeType()); - if (!m_item.hasPayload<KMime::Message::Ptr>()) - m_item.setPayload(KMime::Message::Ptr(new KMime::Message)); -} - -GenNote::operator Akonadi::Item() -{ - return m_item; -} - -GenNote &GenNote::withId(Akonadi::Item::Id id) -{ - m_item.setId(id); - return *this; -} - -GenNote &GenNote::withParent(Akonadi::Collection::Id id) -{ - m_item.setParentCollection(Akonadi::Collection(id)); - return *this; -} - -GenNote &GenNote::withTags(const QList<Akonadi::Tag::Id> &ids) -{ - auto tags = Akonadi::Tag::List(); - std::transform(ids.constBegin(), ids.constEnd(), - std::back_inserter(tags), - [] (Akonadi::Tag::Id id) { - return Akonadi::Tag(id); - }); - m_item.setTags(tags); - return *this; -} - -GenNote &GenNote::withParentUid(const QString &uid) -{ - auto message = m_item.payload<KMime::Message::Ptr>(); - if (!uid.isEmpty()) { - auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader->from7BitString(uid.toUtf8()); - message->appendHeader(relatedHeader); - } else { - (void)message->removeHeader("X-Zanshin-RelatedProjectUid"); - } - message->assemble(); - m_item.setPayload(message); - return *this; -} - -GenNote &GenNote::withTitle(const QString &title) -{ - auto message = m_item.payload<KMime::Message::Ptr>(); - Akonadi::NoteUtils::NoteMessageWrapper wrapper(message); - wrapper.setTitle(title); - m_item.setPayload(wrapper.message()); - return *this; -} - -GenNote &GenNote::withText(const QString &text) -{ - auto message = m_item.payload<KMime::Message::Ptr>(); - Akonadi::NoteUtils::NoteMessageWrapper wrapper(message); - wrapper.setText(text); - m_item.setPayload(wrapper.message()); - return *this; -} diff --git a/tests/units/akonadi/CMakeLists.txt b/tests/units/akonadi/CMakeLists.txt --- a/tests/units/akonadi/CMakeLists.txt +++ b/tests/units/akonadi/CMakeLists.txt @@ -10,14 +10,10 @@ akonadidatasourcerepositorytest akonadilivequeryhelperstest akonadilivequeryintegratortest - akonadinotequeriestest - akonadinoterepositorytest akonadiprojectqueriestest akonadiprojectrepositorytest akonadiserializertest akonadistoragesettingstest - akonaditagqueriestest - akonaditagrepositorytest akonaditaskqueriestest akonaditaskrepositorytest akonaditimestampattributetest diff --git a/tests/units/akonadi/akonadicachetest.cpp b/tests/units/akonadi/akonadicachetest.cpp --- a/tests/units/akonadi/akonadicachetest.cpp +++ b/tests/units/akonadi/akonadicachetest.cpp @@ -106,20 +106,6 @@ // THEN QCOMPARE(cache->collection(stuffCollection.id()).name(), QStringLiteral("stuff2")); - // WHEN - cache->setCollections(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks, - Akonadi::Collection::List() << noteTaskCollection << taskCollection << noteCollection); - - // THEN - QVERIFY(cache->isContentTypesPopulated(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks)); - QVERIFY(cache->isCollectionKnown(noteTaskCollection.id())); - QVERIFY(!cache->isCollectionPopulated(noteTaskCollection.id())); - QVERIFY(cache->items(noteTaskCollection).isEmpty()); - QCOMPARE(cache->collections(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks), - Akonadi::Collection::List() << noteTaskCollection << taskCollection << noteCollection); - QCOMPARE(cache->collection(noteTaskCollection.id()), noteTaskCollection); - QCOMPARE(cache->collection(noteTaskCollection.id()).name(), noteTaskCollection.name()); - // WHEN monitor->changeCollection(GenCollection(noteTaskCollection).withName("note+task2")); @@ -145,57 +131,27 @@ // THEN QCOMPARE(cache->collection(taskCollection.id()).name(), QStringLiteral("task2")); - - // WHEN - cache->setCollections(Akonadi::StorageInterface::Notes, - Akonadi::Collection::List() << noteTaskCollection << noteCollection); - - // THEN - QVERIFY(cache->isContentTypesPopulated(Akonadi::StorageInterface::Notes)); - QVERIFY(cache->isCollectionKnown(noteCollection.id())); - QVERIFY(!cache->isCollectionPopulated(noteCollection.id())); - QVERIFY(cache->items(noteCollection).isEmpty()); - QCOMPARE(cache->collections(Akonadi::StorageInterface::Notes), - Akonadi::Collection::List() << noteTaskCollection << noteCollection); - QCOMPARE(cache->collection(noteCollection.id()), noteCollection); - QCOMPARE(cache->collection(noteCollection.id()).name(), noteCollection.name()); } void shouldHandleCollectionAdds_data() { QTest::addColumn<Akonadi::StorageInterface::FetchContentTypes>("contentTypes"); QTest::addColumn<Akonadi::Collection>("collection"); QTest::addColumn<bool>("seen"); - const auto allContent = Akonadi::StorageInterface::FetchContentTypes(Akonadi::StorageInterface::AllContent); const auto taskContent = Akonadi::StorageInterface::FetchContentTypes(Akonadi::StorageInterface::Tasks); - const auto noteContent = Akonadi::StorageInterface::FetchContentTypes(Akonadi::StorageInterface::Notes); - const auto taskNoteContent = Akonadi::StorageInterface::FetchContentTypes(Akonadi::StorageInterface::Notes - | Akonadi::StorageInterface::Tasks); const auto none = Akonadi::Collection(GenCollection().withRootAsParent() .withId(2) .withName("collection")); const auto task = Akonadi::Collection(GenCollection(none).withTaskContent()); const auto note = Akonadi::Collection(GenCollection(none).withNoteContent()); const auto taskNote = Akonadi::Collection(GenCollection(none).withNoteContent().withTaskContent()); - QTest::newRow("all vs none") << allContent << none << true; - QTest::newRow("all vs task") << allContent << task << true; - QTest::newRow("all vs note") << allContent << note << true; - QTest::newRow("all vs taskNote") << allContent << taskNote << true; QTest::newRow("tasks vs none") << taskContent << none << false; QTest::newRow("tasks vs task") << taskContent << task << true; QTest::newRow("tasks vs note") << taskContent << note << false; QTest::newRow("tasks vs taskNote") << taskContent << taskNote << true; - QTest::newRow("notes vs none") << noteContent << none << false; - QTest::newRow("notes vs task") << noteContent << task << false; - QTest::newRow("notes vs note") << noteContent << note << true; - QTest::newRow("notes vs taskNote") << noteContent << taskNote << true; - QTest::newRow("notes+tasks vs none") << taskNoteContent << none << false; - QTest::newRow("notes+tasks vs task") << taskNoteContent << task << true; - QTest::newRow("notes+tasks vs note") << taskNoteContent << note << true; - QTest::newRow("notes+tasks vs taskNote") << taskNoteContent << taskNote << true; } void shouldHandleCollectionAdds() diff --git a/tests/units/akonadi/akonadicachingstoragetest.cpp b/tests/units/akonadi/akonadicachingstoragetest.cpp --- a/tests/units/akonadi/akonadicachingstoragetest.cpp +++ b/tests/units/akonadi/akonadicachingstoragetest.cpp @@ -88,70 +88,30 @@ << "57Note" << "58Note" << "59Note" << "60Stuff" << "61Stuff" << "62Stuff"; - const auto noteCollections = QStringList() << "42Task" << "44Note" - << "46Note" << "48Note" - << "50Stuff" << "52Note" - << "57Note" << "58Note" << "59Note"; - const auto taskCollections = QStringList() << "42Task" << "43Task" << "46Note" << "47Task" << "50Stuff" << "51Task" << "54Task" << "55Task" << "56Task"; - const auto noteTaskCollections = QStringList() << "42Task" << "43Task" << "44Note" - << "46Note" << "47Task" << "48Note" - << "50Stuff" << "51Task" << "52Note" - << "54Task" << "55Task" << "56Task" - << "57Note" << "58Note" << "59Note"; - QTest::newRow("rootRecursiveAll") << Akonadi::Collection::root() << Akonadi::StorageInterface::Recursive << int(Akonadi::StorageInterface::AllContent) << allCollections << allCollections; QTest::newRow("rootRecursiveTask") << Akonadi::Collection::root() << Akonadi::StorageInterface::Recursive << int(Akonadi::StorageInterface::Tasks) << onlyWithSuffix(taskCollections, "Task") << taskCollections; - QTest::newRow("rootRecursiveNote") << Akonadi::Collection::root() << Akonadi::StorageInterface::Recursive << int(Akonadi::StorageInterface::Notes) - << onlyWithSuffix(noteCollections, "Note") << noteCollections; - QTest::newRow("rootRecursiveNoteTask") << Akonadi::Collection::root() << Akonadi::StorageInterface::Recursive - << int(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks) - << onlyWithSuffixes(noteTaskCollections, {"Task", "Note"}) << noteTaskCollections; QTest::newRow("60RecursiveAll") << Akonadi::Collection(60) << Akonadi::StorageInterface::Recursive << int(Akonadi::StorageInterface::AllContent) << (QStringList() << "61Stuff" << "62Stuff") << allCollections; QTest::newRow("54RecursiveTask") << Akonadi::Collection(54) << Akonadi::StorageInterface::Recursive << int(Akonadi::StorageInterface::Tasks) << (QStringList() << "55Task" << "56Task") << taskCollections; - QTest::newRow("57RecursiveNote") << Akonadi::Collection(57) << Akonadi::StorageInterface::Recursive << int(Akonadi::StorageInterface::Notes) - << (QStringList() << "58Note" << "59Note") << noteCollections; - QTest::newRow("54RecursiveNoteTask") << Akonadi::Collection(54) << Akonadi::StorageInterface::Recursive - << int(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks) - << (QStringList() << "55Task" << "56Task") << noteTaskCollections; - QTest::newRow("57RecursiveNoteTask") << Akonadi::Collection(57) << Akonadi::StorageInterface::Recursive - << int(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks) - << (QStringList() << "58Note" << "59Note") << noteTaskCollections; QTest::newRow("60FirstLevelAll") << Akonadi::Collection(60) << Akonadi::StorageInterface::FirstLevel << int(Akonadi::StorageInterface::AllContent) << (QStringList() << "61Stuff") << allCollections; QTest::newRow("54FirstLevelTask") << Akonadi::Collection(54) << Akonadi::StorageInterface::FirstLevel << int(Akonadi::StorageInterface::Tasks) << (QStringList() << "55Task") << taskCollections; - QTest::newRow("57FirstLevelNote") << Akonadi::Collection(57) << Akonadi::StorageInterface::FirstLevel << int(Akonadi::StorageInterface::Notes) - << (QStringList() << "58Note") << noteCollections; - QTest::newRow("54FirstLevelNoteTask") << Akonadi::Collection(54) << Akonadi::StorageInterface::FirstLevel - << int(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks) - << (QStringList() << "55Task") << noteTaskCollections; - QTest::newRow("57FirstLevelNoteTask") << Akonadi::Collection(57) << Akonadi::StorageInterface::FirstLevel - << int(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks) - << (QStringList() << "58Note") << noteTaskCollections; QTest::newRow("60BaseAll") << Akonadi::Collection(60) << Akonadi::StorageInterface::Base << int(Akonadi::StorageInterface::AllContent) << (QStringList() << "60Stuff") << allCollections; QTest::newRow("54BaseTask") << Akonadi::Collection(54) << Akonadi::StorageInterface::Base << int(Akonadi::StorageInterface::Tasks) << (QStringList() << "54Task") << taskCollections; - QTest::newRow("57BaseNote") << Akonadi::Collection(57) << Akonadi::StorageInterface::Base << int(Akonadi::StorageInterface::Notes) - << (QStringList() << "57Note") << noteCollections; - QTest::newRow("54BaseNoteTask") << Akonadi::Collection(54) << Akonadi::StorageInterface::Base - << int(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks) - << (QStringList() << "54Task") << noteTaskCollections; - QTest::newRow("57BaseNoteTask") << Akonadi::Collection(57) << Akonadi::StorageInterface::Base - << int(Akonadi::StorageInterface::Notes|Akonadi::StorageInterface::Tasks) - << (QStringList() << "57Note") << noteTaskCollections; } void shouldCacheAllCollectionsPerFetchType() diff --git a/tests/units/akonadi/akonadidatasourcequeriestest.cpp b/tests/units/akonadi/akonadidatasourcequeriestest.cpp --- a/tests/units/akonadi/akonadidatasourcequeriestest.cpp +++ b/tests/units/akonadi/akonadidatasourcequeriestest.cpp @@ -587,24 +587,6 @@ QCOMPARE(result->data().size(), 0); } - void shouldLookInAllReportedForSelectedSources_data() - { - QTest::addColumn<int>("contentTypes"); - QTest::addColumn<QStringList>("expectedNames"); - - auto expectedNames = QStringList(); - expectedNames << QStringLiteral("42Task » 43Task") << QStringLiteral("44Note » 45Note"); - QTest::newRow("tasks and notes") << int(Akonadi::StorageInterface::Tasks | Akonadi::StorageInterface::Notes) << expectedNames; - - expectedNames.clear(); - expectedNames << QStringLiteral("42Task » 43Task"); - QTest::newRow("tasks") << int(Akonadi::StorageInterface::Tasks) << expectedNames; - - expectedNames.clear(); - expectedNames << QStringLiteral("44Note » 45Note"); - QTest::newRow("notes") << int(Akonadi::StorageInterface::Notes) << expectedNames; - } - void shouldLookInAllReportedForSelectedSources() { // GIVEN @@ -617,8 +599,7 @@ data.createCollection(GenCollection().withId(45).withName(QStringLiteral("45Note")).withParent(44).withNoteContent().selected(true)); // WHEN - QFETCH(int, contentTypes); - QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::FetchContentTypes(contentTypes), + QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Tasks, Akonadi::StorageInterface::Ptr(data.createStorage()), Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer), Akonadi::MonitorInterface::Ptr(data.createMonitor()))); @@ -638,17 +619,15 @@ [] (const Domain::DataSource::Ptr &source) { return source->name(); }); actualNames.sort(); - QFETCH(QStringList, expectedNames); - expectedNames.sort(); - QCOMPARE(actualNames, expectedNames); + QCOMPARE(actualNames, QStringList() << QStringLiteral("42Task » 43Task")); } void shouldReactToCollectionAddsForSelectedSources() { // GIVEN AkonadiFakeData data; - QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Tasks | Akonadi::StorageInterface::Notes, + QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Tasks, Akonadi::StorageInterface::Ptr(data.createStorage()), Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer), Akonadi::MonitorInterface::Ptr(data.createMonitor()))); @@ -664,9 +643,8 @@ data.createCollection(GenCollection().withId(45).withName(QStringLiteral("45Note")).withParent(44).withNoteContent().selected(true)); // THEN - QCOMPARE(result->data().size(), 2); + QCOMPARE(result->data().size(), 1); QCOMPARE(result->data().at(0)->name(), QStringLiteral("42Task » 43Task")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("44Note » 45Note")); } void shouldReactToCollectionRemovesForSelectedSources() @@ -680,14 +658,14 @@ data.createCollection(GenCollection().withId(44).withName(QStringLiteral("44Note")).withRootAsParent().withNoteContent().selected(false)); data.createCollection(GenCollection().withId(45).withName(QStringLiteral("45Note")).withParent(44).withNoteContent().selected(true)); - QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Tasks | Akonadi::StorageInterface::Notes, + QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Tasks, Akonadi::StorageInterface::Ptr(data.createStorage()), Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer), Akonadi::MonitorInterface::Ptr(data.createMonitor()))); Domain::QueryResult<Domain::DataSource::Ptr>::Ptr result = queries->findAllSelected(); TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 2); + QCOMPARE(result->data().size(), 1); // WHEN data.removeCollection(Akonadi::Collection(43)); @@ -708,7 +686,7 @@ data.createCollection(GenCollection().withId(44).withName(QStringLiteral("44Note")).withRootAsParent().withNoteContent().selected(false)); data.createCollection(GenCollection().withId(45).withName(QStringLiteral("45Note")).withParent(44).withNoteContent().selected(true)); - QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Tasks | Akonadi::StorageInterface::Notes, + QScopedPointer<Domain::DataSourceQueries> queries(new Akonadi::DataSourceQueries(Akonadi::StorageInterface::Tasks, Akonadi::StorageInterface::Ptr(data.createStorage()), Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer), Akonadi::MonitorInterface::Ptr(data.createMonitor()))); @@ -720,17 +698,16 @@ replaceHandlerCalled = true; }); TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 2); + QCOMPARE(result->data().size(), 1); // WHEN data.modifyCollection(GenCollection(data.collection(43)).withName(QStringLiteral("43TaskBis"))); data.modifyCollection(GenCollection(data.collection(45)).withName(QStringLiteral("45NoteBis"))); TestHelpers::waitForEmptyJobQueue(); // THEN - QCOMPARE(result->data().size(), 2); + QCOMPARE(result->data().size(), 1); QCOMPARE(result->data().at(0)->name(), QStringLiteral("42Task » 43TaskBis")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("44Note » 45NoteBis")); QVERIFY(replaceHandlerCalled); } diff --git a/tests/units/akonadi/akonadilivequeryhelperstest.cpp b/tests/units/akonadi/akonadilivequeryhelperstest.cpp --- a/tests/units/akonadi/akonadilivequeryhelperstest.cpp +++ b/tests/units/akonadi/akonadilivequeryhelperstest.cpp @@ -35,7 +35,6 @@ #include "testlib/akonadifakedata.h" #include "testlib/gencollection.h" -#include "testlib/gennote.h" #include "testlib/gentag.h" #include "testlib/gentodo.h" #include "testlib/testhelpers.h" @@ -292,16 +291,6 @@ QCOMPARE(result, expected); } - void shouldFetchItemsByContentTypes_data() - { - QTest::addColumn<Akonadi::StorageInterface::FetchContentTypes>("contentTypes"); - - QTest::newRow("task collections only") << Akonadi::StorageInterface::FetchContentTypes(Akonadi::StorageInterface::Tasks); - QTest::newRow("note collections only") << Akonadi::StorageInterface::FetchContentTypes(Akonadi::StorageInterface::Notes); - QTest::newRow("task and note collections only") << (Akonadi::StorageInterface::Tasks | Akonadi::StorageInterface::Notes); - QTest::newRow("all collections") << Akonadi::StorageInterface::FetchContentTypes(Akonadi::StorageInterface::AllContent); - } - void shouldFetchItemsByContentTypes() { // GIVEN @@ -321,11 +310,11 @@ // One task in the first collection data.createItem(GenTodo().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - // Two items (tasks or notes) in all the other collections + // Two tasks in all the other collections data.createItem(GenTodo().withId(43).withParent(43).withTitle(QStringLiteral("43"))); data.createItem(GenTodo().withId(44).withParent(43).withTitle(QStringLiteral("44"))); - data.createItem(GenNote().withId(45).withParent(44).withTitle(QStringLiteral("45"))); - data.createItem(GenNote().withId(46).withParent(44).withTitle(QStringLiteral("46"))); + data.createItem(GenTodo().withId(45).withParent(44).withTitle(QStringLiteral("45"))); + data.createItem(GenTodo().withId(46).withParent(44).withTitle(QStringLiteral("46"))); data.createItem(GenTodo().withId(47).withParent(45).withTitle(QStringLiteral("47"))); data.createItem(GenTodo().withId(48).withParent(45).withTitle(QStringLiteral("48"))); @@ -336,8 +325,7 @@ }; // WHEN - QFETCH(Akonadi::StorageInterface::FetchContentTypes, contentTypes); - auto fetch = helpers->fetchItems(contentTypes); + auto fetch = helpers->fetchItems(Akonadi::StorageInterface::Tasks); fetch(add); TestHelpers::waitForEmptyJobQueue(); @@ -349,15 +337,7 @@ // THEN auto expected = QStringList(); - - if ((contentTypes & Akonadi::StorageInterface::Tasks) || contentTypes == Akonadi::StorageInterface::AllContent) { - expected << QStringLiteral("43") << QStringLiteral("44") << QStringLiteral("47") << QStringLiteral("48"); - } - - if ((contentTypes & Akonadi::StorageInterface::Notes) || contentTypes == Akonadi::StorageInterface::AllContent) { - expected << QStringLiteral("45") << QStringLiteral("46"); - } - + expected << QStringLiteral("43") << QStringLiteral("44") << QStringLiteral("47") << QStringLiteral("48"); expected.sort(); QCOMPARE(result, expected); @@ -554,10 +534,10 @@ data.createItem(GenTodo().withId(43).withParent(42).withTitle(QStringLiteral("43"))); data.createItem(GenTodo().withId(44).withParent(42).withTitle(QStringLiteral("44"))); data.createItem(GenTodo().withId(45).withParent(42).withTitle(QStringLiteral("45"))); - data.createItem(GenNote().withId(46).withParent(43).withTitle(QStringLiteral("46"))); - data.createItem(GenNote().withId(47).withParent(43).withTitle(QStringLiteral("47"))); - data.createItem(GenNote().withId(48).withParent(43).withTitle(QStringLiteral("48"))); - data.createItem(GenNote().withId(49).withParent(43).withTitle(QStringLiteral("49"))); + data.createItem(GenTodo().withId(46).withParent(43).withTitle(QStringLiteral("46"))); + data.createItem(GenTodo().withId(47).withParent(43).withTitle(QStringLiteral("47"))); + data.createItem(GenTodo().withId(48).withParent(43).withTitle(QStringLiteral("48"))); + data.createItem(GenTodo().withId(49).withParent(43).withTitle(QStringLiteral("49"))); // The list which will be filled by the fetch function auto items = Akonadi::Item::List(); diff --git a/tests/units/akonadi/akonadilivequeryintegratortest.cpp b/tests/units/akonadi/akonadilivequeryintegratortest.cpp --- a/tests/units/akonadi/akonadilivequeryintegratortest.cpp +++ b/tests/units/akonadi/akonadilivequeryintegratortest.cpp @@ -37,7 +37,6 @@ #include "testlib/akonadifakedata.h" #include "testlib/gencollection.h" -#include "testlib/gennote.h" #include "testlib/gentag.h" #include "testlib/gentodo.h" #include "testlib/testhelpers.h" @@ -142,8 +141,8 @@ // Three artifacts in the collection, one not matching the predicate data.createItem(GenTodo().withId(42).withParent(42).withTitle(QStringLiteral("42-in"))); - data.createItem(GenNote().withId(43).withParent(42).withTitle(QStringLiteral("43-in"))); - data.createItem(GenNote().withId(44).withParent(42).withTitle(QStringLiteral("44-ex"))); + data.createItem(GenTodo().withId(43).withParent(42).withTitle(QStringLiteral("43-in"))); + data.createItem(GenTodo().withId(44).withParent(42).withTitle(QStringLiteral("44-ex"))); // Couple of projects in the collection which should not appear or create trouble data.createItem(GenTodo().withId(40).withParent(42).asProject().withTitle(QStringLiteral("40"))); @@ -204,7 +203,7 @@ // Reacts to change (which adds) // WHEN - data.modifyItem(GenNote(data.item(44)).withTitle(QStringLiteral("44-in"))); + data.modifyItem(GenTodo(data.item(44)).withTitle(QStringLiteral("44-in"))); // THEN QCOMPARE(result->data().size(), 3); @@ -214,7 +213,7 @@ // Reacts to change (which removes) // WHEN - data.modifyItem(GenNote(data.item(44)).withTitle(QStringLiteral("44-ex"))); + data.modifyItem(GenTodo(data.item(44)).withTitle(QStringLiteral("44-ex"))); // THEN QCOMPARE(result->data().size(), 2); @@ -251,9 +250,9 @@ // One top level collection data.createCollection(GenCollection().withId(42).withRootAsParent().withName(QStringLiteral("42"))); - // One task and one note which show in one query and not the other + // Two tasks: one which shows in one query and not the other data.createItem(GenTodo().withId(42).withParent(42).withTitle(QStringLiteral("42-in"))); - data.createItem(GenNote().withId(43).withParent(42).withTitle(QStringLiteral("43-in"))); + data.createItem(GenTodo().withId(43).withParent(42).withTitle(QStringLiteral("43-in"))); // Couple of projects in the collection which should not appear or create trouble data.createItem(GenTodo().withId(39).withParent(42).asProject().withTitle(QStringLiteral("39"))); @@ -286,7 +285,7 @@ // WHEN data.modifyItem(GenTodo(data.item(42)).withTitle(QStringLiteral("42-ex"))); - data.modifyItem(GenNote(data.item(43)).withTitle(QStringLiteral("43-ex"))); + data.modifyItem(GenTodo(data.item(43)).withTitle(QStringLiteral("43-ex"))); // THEN QCOMPARE(inResult->data().size(), 0); @@ -654,209 +653,6 @@ - void shouldBindNoteQueries() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withName(QStringLiteral("42"))); - - // Three notes in the collection, one not matching the predicate - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42-in"))); - data.createItem(GenNote().withId(43).withParent(42).withTitle(QStringLiteral("43-in"))); - data.createItem(GenNote().withId(44).withParent(42).withTitle(QStringLiteral("44-ex"))); - - // Couple of tasks in the collection which should not appear or create trouble - data.createItem(GenTodo().withId(40).withParent(42).withTitle(QStringLiteral("40"))); - data.createItem(GenTodo().withId(41).withParent(42).withTitle(QStringLiteral("41-in"))); - - auto integrator = createIntegrator(data); - auto storage = createStorage(data); - - auto query = Domain::LiveQueryOutput<Domain::Note::Ptr>::Ptr(); - auto fetch = fetchItemsInAllCollectionsFunction(storage); - auto predicate = [] (const Akonadi::Item &item) { - return titleFromItem(item).endsWith(QLatin1String("-in")); - }; - - // Initial listing - // WHEN - integrator->bind("note1", query, fetch, predicate); - auto result = query->result(); - result->data(); - integrator->bind("note2", query, fetch, predicate); - result = query->result(); // Should not cause any problem or wrong data - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42-in")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43-in")); - - // Reacts to add - // WHEN - data.createItem(GenNote().withId(45).withParent(42).withTitle(QStringLiteral("45-in"))); - - // THEN - QCOMPARE(result->data().size(), 3); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42-in")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43-in")); - QCOMPARE(result->data().at(2)->title(), QStringLiteral("45-in")); - - // Reacts to remove - // WHEN - data.removeItem(Akonadi::Item(45)); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42-in")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43-in")); - - // Reacts to change - // WHEN - data.modifyItem(GenNote(data.item(42)).withTitle(QStringLiteral("42-bis-in"))); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42-bis-in")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43-in")); - - // Reacts to change (which adds) - // WHEN - data.modifyItem(GenNote(data.item(44)).withTitle(QStringLiteral("44-in"))); - - // THEN - QCOMPARE(result->data().size(), 3); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42-bis-in")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43-in")); - QCOMPARE(result->data().at(2)->title(), QStringLiteral("44-in")); - - // Reacts to change (which removes) - // WHEN - data.modifyItem(GenNote(data.item(44)).withTitle(QStringLiteral("44-ex"))); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42-bis-in")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43-in")); - - // Don't keep a reference on any result - result.clear(); - - // The bug we're trying to hit here is the following: - // - when bind is called the first time a provider is created internally - // - result is deleted at the end of the loop, no one holds the provider with - // a strong reference anymore so it is deleted as well - // - when bind is called the second time, there's a risk of a dangling - // pointer if the recycling of providers is wrongly implemented which can lead - // to a crash, if it is properly done no crash will occur - for (int i = 0; i < 2; i++) { - // WHEN * 2 - integrator->bind("noteN", query, fetch, predicate); - auto result = query->result(); - - // THEN * 2 - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - QVERIFY(!result->data().isEmpty()); - } - } - - void shouldMoveNotesBetweenQueries() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withName(QStringLiteral("42"))); - - // One note which shows in one query and not the other - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42-in"))); - - // Couple of tasks in the collection which should not appear or create trouble - data.createItem(GenTodo().withId(39).withParent(42).withTitle(QStringLiteral("39"))); - data.createItem(GenTodo().withId(40).withParent(42).withTitle(QStringLiteral("40-ex"))); - data.createItem(GenTodo().withId(41).withParent(42).withTitle(QStringLiteral("41-in"))); - - auto integrator = createIntegrator(data); - auto storage = createStorage(data); - - auto inQuery = Domain::LiveQueryOutput<Domain::Note::Ptr>::Ptr(); - auto exQuery = Domain::LiveQueryOutput<Domain::Note::Ptr>::Ptr(); - auto fetch = fetchItemsInAllCollectionsFunction(storage); - auto inPredicate = [] (const Akonadi::Item &item) { - return titleFromItem(item).endsWith(QLatin1String("-in")); - }; - auto exPredicate = [] (const Akonadi::Item &item) { - return titleFromItem(item).endsWith(QLatin1String("-ex")); - }; - - integrator->bind("note-in", inQuery, fetch, inPredicate); - auto inResult = inQuery->result(); - - integrator->bind("note-ex", exQuery, fetch, exPredicate); - auto exResult = exQuery->result(); - - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(inResult->data().size(), 1); - QCOMPARE(exResult->data().size(), 0); - - // WHEN - data.modifyItem(GenNote(data.item(42)).withTitle(QStringLiteral("42-ex"))); - - // THEN - QCOMPARE(inResult->data().size(), 0); - QCOMPARE(exResult->data().size(), 1); - } - - void shouldReactToCollectionSelectionChangesForNoteQueries() - { - // GIVEN - AkonadiFakeData data; - - // Two top level collections - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - data.createCollection(GenCollection().withId(43).withRootAsParent().withNoteContent()); - - // One note in each collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - data.createItem(GenNote().withId(43).withParent(43).withTitle(QStringLiteral("43"))); - - // Couple of tasks in the collections which should not appear or create trouble - data.createItem(GenTodo().withId(40).withParent(42).withTitle(QStringLiteral("40"))); - data.createItem(GenTodo().withId(41).withParent(43).withTitle(QStringLiteral("41"))); - - auto integrator = createIntegrator(data); - auto storage = createStorage(data); - auto serializer = createSerializer(); - - auto query = Domain::LiveQueryOutput<Domain::Note::Ptr>::Ptr(); - auto fetch = fetchItemsInSelectedCollectionsFunction(storage, serializer); - auto predicate = [] (const Akonadi::Item &) { - return true; - }; - - integrator->bind("note query", query, fetch, predicate); - auto result = query->result(); - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 2); - - // WHEN - data.modifyCollection(GenCollection(data.collection(43)).selected(false)); - TestHelpers::waitForEmptyJobQueue(); - - // THEN - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } - - - - void shouldBindProjectQueries() { // GIVEN @@ -1058,173 +854,6 @@ } - void shouldBindTagQueries() - { - // GIVEN - AkonadiFakeData data; - - // Three plain tags, one not matching the predicate - data.createTag(GenTag().withId(42).asPlain().withName(QStringLiteral("42-in"))); - data.createTag(GenTag().withId(43).asPlain().withName(QStringLiteral("43-in"))); - data.createTag(GenTag().withId(44).asPlain().withName(QStringLiteral("44-ex"))); - - // Couple of context tags which should not appear or create trouble - data.createTag(GenTag().withId(40).asContext().withName(QStringLiteral("40"))); - data.createTag(GenTag().withId(41).asContext().withName(QStringLiteral("41-in"))); - - auto integrator = createIntegrator(data); - auto storage = createStorage(data); - - auto query = Domain::LiveQueryOutput<Domain::Tag::Ptr>::Ptr(); - auto fetch = [storage] (const Domain::LiveQueryInput<Akonadi::Tag>::AddFunction &add) { - auto job = storage->fetchTags(); - Utils::JobHandler::install(job->kjob(), [add, job] { - foreach (const auto &tag, job->tags()) { - add(tag); - } - }); - }; - auto predicate = [] (const Akonadi::Tag &tag) { - return tag.name().endsWith(QLatin1String("-in")); - }; - - // Initial listing - // WHEN - integrator->bind("tag1", query, fetch, predicate); - auto result = query->result(); - result->data(); - integrator->bind("tag2", query, fetch, predicate); - result = query->result(); // Should not cause any problem or wrong data - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42-in")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43-in")); - - // Reacts to add - // WHEN - data.createTag(GenTag().withId(45).asPlain().withName(QStringLiteral("45-in"))); - - // THEN - QCOMPARE(result->data().size(), 3); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42-in")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43-in")); - QCOMPARE(result->data().at(2)->name(), QStringLiteral("45-in")); - - // Reacts to remove - // WHEN - data.removeTag(Akonadi::Tag(45)); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42-in")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43-in")); - - // Reacts to change - // WHEN - data.modifyTag(GenTag(data.tag(42)).withName(QStringLiteral("42-bis-in"))); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42-bis-in")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43-in")); - - // Reacts to change (which adds) - // WHEN - data.modifyTag(GenTag(data.tag(44)).withName(QStringLiteral("44-in"))); - - // THEN - QCOMPARE(result->data().size(), 3); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42-bis-in")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43-in")); - QCOMPARE(result->data().at(2)->name(), QStringLiteral("44-in")); - - // Reacts to change (which removes) - // WHEN - data.modifyTag(GenTag(data.tag(44)).withName(QStringLiteral("44-ex"))); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42-bis-in")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43-in")); - - // Don't keep a reference on any result - result.clear(); - - // The bug we're trying to hit here is the following: - // - when bind is called the first time a provider is created internally - // - result is deleted at the end of the loop, no one holds the provider with - // a strong reference anymore so it is deleted as well - // - when bind is called the second time, there's a risk of a dangling - // pointer if the recycling of providers is wrongly implemented which can lead - // to a crash, if it is properly done no crash will occur - for (int i = 0; i < 2; i++) { - // WHEN * 2 - integrator->bind("tagN", query, fetch, predicate); - auto result = query->result(); - - // THEN * 2 - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - QVERIFY(!result->data().isEmpty()); - } - } - - void shouldMoveTagBetweenQueries() - { - // GIVEN - AkonadiFakeData data; - - // One plain tag which shows in one query not the other - data.createTag(GenTag().withId(42).asPlain().withName(QStringLiteral("42-in"))); - - // Couple of context tags which should not appear or create trouble - data.createTag(GenTag().withId(39).asContext().withName(QStringLiteral("39"))); - data.createTag(GenTag().withId(40).asContext().withName(QStringLiteral("40-ex"))); - data.createTag(GenTag().withId(41).asContext().withName(QStringLiteral("41-in"))); - - auto integrator = createIntegrator(data); - auto storage = createStorage(data); - - auto inQuery = Domain::LiveQueryOutput<Domain::Tag::Ptr>::Ptr(); - auto exQuery = Domain::LiveQueryOutput<Domain::Tag::Ptr>::Ptr(); - auto fetch = [storage] (const Domain::LiveQueryInput<Akonadi::Tag>::AddFunction &add) { - auto job = storage->fetchTags(); - Utils::JobHandler::install(job->kjob(), [add, job] { - foreach (const auto &tag, job->tags()) { - add(tag); - } - }); - }; - auto inPredicate = [] (const Akonadi::Tag &tag) { - return tag.name().endsWith(QLatin1String("-in")); - }; - auto exPredicate = [] (const Akonadi::Tag &tag) { - return tag.name().endsWith(QLatin1String("-ex")); - }; - - integrator->bind("tag-in", inQuery, fetch, inPredicate); - auto inResult = inQuery->result(); - - integrator->bind("tag-ex", exQuery, fetch, exPredicate); - auto exResult = exQuery->result(); - - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(inResult->data().size(), 1); - QCOMPARE(exResult->data().size(), 0); - - // WHEN - data.modifyTag(GenTag(data.tag(42)).withName(QStringLiteral("42-ex"))); - - // THEN - QCOMPARE(inResult->data().size(), 0); - QCOMPARE(exResult->data().size(), 1); - } - @@ -1241,11 +870,9 @@ data.createItem(GenTodo().withId(43).withParent(42).withTitle(QStringLiteral("43-in"))); data.createItem(GenTodo().withId(44).withParent(42).withTitle(QStringLiteral("44-ex"))); - // Couple of notes and projects in the collection which should not appear or create trouble + // Couple of projects in the collection which should not appear or create trouble data.createItem(GenTodo().withId(38).withParent(42).asProject().withTitle(QStringLiteral("38"))); data.createItem(GenTodo().withId(39).withParent(42).asProject().withTitle(QStringLiteral("39-in"))); - data.createItem(GenNote().withId(40).withParent(42).withTitle(QStringLiteral("40"))); - data.createItem(GenNote().withId(41).withParent(42).withTitle(QStringLiteral("41-in"))); auto integrator = createIntegrator(data); auto storage = createStorage(data); @@ -1352,11 +979,6 @@ // One task which shows in one query and not the other data.createItem(GenTodo().withId(42).withParent(42).withTitle(QStringLiteral("42-in"))); - // Couple of notes in the collection which should not appear or create trouble - data.createItem(GenNote().withId(39).withParent(42).withTitle(QStringLiteral("39"))); - data.createItem(GenNote().withId(40).withParent(42).withTitle(QStringLiteral("40-ex"))); - data.createItem(GenNote().withId(41).withParent(42).withTitle(QStringLiteral("41-in"))); - auto integrator = createIntegrator(data); auto storage = createStorage(data); diff --git a/tests/units/akonadi/akonadinotequeriestest.cpp b/tests/units/akonadi/akonadinotequeriestest.cpp deleted file mode 100644 --- a/tests/units/akonadi/akonadinotequeriestest.cpp +++ /dev/null @@ -1,487 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - Copyright 2014 Remi Benoit <r3m1.benoit@gmail.com> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include "akonadi/akonadinotequeries.h" -#include "akonadi/akonadiserializer.h" - -#include "testlib/akonadifakedata.h" -#include "testlib/gencollection.h" -#include "testlib/gennote.h" -#include "testlib/gentag.h" -#include "testlib/gentodo.h" -#include "testlib/testhelpers.h" - -using namespace Testlib; - -class AkonadiNoteQueriesTest : public QObject -{ - Q_OBJECT -private slots: - void shouldLookInAllReportedForAllNotes() - { - // GIVEN - AkonadiFakeData data; - - // Two top level collections - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - data.createCollection(GenCollection().withId(43).withRootAsParent().withNoteContent()); - - // One note in the first collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - - // Two notes in the second collection - data.createItem(GenNote().withId(43).withParent(43).withTitle(QStringLiteral("43"))); - data.createItem(GenNote().withId(44).withParent(43).withTitle(QStringLiteral("44"))); - - // WHEN - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - result->data(); - result = queries->findAll(); // Should not cause any problem or wrong data - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 3); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43")); - QCOMPARE(result->data().at(2)->title(), QStringLiteral("44")); - } - - void shouldIgnoreItemsWhichAreNotNotes() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // Two notes in the collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - auto item = Akonadi::Item(43); - item.setPayloadFromData("FooBar"); - item.setParentCollection(Akonadi::Collection(42)); - data.createItem(item); - - // WHEN - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } - - void shouldReactToItemAddsForNotesOnly() - { - // GIVEN - AkonadiFakeData data; - - // One empty collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - TestHelpers::waitForEmptyJobQueue(); - QVERIFY(result->data().isEmpty()); - - // WHEN - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - auto item = Akonadi::Item(43); - item.setPayloadFromData("FooBar"); - item.setParentCollection(Akonadi::Collection(42)); - data.createItem(item); - - // THEN - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().first()->title(), QStringLiteral("42")); - } - - void shouldReactToItemRemovesForAllNotes() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // Three notes in the collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - data.createItem(GenNote().withId(43).withParent(42).withTitle(QStringLiteral("43"))); - data.createItem(GenNote().withId(44).withParent(42).withTitle(QStringLiteral("44"))); - - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 3); - - // WHEN - data.removeItem(Akonadi::Item(43)); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("44")); - } - - void shouldReactToItemChangesForAllNotes() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // Three Note in the collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - data.createItem(GenNote().withId(43).withParent(42).withTitle(QStringLiteral("43"))); - data.createItem(GenNote().withId(44).withParent(42).withTitle(QStringLiteral("44"))); - - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - Domain::QueryResult<Domain::Note::Ptr>::Ptr result = queries->findAll(); - // Even though the pointer didn't change it's convenient to user if we call - // the replace handlers - bool replaceHandlerCalled = false; - result->addPostReplaceHandler([&replaceHandlerCalled](const Domain::Note::Ptr &, int) { - replaceHandlerCalled = true; - }); - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 3); - - // WHEN - data.modifyItem(GenNote(data.item(43)).withTitle(QStringLiteral("43bis"))); - - // THEN - QCOMPARE(result->data().size(), 3); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43bis")); - QCOMPARE(result->data().at(2)->title(), QStringLiteral("44")); - QVERIFY(replaceHandlerCalled); - } - - void shouldLookInAllSelectedCollectionsForInboxNotes() - { - // GIVEN - AkonadiFakeData data; - - // Three top level collections - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - data.createCollection(GenCollection().withId(43).withRootAsParent().withNoteContent()); - data.createCollection(GenCollection().withId(44).withRootAsParent().withNoteContent().selected(false)); - - // One note in the first collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - - // Two notes in the second collection - data.createItem(GenNote().withId(43).withParent(43).withTitle(QStringLiteral("43"))); - data.createItem(GenNote().withId(44).withParent(43).withTitle(QStringLiteral("44"))); - - // One note in the third collection - data.createItem(GenNote().withId(45).withParent(44).withTitle(QStringLiteral("45"))); - - // WHEN - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findInbox(); - result->data(); - result = queries->findInbox(); // Should not cause any problem or wrong data - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 3); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43")); - QCOMPARE(result->data().at(2)->title(), QStringLiteral("44")); - } - - void shouldIgnoreItemsWhichAreNotNotesInInbox() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // Three items in the collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - // One of them is a task - data.createItem(GenTodo().withId(43).withParent(42).withTitle(QStringLiteral("43"))); - // One of them is not a task or a note - auto item = Akonadi::Item(44); - item.setPayloadFromData("FooBar"); - item.setParentCollection(Akonadi::Collection(42)); - data.createItem(item); - - // WHEN - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findInbox(); - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } - - void shouldNotHaveNotesWithTagsInInbox_data() - { - QTest::addColumn<bool>("hasTags"); - QTest::addColumn<bool>("isExpectedInInbox"); - - QTest::newRow("note with no tags") << false << true; - QTest::newRow("note with tags") << true << false; - } - - void shouldNotHaveNotesWithTagsInInbox() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // One plain tag - data.createTag(GenTag().withId(42).withName(QStringLiteral("tag-42")).asPlain()); - - // One item in the collection - QFETCH(bool, hasTags); - auto tagIds = QList<Akonadi::Tag::Id>(); - if (hasTags) tagIds << 42; - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42")).withTags(tagIds)); - - // WHEN - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findInbox(); - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QFETCH(bool, isExpectedInInbox); - if (isExpectedInInbox) { - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } else { - QVERIFY(result->data().isEmpty()); - } - } - - void shouldReactToItemAddsForInbox_data() - { - QTest::addColumn<bool>("reactionExpected"); - QTest::addColumn<bool>("isTodo"); - QTest::addColumn<bool>("hasTags"); - - QTest::newRow("task with no tag") << false << true << false; - QTest::newRow("task with tag") << false << true << true; - - QTest::newRow("note which should be in inbox") << true << false << false; - QTest::newRow("note with tag") << false << false << true; - } - - void shouldReactToItemAddsForInbox() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withTaskContent().withNoteContent()); - - // One plain tag - data.createTag(GenTag().withId(42).withName(QStringLiteral("tag-42")).asPlain()); - - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findInbox(); - TestHelpers::waitForEmptyJobQueue(); - QVERIFY(result->data().isEmpty()); - - // WHEN - QFETCH(bool, hasTags); - auto tagIds = QList<Akonadi::Tag::Id>(); - if (hasTags) tagIds << 42; - - QFETCH(bool, isTodo); - if (isTodo) { - data.createItem(GenTodo().withId(42).withParent(42).withTitle(QStringLiteral("42")).withTags(tagIds)); - } else { - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42")).withTags(tagIds)); - } - - // THEN - QFETCH(bool, reactionExpected); - if (reactionExpected) { - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } else { - QVERIFY(result->data().isEmpty()); - } - } - - void shouldReactToItemRemovesForInbox() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // One item in the collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - - // WHEN - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findInbox(); - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().first()->title(), QStringLiteral("42")); - - // WHEN - data.removeItem(Akonadi::Item(42)); - - // THEN - QVERIFY(result->data().isEmpty()); - } - - void shouldReactToItemChangesForInbox_data() - { - QTest::addColumn<bool>("hasTagsBefore"); - QTest::addColumn<bool>("hasTagsAfter"); - QTest::addColumn<bool>("inListAfterChange"); - - QTest::newRow("note appears in inbox") << true << false << true; - QTest::newRow("note disappears from inbox") << false << true << false; - } - - void shouldReactToItemChangesForInbox() - { - // GIVEN - AkonadiFakeData data; - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // One plain tag - data.createTag(GenTag().withId(42).withName(QStringLiteral("tag-42")).asPlain()); - - // Note data - QFETCH(bool, hasTagsBefore); - - auto tagIds = QList<Akonadi::Tag::Id>(); - if (hasTagsBefore) tagIds << 42; - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42")).withTags(tagIds)); - - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findInbox(); - TestHelpers::waitForEmptyJobQueue(); - - QFETCH(bool, inListAfterChange); - - if (inListAfterChange) { - QVERIFY(result->data().isEmpty()); - } else { - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } - - // WHEN - QFETCH(bool, hasTagsAfter); - - tagIds.clear(); - if (hasTagsAfter) tagIds << 42; - data.modifyItem(GenNote(data.item(42)).withTags(tagIds)); - - // THEN - if (inListAfterChange) { - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } else { - QVERIFY(result->data().isEmpty()); - } - } - - void shouldReactToCollectionSelectionChangesForInbox() - { - // GIVEN - AkonadiFakeData data; - - // Two top level collections - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - data.createCollection(GenCollection().withId(43).withRootAsParent().withNoteContent()); - - // One note in each collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - data.createItem(GenNote().withId(43).withParent(43).withTitle(QStringLiteral("43"))); - - QScopedPointer<Domain::NoteQueries> queries(new Akonadi::NoteQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findInbox(); - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43")); - - // WHEN - data.modifyCollection(GenCollection(data.collection(43)).selected(false)); - TestHelpers::waitForEmptyJobQueue(); - - // THEN - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } -}; - -ZANSHIN_TEST_MAIN(AkonadiNoteQueriesTest) - -#include "akonadinotequeriestest.moc" diff --git a/tests/units/akonadi/akonadinoterepositorytest.cpp b/tests/units/akonadi/akonadinoterepositorytest.cpp deleted file mode 100644 --- a/tests/units/akonadi/akonadinoterepositorytest.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include <AkonadiCore/Collection> -#include <AkonadiCore/Item> - -#include "utils/mockobject.h" - -#include "testlib/akonadifakejobs.h" -#include "testlib/akonadifakemonitor.h" - -#include "akonadi/akonadinoterepository.h" -#include "akonadi/akonadiserializerinterface.h" -#include "akonadi/akonadistorageinterface.h" - -using namespace mockitopp; - -Q_DECLARE_METATYPE(Testlib::AkonadiFakeItemFetchJob*) - -class AkonadiNoteRepositoryTest : public QObject -{ - Q_OBJECT -private slots: - void shouldCreateNewItems() - { - // GIVEN - - // A default collection for saving - auto col = Akonadi::Collection(42); - - // A note and its corresponding item not existing in storage yet - auto item = Akonadi::Item(); - auto note = Domain::Note::Ptr::create(); - - // A mock create job - auto itemCreateJob = new FakeJob(this); - - // Storage mock returning the create job - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().thenReturn(col); - storageMock(&Akonadi::StorageInterface::createItem).when(item, col) - .thenReturn(itemCreateJob); - - // Serializer mock returning the item for the note - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).thenReturn(item); - - // WHEN - QScopedPointer<Akonadi::NoteRepository> repository(new Akonadi::NoteRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->create(note)->exec(); - - // THEN - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::createItem).when(item, col).exactly(1)); - } - - void shouldCreateNewItemsInFirstWritableCollectionIfNothingInSettings() - { - // GIVEN - - // A few collections - auto col1 = Akonadi::Collection(42); - col1.setRights(Akonadi::Collection::ReadOnly); - auto col2 = Akonadi::Collection(43); - col2.setRights(Akonadi::Collection::CanCreateItem); - auto col3 = Akonadi::Collection(44); - col3.setRights(Akonadi::Collection::CanCreateItem - | Akonadi::Collection::CanChangeItem - | Akonadi::Collection::CanDeleteItem); - auto collectionFetchJob = new Testlib::AkonadiFakeCollectionFetchJob; - collectionFetchJob->setCollections(Akonadi::Collection::List() << col1 << col2 << col3); - - // A note and its corresponding item not existing in storage yet - auto item = Akonadi::Item(); - auto note = Domain::Note::Ptr::create(); - - // A mock create job - auto itemCreateJob = new FakeJob(this); - - // Storage mock returning the create job and with no default collection - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().thenReturn(Akonadi::Collection()); - storageMock(&Akonadi::StorageInterface::fetchCollections).when(Akonadi::Collection::root(), - Akonadi::StorageInterface::Recursive, - Akonadi::StorageInterface::Notes) - .thenReturn(collectionFetchJob); - storageMock(&Akonadi::StorageInterface::createItem).when(item, col3) - .thenReturn(itemCreateJob); - - // Serializer mock returning the item for the note - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).thenReturn(item); - - // WHEN - QScopedPointer<Akonadi::NoteRepository> repository(new Akonadi::NoteRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->create(note)->exec(); - - // THEN - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::createItem).when(item, col3).exactly(1)); - } - - void shouldEmitErrorIfNoFallbackCollectionIsFound() - { - // GIVEN - - // A few collections - auto col1 = Akonadi::Collection(42); - col1.setRights(Akonadi::Collection::ReadOnly); - auto col2 = Akonadi::Collection(43); - col2.setRights(Akonadi::Collection::ReadOnly); - auto col3 = Akonadi::Collection(44); - col3.setRights(Akonadi::Collection::ReadOnly); - auto collectionFetchJob = new Testlib::AkonadiFakeCollectionFetchJob; - collectionFetchJob->setCollections(Akonadi::Collection::List() << col1 << col2 << col3); - - // A task and its corresponding item not existing in storage yet - Akonadi::Item item; - Domain::Note::Ptr note(new Domain::Note); - - // Storage mock returning the create job and with no default collection - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().thenReturn(Akonadi::Collection()); - storageMock(&Akonadi::StorageInterface::fetchCollections).when(Akonadi::Collection::root(), - Akonadi::StorageInterface::Recursive, - Akonadi::StorageInterface::Notes) - .thenReturn(collectionFetchJob); - - // Serializer mock returning the item for the task - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).thenReturn(item); - - // WHEN - QScopedPointer<Akonadi::NoteRepository> repository(new Akonadi::NoteRepository(storageMock.getInstance(), - serializerMock.getInstance())); - auto job = repository->create(note); - job->exec(); - - // THEN - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().exactly(1)); - QVERIFY(job->error()); - QVERIFY(!job->errorText().isEmpty()); - } - - void shouldCreateNewItemsInTag() - { - // GIVEN - // a tag - Akonadi::Tag akonadiTag; - akonadiTag.setName(QStringLiteral("akonadiTag42")); - akonadiTag.setId(42); - - // the domain Tag related to the Akonadi Tag - auto tag = Domain::Tag::Ptr::create(); - - // a default collection - Akonadi::Collection defaultCollection(42); - - // A note and its corresponding item not existing in storage yet - Akonadi::Item noteItem; - auto note = Domain::Note::Ptr::create(); - - // A mock create job - auto itemCreateJob = new FakeJob(this); - - // serializer mock returning the item for the task - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - - serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).thenReturn(akonadiTag); - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).thenReturn(noteItem); - - // Storage mock returning the create job - Utils::MockObject<Akonadi::StorageInterface> storageMock; - - storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().thenReturn(defaultCollection); - storageMock(&Akonadi::StorageInterface::createItem).when(noteItem, defaultCollection).thenReturn(itemCreateJob); - - // WHEN - QScopedPointer<Akonadi::NoteRepository> repository(new Akonadi::NoteRepository(storageMock.getInstance(), - serializerMock.getInstance())); - - repository->createInTag(note, tag)->exec(); - - // THEN - - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).exactly(1)); - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).exactly(1)); - - QVERIFY(storageMock(&Akonadi::StorageInterface::defaultNoteCollection).when().exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::createItem).when(noteItem, defaultCollection).exactly(1)); - } - - void shouldUpdateExistingItems() - { - // GIVEN - - // A default collection for saving - auto col = Akonadi::Collection(42); - - // A note and its corresponding item already existing in storage - auto item = Akonadi::Item(42); - auto note = Domain::Note::Ptr::create(); - - // A mock create job - auto itemModifyJob = new FakeJob(this); - - // Storage mock returning the create job - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::updateItem).when(item, Q_NULLPTR) - .thenReturn(itemModifyJob); - - // Serializer mock returning the item for the task - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).thenReturn(item); - - // WHEN - QScopedPointer<Akonadi::NoteRepository> repository(new Akonadi::NoteRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->update(note)->exec(); - - // THEN - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::updateItem).when(item, Q_NULLPTR).exactly(1)); - } - - void shouldRemoveANote() - { - // GIVEN - Akonadi::Item item(42); - Domain::Note::Ptr note(new Domain::Note); - - // A mock delete job - auto itemDeleteJob = new FakeJob(this); - - // Storage mock returning the delete job - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::removeItem).when(item) - .thenReturn(itemDeleteJob); - - // Serializer mock returning the item for the note - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).thenReturn(item); - - // WHEN - QScopedPointer<Akonadi::NoteRepository> repository(new Akonadi::NoteRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->remove(note)->exec(); - - // THEN - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::removeItem).when(item).exactly(1)); - } -}; - -ZANSHIN_TEST_MAIN(AkonadiNoteRepositoryTest) - -#include "akonadinoterepositorytest.moc" diff --git a/tests/units/akonadi/akonadiprojectrepositorytest.cpp b/tests/units/akonadi/akonadiprojectrepositorytest.cpp --- a/tests/units/akonadi/akonadiprojectrepositorytest.cpp +++ b/tests/units/akonadi/akonadiprojectrepositorytest.cpp @@ -151,7 +151,6 @@ Akonadi::Item childItem(42); childItem.setParentCollection(col); Domain::Artifact::Ptr childTask(new Domain::Task); - Domain::Artifact::Ptr childNote(new Domain::Note); Akonadi::Item parentItem(41); parentItem.setParentCollection(col); @@ -167,13 +166,6 @@ QTest::newRow("nominal case (task)") << childItem << parentItem << childTask << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << true << true << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob1->setItems(Akonadi::Item::List() << childItem); - itemFetchJob2 = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob2->setItems(Akonadi::Item::List() << parentItem); - itemFetchJob3 = new Testlib::AkonadiFakeItemFetchJob(this); - QTest::newRow("nominal case (note)") << childItem << parentItem << childNote << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << true << true << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); itemFetchJob1->setExpectedError(KJob::KilledJobError); QTest::newRow("child job error with empty list") << childItem << parentItem << childTask << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << false << false << list; @@ -183,37 +175,19 @@ itemFetchJob1->setItems(Akonadi::Item::List() << childItem); QTest::newRow("child job error with item (task)") << childItem << parentItem << childTask << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << false << false << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob1->setExpectedError(KJob::KilledJobError); - itemFetchJob1->setItems(Akonadi::Item::List() << childItem); - QTest::newRow("child job error with item (note)") << childItem << parentItem << childNote << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << false << false << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); itemFetchJob1->setItems(Akonadi::Item::List() << childItem); itemFetchJob2 = new Testlib::AkonadiFakeItemFetchJob(this); itemFetchJob2->setExpectedError(KJob::KilledJobError); QTest::newRow("parent job error with empty list (task)") << childItem << parentItem << childTask << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << true << false << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob1->setItems(Akonadi::Item::List() << childItem); - itemFetchJob2 = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob2->setExpectedError(KJob::KilledJobError); - QTest::newRow("parent job error with empty list (note)") << childItem << parentItem << childNote << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << true << false << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); itemFetchJob1->setItems(Akonadi::Item::List() << childItem); itemFetchJob2 = new Testlib::AkonadiFakeItemFetchJob(this); itemFetchJob2->setExpectedError(KJob::KilledJobError); itemFetchJob2->setItems(Akonadi::Item::List() << parentItem); QTest::newRow("parent job error with item (task)") << childItem << parentItem << childTask << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << true << false << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob1->setItems(Akonadi::Item::List() << childItem); - itemFetchJob2 = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob2->setExpectedError(KJob::KilledJobError); - itemFetchJob2->setItems(Akonadi::Item::List() << parentItem); - QTest::newRow("parent job error with item (note)") << childItem << parentItem << childNote << parent << itemFetchJob1 << itemFetchJob2 << itemFetchJob3 << true << false << list; - itemFetchJob1 = new Testlib::AkonadiFakeItemFetchJob(this); itemFetchJob1->setItems(Akonadi::Item::List() << childItem); itemFetchJob2 = new Testlib::AkonadiFakeItemFetchJob(this); @@ -281,7 +255,6 @@ // Serializer mock returning the item for the task Utils::MockObject<Akonadi::SerializerInterface> serializerMock; serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(child.objectCast<Domain::Task>()).thenReturn(childItem); - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(child.objectCast<Domain::Note>()).thenReturn(childItem); serializerMock(&Akonadi::SerializerInterface::createItemFromProject).when(parent).thenReturn(parentItem); serializerMock(&Akonadi::SerializerInterface::updateItemProject).when(childItem, parent).thenReturn(); if (execParentJob) @@ -322,7 +295,6 @@ QTest::addColumn<bool>("fetchJobFailed"); Domain::Artifact::Ptr taskChild(new Domain::Task); - Domain::Artifact::Ptr noteChild(new Domain::Note); Akonadi::Item childItem(42); auto itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); @@ -337,19 +309,6 @@ itemFetchJob->setExpectedError(KJob::KilledJobError); itemFetchJob->setItems(Akonadi::Item::List() << childItem); QTest::newRow("task job error with item") << taskChild << childItem << itemFetchJob << true; - - itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob->setItems(Akonadi::Item::List() << childItem); - QTest::newRow("note nominal case") << noteChild << childItem << itemFetchJob << false; - - itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob->setExpectedError(KJob::KilledJobError); - QTest::newRow("note job error with empty list") << noteChild << childItem << itemFetchJob << true; - - itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob->setExpectedError(KJob::KilledJobError); - itemFetchJob->setItems(Akonadi::Item::List() << childItem); - QTest::newRow("note job error with item") << noteChild << childItem << itemFetchJob << true; } void shouldDissociateAnArtifactFromItsProject() @@ -371,22 +330,16 @@ // Serializer mock returning the item for the task Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - if (child.objectCast<Domain::Task>()) - serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(child.objectCast<Domain::Task>()).thenReturn(childItem); - else - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(child.objectCast<Domain::Note>()).thenReturn(childItem); + serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(child.objectCast<Domain::Task>()).thenReturn(childItem); serializerMock(&Akonadi::SerializerInterface::removeItemParent).when(childItem).thenReturn(); // WHEN QScopedPointer<Akonadi::ProjectRepository> repository(new Akonadi::ProjectRepository(storageMock.getInstance(), serializerMock.getInstance())); repository->dissociate(child)->exec(); // THEN - if (child.objectCast<Domain::Task>()) - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(child.objectCast<Domain::Task>()).exactly(1)); - else - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(child.objectCast<Domain::Note>()).exactly(1)); + QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromTask).when(child.objectCast<Domain::Task>()).exactly(1)); QVERIFY(storageMock(&Akonadi::StorageInterface::fetchItem).when(childItem).exactly(1)); if (!fetchJobFailed) { diff --git a/tests/units/akonadi/akonadiserializertest.cpp b/tests/units/akonadi/akonadiserializertest.cpp --- a/tests/units/akonadi/akonadiserializertest.cpp +++ b/tests/units/akonadi/akonadiserializertest.cpp @@ -99,31 +99,6 @@ QVERIFY(!serializer.representsItem(object, item)); } - void shouldKnowWhenAnAkonadiTagRepresentsATag() - { - // GIVEN - Akonadi::Serializer serializer; - Akonadi::Tag akondiTag(42); - auto tag = Domain::Tag::Ptr::create(); - - // WHEN - // Nothing yet - // THEN - QVERIFY(!serializer.representsAkonadiTag(tag, akondiTag)); - - // WHEN - tag->setProperty("tagId", 42); - - // THEN - QVERIFY(serializer.representsAkonadiTag(tag, akondiTag)); - - // WHEN - tag->setProperty("tagId", 43); - - // THEN - QVERIFY(!serializer.representsAkonadiTag(tag, akondiTag)); - } - void shouldKnowTaskItemUid_data() { QTest::addColumn<Akonadi::Item>("item"); @@ -203,9 +178,6 @@ QFETCH(bool, isSelected); Domain::DataSource::ContentTypes expectedContentTypes; - if (mimeTypes.contains(QStringLiteral("text/x-vnd.akonadi.note"))) { - expectedContentTypes |= Domain::DataSource::Notes; - } if (mimeTypes.contains(QStringLiteral("application/x-vnd.akonadi.calendar.todo"))) { expectedContentTypes |= Domain::DataSource::Tasks; } @@ -412,18 +384,15 @@ QTest::addColumn<bool>("isSelected"); QTest::addColumn<bool>("expectedSelected"); - const auto noteMimeTypes = QStringList() << QStringLiteral("text/x-vnd.akonadi.note"); const auto taskMimeTypes = QStringList() << QStringLiteral("application/x-vnd.akonadi.calendar.todo"); const auto bogusMimeTypes = QStringList() << QStringLiteral("foo/bar"); - const auto allMimeTypes = noteMimeTypes + taskMimeTypes + bogusMimeTypes; + const auto allMimeTypes = taskMimeTypes + bogusMimeTypes; QTest::newRow("nominal case") << allMimeTypes << true << false << false; - QTest::newRow("only notes") << noteMimeTypes << true << false << false; QTest::newRow("only tasks") << taskMimeTypes << true << false << false; QTest::newRow("only bogus") << bogusMimeTypes << true << false << false; - QTest::newRow("selected, only notes") << noteMimeTypes << true << true << true; QTest::newRow("selected, only tasks") << taskMimeTypes << true << true << true; QTest::newRow("selected, only bogus") << bogusMimeTypes << true << true << false; @@ -469,11 +438,10 @@ void shouldVerifyCollectionContents_data() { QTest::addColumn<QString>("mimeType"); - QTest::addColumn<bool>("expectedNotes"); QTest::addColumn<bool>("expectedTasks"); - QTest::newRow("task collection") << "application/x-vnd.akonadi.calendar.todo" << false << true; - QTest::newRow("note collection") << "text/x-vnd.akonadi.note" << true << false; + QTest::newRow("task collection") << "application/x-vnd.akonadi.calendar.todo" << true; + QTest::newRow("note collection") << "text/x-vnd.akonadi.note" << false; } void shouldVerifyCollectionContents() @@ -489,11 +457,9 @@ // WHEN Akonadi::Serializer serializer; - QFETCH(bool, expectedNotes); QFETCH(bool, expectedTasks); // THEN - QCOMPARE(serializer.isNoteCollection(collection), expectedNotes); QCOMPARE(serializer.isTaskCollection(collection), expectedTasks); } @@ -1303,37 +1269,8 @@ todo2->setRelatedTo(QStringLiteral("1")); item2.setPayload<KCalCore::Todo::Ptr>(todo2); - Akonadi::Item item3; - KMime::Message::Ptr message1(new KMime::Message); - message1->subject(true)->fromUnicodeString(QStringLiteral("foo"), "utf-8"); - message1->mainBodyPart()->fromUnicodeString(QStringLiteral("bar")); - item3.setMimeType(Akonadi::NoteUtils::noteMimeType()); - item3.setPayload<KMime::Message::Ptr>(message1); - - Akonadi::Item item4; - KMime::Message::Ptr message2(new KMime::Message); - message2->subject(true)->fromUnicodeString(QStringLiteral("foo"), "utf-8"); - message2->mainBodyPart()->fromUnicodeString(QStringLiteral("bar")); - auto relatedHeader1 = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader1->from7BitString("1"); - message2->appendHeader(relatedHeader1); - item4.setMimeType(Akonadi::NoteUtils::noteMimeType()); - item4.setPayload<KMime::Message::Ptr>(message2); - - Akonadi::Item item5; - KMime::Message::Ptr message3(new KMime::Message); - message3->subject(true)->fromUnicodeString(QStringLiteral("foo"), "utf-8"); - message3->mainBodyPart()->fromUnicodeString(QStringLiteral("bar")); - auto relatedHeader2 = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - message3->appendHeader(relatedHeader2); - item5.setMimeType(Akonadi::NoteUtils::noteMimeType()); - item5.setPayload<KMime::Message::Ptr>(message3); - QTest::newRow("task without related") << item1 << QString(); QTest::newRow("task with related") << item2 << "1"; - QTest::newRow("note without related") << item3 << QString(); - QTest::newRow("note with related") << item4 << "1"; - QTest::newRow("note with empty related") << item5 << QString(); } void shouldRetrieveRelatedUidFromItem() @@ -1362,243 +1299,6 @@ QTest::newRow("empty case") << QString() << QString() << QString(); } - void shouldCreateNoteFromItem() - { - // GIVEN - - // Data... - QFETCH(QString, title); - QFETCH(QString, text); - QFETCH(QString, relatedUid); - - // ... stored in a message... - KMime::Message::Ptr message(new KMime::Message); - message->subject(true)->fromUnicodeString(title, "utf-8"); - message->mainBodyPart()->fromUnicodeString(text); - - if (!relatedUid.isEmpty()) { - auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader->from7BitString(relatedUid.toUtf8()); - message->appendHeader(relatedHeader); - } - - // ... as payload of an item. - Akonadi::Item item; - item.setMimeType(Akonadi::NoteUtils::noteMimeType()); - item.setPayload<KMime::Message::Ptr>(message); - - // WHEN - Akonadi::Serializer serializer; - Domain::Note::Ptr note = serializer.createNoteFromItem(item); - auto artifact = serializer.createArtifactFromItem(item).dynamicCast<Domain::Note>(); - - // THEN - const auto expectedText = text.endsWith('\n') ? (text.chop(1), text) : text; - - QCOMPARE(note->title(), title); - QCOMPARE(note->text(), expectedText); - QCOMPARE(note->property("itemId").toLongLong(), item.id()); - QCOMPARE(note->property("relatedUid").toString(), relatedUid); - - QVERIFY(!artifact.isNull()); - QCOMPARE(artifact->title(), title); - QCOMPARE(artifact->text(), expectedText); - QCOMPARE(artifact->property("itemId").toLongLong(), item.id()); - QCOMPARE(artifact->property("relatedUid").toString(), relatedUid); - } - - void shouldCreateNullNoteFromInvalidItem() - { - // GIVEN - Akonadi::Item item; - - // WHEN - Akonadi::Serializer serializer; - Domain::Note::Ptr note = serializer.createNoteFromItem(item); - auto artifact = serializer.createArtifactFromItem(item); - - // THEN - QVERIFY(note.isNull()); - QVERIFY(artifact.isNull()); - } - - void shouldUpdateNoteFromItem_data() - { - QTest::addColumn<QString>("updatedTitle"); - QTest::addColumn<QString>("updatedText"); - QTest::addColumn<QString>("updatedRelatedUid"); - - QTest::newRow("no change") << "title" << "content" << "parent-uid"; - QTest::newRow("data changed (with related)") << "A new title" << "A new content" << "new-parent-uid"; - QTest::newRow("data changed (with no related)") << "A new title" << "A new content" << QString(); - } - - void shouldUpdateNoteFromItem() - { - // GIVEN - - // A message... - KMime::Message::Ptr message(new KMime::Message); - message->subject(true)->fromUnicodeString(QStringLiteral("title"), "utf-8"); - message->mainBodyPart()->fromUnicodeString(QStringLiteral("text")); - auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader->from7BitString("parent-uid"); - message->appendHeader(relatedHeader); - - //... as the payload of an item... - Akonadi::Item item; - item.setMimeType(Akonadi::NoteUtils::noteMimeType()); - item.setPayload<KMime::Message::Ptr>(message); - - //... deserialized as a note - Akonadi::Serializer serializer; - auto note = serializer.createNoteFromItem(item); - auto artifact = serializer.createNoteFromItem(item); - - // WHEN - - // Data... - QFETCH(QString, updatedTitle); - QFETCH(QString, updatedText); - QFETCH(QString, updatedRelatedUid); - - //... stored in a new message... - KMime::Message::Ptr updatedMessage(new KMime::Message); - updatedMessage->subject(true)->fromUnicodeString(updatedTitle, "utf-8"); - updatedMessage->mainBodyPart()->fromUnicodeString(updatedText); - - if (!updatedRelatedUid.isEmpty()) { - relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader->from7BitString(updatedRelatedUid.toUtf8()); - updatedMessage->appendHeader(relatedHeader); - } - - //... as the payload of a new item... - Akonadi::Item updatedItem; - updatedItem.setMimeType(Akonadi::NoteUtils::noteMimeType()); - updatedItem.setPayload<KMime::Message::Ptr>(updatedMessage); - - serializer.updateNoteFromItem(note, updatedItem); - serializer.updateArtifactFromItem(artifact, updatedItem); - - // THEN - QCOMPARE(note->title(), updatedTitle); - QCOMPARE(note->text(), updatedText); - QCOMPARE(note->property("itemId").toLongLong(), updatedItem.id()); - QCOMPARE(note->property("relatedUid").toString(), updatedRelatedUid); - - note = artifact.dynamicCast<Domain::Note>(); - QCOMPARE(note->title(), updatedTitle); - QCOMPARE(note->text(), updatedText); - QCOMPARE(note->property("itemId").toLongLong(), updatedItem.id()); - QCOMPARE(note->property("relatedUid").toString(), updatedRelatedUid); - } - - void shouldNotUpdateNoteFromInvalidItem() - { - // GIVEN - - // Data... - QString title = QStringLiteral("A title"); - QString text = QStringLiteral("A note content"); - - // ... stored in a message... - KMime::Message::Ptr message(new KMime::Message); - message->subject(true)->fromUnicodeString(title, "utf-8"); - message->mainBodyPart()->fromUnicodeString(text); - - //... as the payload of an item... - Akonadi::Item item; - item.setMimeType(Akonadi::NoteUtils::noteMimeType()); - item.setPayload<KMime::Message::Ptr>(message); - - //... deserialized as a note - Akonadi::Serializer serializer; - auto note = serializer.createNoteFromItem(item); - auto artifact = serializer.createArtifactFromItem(item); - - // WHEN - Akonadi::Item invalidItem; - - serializer.updateNoteFromItem(note, invalidItem); - serializer.updateArtifactFromItem(artifact, invalidItem); - - //THEN - QCOMPARE(note->title(), title); - QCOMPARE(note->text(), text); - QCOMPARE(note->property("itemId").toLongLong(), item.id()); - - note = artifact.dynamicCast<Domain::Note>(); - QCOMPARE(note->title(), title); - QCOMPARE(note->text(), text); - QCOMPARE(note->property("itemId").toLongLong(), item.id()); - } - - void shouldCreateItemFromNote_data() - { - QTest::addColumn<QString>("title"); - QTest::addColumn<QString>("content"); - QTest::addColumn<QString>("expectedTitle"); - QTest::addColumn<QString>("expectedContent"); - QTest::addColumn<qint64>("itemId"); - QTest::addColumn<QString>("relatedUid"); - - QTest::newRow("nominal case (no id)") << "title" << "content" << "title" << "content" << qint64(-1) << QString(); - QTest::newRow("empty case (no id)") << QString() << QString() << "New Note" << QString() << qint64(-1) << QString(); - - QTest::newRow("nominal case (with id)") << "title" << "content" << "title" << "content" << qint64(42) << "parent-uid"; - QTest::newRow("empty case (with id)") << QString() << QString() << "New Note" << QString() << qint64(42) << "parent-uid"; - - QTest::newRow("empty line at the end") << "title" << "content\n\n\n" << "title" << "content\n\n\n" << qint64(-1) << QString(); - } - - void shouldCreateItemFromNote() - { - // GIVEN - - // Data... - QFETCH(QString, title); - QFETCH(QString, content); - QFETCH(qint64, itemId); - QFETCH(QString, relatedUid); - - // ... stored in a note - auto note = Domain::Note::Ptr::create(); - note->setTitle(title); - note->setText(content); - - if (itemId > 0) - note->setProperty("itemId", itemId); - - if (!relatedUid.isEmpty()) - note->setProperty("relatedUid", relatedUid); - - // WHEN - Akonadi::Serializer serializer; - auto item = serializer.createItemFromNote(note); - - // THEN - QCOMPARE(item.mimeType(), Akonadi::NoteUtils::noteMimeType()); - - QCOMPARE(item.isValid(), itemId > 0); - if (itemId > 0) { - QCOMPARE(item.id(), itemId); - } - - QFETCH(QString, expectedTitle); - QFETCH(QString, expectedContent); - auto message = item.payload<KMime::Message::Ptr>(); - QCOMPARE(message->subject(false)->asUnicodeString(), expectedTitle); - QCOMPARE(message->mainBodyPart()->decodedText(), expectedContent); - - if (relatedUid.isEmpty()) { - QVERIFY(!message->headerByType("X-Zanshin-RelatedProjectUid")); - } else { - QVERIFY(message->headerByType("X-Zanshin-RelatedProjectUid")); - QCOMPARE(message->headerByType("X-Zanshin-RelatedProjectUid")->asUnicodeString(), relatedUid); - } - } - void shouldCreateProjectFromItem_data() { QTest::addColumn<QString>("summary"); @@ -1885,29 +1585,8 @@ QTest::newRow("child todo") << project << childTodoItem << true; - // Create unrelated note - KMime::Message::Ptr unrelatedNote(new KMime::Message); - unrelatedNote->subject(true)->fromUnicodeString(QStringLiteral("subject"), "utf-8"); - Akonadi::Item unrelatedNoteItem; - unrelatedNoteItem.setMimeType(Akonadi::NoteUtils::noteMimeType()); - unrelatedNoteItem.setPayload<KMime::Message::Ptr>(unrelatedNote); - - QTest::newRow("unrelated note") << project << unrelatedNoteItem << false; - - // Create child note - KMime::Message::Ptr childNote(new KMime::Message); - childNote->subject(true)->fromUnicodeString(QStringLiteral("subject"), "utf-8"); - auto relatedHeader = new KMime::Headers::Generic("X-Zanshin-RelatedProjectUid"); - relatedHeader->from7BitString("1"); - childNote->appendHeader(relatedHeader); - Akonadi::Item childNoteItem; - childNoteItem.setMimeType(Akonadi::NoteUtils::noteMimeType()); - childNoteItem.setPayload<KMime::Message::Ptr>(childNote); - - QTest::newRow("child todo") << project << childNoteItem << true; - auto invalidProject = Domain::Project::Ptr::create(); - QTest::newRow("invalid project") << invalidProject << unrelatedNoteItem << false; + QTest::newRow("invalid project") << invalidProject << unrelatedTodoItem << false; Akonadi::Item invalidItem; QTest::newRow("invalid item") << project << invalidItem << false; @@ -1988,13 +1667,6 @@ auto invalidParent = Domain::Project::Ptr::create(); QTest::newRow("update todo item with a empty parent uid") << todoItem << invalidParent << QString(); - Akonadi::Item noteItem; - KMime::Message::Ptr note(new KMime::Message); - noteItem.setPayload<KMime::Message::Ptr>(note); - - QTest::newRow("nominal note case") << noteItem << parent << "1"; - QTest::newRow("update note item with a empty parent uid") << noteItem << invalidParent << QString(); - Akonadi::Item invalidItem; QTest::newRow("update item without payload") << invalidItem << parent << QString(); } @@ -2328,11 +2000,10 @@ QCOMPARE(value, isChild); } - void shouldCheckIfAnItemHasContextsOrTags_data() + void shouldCheckIfAnItemHasContexts_data() { QTest::addColumn<Akonadi::Item>("item"); QTest::addColumn<bool>("contextsExpected"); - QTest::addColumn<bool>("tagsExpected"); Akonadi::Tag unrelatedTag(QStringLiteral("Foo")); unrelatedTag.setType("unrelated"); @@ -2342,37 +2013,34 @@ akonadiTag.setType(Akonadi::Tag::PLAIN); Akonadi::Item item; - QTest::newRow("no tags") << item << false << false; + QTest::newRow("no tags") << item << false; item.setTags({ unrelatedTag }); - QTest::newRow("unrelated tags") << item << false << false; + QTest::newRow("unrelated tags") << item << false; item.setTags({ unrelatedTag, contextTag }); - QTest::newRow("has contexts") << item << true << false; + QTest::newRow("has contexts") << item << true; item.setTags({ unrelatedTag, akonadiTag }); - QTest::newRow("has tags") << item << false << true; + QTest::newRow("has tags") << item << false; item.setTags({ unrelatedTag, contextTag, akonadiTag }); - QTest::newRow("has both") << item << true << true; + QTest::newRow("has both") << item << true; } - void shouldCheckIfAnItemHasContextsOrTags() + void shouldCheckIfAnItemHasContexts() { // GIVEN QFETCH(Akonadi::Item, item); QFETCH(bool, contextsExpected); - QFETCH(bool, tagsExpected); Akonadi::Serializer serializer; // WHEN const bool hasContexts = serializer.hasContextTags(item); - const bool hasTags = serializer.hasAkonadiTags(item); // THEN QCOMPARE(hasContexts, contextsExpected); - QCOMPARE(hasTags, tagsExpected); } void shouldCreateTagFromContext_data() @@ -2415,154 +2083,6 @@ } } - void shouldCreateTagFromAkonadiTag_data() - { - QTest::addColumn<QString>("name"); - QTest::addColumn<qint64>("tagId"); - QTest::addColumn<QByteArray>("type"); - - QString tagName = QStringLiteral("Optional"); - QByteArray plainType = Akonadi::Tag::PLAIN; - - QTest::newRow("nominal case") << tagName << qint64(42) << plainType; - QTest::newRow("null name case") << QString() << qint64(42) << plainType; - QTest::newRow("null tagId case") << tagName << qint64(-1) << plainType; - QTest::newRow("totally null tag case") << QString() << qint64(-1) << plainType; - } - - void shouldCreateTagFromAkonadiTag() - { - // GIVEN - QFETCH(QString, name); - QFETCH(qint64, tagId); - QFETCH(QByteArray, type); - - auto akonadiTag = Akonadi::Tag(); - akonadiTag.setName(name); - akonadiTag.setId(tagId); - akonadiTag.setType(type); - - // WHEN - Akonadi::Serializer serializer; - Domain::Tag::Ptr resultTag = serializer.createTagFromAkonadiTag(akonadiTag); - - // THEN - QCOMPARE(resultTag->name(), akonadiTag.name()); - QCOMPARE(resultTag->property("tagId").toLongLong(), akonadiTag.id()); - } - - void shouldUpdateTagFromAkonadiTag_data() - { - shouldCreateTagFromAkonadiTag_data(); - } - - void shouldUpdateTagFromAkonadiTag() - { - // GIVEN - QFETCH(QString, name); - QFETCH(qint64, tagId); - QFETCH(QByteArray, type); - - // ... stored as an Akonadi Tag - Akonadi::Tag akonadiTag(name); - akonadiTag.setId(tagId); - akonadiTag.setType(type); - - // WHEN - Akonadi::Serializer serializer; - auto tag = Domain::Tag::Ptr::create(); - tag->setName(QStringLiteral("tag42")); - - serializer.updateTagFromAkonadiTag(tag, akonadiTag); - - // THEN - QCOMPARE(tag->name(), akonadiTag.name()); - QCOMPARE(tag->property("tagId").toLongLong(), akonadiTag.id()); - } - - void shouldCreateAkonadiTagFromTag_data() - { - // GIVEN - QTest::addColumn<QString>("name"); - QTest::addColumn<qint64>("tagId"); - QTest::addColumn<QByteArray>("tagGid"); - - const QByteArray namePhilo = "Philosophy"; - - QTest::newRow("nominal case") << QString(namePhilo) << qint64(42) << namePhilo; - QTest::newRow("null name case") << QString() << qint64(42) << QByteArray(); - QTest::newRow("null tagId case") << QString(namePhilo) << qint64(-1) << namePhilo; - QTest::newRow("totally null tag case") << QString() << qint64(-1) << QByteArray(); - } - - void shouldCreateAkonadiTagFromTag() - { - // GIVEN - QFETCH(QString, name); - QFETCH(qint64, tagId); - QFETCH(QByteArray, tagGid); - - // WHEN - auto tag = Domain::Tag::Ptr::create(); - tag->setProperty("tagId", tagId); - tag->setName(name); - - Akonadi::Serializer serializer; - Akonadi::Tag akonadiTag = serializer.createAkonadiTagFromTag(tag); - - // THEN - QCOMPARE(akonadiTag.name(), name); - QCOMPARE(akonadiTag.isValid(), tagId > 0); - - if (tagId > 0) { - QCOMPARE(akonadiTag.id(), tagId); - QCOMPARE(akonadiTag.gid(), tagGid); - QCOMPARE(akonadiTag.type(), QByteArray(Akonadi::Tag::PLAIN)); - } - } - - void shouldVerifyIfAnItemIsATagChild_data() - { - QTest::addColumn<Domain::Tag::Ptr>("tag"); - QTest::addColumn<Akonadi::Item>("item"); - QTest::addColumn<bool>("isChild"); - - // Create a Tag - auto tag = Domain::Tag::Ptr::create(); - tag->setProperty("tagId", qint64(43)); - Akonadi::Tag akonadiTag(Akonadi::Tag::Id(43)); - - Akonadi::Item unrelatedItem; - QTest::newRow("Unrelated item") << tag << unrelatedItem << false; - - Akonadi::Item relatedItem; - relatedItem.setTag(akonadiTag); - QTest::newRow("Related item") << tag << relatedItem << true; - - auto invalidTag = Domain::Tag::Ptr::create(); - QTest::newRow("Invalid Tag") << invalidTag << relatedItem << false; - - Akonadi::Item invalidItem; - QTest::newRow("Invalid Item") << tag << invalidItem << false; - - QTest::newRow("both invalid") << invalidTag << invalidItem << false; - } - - void shouldVerifyIfAnItemIsATagChild() - { - // GIVEN - QFETCH(Domain::Tag::Ptr, tag); - QFETCH(Akonadi::Item, item); - QFETCH(bool, isChild); - - // WHEN - Akonadi::Serializer serializer; - bool value = serializer.isTagChild(tag, item); - - // THEN - QCOMPARE(value, isChild); - } - // Investigation into how to differentiate all-day events from events with time, // using QDateTime only. Doesn't seem to be possible. void noWayToHaveQDateTimeWithoutTime() diff --git a/tests/units/akonadi/akonaditagqueriestest.cpp b/tests/units/akonadi/akonaditagqueriestest.cpp deleted file mode 100644 --- a/tests/units/akonadi/akonaditagqueriestest.cpp +++ /dev/null @@ -1,302 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include "akonadi/akonaditagqueries.h" -#include "akonadi/akonadiserializer.h" - -#include "testlib/akonadifakedata.h" -#include "testlib/gencollection.h" -#include "testlib/gennote.h" -#include "testlib/gentag.h" -#include "testlib/testhelpers.h" - -using namespace Testlib; - -class AkonadiTagQueriesTest : public QObject -{ - Q_OBJECT -private slots: - void shouldLookInAllReportedForAllTag() - { - // GIVEN - AkonadiFakeData data; - - // Two plain tags - data.createTag(GenTag().withId(42).withName(QStringLiteral("42")).asPlain()); - data.createTag(GenTag().withId(43).withName(QStringLiteral("43")).asPlain()); - - // WHEN - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - result->data(); - result = queries->findAll(); // Should not cause any problem or wrong data - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43")); - } - - void shouldReactToTagAdded() - { - // GIVEN - AkonadiFakeData data; - - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - TestHelpers::waitForEmptyJobQueue(); - QVERIFY(result->data().isEmpty()); - - // WHEN - data.createTag(GenTag().withId(42).withName(QStringLiteral("42")).asPlain()); - data.createTag(GenTag().withId(43).withName(QStringLiteral("43")).asPlain()); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43")); - } - - void shouldReactToTagRemoved() - { - // GIVEN - AkonadiFakeData data; - - // Two plain tags - data.createTag(GenTag().withId(42).withName(QStringLiteral("42")).asPlain()); - data.createTag(GenTag().withId(43).withName(QStringLiteral("43")).asPlain()); - - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 2); - - // WHEN - data.removeTag(Akonadi::Tag(43)); - - // THEN - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42")); - } - - void shouldReactToTagChanges() - { - // GIVEN - AkonadiFakeData data; - - // Two plain tags - data.createTag(GenTag().withId(42).withName(QStringLiteral("42")).asPlain()); - data.createTag(GenTag().withId(43).withName(QStringLiteral("43")).asPlain()); - - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - Akonadi::Serializer::Ptr(new Akonadi::Serializer), - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - auto result = queries->findAll(); - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 2); - - // WHEN - data.modifyTag(GenTag(data.tag(43)).withName(QStringLiteral("43bis"))); - - // THEN - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->name(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->name(), QStringLiteral("43bis")); - } - - void shouldLookInAllCollectionsForTagTopLevelArtifacts() - { - // GIVEN - AkonadiFakeData data; - - // Two top level collections - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - data.createCollection(GenCollection().withId(43).withRootAsParent().withNoteContent()); - - // One plain tag - data.createTag(GenTag().withId(42).withName(QStringLiteral("42")).asPlain()); - - // Two notes in the first collection - data.createItem(GenNote().withParent(42).withId(42).withTitle(QStringLiteral("42")).withTags({42})); - data.createItem(GenNote().withParent(42).withId(43).withTitle(QStringLiteral("43"))); - - // Two notes in the second collection - data.createItem(GenNote().withParent(43).withId(44).withTitle(QStringLiteral("44")).withTags({42})); - data.createItem(GenNote().withParent(43).withId(45).withTitle(QStringLiteral("45"))); - - // WHEN - auto serializer = Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer); - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - serializer, - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - - auto tag = serializer->createTagFromAkonadiTag(data.tag(42)); - auto result = queries->findNotes(tag); - result->data(); - result = queries->findNotes(tag); // Should not cause any problem or wrong data - - // THEN - QVERIFY(result->data().isEmpty()); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("44")); - - // Should not change nothing - result = queries->findNotes(tag); - TestHelpers::waitForEmptyJobQueue(); - - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("44")); - } - - void shouldReactToItemAddedForTag() - { - // GIVEN - AkonadiFakeData data; - - // Two top level collections - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // One plain tag - data.createTag(GenTag().withId(42).withName(QStringLiteral("tag-42")).asPlain()); - - auto serializer = Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer); - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - serializer, - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - - auto tag = serializer->createTagFromAkonadiTag(data.tag(42)); - auto result = queries->findNotes(tag); - TestHelpers::waitForEmptyJobQueue(); - QVERIFY(result->data().isEmpty()); - - // WHEN - data.createItem(GenNote().withParent(42).withId(42).withTitle(QStringLiteral("42")).withTags({42})); - - // THEN - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - } - - void shouldReactToItemNewlyAssociatedToTag() - { - // GIVEN - AkonadiFakeData data; - - // One plain tag - data.createTag(GenTag().withId(42).withName(QStringLiteral("tag-42")).asPlain()); - - // One top level collection with a note - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - - auto serializer = Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer); - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - serializer, - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - - auto tag = serializer->createTagFromAkonadiTag(data.tag(42)); - auto result = queries->findNotes(tag); - - bool insertHandlerCalled = false; - result->addPostInsertHandler([&insertHandlerCalled](const Domain::Artifact::Ptr &, int) { - insertHandlerCalled = true; - }); - - TestHelpers::waitForEmptyJobQueue(); - QVERIFY(result->data().isEmpty()); - - // WHEN - data.modifyItem(GenNote(data.item(42)).withTags({42})); - - // THEN - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - - QVERIFY(insertHandlerCalled); - } - - void shouldReactWhenAnItemTaggedIsRemoved() - { - // GIVEN - - AkonadiFakeData data; - - // One plain tag - data.createTag(GenTag().withId(42).withName(QStringLiteral("tag-42")).asPlain()); - - // One top level collection - data.createCollection(GenCollection().withId(42).withRootAsParent().withNoteContent()); - - // Two notes related to the tag - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42")).withTags({42})); - data.createItem(GenNote().withId(43).withParent(42).withTitle(QStringLiteral("43")).withTags({42})); - - - auto serializer = Akonadi::SerializerInterface::Ptr(new Akonadi::Serializer); - QScopedPointer<Domain::TagQueries> queries(new Akonadi::TagQueries(Akonadi::StorageInterface::Ptr(data.createStorage()), - serializer, - Akonadi::MonitorInterface::Ptr(data.createMonitor()))); - - auto tag = serializer->createTagFromAkonadiTag(data.tag(42)); - auto result = queries->findNotes(tag); - - bool removeHandlerCalled = false; - result->addPostRemoveHandler([&removeHandlerCalled](const Domain::Artifact::Ptr &, int) { - removeHandlerCalled = true; - }); - - TestHelpers::waitForEmptyJobQueue(); - QCOMPARE(result->data().size(), 2); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QCOMPARE(result->data().at(1)->title(), QStringLiteral("43")); - - // WHEN - data.removeItem(Akonadi::Item(43)); - - // THEN - QCOMPARE(result->data().size(), 1); - QCOMPARE(result->data().at(0)->title(), QStringLiteral("42")); - QVERIFY(removeHandlerCalled); - } -}; - -ZANSHIN_TEST_MAIN(AkonadiTagQueriesTest) - -#include "akonaditagqueriestest.moc" diff --git a/tests/units/akonadi/akonaditagrepositorytest.cpp b/tests/units/akonadi/akonaditagrepositorytest.cpp deleted file mode 100644 --- a/tests/units/akonadi/akonaditagrepositorytest.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - Copyright 2014 Franck Arrecot <franck.arrecot@gmail.com> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include "utils/mockobject.h" - -#include "testlib/akonadifakejobs.h" -#include "testlib/akonadifakemonitor.h" - -#include "akonadi/akonaditagrepository.h" -#include "akonadi/akonadiserializerinterface.h" -#include "akonadi/akonadistorageinterface.h" - -using namespace mockitopp; -using namespace mockitopp::matcher; - -Q_DECLARE_METATYPE(Testlib::AkonadiFakeItemFetchJob*) -Q_DECLARE_METATYPE(Testlib::AkonadiFakeTagFetchJob*) - -class AkonadiTagRepositoryTest : public QObject -{ - Q_OBJECT -private slots: - void shouldCreateTag() - { - // GIVEN - - // A Tag and its corresponding Akonadi Tag - Akonadi::Tag akonadiTag; // not existing yet - auto tag = Domain::Tag::Ptr::create(); - - // A mock creating job - auto tagCreateJob = new FakeJob(this); - - // Storage mock returning the tagCreatejob - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::createTag).when(akonadiTag) - .thenReturn(tagCreateJob); - - // Serializer mock - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).thenReturn(akonadiTag); - - - // WHEN - QScopedPointer<Akonadi::TagRepository> repository(new Akonadi::TagRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->create(tag)->exec(); - - //THEN - QVERIFY(storageMock(&Akonadi::StorageInterface::createTag).when(akonadiTag).exactly(1)); - } - - void shouldRemoveTag() - { - // GIVEN - Akonadi::Tag akonadiTag(42); - auto tag = Domain::Tag::Ptr::create(); - tag->setProperty("tagId", qint64(42)); // must be set - tag->setName(QStringLiteral("42")); - - // A mock of removal job - auto tagRemoveJob = new FakeJob(this); - - // Storage mock returning the tagCreatejob - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::removeTag).when(akonadiTag) - .thenReturn(tagRemoveJob); - // Serializer mock - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).thenReturn(akonadiTag); - - // WHEN - QScopedPointer<Akonadi::TagRepository> repository(new Akonadi::TagRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->remove(tag)->exec(); - - // THEN - QVERIFY(storageMock(&Akonadi::StorageInterface::removeTag).when(akonadiTag).exactly(1)); - } - - void shouldAssociateNoteToTag() - { - // GIVEN - auto tag = Domain::Tag::Ptr::create(); - Akonadi::Tag akonadiTag(42); - - auto note = Domain::Note::Ptr::create(); - Akonadi::Item noteItem(42); - - // A mock of update job - auto itemModifyJob = new FakeJob(this); - - auto itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob->setItems(Akonadi::Item::List() << noteItem); - - // Storage mock returning the tagCreatejob - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::updateItem).when(noteItem, Q_NULLPTR) - .thenReturn(itemModifyJob); - - storageMock(&Akonadi::StorageInterface::fetchItem).when(noteItem) - .thenReturn(itemFetchJob); - // Serializer mock - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).thenReturn(akonadiTag); - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).thenReturn(noteItem); - - // WHEN - QScopedPointer<Akonadi::TagRepository> repository(new Akonadi::TagRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->associate(tag, note)->exec(); - - // THEN - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).exactly(1)); - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note).exactly(1)); - - QVERIFY(storageMock(&Akonadi::StorageInterface::updateItem).when(noteItem, Q_NULLPTR).exactly(1)); - } - - void shouldDissociateNoteFromTag() - { - // GIVEN - Akonadi::Item item(42); - Domain::Note::Ptr note(new Domain::Note); - - Akonadi::Tag akonadiTag(qint64(42)); - auto tag = Domain::Tag::Ptr::create(); - - auto itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob->setExpectedError(KJob::KilledJobError); - - auto itemFetchJobFilled = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJobFilled->setItems(Akonadi::Item::List() << item); - - // A mock update job - auto itemModifyJob = new FakeJob(this); - - // Storage mock returning the create job - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::fetchItem).when(item) - .thenReturn(itemFetchJob) - .thenReturn(itemFetchJobFilled); - storageMock(&Akonadi::StorageInterface::updateItem).when(item, Q_NULLPTR) - .thenReturn(itemModifyJob); - - // Serializer mock returning the item for the note - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note) - .thenReturn(item); - serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag) - .thenReturn(akonadiTag); - // WHEN - QScopedPointer<Akonadi::TagRepository> repository(new Akonadi::TagRepository(storageMock.getInstance(), - serializerMock.getInstance())); - repository->dissociate(tag, note)->exec(); - - // THEN - QVERIFY(storageMock(&Akonadi::StorageInterface::fetchItem).when(item).exactly(1)); - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).exactly(0)); - QVERIFY(storageMock(&Akonadi::StorageInterface::updateItem).when(item, Q_NULLPTR).exactly(0)); - - // WHEN - repository->dissociate(tag, note)->exec(); - - // THEN - QVERIFY(storageMock(&Akonadi::StorageInterface::fetchItem).when(item).exactly(2)); - QVERIFY(serializerMock(&Akonadi::SerializerInterface::createAkonadiTagFromTag).when(tag).exactly(1)); - QVERIFY(storageMock(&Akonadi::StorageInterface::updateItem).when(item, Q_NULLPTR).exactly(1)); - } - - void shouldDissociateNoteFromAllTags_data() - { - QTest::addColumn<Akonadi::Item>("item"); - QTest::addColumn<Domain::Note::Ptr>("note"); - QTest::addColumn<Testlib::AkonadiFakeItemFetchJob*>("itemFetchJob"); - QTest::addColumn<bool>("execJob"); - - Akonadi::Item item(42); - auto note = Domain::Note::Ptr::create(); - - auto itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob->setItems(Akonadi::Item::List() << item); - QTest::newRow("nominal case") << item << note << itemFetchJob << true; - - itemFetchJob = new Testlib::AkonadiFakeItemFetchJob(this); - itemFetchJob->setExpectedError(KJob::KilledJobError); - QTest::newRow("task job error, cannot find task") << item << note << itemFetchJob << false; - } - - void shouldDissociateNoteFromAllTags() - { - QFETCH(Akonadi::Item,item); - QFETCH(Domain::Note::Ptr, note); - QFETCH(Testlib::AkonadiFakeItemFetchJob*,itemFetchJob); - QFETCH(bool,execJob); - - // A mock update job - auto itemModifyJob = new FakeJob(this); - - // Storage mock returning the create job - Utils::MockObject<Akonadi::StorageInterface> storageMock; - storageMock(&Akonadi::StorageInterface::fetchItem).when(item) - .thenReturn(itemFetchJob); - storageMock(&Akonadi::StorageInterface::updateItem).when(item, Q_NULLPTR) - .thenReturn(itemModifyJob); - - // Serializer mock returning the item for the task - Utils::MockObject<Akonadi::SerializerInterface> serializerMock; - serializerMock(&Akonadi::SerializerInterface::createItemFromNote).when(note) - .thenReturn(item); - - // WHEN - QScopedPointer<Akonadi::TagRepository> repository(new Akonadi::TagRepository(storageMock.getInstance(), - serializerMock.getInstance())); - - auto dissociateJob = repository->dissociateAll(note); - - if (execJob) - dissociateJob->exec(); - - // THEN - QVERIFY(storageMock(&Akonadi::StorageInterface::fetchItem).when(item).exactly(1)); - if (execJob) { - QVERIFY(storageMock(&Akonadi::StorageInterface::updateItem).when(item, Q_NULLPTR).exactly(1)); - } else { - delete dissociateJob; - } - - // Give a chance to itemFetchJob to delete itself - // in case of an error (since it uses deleteLater() internally) - QTest::qWait(10); - } -}; - -ZANSHIN_TEST_MAIN(AkonadiTagRepositoryTest) - -#include "akonaditagrepositorytest.moc" diff --git a/tests/units/akonadi/akonaditaskqueriestest.cpp b/tests/units/akonadi/akonaditaskqueriestest.cpp --- a/tests/units/akonadi/akonaditaskqueriestest.cpp +++ b/tests/units/akonadi/akonaditaskqueriestest.cpp @@ -30,7 +30,6 @@ #include "testlib/akonadifakedata.h" #include "testlib/gencollection.h" -#include "testlib/gennote.h" #include "testlib/gentag.h" #include "testlib/gentodo.h" #include "testlib/testhelpers.h" @@ -1077,9 +1076,6 @@ data.createCollection(GenCollection().withId(43).withRootAsParent().withTaskContent()); data.createCollection(GenCollection().withId(44).withRootAsParent().withTaskContent().selected(false)); - // One note in the first collection - data.createItem(GenNote().withId(42).withParent(42).withTitle(QStringLiteral("42"))); - // Two tasks in the second collection data.createItem(GenTodo().withId(43).withParent(43).withTitle(QStringLiteral("43"))); data.createItem(GenTodo().withId(44).withParent(43).withTitle(QStringLiteral("44"))); diff --git a/tests/units/domain/CMakeLists.txt b/tests/units/domain/CMakeLists.txt --- a/tests/units/domain/CMakeLists.txt +++ b/tests/units/domain/CMakeLists.txt @@ -5,9 +5,7 @@ livequerytest liverelationshipquerytest mockitotest - notetest projecttest queryresulttest - tagtest tasktest ) diff --git a/tests/units/domain/notetest.cpp b/tests/units/domain/notetest.cpp deleted file mode 100644 --- a/tests/units/domain/notetest.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include "domain/note.h" - -using namespace Domain; - -class NoteTest : public QObject -{ - Q_OBJECT -private slots: - void shouldHaveEmptyPropertiesByDefault() - { - Note n; - QCOMPARE(n.text(), QString()); - QCOMPARE(n.title(), QString()); - } -}; - -ZANSHIN_TEST_MAIN(NoteTest) - -#include "notetest.moc" diff --git a/tests/units/domain/tagtest.cpp b/tests/units/domain/tagtest.cpp deleted file mode 100644 --- a/tests/units/domain/tagtest.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include "domain/tag.h" - -using namespace Domain; - -class TagTest : public QObject -{ - Q_OBJECT -private slots: - void shouldHaveEmptyPropertiesByDefault() - { - Tag t; - QCOMPARE(t.name(), QString()); - } - - void shouldNotifyNameChanges() - { - Tag t; - QSignalSpy spy(&t, &Tag::nameChanged); - t.setName(QStringLiteral("foo")); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.first().first().toString(), QStringLiteral("foo")); - } - - void shouldNotNotifyIdenticalNameChanges() - { - Tag t; - t.setName(QStringLiteral("foo")); - QSignalSpy spy(&t, &Tag::nameChanged); - t.setName(QStringLiteral("foo")); - QCOMPARE(spy.count(), 0); - } -}; - -ZANSHIN_TEST_MAIN(TagTest) - -#include "tagtest.moc" diff --git a/tests/units/presentation/CMakeLists.txt b/tests/units/presentation/CMakeLists.txt --- a/tests/units/presentation/CMakeLists.txt +++ b/tests/units/presentation/CMakeLists.txt @@ -2,19 +2,16 @@ applicationmodeltest artifacteditormodeltest artifactfilterproxymodeltest - availablenotepagesmodeltest availablepagessortfilterproxymodeltest availablesourcesmodeltest availabletaskpagesmodeltest errorhandlertest errorhandlingmodelbasetest metatypestest - noteinboxpagemodeltest pagemodeltest projectpagemodeltest querytreemodeltest runningtaskmodeltest - tagpagemodeltest taskapplicationmodeltest taskinboxpagemodeltest tasklistmodeltest diff --git a/tests/units/presentation/artifacteditormodeltest.cpp b/tests/units/presentation/artifacteditormodeltest.cpp --- a/tests/units/presentation/artifacteditormodeltest.cpp +++ b/tests/units/presentation/artifacteditormodeltest.cpp @@ -31,7 +31,6 @@ #include "testlib/fakejob.h" #include "domain/task.h" -#include "domain/note.h" #include "presentation/artifacteditormodel.h" #include "presentation/errorhandler.h" @@ -167,67 +166,13 @@ QCOMPARE(am->data(am->index(1, 0), Qt::DecorationRole).value<QIcon>(), QIcon::fromTheme("text-html")); } - void shouldHaveNoteProperties() - { - // GIVEN - Presentation::ArtifactEditorModel model; - QSignalSpy textSpy(&model, &Presentation::ArtifactEditorModel::textChanged); - QSignalSpy titleSpy(&model, &Presentation::ArtifactEditorModel::titleChanged); - QSignalSpy doneSpy(&model, &Presentation::ArtifactEditorModel::doneChanged); - QSignalSpy startSpy(&model, &Presentation::ArtifactEditorModel::startDateChanged); - QSignalSpy dueSpy(&model, &Presentation::ArtifactEditorModel::dueDateChanged); - - auto note = Domain::Note::Ptr::create(); - note->setText(QStringLiteral("description")); - note->setTitle(QStringLiteral("title")); - - // WHEN - model.setArtifact(note); - // To make sure we don't signal too much - model.setText(note->text()); - model.setTitle(note->title()); - - // THEN - QVERIFY(!model.hasTaskProperties()); - - QCOMPARE(textSpy.size(), 1); - QCOMPARE(textSpy.takeFirst().at(0).toString(), note->text()); - QCOMPARE(model.property("text").toString(), note->text()); - - QCOMPARE(titleSpy.size(), 1); - QCOMPARE(titleSpy.takeFirst().at(0).toString(), note->title()); - QCOMPARE(model.property("title").toString(), note->title()); - - QCOMPARE(doneSpy.size(), 1); - QCOMPARE(doneSpy.takeFirst().at(0).toBool(), false); - QCOMPARE(model.property("done").toBool(), false); - - QCOMPARE(startSpy.size(), 1); - QVERIFY(startSpy.takeFirst().at(0).toDate().isNull()); - QVERIFY(model.property("startDate").toDate().isNull()); - - QCOMPARE(dueSpy.size(), 1); - QVERIFY(dueSpy.takeFirst().at(0).toDate().isNull()); - QVERIFY(model.property("dueDate").toDate().isNull()); - } - void shouldReactToArtifactPropertyChanges_data() { QTest::addColumn<Domain::Artifact::Ptr>("artifact"); QTest::addColumn<QByteArray>("propertyName"); QTest::addColumn<QVariant>("propertyValue"); QTest::addColumn<QByteArray>("signal"); - QTest::newRow("note text") << Domain::Artifact::Ptr(Domain::Note::Ptr::create()) - << QByteArray("text") - << QVariant("new text") - << QByteArray(SIGNAL(textChanged(QString))); - - QTest::newRow("note title") << Domain::Artifact::Ptr(Domain::Note::Ptr::create()) - << QByteArray("title") - << QVariant("new title") - << QByteArray(SIGNAL(titleChanged(QString))); - QTest::newRow("task text") << Domain::Artifact::Ptr(Domain::Task::Ptr::create()) << QByteArray("text") << QVariant("new text") diff --git a/tests/units/presentation/artifactfilterproxymodeltest.cpp b/tests/units/presentation/artifactfilterproxymodeltest.cpp --- a/tests/units/presentation/artifactfilterproxymodeltest.cpp +++ b/tests/units/presentation/artifactfilterproxymodeltest.cpp @@ -25,7 +25,6 @@ #include <QStandardItemModel> -#include "domain/note.h" #include "domain/task.h" #include "presentation/artifactfilterproxymodel.h" @@ -55,19 +54,6 @@ return item; } - QStandardItem *createNoteItem(const QString &title, const QString &text) const - { - auto note = Domain::Note::Ptr::create(); - note->setTitle(title); - note->setText(text); - - auto item = new QStandardItem; - item->setData(note->title(), Qt::DisplayRole); - item->setData(QVariant::fromValue(Domain::Artifact::Ptr(note)), - Presentation::QueryTreeModelBase::ObjectRole); - return item; - } - private slots: void initTestCase() { @@ -92,22 +78,17 @@ input.appendRow(createTaskItem(QStringLiteral("1. foo"), QStringLiteral("find me"))); input.appendRow(createTaskItem(QStringLiteral("2. Find Me"), QStringLiteral("bar"))); input.appendRow(createTaskItem(QStringLiteral("3. baz"), QStringLiteral("baz"))); - input.appendRow(createNoteItem(QStringLiteral("4. foo"), QStringLiteral("find me"))); - input.appendRow(createNoteItem(QStringLiteral("5. find me"), QStringLiteral("bar"))); - input.appendRow(createNoteItem(QStringLiteral("6. baz"), QStringLiteral("baz"))); Presentation::ArtifactFilterProxyModel output; output.setSourceModel(&input); // WHEN output.setFilterFixedString(QStringLiteral("find me")); // THEN - QCOMPARE(output.rowCount(), 4); + QCOMPARE(output.rowCount(), 2); QCOMPARE(output.index(0, 0).data().toString(), QStringLiteral("1. foo")); QCOMPARE(output.index(1, 0).data().toString(), QStringLiteral("2. Find Me")); - QCOMPARE(output.index(2, 0).data().toString(), QStringLiteral("4. foo")); - QCOMPARE(output.index(3, 0).data().toString(), QStringLiteral("5. find me")); } void shouldFilterByStartDate() @@ -150,8 +131,7 @@ input.appendRow(createTaskItem(QStringLiteral("1. foo"), QStringLiteral("find me"))); QStandardItem *item = createTaskItem(QStringLiteral("2. baz"), QStringLiteral("baz")); item->appendRow(createTaskItem(QStringLiteral("21. bar"), QStringLiteral("bar"))); - item->appendRow(createNoteItem(QStringLiteral("22. foo"), QStringLiteral("Find Me"))); - item->appendRow(createTaskItem(QStringLiteral("23. find me"), QStringLiteral("foo"))); + item->appendRow(createTaskItem(QStringLiteral("22. find me"), QStringLiteral("foo"))); input.appendRow(item); input.appendRow(createTaskItem(QStringLiteral("3. baz"), QStringLiteral("baz"))); @@ -167,9 +147,8 @@ QCOMPARE(output.index(1, 0).data().toString(), QStringLiteral("2. baz")); const QModelIndex parent = output.index(1, 0); - QCOMPARE(output.rowCount(parent), 2); - QCOMPARE(output.index(0, 0, parent).data().toString(), QStringLiteral("22. foo")); - QCOMPARE(output.index(1, 0, parent).data().toString(), QStringLiteral("23. find me")); + QCOMPARE(output.rowCount(parent), 1); + QCOMPARE(output.index(0, 0, parent).data().toString(), QStringLiteral("22. find me")); } void shouldSortFollowingType_data() @@ -184,60 +163,56 @@ inputItems.clear(); expectedOutputTitles.clear(); - inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo")) << createNoteItem(QStringLiteral("A"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo")); - expectedOutputTitles << QStringLiteral("A") << QStringLiteral("B") << QStringLiteral("C"); + inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo")); + expectedOutputTitles << QStringLiteral("B") << QStringLiteral("C"); QTest::newRow("title ascending") << int(Presentation::ArtifactFilterProxyModel::TitleSort) << int(Qt::AscendingOrder) << inputItems << expectedOutputTitles; inputItems.clear(); expectedOutputTitles.clear(); - inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo")) << createNoteItem(QStringLiteral("A"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo")); - expectedOutputTitles << QStringLiteral("C") << QStringLiteral("B") << QStringLiteral("A"); + inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo")); + expectedOutputTitles << QStringLiteral("C") << QStringLiteral("B"); QTest::newRow("title descending") << int(Presentation::ArtifactFilterProxyModel::TitleSort) << int(Qt::DescendingOrder) << inputItems << expectedOutputTitles; inputItems.clear(); expectedOutputTitles.clear(); inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo"), QDate(2014, 03, 10)) - << createNoteItem(QStringLiteral("A"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo"), QDate(2014, 03, 01)) << createTaskItem(QStringLiteral("D"), QStringLiteral("foo")); - expectedOutputTitles << QStringLiteral("C") << QStringLiteral("B") << QStringLiteral("D") << QStringLiteral("A"); + expectedOutputTitles << QStringLiteral("C") << QStringLiteral("B") << QStringLiteral("D"); QTest::newRow("start date ascending") << int(Presentation::ArtifactFilterProxyModel::DateSort) << int(Qt::AscendingOrder) << inputItems << expectedOutputTitles; inputItems.clear(); expectedOutputTitles.clear(); inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo"), QDate(2014, 03, 10)) - << createNoteItem(QStringLiteral("A"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo"), QDate(2014, 03, 01)) << createTaskItem(QStringLiteral("D"), QStringLiteral("foo")); - expectedOutputTitles << QStringLiteral("A") << QStringLiteral("D") << QStringLiteral("B") << QStringLiteral("C"); + expectedOutputTitles << QStringLiteral("D") << QStringLiteral("B") << QStringLiteral("C"); QTest::newRow("start date descending") << int(Presentation::ArtifactFilterProxyModel::DateSort) << int(Qt::DescendingOrder) << inputItems << expectedOutputTitles; inputItems.clear(); expectedOutputTitles.clear(); inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo"), QDate(), QDate(2014, 03, 10)) - << createNoteItem(QStringLiteral("A"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo"), QDate(), QDate(2014, 03, 01)) << createTaskItem(QStringLiteral("D"), QStringLiteral("foo")); - expectedOutputTitles << QStringLiteral("C") << QStringLiteral("B") << QStringLiteral("D") << QStringLiteral("A"); + expectedOutputTitles << QStringLiteral("C") << QStringLiteral("B") << QStringLiteral("D"); QTest::newRow("due date ascending") << int(Presentation::ArtifactFilterProxyModel::DateSort) << int(Qt::AscendingOrder) << inputItems << expectedOutputTitles; inputItems.clear(); expectedOutputTitles.clear(); inputItems << createTaskItem(QStringLiteral("B"), QStringLiteral("foo"), QDate(), QDate(2014, 03, 10)) - << createNoteItem(QStringLiteral("A"), QStringLiteral("foo")) << createTaskItem(QStringLiteral("C"), QStringLiteral("foo"), QDate(), QDate(2014, 03, 01)) << createTaskItem(QStringLiteral("D"), QStringLiteral("foo")); - expectedOutputTitles << QStringLiteral("A") << QStringLiteral("D") << QStringLiteral("B") << QStringLiteral("C"); + expectedOutputTitles << QStringLiteral("D") << QStringLiteral("B") << QStringLiteral("C"); QTest::newRow("due date descending") << int(Presentation::ArtifactFilterProxyModel::DateSort) << int(Qt::DescendingOrder) << inputItems << expectedOutputTitles; diff --git a/tests/units/presentation/availablenotepagesmodeltest.cpp b/tests/units/presentation/availablenotepagesmodeltest.cpp deleted file mode 100644 --- a/tests/units/presentation/availablenotepagesmodeltest.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include <memory> - -#include <QMimeData> - -#include <KLocalizedString> - -#include "utils/mockobject.h" - -#include "presentation/availablenotepagesmodel.h" -#include "presentation/errorhandler.h" -#include "presentation/noteinboxpagemodel.h" -#include "presentation/querytreemodelbase.h" -#include "presentation/tagpagemodel.h" - -#include "testlib/fakejob.h" - -using namespace mockitopp; -using namespace mockitopp::matcher; - -class FakeErrorHandler : public Presentation::ErrorHandler -{ -public: - void doDisplayMessage(const QString &message) override - { - m_message = message; - } - - QString m_message; -}; - -class AvailableNotePagesModelTest : public QObject -{ - Q_OBJECT -private slots: - void shouldDeclareOnlyProjectAndContextPages() - { - // GIVEN - Presentation::AvailableNotePagesModel pages({}, {}, {}, {}); - - // THEN - QVERIFY(!pages.hasProjectPages()); - QVERIFY(!pages.hasContextPages()); - QVERIFY(pages.hasTagPages()); - } - - void shouldListAvailablePages() - { - // GIVEN - - // Two tags - auto tag1 = Domain::Tag::Ptr::create(); - tag1->setName(QStringLiteral("Tag 1")); - auto tag2 = Domain::Tag::Ptr::create(); - tag2->setName(QStringLiteral("Tag 2")); - auto tagProvider = Domain::QueryResultProvider<Domain::Tag::Ptr>::Ptr::create(); - auto tagResult = Domain::QueryResult<Domain::Tag::Ptr>::create(tagProvider); - tagProvider->append(tag1); - tagProvider->append(tag2); - - // One note (used for dropping later on) - auto noteToDrop = Domain::Note::Ptr::create(); - - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findAll).when().thenReturn(tagResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance()); - - // WHEN - QAbstractItemModel *model = pages.pageListModel(); - - // THEN - const QModelIndex inboxIndex = model->index(0, 0); - const QModelIndex tagsIndex = model->index(1, 0); - const QModelIndex tag1Index = model->index(0, 0, tagsIndex); - const QModelIndex tag2Index = model->index(1, 0, tagsIndex); - - QCOMPARE(model->rowCount(), 2); - QCOMPARE(model->rowCount(inboxIndex), 0); - QCOMPARE(model->rowCount(tagsIndex), 2); - QCOMPARE(model->rowCount(tag1Index), 0); - - const Qt::ItemFlags defaultFlags = Qt::ItemIsSelectable - | Qt::ItemIsEnabled - | Qt::ItemIsEditable; - QCOMPARE(model->flags(inboxIndex), (defaultFlags & ~(Qt::ItemIsEditable)) | Qt::ItemIsDropEnabled); - QCOMPARE(model->flags(tagsIndex), Qt::NoItemFlags); - QCOMPARE(model->flags(tag1Index), defaultFlags | Qt::ItemIsDropEnabled); - QCOMPARE(model->flags(tag2Index), defaultFlags | Qt::ItemIsDropEnabled); - - QCOMPARE(model->data(inboxIndex).toString(), i18n("Inbox")); - QCOMPARE(model->data(tagsIndex).toString(), i18n("Tags")); - QCOMPARE(model->data(tag1Index).toString(), tag1->name()); - QCOMPARE(model->data(tag2Index).toString(), tag2->name()); - - QVERIFY(!model->data(inboxIndex, Qt::EditRole).isValid()); - QVERIFY(!model->data(tagsIndex, Qt::EditRole).isValid()); - QCOMPARE(model->data(tag1Index, Qt::EditRole).toString(), tag1->name()); - QCOMPARE(model->data(tag2Index, Qt::EditRole).toString(), tag2->name()); - - QCOMPARE(model->data(inboxIndex, Presentation::QueryTreeModelBase::IconNameRole).toString(), QStringLiteral("mail-folder-inbox")); - QCOMPARE(model->data(tagsIndex, Presentation::QueryTreeModelBase::IconNameRole).toString(), QStringLiteral("folder")); - QCOMPARE(model->data(tag1Index, Presentation::QueryTreeModelBase::IconNameRole).toString(), QStringLiteral("view-pim-tasks")); - QCOMPARE(model->data(tag2Index, Presentation::QueryTreeModelBase::IconNameRole).toString(), QStringLiteral("view-pim-tasks")); - - QVERIFY(!model->data(inboxIndex, Qt::CheckStateRole).isValid()); - QVERIFY(!model->data(tagsIndex, Qt::CheckStateRole).isValid()); - QVERIFY(!model->data(tag1Index, Qt::CheckStateRole).isValid()); - QVERIFY(!model->data(tag2Index, Qt::CheckStateRole).isValid()); - - QVERIFY(!model->setData(inboxIndex, "foo", Qt::EditRole)); - QVERIFY(!model->setData(tagsIndex, "foo", Qt::EditRole)); - QVERIFY(!model->setData(tag1Index, "foo", Qt::EditRole)); - QVERIFY(!model->setData(tag2Index, "foo", Qt::EditRole)); - - // WHEN - tagRepositoryMock(&Domain::TagRepository::associate).when(tag1, noteToDrop).thenReturn(new FakeJob(this)); - auto data = std::make_unique<QMimeData>(); - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << noteToDrop)); - model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, tag1Index); - - // THEN - QVERIFY(tagRepositoryMock(&Domain::TagRepository::associate).when(tag1, noteToDrop).exactly(1)); - - // WHEN - tagRepositoryMock(&Domain::TagRepository::dissociateAll).when(noteToDrop).thenReturn(new FakeJob(this)); - data.reset(new QMimeData); - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << noteToDrop)); - model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, inboxIndex); - QTest::qWait(150); - - // THEN - QVERIFY(tagRepositoryMock(&Domain::TagRepository::dissociateAll).when(noteToDrop).exactly(1)); - } - - void shouldCreateInboxPage() - { - // GIVEN - - // Empty tag provider - auto tagProvider = Domain::QueryResultProvider<Domain::Tag::Ptr>::Ptr::create(); - auto tagResult = Domain::QueryResult<Domain::Tag::Ptr>::create(tagProvider); - - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findAll).when().thenReturn(tagResult); - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - tagQueriesMock.getInstance(), - Domain::TagRepository::Ptr()); - - // WHEN - QAbstractItemModel *model = pages.pageListModel(); - - // THEN - const QModelIndex inboxIndex = model->index(0, 0); - - QObject *inboxPage = pages.createPageForIndex(inboxIndex); - QVERIFY(qobject_cast<Presentation::NoteInboxPageModel*>(inboxPage)); - } - - void shouldCreateTagsPage() - { - // GIVEN - - // Two tags - auto tag1 = Domain::Tag::Ptr::create(); - tag1->setName(QStringLiteral("tag 1")); - auto tag2 = Domain::Tag::Ptr::create(); - tag2->setName(QStringLiteral("tag 2")); - auto tagProvider = Domain::QueryResultProvider<Domain::Tag::Ptr>::Ptr::create(); - auto tagResult = Domain::QueryResult<Domain::Tag::Ptr>::create(tagProvider); - tagProvider->append(tag1); - tagProvider->append(tag2); - - // tags mocking - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findAll).when().thenReturn(tagResult); - - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - tagQueriesMock.getInstance(), - Domain::TagRepository::Ptr()); - - // WHEN - QAbstractItemModel *model = pages.pageListModel(); - - // THEN - const QModelIndex tagsIndex = model->index(1, 0); - const QModelIndex tag1Index = model->index(0, 0, tagsIndex); - const QModelIndex tag2Index = model->index(1, 0, tagsIndex); - - QObject *tagsPage = pages.createPageForIndex(tagsIndex); - QObject *tag1Page = pages.createPageForIndex(tag1Index); - QObject *tag2Page = pages.createPageForIndex(tag2Index); - - QVERIFY(!tagsPage); - QVERIFY(qobject_cast<Presentation::TagPageModel*>(tag1Page)); - QCOMPARE(qobject_cast<Presentation::TagPageModel*>(tag1Page)->tag(), tag1); - QVERIFY(qobject_cast<Presentation::TagPageModel*>(tag2Page)); - QCOMPARE(qobject_cast<Presentation::TagPageModel*>(tag2Page)->tag(), tag2); - } - - void shouldAddTags() - { - // GIVEN - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - tagRepositoryMock(&Domain::TagRepository::create).when(any<Domain::Tag::Ptr>()) - .thenReturn(new FakeJob(this)); - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - Domain::TagQueries::Ptr(), - tagRepositoryMock.getInstance()); - - // WHEN - pages.addTag(QStringLiteral("Foo")); - - // THEN - QVERIFY(tagRepositoryMock(&Domain::TagRepository::create).when(any<Domain::Tag::Ptr>()) - .exactly(1)); - } - - void shouldGetAnErrorMessageWhenAddTagFailed() - { - // GIVEN - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - tagRepositoryMock(&Domain::TagRepository::create).when(any<Domain::Tag::Ptr>()) - .thenReturn(job); - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - Domain::TagQueries::Ptr(), - tagRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - pages.setErrorHandler(&errorHandler); - - // WHEN - pages.addTag(QStringLiteral("Foo")); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot add tag Foo: Foo")); - } - - void shouldRemoveTag() - { - // GIVEN - - // Two tags - auto tag1 = Domain::Tag::Ptr::create(); - tag1->setName(QStringLiteral("tag 1")); - auto tag2 = Domain::Tag::Ptr::create(); - tag2->setName(QStringLiteral("tag 2")); - auto tagProvider = Domain::QueryResultProvider<Domain::Tag::Ptr>::Ptr::create(); - auto tagResult = Domain::QueryResult<Domain::Tag::Ptr>::create(tagProvider); - tagProvider->append(tag1); - tagProvider->append(tag2); - - // tags mocking - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findAll).when().thenReturn(tagResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - pages.setErrorHandler(&errorHandler); - - QAbstractItemModel *model = pages.pageListModel(); - - const QModelIndex tagsIndex = model->index(1, 0); - const QModelIndex tag1Index = model->index(0, 0, tagsIndex); - - auto job = new FakeJob(this); - tagRepositoryMock(&Domain::TagRepository::remove).when(tag1).thenReturn(job); - - // WHEN - pages.removeItem(tag1Index); - - // THEN - QTest::qWait(150); - QVERIFY(errorHandler.m_message.isEmpty()); - QVERIFY(tagRepositoryMock(&Domain::TagRepository::remove).when(tag1).exactly(1)); - } - - void shouldGetAnErrorMessageWhenRemoveTagFailed() - { - // GIVEN - - // Two tags - auto tag1 = Domain::Tag::Ptr::create(); - tag1->setName(QStringLiteral("tag 1")); - auto tag2 = Domain::Tag::Ptr::create(); - tag2->setName(QStringLiteral("tag 2")); - auto tagProvider = Domain::QueryResultProvider<Domain::Tag::Ptr>::Ptr::create(); - auto tagResult = Domain::QueryResult<Domain::Tag::Ptr>::create(tagProvider); - tagProvider->append(tag1); - tagProvider->append(tag2); - - // tags mocking - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findAll).when().thenReturn(tagResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - pages.setErrorHandler(&errorHandler); - - QAbstractItemModel *model = pages.pageListModel(); - - const QModelIndex tagsIndex = model->index(1, 0); - const QModelIndex tag1Index = model->index(0, 0, tagsIndex); - - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - tagRepositoryMock(&Domain::TagRepository::remove).when(tag1).thenReturn(job); - - // WHEN - pages.removeItem(tag1Index); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot remove tag tag 1: Foo")); - } - - void shouldGetAnErrorMessageWhenAssociateTagFailed() - { - // GIVEN - - // Two tags - auto tag1 = Domain::Tag::Ptr::create(); - tag1->setName(QStringLiteral("Tag 1")); - auto tag2 = Domain::Tag::Ptr::create(); - tag2->setName(QStringLiteral("Tag 2")); - auto tagProvider = Domain::QueryResultProvider<Domain::Tag::Ptr>::Ptr::create(); - auto tagResult = Domain::QueryResult<Domain::Tag::Ptr>::create(tagProvider); - tagProvider->append(tag1); - tagProvider->append(tag2); - - // One note (used for dropping later on) - auto noteToDrop = Domain::Note::Ptr::create(); - noteToDrop->setTitle(QStringLiteral("noteDropped")); - - // tags mocking - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findAll).when().thenReturn(tagResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - pages.setErrorHandler(&errorHandler); - - QAbstractItemModel *model = pages.pageListModel(); - const QModelIndex tagsIndex = model->index(1, 0); - const QModelIndex tag1Index = model->index(0, 0, tagsIndex); - - // WHEN - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - tagRepositoryMock(&Domain::TagRepository::associate).when(tag1, noteToDrop).thenReturn(job); - auto data = std::make_unique<QMimeData>(); - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << noteToDrop)); - model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, tag1Index); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot tag noteDropped with Tag 1: Foo")); - } - - void shouldGetAnErrorMessageWhenDissociateTaskFailed() - { - // GIVEN - - // Two tags - auto tag1 = Domain::Tag::Ptr::create(); - tag1->setName(QStringLiteral("tag 1")); - auto tag2 = Domain::Tag::Ptr::create(); - tag2->setName(QStringLiteral("tag 2")); - auto tagProvider = Domain::QueryResultProvider<Domain::Tag::Ptr>::Ptr::create(); - auto tagResult = Domain::QueryResult<Domain::Tag::Ptr>::create(tagProvider); - tagProvider->append(tag1); - tagProvider->append(tag2); - - // One note (used for dropping later on) - auto noteToDrop = Domain::Note::Ptr::create(); - noteToDrop->setTitle(QStringLiteral("noteDropped")); - - // tags mocking - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findAll).when().thenReturn(tagResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - Presentation::AvailableNotePagesModel pages(Domain::NoteQueries::Ptr(), - Domain::NoteRepository::Ptr(), - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - pages.setErrorHandler(&errorHandler); - - QAbstractItemModel *model = pages.pageListModel(); - const QModelIndex inboxIndex = model->index(0, 0); - - // WHEN - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - tagRepositoryMock(&Domain::TagRepository::dissociateAll).when(noteToDrop).thenReturn(job); - auto data = std::make_unique<QMimeData>(); - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << noteToDrop)); - model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, inboxIndex); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot move noteDropped to Inbox: Foo")); - } -}; - -ZANSHIN_TEST_MAIN(AvailableNotePagesModelTest) - -#include "availablenotepagesmodeltest.moc" diff --git a/tests/units/presentation/availablepagessortfilterproxymodeltest.cpp b/tests/units/presentation/availablepagessortfilterproxymodeltest.cpp --- a/tests/units/presentation/availablepagessortfilterproxymodeltest.cpp +++ b/tests/units/presentation/availablepagessortfilterproxymodeltest.cpp @@ -33,10 +33,6 @@ #include "domain/contextrepository.h" #include "domain/projectqueries.h" #include "domain/projectrepository.h" -#include "domain/note.h" -#include "domain/tag.h" -#include "domain/tagqueries.h" -#include "domain/tagrepository.h" #include "domain/task.h" #include "domain/taskrepository.h" diff --git a/tests/units/presentation/availabletaskpagesmodeltest.cpp b/tests/units/presentation/availabletaskpagesmodeltest.cpp --- a/tests/units/presentation/availabletaskpagesmodeltest.cpp +++ b/tests/units/presentation/availabletaskpagesmodeltest.cpp @@ -32,8 +32,6 @@ #include "utils/mockobject.h" #include "utils/datetime.h" -#include "domain/note.h" - #include "presentation/availabletaskpagesmodel.h" #include "presentation/contextpagemodel.h" #include "presentation/errorhandler.h" @@ -117,9 +115,8 @@ contextProvider->append(context1); contextProvider->append(context2); - // Two artifacts (used for dropping later on) + // One artifact (used for dropping later on) Domain::Artifact::Ptr taskToDrop(new Domain::Task); - Domain::Artifact::Ptr noteToDrop(new Domain::Note); Utils::MockObject<Domain::DataSourceQueries> dataSourceQueriesMock; dataSourceQueriesMock(&Domain::DataSourceQueries::findAllSelected).when().thenReturn(sourceResult); @@ -309,38 +306,16 @@ QVERIFY(projectRepositoryMock(&Domain::ProjectRepository::dissociate).when(taskToDrop).exactly(1)); QVERIFY(taskRepositoryMock(&Domain::TaskRepository::dissociateAll).when(taskToDrop.objectCast<Domain::Task>()).exactly(1)); - // WHEN - projectRepositoryMock(&Domain::ProjectRepository::associate).when(project12, noteToDrop).thenReturn(new FakeJob(this)); - data.reset(new QMimeData); - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << noteToDrop)); - model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, project12Index); - - // THEN - QVERIFY(projectRepositoryMock(&Domain::ProjectRepository::associate).when(project12, noteToDrop).exactly(1)); - // WHEN Domain::Artifact::Ptr taskToDrop2(new Domain::Task); - Domain::Artifact::Ptr noteToDrop2(new Domain::Note); projectRepositoryMock(&Domain::ProjectRepository::associate).when(project11, taskToDrop2).thenReturn(new FakeJob(this)); - projectRepositoryMock(&Domain::ProjectRepository::associate).when(project11, noteToDrop2).thenReturn(new FakeJob(this)); data.reset(new QMimeData); data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << taskToDrop2 << noteToDrop2)); + data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << taskToDrop2)); model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, project11Index); // THEN QVERIFY(projectRepositoryMock(&Domain::ProjectRepository::associate).when(project11, taskToDrop2).exactly(1)); - QVERIFY(projectRepositoryMock(&Domain::ProjectRepository::associate).when(project11, noteToDrop2).exactly(1)); - - // WHEN a task and a note are dropped on a context - data.reset(new QMimeData); - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << taskToDrop2 << noteToDrop2)); - model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, context1Index); - - // THEN - QVERIFY(contextRepositoryMock(&Domain::ContextRepository::associate).when(context1, taskToDrop2.objectCast<Domain::Task>()).exactly(0)); // WHEN two tasks are dropped on a context Domain::Task::Ptr taskToDrop3(new Domain::Task); diff --git a/tests/units/presentation/contextpagemodeltest.cpp b/tests/units/presentation/contextpagemodeltest.cpp --- a/tests/units/presentation/contextpagemodeltest.cpp +++ b/tests/units/presentation/contextpagemodeltest.cpp @@ -37,7 +37,6 @@ #include "domain/contextrepository.h" #include "domain/taskqueries.h" #include "domain/taskrepository.h" -#include "domain/noterepository.h" #include "presentation/contextpagemodel.h" #include "presentation/errorhandler.h" @@ -228,7 +227,6 @@ QCOMPARE(task1->title(), QStringLiteral("newTask1")); QCOMPARE(task2->title(), QStringLiteral("newTask2")); - // WHEN a task is dragged auto data = std::unique_ptr<QMimeData>(model->mimeData(QModelIndexList() << task2Index)); @@ -261,17 +259,6 @@ // THEN QVERIFY(taskRepositoryMock(&Domain::TaskRepository::associate).when(task1, childTask3).exactly(1)); QVERIFY(taskRepositoryMock(&Domain::TaskRepository::associate).when(task1, childTask4).exactly(1)); - - // WHEN a task and a note are dropped - Domain::Artifact::Ptr childTask5(new Domain::Task); - Domain::Artifact::Ptr childNote(new Domain::Note); - data.reset(new QMimeData); - data->setData(QStringLiteral("application/x-zanshin-object"), "object"); - data->setProperty("objects", QVariant::fromValue(Domain::Artifact::List() << childTask5 << childNote)); - model->dropMimeData(data.get(), Qt::MoveAction, -1, -1, task1Index); - - // THEN - QVERIFY(taskRepositoryMock(&Domain::TaskRepository::associate).when(task1, childTask5.objectCast<Domain::Task>()).exactly(0)); } void shouldAddTasksInContext() diff --git a/tests/units/presentation/noteinboxpagemodeltest.cpp b/tests/units/presentation/noteinboxpagemodeltest.cpp deleted file mode 100644 --- a/tests/units/presentation/noteinboxpagemodeltest.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include <memory> - -#include <QMimeData> - -#include "utils/mockobject.h" - -#include "presentation/noteinboxpagemodel.h" -#include "presentation/errorhandler.h" - -#include "testlib/fakejob.h" - -using namespace mockitopp; -using namespace mockitopp::matcher; - -class FakeErrorHandler : public Presentation::ErrorHandler -{ -public: - void doDisplayMessage(const QString &message) override - { - m_message = message; - } - - QString m_message; -}; - -class NoteInboxPageModelTest : public QObject -{ - Q_OBJECT -private slots: - void shouldListInboxInCentralListModel() - { - // GIVEN - - // Two notes - auto note1 = Domain::Note::Ptr::create(); - note1->setTitle(QStringLiteral("note1")); - auto note2 = Domain::Note::Ptr::create(); - note2->setTitle(QStringLiteral("note2")); - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(note1); - noteProvider->append(note2); - - Utils::MockObject<Domain::NoteQueries> noteQueriesMock; - noteQueriesMock(&Domain::NoteQueries::findInbox).when().thenReturn(noteResult); - - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - - Presentation::NoteInboxPageModel inbox(noteQueriesMock.getInstance(), - noteRepositoryMock.getInstance()); - - // WHEN - QAbstractItemModel *model = inbox.centralListModel(); - - // THEN - const QModelIndex note1Index = model->index(0, 0); - const QModelIndex note2Index = model->index(1, 0); - - QCOMPARE(model->rowCount(), 2); - QCOMPARE(model->rowCount(note1Index), 0); - QCOMPARE(model->rowCount(note2Index), 0); - - const Qt::ItemFlags defaultFlags = Qt::ItemIsSelectable - | Qt::ItemIsEnabled - | Qt::ItemIsEditable - | Qt::ItemIsDragEnabled; - QCOMPARE(model->flags(note1Index), defaultFlags); - QCOMPARE(model->flags(note2Index), defaultFlags); - - QCOMPARE(model->data(note1Index).toString(), note1->title()); - QCOMPARE(model->data(note2Index).toString(), note2->title()); - - QCOMPARE(model->data(note1Index, Qt::EditRole).toString(), note1->title()); - QCOMPARE(model->data(note2Index, Qt::EditRole).toString(), note2->title()); - - QVERIFY(!model->data(note1Index, Qt::CheckStateRole).isValid()); - QVERIFY(!model->data(note2Index, Qt::CheckStateRole).isValid()); - - // WHEN - noteRepositoryMock(&Domain::NoteRepository::update).when(note1).thenReturn(new FakeJob(this)); - noteRepositoryMock(&Domain::NoteRepository::update).when(note2).thenReturn(new FakeJob(this)); - - QVERIFY(model->setData(note1Index, "newNote1")); - QVERIFY(model->setData(note2Index, "newNote2")); - - QVERIFY(!model->setData(note1Index, Qt::Checked, Qt::CheckStateRole)); - QVERIFY(!model->setData(note2Index, Qt::Checked, Qt::CheckStateRole)); - - // THEN - QVERIFY(noteRepositoryMock(&Domain::NoteRepository::update).when(note1).exactly(1)); - QVERIFY(noteRepositoryMock(&Domain::NoteRepository::update).when(note2).exactly(1)); - - QCOMPARE(note1->title(), QStringLiteral("newNote1")); - QCOMPARE(note2->title(), QStringLiteral("newNote2")); - - // WHEN - auto data = std::unique_ptr<QMimeData>(model->mimeData(QModelIndexList() << note2Index)); - - // THEN - QVERIFY(data->hasFormat(QStringLiteral("application/x-zanshin-object"))); - QCOMPARE(data->property("objects").value<Domain::Artifact::List>(), - Domain::Artifact::List() << note2); - } - - void shouldAddNotes() - { - // GIVEN - - // ... in fact we won't list any model - Utils::MockObject<Domain::NoteQueries> noteQueriesMock; - - // We'll gladly create a note though - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - noteRepositoryMock(&Domain::NoteRepository::create).when(any<Domain::Note::Ptr>()).thenReturn(new FakeJob(this)); - - - Presentation::NoteInboxPageModel inbox(noteQueriesMock.getInstance(), - noteRepositoryMock.getInstance()); - - // WHEN - auto title = QStringLiteral("New note"); - auto note = inbox.addItem(title).objectCast<Domain::Note>(); - - // THEN - QVERIFY(noteRepositoryMock(&Domain::NoteRepository::create).when(any<Domain::Note::Ptr>()).exactly(1)); - QVERIFY(note); - QCOMPARE(note->title(), title); - } - - void shouldGetAnErrorMessageWhenAddNoteFailed() - { - // GIVEN - - // ... in fact we won't list any model - Utils::MockObject<Domain::NoteQueries> noteQueriesMock; - - // We'll gladly create a note though - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - noteRepositoryMock(&Domain::NoteRepository::create).when(any<Domain::Note::Ptr>()).thenReturn(job); - - Presentation::NoteInboxPageModel inbox(noteQueriesMock.getInstance(), - noteRepositoryMock.getInstance()); - - FakeErrorHandler errorHandler; - inbox.setErrorHandler(&errorHandler); - - // WHEN - inbox.addItem(QStringLiteral("New note")); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot add note New note in Inbox: Foo")); - } - - void shouldDeleteItems() - { - // GIVEN - - // Two notes - auto note1 = Domain::Note::Ptr::create(); - note1->setTitle(QStringLiteral("note1")); - auto note2 = Domain::Note::Ptr::create(); - note2->setTitle(QStringLiteral("note2")); - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(note1); - noteProvider->append(note2); - - Utils::MockObject<Domain::NoteQueries> noteQueriesMock; - noteQueriesMock(&Domain::NoteQueries::findInbox).when().thenReturn(noteResult); - - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - noteRepositoryMock(&Domain::NoteRepository::remove).when(note2).thenReturn(new FakeJob(this)); - - Presentation::NoteInboxPageModel inbox(noteQueriesMock.getInstance(), - noteRepositoryMock.getInstance()); - - // WHEN - const QModelIndex index = inbox.centralListModel()->index(1, 0); - inbox.removeItem(index); - - // THEN - QVERIFY(noteRepositoryMock(&Domain::NoteRepository::remove).when(note2).exactly(1)); - } - - void shouldGetAnErrorMessageWhenDeleteItemsFailed() - { - // GIVEN - - // Two notes - auto note1 = Domain::Note::Ptr::create(); - note1->setTitle(QStringLiteral("note1")); - auto note2 = Domain::Note::Ptr::create(); - note2->setTitle(QStringLiteral("note2")); - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(note1); - noteProvider->append(note2); - - Utils::MockObject<Domain::NoteQueries> noteQueriesMock; - noteQueriesMock(&Domain::NoteQueries::findInbox).when().thenReturn(noteResult); - - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - noteRepositoryMock(&Domain::NoteRepository::remove).when(note2).thenReturn(job); - - Presentation::NoteInboxPageModel inbox(noteQueriesMock.getInstance(), - noteRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - inbox.setErrorHandler(&errorHandler); - - // WHEN - const QModelIndex index = inbox.centralListModel()->index(1, 0); - inbox.removeItem(index); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot remove note note2 from Inbox: Foo")); - } - - void shouldGetAnErrorMessageWhenUpdateNoteFailed() - { - // GIVEN - - // Two notes - auto note1 = Domain::Note::Ptr::create(); - note1->setTitle(QStringLiteral("note1")); - auto note2 = Domain::Note::Ptr::create(); - note2->setTitle(QStringLiteral("note2")); - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(note1); - noteProvider->append(note2); - - Utils::MockObject<Domain::NoteQueries> noteQueriesMock; - noteQueriesMock(&Domain::NoteQueries::findInbox).when().thenReturn(noteResult); - - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - - Presentation::NoteInboxPageModel inbox(noteQueriesMock.getInstance(), - noteRepositoryMock.getInstance()); - - QAbstractItemModel *model = inbox.centralListModel(); - const QModelIndex note1Index = model->index(0, 0); - FakeErrorHandler errorHandler; - inbox.setErrorHandler(&errorHandler); - - // WHEN - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - noteRepositoryMock(&Domain::NoteRepository::update).when(note1).thenReturn(job); - - QVERIFY(model->setData(note1Index, "newNote1")); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot modify note note1 in Inbox: Foo")); - } -}; - -ZANSHIN_TEST_MAIN(NoteInboxPageModelTest) - -#include "noteinboxpagemodeltest.moc" diff --git a/tests/units/presentation/tagpagemodeltest.cpp b/tests/units/presentation/tagpagemodeltest.cpp deleted file mode 100644 --- a/tests/units/presentation/tagpagemodeltest.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2014 Kevin Ottens <ervin@kde.org> - Copyright 2014 Franck Arrecot <franck.arrecot@gmail.com> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include <testlib/qtest_zanshin.h> - -#include <memory> - -#include <QMimeData> - -#include "utils/mockobject.h" - -#include "domain/noterepository.h" -#include "domain/tagqueries.h" -#include "domain/tagrepository.h" - -#include "presentation/tagpagemodel.h" -#include "presentation/errorhandler.h" - -#include "testlib/fakejob.h" - -using namespace mockitopp; -using namespace mockitopp::matcher; - -class FakeErrorHandler : public Presentation::ErrorHandler -{ -public: - void doDisplayMessage(const QString &message) override - { - m_message = message; - } - - QString m_message; -}; - -class TagPageModelTest : public QObject -{ - Q_OBJECT -private slots: - void shouldListTagNotesInCentralListModel() - { - // GIVEN - - // One Tag - auto tag = Domain::Tag::Ptr::create(); - - // Two notes - auto note1 = Domain::Note::Ptr::create(); - note1->setTitle(QStringLiteral("note1")); - auto note2 = Domain::Note::Ptr::create(); - note2->setTitle(QStringLiteral("note2")); - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(note1); - noteProvider->append(note2); - - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findNotes).when(tag).thenReturn(noteResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - - Presentation::TagPageModel page(tag, - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance(), - noteRepositoryMock.getInstance()); - - // WHEN - QAbstractItemModel *model = page.centralListModel(); - - // THEN - const QModelIndex note1Index = model->index(0, 0); - const QModelIndex note2Index = model->index(1, 0); - - QCOMPARE(page.tag(), tag); - - QCOMPARE(model->rowCount(), 2); - QCOMPARE(model->rowCount(note1Index), 0); - QCOMPARE(model->rowCount(note2Index), 0); - - const Qt::ItemFlags defaultFlags = Qt::ItemIsSelectable - | Qt::ItemIsEnabled - | Qt::ItemIsEditable - | Qt::ItemIsDragEnabled; - QCOMPARE(model->flags(note1Index), defaultFlags); - QCOMPARE(model->flags(note2Index), defaultFlags); - - QCOMPARE(model->data(note1Index).toString(), note1->title()); - QCOMPARE(model->data(note2Index).toString(), note2->title()); - - QCOMPARE(model->data(note1Index, Qt::EditRole).toString(), note1->title()); - QCOMPARE(model->data(note2Index, Qt::EditRole).toString(), note2->title()); - - QVERIFY(!model->data(note1Index, Qt::CheckStateRole).isValid()); - QVERIFY(!model->data(note2Index, Qt::CheckStateRole).isValid()); - - // WHEN - noteRepositoryMock(&Domain::NoteRepository::update).when(note1).thenReturn(new FakeJob(this)); - noteRepositoryMock(&Domain::NoteRepository::update).when(note2).thenReturn(new FakeJob(this)); - - QVERIFY(model->setData(note1Index, "newNote1")); - QVERIFY(model->setData(note2Index, "newNote2")); - - QVERIFY(!model->setData(note1Index, Qt::Checked, Qt::CheckStateRole)); - QVERIFY(!model->setData(note2Index, Qt::Checked, Qt::CheckStateRole)); - - // THEN - QVERIFY(noteRepositoryMock(&Domain::NoteRepository::update).when(note1).exactly(1)); - QVERIFY(noteRepositoryMock(&Domain::NoteRepository::update).when(note2).exactly(1)); - - QCOMPARE(note1->title(), QStringLiteral("newNote1")); - QCOMPARE(note2->title(), QStringLiteral("newNote2")); - - // WHEN - auto data = std::unique_ptr<QMimeData>(model->mimeData(QModelIndexList() << note2Index)); - - // THEN - QVERIFY(data->hasFormat(QStringLiteral("application/x-zanshin-object"))); - QCOMPARE(data->property("objects").value<Domain::Artifact::List>(), - Domain::Artifact::List() << note2); - } - - void shouldAddNotes() - { - // GIVEN - - // One Tag - auto tag = Domain::Tag::Ptr::create(); - - // ... in fact we won't list any model - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - // We'll gladly create a note though - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - noteRepositoryMock(&Domain::NoteRepository::createInTag).when(any<Domain::Note::Ptr>(), - any<Domain::Tag::Ptr>()) - .thenReturn(new FakeJob(this)); - - Presentation::TagPageModel page(tag, - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance(), - noteRepositoryMock.getInstance()); - - // WHEN - auto title = QStringLiteral("New note"); - auto note = page.addItem(title).objectCast<Domain::Note>(); - - // THEN - QVERIFY(noteRepositoryMock(&Domain::NoteRepository::createInTag).when(any<Domain::Note::Ptr>(), - any<Domain::Tag::Ptr>()) - .exactly(1)); - QVERIFY(note); - QCOMPARE(note->title(), title); - } - - void shouldRemoveItem() - { - // GIVEN - - // One domain tag - auto tag = Domain::Tag::Ptr::create(); - - // Two notes - auto note1 = Domain::Note::Ptr::create(); - auto note2 = Domain::Note::Ptr::create(); - - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(note1); - noteProvider->append(note2); - - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findNotes).when(tag).thenReturn(noteResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - tagRepositoryMock(&Domain::TagRepository::dissociate).when(tag, note2).thenReturn(new FakeJob(this)); - - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - - Presentation::TagPageModel page(tag, - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance(), - noteRepositoryMock.getInstance()); - - // WHEN - const QModelIndex indexNote2 = page.centralListModel()->index(1, 0); - page.removeItem(indexNote2); - - // THEN - QVERIFY(tagRepositoryMock(&Domain::TagRepository::dissociate).when(tag, note2).exactly(1)); - } - - void shouldGetAnErrorMessageWhenRemoveItemFailed() - { - // GIVEN - - // One domain tag - auto tag = Domain::Tag::Ptr::create(); - tag->setName(QStringLiteral("Tag1")); - - // Two notes - auto note1 = Domain::Note::Ptr::create(); - note1->setTitle(QStringLiteral("Note 1")); - auto note2 = Domain::Note::Ptr::create(); - note2->setTitle(QStringLiteral("Note 2")); - - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(note1); - noteProvider->append(note2); - - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findNotes).when(tag).thenReturn(noteResult); - - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - tagRepositoryMock(&Domain::TagRepository::dissociate).when(tag, note2).thenReturn(job); - - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - - Presentation::TagPageModel page(tag, - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance(), - noteRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - page.setErrorHandler(&errorHandler); - - // WHEN - const QModelIndex indexNote2 = page.centralListModel()->index(1, 0); - page.removeItem(indexNote2); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot remove note Note 2 from tag Tag1: Foo")); - } - - void shouldGetAnErrorMessageWhenAddNoteFailed() - { - // GIVEN - - // One Tag - auto tag = Domain::Tag::Ptr::create(); - tag->setName(QStringLiteral("Tag1")); - - // ... in fact we won't list any model - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - // We'll gladly create a note though - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - noteRepositoryMock(&Domain::NoteRepository::createInTag).when(any<Domain::Note::Ptr>(), - any<Domain::Tag::Ptr>()) - .thenReturn(job); - - Presentation::TagPageModel page(tag, - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance(), - noteRepositoryMock.getInstance()); - FakeErrorHandler errorHandler; - page.setErrorHandler(&errorHandler); - - // WHEN - page.addItem(QStringLiteral("New note")); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot add note New note in tag Tag1: Foo")); - } - - void shouldGetAnErrorMessageWhenUpdateNoteFailed() - { - // GIVEN - - // One Tag - auto tag = Domain::Tag::Ptr::create(); - tag->setName(QStringLiteral("Tag1")); - - // One note - auto rootNote = Domain::Note::Ptr::create(); - rootNote->setTitle(QStringLiteral("rootNote")); - auto noteProvider = Domain::QueryResultProvider<Domain::Note::Ptr>::Ptr::create(); - auto noteResult = Domain::QueryResult<Domain::Note::Ptr>::create(noteProvider); - noteProvider->append(rootNote); - - Utils::MockObject<Domain::TagQueries> tagQueriesMock; - tagQueriesMock(&Domain::TagQueries::findNotes).when(tag).thenReturn(noteResult); - - Utils::MockObject<Domain::NoteRepository> noteRepositoryMock; - Utils::MockObject<Domain::TagRepository> tagRepositoryMock; - - Presentation::TagPageModel page(tag, - tagQueriesMock.getInstance(), - tagRepositoryMock.getInstance(), - noteRepositoryMock.getInstance()); - - QAbstractItemModel *model = page.centralListModel(); - const QModelIndex rootNoteIndex = model->index(0, 0); - FakeErrorHandler errorHandler; - page.setErrorHandler(&errorHandler); - - // WHEN - auto job = new FakeJob(this); - job->setExpectedError(KJob::KilledJobError, QStringLiteral("Foo")); - noteRepositoryMock(&Domain::NoteRepository::update).when(rootNote).thenReturn(job); - - QVERIFY(model->setData(rootNoteIndex, "newRootNote")); - - // THEN - QTest::qWait(150); - QCOMPARE(errorHandler.m_message, QStringLiteral("Cannot modify note rootNote in tag Tag1: Foo")); - } -}; - -ZANSHIN_TEST_MAIN(TagPageModelTest) - -#include "tagpagemodeltest.moc" diff --git a/tests/units/presentation/workdaypagemodeltest.cpp b/tests/units/presentation/workdaypagemodeltest.cpp --- a/tests/units/presentation/workdaypagemodeltest.cpp +++ b/tests/units/presentation/workdaypagemodeltest.cpp @@ -32,7 +32,6 @@ #include "utils/datetime.h" #include "utils/mockobject.h" -#include "domain/noterepository.h" #include "domain/taskqueries.h" #include "domain/taskrepository.h" #include "presentation/workdaypagemodel.h" diff --git a/tests/units/testlib/CMakeLists.txt b/tests/units/testlib/CMakeLists.txt --- a/tests/units/testlib/CMakeLists.txt +++ b/tests/units/testlib/CMakeLists.txt @@ -5,7 +5,6 @@ akonadifakedataxmlloadertest akonadifakestoragetest gencollectiontest - gennotetest gentagtest gentodotest monitorspytest diff --git a/tests/units/testlib/gennotetest.cpp b/tests/units/testlib/gennotetest.cpp deleted file mode 100644 --- a/tests/units/testlib/gennotetest.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Kevin Ottens <ervin@kde.org> - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License or (at your option) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include "testlib/gennote.h" - -#include <Akonadi/Notes/NoteUtils> -#include <KMime/Message> - -#include <testlib/qtest_zanshin.h> - -using namespace Testlib; - -class GenNoteTest : public QObject -{ - Q_OBJECT -private slots: - void shouldImplicitlyConvertBackToItem() - { - // GIVEN - auto item = Akonadi::Item(42); - auto gen = GenNote(item); - - // WHEN - Akonadi::Item newItem = gen; - - // THEN - QCOMPARE(newItem, item); - QCOMPARE(newItem.mimeType(), Akonadi::NoteUtils::noteMimeType()); - QVERIFY(newItem.hasPayload<KMime::Message::Ptr>()); - } - - void shouldAllowToSetId() - { - // GIVEN - Akonadi::Item item = GenNote().withId(42); - - // THEN - QCOMPARE(item.id(), 42LL); - } - - void shouldAllowToSetParent() - { - // GIVEN - Akonadi::Item item = GenNote().withParent(42); - - // THEN - QCOMPARE(item.parentCollection().id(), 42LL); - } - - void shouldAllowToSetTags() - { - // GIVEN - Akonadi::Item item = GenNote().withTags({42, 43, 44}); - - // THEN - QCOMPARE(item.tags().size(), 3); - QCOMPARE(item.tags().at(0).id(), 42LL); - QCOMPARE(item.tags().at(1).id(), 43LL); - QCOMPARE(item.tags().at(2).id(), 44LL); - } - - void shouldAllowToSetParentUid() - { - // GIVEN - Akonadi::Item item = GenNote().withParentUid(QStringLiteral("42")); - - // THEN - QCOMPARE(item.payload<KMime::Message::Ptr>()->headerByType("X-Zanshin-RelatedProjectUid")->asUnicodeString(), QStringLiteral("42")); - } - - void shouldAllowToSetTitle() - { - // GIVEN - Akonadi::Item item = GenNote().withTitle(QStringLiteral("42")); - - // THEN - QCOMPARE(item.payload<KMime::Message::Ptr>()->subject()->asUnicodeString(), QStringLiteral("42")); - } - - void shouldAllowToSetText() - { - // GIVEN - Akonadi::Item item = GenNote().withText(QStringLiteral("42")); - - // THEN - QCOMPARE(item.payload<KMime::Message::Ptr>()->body(), QByteArray("42")); - } -}; - -ZANSHIN_TEST_MAIN(GenNoteTest) - -#include "gennotetest.moc" diff --git a/tests/units/widgets/applicationcomponentstest.cpp b/tests/units/widgets/applicationcomponentstest.cpp --- a/tests/units/widgets/applicationcomponentstest.cpp +++ b/tests/units/widgets/applicationcomponentstest.cpp @@ -33,7 +33,6 @@ #include "utils/mem_fn.h" -#include "domain/note.h" #include "domain/task.h" #include "presentation/artifactfilterproxymodel.h" @@ -569,9 +568,9 @@ PageModelStub pageModel; pageModel.addItem<Domain::Task>(QStringLiteral("0. First task")); - pageModel.addItem<Domain::Note>(QStringLiteral("1. A note")); - pageModel.addItem<Domain::Task>(QStringLiteral("2. Second task")); - pageModel.addItem<Domain::Note>(QStringLiteral("3. Another note")); + pageModel.addItem<Domain::Task>(QStringLiteral("1. Second task")); + pageModel.addItem<Domain::Task>(QStringLiteral("2. Third task")); + pageModel.addItem<Domain::Task>(QStringLiteral("3. Yet another task")); model->setProperty("currentPage", QVariant::fromValue<QObject*>(&pageModel)); EditorModelStub editorModel; @@ -629,9 +628,9 @@ PageModelStub pageModel; pageModel.addItem<Domain::Task>(QStringLiteral("0. First task")); - pageModel.addItem<Domain::Note>(QStringLiteral("1. A note")); - pageModel.addItem<Domain::Task>(QStringLiteral("2. Second task")); - pageModel.addItem<Domain::Note>(QStringLiteral("3. Another note")); + pageModel.addItem<Domain::Task>(QStringLiteral("1. Second task")); + pageModel.addItem<Domain::Task>(QStringLiteral("2. Third task")); + pageModel.addItem<Domain::Task>(QStringLiteral("3. Yet another task")); model->setProperty("currentPage", QVariant::fromValue<QObject*>(&pageModel)); AvailablePagesModelStub availablePagesModelStub; diff --git a/tests/units/widgets/availablepagesviewtest.cpp b/tests/units/widgets/availablepagesviewtest.cpp --- a/tests/units/widgets/availablepagesviewtest.cpp +++ b/tests/units/widgets/availablepagesviewtest.cpp @@ -34,7 +34,6 @@ #include "domain/project.h" #include "domain/context.h" -#include "domain/tag.h" #include "presentation/metatypes.h" #include "presentation/querytreemodelbase.h" @@ -410,10 +409,6 @@ context1->setName(QStringLiteral("Context 1")); QTest::newRow("context") << QObjectPtr(context1) << true; - auto tag1 = Domain::Tag::Ptr::create(); - tag1->setName(QStringLiteral("Tag 1")); - QTest::newRow("tag") << QObjectPtr(tag1) << true; - QTest::newRow("non removable") << QObjectPtr::create() << false; } diff --git a/tests/units/widgets/editorviewtest.cpp b/tests/units/widgets/editorviewtest.cpp --- a/tests/units/widgets/editorviewtest.cpp +++ b/tests/units/widgets/editorviewtest.cpp @@ -32,7 +32,6 @@ #include <KLocalizedString> -#include "domain/note.h" #include "domain/task.h" #include "widgets/editorview.h"