summaryrefslogtreecommitdiffstats
path: root/qt-mobile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-17 11:57:21 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-17 12:00:38 -0700
commitd595f5c167c7283dc22f902ed0b18a7d6da2221e (patch)
tree10efaa6874740510a90fb9144facd7abe86ab577 /qt-mobile
parent76e61bd8d9baea008628bf5b176cf8f0b664e78f (diff)
parent0c9756c5d786158f25aaf1ad2d9c316be9e2b9e5 (diff)
downloadsubsurface-d595f5c167c7283dc22f902ed0b18a7d6da2221e.tar.gz
Merge branch 'devel' of https://github.com/gracie89/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile')
-rw-r--r--qt-mobile/DiveList.qml18
-rw-r--r--qt-mobile/main.qml8
-rw-r--r--qt-mobile/qmlmanager.cpp48
-rw-r--r--qt-mobile/qmlmanager.h2
-rw-r--r--qt-mobile/qmlprofile.cpp43
-rw-r--r--qt-mobile/qmlprofile.h27
6 files changed, 144 insertions, 2 deletions
diff --git a/qt-mobile/DiveList.qml b/qt-mobile/DiveList.qml
index 40507e26a..7fa7a53f0 100644
--- a/qt-mobile/DiveList.qml
+++ b/qt-mobile/DiveList.qml
@@ -77,6 +77,13 @@ Rectangle {
id: editorDetails
width: detailsPage.width
columns: 2
+ Text { }
+ QMLProfile {
+ diveId: id
+ height: 400
+ Layout.fillWidth: true
+ }
+
Text { text: "Location:"; font.bold: true }
TextField { id: txtLocation; text: location; Layout.fillWidth: true }
Text { text: "Air Temp:"; font.bold: true }
@@ -109,7 +116,16 @@ Rectangle {
opacity: dive.detailsOpacity
text: "Close"
- onClicked: dive.state = '';
+ onClicked: {
+ manager.commitChanges(
+ id,
+ txtSuit.text,
+ txtBuddy.text,
+ txtDiveMaster.text,
+ txtNotes.text
+ )
+ dive.state = '';
+ }
}
states: State {
diff --git a/qt-mobile/main.qml b/qt-mobile/main.qml
index dac37e09b..d64c27760 100644
--- a/qt-mobile/main.qml
+++ b/qt-mobile/main.qml
@@ -54,6 +54,14 @@ ApplicationWindow {
manager.loadDives();
}
}
+
+ Button {
+ id: saveChanges
+ text: "Save Changes"
+ onClicked: {
+ manager.saveChanges();
+ }
+ }
}
}
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 118465a2d..a1c64191b 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -66,7 +66,53 @@ void QMLManager::loadDives()
struct dive *d;
for_each_dive(i, d)
- DiveListModel::instance()->addDive(d);
+ DiveListModel::instance()->addDive(d);
+}
+
+void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes)
+{
+ struct dive *d = get_dive_by_uniq_id(diveId.toInt());
+ bool diveChanged = false;
+
+ if (d->suit != suit.toUtf8().data()) {
+ diveChanged = true;
+ free(d->suit);
+ d->suit = strdup(suit.toUtf8().data());
+ }
+ if (d->buddy != buddy.toUtf8().data()) {
+ diveChanged = true;
+ free(d->buddy);
+ d->buddy = strdup(buddy.toUtf8().data());
+ }
+ if (d->divemaster != diveMaster.toUtf8().data()) {
+ diveChanged = true;
+ free(d->divemaster);
+ d->divemaster = strdup(diveMaster.toUtf8().data());
+ }
+ if (d->notes != notes.toUtf8().data()) {
+ diveChanged = true;
+ free(d->notes);
+ d->notes = strdup(notes.toUtf8().data());
+ }
+}
+
+void QMLManager::saveChanges()
+{
+ showMessage("Saving dives.");
+ QString fileName;
+ if (getCloudURL(fileName)) {
+ showMessage(get_error_string());
+ return;
+ }
+
+ if (save_dives(fileName.toUtf8().data())) {
+ showMessage(get_error_string());
+ return;
+ }
+
+ showMessage("Dives saved.");
+ set_filename(fileName.toUtf8().data(), true);
+ mark_divelist_changed(false);
}
QString QMLManager::cloudPassword() const
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 558249e4e..2f5ac2894 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -22,6 +22,8 @@ public:
public slots:
void savePreferences();
void loadDives();
+ void commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes);
+ void saveChanges();
private:
QString m_cloudUserName;
QString m_cloudPassword;
diff --git a/qt-mobile/qmlprofile.cpp b/qt-mobile/qmlprofile.cpp
new file mode 100644
index 000000000..351b5b1ce
--- /dev/null
+++ b/qt-mobile/qmlprofile.cpp
@@ -0,0 +1,43 @@
+#include "qmlprofile.h"
+#include "profilewidget2.h"
+#include "dive.h"
+
+QMLProfile::QMLProfile(QQuickItem *parent) :
+ QQuickPaintedItem(parent)
+{
+ profile = new ProfileWidget2(0);
+ profile->setProfileState();
+ profile->setToolTipVisibile(false);
+}
+
+void QMLProfile::paint(QPainter *painter)
+{
+ if (m_diveId.toInt() < 1)
+ return;
+
+ struct dive *d;
+ d = get_dive_by_uniq_id(m_diveId.toInt());
+ if (!d)
+ return;
+
+ int old_animation_speed = prefs.animation_speed;
+ prefs.animation_speed = 0; // no animations while rendering the QGraphicsView
+ profile->plotDive(d);
+ // we need to show the widget so it gets populated, but then
+ // hide it right away so we get to draw it ourselves below
+ profile->show();
+ profile->hide();
+ profile->resize(this->width(), this->height());
+ profile->render(painter, profile->geometry());
+ prefs.animation_speed = old_animation_speed;
+}
+
+QString QMLProfile::diveId() const
+{
+ return m_diveId;
+}
+
+void QMLProfile::setDiveId(const QString &diveId)
+{
+ m_diveId = diveId;
+}
diff --git a/qt-mobile/qmlprofile.h b/qt-mobile/qmlprofile.h
new file mode 100644
index 000000000..b5192913a
--- /dev/null
+++ b/qt-mobile/qmlprofile.h
@@ -0,0 +1,27 @@
+#ifndef QMLPROFILE_H
+#define QMLPROFILE_H
+
+#include <QQuickPaintedItem>
+
+class ProfileWidget2;
+
+class QMLProfile : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString diveId READ diveId WRITE setDiveId NOTIFY diveIdChanged)
+public:
+ explicit QMLProfile(QQuickItem *parent = 0);
+ void paint(QPainter *painter);
+
+ QString diveId() const;
+ void setDiveId(const QString &diveId);
+
+private:
+ QString m_diveId;
+ ProfileWidget2 *profile;
+signals:
+ void rightAlignedChanged();
+ void diveIdChanged();
+};
+
+#endif // QMLPROFILE_H