summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--divesite.c16
-rw-r--r--divesite.h1
-rw-r--r--qt-models/divelocationmodel.cpp53
-rw-r--r--qt-models/divelocationmodel.h4
-rw-r--r--qt-ui/locationinformation.cpp112
-rw-r--r--qt-ui/locationinformation.h21
-rw-r--r--qt-ui/maintab.cpp141
-rw-r--r--qt-ui/maintab.h4
-rw-r--r--qt-ui/maintab.ui27
-rw-r--r--qt-ui/modeldelegates.cpp23
-rw-r--r--qt-ui/simpledivesiteedit.ui68
12 files changed, 207 insertions, 265 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5b94d13bd..9e0fcafad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -574,7 +574,7 @@ if(NOT NO_DOCS)
add_custom_target(
documentation ALL
COMMAND
- make -C ${CMAKE_SOURCE_DIR}/Documentation OUT=${CMAKE_BINARY_DIR}/Documentation/ doc
+ ${MAKE} -C ${CMAKE_SOURCE_DIR}/Documentation OUT=${CMAKE_BINARY_DIR}/Documentation/ doc
DEPENDS documentationLink
)
endif()
diff --git a/divesite.c b/divesite.c
index 56479508b..b72672177 100644
--- a/divesite.c
+++ b/divesite.c
@@ -200,3 +200,19 @@ void clear_dive_site(struct dive_site *ds)
ds->taxonomy.nr = 0;
free_taxonomy(&ds->taxonomy);
}
+
+uint32_t find_or_create_dive_site_with_name(const char *name)
+{
+ int i;
+ struct dive_site *ds;
+ bool found = false;
+ for_each_dive_site(i,ds) {
+ if (same_string(name, ds->name)) {
+ found = true;
+ break;
+ }
+ }
+ if (ds)
+ return ds->uuid;
+ return create_dive_site(name);
+}
diff --git a/divesite.h b/divesite.h
index 3447d1836..fd590eb2c 100644
--- a/divesite.h
+++ b/divesite.h
@@ -60,6 +60,7 @@ bool dive_site_is_empty(struct dive_site *ds);
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);
#ifdef __cplusplus
}
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index 42af4f63a..bddca8f77 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -1,6 +1,8 @@
#include "divelocationmodel.h"
#include "dive.h"
#include <QDebug>
+#include <QLineEdit>
+#include <QIcon>
bool dive_site_less_than(dive_site *a, dive_site *b)
{
@@ -13,7 +15,9 @@ LocationInformationModel *LocationInformationModel::instance()
return self;
}
-LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj), internalRowCount(0)
+LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj),
+ internalRowCount(0),
+ textField(NULL)
{
}
@@ -25,19 +29,45 @@ int LocationInformationModel::columnCount(const QModelIndex &parent) const
int LocationInformationModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
- return internalRowCount;
+ return internalRowCount + 1;
}
QVariant LocationInformationModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
- struct dive_site *ds = get_dive_site(index.row());
+
+ // Special case to handle the 'create dive site' with name.
+ if (index.row() == 0) {
+ if (index.column() == UUID)
+ return 0;
+ switch(role) {
+ case Qt::DisplayRole : {
+ struct dive_site *ds;
+ int i;
+ for_each_dive_site(i, ds) {
+ QString dsName(ds->name);
+ if (dsName.startsWith(textField->text()))
+ return dsName;
+ }
+ return textField->text();
+ }
+ case Qt::ToolTipRole : {
+ return QString(tr("Create dive site"));
+ }
+ case Qt::EditRole : return textField->text();
+ case Qt::DecorationRole : return QIcon(":plus");
+ }
+ }
+
+ // The dive sites are -1 because of the first item.
+ struct dive_site *ds = get_dive_site(index.row()-1);
if (!ds)
return QVariant();
switch(role) {
+ case Qt::EditRole:
case Qt::DisplayRole :
switch(index.column()) {
case UUID: return ds->uuid;
@@ -52,11 +82,22 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
case TAXONOMY_3: return "TODO";
}
break;
+ case Qt::DecorationRole : {
+ if (dive_site_has_gps_location(ds))
+ return QIcon(":geocode");
+ else
+ return QVariant();
+ }
}
return QVariant();
}
+void LocationInformationModel::setFirstRowTextField(QLineEdit *t)
+{
+ textField = t;
+}
+
void LocationInformationModel::update()
{
beginResetModel();
@@ -71,7 +112,7 @@ int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int
latitude.udeg = lat;
longitude.udeg = lon;
- beginInsertRows(QModelIndex(), dive_site_table.nr, dive_site_table.nr);
+ beginInsertRows(QModelIndex(), dive_site_table.nr + 1, dive_site_table.nr + 1);
uint32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude);
qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
internalRowCount = dive_site_table.nr;
@@ -81,7 +122,7 @@ int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int
bool LocationInformationModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- if (!index.isValid())
+ if (!index.isValid() || index.row() == 0)
return false;
if (role != Qt::EditRole)
@@ -99,7 +140,7 @@ bool LocationInformationModel::removeRows(int row, int count, const QModelIndex
if(row >= rowCount())
return false;
- beginRemoveRows(QModelIndex(), row, row);
+ beginRemoveRows(QModelIndex(), row + 1, row + 1);
struct dive_site *ds = get_dive_site(row);
if (ds)
delete_dive_site(ds->uuid);
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index 8cae3a08a..ee52d2ba4 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -5,6 +5,8 @@
#include <QStringListModel>
#include <stdint.h>
+class QLineEdit;
+
class LocationInformationModel : public QAbstractTableModel {
Q_OBJECT
public:
@@ -16,12 +18,14 @@ public:
int32_t addDiveSite(const QString& name, 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);
public slots:
void update();
private:
LocationInformationModel(QObject *obj = 0);
int internalRowCount;
+ QLineEdit *textField;
};
class GeoReferencingOptionsModel : public QStringListModel {
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index b3907a89a..39a8341cd 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -227,100 +227,48 @@ void LocationInformationWidget::resetPallete()
ui.diveSiteNotes->setPalette(p);
}
-SimpleDiveSiteEditDialog::SimpleDiveSiteEditDialog(QWidget *parent) :
- QDialog(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::Popup),
- ui(new Ui::SimpleDiveSiteEditDialog()), changed_dive_site(false)
+bool LocationManagementEditHelper::eventFilter(QObject *obj, QEvent *ev)
{
- ui->setupUi(this);
- ui->diveSiteDescription->installEventFilter(this);
- ui->diveSiteNotes->installEventFilter(this);
-}
-
-SimpleDiveSiteEditDialog::~SimpleDiveSiteEditDialog()
-{
- delete ui;
-}
-
-bool SimpleDiveSiteEditDialog::eventFilter(QObject *obj, QEvent *ev)
-{
- if (ev->type() != QEvent::FocusOut)
+ QListView *view = qobject_cast<QListView*>(obj);
+ if(!view)
return false;
- if (obj == ui->diveSiteDescription) {
- diveSiteDescription_editingFinished();
- } else if (obj == ui->diveSiteNotes) {
- diveSiteNotes_editingFinished();
+ if(ev->type() == QEvent::Show) {
+ last_uuid = 0;
+ qDebug() << "EventFilter: " << last_uuid;
}
- return false;
-}
-void SimpleDiveSiteEditDialog::showEvent(QShowEvent *ev)
-{
- const int heigth = 275;
- const int width = 450;
-
- // Position.
- QDialog::showEvent(ev);
- QRect currGeometry = geometry();
- currGeometry.setX(QCursor::pos().x() + 15);
- currGeometry.setY(QCursor::pos().y() - heigth / 2);
- currGeometry.setWidth(width);
- currGeometry.setHeight(heigth);
- setGeometry(currGeometry);
- ev->accept();
-
- //Da
- ui->diveSiteName->setText(displayed_dive_site.name);
- ui->diveSiteNotes->setPlainText(displayed_dive_site.notes);
- ui->diveSiteDescription->setPlainText(displayed_dive_site.description);
-
- const char *gps_text = printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg);
- ui->diveSiteCoordinates->setText(QString(gps_text));
- free( (void*) gps_text);
-
- changed_dive_site = false;
-}
+ if(ev->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEv = (QKeyEvent*) ev;
+ if(keyEv->key() == Qt::Key_Space || keyEv->key() == Qt::Key_Return) {
+ handleActivation(view->currentIndex());
+ }
-void SimpleDiveSiteEditDialog::on_diveSiteName_editingFinished()
-{
- if (ui->diveSiteName->text() == displayed_dive_site.name)
- return;
- free(displayed_dive_site.name);
- displayed_dive_site.name = copy_string(qPrintable(ui->diveSiteName->text()));
- changed_dive_site = true;
+ }
+ return false;
}
-void SimpleDiveSiteEditDialog::on_diveSiteCoordinates_editingFinished()
+void LocationManagementEditHelper::handleActivation(const QModelIndex& activated)
{
- double lat, lon;
- uint32_t uLat, uLon;
-
- parseGpsText(ui->diveSiteCoordinates->text(), &lat, &lon);
- uLat = lat * 1000000;
- uLon = lon * 1000000;
-
- if (uLat == displayed_dive_site.latitude.udeg && uLon == displayed_dive_site.longitude.udeg)
+ if (!activated.isValid())
return;
-
- displayed_dive_site.latitude.udeg = uLat;
- displayed_dive_site.longitude.udeg = uLon;
- changed_dive_site = true;
+ QModelIndex uuidIdx = activated.model()->index(
+ activated.row(), LocationInformationModel::UUID);
+ last_uuid = uuidIdx.data().toInt();
+
+ // Special case: first option, add dive site.
+ if (activated.row() == 0) {
+ qDebug() << "Setting to " << activated.data().toString();
+ emit setLineEditText(activated.data().toString());
+ }
+ qDebug() << "Selected dive_site: " << last_uuid;
}
-void SimpleDiveSiteEditDialog::diveSiteDescription_editingFinished()
-{
- if (ui->diveSiteDescription->toPlainText() == displayed_dive_site.description)
- return;
- free(displayed_dive_site.description);
- displayed_dive_site.description = copy_string(qPrintable(ui->diveSiteDescription->toPlainText()));
- changed_dive_site = true;
+void LocationManagementEditHelper::resetDiveSiteUuid() {
+ last_uuid = 0;
+ qDebug() << "Reset: " << last_uuid;
}
-void SimpleDiveSiteEditDialog::diveSiteNotes_editingFinished()
-{
- if (ui->diveSiteNotes->toPlainText() == displayed_dive_site.notes)
- return;
- free(displayed_dive_site.notes);
- displayed_dive_site.notes = copy_string(qPrintable(ui->diveSiteNotes->toPlainText()));
- changed_dive_site = true;
+uint32_t LocationManagementEditHelper::diveSiteUuid() const {
+ return last_uuid;
}
diff --git a/qt-ui/locationinformation.h b/qt-ui/locationinformation.h
index 42e4d5ace..b55a1b42c 100644
--- a/qt-ui/locationinformation.h
+++ b/qt-ui/locationinformation.h
@@ -44,24 +44,17 @@ private:
mode current_mode;
};
-
-#include "ui_simpledivesiteedit.h"
-class SimpleDiveSiteEditDialog : public QDialog {
+class LocationManagementEditHelper : public QObject {
Q_OBJECT
public:
- SimpleDiveSiteEditDialog(QWidget *parent);
- virtual ~SimpleDiveSiteEditDialog();
- bool changed_dive_site;
bool eventFilter(QObject *obj, QEvent *ev);
-public slots:
- void on_diveSiteName_editingFinished();
- void on_diveSiteCoordinates_editingFinished();
- void diveSiteDescription_editingFinished();
- void diveSiteNotes_editingFinished();
-protected:
- void showEvent(QShowEvent *ev);
+ void handleActivation(const QModelIndex& activated);
+ void resetDiveSiteUuid();
+ uint32_t diveSiteUuid() const;
+signals:
+ void setLineEditText(const QString& text);
private:
- Ui::SimpleDiveSiteEditDialog *ui;
+ uint32_t last_uuid;
};
#endif
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 043fe0a6a..53d8e30b6 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -23,6 +23,7 @@
#include "divelocationmodel.h"
#include "divesite.h"
#include "locationinformation.h"
+#include "divesite.h"
#if defined(FBSUPPORT)
#include "socialnetworks.h"
@@ -60,15 +61,21 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
QCompleter *completer = new QCompleter();
QListView *completerListview = new QListView();
+ LocationInformationModel::instance()->setFirstRowTextField(ui.location);
completer->setPopup(completerListview);
completer->setModel(LocationInformationModel::instance());
completer->setCompletionColumn(LocationInformationModel::NAME);
- completer->setCompletionRole(Qt::DisplayRole);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completerListview->setItemDelegate(new LocationFilterDelegate());
+ locationManagementEditHelper = new LocationManagementEditHelper();
+ connect(locationManagementEditHelper, &LocationManagementEditHelper::setLineEditText,
+ ui.location, &QLineEdit::setText);
+ completerListview->installEventFilter(locationManagementEditHelper);
+ connect(completerListview, &QAbstractItemView::activated,
+ locationManagementEditHelper, &LocationManagementEditHelper::handleActivation);
+
ui.location->setCompleter(completer);
- connect(ui.addDiveSite, SIGNAL(clicked()), this, SLOT(showDiveSiteSimpleEdit()));
connect(ui.geocodeButton, SIGNAL(clicked()), this, SLOT(reverseGeocode()));
QAction *action = new QAction(tr("Apply changes"), this);
@@ -244,27 +251,14 @@ void MainTab::setCurrentLocationIndex()
}
}
-void MainTab::showDiveSiteSimpleEdit()
-{
- if (ui.location->text().isEmpty())
- return;
- SimpleDiveSiteEditDialog dlg(this);
- dlg.exec();
- if (dlg.changed_dive_site) {
- markChangedWidget(ui.location);
- }
-}
-
void MainTab::enableGeoLookupEdition()
{
ui.waitingSpinner->stop();
- ui.addDiveSite->show();
}
void MainTab::disableGeoLookupEdition()
{
ui.waitingSpinner->start();
- ui.addDiveSite->hide();
}
void MainTab::toggleTriggeredColumn()
@@ -386,6 +380,7 @@ void MainTab::enableEdition(EditMode newEditMode)
displayMessage(tr("Multiple dives are being edited."));
} else {
displayMessage(tr("This dive is being edited."));
+ locationManagementEditHelper->resetDiveSiteUuid();
}
editMode = newEditMode != NONE ? newEditMode : DIVE;
}
@@ -754,6 +749,7 @@ void MainTab::updateDiveInfo(bool clear)
else
ui.cylinders->view()->hideColumn(CylindersModel::USE);
+ qDebug() << "Set the current dive site:" << displayed_dive.dive_site_uuid;
emit diveSiteChanged(displayed_dive.dive_site_uuid);
}
@@ -810,12 +806,64 @@ void MainTab::reload()
mydive->what = displayed_dive.what; \
}
+void MainTab::updateDisplayedDiveSite()
+{
+ const QString new_name = ui.location->text();
+ const QString orig_name = displayed_dive_site.name;
+ const uint32_t orig_uuid = displayed_dive_site.uuid;
+ const uint32_t new_uuid = locationManagementEditHelper->diveSiteUuid();
+
+ qDebug() << "Updating Displayed Dive Site";
+ if(current_dive) {
+ struct dive_site *ds_from_dive = get_dive_site_by_uuid(current_dive->dive_site_uuid);
+ if (!dive_site_has_gps_location(ds_from_dive) &&
+ same_string(displayed_dive_site.notes, "SubsurfaceWebservice")) {
+ ds_from_dive->latitude = displayed_dive_site.latitude;
+ ds_from_dive->longitude = displayed_dive_site.longitude;
+ delete_dive_site(displayed_dive_site.uuid);
+ }
+ }
+
+ if(orig_uuid) {
+ if (new_uuid && orig_uuid != new_uuid) {
+ displayed_dive.dive_site_uuid = new_uuid;
+ copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site);
+ } else if (new_name.count() && orig_name != new_name) {
+ // As per linus request.: If I enter the name of a dive site,
+ // do not select a new one, but "clone" the old one and copy
+ // the information of it, just changing it's name.
+ uint32_t new_ds_uuid = create_dive_site(NULL);
+ struct dive_site *new_ds = get_dive_site_by_uuid(new_ds_uuid);
+ copy_dive_site(&displayed_dive_site, new_ds);
+ new_ds->name = copy_string(qPrintable(new_name));
+ displayed_dive.dive_site_uuid = new_ds->uuid;
+ copy_dive_site(new_ds, &displayed_dive_site);
+ } else {
+ qDebug() << "Current divesite is the same as informed";
+ }
+ } else if (!orig_uuid) {
+ if (new_uuid) {
+ displayed_dive.dive_site_uuid = new_uuid;
+ copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site);
+ } else if (new_name.count()) {
+ displayed_dive.dive_site_uuid = find_or_create_dive_site_with_name(qPrintable(new_name));
+ copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site);
+ } else {
+ qDebug() << "No divesite will be set";
+ }
+ }
+}
+
void MainTab::acceptChanges()
{
int i, addedId = -1;
struct dive *d;
bool do_replot = false;
+ if(ui.location->hasFocus()) {
+ this->setFocus();
+ }
+
acceptingEdit = true;
tabBar()->setTabIcon(0, QIcon()); // Notes
tabBar()->setTabIcon(1, QIcon()); // Equipment
@@ -828,12 +876,8 @@ void MainTab::acceptChanges()
struct dive *added_dive = clone_dive(&displayed_dive);
record_dive(added_dive);
addedId = added_dive->id;
- if (displayed_dive_site.uuid)
- copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid));
- else if (ui.location->text().count()) {
- uint32_t uuid = create_dive_site(qPrintable(ui.location->text()));
- added_dive->dive_site_uuid = uuid;
- }
+ get_dive_by_uniq_id(added_dive->id)->dive_site_uuid = displayed_dive_site.uuid;
+
// unselect everything as far as the UI is concerned and select the new
// dive - we'll have to undo/redo this later after we resort the dive_table
// but we need the dive selected for the middle part of this function - this
@@ -889,6 +933,7 @@ void MainTab::acceptChanges()
time_t offset = cd->when - displayed_dive.when;
MODIFY_SELECTED_DIVES(mydive->when -= offset;);
}
+
if (displayed_dive.dive_site_uuid != cd->dive_site_uuid)
MODIFY_SELECTED_DIVES(EDIT_VALUE(dive_site_uuid));
@@ -897,9 +942,6 @@ void MainTab::acceptChanges()
saveTaggedStrings();
saveTags();
- if (displayed_dive_site.uuid)
- copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid));
-
if (editMode != ADD && cylindersModel->changed) {
mark_divelist_changed(true);
MODIFY_SELECTED_DIVES(
@@ -956,6 +998,8 @@ void MainTab::acceptChanges()
cd->weightsystem[i].description = copy_string(displayed_dive.weightsystem[i].description);
}
}
+
+
// each dive that was selected might have had the temperatures in its active divecomputer changed
// so re-populate the temperatures - easiest way to do this is by calling fixup_dive
for_each_dive (i, d) {
@@ -1370,54 +1414,7 @@ void MainTab::on_location_editingFinished()
return;
}
- QString currText = ui.location->text();
-
- struct dive_site *ds;
- int idx;
- bool found = false;
- for_each_dive_site (idx,ds) {
- if (same_string(ds->name, qPrintable(currText))) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- uint32_t uuid = create_dive_site(qPrintable(ui.location->text()));
- ds = get_dive_site_by_uuid(uuid);
- if (same_string(displayed_dive_site.notes, "SubsurfaceWebservice")) {
- ds->latitude = displayed_dive_site.latitude;
- ds->longitude = displayed_dive_site.longitude;
- delete_dive_site(displayed_dive_site.uuid);
- }
- displayed_dive.dive_site_uuid = uuid;
- copy_dive_site(get_dive_site_by_uuid(uuid), &displayed_dive_site);
- markChangedWidget(ui.location);
-
- LocationInformationModel::instance()->update();
- emit diveSiteChanged(uuid);
- return;
- }
-
- if (!get_dive_site(idx))
- return;
-
- if (current_dive) {
- struct dive_site *ds_from_dive = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
- if(ds_from_dive && ui.location->text() == ds_from_dive->name)
- return;
- ds_from_dive = get_dive_site(idx);
- if (!dive_site_has_gps_location(ds_from_dive) &&
- same_string(displayed_dive_site.notes, "SubsurfaceWebservice")) {
- ds_from_dive->latitude = displayed_dive_site.latitude;
- ds_from_dive->longitude = displayed_dive_site.longitude;
- delete_dive_site(displayed_dive_site.uuid);
- }
- displayed_dive.dive_site_uuid = ds_from_dive->uuid;
- copy_dive_site(get_dive_site_by_uuid(ds_from_dive->uuid), &displayed_dive_site);
- markChangedWidget(ui.location);
- emit diveSiteChanged(ds_from_dive->uuid);
- }
+ updateDisplayedDiveSite();
}
void MainTab::on_suit_textChanged(const QString &text)
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 306aee66e..bcfb3340e 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -22,6 +22,7 @@ class CylindersModel;
class ExtraDataModel;
class DivePictureModel;
class QCompleter;
+class LocationManagementEditHelper;
struct Completers {
QCompleter *divemaster;
@@ -97,7 +98,6 @@ slots:
void enableGeoLookupEdition();
void disableGeoLookupEdition();
void setCurrentLocationIndex();
- void showDiveSiteSimpleEdit();
void reverseGeocode();
private:
Ui::MainTab ui;
@@ -121,6 +121,8 @@ private:
dive_trip_t *currentTrip;
dive_trip_t displayedTrip;
bool acceptingEdit;
+ LocationManagementEditHelper *locationManagementEditHelper;
+ void updateDisplayedDiveSite();
};
#endif // MAINTAB_H
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index 3318bf788..c83d12ec3 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -56,7 +56,7 @@
<x>0</x>
<y>0</y>
<width>449</width>
- <height>751</height>
+ <height>758</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -167,15 +167,15 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
- <property name="spacing">
- <number>0</number>
- </property>
<item>
<layout class="QHBoxLayout" name="LocationLayout" stretch="0,1">
<item>
@@ -209,17 +209,6 @@
<widget class="QLineEdit" name="location"/>
</item>
<item>
- <widget class="QToolButton" name="addDiveSite">
- <property name="text">
- <string>...</string>
- </property>
- <property name="icon">
- <iconset resource="../subsurface.qrc">
- <normaloff>:/edit</normaloff>:/edit</iconset>
- </property>
- </widget>
- </item>
- <item>
<widget class="QToolButton" name="geocodeButton">
<property name="text">
<string>...</string>
@@ -658,8 +647,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>286</width>
- <height>300</height>
+ <width>317</width>
+ <height>365</height>
</rect>
</property>
<layout class="QGridLayout" name="diveInfoScrollAreaLayout">
@@ -999,8 +988,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>297</width>
- <height>177</height>
+ <width>331</width>
+ <height>220</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index 268312a4d..8e296d412 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -498,14 +498,22 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
QStyledItemDelegate::initStyleOption(&opt, index);
QBrush bg;
QString diveSiteName = index.data().toString();
-
+ QString bottomText;
+ QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
struct dive_site *ds = get_dive_site_by_uuid(
index.model()->data(index.model()->index(index.row(),0)).toInt()
);
+
+ //Special case: do not show name, but instead, show
+ if (index.row() == 0) {
+ diveSiteName = index.data().toString();
+ bottomText = index.data(Qt::ToolTipRole).toString();
+ goto print_part;
+ }
+
if (!ds)
return;
- QString bottomText;
for (int i = 0; i < 3; i++) {
if (prefs.geocoding.category[i] == TC_NONE)
continue;
@@ -542,11 +550,14 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
bottomText += tr(" (~ %1 away)").arg(distance);
}
}
+print_part:
+
fontBigger.setPointSize(fontBigger.pointSize() + 1);
fontBigger.setBold(true);
initStyleOption(&opt, index);
opt.text = QString();
+ opt.icon = QIcon();
qApp->style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, NULL);
painter->save();
@@ -564,6 +575,14 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
painter->setBrush(option.palette.brightText());
painter->drawText(option.rect.x(),option.rect.y() + fmBigger.boundingRect("YH").height() * 2, bottomText);
painter->restore();
+
+ if (!icon.isNull()) {
+ painter->save();
+ painter->drawPixmap(
+ option.rect.x() + option.rect.width() - 24,
+ option.rect.y() + option.rect.height() - 24, icon.pixmap(20,20));
+ painter->restore();
+ }
}
QSize LocationFilterDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
diff --git a/qt-ui/simpledivesiteedit.ui b/qt-ui/simpledivesiteedit.ui
deleted file mode 100644
index 7153023da..000000000
--- a/qt-ui/simpledivesiteedit.ui
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SimpleDiveSiteEditDialog</class>
- <widget class="QDialog" name="SimpleDiveSiteEditDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>449</width>
- <height>338</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Dialog</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Name</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="diveSiteName"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Coordinates</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="diveSiteCoordinates"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Description</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QPlainTextEdit" name="diveSiteNotes"/>
- </item>
- <item row="3" column="1">
- <widget class="QPlainTextEdit" name="diveSiteDescription"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Notes</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="2">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Dive site quick edit. Hit ESC or click outside to close</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>