File indexing completed on 2024-10-13 06:39:57
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2010 Teo Mrnjavac <teo@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef KABOUT_APPLICATION_PERSON_LIST_DELEGATE_H 0009 #define KABOUT_APPLICATION_PERSON_LIST_DELEGATE_H 0010 0011 #include <KWidgetItemDelegate> 0012 0013 namespace KDEPrivate 0014 { 0015 class KAboutApplicationPersonProfile; 0016 0017 class KAboutApplicationPersonListDelegate : public KWidgetItemDelegate 0018 { 0019 Q_OBJECT 0020 public: 0021 explicit KAboutApplicationPersonListDelegate(QAbstractItemView *itemView, QObject *parent = nullptr); 0022 0023 ~KAboutApplicationPersonListDelegate() override 0024 { 0025 } 0026 0027 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) 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 KAboutApplicationPersonProfile &profile) const; 0041 QRect widgetsRect(const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const; 0042 0043 enum DelegateWidgets { 0044 TextLabel = 0, 0045 MainLinks, 0046 SocialLinks, 0047 }; 0048 0049 enum MainLinkActions { 0050 EmailAction = 0, 0051 HomepageAction, 0052 VisitProfileAction, 0053 }; 0054 }; 0055 0056 } // namespace KDEPrivate 0057 0058 #endif // KABOUT_APPLICATION_PERSON_LIST_DELEGATE_H