Changeset View
Changeset View
Standalone View
Standalone View
src/acbf/AcbfAuthor.h
Show All 19 Lines | |||||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #ifndef ACBFAUTHORINFO_H | 22 | #ifndef ACBFAUTHORINFO_H | ||
23 | #define ACBFAUTHORINFO_H | 23 | #define ACBFAUTHORINFO_H | ||
24 | 24 | | |||
25 | #include "AcbfMetadata.h" | 25 | #include "AcbfMetadata.h" | ||
26 | #include <memory> | 26 | #include <memory> | ||
27 | 27 | | |||
28 | /** | ||||
29 | * \brief Class for handling ACBF style authors. | ||||
30 | * | ||||
31 | * ACBF style authors have their names split up into | ||||
32 | * first/middle/last and nickname. This is because | ||||
33 | * traditionally archives use a lastname, first name | ||||
34 | * format to catalogue the entry, while in the west | ||||
35 | * their proper name is firstname/lastname. | ||||
36 | * | ||||
37 | * Nickname is particularly necessary for comics because | ||||
38 | * many artists use a nom de plume of sorts. | ||||
39 | * | ||||
40 | * activity is similar to EPUB role, but where EPUB uses | ||||
41 | * MARC relators, ACBF has its own limited list of activities. | ||||
42 | * These are available as a stringlist from | ||||
43 | * the available activities function. | ||||
44 | * | ||||
45 | * Authors also have two contact options | ||||
46 | * available(homepage and email), the official xsd | ||||
47 | * allows multiple of these. | ||||
48 | * | ||||
49 | * Authors can also have a language assigned. | ||||
50 | * This is relevant for translator in particular, but | ||||
51 | * the official xsd does not invalidate any other with | ||||
52 | * the attribute. | ||||
53 | * | ||||
54 | * Authors should, at minimum have a name, which is either | ||||
55 | * a nickname, or a first and lastname. | ||||
56 | * | ||||
57 | * TODO: Authors can have multiple email and homepage entries | ||||
58 | * according to the official xsd. | ||||
59 | */ | ||||
60 | | ||||
28 | namespace AdvancedComicBookFormat | 61 | namespace AdvancedComicBookFormat | ||
29 | { | 62 | { | ||
30 | class ACBF_EXPORT Author : public QObject | 63 | class ACBF_EXPORT Author : public QObject | ||
31 | { | 64 | { | ||
32 | Q_OBJECT | 65 | Q_OBJECT | ||
33 | public: | 66 | public: | ||
34 | // Author is used in both Bookinfo and Documentinfo, and as such it is parented to Metadata | 67 | // Author is used in both Bookinfo and Documentinfo, and as such it is parented to Metadata | ||
35 | explicit Author(Metadata* parent = nullptr); | 68 | explicit Author(Metadata* parent = nullptr); | ||
36 | ~Author(); | 69 | ~Author(); | ||
37 | 70 | | |||
71 | /** | ||||
72 | * Write the data from this author object into the XmlStream. | ||||
73 | */ | ||||
38 | void toXml(QXmlStreamWriter* writer); | 74 | void toXml(QXmlStreamWriter* writer); | ||
75 | | ||||
76 | /** | ||||
77 | * \brief Load the data from the acbf xml into this author object. | ||||
78 | * @return True if the xmlReader encountered no errors. | ||||
79 | */ | ||||
39 | bool fromXml(QXmlStreamReader *xmlReader); | 80 | bool fromXml(QXmlStreamReader *xmlReader); | ||
40 | 81 | | |||
82 | /** | ||||
83 | * \brief convenience function to put together the different parts | ||||
84 | * of the author's name into a single string. | ||||
85 | * @return a single string for the author's name. | ||||
86 | */ | ||||
41 | Q_INVOKABLE QString displayName() const; | 87 | Q_INVOKABLE QString displayName() const; | ||
42 | 88 | | |||
89 | /** | ||||
90 | * @return The activity this author performed on the book. | ||||
91 | */ | ||||
43 | Q_INVOKABLE QString activity() const; | 92 | Q_INVOKABLE QString activity() const; | ||
93 | | ||||
94 | /** | ||||
95 | * \brief Set the activity this author performed on the book. | ||||
96 | * @param activity - the activity as a string, should be an entry | ||||
97 | * of availableActivities(). | ||||
98 | */ | ||||
44 | Q_INVOKABLE void setActivity(const QString& activity); | 99 | Q_INVOKABLE void setActivity(const QString& activity); | ||
100 | | ||||
101 | /** | ||||
102 | * @return A list of all the approved activities. | ||||
103 | */ | ||||
45 | Q_INVOKABLE static QStringList availableActivities(); | 104 | Q_INVOKABLE static QStringList availableActivities(); | ||
46 | 105 | | |||
47 | // The language this author worked in for this book. Activity dependent (writer, translator, letterer...) | 106 | /** | ||
107 | * \brief The language this author worked in for this book. Activity dependent (writer, translator, letterer...) | ||||
108 | * @return The language in xs:language style language-COUNTRY format. | ||||
109 | */ | ||||
48 | Q_INVOKABLE QString language() const; | 110 | Q_INVOKABLE QString language() const; | ||
111 | | ||||
112 | /** | ||||
113 | * \brief Set the language used by this author, in particular necessary for translator. | ||||
114 | * | ||||
115 | * @param language should be xs:language, which is BCP 47 minus the script. | ||||
116 | */ | ||||
49 | Q_INVOKABLE void setLanguage(const QString& language = QString()); | 117 | Q_INVOKABLE void setLanguage(const QString& language = QString()); | ||
50 | 118 | | |||
119 | /** | ||||
120 | * @return the given name of this author as a QString. | ||||
121 | */ | ||||
51 | Q_INVOKABLE QString firstName() const; | 122 | Q_INVOKABLE QString firstName() const; | ||
123 | | ||||
124 | /** | ||||
125 | * \brief Set the given name of this author. | ||||
126 | * @param name - the given name as a string. | ||||
127 | */ | ||||
52 | Q_INVOKABLE void setFirstName(const QString& name); | 128 | Q_INVOKABLE void setFirstName(const QString& name); | ||
129 | | ||||
130 | /** | ||||
131 | * @return the middles name(s) of this author as a QString. | ||||
132 | */ | ||||
53 | Q_INVOKABLE QString middleName() const; | 133 | Q_INVOKABLE QString middleName() const; | ||
134 | | ||||
135 | /** | ||||
136 | * \brief Set the middles name(s) of this author. | ||||
137 | * @param name - the middle name(s) as a string. | ||||
138 | */ | ||||
54 | Q_INVOKABLE void setMiddleName(const QString& name); | 139 | Q_INVOKABLE void setMiddleName(const QString& name); | ||
140 | | ||||
141 | /** | ||||
142 | * @return the family name of this author as a QString. | ||||
143 | */ | ||||
55 | Q_INVOKABLE QString lastName() const; | 144 | Q_INVOKABLE QString lastName() const; | ||
145 | | ||||
146 | /** | ||||
147 | * \brief Set the family name of this author. | ||||
148 | * @param name - the family name as a string. | ||||
149 | */ | ||||
56 | Q_INVOKABLE void setLastName(const QString& name); | 150 | Q_INVOKABLE void setLastName(const QString& name); | ||
151 | | ||||
152 | /** | ||||
153 | * @return the nick name of this author as a QString. | ||||
154 | */ | ||||
57 | Q_INVOKABLE QString nickName() const; | 155 | Q_INVOKABLE QString nickName() const; | ||
156 | | ||||
157 | /** | ||||
158 | * \brief set the nick name of this author. | ||||
159 | * @param name - the nickname as a string. | ||||
160 | */ | ||||
58 | Q_INVOKABLE void setNickName(const QString& name); | 161 | Q_INVOKABLE void setNickName(const QString& name); | ||
162 | | ||||
163 | /** | ||||
164 | * @return the homepage associated with this author as a QString. | ||||
165 | */ | ||||
59 | Q_INVOKABLE QString homePage() const; | 166 | Q_INVOKABLE QString homePage() const; | ||
167 | | ||||
168 | /** | ||||
169 | * \brief Set the homepage associated with this author. | ||||
170 | * @param homepage - the url of the homepage as a string. | ||||
171 | */ | ||||
60 | Q_INVOKABLE void setHomePage(const QString& homepage); | 172 | Q_INVOKABLE void setHomePage(const QString& homepage); | ||
173 | | ||||
174 | /** | ||||
175 | * @return The email adress associated with this author as a QString. | ||||
176 | */ | ||||
61 | Q_INVOKABLE QString email() const; | 177 | Q_INVOKABLE QString email() const; | ||
178 | | ||||
179 | /** | ||||
180 | * \brief Set the email adress associated with this author. | ||||
181 | * @param email - email as a string. | ||||
182 | */ | ||||
62 | Q_INVOKABLE void setEmail(const QString& email); | 183 | Q_INVOKABLE void setEmail(const QString& email); | ||
63 | private: | 184 | private: | ||
64 | class Private; | 185 | class Private; | ||
65 | std::unique_ptr<Private> d; | 186 | std::unique_ptr<Private> d; | ||
66 | }; | 187 | }; | ||
67 | } | 188 | } | ||
68 | 189 | | |||
69 | #endif//ACBFAUTHORINFO_H | 190 | #endif//ACBFAUTHORINFO_H |