Changeset View
Changeset View
Standalone View
Standalone View
Modules/about-distro/src/Entry.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | SPDX-FileCopyrightText: 2012-2020 Harald Sitter <sitter@kde.org> | ||||
3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL | ||||
4 | */ | ||||
5 | | ||||
6 | #ifndef ENTRY_H | ||||
7 | #define ENTRY_H | ||||
8 | | ||||
9 | #include <QString> | ||||
10 | #include <KLocalizedString> | ||||
11 | | ||||
12 | // Generic dumpable info entry. | ||||
13 | // This encapsulates a table entry so that it may be put into the UI | ||||
14 | // and also serialized into textual form for copy to clipboard. | ||||
15 | // All entries that are meant to be serializable should derive from this! | ||||
16 | // This class may either be subclassed or used as-is if label/value are trivial | ||||
17 | // to obtain. | ||||
18 | class Entry | ||||
19 | { | ||||
20 | public: | ||||
21 | enum class Language { | ||||
22 | System, | ||||
23 | English | ||||
24 | }; | ||||
25 | | ||||
26 | Entry(const KLocalizedString &label_, const QString &value_); | ||||
27 | virtual ~Entry(); | ||||
28 | | ||||
29 | // When false this entry is garbage (e.g. incomplete data) and shouldn't be rendered. | ||||
30 | bool isValid() const; | ||||
31 | | ||||
32 | // Returns textual representation of entry. | ||||
33 | QString diagnosticLine(Language language = Language::System) const; | ||||
34 | | ||||
35 | // Descriptive label | ||||
36 | KLocalizedString label; | ||||
37 | // Value of the entry (e.g. the version of plasma) | ||||
38 | QString value; | ||||
39 | | ||||
40 | private: | ||||
41 | QString localizedLabel(Language language) const; | ||||
42 | }; | ||||
43 | | ||||
44 | #endif // ENTRY_H |