digiKam
trackmanager.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2006-09-19
7  * Description : Track file loading and managing
8  *
9  * Copyright (C) 2006-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2010-2014 by Michael G. Hansen <mike at mghansen dot de>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_TRACK_MANAGER_H
26 #define DIGIKAM_TRACK_MANAGER_H
27 
28 // Qt includes
29 
30 #include <QColor>
31 #include <QDateTime>
32 #include <QUrl>
33 
34 // local includes
35 
36 #include "geoifacetypes.h"
37 #include "geocoordinates.h"
38 #include "digikam_export.h"
39 
40 class TestGPXParsing;
41 
42 namespace Digikam
43 {
44 
45 class DIGIKAM_EXPORT TrackManager : public QObject
46 {
47  Q_OBJECT
48 
49 public:
50 
52  typedef quint32 Id;
53 
55  {
56  ChangeTrackPoints = 1,
57  ChangeMetadata = 2,
58 
59  ChangeRemoved = 4,
60  ChangeAdd = ChangeTrackPoints | ChangeMetadata
61  };
62 
63  typedef QPair<Id, ChangeFlag> TrackChanges;
64 
65 public:
66 
67  class TrackPoint
68  {
69  public:
70 
71  explicit TrackPoint()
72  : dateTime (),
73  coordinates (),
74  nSatellites (-1),
75  hDop (-1),
76  pDop (-1),
77  fixType (-1),
78  speed (-1)
79  {
80  }
81 
82  static bool EarlierThan(const TrackPoint& a, const TrackPoint& b);
83 
84  public:
85 
86  QDateTime dateTime;
89  qreal hDop;
90  qreal pDop;
91  int fixType;
92  qreal speed;
93 
95  };
96 
97  // -------------------------------------
98 
99  class Track
100  {
101  public:
102 
103  enum Flags
104  {
105  FlagVisible = 1,
106  FlagDefault = FlagVisible
107  };
108 
109  public:
110 
111  explicit Track()
112  : url (),
113  points (),
114  id (0),
115  color (Qt::red),
116  flags (FlagDefault)
117  {
118  qRegisterMetaType<TrackChanges>("TrackChanges");
119  }
120 
121  QUrl url;
123 
126  QColor color;
128 
130  };
131 
132 public:
133 
134  explicit TrackManager(QObject* const parent = nullptr);
135  ~TrackManager() override;
136 
137  void loadTrackFiles(const QList<QUrl>& urls);
138  QList<QPair<QUrl, QString> > readLoadErrors();
139  void clear();
140 
141  const Track& getTrack(const int index) const;
142  Track::List getTrackList() const;
143  int trackCount() const;
144 
145  quint64 getNextFreeTrackId();
146  Track getTrackById(const quint64 trackId) const;
147  QColor getNextFreeTrackColor();
148 
149  void setVisibility(const bool value);
150  bool getVisibility() const;
151 
152 Q_SIGNALS:
153 
154  void signalTrackFilesReadyAt(const int startIndex, const int endIndex);
157  void signalVisibilityChanged(const bool newValue);
158 
159 private Q_SLOTS:
160 
161  void slotTrackFilesReadyAt(int beginIndex, int endIndex);
162  void slotTrackFilesFinished();
163 
164 private:
165 
166  class Private;
167  const QScopedPointer<Private> d;
168 };
169 
170 } // namespace Digikam
171 
172 #endif // DIGIKAM_TRACK_MANAGER_H
Definition: geocoordinates.h:49
Definition: trackmanager.h:68
QList< TrackPoint > List
Definition: trackmanager.h:94
QDateTime dateTime
Definition: trackmanager.h:86
qreal pDop
Definition: trackmanager.h:90
int fixType
Definition: trackmanager.h:91
TrackPoint()
Definition: trackmanager.h:71
qreal hDop
Definition: trackmanager.h:89
qreal speed
Definition: trackmanager.h:92
GeoCoordinates coordinates
Definition: trackmanager.h:87
int nSatellites
Definition: trackmanager.h:88
Definition: trackmanager.h:100
QUrl url
Definition: trackmanager.h:121
Flags
Definition: trackmanager.h:104
QColor color
Definition: trackmanager.h:126
QList< Track > List
Definition: trackmanager.h:129
QList< TrackPoint > points
Definition: trackmanager.h:122
Flags flags
Definition: trackmanager.h:127
Track()
Definition: trackmanager.h:111
Id id
0 means no track id assigned yet
Definition: trackmanager.h:125
Definition: trackmanager.h:46
void signalVisibilityChanged(const bool newValue)
QPair< Id, ChangeFlag > TrackChanges
Definition: trackmanager.h:63
void signalTrackFilesReadyAt(const int startIndex, const int endIndex)
ChangeFlag
Definition: trackmanager.h:55
quint32 Id
NOTE: we assume here that we will never load more than uint32_max tracks.
Definition: trackmanager.h:52
void signalTracksChanged(const QList< TrackManager::TrackChanges > &trackChanges)
Definition: piwigotalker.h:48
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43