diff --git a/src/tasks/task.cpp b/src/tasks/task.cpp index 8797ed7..07389e7 100644 --- a/src/tasks/task.cpp +++ b/src/tasks/task.cpp @@ -1,82 +1,102 @@ /* * This file is part of LibKGAPI library * * Copyright (C) 2013 Daniel Vrátil * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 6 of version 3 of the license. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "task.h" +#include "../debug.h" using namespace KGAPI2; class Q_DECL_HIDDEN Task::Private { public: Private(); Private (const Private&); bool deleted; }; Task::Private::Private(): deleted(false) { } Task::Private::Private(const Private &other): deleted(other.deleted) { } Task::Task(): Object(), KCalCore::Todo(), d(new Private) { } Task::Task(const Task& other): Object(other), KCalCore::Todo(other), d(new Private(*(other.d))) { } Task::Task(const KCalCore::Todo &other): Object(), KCalCore::Todo(other), d(new Private) { } Task::~Task() { delete d; } +bool Task::operator==(const Task &other) const +{ + if (!Object::operator==(other)) { + qCDebug(KGAPIDebug) << "Objects don't match"; + return false; + } + if (!Todo::operator==(other)) { + qCDebug(KGAPIDebug) << "Todos don't match"; + return false; + } + if (d->deleted != other.d->deleted) { + qCDebug(KGAPIDebug) << "Deleted does not match"; + return false; + } + + return true; +} + + void Task::setDeleted(const bool deleted) { d->deleted = deleted; } bool Task::deleted() const { return d->deleted; } diff --git a/src/tasks/task.h b/src/tasks/task.h index f37592e..1531b90 100644 --- a/src/tasks/task.h +++ b/src/tasks/task.h @@ -1,87 +1,89 @@ /* * This file is part of LibKGAPI library * * Copyright (C) 2013 Daniel Vrátil * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 6 of version 3 of the license. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef LIBKGAPI2_TASK_H #define LIBKGAPI2_TASK_H #include "object.h" #include "types.h" #include "kgapitasks_export.h" #include namespace KGAPI2 { /** * @brief Represents a single task (or todo) * * @author Daniel Vrátil * @since 0.3 */ class KGAPITASKS_EXPORT Task: public KGAPI2::Object, public KCalCore::Todo { public: /** * @brief Constructor */ explicit Task(); /** * @brief Copy constructor */ Task(const Task& other); /** * @brief Copy constructor */ Task(const KCalCore::Todo &other); /** * @brief Destructor */ ~Task() override; + bool operator==(const Task &other) const; + /** * @brief Sets whether the task has been deleted * * @param deleted */ void setDeleted(bool deleted); /** * @brief Returns whether the task has been deleted */ bool deleted() const; private: class Private; Private * const d; friend class Private; }; } // namespace KGAPI2/ #endif // LIBKGAPI2_OBJECTS_TASK_H diff --git a/src/tasks/tasklist.cpp b/src/tasks/tasklist.cpp index 7333b13..bb6358c 100644 --- a/src/tasks/tasklist.cpp +++ b/src/tasks/tasklist.cpp @@ -1,83 +1,103 @@ /* * This file is part of LibKGAPI library * * Copyright (C) 2013 Daniel Vrátil * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 6 of version 3 of the license. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "tasklist.h" +#include "../debug.h" using namespace KGAPI2; class Q_DECL_HIDDEN TaskList::Private { public: Private(); Private(const Private &other); QString title; QString uid; }; TaskList::Private::Private() { } TaskList::Private::Private (const Private& other): title(other.title), uid(other.uid) { } TaskList::TaskList(): Object(), d(new Private) { } TaskList::TaskList (const TaskList& other): Object(other), d(new Private(*(other.d))) { } TaskList::~TaskList() { delete d; } +bool TaskList::operator==(const TaskList &other) const +{ + if (!Object::operator==(other)) { + return false; + } + + if (d->uid != other.d->uid) { + qCDebug(KGAPIDebug) << "UIDs don't match"; + return false; + } + + if (d->title != other.d->title) { + qCDebug(KGAPIDebug) << "Titles don't match"; + return false; + } + + return true; +} + void TaskList::setUid(const QString &uid) { d->uid = uid; } QString TaskList::uid() const { return d->uid; } void TaskList::setTitle(const QString& title) { d->title = title; } QString TaskList::title() const { return d->title; } diff --git a/src/tasks/tasklist.h b/src/tasks/tasklist.h index 9c5048d..1a4cb5c 100644 --- a/src/tasks/tasklist.h +++ b/src/tasks/tasklist.h @@ -1,92 +1,94 @@ /* * This file is part of LibKGAPI library * * Copyright (C) 2013 Daniel Vrátil * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 6 of version 3 of the license. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef LIBKGAPI2_TASKLIST_H #define LIBKGAPI2_TASKLIST_H #include "object.h" #include "types.h" #include "kgapitasks_export.h" namespace KGAPI2 { /** * @brief Represents a tasklist for Google Tasks service. * * @author Daniel Vrátil * @since: 0.3 */ class KGAPITASKS_EXPORT TaskList: public KGAPI2::Object { public: /** * @brief Constructor */ TaskList(); /** * @brief Copy constructor */ TaskList (const TaskList& other); /** * @brief Destructor */ ~TaskList() override; + bool operator==(const TaskList &other) const; + /** * @brief Sets tasklist UID * * @param uid */ void setUid(const QString &uid); /** * @brief Returns tasklist UID */ QString uid() const; /** * @brief Sets tasklist name * * @param title */ void setTitle(const QString &title); /** * @brief Returns tasklist title */ QString title() const; private: class Private; Private * const d; friend class Private; }; } // namespace KGAPI2 #endif // LIBKGAPI2_TASKLIST_H