Browse Source

save session page number and current tab activity status

CPP-GTK4
yggverse 3 months ago
parent
commit
aceef398bf
  1. 19
      src/app/browser/main/tab.cpp
  2. 2
      src/app/browser/main/tab.hpp

19
src/app/browser/main/tab.cpp

@ -25,6 +25,8 @@ Tab::Tab(
( (
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`time` INTEGER NOT NULL, `time` INTEGER NOT NULL,
`number` INTEGER NOT NULL,
`current` INTEGER NOT NULL,
`request` VARCHAR(1024) `request` VARCHAR(1024)
) )
)SQL", )SQL",
@ -56,7 +58,7 @@ Tab::Tab(
const int PREPARE = ::sqlite3_prepare_v3( const int PREPARE = ::sqlite3_prepare_v3(
this->db, this->db,
R"SQL( R"SQL(
SELECT * FROM `app_browser_main_tab` SELECT * FROM `app_browser_main_tab` ORDER BY `number` ASC
)SQL", )SQL",
-1, -1,
SQLITE_PREPARE_NORMALIZE, SQLITE_PREPARE_NORMALIZE,
@ -81,9 +83,12 @@ Tab::Tab(
) )
); );
set_current_page( if (::sqlite3_column_int(statement, DB::APP_BROWSER_MAIN_TAB::CURRENT) == 1)
PAGE_NUMBER {
); set_current_page(
PAGE_NUMBER
);
}
} }
} }
@ -130,12 +135,18 @@ void Tab::shutdown()
R"SQL( R"SQL(
INSERT INTO `app_browser_main_tab` ( INSERT INTO `app_browser_main_tab` (
`time`, `time`,
`number`,
`current`,
`request` `request`
) VALUES ( ) VALUES (
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP,
'%d',
'%d',
'%s' '%s'
) )
)SQL", )SQL",
page_number,
page_number == get_current_page() ? 1 : 0,
tabPage->get_navigation_request_text() tabPage->get_navigation_request_text()
).c_str(), ).c_str(),
nullptr, nullptr,

2
src/app/browser/main/tab.hpp

@ -27,6 +27,8 @@ namespace app::browser::main
{ {
ID, ID,
TIME, TIME,
NUMBER,
CURRENT,
REQUEST REQUEST
}; };
}; };

Loading…
Cancel
Save