From de40ed88921945cef8c125aa4f9ecef69b4f52be Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 4 Sep 2024 20:51:14 +0300 Subject: [PATCH] rename method --- src/app/browser/main/tab/page.cpp | 2 +- src/app/browser/main/tab/page/navbar.cpp | 4 +- src/app/browser/main/tab/page/navbar.hpp | 8 +- .../browser/main/tab/page/navbar/history.cpp | 79 ++++++++++--------- .../browser/main/tab/page/navbar/history.hpp | 18 ++--- 5 files changed, 57 insertions(+), 54 deletions(-) diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index 251eaf99..225b3ec9 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -104,7 +104,7 @@ void Page::refresh( void Page::update() { // Update navigation history - pageNavbar->history_push( + pageNavbar->history_add( pageNavbar->get_request_text() ); diff --git a/src/app/browser/main/tab/page/navbar.cpp b/src/app/browser/main/tab/page/navbar.cpp index 398cfd32..068509ff 100644 --- a/src/app/browser/main/tab/page/navbar.cpp +++ b/src/app/browser/main/tab/page/navbar.cpp @@ -115,10 +115,10 @@ void Navbar::history_forward() } } -void Navbar::history_push( +void Navbar::history_add( const Glib::ustring & VALUE ) { - navbarHistory->push( + navbarHistory->add( VALUE ); } diff --git a/src/app/browser/main/tab/page/navbar.hpp b/src/app/browser/main/tab/page/navbar.hpp index 647cfb3d..88f063b1 100644 --- a/src/app/browser/main/tab/page/navbar.hpp +++ b/src/app/browser/main/tab/page/navbar.hpp @@ -37,12 +37,14 @@ namespace app::browser::main::tab::page ); // Actions - void history_back(); - void history_forward(); - void history_push( + void history_add( const Glib::ustring & VALUE ); + void history_back(); + void history_forward(); + + void refresh(); // Setters diff --git a/src/app/browser/main/tab/page/navbar/history.cpp b/src/app/browser/main/tab/page/navbar/history.cpp index 4ad08f57..f37b3ada 100644 --- a/src/app/browser/main/tab/page/navbar/history.cpp +++ b/src/app/browser/main/tab/page/navbar/history.cpp @@ -24,6 +24,46 @@ History::History() } // Actions +void History::add( + const Glib::ustring & REQUEST, + const bool & FOLLOW +) { + memory.push_back( + { + REQUEST, + std::time( + nullptr + ), + true + } + ); + + if (FOLLOW) + { + index = memory.size(); // @TODO not last index, use iterator + } +} + +void History::refresh() +{ + Memory match; + + historyBack->set_sensitive( + try_back( + match, + false + ) + ); + + historyForward->set_sensitive( + try_forward( + match, + false + ) + ); +} + + bool History::try_back( Memory & match, const bool & FOLLOW @@ -70,43 +110,4 @@ bool History::try_forward( { return false; } -} - -void History::push( - const Glib::ustring & REQUEST, - const bool & FOLLOW -) { - memory.push_back( - { - REQUEST, - std::time( - nullptr - ), - true - } - ); - - if (FOLLOW) - { - index = memory.size(); // @TODO not last index, use iterator - } -} - -void History::refresh() -{ - Memory match; - - historyBack->set_sensitive( - try_back( - match, - false - ) - ); - - historyForward->set_sensitive( - try_forward( - match, - false - ) - ); } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/navbar/history.hpp b/src/app/browser/main/tab/page/navbar/history.hpp index f5920a2f..173bc0f3 100644 --- a/src/app/browser/main/tab/page/navbar/history.hpp +++ b/src/app/browser/main/tab/page/navbar/history.hpp @@ -40,24 +40,24 @@ namespace app::browser::main::tab::page::navbar History(); // Actions - bool try_back( - Memory & match, + void add( + const Glib::ustring & REQUEST, const bool & FOLLOW = true ); - bool try_forward( + void refresh(); + + void save(); // @TODO save history to the permanent storage + + bool try_back( Memory & match, const bool & FOLLOW = true ); - void push( - const Glib::ustring & REQUEST, + bool try_forward( + Memory & match, const bool & FOLLOW = true ); - - void save(); // @TODO save history to the permanent storage - - void refresh(); }; }