summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-11 15:26:13 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-10 09:25:57 -0700
commit8e6cc9b8d0dd5d312440b3329ee0dc4c5a133f4e (patch)
treea5c108793eb548a51ea361993425a441f239de93 /mobile-widgets/qmlmanager.cpp
parent41072cf48f59b67391bac637002ca4a4c224eff6 (diff)
downloadsubsurface-8e6cc9b8d0dd5d312440b3329ee0dc4c5a133f4e.tar.gz
mobile UI: make the text of the undo/redo action available to QML
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index f9fdb3a87..81806ddea 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -16,6 +16,7 @@
#include <QFile>
#include <QtConcurrent>
#include <QFuture>
+#include <QUndoStack>
#include <QBluetoothLocalDevice>
@@ -269,6 +270,10 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
// careful - changing verbose at runtime isn't enough (of course that could be added if we want it)
if (verbose)
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &QMLManager::divesChanged);
+
+ // get updates to the undo/redo texts
+ connect(Command::getUndoStack(), &QUndoStack::undoTextChanged, this, &QMLManager::undoTextChanged);
+ connect(Command::getUndoStack(), &QUndoStack::redoTextChanged, this, &QMLManager::redoTextChanged);
}
void QMLManager::applicationStateChanged(Qt::ApplicationState state)
@@ -1392,7 +1397,13 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync)
void QMLManager::undoDelete(int)
{
- undoAction->activate(QAction::Trigger);
+ Command::getUndoStack()->undo();
+ changesNeedSaving();
+}
+
+void QMLManager::redo()
+{
+ Command::getUndoStack()->redo();
changesNeedSaving();
}
@@ -2199,3 +2210,15 @@ void QMLManager::divesChanged(const QVector<dive *> &dives, DiveField field)
// invalidate_dive_cache(d);
}
}
+
+QString QMLManager::getUndoText() const
+{
+ QString undoText = Command::getUndoStack()->undoText();
+ return undoText;
+}
+
+QString QMLManager::getRedoText() const
+{
+ QString redoText = Command::getUndoStack()->redoText();
+ return redoText;
+}