diff options
-rw-r--r-- | qt-gui.cpp | 8 | ||||
-rw-r--r-- | qt-mobile/DiveDetails.qml | 85 | ||||
-rw-r--r-- | qt-mobile/DiveList.qml | 138 | ||||
-rw-r--r-- | qt-mobile/DownloadFromDiveComputer.qml | 97 | ||||
-rw-r--r-- | qt-mobile/Preferences.qml | 2 | ||||
-rw-r--r-- | qt-mobile/main.qml | 19 | ||||
-rw-r--r-- | qt-mobile/mobile-resources.qrc | 2 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 26 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.h | 6 |
9 files changed, 255 insertions, 128 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp index fac743a43..a4997a6fe 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -17,6 +17,7 @@ #include <QQuickWindow> #include <QQmlApplicationEngine> #include <QQmlContext> +#include <QSortFilterProxyModel> #include "qt-mobile/qmlmanager.h" #include "qt-models/divelistmodel.h" #include "qt-mobile/qmlprofile.h" @@ -44,8 +45,13 @@ void run_ui() qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile"); QQmlApplicationEngine engine; DiveListModel diveListModel; + QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(0); + sortModel->setSourceModel(&diveListModel); + sortModel->setDynamicSortFilter(true); + sortModel->setSortRole(DiveListModel::DiveDateRole); + sortModel->sort(0, Qt::DescendingOrder); QQmlContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("diveModel", &diveListModel); + ctxt->setContextProperty("diveModel", sortModel); engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); qqWindowObject = engine.rootObjects().value(0); if (!qqWindowObject) { diff --git a/qt-mobile/DiveDetails.qml b/qt-mobile/DiveDetails.qml new file mode 100644 index 000000000..5dfefdff8 --- /dev/null +++ b/qt-mobile/DiveDetails.qml @@ -0,0 +1,85 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import org.subsurfacedivelog.mobile 1.0 + +Item { + id: diveDetailsWindow + width: parent.width + + property string location + property string dive_id + property string airtemp + property string watertemp + property string suit + property string buddy + property string divemaster; + property string notes; + + onDive_idChanged: { + qmlProfile.diveId = dive_id + qmlProfile.update() + } + + Flickable { + id: flick + width: parent.width + anchors { top: parent.top; bottom: parent.bottom } + contentHeight: parent.height + clip: true + ColumnLayout { + width: parent.width + RowLayout { + Button { + text: "Back" + onClicked: { + manager.commitChanges( + dive_id, + suit, + buddy, + divemaster, + notes + ) + stackView.pop(); + } + } + } + + GridLayout { + id: editorDetails + width: parent.width + columns: 2 + Text { } + QMLProfile { + id: qmlProfile + height: 500 + Layout.fillWidth: true + } + Text { text: "Location:"; font.bold: true } + TextField { id: txtLocation; text: location; Layout.fillWidth: true } + Text { text: "Air Temp:"; font.bold: true } + TextField { id: txtAirTemp; text: airtemp; Layout.fillWidth: true } + Text { text: "Water Temp:"; font.bold: true } + TextField { id: txtWaterTemp; text: watertemp; Layout.fillWidth: true } + Text { text: "Suit:"; font.bold: true } + TextField { id: txtSuit; text: suit; Layout.fillWidth: true } + Text { text: "Buddy:"; font.bold: true } + TextField { id: txtBuddy; text: buddy; Layout.fillWidth: true } + Text { text: "Dive Master:"; font.bold: true } + TextField { id: txtDiveMaster; text: divemaster; Layout.fillWidth: true} + Text { text: "Notes:"; font.bold: true } + TextEdit{ + id: txtNotes + text: notes + focus: true + Layout.fillWidth: true + Layout.fillHeight: true + selectByMouse: true + wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere + } + } + } + } +} diff --git a/qt-mobile/DiveList.qml b/qt-mobile/DiveList.qml index 7fa7a53f0..e2f6857b7 100644 --- a/qt-mobile/DiveList.qml +++ b/qt-mobile/DiveList.qml @@ -10,7 +10,6 @@ Rectangle { Component { id: diveDelegate - Item { id: dive @@ -24,14 +23,25 @@ Rectangle { id: background x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2; color: "ivory" - border.color: "orange" + border.color: "lightblue" radius: 5 } //Mouse region: When clicked, the mode changes to details view MouseArea { anchors.fill: parent - onClicked: dive.state = 'Details' + onClicked: { + detailsWindow.width = parent.width + detailsWindow.location = location + detailsWindow.dive_id = id + detailsWindow.buddy = buddy + detailsWindow.suit = suit + detailsWindow.airtemp = airtemp + detailsWindow.watertemp = watertemp + detailsWindow.divemaster = divemaster + detailsWindow.notes = notes + stackView.push(detailsWindow) + } } //Layout of the page: (mini profile, dive no, date at the tio @@ -39,7 +49,6 @@ Rectangle { Row { id: topLayout x: 10; y: 10; height: childrenRect.height; width: parent.width - spacing: 10 Column { width: background.width; height: childrenRect.height * 1.1 @@ -48,125 +57,8 @@ Rectangle { Text { text: diveNumber + ' (' + date + ')' } - Text { text: location; width: details.width } - Text { text: '<b>Depth:</b> ' + depth + ' <b>Duration:</b>' + duration; width: details.width } - } - } - - Item { - id: details - x: 10; width: parent.width - 20 - anchors { top: topLayout.bottom; topMargin: 10; bottom:parent.bottom; bottomMargin: 10 } - opacity: dive.detailsOpacity - - Text { - id: detailsTitle - anchors.top: parent.top - text: "Dive Details" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: detailsTitle.bottom; bottom: parent.bottom } - contentHeight: editorDetails.height - clip: true - - GridLayout { - 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 } - TextField { id: txtAirTemp; text: airtemp; Layout.fillWidth: true } - Text { text: "Water Temp:"; font.bold: true } - TextField { id: txtWaterTemp; text: watertemp; Layout.fillWidth: true } - Text { text: "Suit:"; font.bold: true } - TextField { id: txtSuit; text: suit; Layout.fillWidth: true } - Text { text: "Buddy:"; font.bold: true } - TextField { id: txtBuddy; text: buddy; Layout.fillWidth: true } - Text { text: "Dive Master:"; font.bold: true } - TextField { id: txtDiveMaster; text: divemaster; Layout.fillWidth: true} - Text { text: "Notes:"; font.bold: true } - TextEdit{ - id: txtNotes - text: notes - focus: true - Layout.fillWidth: true - Layout.fillHeight: true - selectByMouse: true - wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere - } - } - } - } - - TextButton { - y: 10 - anchors { right: background.right; rightMargin: 10 } - opacity: dive.detailsOpacity - text: "Close" - - onClicked: { - manager.commitChanges( - id, - txtSuit.text, - txtBuddy.text, - txtDiveMaster.text, - txtNotes.text - ) - dive.state = ''; - } - } - - states: State { - name: "Details" - - PropertyChanges { - target: background - color: "white" - } - - PropertyChanges { - target: dive - detailsOpacity: 1; x:0 //Make details visible - height: diveListView.height //Fill entire list area with the details - } - - //Move the list so that this item is at the top - PropertyChanges { - target: dive.ListView.view - explicit: true - contentY: dive.y - } - - //Disable flicking while we are in detailed view - PropertyChanges { - target: dive.ListView.view - interactive: false - } - } - - transitions: Transition { - //make the state changes smooth - ParallelAnimation { - ColorAnimation { - property: "color" - duration: 500 - } - NumberAnimation { - duration: 300 - properties: "detailsOpacity,x,contentY,height,width" - } + Text { text: location; width: parent.width } + Text { text: '<b>Depth:</b> ' + depth + ' <b>Duration:</b>' + duration; width: parent.width } } } } diff --git a/qt-mobile/DownloadFromDiveComputer.qml b/qt-mobile/DownloadFromDiveComputer.qml new file mode 100644 index 000000000..d23754407 --- /dev/null +++ b/qt-mobile/DownloadFromDiveComputer.qml @@ -0,0 +1,97 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Window 2.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import org.subsurfacedivelog.mobile 1.0 + +Item { + id: diveComputerDownloadWindow + anchors.top: parent.top + width: parent.width + height: parent.height + + GridLayout { + columns: 2 + anchors.top: parent.top + width: parent.width + height: parent.height + ColumnLayout { + height: parent.height + width: parent.width + ColumnLayout { + width: parent.width + Layout.fillHeight: true + ColumnLayout { + Layout.fillHeight: true + Layout.fillWidth: true + ColumnLayout { + height: parent.height + Layout.fillWidth: true + Text { text: "Vendor" } + ComboBox { Layout.fillWidth: true } + Text { text: "Dive Computer" } + ComboBox { Layout.fillWidth: true } + Text { text: "Device or mount point" } + RowLayout { + Layout.fillWidth: true + TextField { Layout.fillWidth: true } + Button { text: "..." } + } + GridLayout { + columns: 2 + CheckBox { text: "Force download of all dives" } + CheckBox { text: "Always prefer downloaded dives" } + CheckBox { text: "Download into new trip" } + CheckBox { text: "Save libdivecomputer logfile" } + CheckBox { text: "Save libdivecomputer dumpfile" } + CheckBox { text: "Choose Bluetooth download mode" } + } + + RowLayout { + Layout.fillWidth: true + ProgressBar { Layout.fillWidth: true } + Button { text: "Download" } + } + } + } + ColumnLayout { + height: parent.height + Layout.fillWidth: true + RowLayout { + Text { + text: "Downloaded dives" + } + Button { + text: "Select All" + } + Button { + text: "Unselect All" + } + } + TableView { + Layout.fillWidth: true + Layout.fillHeight: true + } + } + } + RowLayout { + width: parent.width + Button { + text: "OK" + + onClicked: { + stackView.pop(); + } + } + Button { + text: "Cancel" + + onClicked: { + stackView.pop(); + } + } + } + } + } +} diff --git a/qt-mobile/Preferences.qml b/qt-mobile/Preferences.qml index f03ab8a02..8f4a15328 100644 --- a/qt-mobile/Preferences.qml +++ b/qt-mobile/Preferences.qml @@ -50,6 +50,7 @@ Item { } CheckBox { + checked: manager.saveCloudPassword id: savePassword } @@ -63,6 +64,7 @@ Item { onClicked: { manager.cloudUserName = login.text manager.cloudPassword = password.text + manager.saveCloudPassword = savePassword.checked manager.savePreferences() stackView.pop() } diff --git a/qt-mobile/main.qml b/qt-mobile/main.qml index d64c27760..9553197b6 100644 --- a/qt-mobile/main.qml +++ b/qt-mobile/main.qml @@ -56,6 +56,16 @@ ApplicationWindow { } Button { + id: downloadDivesButton + text: "Download Dives" + onClicked: { + downloadDivesWindow.height = parent.height + downloadDivesWindow.width = parent.width + stackView.push(downloadDivesWindow) + } + } + + Button { id: saveChanges text: "Save Changes" onClicked: { @@ -104,4 +114,13 @@ ApplicationWindow { visible: false } + DiveDetails { + id: detailsWindow + visible: false + } + + DownloadFromDiveComputer { + id: downloadDivesWindow + visible: false + } } diff --git a/qt-mobile/mobile-resources.qrc b/qt-mobile/mobile-resources.qrc index d0fe06701..969f727d9 100644 --- a/qt-mobile/mobile-resources.qrc +++ b/qt-mobile/mobile-resources.qrc @@ -4,5 +4,7 @@ <file>TextButton.qml</file> <file>Preferences.qml</file> <file>DiveList.qml</file> + <file>DiveDetails.qml</file> + <file>DownloadFromDiveComputer.qml</file> </qresource> </RCC> diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index a1c64191b..8cefbe95f 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -20,6 +20,7 @@ QMLManager::QMLManager() //Initialize cloud credentials. setCloudUserName(prefs.cloud_storage_email); setCloudPassword(prefs.cloud_storage_password); + setSaveCloudPassword(prefs.save_password_local); } QMLManager::~QMLManager() @@ -31,15 +32,22 @@ void QMLManager::savePreferences() QSettings s; s.beginGroup("CloudStorage"); s.setValue("email", cloudUserName()); - s.setValue("password", cloudPassword()); + s.setValue("save_password_local", saveCloudPassword()); + if (saveCloudPassword()) + s.setValue("password", cloudPassword()); s.sync(); if (!same_string(prefs.cloud_storage_email, qPrintable(cloudUserName()))) { free(prefs.cloud_storage_email); prefs.cloud_storage_email = strdup(qPrintable(cloudUserName())); } - if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPassword()))) { - free(prefs.cloud_storage_password); - prefs.cloud_storage_password = strdup(qPrintable(cloudPassword())); + if (saveCloudPassword() != prefs.save_password_local) { + prefs.save_password_local = saveCloudPassword(); + } + if (saveCloudPassword()) { + if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPassword()))) { + free(prefs.cloud_storage_password); + prefs.cloud_storage_password = strdup(qPrintable(cloudPassword())); + } } } @@ -114,6 +122,16 @@ void QMLManager::saveChanges() set_filename(fileName.toUtf8().data(), true); mark_divelist_changed(false); } +bool QMLManager::saveCloudPassword() const +{ + return m_saveCloudPassword; +} + +void QMLManager::setSaveCloudPassword(bool saveCloudPassword) +{ + m_saveCloudPassword = saveCloudPassword; +} + QString QMLManager::cloudPassword() const { diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index 2f5ac2894..0f1df2b59 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -9,6 +9,7 @@ class QMLManager : public QObject Q_OBJECT Q_PROPERTY(QString cloudUserName READ cloudUserName WRITE setCloudUserName NOTIFY cloudUserNameChanged) Q_PROPERTY(QString cloudPassword READ cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged) + Q_PROPERTY(bool saveCloudPassword READ saveCloudPassword WRITE setSaveCloudPassword NOTIFY saveCloudPasswordChanged) public: QMLManager(); ~QMLManager(); @@ -19,6 +20,9 @@ public: QString cloudPassword() const; void setCloudPassword(const QString &cloudPassword); + bool saveCloudPassword() const; + void setSaveCloudPassword(bool saveCloudPassword); + public slots: void savePreferences(); void loadDives(); @@ -27,10 +31,12 @@ public slots: private: QString m_cloudUserName; QString m_cloudPassword; + bool m_saveCloudPassword; signals: void cloudUserNameChanged(); void cloudPasswordChanged(); + void saveCloudPasswordChanged(); }; #endif |