mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-12 13:41:34 +00:00
draft page session db features
This commit is contained in:
parent
b1f2a1b893
commit
e78b7e5487
@ -71,7 +71,7 @@ int Tab::restore()
|
|||||||
sqlite3_stmt* statement;
|
sqlite3_stmt* statement;
|
||||||
|
|
||||||
const int PREPARE_STATUS = ::sqlite3_prepare_v3(
|
const int PREPARE_STATUS = ::sqlite3_prepare_v3(
|
||||||
this->db,
|
db,
|
||||||
R"SQL(
|
R"SQL(
|
||||||
SELECT * FROM `app_browser_main_tab__session` ORDER BY `page_number` ASC
|
SELECT * FROM `app_browser_main_tab__session` ORDER BY `page_number` ASC
|
||||||
)SQL",
|
)SQL",
|
||||||
@ -161,7 +161,11 @@ int Tab::save()
|
|||||||
// Delegate save action to the page component
|
// Delegate save action to the page component
|
||||||
get_tabPage(
|
get_tabPage(
|
||||||
page_number
|
page_number
|
||||||
)->save();
|
)->save(
|
||||||
|
::sqlite3_last_insert_rowid(
|
||||||
|
db
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +202,7 @@ int Tab::append(
|
|||||||
const bool & IS_CURRENT
|
const bool & IS_CURRENT
|
||||||
) {
|
) {
|
||||||
const auto TAB_PAGE = new tab::Page(
|
const auto TAB_PAGE = new tab::Page(
|
||||||
|
db,
|
||||||
tab::Page::MIME::UNDEFINED,
|
tab::Page::MIME::UNDEFINED,
|
||||||
LABEL_TEXT,
|
LABEL_TEXT,
|
||||||
"", // @TODO restore feature
|
"", // @TODO restore feature
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
using namespace app::browser::main::tab;
|
using namespace app::browser::main::tab;
|
||||||
|
|
||||||
Page::Page(
|
Page::Page(
|
||||||
|
sqlite3 * db,
|
||||||
const MIME & MIME,
|
const MIME & MIME,
|
||||||
const Glib::ustring & TITLE,
|
const Glib::ustring & TITLE,
|
||||||
const Glib::ustring & DESCRIPTION,
|
const Glib::ustring & DESCRIPTION,
|
||||||
@ -22,6 +23,28 @@ Page::Page(
|
|||||||
// Init actions
|
// Init actions
|
||||||
action__refresh = ACTION__REFRESH;
|
action__refresh = ACTION__REFRESH;
|
||||||
|
|
||||||
|
// Init database
|
||||||
|
this->db = db;
|
||||||
|
|
||||||
|
char * error;
|
||||||
|
|
||||||
|
::sqlite3_exec(
|
||||||
|
db,
|
||||||
|
R"SQL(
|
||||||
|
CREATE TABLE IF NOT EXISTS `app_browser_main_tab_page__session`
|
||||||
|
(
|
||||||
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `app_browser_main_tab__session_id` INTEGER NOT NULL,
|
||||||
|
`time` INTEGER NOT NULL,
|
||||||
|
`mime` INTEGER NOT NULL,
|
||||||
|
`title` VARCHAR(1024) NOT NULL,
|
||||||
|
`description` VARCHAR(1024) NOT NULL
|
||||||
|
)
|
||||||
|
)SQL",
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
&error
|
||||||
|
);
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
pageNavigation = Gtk::make_managed<page::Navigation>(
|
pageNavigation = Gtk::make_managed<page::Navigation>(
|
||||||
ACTION__REFRESH,
|
ACTION__REFRESH,
|
||||||
@ -63,9 +86,46 @@ void Page::refresh()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Page::save()
|
int Page::save(
|
||||||
{
|
const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB__SESSION_ID
|
||||||
pageNavigation->save();
|
) {
|
||||||
|
char * error; // @TODO
|
||||||
|
|
||||||
|
::sqlite3_exec(
|
||||||
|
db,
|
||||||
|
Glib::ustring::sprintf(
|
||||||
|
R"SQL(
|
||||||
|
INSERT INTO `app_browser_main_tab_page__session` (
|
||||||
|
`app_browser_main_tab__session_id`,
|
||||||
|
`time`,
|
||||||
|
`mime`,
|
||||||
|
`title`,
|
||||||
|
`description`
|
||||||
|
) VALUES (
|
||||||
|
'%d',
|
||||||
|
CURRENT_TIMESTAMP,
|
||||||
|
'%d',
|
||||||
|
'%d',
|
||||||
|
'%s',
|
||||||
|
'%s'
|
||||||
|
)
|
||||||
|
)SQL",
|
||||||
|
DB__APP_BROWSER_MAIN_TAB__SESSION_ID,
|
||||||
|
mime,
|
||||||
|
title,
|
||||||
|
description
|
||||||
|
).c_str(),
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
&error
|
||||||
|
); // @TODO auto-clean old records somewhere
|
||||||
|
|
||||||
|
// Delegate save action to child components
|
||||||
|
pageNavigation->save(
|
||||||
|
::sqlite3_last_insert_rowid(
|
||||||
|
db
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return 1; // @TODO SQL
|
return 1; // @TODO SQL
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
#include <gtkmm/object.h>
|
#include <gtkmm/object.h>
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
namespace app::browser::main::tab
|
namespace app::browser::main::tab
|
||||||
{
|
{
|
||||||
@ -45,6 +46,21 @@ namespace app::browser::main::tab
|
|||||||
// Actions
|
// Actions
|
||||||
Glib::RefPtr<Gio::SimpleAction> action__refresh;
|
Glib::RefPtr<Gio::SimpleAction> action__refresh;
|
||||||
|
|
||||||
|
// Database
|
||||||
|
sqlite3 * db;
|
||||||
|
|
||||||
|
struct DB
|
||||||
|
{
|
||||||
|
enum APP_BROWSER_MAIN_TAB_PAGE__DATA
|
||||||
|
{
|
||||||
|
ID,
|
||||||
|
TIME,
|
||||||
|
MIME,
|
||||||
|
TITLE,
|
||||||
|
DESCRIPTION
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// Socket
|
// Socket
|
||||||
char buffer[0xfffff]; // 1Mb
|
char buffer[0xfffff]; // 1Mb
|
||||||
|
|
||||||
@ -58,6 +74,7 @@ namespace app::browser::main::tab
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Page(
|
Page(
|
||||||
|
sqlite3 * db,
|
||||||
const MIME & MIME,
|
const MIME & MIME,
|
||||||
const Glib::ustring & TITLE,
|
const Glib::ustring & TITLE,
|
||||||
const Glib::ustring & DESCRIPTION,
|
const Glib::ustring & DESCRIPTION,
|
||||||
@ -70,7 +87,9 @@ namespace app::browser::main::tab
|
|||||||
// Actions
|
// Actions
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
int save();
|
int save(
|
||||||
|
const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB__SESSION_ID
|
||||||
|
);
|
||||||
|
|
||||||
void update(
|
void update(
|
||||||
const MIME & MIME,
|
const MIME & MIME,
|
||||||
|
@ -101,8 +101,9 @@ void Navigation::refresh(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Navigation::save()
|
int Navigation::save(
|
||||||
{
|
const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB_PAGE__SESSION_ID
|
||||||
|
) {
|
||||||
navigationRequest->save();
|
navigationRequest->save();
|
||||||
|
|
||||||
return 1; // @TODO SQL
|
return 1; // @TODO SQL
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
#include <gtkmm/object.h>
|
#include <gtkmm/object.h>
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
namespace app::browser::main::tab::page
|
namespace app::browser::main::tab::page
|
||||||
{
|
{
|
||||||
@ -45,7 +46,9 @@ namespace app::browser::main::tab::page
|
|||||||
const double & PROGRESS_FRACTION
|
const double & PROGRESS_FRACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
int save();
|
int save(
|
||||||
|
const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB__SESSION_ID
|
||||||
|
);
|
||||||
|
|
||||||
void history_add(
|
void history_add(
|
||||||
const Glib::ustring & REQUEST,
|
const Glib::ustring & REQUEST,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user