From b1f2a1b893b47bd1b7c28d5b7e76da1f23e685d9 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 10 Sep 2024 20:50:31 +0300 Subject: [PATCH] draft children components save action delegation --- src/app/browser/main/tab.cpp | 9 +++++++-- src/app/browser/main/tab/page.cpp | 7 +++++++ src/app/browser/main/tab/page.hpp | 2 ++ src/app/browser/main/tab/page/navigation.cpp | 7 +++++++ src/app/browser/main/tab/page/navigation.hpp | 2 ++ src/app/browser/main/tab/page/navigation/request.cpp | 5 +++++ src/app/browser/main/tab/page/navigation/request.hpp | 2 ++ 7 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index b532c496..ed257ac4 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -129,7 +129,7 @@ int Tab::save() // Save current tab session for (int page_number = 0; page_number < get_n_pages(); page_number++) { - auto tabLabel = get_tabLabel( + const auto TAB_LABEL = get_tabLabel( page_number ); @@ -151,12 +151,17 @@ int Tab::save() )SQL", page_number, page_number == get_current_page() ? 1 : 0, - tabLabel->get_text() + TAB_LABEL->get_text() ).c_str(), nullptr, nullptr, &error ); + + // Delegate save action to the page component + get_tabPage( + page_number + )->save(); } } diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index e0097608..380858f8 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -63,6 +63,13 @@ void Page::refresh() ); } +int Page::save() +{ + pageNavigation->save(); + + return 1; // @TODO SQL +} + void Page::update( const enum MIME & MIME, const Glib::ustring & TITLE, diff --git a/src/app/browser/main/tab/page.hpp b/src/app/browser/main/tab/page.hpp index bf9dc40d..94294ac7 100644 --- a/src/app/browser/main/tab/page.hpp +++ b/src/app/browser/main/tab/page.hpp @@ -70,6 +70,8 @@ namespace app::browser::main::tab // Actions void refresh(); + int save(); + void update( const MIME & MIME, const Glib::ustring & TITLE, diff --git a/src/app/browser/main/tab/page/navigation.cpp b/src/app/browser/main/tab/page/navigation.cpp index 9c0b79e0..0b7cf91f 100644 --- a/src/app/browser/main/tab/page/navigation.cpp +++ b/src/app/browser/main/tab/page/navigation.cpp @@ -101,6 +101,13 @@ void Navigation::refresh( ); } +int Navigation::save() +{ + navigationRequest->save(); + + return 1; // @TODO SQL +} + void Navigation::history_add( const Glib::ustring & REQUEST, const bool & UPDATE_MEMORY_INDEX diff --git a/src/app/browser/main/tab/page/navigation.hpp b/src/app/browser/main/tab/page/navigation.hpp index 654dce85..9c4bd193 100644 --- a/src/app/browser/main/tab/page/navigation.hpp +++ b/src/app/browser/main/tab/page/navigation.hpp @@ -45,6 +45,8 @@ namespace app::browser::main::tab::page const double & PROGRESS_FRACTION ); + int save(); + void history_add( const Glib::ustring & REQUEST, const bool & UPDATE_MEMORY_INDEX diff --git a/src/app/browser/main/tab/page/navigation/request.cpp b/src/app/browser/main/tab/page/navigation/request.cpp index b9d30ee1..138028f3 100644 --- a/src/app/browser/main/tab/page/navigation/request.cpp +++ b/src/app/browser/main/tab/page/navigation/request.cpp @@ -78,6 +78,11 @@ void Request::refresh( ); } +int Request::save() +{ + return 1; // @TODO SQL +} + void Request::parse() { auto match = Glib::Regex::split_simple( diff --git a/src/app/browser/main/tab/page/navigation/request.hpp b/src/app/browser/main/tab/page/navigation/request.hpp index 7ccea522..54322c70 100644 --- a/src/app/browser/main/tab/page/navigation/request.hpp +++ b/src/app/browser/main/tab/page/navigation/request.hpp @@ -46,6 +46,8 @@ namespace app::browser::main::tab::page::navigation const double & PROGRESS_FRACTION ); + int save(); + // Getters Glib::ustring get_scheme(); Glib::ustring get_host();