summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-24 10:37:18 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-25 10:43:48 -0700
commite03b553e80a00b07757f51f7866bc666b807dce8 (patch)
tree5c3ec6d5cc5bdc556f01d4a524a3df44113fbbb4 /qt-models
parent6eed3155e6a84f1b27b5340b45d6deb801fee42d (diff)
downloadsubsurface-e03b553e80a00b07757f51f7866bc666b807dce8.tar.gz
Make created dive site uuid deterministic
Having random uuids seemed like a good idea, but there are several situations where they really cause problems. One is merging dive file imports from V2 logfiles. Another is testing such imports. Instead of making the uuid random we now hash the name and add the timestamp of the first dive associated with this dive site to the hash (first in this context is "first encountered" with no guarantee that it is the chronologically first). This way V2 imports create deterministic uuids but uuid conflicts are still extremely unlikely, even if the user has multiple dive sites with the same name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divelocationmodel.cpp5
-rw-r--r--qt-models/divelocationmodel.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index 5aa3a3ac8..30b3f82ae 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -1,3 +1,4 @@
+#include "units.h"
#include "divelocationmodel.h"
#include "dive.h"
#include <QDebug>
@@ -126,14 +127,14 @@ void LocationInformationModel::update()
endResetModel();
}
-int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int lat)
+int32_t LocationInformationModel::addDiveSite(const QString& name, timestamp_t divetime, int lon, int lat)
{
degrees_t latitude, longitude;
latitude.udeg = lat;
longitude.udeg = lon;
beginInsertRows(QModelIndex(), dive_site_table.nr + 2, dive_site_table.nr + 2);
- uint32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude);
+ uint32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude, divetime);
qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
internalRowCount = dive_site_table.nr;
endInsertRows();
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index ee52d2ba4..77dbb7bca 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -15,7 +15,7 @@ public:
int columnCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
- int32_t addDiveSite(const QString& name, int lat = 0, int lon = 0);
+ int32_t addDiveSite(const QString& name, timestamp_t divetime, int lat = 0, int lon = 0);
bool setData(const QModelIndex &index, const QVariant &value, int role);
bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
void setFirstRowTextField(QLineEdit *textField);