~mterry/qtorganizer5-eds/cleanup-packaging

« back to all changes in this revision

Viewing changes to qorganizer/qorganizer-eds-saverequestdata.cpp

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2013-08-14 21:23:01 UTC
  • Revision ID: renato.filho@canonical.com-20130814212301-cmqs3nv48cvzy9qq
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * This file is part of ubuntu-pim-service.
 
5
 *
 
6
 * contact-service-app 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
 * contact-service-app 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
 
 
19
#include "qorganizer-eds-saverequestdata.h"
 
20
 
 
21
#include <QtOrganizer/QOrganizerManagerEngine>
 
22
#include <QtOrganizer/QOrganizerItemSaveRequest>
 
23
 
 
24
using namespace QtOrganizer;
 
25
 
 
26
SaveRequestData::SaveRequestData(QOrganizerEDSEngine *engine,
 
27
                                 QtOrganizer::QOrganizerAbstractRequest *req,
 
28
                                 QOrganizerCollectionId collectionId)
 
29
    : RequestData(engine, req),
 
30
      m_collectionId(collectionId)
 
31
{
 
32
}
 
33
 
 
34
SaveRequestData::~SaveRequestData()
 
35
{
 
36
}
 
37
 
 
38
 
 
39
void SaveRequestData::finish(QtOrganizer::QOrganizerManager::Error error)
 
40
{
 
41
 
 
42
    QOrganizerManagerEngine::updateItemSaveRequest(request<QOrganizerItemSaveRequest>(),
 
43
                                                   m_result,
 
44
                                                   error,
 
45
                                                   QMap<int, QOrganizerManager::Error>(),
 
46
                                                   QOrganizerAbstractRequest::FinishedState);
 
47
    Q_FOREACH(QOrganizerItem item, m_result) {
 
48
        qDebug() << "Item Added" << item.id();
 
49
        m_changeSet.insertAddedItem(item.id());
 
50
    }
 
51
    m_changeSet.emitSignals(m_parent);
 
52
}
 
53
 
 
54
void SaveRequestData::appendResults(QList<QOrganizerItem> result)
 
55
{
 
56
    m_result += result;
 
57
}
 
58
 
 
59
QOrganizerCollectionId SaveRequestData::collectionId() const
 
60
{
 
61
    return m_collectionId;
 
62
}
 
63
 
 
64
bool SaveRequestData::isNew() const
 
65
{
 
66
    QList<QOrganizerItem> items = request<QOrganizerItemSaveRequest>()->items();
 
67
    if (items.count() > 0) {
 
68
        return items[0].id().isNull();
 
69
    }
 
70
    return false;
 
71
}