From b8092c07a4b4d7715d825641e458be5fa56972d6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 1 Jun 2015 16:58:23 -0300 Subject: Create a new DiveSite when user clicks on add Also reorganized a bit of the code, and renamed a few misleading methods. [Dirk Hohndel: remove some C++11 code] Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-models/divelocationmodel.cpp | 11 +++++++++++ qt-models/divelocationmodel.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'qt-models') diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index c335f7039..3f8c486fe 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -49,3 +49,14 @@ void LocationInformationModel::update() endInsertRows(); } } + +int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int lat) +{ + degrees_t latitude, longitude; + latitude.udeg = lat; + longitude.udeg = lon; + + int32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude); + update(); + return uuid; +} diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h index 9238c4b5b..9d30adf41 100644 --- a/qt-models/divelocationmodel.h +++ b/qt-models/divelocationmodel.h @@ -10,6 +10,8 @@ public: static LocationInformationModel *instance(); 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); + public slots: void update(); private: -- cgit v1.2.3-70-g09d2