Browse Source

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@videolan.org>
pull/103/head
Pierre Lamot 7 years ago
committed by Jean-Baptiste Kempf
parent
commit
e627f54bf7
  1. 17
      modules/gui/qt/util/navigation_history.cpp
  2. 15
      modules/gui/qt/util/navigation_history.hpp

17
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)

15
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 );

Loading…
Cancel
Save