digiKam
gpsitemcontainer.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 : 2010-03-21
7  * Description : A container to hold GPS information about an item.
8  *
9  * Copyright (C) 2010-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_GPS_ITEM_CONTAINER_H
26 #define DIGIKAM_GPS_ITEM_CONTAINER_H
27 
28 // Qt includes
29 
30 #include <QVariant>
31 #include <QDateTime>
32 #include <QUrl>
33 
34 // Local includes
35 
36 #include "geoifacetypes.h"
37 #include "digikam_export.h"
38 #include "gpsdatacontainer.h"
39 #include "rginfo.h"
40 
41 namespace Digikam
42 {
43 
44 enum Type
45 {
46  TypeChild = 1,
48  TypeNewChild = 4
49 };
50 
51 typedef struct TagData
52 {
55  {
56  }
57 
58  QString tagName;
59  QString tipName;
61 
63 
64 // --------------------------------------------------------------------------
65 
67 {
68 public:
69 
70  explicit SaveProperties()
71  : shouldRemoveCoordinates (false),
72  shouldRemoveAltitude (false),
73  shouldWriteCoordinates (false),
74  shouldWriteAltitude (false),
75  altitude (0.0),
76  latitude (0.0),
77  longitude (0.0)
78  {
79  }
80 
85  qreal altitude;
86  qreal latitude;
87  qreal longitude;
88 };
89 
90 // --------------------------------------------------------------------------
91 
92 class GPSItemModel;
93 class DMetadata;
94 
95 class DIGIKAM_EXPORT GPSItemContainer
96 {
97 public:
98 
99  static const int RoleCoordinates = Qt::UserRole + 1;
100 
101  static const int ColumnThumbnail = 0;
102  static const int ColumnFilename = 1;
103  static const int ColumnDateTime = 2;
104  static const int ColumnLatitude = 3;
105  static const int ColumnLongitude = 4;
106  static const int ColumnAltitude = 5;
107  static const int ColumnAccuracy = 6;
108  static const int ColumnTags = 7;
109  static const int ColumnStatus = 8;
110  static const int ColumnDOP = 9;
111  static const int ColumnFixType = 10;
112  static const int ColumnNSatellites = 11;
113  static const int ColumnSpeed = 12;
114 
115  static const int ColumnGPSItemContainerCount = 13;
116 
117 public:
118 
119  explicit GPSItemContainer(const QUrl& url);
120  virtual ~GPSItemContainer();
121 
123 
124  virtual QString saveChanges();
125  virtual bool loadImageData();
127 
128  bool isDirty() const;
129  QUrl url() const;
130  QDateTime dateTime() const;
131 
133 
134  static void setHeaderData(GPSItemModel* const model);
135  bool lessThan(const GPSItemContainer* const otherItem, const int column) const;
137 
139 
140  void setCoordinates(const GeoCoordinates& newCoordinates);
141  GeoCoordinates coordinates() const;
142  GPSDataContainer gpsData() const;
143  void setGPSData(const GPSDataContainer& container);
144  void restoreGPSData(const GPSDataContainer& container);
146 
148 
149 
153  void setTagList(const QList<QList<TagData> >& externalTagList);
154 
158  bool isTagListDirty() const;
159 
163  QList<QList<TagData> > getTagList() const;
164 
168  void restoreRGTagList(const QList<QList<TagData> >& tagList);
169 
173  void writeTagsToXmp(const bool writeXmpTags) { m_writeXmpTags = writeXmpTags; }
175 
176 protected:
177 
179  QVariant data(const int column, const int role) const;
180  void setModel(GPSItemModel* const model);
181  void emitDataChanged();
182  DMetadata* getMetadataForFile() const;
183  SaveProperties saveProperties() const;
184 
185 protected:
186 
188 
189  QUrl m_url;
190  QDateTime m_dateTime;
191 
192  bool m_dirty;
195 
200 
202  bool m_saveGPS;
203 
204  friend class GPSItemModel;
205 
206 private:
207 
208  Q_DISABLE_COPY(GPSItemContainer)
209 };
210 
211 } // namespace Digikam
212 
213 #endif // DIGIKAM_GPS_ITEM_CONTAINER_H
Definition: dmetadata.h:55
Definition: gpsdatacontainer.h:36
Definition: gpsitemcontainer.h:96
QList< QList< TagData > > m_savedTagList
Definition: gpsitemcontainer.h:198
void writeTagsToXmp(const bool writeXmpTags)
Definition: gpsitemcontainer.h:173
bool m_saveGPS
Definition: gpsitemcontainer.h:202
QDateTime m_dateTime
Definition: gpsitemcontainer.h:190
GPSItemModel * m_model
Definition: gpsitemcontainer.h:187
bool m_saveTags
Definition: gpsitemcontainer.h:201
GPSDataContainer m_savedState
Definition: gpsitemcontainer.h:194
bool m_writeXmpTags
Definition: gpsitemcontainer.h:199
QList< QList< TagData > > m_tagList
Definition: gpsitemcontainer.h:197
bool m_dirty
Definition: gpsitemcontainer.h:192
QUrl m_url
Definition: gpsitemcontainer.h:189
GPSDataContainer m_gpsData
Definition: gpsitemcontainer.h:193
bool m_tagListDirty
Definition: gpsitemcontainer.h:196
Definition: gpsitemmodel.h:43
Definition: geocoordinates.h:49
Definition: gpsitemcontainer.h:67
bool shouldWriteAltitude
Definition: gpsitemcontainer.h:84
qreal altitude
Definition: gpsitemcontainer.h:85
qreal longitude
Definition: gpsitemcontainer.h:87
bool shouldRemoveCoordinates
Definition: gpsitemcontainer.h:81
SaveProperties()
Definition: gpsitemcontainer.h:70
bool shouldRemoveAltitude
Definition: gpsitemcontainer.h:82
qreal latitude
Definition: gpsitemcontainer.h:86
bool shouldWriteCoordinates
Definition: gpsitemcontainer.h:83
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43
struct Digikam::TagData TagData
@ ColumnFilename
Definition: track_listmodel.cpp:42
Type
Definition: gpsitemcontainer.h:45
@ TypeChild
Definition: gpsitemcontainer.h:46
@ TypeNewChild
Definition: gpsitemcontainer.h:48
@ TypeSpacer
Definition: gpsitemcontainer.h:47
Definition: gpsitemcontainer.h:52
QString tipName
Definition: gpsitemcontainer.h:59
Type tagType
Definition: gpsitemcontainer.h:60
TagData()
Definition: gpsitemcontainer.h:53
QString tagName
Definition: gpsitemcontainer.h:58