aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-08-31 21:35:17 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-31 18:43:09 -0700
commite36e4d1faa95439a1806935de6dcbd04d2283d20 (patch)
tree47a54f026cb0be6084d47ebff250b798df91591e
parent560426bf82ef7cb163d8046b722c12b76604006c (diff)
downloadsubsurface-e36e4d1faa95439a1806935de6dcbd04d2283d20.tar.gz
UI code to merge dive sites
Get the Qt data structures and convert to something that we can use in our C - core. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--divesite.c5
-rw-r--r--divesite.h2
-rw-r--r--qt-models/divelocationmodel.cpp3
-rw-r--r--qt-models/divelocationmodel.h1
-rw-r--r--qt-ui/locationinformation.cpp14
-rw-r--r--qt-ui/locationinformation.h1
6 files changed, 24 insertions, 2 deletions
diff --git a/divesite.c b/divesite.c
index ec552b66a..2b5c48849 100644
--- a/divesite.c
+++ b/divesite.c
@@ -276,6 +276,11 @@ void clear_dive_site(struct dive_site *ds)
free_taxonomy(&ds->taxonomy);
}
+void merge_dive_sites(uint32_t* uuids, int count)
+{
+
+}
+
uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t divetime)
{
int i;
diff --git a/divesite.h b/divesite.h
index b0d56f1d1..154788460 100644
--- a/divesite.h
+++ b/divesite.h
@@ -66,10 +66,12 @@ void copy_dive_site(struct dive_site *orig, struct dive_site *copy);
void clear_dive_site(struct dive_site *ds);
unsigned int get_distance(degrees_t lat1, degrees_t lon1, degrees_t lat2, degrees_t lon2);
uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t divetime);
+void merge_dive_sites(uint32_t *uuids, int count);
#define INVALID_DIVE_SITE_NAME "development use only - not a valid dive site name"
#ifdef __cplusplus
}
#endif
+
#endif // DIVESITE_H
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index ff733f5ad..0ddd0eb49 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -109,8 +109,9 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
else
return QVariant();
}
+ case UUID_ROLE:
+ return ds->uuid;
}
-
return QVariant();
}
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index 83bc97e67..d5b8705ce 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -17,6 +17,7 @@ class LocationInformationModel : public QAbstractTableModel {
Q_OBJECT
public:
enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS};
+ enum Roles { UUID_ROLE = Qt::UserRole + 1 };
static LocationInformationModel *instance();
int columnCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index b3acc6682..d029dd2a1 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -11,6 +11,7 @@
#include <QDebug>
#include <QShowEvent>
#include <QItemSelectionModel>
+#include <cstdlib>
LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), modified(false)
{
@@ -56,12 +57,23 @@ bool LocationInformationWidget::eventFilter(QObject*, QEvent *ev)
if (ui.diveSiteListView->selectionModel()->selectedIndexes().count() >= 2) {
QContextMenuEvent *ctx = (QContextMenuEvent*) ev;
QMenu contextMenu;
- contextMenu.addAction(tr("Merge dive Sites"), this, SLOT(merge_dive_sites()));
+ contextMenu.addAction(tr("Merge dive Sites"), this, SLOT(mergeSelectedDiveSites()));
contextMenu.exec(ctx->globalPos());
}
}
}
+void LocationInformationWidget::mergeSelectedDiveSites() {
+ QModelIndexList selection = ui.diveSiteListView->selectionModel()->selectedIndexes();
+ uint32_t *selected_dive_sites = (uint32_t*) malloc(sizeof(u_int32_t) * selection.count());
+ int i = 0;
+ Q_FOREACH(const QModelIndex& idx, selection) {
+ selected_dive_sites[i] = (uint32_t) idx.data(LocationInformationModel::UUID_ROLE).toInt();
+ }
+ merge_dive_sites(selected_dive_sites, i);
+ free(selected_dive_sites);
+}
+
void LocationInformationWidget::updateLabels()
{
if (displayed_dive_site.name)
diff --git a/qt-ui/locationinformation.h b/qt-ui/locationinformation.h
index 2442e16aa..080e013a8 100644
--- a/qt-ui/locationinformation.h
+++ b/qt-ui/locationinformation.h
@@ -27,6 +27,7 @@ public slots:
void on_diveSiteName_textChanged(const QString& text);
void on_diveSiteNotes_textChanged();
void reverseGeocode();
+ void mergeSelectedDiveSites();
private slots:
void updateLabels();
signals: