File indexing completed on 2024-04-28 15:29:04
0001 /* 0002 SPDX-FileCopyrightText: 2008 Jeremy Whiting <jpwhiting@kde.org> 0003 SPDX-FileCopyrightText: 2010 Reza Fatahilah Shah <rshah0385@kireihana.com> 0004 SPDX-FileCopyrightText: 2010 Frederik Gladhorn <gladhorn@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 0009 #ifndef KNEWSTUFF3_ITEMSVIEWBASEDELEGATE_P_H 0010 #define KNEWSTUFF3_ITEMSVIEWBASEDELEGATE_P_H 0011 0012 #include <QList> 0013 #include <QModelIndex> 0014 #include <QObject> 0015 0016 #include "core/engine.h" 0017 #include "core/entryinternal.h" 0018 0019 #include <KWidgetItemDelegate> 0020 0021 namespace KNS3 0022 { 0023 class ItemsViewBaseDelegate : public KWidgetItemDelegate 0024 { 0025 Q_OBJECT 0026 public: 0027 explicit ItemsViewBaseDelegate(QAbstractItemView *itemView, KNSCore::Engine *engine, QObject *parent = nullptr); 0028 ~ItemsViewBaseDelegate() override; 0029 // paint the item at index with all its attributes shown 0030 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override = 0; 0031 0032 // get the list of widgets 0033 QList<QWidget *> createItemWidgets(const QModelIndex &index) const override = 0; 0034 0035 // update the widgets 0036 void updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const override = 0; 0037 0038 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override = 0; 0039 0040 Q_SIGNALS: 0041 void signalShowDetails(const KNSCore::EntryInternal &entry); 0042 0043 protected Q_SLOTS: 0044 bool eventFilter(QObject *watched, QEvent *event) override; 0045 void slotInstallClicked(); 0046 void slotInstallActionTriggered(QAction *action); 0047 void slotLinkClicked(const QString &url); 0048 void slotDetailsClicked(const QModelIndex &index); 0049 void slotDetailsClicked(); 0050 0051 protected: 0052 KNSCore::Engine *const m_engine; 0053 QAbstractItemView *const m_itemView; 0054 QIcon m_iconInvalid; 0055 QIcon m_iconDownloadable; 0056 QIcon m_iconInstall; 0057 QIcon m_iconUpdate; 0058 QIcon m_iconDelete; 0059 QPixmap m_frameImage; 0060 QSize m_buttonSize; 0061 }; 0062 } 0063 #endif