.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
#include "cbook.h"
|
||||
|
||||
|
||||
cBook::cBook(const QString &szTitle) :
|
||||
m_szTitle(szTitle),
|
||||
m_szSubtitle(""),
|
||||
m_szShortDescription(""),
|
||||
m_szDescription(""),
|
||||
m_szAuthor(""),
|
||||
m_startedAt(QDate(1, 1, 1)),
|
||||
m_finishedAt(QDate(1, 1, 1)),
|
||||
m_targetDate(QDate(1, 1, 1))
|
||||
{
|
||||
}
|
||||
|
||||
void cBook::setTitle(const QString& szTitle)
|
||||
{
|
||||
m_szTitle = szTitle;
|
||||
}
|
||||
|
||||
QString cBook::title()
|
||||
{
|
||||
return(m_szTitle);
|
||||
}
|
||||
|
||||
void cBook::setSubTitle(const QString& szSubTitle)
|
||||
{
|
||||
m_szSubtitle = szSubTitle;
|
||||
}
|
||||
|
||||
QString cBook::subTitle()
|
||||
{
|
||||
return(m_szSubtitle);
|
||||
}
|
||||
|
||||
void cBook::setShortDescription(const QString& szShortDescription)
|
||||
{
|
||||
m_szShortDescription = szShortDescription;
|
||||
}
|
||||
|
||||
QString cBook::shortDescription()
|
||||
{
|
||||
return(m_szShortDescription);
|
||||
}
|
||||
|
||||
void cBook::setDescription(const QString& szDescription)
|
||||
{
|
||||
m_szDescription = szDescription;
|
||||
}
|
||||
|
||||
QString cBook::description()
|
||||
{
|
||||
return(m_szDescription);
|
||||
}
|
||||
|
||||
void cBook::setAuthor(const QString& szAuthor)
|
||||
{
|
||||
m_szAuthor = szAuthor;
|
||||
}
|
||||
|
||||
QString cBook::author()
|
||||
{
|
||||
return(m_szAuthor);
|
||||
}
|
||||
|
||||
void cBook::setStartedAt(const QDate& startedAt)
|
||||
{
|
||||
m_startedAt = startedAt;
|
||||
}
|
||||
|
||||
QDate cBook::startedAt()
|
||||
{
|
||||
return(m_startedAt);
|
||||
}
|
||||
|
||||
void cBook::setFinishedAt(const QDate& finishedAt)
|
||||
{
|
||||
m_finishedAt = finishedAt;
|
||||
|
||||
}
|
||||
QDate cBook::finishedAt()
|
||||
{
|
||||
return(m_finishedAt);
|
||||
}
|
||||
|
||||
void cBook::setTargetDate(const QDate& targetDate)
|
||||
{
|
||||
m_targetDate = targetDate;
|
||||
}
|
||||
|
||||
QDate cBook::targetDate()
|
||||
{
|
||||
return(m_targetDate);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef CBOOK_H
|
||||
#define CBOOK_H
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QDate>
|
||||
|
||||
|
||||
class cBook
|
||||
{
|
||||
public:
|
||||
cBook(const QString& szTitle = "");
|
||||
|
||||
void setTitle(const QString& szTitle);
|
||||
QString title();
|
||||
|
||||
void setSubTitle(const QString& szSubTitle);
|
||||
QString subTitle();
|
||||
|
||||
void setShortDescription(const QString& szShortDescription);
|
||||
QString shortDescription();
|
||||
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
|
||||
void setAuthor(const QString& szAuthor);
|
||||
QString author();
|
||||
|
||||
void setStartedAt(const QDate& startedAt);
|
||||
QDate startedAt();
|
||||
|
||||
void setFinishedAt(const QDate& finishedAt);
|
||||
QDate finishedAt();
|
||||
|
||||
void setTargetDate(const QDate& targetDate);
|
||||
QDate targetDate();
|
||||
private:
|
||||
QString m_szTitle;
|
||||
QString m_szSubtitle;
|
||||
QString m_szShortDescription;
|
||||
QString m_szDescription;
|
||||
QString m_szAuthor;
|
||||
QDate m_startedAt;
|
||||
QDate m_finishedAt;
|
||||
QDate m_targetDate;
|
||||
};
|
||||
|
||||
#endif // CBOOK_H
|
||||
+38
-31
@@ -15,9 +15,13 @@
|
||||
cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_bUpdatingTab(false)
|
||||
m_bUpdatingTab(false),
|
||||
m_lpStoryBook(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
initUI();
|
||||
createActions();
|
||||
|
||||
m_lpStoryBook = new cStoryBook("c:/temp/qtStoryWriter/DerAdler");
|
||||
|
||||
cStructureWindow* lpStructureWindow = new cStructureWindow(this);
|
||||
cWidget* lpWidget1 = new cWidget(lpStructureWindow);
|
||||
@@ -30,42 +34,31 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
|
||||
ui->m_lpMainTab->addTab((QWidget*)lpWidget1, "Structure");
|
||||
ui->m_lpMainTab->addTab((QWidget*)lpWidget2, "Bla");
|
||||
|
||||
// g_lpInputDocument = new cTextDocument(ui->m_lpInput);
|
||||
// g_lpOutputDocument = new cTextDocument(ui->m_lpOutput);
|
||||
|
||||
// ui->m_lpInput->setDocument(g_lpInputDocument);
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
{
|
||||
if(m_lpStoryBook)
|
||||
delete m_lpStoryBook;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//void cMainWindow::on_actionSave_triggered()
|
||||
//{
|
||||
//#ifdef __linux__
|
||||
// #ifdef WITH_ZIP
|
||||
// g_lpInputDocument->saveAs("/tmp/qtStoryWriter/documentText.zip", false);
|
||||
// cDocumentReader reader("/tmp/qtStoryWriter/documentText.zip", false);
|
||||
// #else
|
||||
// g_lpInputDocument->saveAs("/tmp/qtStoryWriter/documentText.xml", false);
|
||||
// cDocumentReader reader("/tmp/qtStoryWriter/documentText.xml", false);
|
||||
// #endif
|
||||
//#elif _WIN32
|
||||
// #ifdef WITH_ZIP
|
||||
// g_lpInputDocument->saveAs("C:/Temp/qtStoryWriter/documentText.zip", false);
|
||||
// cDocumentReader reader("C:/Temp/qtStoryWriter/documentText.zip", false);
|
||||
// #else
|
||||
// g_lpInputDocument->saveAs("C:/Temp/qtStoryWriter/documentText.xml", false);
|
||||
// cDocumentReader reader("C:/Temp/qtStoryWriter/documentText.xml", false);
|
||||
// #endif
|
||||
// g_lpOutputDocument = reader.readDocument();
|
||||
// ui->m_lpOutput->setDocument(g_lpOutputDocument);
|
||||
//#endif
|
||||
//}
|
||||
void cMainWindow::initUI()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
void cMainWindow::on_m_lpMainTab_currentChanged(int index)
|
||||
ui->m_lpMainToolBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void cMainWindow::createActions()
|
||||
{
|
||||
connect(ui->m_lpMainTab, SIGNAL(currentChanged(int)), this, SLOT(onMainTabCurrentChanged(int)));
|
||||
connect(ui->m_lpMainTab, SIGNAL(tabCloseRequested(int)), this,SLOT(onMainTabTabCloseRequested(int)));
|
||||
connect(ui->m_lpMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onMdiAreaSubWindowActivated(QMdiSubWindow*)));
|
||||
}
|
||||
|
||||
void cMainWindow::onMainTabCurrentChanged(int index)
|
||||
{
|
||||
if(m_bUpdatingTab)
|
||||
return;
|
||||
@@ -77,7 +70,21 @@ void cMainWindow::on_m_lpMainTab_currentChanged(int index)
|
||||
m_bUpdatingTab = false;
|
||||
}
|
||||
|
||||
void cMainWindow::on_m_lpMdiArea_subWindowActivated(QMdiSubWindow *arg1)
|
||||
void cMainWindow::onMainTabTabCloseRequested(int index)
|
||||
{
|
||||
if(m_bUpdatingTab)
|
||||
return;
|
||||
|
||||
m_bUpdatingTab = true;
|
||||
cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->currentWidget();
|
||||
QMdiSubWindow* lpWindow = lpWidget->window();
|
||||
ui->m_lpMainTab->removeTab(index);
|
||||
ui->m_lpMdiArea->removeSubWindow(lpWindow);
|
||||
delete(lpWidget);
|
||||
m_bUpdatingTab = false;
|
||||
}
|
||||
|
||||
void cMainWindow::onMdiAreaSubWindowActivated(QMdiSubWindow *arg1)
|
||||
{
|
||||
if(m_bUpdatingTab)
|
||||
return;
|
||||
|
||||
+10
-4
@@ -1,6 +1,9 @@
|
||||
#ifndef CMAINWINDOW_H
|
||||
#define CMAINWINDOW_H
|
||||
|
||||
|
||||
#include "cstorybook.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
@@ -18,14 +21,17 @@ public:
|
||||
~cMainWindow();
|
||||
|
||||
private slots:
|
||||
|
||||
void on_m_lpMainTab_currentChanged(int index);
|
||||
void on_m_lpMdiArea_subWindowActivated(QMdiSubWindow *arg1);
|
||||
void onMainTabCurrentChanged(int index);
|
||||
void onMainTabTabCloseRequested(int index);
|
||||
void onMdiAreaSubWindowActivated(QMdiSubWindow *arg1);
|
||||
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
|
||||
bool m_bUpdatingTab;
|
||||
cStoryBook* m_lpStoryBook;
|
||||
|
||||
void initUI();
|
||||
void createActions();
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+108
-43
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>569</width>
|
||||
<height>460</height>
|
||||
<width>869</width>
|
||||
<height>660</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -15,50 +15,115 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,99999">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="m_lpMainTab">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QToolBox" name="m_lpMainToolBox">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxOutline">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<height>481</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Outline</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QMdiArea" name="m_lpMdiArea">
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QMdiArea::SubWindowView</enum>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsMovable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::South</enum>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxCharacter">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<height>481</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Character</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxPlace">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<height>481</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Place</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxObject">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<height>481</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Object</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,99999">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="m_lpMainTab">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QMdiArea" name="m_lpMdiArea">
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QMdiArea::SubWindowView</enum>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabsMovable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -67,7 +132,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>569</width>
|
||||
<width>869</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
@@ -4,10 +4,8 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define myDebug qDebug()
|
||||
#else
|
||||
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
|
||||
#endif
|
||||
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
+305
-1
@@ -1,7 +1,311 @@
|
||||
#include "cstorybook.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
|
||||
cStoryBook::cStoryBook()
|
||||
cStoryBook::cStoryBook(const QString &szProjectPath) :
|
||||
m_szProjectPath(szProjectPath),
|
||||
m_bIsOpen(false)
|
||||
{
|
||||
if(!openDatabase())
|
||||
return;
|
||||
|
||||
if(!loadBook())
|
||||
return;
|
||||
|
||||
m_bIsOpen = true;
|
||||
}
|
||||
|
||||
cStoryBook::~cStoryBook()
|
||||
{
|
||||
if(m_db.isOpen())
|
||||
m_db.close();
|
||||
}
|
||||
|
||||
bool cStoryBook::openDatabase()
|
||||
{
|
||||
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
m_db.setHostName("localhost");
|
||||
m_db.setDatabaseName(QString("%1%2storyBook.project").arg(m_szProjectPath).arg(QDir::separator()));
|
||||
|
||||
if(!m_db.open())
|
||||
{
|
||||
myDebug << m_db.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("config"))
|
||||
createDatabase();
|
||||
else
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT value FROM config WHERE key = 'version';");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
m_db.close();
|
||||
return(false);
|
||||
}
|
||||
|
||||
query.first();
|
||||
if(query.value("value").toDouble() < 0.1)
|
||||
updateDatabase();
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::createTable(const QString& szSQL)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare(szSQL);
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << szSQL << "\n" << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::createDatabase()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
if(!createTable("CREATE TABLE config ( "
|
||||
" key STRING, "
|
||||
" value STRING "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
query.prepare("INSERT INTO config (key, value) VALUES (:key, :value);");
|
||||
query.bindValue(":key", "version");
|
||||
query.bindValue(":value", 0.1);
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!createTable("CREATE TABLE book ( "
|
||||
" title TEXT, "
|
||||
" subTitle TEXT, "
|
||||
" shortDescription TEXT, "
|
||||
" description TEXT, "
|
||||
" author TEXT, "
|
||||
" startedAt DATE, "
|
||||
" finishedAt DATE, "
|
||||
" targetDate DATE "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE chapter ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" partID INTEGER REFERENCES part (id), "
|
||||
" name TEXT, "
|
||||
" [order] INTEGER, "
|
||||
" description TEXT, "
|
||||
" file TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE character ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" mainCharacter BOOLEAN, "
|
||||
" gender BOOLEAN, "
|
||||
" title TEXT, "
|
||||
" firstName TEXT, "
|
||||
" middleName TEXT, "
|
||||
" lastName TEXT, "
|
||||
" height DOUBLE, "
|
||||
" weight DOUBLE, "
|
||||
" dateOfBirth DATE, "
|
||||
" placeOfBirth TEXT, "
|
||||
" dateOfDeath DATE, "
|
||||
" placeOfDeath TEXT, "
|
||||
" hairColor TEXT, "
|
||||
" hairCut TEXT, "
|
||||
" hairLength TEXT, "
|
||||
" figure TEXT, "
|
||||
" nature TEXT, "
|
||||
" spokenLanguages TEXT, "
|
||||
" skin TEXT, "
|
||||
" school TEXT, "
|
||||
" job TEXT, "
|
||||
" description TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE characterImage ( "
|
||||
" characterID INTEGER REFERENCES character (id), "
|
||||
" imageID INTEGER REFERENCES image (id) "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE image ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" type TEXT, "
|
||||
" name TEXT, "
|
||||
" description TEXT, "
|
||||
" file TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE object ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" name TEXT, "
|
||||
" type TEXT, "
|
||||
" description TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE objectImage ( "
|
||||
" objectID INTEGER REFERENCES object (id), "
|
||||
" imageID INTEGER REFERENCES image (id) "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE part ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" name TEXT, "
|
||||
" [order] INTEGER, "
|
||||
" description TEXT, "
|
||||
" file TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE place ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" name TEXT, "
|
||||
" location TEXT, "
|
||||
" type TEXT, "
|
||||
" description TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE placeImage ( "
|
||||
" placeID INTEGER REFERENCES place (id), "
|
||||
" imageID INTEGER REFERENCES image (id) "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE recherche ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" name TEXT, "
|
||||
" description TEXT, "
|
||||
" link TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE rechercheCharacter ( "
|
||||
" rechercheID INTEGER REFERENCES recherche (id), "
|
||||
" characterID INTEGER REFERENCES character (id) "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE rechercheImage ( "
|
||||
" rechercheID INTEGER REFERENCES recherche (id), "
|
||||
" imageID INTEGER REFERENCES image (id) "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE rechercheObject ( "
|
||||
" rechercheID INTEGER REFERENCES recherche (id), "
|
||||
" objectID INTEGER REFERENCES object (id) "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE recherchePlace ( "
|
||||
" rechercheID INTEGER REFERENCES recherche (id), "
|
||||
" placeID INTEGER REFERENCES place (id) "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE scene ( "
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" chapterID INTEGER REFERENCES chapter (id), "
|
||||
" name TEXT, "
|
||||
" [order] INTEGER, "
|
||||
" description TEXT, "
|
||||
" state INTEGER, "
|
||||
" startedAt DATE, "
|
||||
" finishedAt DATE, "
|
||||
" targetDate DATE, "
|
||||
" file TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE sceneCharacter ( "
|
||||
" sceneID INTEGER REFERENCES scene (id), "
|
||||
" characterID INTEGER REFERENCES character (id), "
|
||||
" description TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE sceneObject ( "
|
||||
" sceneID INTEGER REFERENCES scene (id), "
|
||||
" objectID INTEGER REFERENCES object (id), "
|
||||
" description TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE scenePlace ( "
|
||||
" sceneID INTEGER REFERENCES scene (id), "
|
||||
" placeID INTEGER REFERENCES place (id), "
|
||||
" description TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::updateDatabase()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::verify()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::loadBook()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT title, subTitle, shortDescription, description, author, startedAt, finishedAt, targetDate FROM book;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
query.first();
|
||||
|
||||
m_book.setTitle(query.value("title").toString());
|
||||
m_book.setSubTitle(query.value("subtitle").toString());
|
||||
m_book.setShortDescription(query.value("shortDescription").toString());
|
||||
m_book.setDescription(query.value("description").toString());
|
||||
m_book.setAuthor(query.value("author").toString());
|
||||
m_book.setStartedAt(query.value("startedAt").toDate());
|
||||
m_book.setFinishedAt(query.value("finishedAt").toDate());
|
||||
m_book.setTargetDate(query.value("targetDate").toDate());
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
+24
-2
@@ -2,10 +2,32 @@
|
||||
#define CSTORYBOOK_H
|
||||
|
||||
|
||||
#include "cbook.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <QSqlDatabase>
|
||||
|
||||
|
||||
class cStoryBook
|
||||
{
|
||||
public:
|
||||
cStoryBook();
|
||||
cStoryBook(const QString& szProjectPath);
|
||||
~cStoryBook();
|
||||
|
||||
bool openDatabase();
|
||||
bool verify();
|
||||
private:
|
||||
QString m_szProjectPath;
|
||||
bool m_bIsOpen;
|
||||
QSqlDatabase m_db;
|
||||
cBook m_book;
|
||||
|
||||
bool createDatabase();
|
||||
bool updateDatabase();
|
||||
bool createTable(const QString& szSQL);
|
||||
|
||||
bool loadBook();
|
||||
};
|
||||
|
||||
#endif // CSTORYBOOK_H
|
||||
#endif // CSTORYBOOK_H
|
||||
|
||||
+8
-4
@@ -4,7 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui xml
|
||||
QT += core gui xml sql
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
@@ -62,7 +62,8 @@ SOURCES += \
|
||||
ctextedit.cpp \
|
||||
cstructurewindow.cpp \
|
||||
cwidget.cpp \
|
||||
cstorybook.cpp
|
||||
cstorybook.cpp \
|
||||
cbook.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
@@ -73,13 +74,16 @@ HEADERS += \
|
||||
ctextedit.h \
|
||||
cstructurewindow.h \
|
||||
cwidget.h \
|
||||
cstorybook.h
|
||||
cstorybook.h \
|
||||
common.h \
|
||||
cbook.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
cstructurewindow.ui
|
||||
|
||||
DISTFILES +=
|
||||
DISTFILES += \
|
||||
storyBook.project
|
||||
|
||||
RESOURCES += \
|
||||
qtstorywriter.qrc
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user