File indexing completed on 2024-05-12 04:42:52

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPUBLICTRANSPORT_PATHMODEL_H
0008 #define KPUBLICTRANSPORT_PATHMODEL_H
0009 
0010 #include "kpublictransport_export.h"
0011 
0012 #include <KPublicTransport/Path>
0013 
0014 #include <QAbstractListModel>
0015 
0016 namespace KPublicTransport {
0017 
0018 /** Model representing a KPublicTransport::Path.
0019  *  Each row is a KPublicTransport::PathSection, the model computes
0020  *  additional information such as turn directions for each section.
0021  */
0022 class KPUBLICTRANSPORT_EXPORT PathModel : public QAbstractListModel
0023 {
0024     Q_OBJECT
0025     Q_PROPERTY(KPublicTransport::Path path READ path WRITE setPath)
0026 
0027 public:
0028     explicit PathModel(QObject *parent = nullptr);
0029     ~PathModel() override;
0030 
0031     enum Role {
0032         PathSectionRole = Qt::UserRole,
0033         TurnDirectionRole,
0034     };
0035 
0036     Path path() const;
0037     void setPath(const Path &path);
0038 
0039     int rowCount(const QModelIndex &parent = {}) const override;
0040     QVariant data(const QModelIndex &index, int role) const override;
0041     QHash<int, QByteArray> roleNames() const override;
0042 
0043 private:
0044     Path m_path;
0045 };
0046 
0047 }
0048 
0049 #endif // KPUBLICTRANSPORT_PATHMODEL_H