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

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

@ -22,29 +22,33 @@ namespace app::browser::main
struct DB struct DB
{ {
enum APP_BROWSER_MAIN_TAB__SESSION struct APP_BROWSER_MAIN_TAB__SESSION
{ {
ID, enum
TIME, {
PAGE_NUMBER, ID,
IS_CURRENT, TIME,
LABEL_TEXT PAGE_NUMBER,
}; IS_CURRENT,
LABEL_TEXT
static int init( };
sqlite3 * db
); static int init(
sqlite3 * db
static int clear( );
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: private:

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

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

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

@ -37,31 +37,34 @@ namespace app::browser::main::tab
struct DB struct DB
{ {
enum APP_BROWSER_MAIN_TAB_PAGE__SESSION struct APP_BROWSER_MAIN_TAB_PAGE__SESSION
{ {
ID, enum
TIME, {
MIME, ID,
TITLE, TIME,
DESCRIPTION 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: private:

Loading…
Cancel
Save