1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2021 Julius Künzel <jk.kdedev@smartlab.uber.space> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.1-or-later |
6 | */ |
7 | |
8 | #ifndef KABOUT_APPLICATION_COMPONENT_MODEL_H |
9 | #define KABOUT_APPLICATION_COMPONENT_MODEL_H |
10 | |
11 | #include <KAboutData> |
12 | |
13 | #include <QAbstractListModel> |
14 | |
15 | namespace KDEPrivate |
16 | { |
17 | enum { |
18 | LINK_HEIGHT = 32, |
19 | }; |
20 | class KAboutApplicationComponentProfile; |
21 | |
22 | class KAboutApplicationComponentModel : public QAbstractListModel |
23 | { |
24 | Q_OBJECT |
25 | public: |
26 | explicit KAboutApplicationComponentModel(const QList<KAboutComponent> &personList, QObject *parent = nullptr); |
27 | |
28 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
29 | int columnCount(const QModelIndex &parent = QModelIndex()) const override |
30 | { |
31 | Q_UNUSED(parent) |
32 | return 1; |
33 | } |
34 | QVariant data(const QModelIndex &index, int role) const override; |
35 | |
36 | Qt::ItemFlags flags(const QModelIndex &index) const override; |
37 | |
38 | private: |
39 | const QList<KAboutComponent> m_componentList; |
40 | QList<KAboutApplicationComponentProfile> m_profileList; |
41 | }; |
42 | |
43 | class KAboutApplicationComponentProfile |
44 | { |
45 | public: |
46 | KAboutApplicationComponentProfile() |
47 | : m_name() |
48 | , m_description() |
49 | , m_version() |
50 | , m_webAdress() |
51 | , m_license() |
52 | { |
53 | } // needed for QVariant |
54 | |
55 | KAboutApplicationComponentProfile(const QString &name, |
56 | const QString &description, |
57 | const QString &version, |
58 | const QString &webAdress, |
59 | const KAboutLicense &license) |
60 | : m_name(name) |
61 | , m_description(description) |
62 | , m_version(version) |
63 | , m_webAdress(webAdress) |
64 | , m_license(license) |
65 | { |
66 | } |
67 | |
68 | const QString &name() const |
69 | { |
70 | return m_name; |
71 | } |
72 | const QString &description() const |
73 | { |
74 | return m_description; |
75 | } |
76 | const QString &version() const |
77 | { |
78 | return m_version; |
79 | } |
80 | const QString &webAdress() const |
81 | { |
82 | return m_webAdress; |
83 | } |
84 | const KAboutLicense &license() const |
85 | { |
86 | return m_license; |
87 | } |
88 | |
89 | private: |
90 | QString m_name; |
91 | QString m_description; |
92 | QString m_version; |
93 | QString m_webAdress; |
94 | KAboutLicense m_license; |
95 | }; |
96 | |
97 | } // namespace KDEPrivate |
98 | |
99 | Q_DECLARE_METATYPE(KDEPrivate::KAboutApplicationComponentProfile) |
100 | #endif // KABOUT_APPLICATION_COMPONENT_MODEL_H |
101 | |