File indexing completed on 2024-06-09 04:32:01
0001 /* 0002 * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 #ifndef ACBFCONTENTRATING_H 0023 #define ACBFCONTENTRATING_H 0024 0025 #include <memory> 0026 0027 #include "AcbfBookinfo.h" 0028 /** 0029 * \brief Class to handle the content rating of the work. 0030 * 0031 * Because there are multiple ContentRating systems over various 0032 * countries, ACBF can handle multiple content rating objects, and 0033 * has entries for handling which system said rating is in. 0034 * 0035 * This is used in the BookInfo object. 0036 */ 0037 namespace AdvancedComicBookFormat 0038 { 0039 class ACBF_EXPORT ContentRating : public QObject 0040 { 0041 Q_OBJECT 0042 Q_PROPERTY(QString rating READ rating WRITE setRating NOTIFY ratingChanged) 0043 Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) 0044 public: 0045 explicit ContentRating(BookInfo* parent = nullptr); 0046 ~ContentRating() override; 0047 0048 /** 0049 * \brief write this content rating to the xml writer. 0050 */ 0051 void toXml(QXmlStreamWriter* writer); 0052 /** 0053 * \brief load a content-rating section from the xml into this object. 0054 * @return True if the xmlReader encountered no errors. 0055 */ 0056 bool fromXml(QXmlStreamReader *xmlReader); 0057 0058 /** 0059 * @return the system that the content rating belongs to. 0060 */ 0061 Q_INVOKABLE QString type() const; 0062 /** 0063 * \brief set the system that defines this rating. 0064 * @param type - the name of the system. 0065 */ 0066 Q_INVOKABLE void setType(const QString& type); 0067 /** 0068 * @brief fires when the type changes. 0069 */ 0070 Q_SIGNAL void typeChanged(); 0071 0072 /** 0073 * @return the rating label as a string. 0074 */ 0075 Q_INVOKABLE QString rating() const; 0076 /** 0077 * \brief set the rating. 0078 * @param rating - the name of the rating label as a QString. 0079 */ 0080 Q_INVOKABLE void setRating(const QString& rating); 0081 /** 0082 * @brief fires when the rating changes. 0083 */ 0084 Q_SIGNAL void ratingChanged(); 0085 private: 0086 class Private; 0087 std::unique_ptr<Private> d; 0088 }; 0089 } 0090 0091 #endif//ACBFCONTENTRATING_H