Marble

RouteRequestModel.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <[email protected]>
4 //
5 
6 #ifndef MARBLE_ROUTEREQUESTMODEL_H
7 #define MARBLE_ROUTEREQUESTMODEL_H
8 
9 #include <QAbstractListModel>
10 
11 namespace Marble {
12  class RouteRequest;
13  class Routing;
14 }
15 
16 class RouteRequestModel : public QAbstractListModel
17 {
18  Q_OBJECT
19 
20  Q_PROPERTY( Marble::Routing* routing READ routing WRITE setRouting NOTIFY routingChanged )
21  Q_PROPERTY( int count READ rowCount NOTIFY rowCountChanged )
22 
23 public:
24  enum RouteRequestModelRoles {
25  LongitudeRole = Qt::UserRole+1,
26  LatitudeRole = Qt::UserRole+2
27  };
28 
29  /** Constructor */
30  explicit RouteRequestModel( QObject *parent = nullptr );
31 
32  /** Destructor */
33  ~RouteRequestModel() override;
34 
35  // Model querying
36 
37  /** Overload of QAbstractListModel */
38  int rowCount ( const QModelIndex &parent = QModelIndex() ) const override;
39 
40  /** Overload of QAbstractListModel */
41  QHash<int, QByteArray> roleNames() const override;
42 
43  /** Overload of QAbstractListModel */
44  QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
45 
46  /** Overload of QAbstractListModel */
47  QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
48 
49  Marble::Routing *routing();
50 
51 public Q_SLOTS:
52  void setRouting( Marble::Routing *routing );
53 
54  void setPosition ( int index, qreal longitude, qreal latitude );
55 
56 Q_SIGNALS:
57  void routingChanged();
58  void rowCountChanged();
59 
60 private Q_SLOTS:
61  void updateMap();
62 
63  void updateData( int index );
64 
65  void updateAfterRemoval( int index );
66 
67  void updateAfterAddition( int index );
68 
69 private:
70  Marble::RouteRequest* m_request;
71  Marble::Routing *m_routing;
72  QHash<int, QByteArray> m_roleNames;
73 };
74 
75 #endif // MARBLE_ROUTEREQUESTMODEL_H
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
UserRole
virtual int rowCount(const QModelIndex &parent) const const=0
Q_SLOTSQ_SLOTS
virtual QVariant data(const QModelIndex &index, int role) const const=0
virtual QHash< int, QByteArray > roleNames() const const
Orientation
Binds a QML item to a specific geodetic location in screen coordinates.
Q_SIGNALSQ_SIGNALS
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const const
Points to be included in a route.
Definition: RouteRequest.h:26
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.