mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
implement clean method
This commit is contained in:
parent
d0cd98a5d8
commit
f0ff57e799
2 changed files with 76 additions and 37 deletions
|
|
@ -109,23 +109,63 @@ int Tab::restore()
|
||||||
return PREPARE_STATUS;
|
return PREPARE_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Tab::save()
|
void Tab::clean()
|
||||||
{
|
{
|
||||||
char * error; // @TODO
|
char * error; // @TODO
|
||||||
|
sqlite3_stmt * statement;
|
||||||
|
|
||||||
// Delete previous tab session
|
const int PREPARE_STATUS = ::sqlite3_prepare_v3(
|
||||||
const int EXEC_STATUS = ::sqlite3_exec(
|
|
||||||
db,
|
db,
|
||||||
R"SQL(
|
R"SQL(
|
||||||
DELETE FROM `app_browser_main_tab__session`
|
SELECT * FROM `app_browser_main_tab__session`
|
||||||
)SQL",
|
)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
|
||||||
|
);
|
||||||
|
|
||||||
|
// @TODO Delegate cleanup to the child components
|
||||||
|
|
||||||
|
// Delete record
|
||||||
|
::sqlite3_exec(
|
||||||
|
db,
|
||||||
|
Glib::ustring::sprintf(
|
||||||
|
R"SQL(
|
||||||
|
DELETE FROM `app_browser_main_tab__session` WHERE `id` = %d
|
||||||
|
)SQL",
|
||||||
|
APP_BROWSER_MAIN_TAB__SESSION_ID
|
||||||
|
).c_str(),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
&error
|
&error
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (EXEC_STATUS == SQLITE_OK)
|
::sqlite3_finalize(
|
||||||
|
statement
|
||||||
|
);
|
||||||
|
|
||||||
|
close_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tab::save()
|
||||||
{
|
{
|
||||||
|
char * error; // @TODO
|
||||||
|
|
||||||
|
// Delete previous data
|
||||||
|
clean();
|
||||||
|
|
||||||
// Save current tab session
|
// Save current tab session
|
||||||
for (int page_number = 0; page_number < get_n_pages(); page_number++)
|
for (int page_number = 0; page_number < get_n_pages(); page_number++)
|
||||||
{
|
{
|
||||||
|
|
@ -169,9 +209,6 @@ int Tab::save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXEC_STATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
void Tab::refresh(
|
void Tab::refresh(
|
||||||
const int & PAGE_NUMBER
|
const int & PAGE_NUMBER
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,9 @@ namespace app::browser::main
|
||||||
|
|
||||||
int restore();
|
int restore();
|
||||||
|
|
||||||
int save();
|
void clean();
|
||||||
|
|
||||||
|
void save();
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
Glib::ustring get_page_title(
|
Glib::ustring get_page_title(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue