Marble

GeoDataTreeModel.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Thibaut Gridel <tgridel@free.fr>
4//
5
6#ifndef MARBLE_GEODATATREEMODEL_H
7#define MARBLE_GEODATATREEMODEL_H
8
9#include "marble_export.h"
10
11#include <QAbstractItemModel>
12
14
15namespace Marble
16{
17class GeoDataObject;
18class GeoDataDocument;
19class GeoDataFeature;
20class GeoDataContainer;
21class GeoDataTourPrimitive;
22
23/**
24 * @short The representation of GeoData in a model
25 * This class represents all available data given by kml-data files.
26 */
27class MARBLE_EXPORT GeoDataTreeModel : public QAbstractItemModel
28{
29 Q_OBJECT
30
31public:
32 /**
33 * Creates a new GeoDataTreeModel.
34 *
35 * @param parent The parent object.
36 */
37 explicit GeoDataTreeModel(QObject *parent = nullptr);
38
39 /**
40 * Destroys the GeoDataModel.
41 */
42 ~GeoDataTreeModel() override;
43
44 /**
45 * Return the number of Items in the Model.
46 */
47 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
48
49 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
50
51 QHash<int, QByteArray> roleNames() const override;
52
53 QVariant data(const QModelIndex &index, int role) const override;
54
55 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
56
57 QModelIndex index(const GeoDataObject *object) const;
58
59 QModelIndex parent(const QModelIndex &index) const override;
60
61 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
62
63 Qt::ItemFlags flags(const QModelIndex &index) const override;
64
65 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
66
67 QItemSelectionModel *selectionModel();
68
69 GeoDataDocument *rootDocument();
70
71public Q_SLOTS:
72
73 /**
74 * Sets the root document to use. This replaces previously loaded data, if any.
75 * @param document The new root document. Ownership retains with the caller,
76 * i.e. GeoDataTreeModel will not delete the passed document at its destruction.
77 */
78 void setRootDocument(GeoDataDocument *document);
79
80 Q_INVOKABLE int addFeature(GeoDataContainer *parent, GeoDataFeature *feature, int row = -1);
81
82 Q_INVOKABLE bool removeFeatureRow(Marble::GeoDataContainer *parent, int index);
83
84 Q_INVOKABLE int removeFeature(GeoDataFeature *feature);
85
86 void updateFeature(GeoDataFeature *feature);
87
88 Q_INVOKABLE int addDocument(GeoDataDocument *document);
89
90 void removeDocument(int index);
91
92 void removeDocument(GeoDataDocument *document);
93
94 Q_INVOKABLE int addTourPrimitive(const QModelIndex &parent, GeoDataTourPrimitive *primitive, int row = -1);
95 Q_INVOKABLE bool removeTourPrimitive(const QModelIndex &parent, int index);
96 Q_INVOKABLE bool swapTourPrimitives(const QModelIndex &parent, int indexA, int indexB);
97
98Q_SIGNALS:
99 /// insert and remove row don't trigger any signal that proxies forward
100 /// this signal will refresh geometry layer and placemark layout
101 void removed(GeoDataObject *object);
102 void added(GeoDataObject *object);
103
104private:
105 Q_DISABLE_COPY(GeoDataTreeModel)
106 class Private;
107 Private *const d;
108};
109
110}
111
112#endif // MARBLE_GEODATATREEMODEL_H
A base class that can hold GeoDataFeatures.
A container for Features, Styles and in the future Schemas.
A base class for all geodata features.
A base class for all geodata objects.
The representation of GeoData in a model This class represents all available data given by kml-data f...
void removed(GeoDataObject *object)
insert and remove row don't trigger any signal that proxies forward this signal will refresh geometry...
Binds a QML item to a specific geodetic location in screen coordinates.
DisplayRole
typedef ItemFlags
Orientation
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.