Browse Source

implement multi-table struct model

CPP-GTK4
yggverse 2 months ago
parent
commit
b3635c77bc
  1. 19
      src/app/browser/main/tab.cpp
  2. 46
      src/app/browser/main/tab.hpp
  3. 10
      src/app/browser/main/tab/page.cpp
  4. 49
      src/app/browser/main/tab/page.hpp

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

@ -14,7 +14,7 @@ Tab::Tab( @@ -14,7 +14,7 @@ Tab::Tab(
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_UPDATE
) {
// Init database
DB::init(
DB::APP_BROWSER_MAIN_TAB__SESSION::init(
this->db = db
);
@ -94,7 +94,7 @@ int Tab::restore() @@ -94,7 +94,7 @@ int Tab::restore()
void Tab::clear() // @TODO menu action?
{
DB::clear(
DB::APP_BROWSER_MAIN_TAB__SESSION::clear(
db
);
@ -106,7 +106,7 @@ void Tab::save() @@ -106,7 +106,7 @@ void Tab::save()
char * error; // @TODO
// Delete previous data
DB::clear(
DB::APP_BROWSER_MAIN_TAB__SESSION::clear(
db
);
@ -117,7 +117,7 @@ void Tab::save() @@ -117,7 +117,7 @@ void Tab::save()
get_tabPage(
page_number
)->save(
DB::add(
DB::APP_BROWSER_MAIN_TAB__SESSION::add(
db,
page_number,
page_number == get_current_page() ? 1 : 0,
@ -331,9 +331,8 @@ tab::Page * Tab::get_tabPage( @@ -331,9 +331,8 @@ tab::Page * Tab::get_tabPage(
return TAB_PAGE;
}
// Database model
int Tab::DB::init(
// Database
int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::init(
sqlite3 * db
) {
char * error;
@ -356,7 +355,7 @@ int Tab::DB::init( @@ -356,7 +355,7 @@ int Tab::DB::init(
);
}
int Tab::DB::clear(
int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::clear(
sqlite3 * db
) {
char * error; // @TODO
@ -397,7 +396,7 @@ int Tab::DB::clear( @@ -397,7 +396,7 @@ int Tab::DB::clear(
);
// Delegate cleanup childs
tab::Page::DB::clear(
tab::Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::clear(
db,
APP_BROWSER_MAIN_TAB__SESSION_ID
);
@ -409,7 +408,7 @@ int Tab::DB::clear( @@ -409,7 +408,7 @@ int Tab::DB::clear(
);
}
sqlite3_int64 Tab::DB::add(
sqlite3_int64 Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::add(
sqlite3 * db,
const int & PAGE_NUMBER,
const bool & IS_CURRENT,

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

@ -22,29 +22,33 @@ namespace app::browser::main @@ -22,29 +22,33 @@ namespace app::browser::main
struct DB
{
enum APP_BROWSER_MAIN_TAB__SESSION
struct APP_BROWSER_MAIN_TAB__SESSION
{
ID,
TIME,
PAGE_NUMBER,
IS_CURRENT,
LABEL_TEXT
};
static int init(
sqlite3 * db
);
static int clear(
sqlite3 * db
);
enum
{
ID,
TIME,
PAGE_NUMBER,
IS_CURRENT,
LABEL_TEXT
};
static int init(
sqlite3 * db
);
static int clear(
sqlite3 * db
);
static sqlite3_int64 add(
sqlite3 * db,
const int & PAGE_NUMBER,
const bool & IS_CURRENT,
const Glib::ustring & LABEL_TEXT
);
static sqlite3_int64 add(
sqlite3 * db,
const int & PAGE_NUMBER,
const bool & IS_CURRENT,
const Glib::ustring & LABEL_TEXT
);
};
};
private:

10
src/app/browser/main/tab/page.cpp

@ -24,7 +24,7 @@ Page::Page( @@ -24,7 +24,7 @@ Page::Page(
action__refresh = ACTION__REFRESH;
// Init database
DB::init(
DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::init(
this->db = db
);
@ -74,7 +74,7 @@ int Page::save( @@ -74,7 +74,7 @@ int Page::save(
) {
// Delegate save action to child components
return pageNavigation->save(
Page::DB::add(
Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::add(
db,
DB__APP_BROWSER_MAIN_TAB__SESSION_ID,
mime,
@ -364,7 +364,7 @@ void Page::set_navbar_request_text( @@ -364,7 +364,7 @@ void Page::set_navbar_request_text(
}
// Database model
int Page::DB::init(
int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::init(
sqlite3 * db
) {
char * error;
@ -387,7 +387,7 @@ int Page::DB::init( @@ -387,7 +387,7 @@ int Page::DB::init(
);
}
int Page::DB::clear(
int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::clear(
sqlite3 * db,
const int & DB__APP_BROWSER_MAIN_TAB__SESSION_ID
) {
@ -440,7 +440,7 @@ int Page::DB::clear( @@ -440,7 +440,7 @@ int Page::DB::clear(
);
}
sqlite3_int64 Page::DB::add(
sqlite3_int64 Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::add(
sqlite3 * db,
const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB__SESSION_ID,
const Page::MIME & MIME,

49
src/app/browser/main/tab/page.hpp

@ -37,31 +37,34 @@ namespace app::browser::main::tab @@ -37,31 +37,34 @@ namespace app::browser::main::tab
struct DB
{
enum APP_BROWSER_MAIN_TAB_PAGE__SESSION
struct APP_BROWSER_MAIN_TAB_PAGE__SESSION
{
ID,
TIME,
MIME,
TITLE,
DESCRIPTION
enum
{
ID,
TIME,
MIME,
TITLE,
DESCRIPTION
};
static int init(
sqlite3 * db
);
static int clear(
sqlite3 * db,
const int & DB__APP_BROWSER_MAIN_TAB__SESSION_ID
);
static sqlite3_int64 add(
sqlite3 * db,
const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB__SESSION_ID,
const Page::MIME & MIME,
const Glib::ustring & TITLE,
const Glib::ustring & DESCRIPTION
);
};
static int init(
sqlite3 * db
);
static int clear(
sqlite3 * db,
const int & DB__APP_BROWSER_MAIN_TAB__SESSION_ID
);
static sqlite3_int64 add(
sqlite3 * db,
const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB__SESSION_ID,
const Page::MIME & MIME,
const Glib::ustring & TITLE,
const Glib::ustring & DESCRIPTION
);
};
private:

Loading…
Cancel
Save