summaryrefslogtreecommitdiffstats
path: root/qt-mobile/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-02 18:49:02 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-02 18:49:02 -0800
commitf17041e1cb2e708e2968f7c313e7af559132ccc1 (patch)
treeca08bea947fb2a977a9e4bdb4d9b5a0e3e3b0e55 /qt-mobile/qmlmanager.cpp
parent789c32bf4ca93813095beefa9d0c4bc662a354d2 (diff)
downloadsubsurface-f17041e1cb2e708e2968f7c313e7af559132ccc1.tar.gz
QML-UI: refuse to save to cloud unless you loaded from cloud, first
This prevents people from overwriting a perfectly fine repository with an empty one. Typically happens when you first enter your cloud credentials and then don't Load Dives right away. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qmlmanager.cpp')
-rw-r--r--qt-mobile/qmlmanager.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index ffd0a4e8c..d5a3c51ad 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -129,6 +129,7 @@ void QMLManager::loadDives()
DiveListModel::instance()->addDive(d);
}
appendTextToLog(QString("%1 dives loaded").arg(i));
+ setLoadFromCloud(true);
}
void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes)
@@ -162,6 +163,10 @@ void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QStr
void QMLManager::saveChanges()
{
+ if (!loadFromCloud()) {
+ qmlUiShowMessage("Don't save dives without loading from the cloud, first.");
+ return;
+ }
qmlUiShowMessage("Saving dives.");
QString fileName;
if (getCloudURL(fileName)) {
@@ -287,3 +292,14 @@ void QMLManager::setTimeThreshold(int time)
m_timeThreshold = time;
emit timeThresholdChanged();
}
+
+bool QMLManager::loadFromCloud() const
+{
+ return m_loadFromCloud;
+}
+
+void QMLManager::setLoadFromCloud(bool done)
+{
+ m_loadFromCloud = done;
+ emit loadFromCloudChanged();
+}