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
56 enum Element {
57 GeoDataElementIcon,
58 Label,
59 EditButton,
60 ActionButton
61 };
62
63protected:
64 bool editorEvent( QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index ) override;
65
66private Q_SLOTS:
67 void closeEditor(const QModelIndex& index);
68
69private:
70 static QRect position( Element element, const QStyleOptionViewItem &option );
71 static QStringList findIds(const GeoDataPlaylist &playlist, bool onlyFeatures = false);
72 GeoDataPlaylist *playlist() const;
73 QList<QPersistentModelIndex> m_editingIndices;
74 QListView* m_listView;
75 MarbleWidget *m_widget;
76 bool m_editable;
77 QPersistentModelIndex m_firstFlyTo;
78 QString m_defaultFeatureId;
79 TourWidget* m_tourWidget;
80};
81
82} // namespace Marble
83
84#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
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.