Browse Source

implement clean method

CPP-GTK4
yggverse 2 months ago
parent
commit
f0ff57e799
  1. 53
      src/app/browser/main/tab.cpp
  2. 4
      src/app/browser/main/tab.hpp

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

@ -109,23 +109,63 @@ int Tab::restore() @@ -109,23 +109,63 @@ int Tab::restore()
return PREPARE_STATUS;
}
int Tab::save()
void Tab::clean()
{
char * error; // @TODO
sqlite3_stmt * statement;
const int PREPARE_STATUS = ::sqlite3_prepare_v3(
db,
R"SQL(
SELECT * FROM `app_browser_main_tab__session`
)SQL",
-1,
SQLITE_PREPARE_NORMALIZE,
&statement,
nullptr
);
if (PREPARE_STATUS == SQLITE_OK)
{
while (::sqlite3_step(statement) == SQLITE_ROW)
{
const int APP_BROWSER_MAIN_TAB__SESSION_ID = ::sqlite3_column_int(
statement,
DB::APP_BROWSER_MAIN_TAB__SESSION::ID
);
// Delete previous tab session
const int EXEC_STATUS = ::sqlite3_exec(
// @TODO Delegate cleanup to the child components
// Delete record
::sqlite3_exec(
db,
Glib::ustring::sprintf(
R"SQL(
DELETE FROM `app_browser_main_tab__session`
DELETE FROM `app_browser_main_tab__session` WHERE `id` = %d
)SQL",
APP_BROWSER_MAIN_TAB__SESSION_ID
).c_str(),
nullptr,
nullptr,
&error
);
}
}
::sqlite3_finalize(
statement
);
if (EXEC_STATUS == SQLITE_OK)
close_all();
}
void Tab::save()
{
char * error; // @TODO
// Delete previous data
clean();
// Save current tab session
for (int page_number = 0; page_number < get_n_pages(); page_number++)
{
@ -169,9 +209,6 @@ int Tab::save() @@ -169,9 +209,6 @@ int Tab::save()
}
}
return EXEC_STATUS;
}
// Actions
void Tab::refresh(
const int & PAGE_NUMBER

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

@ -99,7 +99,9 @@ namespace app::browser::main @@ -99,7 +99,9 @@ namespace app::browser::main
int restore();
int save();
void clean();
void save();
// Getters
Glib::ustring get_page_title(

Loading…
Cancel
Save