-
This commit is contained in:
parent
e95956cca6
commit
202e5ab5c5
@ -4,6 +4,7 @@
|
|||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include "core/defs.h"
|
||||||
#include "core/databasefactory.h"
|
#include "core/databasefactory.h"
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +27,20 @@ DatabaseFactory *DatabaseFactory::getInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseFactory::assemblyDatabaseFilePath() {
|
void DatabaseFactory::assemblyDatabaseFilePath() {
|
||||||
// TODO: Fill m_databasePath with correct path (portable or non-portable).
|
// Fill m_databasePath with correct path (portable or non-portable).
|
||||||
|
QString home_path = QDir::homePath() + QDir::separator() +
|
||||||
|
APP_LOW_H_NAME;
|
||||||
|
QString home_path_file = home_path + QDir::separator() +
|
||||||
|
APP_DB_PATH + QDir::separator() + APP_DB_FILE;
|
||||||
|
QString app_path = qApp->applicationDirPath();
|
||||||
|
QString app_path_file = app_path + QDir::separator() + APP_DB_FILE;
|
||||||
|
|
||||||
|
if (QFile(app_path_file).exists()) {
|
||||||
|
m_databasePath = app_path_file;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_databasePath = home_path_file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DatabaseFactory::getDatabasePath() {
|
QString DatabaseFactory::getDatabasePath() {
|
||||||
@ -49,14 +63,15 @@ QSqlDatabase DatabaseFactory::initialize(const QString &connection_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Folders are created. Create new QSQLDatabase object.
|
// Folders are created. Create new QSQLDatabase object.
|
||||||
QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE", connection_name);
|
QSqlDatabase database = QSqlDatabase::addDatabase(DATABASE_DRIVER,
|
||||||
|
connection_name);
|
||||||
|
|
||||||
// Setup database file path.
|
// Setup database file path.
|
||||||
database.setDatabaseName(db_file.symLinkTarget());
|
database.setDatabaseName(db_file.symLinkTarget());
|
||||||
|
|
||||||
if (!database.open()) {
|
if (!database.open()) {
|
||||||
qFatal("Database was NOT opened. Delivered error message: '%s'",
|
qFatal("Database was NOT opened. Delivered error message: '%s'",
|
||||||
qPrintable(database.lastError().databaseText()));
|
qPrintable(database.lastError().text()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
database.exec("PRAGMA synchronous = OFF");
|
database.exec("PRAGMA synchronous = OFF");
|
||||||
@ -65,7 +80,8 @@ QSqlDatabase DatabaseFactory::initialize(const QString &connection_name) {
|
|||||||
database.exec("PRAGMA temp_store = MEMORY");
|
database.exec("PRAGMA temp_store = MEMORY");
|
||||||
//database.exec("PRAGMA foreign_keys = ON");
|
//database.exec("PRAGMA foreign_keys = ON");
|
||||||
|
|
||||||
QSqlQuery q = database.exec("SELECT value FROM rssg_information WHERE key = 'schema_version'");
|
// Sample query which checks for existence of tables.
|
||||||
|
QSqlQuery q = database.exec("SELECT value FROM Information WHERE key = 'schema_version'");
|
||||||
|
|
||||||
if (q.lastError().isValid()) {
|
if (q.lastError().isValid()) {
|
||||||
qWarning("Error occurred. Database is not initialized. Initializing now.");
|
qWarning("Error occurred. Database is not initialized. Initializing now.");
|
||||||
@ -102,13 +118,13 @@ QSqlDatabase DatabaseFactory::initialize(const QString &connection_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QSqlDatabase DatabaseFactory::addConnection(const QString &connection_name) {
|
QSqlDatabase DatabaseFactory::addConnection(const QString &connection_name) {
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", connection_name);
|
|
||||||
|
|
||||||
if (!m_initialized) {
|
if (!m_initialized) {
|
||||||
|
// Initialize database file and return connection if it is not
|
||||||
|
// initialized yet.
|
||||||
return initialize(connection_name);
|
return initialize(connection_name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return QSqlDatabase::addDatabase("QSQLITE", connection_name);
|
return QSqlDatabase::addDatabase(DATABASE_DRIVER, connection_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,14 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TEXT_TITLE_LIMIT 30
|
#define TEXT_TITLE_LIMIT 30
|
||||||
|
#define MAX_ZOOM_FACTOR 10.0
|
||||||
|
#define DATABASE_DRIVER "QSQLITE"
|
||||||
|
|
||||||
|
#define APP_DB_PATH "data/database/local"
|
||||||
|
#define APP_DB_FILE "database.db"
|
||||||
|
|
||||||
#define APP_CFG_PATH "data/config"
|
#define APP_CFG_PATH "data/config"
|
||||||
#define APP_CFG_WEB_PATH "data/web"
|
#define APP_CFG_WEB_PATH "data/database/web"
|
||||||
#define APP_CFG_FILE "config.ini"
|
#define APP_CFG_FILE "config.ini"
|
||||||
#define APP_CFG_GUI "gui"
|
#define APP_CFG_GUI "gui"
|
||||||
#define APP_CFG_GEN "main"
|
#define APP_CFG_GEN "main"
|
||||||
@ -38,7 +43,6 @@
|
|||||||
#define APP_CFG_BROWSER "browser"
|
#define APP_CFG_BROWSER "browser"
|
||||||
|
|
||||||
#define APP_HTML_MARKUP "styled_pattern.html"
|
#define APP_HTML_MARKUP "styled_pattern.html"
|
||||||
#define APP_DB_PATH "data/storage/database.db"
|
|
||||||
#define APP_PREFIX "@CMAKE_INSTALL_PREFIX@"
|
#define APP_PREFIX "@CMAKE_INSTALL_PREFIX@"
|
||||||
#define APP_REVISION "@APP_REVISION@"
|
#define APP_REVISION "@APP_REVISION@"
|
||||||
|
|
||||||
|
@ -226,14 +226,38 @@ void BaseWebView::paintEvent(QPaintEvent *event) {
|
|||||||
style()->drawControl(QStyle::CE_ShapedFrame, &style_option, &painter, this);
|
style()->drawControl(QStyle::CE_ShapedFrame, &style_option, &painter, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::increaseWebPageZoom() {
|
bool BaseWebView::increaseWebPageZoom() {
|
||||||
setZoomFactor(zoomFactor() + 0.1);
|
qreal new_factor = zoomFactor() + 0.1;
|
||||||
|
|
||||||
|
if (new_factor >= 0.0 && new_factor <= MAX_ZOOM_FACTOR) {
|
||||||
|
setZoomFactor(new_factor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::decreaseWebPageZoom() {
|
bool BaseWebView::decreaseWebPageZoom() {
|
||||||
setZoomFactor(zoomFactor() - 0.1);
|
qreal new_factor = zoomFactor() - 0.1;
|
||||||
|
|
||||||
|
if (new_factor >= 0.0 && new_factor <= MAX_ZOOM_FACTOR) {
|
||||||
|
setZoomFactor(new_factor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWebView::resetWebPageZoom() {
|
bool BaseWebView::resetWebPageZoom() {
|
||||||
setZoomFactor(1.0);
|
qreal new_factor = 1.0;
|
||||||
|
|
||||||
|
if (new_factor != zoomFactor()) {
|
||||||
|
setZoomFactor(new_factor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,9 @@ class BaseWebView : public QWebView {
|
|||||||
void newTabRequested();
|
void newTabRequested();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void increaseWebPageZoom();
|
bool increaseWebPageZoom();
|
||||||
void decreaseWebPageZoom();
|
bool decreaseWebPageZoom();
|
||||||
void resetWebPageZoom();
|
bool resetWebPageZoom();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// Executes if loading of any page is done.
|
// Executes if loading of any page is done.
|
||||||
|
@ -15,6 +15,18 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="TabWidget" name="m_tabWidget">
|
<widget class="TabWidget" name="m_tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
|
@ -12,6 +12,7 @@ TabBar::TabBar(QWidget *parent) : QTabBar(parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TabBar::~TabBar() {
|
TabBar::~TabBar() {
|
||||||
|
qDebug("Destroying TabBar instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabBar::setTabType(int index, const TabBar::TabType &type) {
|
void TabBar::setTabType(int index, const TabBar::TabType &type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user