diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index ad536576..6c592a43 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -53,48 +53,7 @@ Tab::Tab( [this] { // Restore session from DB - sqlite3_stmt* statement; - - const int PREPARE = ::sqlite3_prepare_v3( - this->db, - R"SQL( - SELECT * FROM `app_browser_main_tab` ORDER BY `number` ASC - )SQL", - -1, - SQLITE_PREPARE_NORMALIZE, - &statement, - nullptr - ); - - if (PREPARE == SQLITE_OK) - { - while (::sqlite3_step(statement) == SQLITE_ROW) - { - const int PAGE_NUMBER = append(); - - get_tabPage( - PAGE_NUMBER - )->set_navbar_request_text( - reinterpret_cast( - ::sqlite3_column_text( - statement, - DB::APP_BROWSER_MAIN_TAB::REQUEST - ) - ) - ); - - if (::sqlite3_column_int(statement, DB::APP_BROWSER_MAIN_TAB::CURRENT) == 1) - { - set_current_page( - PAGE_NUMBER - ); - } - } - } - - sqlite3_finalize( - statement - ); + restore(); } ); @@ -107,6 +66,52 @@ Tab::Tab( ); } +void Tab::restore() +{ + sqlite3_stmt* statement; + + const int PREPARE = ::sqlite3_prepare_v3( + this->db, + R"SQL( + SELECT * FROM `app_browser_main_tab` ORDER BY `number` ASC + )SQL", + -1, + SQLITE_PREPARE_NORMALIZE, + &statement, + nullptr + ); + + if (PREPARE == SQLITE_OK) + { + while (::sqlite3_step(statement) == SQLITE_ROW) + { + const int PAGE_NUMBER = append(); + + get_tabPage( + PAGE_NUMBER + )->set_navbar_request_text( + reinterpret_cast( + ::sqlite3_column_text( + statement, + DB::APP_BROWSER_MAIN_TAB::REQUEST + ) + ) + ); + + if (::sqlite3_column_int(statement, DB::APP_BROWSER_MAIN_TAB::CURRENT) == 1) + { + set_current_page( + PAGE_NUMBER + ); + } + } + } + + sqlite3_finalize( + statement + ); +} + void Tab::save() { char * error; // @TODO diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index 0711edbe..675daa8e 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -94,6 +94,8 @@ namespace app::browser::main const int & PAGE_NUMBER ); + void restore(); + void save(); void shutdown();