2
* Copyright (C) 2011 Tuomo Penttinen, all rights reserved.
4
* Author: Tuomo Penttinen <tp@herqq.org>
6
* This file is part of Herqq UPnP Av (HUPnPAv) library.
8
* Herqq UPnP Av is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
13
* Herqq UPnP Av is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with Herqq UPnP Av. If not, see <http://www.gnu.org/licenses/>.
22
#include "htextitem.h"
23
#include "htextitem_p.h"
25
#include "../hpersonwithrole.h"
26
#include "../model_mgmt/hcdsproperties.h"
28
#include "../../common/hrating.h"
29
#include "../../common/hstoragemedium.h"
31
#include <QtCore/QUrl>
32
#include <QtCore/QDateTime>
33
#include <QtCore/QStringList>
44
/*******************************************************************************
46
******************************************************************************/
47
HTextItemPrivate::HTextItemPrivate(
48
const QString& clazz, HObject::CdsType cdsType) :
49
HItemPrivate(clazz, cdsType)
51
const HCdsProperties& inst = HCdsProperties::instance();
52
insert(inst.get(HCdsProperties::upnp_author));
53
insert(inst.get(HCdsProperties::upnp_longDescription));
54
insert(inst.get(HCdsProperties::upnp_storageMedium));
55
insert(inst.get(HCdsProperties::upnp_rating));
56
insert(inst.get(HCdsProperties::dc_description));
57
insert(inst.get(HCdsProperties::dc_publisher));
58
insert(inst.get(HCdsProperties::dc_contributor));
59
insert(inst.get(HCdsProperties::dc_date));
60
insert(inst.get(HCdsProperties::dc_relation));
61
insert(inst.get(HCdsProperties::dc_language));
62
insert(inst.get(HCdsProperties::dc_rights));
65
/*******************************************************************************
67
******************************************************************************/
68
HTextItem::HTextItem(const QString& clazz, CdsType cdsType) :
69
HItem(*new HTextItemPrivate(clazz, cdsType))
74
const QString& title, const QString& parentId, const QString& id) :
75
HItem(*new HTextItemPrivate(sClass(), sType()))
77
init(title, parentId, id);
80
HTextItem::~HTextItem()
84
HTextItem* HTextItem::newInstance() const
86
return new HTextItem();
89
QList<HPersonWithRole> HTextItem::authors() const
92
getCdsProperty(HCdsProperties::upnp_author, &value);
93
return toList<HPersonWithRole>(value.toList());
96
QString HTextItem::longDescription() const
99
getCdsProperty(HCdsProperties::upnp_longDescription, &value);
100
return value.toString();
103
HStorageMedium HTextItem::storageMedium() const
106
getCdsProperty(HCdsProperties::upnp_storageMedium, &value);
107
return value.value<HStorageMedium>();
110
QList<HRating> HTextItem::ratings() const
113
getCdsProperty(HCdsProperties::upnp_rating, &value);
114
return toList<HRating>(value.toList());
117
QString HTextItem::description() const
120
getCdsProperty(HCdsProperties::dc_description, &value);
121
return value.toString();
124
QStringList HTextItem::publishers() const
127
getCdsProperty(HCdsProperties::dc_publisher, &value);
128
return value.toStringList();
131
QStringList HTextItem::contributors() const
134
getCdsProperty(HCdsProperties::dc_contributor, &value);
135
return value.toStringList();
138
QDateTime HTextItem::date() const
141
getCdsProperty(HCdsProperties::dc_date, &value);
142
return value.toDateTime();
145
QList<QUrl> HTextItem::relations() const
148
getCdsProperty(HCdsProperties::dc_relation, &value);
149
return toList<QUrl>(value.toList());
152
QStringList HTextItem::languages() const
155
getCdsProperty(HCdsProperties::dc_language, &value);
156
return value.toStringList();
159
QStringList HTextItem::rights() const
162
getCdsProperty(HCdsProperties::dc_rights, &value);
163
return value.toStringList();
166
void HTextItem::setAuthors(const QList<HPersonWithRole>& arg)
168
setCdsProperty(HCdsProperties::upnp_author, toList(arg));
171
void HTextItem::setLongDescription(const QString& arg)
173
setCdsProperty(HCdsProperties::upnp_longDescription, arg);
176
void HTextItem::setStorageMedium(const HStorageMedium& arg)
178
setCdsProperty(HCdsProperties::upnp_storageMedium, QVariant::fromValue(arg));
181
void HTextItem::setRatings(const QList<HRating>& arg)
183
setCdsProperty(HCdsProperties::upnp_rating, toList(arg));
186
void HTextItem::setDescription(const QString& arg)
188
setCdsProperty(HCdsProperties::dc_description, arg);
191
void HTextItem::setPublishers(const QStringList& arg)
193
setCdsProperty(HCdsProperties::dc_publisher, arg);
196
void HTextItem::setContributors(const QStringList& arg)
198
setCdsProperty(HCdsProperties::dc_contributor, arg);
201
void HTextItem::setDate(const QDateTime& arg)
203
setCdsProperty(HCdsProperties::dc_date, arg);
206
void HTextItem::setRelations(const QList<QUrl>& arg)
208
setCdsProperty(HCdsProperties::dc_relation, toList(arg));
211
void HTextItem::setLanguages(const QStringList& arg)
213
setCdsProperty(HCdsProperties::dc_language, arg);
216
void HTextItem::setRights(const QStringList& arg)
218
setCdsProperty(HCdsProperties::dc_rights, arg);