summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/locationinformation.cpp3
-rw-r--r--desktop-widgets/locationinformation.h1
-rw-r--r--qt-models/filtermodels.cpp18
-rw-r--r--qt-models/filtermodels.h1
4 files changed, 23 insertions, 0 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index a74f08fa1..ad00198b7 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -36,6 +36,8 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
connect(this, SIGNAL(startFilterDiveSite(uint32_t)), MultiFilterSortModel::instance(), SLOT(startFilterDiveSite(uint32_t)));
connect(this, SIGNAL(stopFilterDiveSite()), MultiFilterSortModel::instance(), SLOT(stopFilterDiveSite()));
connect(ui.geoCodeButton, SIGNAL(clicked()), this, SLOT(reverseGeocode()));
+ connect(this, SIGNAL(nameChanged(const QString &, const QString &)),
+ LocationFilterModel::instance(), SLOT(changeName(const QString &, const QString &)));
SsrfSortFilterProxyModel *filter_model = new SsrfSortFilterProxyModel(this);
filter_model->setSourceModel(LocationInformationModel::instance());
@@ -156,6 +158,7 @@ void LocationInformationWidget::acceptChanges()
currentDs->latitude = displayed_dive_site.latitude;
currentDs->longitude = displayed_dive_site.longitude;
if (!same_string(uiString, currentDs->name)) {
+ emit nameChanged(QString(currentDs->name), ui.diveSiteName->text());
free(currentDs->name);
currentDs->name = uiString;
} else {
diff --git a/desktop-widgets/locationinformation.h b/desktop-widgets/locationinformation.h
index 01bc2c74a..3a2696a54 100644
--- a/desktop-widgets/locationinformation.h
+++ b/desktop-widgets/locationinformation.h
@@ -41,6 +41,7 @@ signals:
void stopFilterDiveSite();
void requestCoordinates();
void endRequestCoordinates();
+ void nameChanged(const QString &oldName, const QString &newName);
private:
void clearLabels();
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 51587edc8..568fcd9e2 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -315,6 +315,24 @@ void LocationFilterModel::repopulate()
updateList(list);
}
+void LocationFilterModel::changeName(const QString &oldName, const QString &newName)
+{
+ if (oldName.isEmpty() || newName.isEmpty() || oldName == newName)
+ return;
+ QStringList list = stringList();
+ int oldIndex = list.indexOf(oldName);
+ if (oldIndex < 0)
+ return;
+ int newIndex = list.indexOf(newName);
+ list[oldIndex] = newName;
+ setStringList(list);
+
+ // If there was already an entry with the new name, we are merging entries.
+ // Thus, if the old entry was selected, also select the new entry.
+ if (newIndex >= 0 && checkState[oldIndex])
+ checkState[newIndex] = true;
+}
+
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) :
QSortFilterProxyModel(parent),
divesDisplayed(0),
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 3060f7cf3..45f820984 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -68,6 +68,7 @@ public:
public
slots:
void repopulate();
+ void changeName(const QString &oldName, const QString &newName);
private:
explicit LocationFilterModel(QObject *parent = 0);