File indexing completed on 2024-05-05 03:50:39
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2015 Stanciu Marius-Valeriu <stanciumarius94@gmail.com> 0004 // 0005 0006 #ifndef NODEITEMDELEGATE_H 0007 #define NODEITEMDELEGATE_H 0008 0009 // Qt 0010 #include <QItemDelegate> 0011 #include <QTreeView> 0012 0013 // Marble 0014 #include "EditPolygonDialog.h" 0015 0016 namespace Marble 0017 { 0018 0019 class GeoDataPlacemark; 0020 0021 /** 0022 * @brief The NodeItemDelegate class handles the NodeModel view for both the EditPolygonDialog 0023 * and EditPolylineDialog. It manages editing and updating the NodeModel and triggers drawing 0024 * updates when changes are made. 0025 */ 0026 class NodeItemDelegate : public QItemDelegate 0027 { 0028 0029 Q_OBJECT 0030 0031 public: 0032 NodeItemDelegate( GeoDataPlacemark* placemark, QTreeView* view ); 0033 QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override; 0034 QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0035 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0036 void setEditorData(QWidget *editor, const QModelIndex &index) const override; 0037 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; 0038 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0039 0040 private: 0041 GeoDataPlacemark* m_placemark; 0042 mutable QModelIndex m_indexBeingEdited; 0043 QTreeView* m_view; 0044 0045 private Q_SLOTS: 0046 void previewNodeMove( qreal value); 0047 void unsetCurrentEditor( QWidget* widget ); 0048 0049 Q_SIGNALS: 0050 void modelChanged( GeoDataPlacemark* placemark ) const; 0051 void geometryChanged() const; 0052 }; 0053 0054 } 0055 #endif