.
This commit is contained in:
@@ -12,8 +12,8 @@ cBook::cBook(const QString &szTitle, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_szTitle(szTitle),
|
||||
m_szSubtitle(""),
|
||||
m_szShortDescription(""),
|
||||
m_szDescription(""),
|
||||
m_lpShortDescription(0),
|
||||
m_lpDescription(0),
|
||||
m_szAuthor(""),
|
||||
m_startedAt(QDateTime(QDate(1, 1, 1))),
|
||||
m_finishedAt(QDateTime(QDate(1, 1, 1))),
|
||||
@@ -36,8 +36,15 @@ bool cBook::load()
|
||||
|
||||
setTitle(query.value("title").toString());
|
||||
setSubTitle(query.value("subtitle").toString());
|
||||
setShortDescription(query.value("shortDescription").toString());
|
||||
setDescription(query.value("description").toString());
|
||||
|
||||
cTextDocument* lpShortDescription = new cTextDocument;
|
||||
lpShortDescription->setHtml(uncompressText(query.value("shortDescription").toByteArray()));
|
||||
setShortDescription(lpShortDescription);
|
||||
|
||||
cTextDocument* lpDescription = new cTextDocument;
|
||||
lpDescription->setHtml(uncompressText(query.value("description").toByteArray()));
|
||||
setDescription(lpDescription);
|
||||
|
||||
setAuthor(query.value("author").toString());
|
||||
setStartedAt(query.value("startedAt").toDateTime());
|
||||
setFinishedAt(query.value("finishedAt").toDateTime());
|
||||
@@ -66,8 +73,15 @@ bool cBook::save()
|
||||
|
||||
query.bindValue(":title", title());
|
||||
query.bindValue(":subTitle", subTitle());
|
||||
query.bindValue(":shortDescription", shortDescription());
|
||||
query.bindValue(":description", description());
|
||||
|
||||
QByteArray ba;
|
||||
|
||||
ba = description()->toHtml().toUtf8();
|
||||
query.bindValue(":shortDescription", qCompress(ba));
|
||||
|
||||
ba = shortDescription()->toHtml().toUtf8();
|
||||
query.bindValue(":description", qCompress(ba));
|
||||
|
||||
query.bindValue(":author", author());
|
||||
query.bindValue(":startedAt", startedAt());
|
||||
query.bindValue(":finishedAt", finishedAt());
|
||||
@@ -102,24 +116,24 @@ QString cBook::subTitle()
|
||||
return(m_szSubtitle);
|
||||
}
|
||||
|
||||
void cBook::setShortDescription(const QString& szShortDescription)
|
||||
void cBook::setShortDescription(cTextDocument *lpShortDescription)
|
||||
{
|
||||
m_szShortDescription = szShortDescription;
|
||||
m_lpShortDescription = lpShortDescription;
|
||||
}
|
||||
|
||||
QString cBook::shortDescription()
|
||||
cTextDocument* cBook::shortDescription()
|
||||
{
|
||||
return(m_szShortDescription);
|
||||
return(m_lpShortDescription);
|
||||
}
|
||||
|
||||
void cBook::setDescription(const QString& szDescription)
|
||||
void cBook::setDescription(cTextDocument* lpDescription)
|
||||
{
|
||||
m_szDescription = szDescription;
|
||||
m_lpDescription = lpDescription;
|
||||
}
|
||||
|
||||
QString cBook::description()
|
||||
cTextDocument* cBook::description()
|
||||
{
|
||||
return(m_szDescription);
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
void cBook::setAuthor(const QString& szAuthor)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define CBOOK_H
|
||||
|
||||
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
@@ -14,41 +16,41 @@ class cBook : public QObject
|
||||
public:
|
||||
explicit cBook(const QString& szTitle = "", QObject *parent = nullptr);
|
||||
|
||||
bool load();
|
||||
bool save();
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
void setTitle(const QString& szTitle);
|
||||
QString title();
|
||||
void setTitle(const QString& szTitle);
|
||||
QString title();
|
||||
|
||||
void setSubTitle(const QString& szSubTitle);
|
||||
QString subTitle();
|
||||
void setSubTitle(const QString& szSubTitle);
|
||||
QString subTitle();
|
||||
|
||||
void setShortDescription(const QString& szShortDescription);
|
||||
QString shortDescription();
|
||||
void setShortDescription(cTextDocument* lpShortDescription);
|
||||
cTextDocument* shortDescription();
|
||||
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
cTextDocument* description();
|
||||
|
||||
void setAuthor(const QString& szAuthor);
|
||||
QString author();
|
||||
void setAuthor(const QString& szAuthor);
|
||||
QString author();
|
||||
|
||||
void setStartedAt(const QDateTime& startedAt);
|
||||
QDateTime startedAt();
|
||||
void setStartedAt(const QDateTime& startedAt);
|
||||
QDateTime startedAt();
|
||||
|
||||
void setFinishedAt(const QDateTime& finishedAt);
|
||||
QDateTime finishedAt();
|
||||
void setFinishedAt(const QDateTime& finishedAt);
|
||||
QDateTime finishedAt();
|
||||
|
||||
void setTargetDate(const QDateTime& targetDate);
|
||||
QDateTime targetDate();
|
||||
void setTargetDate(const QDateTime& targetDate);
|
||||
QDateTime targetDate();
|
||||
private:
|
||||
QString m_szTitle;
|
||||
QString m_szSubtitle;
|
||||
QString m_szShortDescription;
|
||||
QString m_szDescription;
|
||||
QString m_szAuthor;
|
||||
QDateTime m_startedAt;
|
||||
QDateTime m_finishedAt;
|
||||
QDateTime m_targetDate;
|
||||
QString m_szTitle;
|
||||
QString m_szSubtitle;
|
||||
cTextDocument* m_lpShortDescription;
|
||||
cTextDocument* m_lpDescription;
|
||||
QString m_szAuthor;
|
||||
QDateTime m_startedAt;
|
||||
QDateTime m_finishedAt;
|
||||
QDateTime m_targetDate;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cBook*)
|
||||
|
||||
+10
-7
@@ -13,7 +13,7 @@ cChapter::cChapter(qint32 iID, QObject *parent) :
|
||||
m_szName(""),
|
||||
m_iSortOrder(-1),
|
||||
m_szDescription(""),
|
||||
m_szFile("")
|
||||
m_lpText(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,14 +67,14 @@ QString cChapter::description()
|
||||
return(m_szDescription);
|
||||
}
|
||||
|
||||
void cChapter::setFile(const QString& szFile)
|
||||
void cChapter::setText(cTextDocument* lpText)
|
||||
{
|
||||
m_szFile = szFile;
|
||||
m_lpText = lpText;
|
||||
}
|
||||
|
||||
QString cChapter::file()
|
||||
cTextDocument* cChapter::text()
|
||||
{
|
||||
return(m_szFile);
|
||||
return(m_lpText);
|
||||
}
|
||||
|
||||
cChapter* cChapterList::add(const qint32& iID)
|
||||
@@ -105,7 +105,7 @@ bool cChapterList::load(cPartList* lpPartList)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, partID, name, sortOrder, description, file FROM chapter ORDER BY sortOrder;");
|
||||
query.prepare("SELECT id, partID, name, sortOrder, description, text FROM chapter ORDER BY sortOrder;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
@@ -120,7 +120,10 @@ bool cChapterList::load(cPartList* lpPartList)
|
||||
lpChapter->setName(query.value("name").toString());
|
||||
lpChapter->setSortOrder(query.value("sortOrder").toInt());
|
||||
lpChapter->setDescription(query.value("description").toString());
|
||||
lpChapter->setFile(query.value("file").toString());
|
||||
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
lpText->setHtml(uncompressText(query.value("text").toByteArray()));
|
||||
lpChapter->setText(lpText);
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
+5
-3
@@ -3,6 +3,8 @@
|
||||
|
||||
|
||||
#include "cpart.h"
|
||||
#include "ctextdocument.h"
|
||||
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
@@ -31,8 +33,8 @@ public:
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
|
||||
void setFile(const QString& szFile);
|
||||
QString file();
|
||||
void setText(cTextDocument* lpText);
|
||||
cTextDocument* text();
|
||||
|
||||
private:
|
||||
qint32 m_iID;
|
||||
@@ -40,7 +42,7 @@ private:
|
||||
QString m_szName;
|
||||
qint32 m_iSortOrder;
|
||||
QString m_szDescription;
|
||||
QString m_szFile;
|
||||
cTextDocument* m_lpText;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cChapter*)
|
||||
|
||||
+9
-6
@@ -33,7 +33,7 @@ cCharacter::cCharacter(qint32 iID, QObject *parent) :
|
||||
m_szSkin(QString("")),
|
||||
m_szSchool(QString("")),
|
||||
m_szJob(QString("")),
|
||||
m_szDescription(QString(""))
|
||||
m_lpDescription(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -310,14 +310,14 @@ QString cCharacter::job()
|
||||
return(m_szJob);
|
||||
}
|
||||
|
||||
void cCharacter::setDescription(const QString& szDescription)
|
||||
void cCharacter::setDescription(cTextDocument* lpDescription)
|
||||
{
|
||||
m_szDescription = szDescription;
|
||||
m_lpDescription = lpDescription;
|
||||
}
|
||||
|
||||
QString cCharacter::description()
|
||||
cTextDocument* cCharacter::description()
|
||||
{
|
||||
return(m_szDescription);
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
cCharacter* cCharacterList::add(const qint32& iID)
|
||||
@@ -380,7 +380,10 @@ bool cCharacterList::load()
|
||||
lpCharacter->setSkin(query.value("skin").toString());
|
||||
lpCharacter->setSchool(query.value("school").toString());
|
||||
lpCharacter->setJob(query.value("job").toString());
|
||||
lpCharacter->setDescription(query.value("description").toString());
|
||||
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
lpText->setHtml(uncompressText(query.value("description").toByteArray()));
|
||||
lpCharacter->setDescription(lpText);
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
+5
-3
@@ -2,6 +2,8 @@
|
||||
#define CCHARACTER_H
|
||||
|
||||
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
@@ -100,8 +102,8 @@ public:
|
||||
void setJob(const QString& szJob);
|
||||
QString job();
|
||||
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
cTextDocument* description();
|
||||
private:
|
||||
qint32 m_id;
|
||||
bool m_bMainCharacter;
|
||||
@@ -128,7 +130,7 @@ private:
|
||||
QString m_szSkin;
|
||||
QString m_szSchool;
|
||||
QString m_szJob;
|
||||
QString m_szDescription;
|
||||
cTextDocument* m_lpDescription;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
+14
@@ -1 +1,15 @@
|
||||
#include "common.h"
|
||||
|
||||
QString uncompressText(const QByteArray& compressed)
|
||||
{
|
||||
if(compressed.isNull() || compressed.isEmpty())
|
||||
return("");
|
||||
return(qUncompress(compressed));
|
||||
}
|
||||
|
||||
QByteArray compressText(const QString& uncompressed)
|
||||
{
|
||||
if(uncompressed.isNull() || uncompressed.isEmpty())
|
||||
return(QByteArray());
|
||||
return(qCompress(uncompressed.toUtf8()));
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -12,4 +15,7 @@
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __FUNCTION__ << ":"
|
||||
#endif
|
||||
|
||||
QString uncompressText(const QByteArray& compressed);
|
||||
QByteArray compressText(const QString& uncompressed);
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
@@ -12,7 +12,7 @@ cPart::cPart(qint32 iID, QObject *parent) :
|
||||
m_szName(""),
|
||||
m_iSortOrder(-1),
|
||||
m_szDescription(""),
|
||||
m_szFile("")
|
||||
m_lpText(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,14 +56,14 @@ QString cPart::description()
|
||||
return(m_szDescription);
|
||||
}
|
||||
|
||||
void cPart::setFile(const QString& szFile)
|
||||
void cPart::setText(cTextDocument* lpText)
|
||||
{
|
||||
m_szFile = szFile;
|
||||
m_lpText = lpText;
|
||||
}
|
||||
|
||||
QString cPart::file()
|
||||
cTextDocument* cPart::text()
|
||||
{
|
||||
return(m_szFile);
|
||||
return(m_lpText);
|
||||
}
|
||||
|
||||
cPart* cPartList::add(const qint32& iID)
|
||||
@@ -94,7 +94,7 @@ bool cPartList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, name, sortOrder, description, file FROM part ORDER BY sortOrder;");
|
||||
query.prepare("SELECT id, name, sortOrder, description, text FROM part ORDER BY sortOrder;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
@@ -107,7 +107,11 @@ bool cPartList::load()
|
||||
lpPart->setName(query.value("name").toString());
|
||||
lpPart->setSortOrder(query.value("sortOrder").toInt());
|
||||
lpPart->setDescription(query.value("description").toString());
|
||||
lpPart->setFile(query.value("file").toString());
|
||||
|
||||
QByteArray ba = query.value("text").toByteArray();
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
if(!ba.isEmpty())
|
||||
lpText->setHtml(qUncompress(ba));
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define CPART_H
|
||||
|
||||
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
@@ -26,15 +28,15 @@ public:
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
|
||||
void setFile(const QString& szFile);
|
||||
QString file();
|
||||
void setText(cTextDocument* lpText);
|
||||
cTextDocument* text();
|
||||
|
||||
private:
|
||||
qint32 m_iID;
|
||||
QString m_szName;
|
||||
qint32 m_iSortOrder;
|
||||
QString m_szDescription;
|
||||
QString m_szFile;
|
||||
cTextDocument* m_lpText;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cPart*)
|
||||
|
||||
+11
-7
@@ -14,7 +14,7 @@ cScene::cScene(qint32 iID, QObject *parent) :
|
||||
m_iSortOrder(-1),
|
||||
m_szDescription(""),
|
||||
m_state(STATE::STATE_unknown),
|
||||
m_szFile("")
|
||||
m_lpText(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -108,14 +108,14 @@ QDateTime cScene::targetDate()
|
||||
return(m_targetDate);
|
||||
}
|
||||
|
||||
void cScene::setFile(const QString& szFile)
|
||||
void cScene::setText(cTextDocument* lpText)
|
||||
{
|
||||
m_szFile = szFile;
|
||||
m_lpText = lpText;
|
||||
}
|
||||
|
||||
QString cScene::file()
|
||||
cTextDocument* cScene::text()
|
||||
{
|
||||
return(m_szFile);
|
||||
return(m_lpText);
|
||||
}
|
||||
|
||||
QString cScene::stateText()
|
||||
@@ -192,7 +192,7 @@ bool cSceneList::load(cChapterList* lpChapterList)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, chapterID, name, sortOrder, description, state, startedAt, finishedAt, targetDate, file FROM scene ORDER BY sortOrder;");
|
||||
query.prepare("SELECT id, chapterID, name, sortOrder, description, state, startedAt, finishedAt, targetDate, text FROM scene ORDER BY sortOrder;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
@@ -211,7 +211,11 @@ bool cSceneList::load(cChapterList* lpChapterList)
|
||||
lpScene->setStartedAt(query.value("startedAt").toDateTime());
|
||||
lpScene->setFinishedAt(query.value("finishedAt").toDateTime());
|
||||
lpScene->setTargetDate(query.value("targetDate").toDateTime());
|
||||
lpScene->setFile(query.value("file").toString());
|
||||
|
||||
QByteArray ba = query.value("text").toByteArray();
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
if(!ba.isEmpty())
|
||||
lpText->setHtml(qUncompress(ba));
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include "cchapter.h"
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
@@ -55,8 +56,8 @@ public:
|
||||
void setTargetDate(const QDateTime& targetDate);
|
||||
QDateTime targetDate();
|
||||
|
||||
void setFile(const QString& szFile);
|
||||
QString file();
|
||||
void setText(cTextDocument* lpText);
|
||||
cTextDocument* text();
|
||||
|
||||
QString stateText();
|
||||
QString stateText(STATE state) const;
|
||||
@@ -72,7 +73,7 @@ private:
|
||||
QDateTime m_startedAt;
|
||||
QDateTime m_finishedAt;
|
||||
QDateTime m_targetDate;
|
||||
QString m_szFile;
|
||||
cTextDocument* m_lpText;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cScene*)
|
||||
|
||||
+11
-11
@@ -129,8 +129,8 @@ bool cStoryBook::createDatabase()
|
||||
if(!createTable("CREATE TABLE book ( "
|
||||
" title TEXT, "
|
||||
" subTitle TEXT, "
|
||||
" shortDescription TEXT, "
|
||||
" description TEXT, "
|
||||
" shortDescription BLOB, "
|
||||
" description BLOB, "
|
||||
" author TEXT, "
|
||||
" startedAt DATETIME, "
|
||||
" finishedAt DATETIME, "
|
||||
@@ -143,9 +143,9 @@ bool cStoryBook::createDatabase()
|
||||
" UNIQUE, "
|
||||
" partID INTEGER REFERENCES part (id), "
|
||||
" name TEXT, "
|
||||
" [order] INTEGER, "
|
||||
" sortOrder INTEGER, "
|
||||
" description TEXT, "
|
||||
" file TEXT "
|
||||
" text BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -175,7 +175,7 @@ bool cStoryBook::createDatabase()
|
||||
" skin TEXT, "
|
||||
" school TEXT, "
|
||||
" job TEXT, "
|
||||
" description TEXT "
|
||||
" description BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -191,7 +191,7 @@ bool cStoryBook::createDatabase()
|
||||
" type TEXT, "
|
||||
" name TEXT, "
|
||||
" description TEXT, "
|
||||
" file TEXT "
|
||||
" image BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -216,7 +216,7 @@ bool cStoryBook::createDatabase()
|
||||
" name TEXT, "
|
||||
" [order] INTEGER, "
|
||||
" description TEXT, "
|
||||
" file TEXT "
|
||||
" text BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -226,7 +226,7 @@ bool cStoryBook::createDatabase()
|
||||
" name TEXT, "
|
||||
" location TEXT, "
|
||||
" type TEXT, "
|
||||
" description TEXT "
|
||||
" description BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -280,7 +280,7 @@ bool cStoryBook::createDatabase()
|
||||
" startedAt DATETIME, "
|
||||
" finishedAt DATETIME, "
|
||||
" targetDate DATETIME, "
|
||||
" file TEXT "
|
||||
" text BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -294,14 +294,14 @@ bool cStoryBook::createDatabase()
|
||||
if(!createTable("CREATE TABLE sceneObject ( "
|
||||
" sceneID INTEGER REFERENCES scene (id), "
|
||||
" objectID INTEGER REFERENCES object (id), "
|
||||
" description TEXT "
|
||||
" description BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
if(!createTable("CREATE TABLE scenePlace ( "
|
||||
" sceneID INTEGER REFERENCES scene (id), "
|
||||
" placeID INTEGER REFERENCES place (id), "
|
||||
" description TEXT "
|
||||
" description BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user