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_ITEMSGRIDVIEWDELEGATE_P_H
0010 #define KNEWSTUFF3_ITEMSGRIDVIEWDELEGATE_P_H
0011 
0012 #include "itemsviewbasedelegate_p.h"
0013 class QToolButton;
0014 namespace KNS3
0015 {
0016 static const int ItemGridHeight = 202;
0017 static const int ItemGridWidth = 158;
0018 
0019 static const int FrameThickness = 5;
0020 static const int ItemMargin = 2;
0021 class ItemsGridViewDelegate : public ItemsViewBaseDelegate
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit ItemsGridViewDelegate(QAbstractItemView *itemView, KNSCore::Engine *engine, QObject *parent = nullptr);
0026     ~ItemsGridViewDelegate() override;
0027 
0028     // paint the item at index with all its attributes shown
0029     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0030 
0031     // get the list of widgets
0032     QList<QWidget *> createItemWidgets(const QModelIndex &index) const override;
0033 
0034     // update the widgets
0035     void updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const override;
0036 
0037     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0038 
0039 private:
0040     void createOperationBar();
0041     void displayOperationBar(const QRect &rect, const QModelIndex &index);
0042 
0043 private:
0044     QWidget *m_operationBar;
0045     QToolButton *m_detailsButton;
0046     QToolButton *m_installButton;
0047 
0048     QModelIndex m_oldIndex;
0049     mutable int m_elementYPos;
0050 };
0051 }
0052 
0053 #endif