aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-07 22:30:58 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-07 22:30:58 -0800
commit624e44e73ddcec374a67c477e61bac2250de33b5 (patch)
tree7bcd110e4bec82a257952045f72baad4a0a5e12b /qt-mobile
parenta0d3480bbe5a14eec43242923657ecbff9f89dbe (diff)
downloadsubsurface-624e44e73ddcec374a67c477e61bac2250de33b5.tar.gz
QML UI: clean up notes field after edit
We don't want any of the rich text markup to sneak into our fields. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile')
-rw-r--r--qt-mobile/qml/DiveDetails.qml7
-rw-r--r--qt-mobile/qmlmanager.cpp12
-rw-r--r--qt-mobile/qmlmanager.h2
3 files changed, 13 insertions, 8 deletions
diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml
index c464551db..0dd380311 100644
--- a/qt-mobile/qml/DiveDetails.qml
+++ b/qt-mobile/qml/DiveDetails.qml
@@ -80,9 +80,9 @@ MobileComponents.Page {
iconName: "document-save"
onTriggered: {
// apply the changes to the dive_table
- manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
- detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
- detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText)
+ notes = manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
+ detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
+ detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText)
// apply the changes to the dive detail view
date = detailsEdit.dateText
location = detailsEdit.locationText
@@ -93,7 +93,6 @@ MobileComponents.Page {
suit = detailsEdit.suitText
buddy = detailsEdit.buddyText
divemaster = detailsEdit.divemasterText
- notes = detailsEdit.notesText
// back to view state and close the drawer
diveDetailsWindow.state = "view"
contextDrawer.close()
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 4dd5ca4fb..b3c5840b4 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -5,6 +5,7 @@
#include <QNetworkAccessManager>
#include <QAuthenticator>
#include <QDesktopServices>
+#include <QTextDocument>
#include "qt-models/divelistmodel.h"
#include "divelist.h"
@@ -309,15 +310,19 @@ void QMLManager::loadDivesWithValidCredentials()
setLoadFromCloud(true);
}
-void QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
+// update the dive and return the notes field, stripped of the HTML junk
+QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
{
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
- qDebug() << diveId.toInt() << (d != 0 ? d->number : -1);
+ // notes comes back as rich text - let's convert this into plain text
+ QTextDocument doc;
+ doc.setHtml(notes);
+ notes = doc.toPlainText();
if (!d) {
qDebug() << "don't touch this... no dive";
- return;
+ return notes;
}
bool diveChanged = false;
bool needResort = false;
@@ -455,6 +460,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
}
mark_divelist_changed(true);
}
+ return notes;
}
void QMLManager::saveChanges()
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 1953f0d76..ebc33abf9 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -71,7 +71,7 @@ public slots:
void loadDivesWithValidCredentials();
void loadDiveProgress(int percent);
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
- void commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
+ QString commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes);
void saveChanges();
QString addDive();