1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtOrganizer module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
42
#include "qorganizerjsondbid.h"
43
#include "qorganizerjsondbstring.h"
45
QT_BEGIN_NAMESPACE_ORGANIZER
47
QOrganizerJsonDbItemId::QOrganizerJsonDbItemId()
48
: QOrganizerItemEngineId()
49
, m_jsonDbUuid(QString())
50
, m_storageLocation(QOrganizerJsonDbEngine::UserDataStorage)
54
QOrganizerJsonDbItemId::QOrganizerJsonDbItemId(const QString &fullEngineId)
55
: QOrganizerItemEngineId()
57
splitId(fullEngineId, m_jsonDbUuid, m_storageLocation);
60
QOrganizerJsonDbItemId::QOrganizerJsonDbItemId(const QOrganizerJsonDbItemId &other)
61
: QOrganizerItemEngineId(),
62
m_jsonDbUuid(other.m_jsonDbUuid),
63
m_storageLocation(other.m_storageLocation)
67
QOrganizerJsonDbItemId::~QOrganizerJsonDbItemId()
71
bool QOrganizerJsonDbItemId::isEqualTo(const QOrganizerItemEngineId *other) const
73
const QOrganizerJsonDbItemId* id = static_cast<const QOrganizerJsonDbItemId *>(other);
74
return ((m_jsonDbUuid == id->m_jsonDbUuid) && (m_storageLocation == id->m_storageLocation));
77
bool QOrganizerJsonDbItemId::isLessThan(const QOrganizerItemEngineId *other) const
79
const QOrganizerJsonDbItemId* id = static_cast<const QOrganizerJsonDbItemId *>(other);
80
if (m_storageLocation == id->m_storageLocation)
81
return (m_jsonDbUuid < id->m_jsonDbUuid);
83
return (m_storageLocation < id->m_storageLocation);
86
QString QOrganizerJsonDbItemId::managerUri() const
88
return QOrganizerJsonDbStr::jsonDbManagerUri();
91
QOrganizerItemEngineId *QOrganizerJsonDbItemId::clone() const
93
QOrganizerJsonDbItemId *newId = new QOrganizerJsonDbItemId();
94
newId->setJsonDbUuid(m_jsonDbUuid);
95
newId->setStorageLocation(m_storageLocation);
99
#ifndef QT_NO_DEBUG_STREAM
100
QDebug &QOrganizerJsonDbItemId::debugStreamOut(QDebug &dbg) const
102
dbg.nospace() << "QOrganizerJsonDbItemId(" << toString() << ")";
103
return dbg.maybeSpace();
107
QString QOrganizerJsonDbItemId::toString() const
109
return QString("%1/%2").arg(m_storageLocation).arg(m_jsonDbUuid);
112
uint QOrganizerJsonDbItemId::hash() const
114
return QT_PREPEND_NAMESPACE(qHash)(this->toString());
117
void QOrganizerJsonDbItemId::setFullEngineId(const QString &fullEngineId)
119
splitId(fullEngineId, m_jsonDbUuid, m_storageLocation);
122
QString QOrganizerJsonDbItemId::jsondbUuid() const
127
void QOrganizerJsonDbItemId::setJsonDbUuid(const QString &jsonDbUuid)
129
m_jsonDbUuid = jsonDbUuid;
132
QOrganizerJsonDbEngine::StorageLocation QOrganizerJsonDbItemId::storageLocation() const
134
return m_storageLocation;
137
void QOrganizerJsonDbItemId::setStorageLocation(QOrganizerJsonDbEngine::StorageLocation storageLocation)
139
m_storageLocation = storageLocation;
142
void QOrganizerJsonDbItemId::splitId(const QString &fullId, QString &jsondbUuid, QOrganizerJsonDbEngine::StorageLocation &storageLocation)
144
// separate engine id part, if full id given
145
QString engineId = fullId.contains(":") ? fullId.mid(fullId.lastIndexOf(":")+1) : fullId;
146
// separate storagelocation and collection id from each other
147
const QStringList splittedEngineId = engineId.split(QStringLiteral("/"));
148
storageLocation = (QOrganizerJsonDbEngine::StorageLocation)splittedEngineId.first().toInt();
149
jsondbUuid = splittedEngineId.last();
152
QOrganizerJsonDbCollectionId::QOrganizerJsonDbCollectionId()
153
: QOrganizerCollectionEngineId()
154
, m_jsonDbUuid(QString())
155
, m_storageLocation(QOrganizerJsonDbEngine::UserDataStorage)
159
QOrganizerJsonDbCollectionId::QOrganizerJsonDbCollectionId(const QString &fullEngineId)
160
: QOrganizerCollectionEngineId()
162
splitId(fullEngineId, m_jsonDbUuid, m_storageLocation);
165
QOrganizerJsonDbCollectionId::QOrganizerJsonDbCollectionId(const QOrganizerJsonDbCollectionId &other)
166
: QOrganizerCollectionEngineId()
167
, m_jsonDbUuid(other.m_jsonDbUuid)
168
, m_storageLocation(other.m_storageLocation)
172
QOrganizerJsonDbCollectionId::~QOrganizerJsonDbCollectionId()
176
bool QOrganizerJsonDbCollectionId::isEqualTo(const QOrganizerCollectionEngineId *other) const
178
const QOrganizerJsonDbCollectionId* collId = static_cast<const QOrganizerJsonDbCollectionId *>(other);
179
return ((m_jsonDbUuid == collId->m_jsonDbUuid) && (m_storageLocation == collId->m_storageLocation));
182
bool QOrganizerJsonDbCollectionId::isLessThan(const QOrganizerCollectionEngineId *other) const
184
const QOrganizerJsonDbCollectionId* collId = static_cast<const QOrganizerJsonDbCollectionId *>(other);
185
if (m_storageLocation == collId->m_storageLocation)
186
return (m_jsonDbUuid < collId->m_jsonDbUuid);
188
return (m_storageLocation < collId->m_storageLocation);
191
QString QOrganizerJsonDbCollectionId::managerUri() const
193
return QOrganizerJsonDbStr::jsonDbManagerUri();
196
QOrganizerCollectionEngineId *QOrganizerJsonDbCollectionId::clone() const
198
QOrganizerJsonDbCollectionId *newId = new QOrganizerJsonDbCollectionId();
199
newId->setJsonDbUuid(m_jsonDbUuid);
200
newId->setStorageLocation(m_storageLocation);
204
#ifndef QT_NO_DEBUG_STREAM
205
QDebug &QOrganizerJsonDbCollectionId::debugStreamOut(QDebug &dbg) const
207
dbg.nospace() << "QOrganizerJsonDbCollectionId(" << toString() << ")";
208
return dbg.maybeSpace();
212
QString QOrganizerJsonDbCollectionId::toString() const
214
return QString("%1/%2").arg(m_storageLocation).arg(m_jsonDbUuid);
217
uint QOrganizerJsonDbCollectionId::hash() const
219
return QT_PREPEND_NAMESPACE(qHash)(toString());
222
void QOrganizerJsonDbCollectionId::setFullEngineId(const QString &fullEngineId)
224
splitId(fullEngineId, m_jsonDbUuid, m_storageLocation);
227
QString QOrganizerJsonDbCollectionId::jsondbUuid() const
232
void QOrganizerJsonDbCollectionId::setJsonDbUuid(const QString &jsonDbUuid)
234
m_jsonDbUuid = jsonDbUuid;
237
QOrganizerJsonDbEngine::StorageLocation QOrganizerJsonDbCollectionId::storageLocation() const
239
return m_storageLocation;
242
void QOrganizerJsonDbCollectionId::setStorageLocation(QOrganizerJsonDbEngine::StorageLocation storageLocation)
244
m_storageLocation = storageLocation;
247
void QOrganizerJsonDbCollectionId::splitId(const QString &fullId, QString &jsondbUuid, QOrganizerJsonDbEngine::StorageLocation &storageLocation)
249
// separate engine id part, if full id given
250
QString engineId = fullId.contains(":") ? fullId.mid(fullId.lastIndexOf(":")+1) : fullId;
251
// separate storagelocation and collection id from each other
252
const QStringList splittedEngineId = engineId.split(QStringLiteral("/"));
253
storageLocation = QOrganizerJsonDbEngine::StorageLocation(splittedEngineId.first().toInt());
254
jsondbUuid = splittedEngineId.last();
257
QT_END_NAMESPACE_ORGANIZER