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_LIST_DELEGATE_H |
9 | #define KABOUT_APPLICATION_COMPONENT_LIST_DELEGATE_H |
10 | |
11 | #include <KWidgetItemDelegate> |
12 | |
13 | namespace KDEPrivate |
14 | { |
15 | class KAboutApplicationComponentProfile; |
16 | |
17 | class KAboutApplicationComponentListDelegate : public KWidgetItemDelegate |
18 | { |
19 | Q_OBJECT |
20 | public: |
21 | explicit KAboutApplicationComponentListDelegate(QAbstractItemView *itemView, QObject *parent = nullptr); |
22 | |
23 | ~KAboutApplicationComponentListDelegate() override |
24 | { |
25 | } |
26 | |
27 | void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &) const override; |
28 | |
29 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; |
30 | |
31 | QList<QWidget *> createItemWidgets(const QModelIndex &index) const override; |
32 | |
33 | void updateItemWidgets(const QList<QWidget *> &widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const override; |
34 | |
35 | private Q_SLOTS: |
36 | void launchUrl(QAction *action) const; |
37 | |
38 | private: |
39 | int heightForString(const QString &string, int lineWidth, const QStyleOptionViewItem &option) const; |
40 | QString buildTextForProfile(const KAboutApplicationComponentProfile &profile) const; |
41 | QRect widgetsRect(const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const; |
42 | |
43 | enum DelegateWidgets { TextLabel = 0, MainLinks }; |
44 | |
45 | enum MainLinkActions { |
46 | HomepageAction = 0, |
47 | }; |
48 | }; |
49 | |
50 | } // namespace KDEPrivate |
51 | |
52 | #endif // KABOUT_APPLICATION_COMPONENT_LIST_DELEGATE_H |
53 | |