Marble

TourItemDelegate.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Mihail Ivchenko <ematirov@gmail.com>
4// SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <sanjiban22393@gmail.com>
5// SPDX-FileCopyrightText: 2014 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
6//
7
8#ifndef TOURITEMDELEGATE_H
9#define TOURITEMDELEGATE_H
10
11#include <QStyledItemDelegate>
12
13class QListView;
14
15namespace Marble
16{
17
18class MarbleWidget;
19class GeoDataAnimatedUpdate;
20class GeoDataPlaylist;
21class GeoDataFeature;
22class TourWidget;
23
24class TourItemDelegate : public QStyledItemDelegate
25{
27
28public:
29 TourItemDelegate(QListView *view, MarbleWidget *widget, TourWidget *tour);
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 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
33 bool editable() const;
34 void setEditable(bool editable);
35 QModelIndex firstFlyTo() const;
36 bool editAnimatedUpdate(GeoDataAnimatedUpdate *animatedUpdate, bool create = true);
37 QString defaultFeatureId() const;
38 GeoDataFeature *findFeature(const QString &id) const;
39
40public Q_SLOTS:
41 /** Editing duration for first flyTo element in playlist will be disabled. */
42 void setFirstFlyTo(const QPersistentModelIndex &index);
43 /** Sets id of default feature for Remove Item */
44 void setDefaultFeatureId(const QString &id);
45
47 void editingChanged(const QModelIndex &index);
48 void edited(const QModelIndex &index);
49 void editableChanged(bool editable);
50 void firstFlyToChanged(const QPersistentModelIndex &newFirstFlyTo);
51 void featureIdsChanged(const QStringList &ids);
52 void defaultFeatureIdChanged(const QString &id);
53
54public:
55 enum Element {
56 GeoDataElementIcon,
57 Label,
58 EditButton,
59 ActionButton
60 };
61
62protected:
63 bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
64
65private Q_SLOTS:
66 void closeEditor(const QModelIndex &index);
67
68private:
69 static QRect position(Element element, const QStyleOptionViewItem &option);
70 static QStringList findIds(const GeoDataPlaylist &playlist, bool onlyFeatures = false);
71 GeoDataPlaylist *playlist() const;
72 QList<QPersistentModelIndex> m_editingIndices;
73 QListView *m_listView;
74 MarbleWidget *m_widget;
75 bool m_editable;
76 QPersistentModelIndex m_firstFlyTo;
77 QString m_defaultFeatureId;
78 TourWidget *m_tourWidget;
79};
80
81} // namespace Marble
82
83#endif
Binds a QML item to a specific geodetic location in screen coordinates.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
virtual bool event(QEvent *e)
QObject * parent() const const
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.