~rpadovani/reminders-app/1385429

« back to all changes in this revision

Viewing changes to src/plugin/Evernote/jobs/createtagjob.cpp

  • Committer: Tarmac
  • Author(s): Michael Zanetti
  • Date: 2014-10-11 16:31:17 UTC
  • mfrom: (266.2.6 reminders-app-tags)
  • Revision ID: tarmac-20141011163117-k34jgx6jk5zizxpw
Add support for tags. Fixes: https://bugs.launchpad.net/bugs/1379747.

Approved by Riccardo Padovani, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright: 2014 Canonical, Ltd
 
3
 *
 
4
 * This file is part of reminders
 
5
 *
 
6
 * reminders is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * reminders is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 *
 
18
 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
 
19
 */
 
20
 
 
21
#include "createtagjob.h"
 
22
 
 
23
#include <QDebug>
 
24
 
 
25
CreateTagJob::CreateTagJob(const QString &name, QObject *parent) :
 
26
    NotesStoreJob(parent),
 
27
    m_name(name)
 
28
{
 
29
}
 
30
 
 
31
void CreateTagJob::startJob()
 
32
{
 
33
    m_result.name = m_name.toStdString();
 
34
    m_result.__isset.name = true;
 
35
    client()->createTag(m_result, token().toStdString(), m_result);
 
36
}
 
37
 
 
38
bool CreateTagJob::operator==(const EvernoteJob *other) const
 
39
{
 
40
    const CreateTagJob *otherJob = qobject_cast<const CreateTagJob*>(other);
 
41
    if (!otherJob) {
 
42
        return false;
 
43
    }
 
44
    return this->m_name == otherJob->m_name;
 
45
}
 
46
 
 
47
void CreateTagJob::attachToDuplicate(const EvernoteJob *other)
 
48
{
 
49
    const CreateTagJob *otherJob = static_cast<const CreateTagJob*>(other);
 
50
    connect(otherJob, &CreateTagJob::jobDone, this, &CreateTagJob::jobDone);
 
51
}
 
52
 
 
53
void CreateTagJob::emitJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage)
 
54
{
 
55
    emit jobDone(errorCode, errorMessage, m_result);
 
56
}