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 <QModelIndex>
12#include <QIcon>
13
14class QPainter;
15class QRect;
18
19namespace Marble
20{
21
22class PluginItemDelegate : public QAbstractItemDelegate
23{
25
26 public:
27 explicit PluginItemDelegate( QAbstractItemView *view, QObject * parent = nullptr );
28 ~PluginItemDelegate() override;
29
30 void paint( QPainter *painter,
31 const QStyleOptionViewItem& option,
32 const QModelIndex& index ) const override;
33 QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex & index ) const override;
34
35 void setAboutIcon( const QIcon& icon );
36 void setConfigIcon( const QIcon& icon );
37
39 /**
40 * This signal is emitted if the user clicks on a "about"-button of an item in the view
41 * passed to the constructor.
42 */
43 void aboutPluginClicked( const QModelIndex &index );
44
45 /**
46 * This signal is emitted if the user clicks on a "configure"-button of an item in the view
47 * passed to the constructor.
48 */
49 void configPluginClicked( const QModelIndex &index );
50
51 protected:
52 bool editorEvent( QEvent *event,
53 QAbstractItemModel *model,
54 const QStyleOptionViewItem &option,
55 const QModelIndex &index ) override;
56
57 private:
58 enum ButtonType {
59 About,
60 Configure
61 };
62
63 static QStyleOptionButton checkboxOption( const QStyleOptionViewItem& option,
64 const QModelIndex& index,
65 int position = 0,
66 Qt::AlignmentFlag alignment = Qt::AlignLeft );
67 QStyleOptionButton buttonOption( const QStyleOptionViewItem& option,
68 const QModelIndex& index,
69 PluginItemDelegate::ButtonType type,
70 int position = 0,
71 Qt::AlignmentFlag alignment = Qt::AlignLeft ) const;
72 static QSize nameSize( const QModelIndex& index );
73
74 static QRect alignRect( const QRect& object, const QRect& frame, int position, Qt::AlignmentFlag alignment );
75
76 QModelIndex m_configPressedIndex;
77 QModelIndex m_aboutPressedIndex;
78
79 QIcon m_aboutIcon;
80 QIcon m_configIcon;
81};
82
83}
84
85#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 Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.