Changeset View
Changeset View
Standalone View
Standalone View
src/acbf/AcbfContentrating.cpp
Show All 34 Lines | |||||
35 | }; | 35 | }; | ||
36 | 36 | | |||
37 | ContentRating::ContentRating(BookInfo* parent) | 37 | ContentRating::ContentRating(BookInfo* parent) | ||
38 | : QObject(parent) | 38 | : QObject(parent) | ||
39 | , d(new Private) | 39 | , d(new Private) | ||
40 | { | 40 | { | ||
41 | } | 41 | } | ||
42 | 42 | | |||
43 | ContentRating::~ContentRating() | 43 | ContentRating::~ContentRating() = default; | ||
44 | { | | |||
45 | delete d; | | |||
46 | } | | |||
47 | 44 | | |||
48 | void ContentRating::toXml(QXmlStreamWriter* writer) | 45 | void ContentRating::toXml(QXmlStreamWriter* writer) | ||
49 | { | 46 | { | ||
50 | writer->writeStartElement("content-rating"); | 47 | writer->writeStartElement(QStringLiteral("content-rating")); | ||
51 | writer->writeAttribute("type", d->type); | 48 | writer->writeAttribute(QStringLiteral("type"), d->type); | ||
52 | writer->writeCharacters(d->rating); | 49 | writer->writeCharacters(d->rating); | ||
53 | writer->writeEndElement(); | 50 | writer->writeEndElement(); | ||
54 | } | 51 | } | ||
55 | 52 | | |||
56 | bool ContentRating::fromXml(QXmlStreamReader *xmlReader) | 53 | bool ContentRating::fromXml(QXmlStreamReader *xmlReader) | ||
57 | { | 54 | { | ||
58 | setType(xmlReader->attributes().value("type").toString()); | 55 | setType(xmlReader->attributes().value(QStringLiteral("type")).toString()); | ||
59 | setRating(xmlReader->readElementText(QXmlStreamReader::IncludeChildElements)); | 56 | setRating(xmlReader->readElementText(QXmlStreamReader::IncludeChildElements)); | ||
60 | qDebug() << Q_FUNC_INFO << "Created a content rating for" << type() << "with rating" << rating(); | 57 | qDebug() << Q_FUNC_INFO << "Created a content rating for" << type() << "with rating" << rating(); | ||
61 | return true; | 58 | return true; | ||
62 | } | 59 | } | ||
63 | 60 | | |||
64 | QString ContentRating::type() | 61 | QString ContentRating::type() const | ||
65 | { | 62 | { | ||
66 | return d->type; | 63 | return d->type; | ||
67 | } | 64 | } | ||
68 | 65 | | |||
69 | void ContentRating::setType(QString type) | 66 | void ContentRating::setType(const QString& type) | ||
70 | { | 67 | { | ||
71 | d->type = type; | 68 | d->type = type; | ||
72 | } | 69 | } | ||
73 | 70 | | |||
74 | QString ContentRating::rating() | 71 | QString ContentRating::rating() const | ||
75 | { | 72 | { | ||
76 | return d->rating; | 73 | return d->rating; | ||
77 | } | 74 | } | ||
78 | 75 | | |||
79 | void ContentRating::setRating(QString rating) | 76 | void ContentRating::setRating(const QString& rating) | ||
80 | { | 77 | { | ||
81 | d->rating = rating; | 78 | d->rating = rating; | ||
82 | } | 79 | } |