QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoTagImageModel.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QAbstractListModel>
4#include <QtCore/QLoggingCategory>
5#include <QtPositioning/QGeoCoordinate>
6#include <QtQmlIntegration/QtQmlIntegration>
7
8Q_DECLARE_LOGGING_CATEGORY(GeoTagImageModelLog)
9
10
11class GeoTagImageModel : public QAbstractListModel
12{
13 Q_OBJECT
14 QML_ELEMENT
15
16 Q_PROPERTY(int count READ count NOTIFY countChanged)
17
18public:
19 enum Status {
20 Pending,
21 Processing,
22 Tagged,
23 Skipped,
24 Failed
25 };
26 Q_ENUM(Status)
27
28 enum Roles {
29 FileNameRole = Qt::UserRole + 1,
30 FilePathRole,
31 StatusRole,
32 StatusStringRole,
33 ErrorMessageRole,
34 CoordinateRole
35 };
36
37 explicit GeoTagImageModel(QObject *parent = nullptr);
38 ~GeoTagImageModel() override;
39
40 // QAbstractListModel interface
41 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
42 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
43 QHash<int, QByteArray> roleNames() const override;
44
45 int count() const { return rowCount(); }
46
47 // Model manipulation
48 void clear();
49 void addImage(const QString &filePath);
50 void setStatus(int index, Status status, const QString &errorMessage = QString());
51 void setCoordinate(int index, const QGeoCoordinate &coordinate);
52 void setStatusByPath(const QString &filePath, Status status, const QString &errorMessage = QString());
53
54 // Batch operations
55 void setAllStatus(Status status);
56
57signals:
59
60private:
61 struct ImageInfo {
62 QString filePath;
63 QString fileName;
64 Status status = Pending;
65 QString errorMessage;
66 QGeoCoordinate coordinate;
67 };
68
69 QList<ImageInfo> _images;
70
71 static QString statusToString(Status status);
72};
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
Model for displaying geotagging image status in QML.