File indexing completed on 2025-01-05 03:58:35
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-09-19 0007 * Description : Track file loading and managing 0008 * 0009 * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2010-2014 by Michael G. Hansen <mike at mghansen dot de> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #ifndef DIGIKAM_TRACK_MANAGER_H 0017 #define DIGIKAM_TRACK_MANAGER_H 0018 0019 // Qt includes 0020 0021 #include <QColor> 0022 #include <QDateTime> 0023 #include <QUrl> 0024 0025 // local includes 0026 0027 #include "geoifacetypes.h" 0028 #include "geocoordinates.h" 0029 #include "digikam_export.h" 0030 0031 class TestGPXParsing; 0032 0033 namespace Digikam 0034 { 0035 0036 class DIGIKAM_EXPORT TrackManager : public QObject 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 0042 /// NOTE: we assume here that we will never load more than uint32_max tracks. 0043 typedef quint32 Id; 0044 0045 enum ChangeFlag 0046 { 0047 ChangeTrackPoints = 1, 0048 ChangeMetadata = 2, 0049 0050 ChangeRemoved = 4, 0051 ChangeAdd = ChangeTrackPoints | ChangeMetadata 0052 }; 0053 0054 typedef QPair<Id, ChangeFlag> TrackChanges; 0055 0056 public: 0057 0058 class TrackPoint 0059 { 0060 public: 0061 0062 explicit TrackPoint() 0063 : dateTime (), 0064 coordinates (), 0065 nSatellites (-1), 0066 hDop (-1), 0067 pDop (-1), 0068 fixType (-1), 0069 speed (-1) 0070 { 0071 } 0072 0073 static bool EarlierThan(const TrackPoint& a, const TrackPoint& b); 0074 0075 public: 0076 0077 QDateTime dateTime; 0078 GeoCoordinates coordinates; 0079 int nSatellites; 0080 qreal hDop; 0081 qreal pDop; 0082 int fixType; 0083 qreal speed; 0084 0085 typedef QList<TrackPoint> List; 0086 }; 0087 0088 // ------------------------------------- 0089 0090 class Track 0091 { 0092 public: 0093 0094 enum Flags 0095 { 0096 FlagVisible = 1, 0097 FlagDefault = FlagVisible 0098 }; 0099 0100 public: 0101 0102 explicit Track() 0103 : url (), 0104 points (), 0105 id (0), 0106 color (Qt::red), 0107 flags (FlagDefault) 0108 { 0109 qRegisterMetaType<TrackChanges>("TrackChanges"); 0110 } 0111 0112 QUrl url; 0113 QList<TrackPoint> points; 0114 0115 /// 0 means no track id assigned yet 0116 Id id; 0117 QColor color; 0118 Flags flags; 0119 0120 typedef QList<Track> List; 0121 }; 0122 0123 public: 0124 0125 explicit TrackManager(QObject* const parent = nullptr); 0126 ~TrackManager() override; 0127 0128 void loadTrackFiles(const QList<QUrl>& urls); 0129 QList<QPair<QUrl, QString> > readLoadErrors(); 0130 void clear(); 0131 0132 const Track& getTrack(const int index) const; 0133 Track::List getTrackList() const; 0134 int trackCount() const; 0135 0136 quint64 getNextFreeTrackId(); 0137 Track getTrackById(const quint64 trackId) const; 0138 QColor getNextFreeTrackColor(); 0139 0140 void setVisibility(const bool value); 0141 bool getVisibility() const; 0142 0143 Q_SIGNALS: 0144 0145 void signalTrackFilesReadyAt(const int startIndex, const int endIndex); 0146 void signalAllTrackFilesReady(); 0147 void signalTracksChanged(const QList<TrackManager::TrackChanges>& trackChanges); 0148 void signalVisibilityChanged(const bool newValue); 0149 0150 private Q_SLOTS: 0151 0152 void slotTrackFilesReadyAt(int beginIndex, int endIndex); 0153 void slotTrackFilesFinished(); 0154 0155 private: 0156 0157 class Private; 0158 const QScopedPointer<Private> d; 0159 }; 0160 0161 } // namespace Digikam 0162 0163 #endif // DIGIKAM_TRACK_MANAGER_H