[vlc-devel] [PATCH 08/10] qt: remove support for history next

Prince Gupta guptaprince8832 at gmail.com
Fri Nov 20 18:29:41 CET 2020


From: Pierre Lamot <pierre at videolabs.io>

  the next button is no longer accessible
---
 modules/gui/qt/util/navigation_history.cpp | 55 ++++------------------
 modules/gui/qt/util/navigation_history.hpp |  7 ---
 2 files changed, 9 insertions(+), 53 deletions(-)

diff --git a/modules/gui/qt/util/navigation_history.cpp b/modules/gui/qt/util/navigation_history.cpp
index a3cedb876f..9d5e622ea8 100644
--- a/modules/gui/qt/util/navigation_history.cpp
+++ b/modules/gui/qt/util/navigation_history.cpp
@@ -2,42 +2,24 @@
 #include <cassert>
 
 NavigationHistory::NavigationHistory(QObject *parent)
-    : QObject(parent), m_position(-1)
+    : QObject(parent)
 {
-
 }
 
 QVariant NavigationHistory::getCurrent()
 {
-    return m_history[m_position];
+    return m_history.back();
 }
 
 bool NavigationHistory::isPreviousEmpty()
 {
-    return m_position < 1;
-}
-
-bool NavigationHistory::isNextEmpty()
-{
-    return m_position == m_history.length() - 1;
+    return m_history.count() <= 1;
 }
 
 void NavigationHistory::push(QVariantMap item, PostAction postAction)
 {
-    if (m_position < m_history.length() - 1) {
-        /* We want to push a new view while we have other views
-         * after the current one.
-         * In the case we delete all the following views. */
-        m_history.erase(m_history.begin() + m_position + 1, m_history.end());
-        emit nextEmptyChanged(true);
-    }
-
-    //m_history.push_back(VariantToPropertyMap(item));
     m_history.push_back(item);
-    // Set to last position
-    m_position++;
-    if (m_position == 1)
-        emit previousEmptyChanged(true);
+    emit previousEmptyChanged(false);
     if (postAction == PostAction::Go)
         emit currentChanged(m_history.back());
 }
@@ -74,7 +56,7 @@ void NavigationHistory::update(QVariantMap item)
 {
     int length = m_history.length();
     assert(length >= 1);
-    m_history.replace(m_position, item);
+    m_history.back() = item;
 }
 
 void NavigationHistory::update(QVariantList itemList)
@@ -86,33 +68,14 @@ void NavigationHistory::update(QVariantList itemList)
 
 void NavigationHistory::previous(PostAction postAction)
 {
-    if (m_position == 0)
+    if (m_history.count() == 1)
         return;
 
-    //delete m_history.back();
-    m_position--;
+    m_history.pop_back();
 
-    if (m_position == 0)
+    if (m_history.count() == 1)
         emit previousEmptyChanged(true);
-    if (m_position == m_history.length() - 2)
-        emit nextEmptyChanged(false);
-
-    if (postAction == PostAction::Go)
-        emit currentChanged(m_history[m_position]);
-}
-
-void NavigationHistory::next(PostAction postAction)
-{
-    if (m_position == m_history.length() - 1)
-        return;
-
-    m_position++;
-
-    if (m_position == 1)
-        emit previousEmptyChanged(false);
-    if (m_position == m_history.length() - 1)
-        emit nextEmptyChanged(true);
 
     if (postAction == PostAction::Go)
-        emit currentChanged(m_history[m_position]);
+        emit currentChanged( m_history.back() );
 }
diff --git a/modules/gui/qt/util/navigation_history.hpp b/modules/gui/qt/util/navigation_history.hpp
index e6800f6f05..4e9793ace0 100644
--- a/modules/gui/qt/util/navigation_history.hpp
+++ b/modules/gui/qt/util/navigation_history.hpp
@@ -11,7 +11,6 @@ class NavigationHistory : public QObject
 public:
     Q_PROPERTY(QVariant current READ getCurrent NOTIFY currentChanged)
     Q_PROPERTY(bool previousEmpty READ isPreviousEmpty NOTIFY previousEmptyChanged)
-    Q_PROPERTY(bool nextEmpty READ isNextEmpty NOTIFY nextEmptyChanged)
 
     enum class PostAction{
         Stay,
@@ -24,12 +23,10 @@ public:
 
     QVariant getCurrent();
     bool isPreviousEmpty();
-    bool isNextEmpty();
 
 signals:
     void currentChanged(QVariant current);
     void previousEmptyChanged(bool empty);
-    void nextEmptyChanged(bool empty);
 
 public slots:
     /**
@@ -84,12 +81,8 @@ public slots:
     // Go to previous page
     void previous( PostAction = PostAction::Go );
 
-    // Go to next page
-    void next( PostAction = PostAction::Go );
-
 private:
     QVariantList m_history;
-    int m_position;
 };
 
 #endif // NAVIGATION_HISTORY_HPP
-- 
2.25.1



More information about the vlc-devel mailing list