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 { GeoDataElementIcon, Label, EditButton, ActionButton };
56
57protected:
58 bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
59
60private Q_SLOTS:
61 void closeEditor(const QModelIndex &index);
62
63private:
64 static QRect position(Element element, const QStyleOptionViewItem &option);
65 static QStringList findIds(const GeoDataPlaylist &playlist, bool onlyFeatures = false);
66 GeoDataPlaylist *playlist() const;
67 QList<QPersistentModelIndex> m_editingIndices;
68 QListView *m_listView;
69 MarbleWidget *m_widget;
70 bool m_editable;
71 QPersistentModelIndex m_firstFlyTo;
72 QString m_defaultFeatureId;
73 TourWidget *m_tourWidget;
74};
75
76} // namespace Marble
77
78#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 Oct 4 2024 11:59:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.