1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtOrganizer module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
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 The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
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 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qdeclarativeorganizercollection_p.h"
35
36QTORGANIZER_USE_NAMESPACE
37
38QT_BEGIN_NAMESPACE
39
40/*!
41 \qmltype Collection
42 \instantiates QDeclarativeOrganizerCollection
43 \brief The Collection element represents a collection of items in an organizer manager.
44 \inqmlmodule QtOrganizer
45 \ingroup qml-organizer-main
46 */
47
48/*!
49 \internal
50 */
51QDeclarativeOrganizerCollection::QDeclarativeOrganizerCollection(QObject *parent)
52 : QObject(parent)
53{
54}
55
56/*!
57 \qmlproperty string Collection::collectionId
58
59 This property holds the ID of the collection.
60 */
61QString QDeclarativeOrganizerCollection::id() const
62{
63 return d.id().toString();
64}
65
66void QDeclarativeOrganizerCollection::setId(const QString &id)
67{
68 if (d.id().toString() != id) {
69 d.setId(QOrganizerCollectionId::fromString(idString: id));
70 emit valueChanged();
71 }
72}
73
74/*!
75 \qmlproperty string Collection::name
76
77 This property holds the name meta data of a collection.
78 */
79QString QDeclarativeOrganizerCollection::name() const
80{
81 return metaData(key: QOrganizerCollection::KeyName).toString();
82}
83
84void QDeclarativeOrganizerCollection::setName(const QString &name)
85{
86 setMetaData(key: QOrganizerCollection::KeyName, value: name);
87}
88
89/*!
90 \qmlproperty string Collection::description
91
92 This property holds the description meta data of a collection.
93 */
94QString QDeclarativeOrganizerCollection::description() const
95{
96 return metaData(key: QOrganizerCollection::KeyDescription).toString();
97}
98
99void QDeclarativeOrganizerCollection::setDescription(const QString &description)
100{
101 setMetaData(key: QOrganizerCollection::KeyDescription, value: description);
102}
103
104/*!
105 \qmlproperty color Collection::secondaryColor
106
107 This property holds the secondary color meta data of a collection.
108 */
109QColor QDeclarativeOrganizerCollection::secondaryColor() const
110{
111 return metaData(key: QOrganizerCollection::KeySecondaryColor).value<QColor>();
112}
113
114void QDeclarativeOrganizerCollection::setSecondaryColor(const QColor &secondaryColor)
115{
116 setMetaData(key: QOrganizerCollection::KeySecondaryColor, value: secondaryColor);
117}
118
119/*!
120 \qmlproperty color Collection::color
121
122 This property holds the color meta data of a collection.
123 */
124QColor QDeclarativeOrganizerCollection::color() const
125{
126 return metaData(key: QOrganizerCollection::KeyColor).value<QColor>();
127}
128
129void QDeclarativeOrganizerCollection::setColor(const QColor &color)
130{
131 setMetaData(key: QOrganizerCollection::KeyColor, value: color);
132}
133
134/*!
135 \qmlproperty url Collection::image
136
137 This property holds the image url meta data of a collection.
138 */
139QUrl QDeclarativeOrganizerCollection::image() const
140{
141 return QUrl(metaData(key: QOrganizerCollection::KeyImage).toString());
142}
143
144void QDeclarativeOrganizerCollection::setImage(const QUrl &url)
145{
146 setMetaData(key: QOrganizerCollection::KeyImage, value: url);
147}
148
149/*!
150 \qmlmethod Collection::setMetaData(key, value)
151
152 Sets the meta data of the collection for the given \a key to the given \a value. Possible keys
153 include:
154 \list
155 \li Collection.KeyName
156 \li Collection.KeyDescription
157 \li Collection.KeyColor
158 \li Collection.KeySecondaryColor
159 \li Collection.KeyImage
160 \li Collection.KeyExtended
161 \endlist
162 */
163void QDeclarativeOrganizerCollection::setMetaData(QOrganizerCollection::MetaDataKey key, const QVariant &value)
164{
165 if (metaData(key) != value) {
166 d.setMetaData(key, value);
167 emit valueChanged();
168 }
169}
170
171/*!
172 \qmlmethod var Collection::metaData(key)
173
174 Returns the meta data stored in this collection for the given \a key. Possible keys include:
175 \list
176 \li Collection.KeyName
177 \li Collection.KeyDescription
178 \li Collection.KeyColor
179 \li Collection.KeyImage
180 \li Collection.KeyExtended
181 \endlist
182 */
183QVariant QDeclarativeOrganizerCollection::metaData(QOrganizerCollection::MetaDataKey key) const
184{
185 return d.metaData(key);
186}
187
188/*!
189 \qmlmethod Collection::setExtendedMetaData(key, value)
190
191 Sets the value of the extended metadata with the given \a key to \a value.
192 */
193void QDeclarativeOrganizerCollection::setExtendedMetaData(const QString &key, const QVariant &value)
194{
195 if (extendedMetaData(key) != value) {
196 d.setExtendedMetaData(key, value);
197 emit valueChanged();
198 }
199}
200
201/*!
202 \qmlmethod var Collection::extendedMetaData(key)
203
204 Returns the value of extended metadata with the given \a key.
205 */
206QVariant QDeclarativeOrganizerCollection::extendedMetaData(const QString &key) const
207{
208 return d.extendedMetaData(key);
209}
210
211/*!
212 \internal
213 */
214QOrganizerCollection QDeclarativeOrganizerCollection::collection() const
215{
216 return d;
217}
218
219/*!
220 \internal
221 */
222void QDeclarativeOrganizerCollection::setCollection(const QOrganizerCollection &collection)
223{
224 d = collection;
225}
226
227#include "moc_qdeclarativeorganizercollection_p.cpp"
228
229QT_END_NAMESPACE
230

source code of qtpim/src/imports/organizer/qdeclarativeorganizercollection.cpp