summaryrefslogtreecommitdiff
path: root/navit/gui/qt5_qml/navitvehiclesmodel.h
blob: 625be7486e2a77022504a64e0c37c0e48f861c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef NAVITVEHICLESMODEL_H
#define NAVITVEHICLESMODEL_H

#include <QAbstractItemModel>
#include <QDebug>
#include <QVariantMap>
#include "navitinstance.h"
#include "navithelper.h"

#include <glib.h>
extern "C" {
#include "config.h"
#include "item.h" /* needs to be first, as attr.h depends on it */
#include "navit.h"

#include "coord.h"
#include "attr.h"
#include "xmlconfig.h" // for NAVIT_OBJECT
#include "layout.h"
#include "map.h"
#include "transform.h"

#include "mapset.h"
#include "search.h"
#include "vehicleprofile.h"

#include "proxy.h"
}

class NavitVehiclesModel : public QAbstractItemModel
{
    Q_OBJECT
    Q_PROPERTY(NavitInstance * navit MEMBER m_navitInstance WRITE setNavit)
public:
    NavitVehiclesModel(QObject *parent = 0);

    enum VehiclesModelRoles {
        NameRole = Qt::UserRole + 1,
        ActionRole,
        ImageUrlRole
    };

    int rowCount(const QModelIndex & parent = QModelIndex()) const override;
    QHash<int, QByteArray> roleNames() const override;
    QVariant data(const QModelIndex & index, int role) const override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;

    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
    QModelIndex parent(const QModelIndex &child) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    void setNavit(NavitInstance * navit);
    Q_INVOKABLE void setVehicle(QString name);
    Q_INVOKABLE void update();
private:
    QList<QVariantMap> m_vehicles;
    NavitInstance *m_navitInstance = nullptr;
};

#endif // NAVITVEHICLESMODEL_H