mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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>
This commit is contained in:
parent
560426bf82
commit
e36e4d1faa
6 changed files with 24 additions and 2 deletions
|
@ -276,6 +276,11 @@ void clear_dive_site(struct dive_site *ds)
|
||||||
free_taxonomy(&ds->taxonomy);
|
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)
|
uint32_t find_or_create_dive_site_with_name(const char *name, timestamp_t divetime)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -66,10 +66,12 @@ void copy_dive_site(struct dive_site *orig, struct dive_site *copy);
|
||||||
void clear_dive_site(struct dive_site *ds);
|
void clear_dive_site(struct dive_site *ds);
|
||||||
unsigned int get_distance(degrees_t lat1, degrees_t lon1, degrees_t lat2, degrees_t lon2);
|
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);
|
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"
|
#define INVALID_DIVE_SITE_NAME "development use only - not a valid dive site name"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // DIVESITE_H
|
#endif // DIVESITE_H
|
||||||
|
|
|
@ -109,8 +109,9 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
|
||||||
else
|
else
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
case UUID_ROLE:
|
||||||
|
return ds->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ class LocationInformationModel : public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS};
|
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();
|
static LocationInformationModel *instance();
|
||||||
int columnCount(const QModelIndex &parent) const;
|
int columnCount(const QModelIndex &parent) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), modified(false)
|
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) {
|
if (ui.diveSiteListView->selectionModel()->selectedIndexes().count() >= 2) {
|
||||||
QContextMenuEvent *ctx = (QContextMenuEvent*) ev;
|
QContextMenuEvent *ctx = (QContextMenuEvent*) ev;
|
||||||
QMenu contextMenu;
|
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());
|
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()
|
void LocationInformationWidget::updateLabels()
|
||||||
{
|
{
|
||||||
if (displayed_dive_site.name)
|
if (displayed_dive_site.name)
|
||||||
|
|
|
@ -27,6 +27,7 @@ public slots:
|
||||||
void on_diveSiteName_textChanged(const QString& text);
|
void on_diveSiteName_textChanged(const QString& text);
|
||||||
void on_diveSiteNotes_textChanged();
|
void on_diveSiteNotes_textChanged();
|
||||||
void reverseGeocode();
|
void reverseGeocode();
|
||||||
|
void mergeSelectedDiveSites();
|
||||||
private slots:
|
private slots:
|
||||||
void updateLabels();
|
void updateLabels();
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Add table
Reference in a new issue