mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement separated restore action method
This commit is contained in:
parent
55524221ff
commit
817c946270
2 changed files with 49 additions and 42 deletions
|
|
@ -53,48 +53,7 @@ Tab::Tab(
|
||||||
[this]
|
[this]
|
||||||
{
|
{
|
||||||
// Restore session from DB
|
// Restore session from DB
|
||||||
sqlite3_stmt* statement;
|
restore();
|
||||||
|
|
||||||
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<const char*>(
|
|
||||||
::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
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -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<const char*>(
|
||||||
|
::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()
|
void Tab::save()
|
||||||
{
|
{
|
||||||
char * error; // @TODO
|
char * error; // @TODO
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,8 @@ namespace app::browser::main
|
||||||
const int & PAGE_NUMBER
|
const int & PAGE_NUMBER
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void restore();
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue