File indexing completed on 2024-05-05 03:49:19
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #ifndef MARBLE_ROUTEREQUESTMODEL_H 0007 #define MARBLE_ROUTEREQUESTMODEL_H 0008 0009 #include <QAbstractListModel> 0010 0011 namespace Marble { 0012 class RouteRequest; 0013 class Routing; 0014 } 0015 0016 class RouteRequestModel : public QAbstractListModel 0017 { 0018 Q_OBJECT 0019 0020 Q_PROPERTY( Marble::Routing* routing READ routing WRITE setRouting NOTIFY routingChanged ) 0021 Q_PROPERTY( int count READ rowCount NOTIFY rowCountChanged ) 0022 0023 public: 0024 enum RouteRequestModelRoles { 0025 LongitudeRole = Qt::UserRole+1, 0026 LatitudeRole = Qt::UserRole+2 0027 }; 0028 0029 /** Constructor */ 0030 explicit RouteRequestModel( QObject *parent = nullptr ); 0031 0032 /** Destructor */ 0033 ~RouteRequestModel() override; 0034 0035 // Model querying 0036 0037 /** Overload of QAbstractListModel */ 0038 int rowCount ( const QModelIndex &parent = QModelIndex() ) const override; 0039 0040 /** Overload of QAbstractListModel */ 0041 QHash<int, QByteArray> roleNames() const override; 0042 0043 /** Overload of QAbstractListModel */ 0044 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; 0045 0046 /** Overload of QAbstractListModel */ 0047 QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const override; 0048 0049 Marble::Routing *routing(); 0050 0051 public Q_SLOTS: 0052 void setRouting( Marble::Routing *routing ); 0053 0054 void setPosition ( int index, qreal longitude, qreal latitude ); 0055 0056 Q_SIGNALS: 0057 void routingChanged(); 0058 void rowCountChanged(); 0059 0060 private Q_SLOTS: 0061 void updateMap(); 0062 0063 void updateData( int index ); 0064 0065 void updateAfterRemoval( int index ); 0066 0067 void updateAfterAddition( int index ); 0068 0069 private: 0070 Marble::RouteRequest* m_request; 0071 Marble::Routing *m_routing; 0072 QHash<int, QByteArray> m_roleNames; 0073 }; 0074 0075 #endif // MARBLE_ROUTEREQUESTMODEL_H