modernize: Pass arguments by value and move in constructors
[quassel.git] / src / uisupport / aboutdata.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #pragma once
22
23 #include "uisupport-export.h"
24
25 #include <QList>
26 #include <QLocale>
27 #include <QString>
28
29 #ifdef HAVE_KF5
30 #  include <KCoreAddons/KAboutData>
31 #endif
32
33
34 /**
35  * Represents a contributor or author for Quassel.
36  *
37  * This is used to show a list of contributors in the About Quassel dialog.
38  */
39 class UISUPPORT_EXPORT AboutPerson
40 {
41 public:
42     /**
43      * Constructor.
44      *
45      * @param[in] name The person's name (in the form "Firstname Surname")
46      * @param[in] nick The person's nickname, if applicable
47      * @param[in] task Things the person does or has done for the project
48      * @param[in] emailAddress The person's email address, if applicable
49      * @param[in] translatedLanguage The language the person helped translate (only applicable for translators)
50      */
51     AboutPerson(QString name, QString nick, QString task, QString emailAddress = QString(), QLocale::Language translatedLanguage = QLocale::C);
52
53     /**
54      * Gets the person's name.
55      *
56      * @returns The person's name
57      */
58     QString name() const;
59
60     /**
61      * Gets the person's nick.
62      *
63      * @returns The person's nick
64      */
65     QString nick() const;
66
67     /**
68      * Gets the person's task.
69      *
70      * @returns The person's task
71      */
72     QString task() const;
73
74     /**
75      * Gets the person's e-mail address.
76      *
77      * @returns The person's e-mail address
78      */
79     QString emailAddress() const;
80
81     /**
82      * Gets the language this person helped translate.
83      *
84      * @returns The language this person helped translate
85      */
86     QLocale::Language translatedLanguage() const;
87
88     /**
89      * Gets the person's formatted name and nick.
90      *
91      * @returns The person's name and nick formatted for combined output
92      */
93     QString prettyName() const;
94
95 private:
96     QString _name;               ///< The person's name
97     QString _nick;               ///< The person's nick
98     QString _task;               ///< The person's task
99     QString _emailAddress;       ///< The person's email address
100     QLocale::Language _language; ///< The language the person helps translate
101 };
102
103
104 /**
105  * Holds a list of authors, contributors and translators.
106  *
107  * This class is meant to hold the list of people who contributed to Quassel, used for displaying
108  * the About Quassel dialog. Additionally, this class can provide a KAboutData object to be shown
109  * if KDE integration is enabled.
110  */
111 class UISUPPORT_EXPORT AboutData : public QObject
112 {
113     Q_OBJECT
114 public:
115     /**
116      * Default constructor.
117      *
118      * @param[in] parent The parent object, if applicable
119      */
120     AboutData(QObject *parent = nullptr);
121
122     /**
123      * Adds an author to the list of contributors.
124      *
125      * Authors are people who contributed a significant amount of code to Quassel.
126      *
127      * @param[in] author The author to add
128      * @returns A reference to this AboutData instance
129      */
130     AboutData &addAuthor(const AboutPerson &author);
131
132     /**
133      * Adds a list of authors to the list of contributors.
134      *
135      * This method allows the use of a brace initializer in order to easily add a long list of
136      * people.
137      *
138      * @param[in] authors A list of authors to add
139      * @returns A reference to this AboutData instance
140      */
141     AboutData &addAuthors(std::initializer_list<AboutPerson> authors);
142
143     /**
144      * Adds a contributor.
145      *
146      * @param[in] author The contributor to add
147      * @returns A reference to this AboutData instance
148      */
149     AboutData &addCredit(const AboutPerson &credit);
150
151     /**
152      * Adds a list of contributors.
153      *
154      * This method allows the use of brace initializers in order to easily add a long list of
155      * people.
156      *
157      * @param[in] authors A list of contributors to add
158      * @returns A reference to this AboutData instance
159      */
160     AboutData &addCredits(std::initializer_list<AboutPerson> credits);
161
162     /**
163      * Gets the list of authors stored in this AboutData instance.
164      *
165      * @returns A list of authors
166      */
167     QList<AboutPerson> authors() const;
168
169     /**
170      * Gets the list of non-author contributors stored in this AboutData instance.
171      *
172      * @returns A list of contributors
173      */
174     QList<AboutPerson> credits() const;
175
176 #ifdef HAVE_KF5
177     /**
178      * Creates a KAboutData instance based on the contents of this AboutData instance.
179      *
180      * @returns A KAboutData instance holding the list of contributors as well as any additional
181      *          data required for KAboutDialog and friends
182      */
183     KAboutData kAboutData() const;
184 #endif
185
186     /**
187      * Fills the given AboutData instance with data relevant for Quassel itself.
188      *
189      * This method adds a (hardcoded) list of contributors to the given AboutData instance.
190      *
191      * @param[in,out] aboutData An existing AboutData instance to add Quassel's contributors to
192      */
193     static void setQuasselPersons(AboutData *aboutData);
194
195 private:
196     QList<AboutPerson> _authors;  ///< The list of authors
197     QList<AboutPerson> _credits;  ///< The list of other contributors
198 };