[vlc-commits] qml: allow to update the current history item
Pierre Lamot
git at videolan.org
Fri Feb 14 11:59:49 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Jan 27 12:52:28 2020 +0100| [e627f54bf7e7454999173b1b4ca3bfb500043e8d] | committer: Jean-Baptiste Kempf
qml: allow to update the current history item
this may be used for instance to save the current view position,
like #fragment in url links
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e627f54bf7e7454999173b1b4ca3bfb500043e8d
---
modules/gui/qt/util/navigation_history.cpp | 17 ++++++++++++++++-
modules/gui/qt/util/navigation_history.hpp | 15 +++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/modules/gui/qt/util/navigation_history.cpp b/modules/gui/qt/util/navigation_history.cpp
index 5f494d1c58..7952f7829b 100644
--- a/modules/gui/qt/util/navigation_history.cpp
+++ b/modules/gui/qt/util/navigation_history.cpp
@@ -1,5 +1,5 @@
#include "navigation_history.hpp"
-#include <QDebug>
+#include <cassert>
NavigationHistory::NavigationHistory(QObject *parent)
: QObject(parent), m_position(-1)
@@ -67,6 +67,21 @@ void NavigationHistory::push(QVariantList itemList, NavigationHistory::PostActio
push(itemMap, postAction);
}
+
+void NavigationHistory::update(QVariantMap item)
+{
+ int length = m_history.length();
+ assert(length >= 1);
+ m_history.replace(m_position, item);
+}
+
+void NavigationHistory::update(QVariantList itemList)
+{
+ QVariantMap itemMap;
+ pushListRec(itemMap, itemList.cbegin(), itemList.cend());
+ update(itemMap);
+}
+
void NavigationHistory::previous(PostAction postAction)
{
if (m_position == 0)
diff --git a/modules/gui/qt/util/navigation_history.hpp b/modules/gui/qt/util/navigation_history.hpp
index a07c0ab93a..b19d476b14 100644
--- a/modules/gui/qt/util/navigation_history.hpp
+++ b/modules/gui/qt/util/navigation_history.hpp
@@ -66,6 +66,21 @@ public slots:
*/
Q_INVOKABLE void push(QVariantList itemList, PostAction = PostAction::Stay );
+
+ /**
+ * @brief same as @a push(QVariantMap) but modify the last (current) item instead of insterting a new one
+ *
+ * @see push
+ */
+ Q_INVOKABLE void update(QVariantMap itemList);
+
+ /**
+ * @brief same as @a push(QVariantList) but modify the last (current) item instead of insterting a new one
+ *
+ * @see push
+ */
+ Q_INVOKABLE void update(QVariantList itemList);
+
// Go to previous page
void previous( PostAction = PostAction::Stay );
More information about the vlc-commits
mailing list