File indexing completed on 2024-04-14 14:29:56

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2021 Julius Künzel <jk.kdedev@smartlab.uber.space>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef KABOUT_APPLICATION_COMPONENT_LIST_DELEGATE_H
0009 #define KABOUT_APPLICATION_COMPONENT_LIST_DELEGATE_H
0010 
0011 #include <KWidgetItemDelegate>
0012 
0013 namespace KDEPrivate
0014 {
0015 class KAboutApplicationComponentProfile;
0016 
0017 class KAboutApplicationComponentListDelegate : public KWidgetItemDelegate
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit KAboutApplicationComponentListDelegate(QAbstractItemView *itemView, QObject *parent = nullptr);
0022 
0023     ~KAboutApplicationComponentListDelegate() override
0024     {
0025     }
0026 
0027     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &) const override;
0028 
0029     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0030 
0031     QList<QWidget *> createItemWidgets(const QModelIndex &index) const override;
0032 
0033     void updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const override;
0034 
0035 private Q_SLOTS:
0036     void launchUrl(QAction *action) const;
0037 
0038 private:
0039     int heightForString(const QString &string, int lineWidth, const QStyleOptionViewItem &option) const;
0040     QString buildTextForProfile(const KAboutApplicationComponentProfile &profile) const;
0041     QRect widgetsRect(const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const;
0042 
0043     enum DelegateWidgets { TextLabel = 0, MainLinks };
0044 
0045     enum MainLinkActions {
0046         HomepageAction = 0,
0047     };
0048 };
0049 
0050 } // namespace KDEPrivate
0051 
0052 #endif // KABOUT_APPLICATION_COMPONENT_LIST_DELEGATE_H