Marble

PluginItemDelegate.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
4//
5
6#ifndef MARBLE_PLUGINITEMDELEGATE_H
7#define MARBLE_PLUGINITEMDELEGATE_H
8
9#include <QAbstractItemDelegate>
10
11#include <QIcon>
12#include <QModelIndex>
13
14class QPainter;
15class QRect;
18
19namespace Marble
20{
21
22class PluginItemDelegate : public QAbstractItemDelegate
23{
25
26public:
27 explicit PluginItemDelegate(QAbstractItemView *view, QObject *parent = nullptr);
28 ~PluginItemDelegate() override;
29
30 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
31 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
32
33 void setAboutIcon(const QIcon &icon);
34 void setConfigIcon(const QIcon &icon);
35
37 /**
38 * This signal is emitted if the user clicks on a "about"-button of an item in the view
39 * passed to the constructor.
40 */
41 void aboutPluginClicked(const QModelIndex &index);
42
43 /**
44 * This signal is emitted if the user clicks on a "configure"-button of an item in the view
45 * passed to the constructor.
46 */
47 void configPluginClicked(const QModelIndex &index);
48
49protected:
50 bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
51
52private:
53 enum ButtonType {
54 About,
55 Configure
56 };
57
59 checkboxOption(const QStyleOptionViewItem &option, const QModelIndex &index, int position = 0, Qt::AlignmentFlag alignment = Qt::AlignLeft);
60 QStyleOptionButton buttonOption(const QStyleOptionViewItem &option,
61 const QModelIndex &index,
62 PluginItemDelegate::ButtonType type,
63 int position = 0,
64 Qt::AlignmentFlag alignment = Qt::AlignLeft) const;
65 static QSize nameSize(const QModelIndex &index);
66
67 static QRect alignRect(const QRect &object, const QRect &frame, int position, Qt::AlignmentFlag alignment);
68
69 QModelIndex m_configPressedIndex;
70 QModelIndex m_aboutPressedIndex;
71
72 QIcon m_aboutIcon;
73 QIcon m_configIcon;
74};
75
76}
77
78#endif
Binds a QML item to a specific geodetic location in screen coordinates.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
virtual bool event(QEvent *e)
QObject * parent() const const
AlignmentFlag
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.