This commit is contained in:
Herwig Birke
2018-04-17 15:52:26 +02:00
parent 223eebb0e6
commit 397620208f
15 changed files with 919 additions and 51 deletions
+77 -9
View File
@@ -1,4 +1,11 @@
#include "cbook.h"
#include "common.h"
#include <QSqlQuery>
#include <QSqlError>
#include <QString>
#include <QVariant>
cBook::cBook(const QString &szTitle) :
@@ -7,12 +14,73 @@ cBook::cBook(const QString &szTitle) :
m_szShortDescription(""),
m_szDescription(""),
m_szAuthor(""),
m_startedAt(QDate(1, 1, 1)),
m_finishedAt(QDate(1, 1, 1)),
m_targetDate(QDate(1, 1, 1))
m_startedAt(QDateTime(QDate(1, 1, 1))),
m_finishedAt(QDateTime(QDate(1, 1, 1))),
m_targetDate(QDateTime(QDate(1, 1, 1)))
{
}
bool cBook::load()
{
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();
setTitle(query.value("title").toString());
setSubTitle(query.value("subtitle").toString());
setShortDescription(query.value("shortDescription").toString());
setDescription(query.value("description").toString());
setAuthor(query.value("author").toString());
setStartedAt(query.value("startedAt").toDateTime());
setFinishedAt(query.value("finishedAt").toDateTime());
setTargetDate(query.value("targetDate").toDateTime());
return(true);
}
bool cBook::save()
{
QSqlQuery query;
query.prepare("SELECT COUNT(1) CNT FROM book;");
if(!query.exec())
{
myDebug << query.lastError().text();
return(false);
}
query.first();
if(query.value("CNT").toInt() == 1)
query.prepare("UPDATE book SET title = :title, subTitle = :subTitle, shortDescription = :shortDescription, description = :description, author = :author, startedAt = :startedAt, finishedAt = :finishedAt, targetDate = :targetDate;");
else
query.prepare("INSERT INTO book (title, subTitle, shortDesctiption, description, author, startedAt, finishedAt, targetDate) VALUES (:title, :subTitle, :shortDesctiption, :description, :author, :startedAt, :finishedAt, :targetDate);");
query.bindValue(":title", title());
query.bindValue(":subTitle", subTitle());
query.bindValue(":shortDescription", shortDescription());
query.bindValue(":description", description());
query.bindValue(":author", author());
query.bindValue(":startedAt", startedAt());
query.bindValue(":finishedAt", finishedAt());
query.bindValue(":targetDate", targetDate());
if(!query.exec())
{
myDebug << query.lastError().text();
return(false);
}
return(true);
}
void cBook::setTitle(const QString& szTitle)
{
m_szTitle = szTitle;
@@ -63,32 +131,32 @@ QString cBook::author()
return(m_szAuthor);
}
void cBook::setStartedAt(const QDate& startedAt)
void cBook::setStartedAt(const QDateTime& startedAt)
{
m_startedAt = startedAt;
}
QDate cBook::startedAt()
QDateTime cBook::startedAt()
{
return(m_startedAt);
}
void cBook::setFinishedAt(const QDate& finishedAt)
void cBook::setFinishedAt(const QDateTime& finishedAt)
{
m_finishedAt = finishedAt;
}
QDate cBook::finishedAt()
QDateTime cBook::finishedAt()
{
return(m_finishedAt);
}
void cBook::setTargetDate(const QDate& targetDate)
void cBook::setTargetDate(const QDateTime& targetDate)
{
m_targetDate = targetDate;
}
QDate cBook::targetDate()
QDateTime cBook::targetDate()
{
return(m_targetDate);
}
+13 -10
View File
@@ -3,7 +3,7 @@
#include <QString>
#include <QDate>
#include <QDateTime>
class cBook
@@ -11,6 +11,9 @@ class cBook
public:
cBook(const QString& szTitle = "");
bool load();
bool save();
void setTitle(const QString& szTitle);
QString title();
@@ -26,23 +29,23 @@ public:
void setAuthor(const QString& szAuthor);
QString author();
void setStartedAt(const QDate& startedAt);
QDate startedAt();
void setStartedAt(const QDateTime& startedAt);
QDateTime startedAt();
void setFinishedAt(const QDate& finishedAt);
QDate finishedAt();
void setFinishedAt(const QDateTime& finishedAt);
QDateTime finishedAt();
void setTargetDate(const QDate& targetDate);
QDate targetDate();
void setTargetDate(const QDateTime& targetDate);
QDateTime 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;
QDateTime m_startedAt;
QDateTime m_finishedAt;
QDateTime m_targetDate;
};
#endif // CBOOK_H
+131
View File
@@ -0,0 +1,131 @@
#include "cchapter.h"
#include "common.h"
#include <QSqlQuery>
#include <QSqlError>
cChapter::cChapter(qint32 iID) :
m_iID(iID),
m_lpPart(0),
m_szName(""),
m_iSortOrder(-1),
m_szDescription(""),
m_szFile("")
{
}
void cChapter::setID(const qint32& iID)
{
m_iID = iID;
}
qint32 cChapter::id()
{
return(m_iID);
}
void cChapter::setPart(cPart* lpPart)
{
m_lpPart = lpPart;
}
cPart* cChapter::part()
{
return(m_lpPart);
}
void cChapter::setName(const QString& szName)
{
m_szName = szName;
}
QString cChapter::name()
{
return(m_szName);
}
void cChapter::setSortOrder(const qint32& iSortOrder)
{
m_iSortOrder = iSortOrder;
}
qint32 cChapter::sortOrder()
{
return(m_iSortOrder);
}
void cChapter::setDescription(const QString& szDescription)
{
m_szDescription = szDescription;
}
QString cChapter::description()
{
return(m_szDescription);
}
void cChapter::setFile(const QString& szFile)
{
m_szFile = szFile;
}
QString cChapter::file()
{
return(m_szFile);
}
cChapter* cChapterList::add(const qint32& iID)
{
cChapter* lpChapter = find(iID);
if(!lpChapter)
{
lpChapter = new cChapter(iID);
append(lpChapter);
}
return(lpChapter);
}
cChapter* cChapterList::find(const qint32& iID)
{
for(int x = 0;x < count();x++)
{
if(at(x)->id() == iID)
return(at(x));
}
return(0);
}
bool cChapterList::load(cPartList* lpPartList)
{
QSqlQuery query;
query.prepare("SELECT id, partID, name, sortOrder, description, file FROM chapter;");
if(!query.exec())
{
myDebug << query.lastError().text();
return(false);
}
while(query.next())
{
cChapter* lpChapter = add(query.value("id").toInt());
lpChapter->setPart(lpPartList->find(query.value("partID").toInt()));
lpChapter->setName(query.value("name").toString());
lpChapter->setSortOrder(query.value("sortOrder").toInt());
lpChapter->setDescription(query.value("description").toString());
lpChapter->setFile(query.value("file").toString());
}
return(true);
}
bool cChapterList::save()
{
return(true);
}
+56
View File
@@ -0,0 +1,56 @@
#ifndef CCHAPTER_H
#define CCHAPTER_H
#include "cpart.h"
#include <QMetaType>
#include <QList>
#include <QString>
class cChapter
{
public:
cChapter(qint32 iID = -1);
void setID(const qint32& iID);
qint32 id();
void setPart(cPart *lpPart);
cPart* part();
void setName(const QString& szName);
QString name();
void setSortOrder(const qint32& iSortOrder);
qint32 sortOrder();
void setDescription(const QString& szDescription);
QString description();
void setFile(const QString& szFile);
QString file();
private:
qint32 m_iID;
cPart* m_lpPart;
QString m_szName;
qint32 m_iSortOrder;
QString m_szDescription;
QString m_szFile;
};
Q_DECLARE_METATYPE(cChapter*)
class cChapterList : public QList<cChapter*>
{
public:
bool load(cPartList *lpPartList);
bool save();
cChapter* add(const qint32& iID);
cChapter* find(const qint32& iID);
};
#endif // CCHAPTER_H
+60 -1
View File
@@ -11,9 +11,12 @@
#include <QTextBlockFormat>
#include <QTextCharFormat>
#include <QSettings>
cMainWindow::cMainWindow(QWidget *parent) :
QMainWindow(parent),
m_lpOutlineModel(0),
ui(new Ui::cMainWindow),
m_bUpdatingTab(false),
m_lpStoryBook(0)
@@ -21,7 +24,10 @@ cMainWindow::cMainWindow(QWidget *parent) :
initUI();
createActions();
m_lpStoryBook = new cStoryBook("c:/temp/qtStoryWriter/DerAdler");
m_lpStoryBook = new cStoryBook("c:/temp/qtStoryWriter/DerAdler");
m_lpStoryBook->fillOutlineList(m_lpOutlineModel);
updateWindowTitle();
cStructureWindow* lpStructureWindow = new cStructureWindow(this);
cWidget* lpWidget1 = new cWidget(lpStructureWindow);
@@ -44,10 +50,46 @@ cMainWindow::~cMainWindow()
delete ui;
}
void cMainWindow::closeEvent(QCloseEvent *event)
{
QSettings settings;
settings.setValue("main/width", QVariant::fromValue(size().width()));
settings.setValue("main/height", QVariant::fromValue(size().height()));
settings.setValue("main/x", QVariant::fromValue(x()));
settings.setValue("main/y", QVariant::fromValue(y()));
settings.setValue("main/splitter1", QVariant::fromValue(ui->m_lpMainSplitter->sizes()[0]));
settings.setValue("main/splitter2", QVariant::fromValue(ui->m_lpMainSplitter->sizes()[1]));
if(this->isMaximized())
settings.setValue("main/maximized", QVariant::fromValue(true));
else
settings.setValue("main/maximized", QVariant::fromValue(false));
event->accept();
}
void cMainWindow::initUI()
{
ui->setupUi(this);
m_lpOutlineModel = new QStandardItemModel(0, 1);
ui->m_lpOutline->setModel(m_lpOutlineModel);
QSettings settings;
qint16 iX = settings.value("main/x", QVariant::fromValue(-1)).toInt();
qint16 iY = settings.value("main/y", QVariant::fromValue(-1)).toInt();
qint16 iWidth = settings.value("main/width", QVariant::fromValue(-1)).toInt();
qint16 iHeight = settings.value("main/height", QVariant::fromValue(-1)).toInt();
qint16 iSplitter1 = settings.value("main/splitter1", QVariant::fromValue(-1)).toInt();
qint16 iSplitter2 = settings.value("main/splitter2", QVariant::fromValue(-1)).toInt();
if(iWidth != -1 && iHeight != -1)
resize(iWidth, iHeight);
if(iX != -1 && iY != -1)
move(iX, iY);
if(iSplitter1 != -1 && iSplitter2 != -1)
ui->m_lpMainSplitter->setSizes(QList<int>() << iSplitter1 << iSplitter2);
ui->m_lpMainToolBox->setCurrentIndex(0);
}
@@ -58,6 +100,23 @@ void cMainWindow::createActions()
connect(ui->m_lpMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onMdiAreaSubWindowActivated(QMdiSubWindow*)));
}
void cMainWindow::updateWindowTitle()
{
if(!m_lpStoryBook)
{
setWindowTitle("qtStoryWriter");
return;
}
QString szTitle = m_lpStoryBook->title();
QString szAuthor = m_lpStoryBook->author();
if(szAuthor.isEmpty())
setWindowTitle(QString("%1 - qtStoryWriter").arg(szTitle));
else
setWindowTitle(QString("%1 by %2 - qtStoryWriter").arg(szTitle).arg(szAuthor));
}
void cMainWindow::onMainTabCurrentChanged(int index)
{
if(m_bUpdatingTab)
+10
View File
@@ -7,6 +7,10 @@
#include <QMainWindow>
#include <QMdiSubWindow>
#include <QStandardItemModel>
#include <QCloseEvent>
namespace Ui {
class cMainWindow;
@@ -20,6 +24,8 @@ public:
explicit cMainWindow(QWidget *parent = 0);
~cMainWindow();
void updateWindowTitle();
private slots:
void onMainTabCurrentChanged(int index);
void onMainTabTabCloseRequested(int index);
@@ -27,11 +33,15 @@ private slots:
private:
Ui::cMainWindow* ui;
QStandardItemModel* m_lpOutlineModel;
bool m_bUpdatingTab;
cStoryBook* m_lpStoryBook;
void initUI();
void createActions();
protected:
void closeEvent(QCloseEvent *event);
};
#endif // CMAINWINDOW_H
+19 -8
View File
@@ -11,31 +11,42 @@
</rect>
</property>
<property name="windowTitle">
<string>cMainWindow</string>
<string>qtStoryBook</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<widget class="QSplitter" name="m_lpMainSplitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QToolBox" name="m_lpMainToolBox">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="m_lpMainToolBoxOutline">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>481</height>
<width>89</width>
<height>460</height>
</rect>
</property>
<attribute name="label">
<string>Outline</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpOutline"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_lpMainToolBoxCharacter">
<property name="geometry">
@@ -43,7 +54,7 @@
<x>0</x>
<y>0</y>
<width>69</width>
<height>481</height>
<height>477</height>
</rect>
</property>
<attribute name="label">
@@ -56,7 +67,7 @@
<x>0</x>
<y>0</y>
<width>69</width>
<height>481</height>
<height>477</height>
</rect>
</property>
<attribute name="label">
@@ -69,7 +80,7 @@
<x>0</x>
<y>0</y>
<width>69</width>
<height>481</height>
<height>477</height>
</rect>
</property>
<attribute name="label">
+118
View File
@@ -0,0 +1,118 @@
#include "cpart.h"
#include "common.h"
#include <QSqlQuery>
#include <QSqlError>
cPart::cPart(qint32 iID) :
m_iID(iID),
m_szName(""),
m_iSortOrder(-1),
m_szDescription(""),
m_szFile("")
{
}
void cPart::setID(const qint32& iID)
{
m_iID = iID;
}
qint32 cPart::id()
{
return(m_iID);
}
void cPart::setName(const QString& szName)
{
m_szName = szName;
}
QString cPart::name()
{
return(m_szName);
}
void cPart::setSortOrder(const qint32& iSortOrder)
{
m_iSortOrder = iSortOrder;
}
qint32 cPart::sortOrder()
{
return(m_iSortOrder);
}
void cPart::setDescription(const QString& szDescription)
{
m_szDescription = szDescription;
}
QString cPart::description()
{
return(m_szDescription);
}
void cPart::setFile(const QString& szFile)
{
m_szFile = szFile;
}
QString cPart::file()
{
return(m_szFile);
}
cPart* cPartList::add(const qint32& iID)
{
cPart* lpPart = find(iID);
if(!lpPart)
{
lpPart = new cPart(iID);
append(lpPart);
}
return(lpPart);
}
cPart* cPartList::find(const qint32& iID)
{
for(int x = 0;x < count();x++)
{
if(at(x)->id() == iID)
return(at(x));
}
return(0);
}
bool cPartList::load()
{
QSqlQuery query;
query.prepare("SELECT id, name, sortOrder, description, file FROM part;");
if(!query.exec())
{
myDebug << query.lastError().text();
return(false);
}
while(query.next())
{
cPart* lpPart = add(query.value("id").toInt());
lpPart->setName(query.value("name").toString());
lpPart->setSortOrder(query.value("sortOrder").toInt());
lpPart->setDescription(query.value("description").toString());
lpPart->setFile(query.value("file").toString());
}
return(true);
}
bool cPartList::save()
{
return(true);
}
+50
View File
@@ -0,0 +1,50 @@
#ifndef CPART_H
#define CPART_H
#include <QMetaType>
#include <QList>
#include <QString>
class cPart
{
public:
cPart(qint32 iID = -1);
void setID(const qint32& iID);
qint32 id();
void setName(const QString& szName);
QString name();
void setSortOrder(const qint32& iSortOrder);
qint32 sortOrder();
void setDescription(const QString& szDescription);
QString description();
void setFile(const QString& szFile);
QString file();
private:
qint32 m_iID;
QString m_szName;
qint32 m_iSortOrder;
QString m_szDescription;
QString m_szFile;
};
Q_DECLARE_METATYPE(cPart*)
class cPartList : public QList<cPart*>
{
public:
bool load();
bool save();
cPart* add(const qint32& iID);
cPart* find(const qint32& iID);
};
#endif // CPART_H
+176
View File
@@ -0,0 +1,176 @@
#include "cscene.h"
#include "common.h"
#include <QSqlQuery>
#include <QSqlError>
cScene::cScene(qint32 iID) :
m_iID(iID),
m_lpChapter(0),
m_szName(""),
m_iSortOrder(-1),
m_szDescription(""),
m_state(STATE::STATE_unknown),
m_szFile("")
{
}
void cScene::setID(const qint32& iID)
{
m_iID = iID;
}
qint32 cScene::id()
{
return(m_iID);
}
void cScene::setChapter(cChapter* lpChapter)
{
m_lpChapter = lpChapter;
}
cChapter* cScene::chapter()
{
return(m_lpChapter);
}
void cScene::setName(const QString& szName)
{
m_szName = szName;
}
QString cScene::name()
{
return(m_szName);
}
void cScene::setSortOrder(const qint32& iSortOrder)
{
m_iSortOrder = iSortOrder;
}
qint32 cScene::sortOrder()
{
return(m_iSortOrder);
}
void cScene::setDescription(const QString& szDescription)
{
m_szDescription = szDescription;
}
QString cScene::description()
{
return(m_szDescription);
}
void cScene::setState(const cScene::STATE state)
{
m_state = state;
}
cScene::STATE cScene::state()
{
return(m_state);
}
void cScene::setStartedAt(const QDateTime& startedAt)
{
m_startedAt = startedAt;
}
QDateTime cScene::startedAt()
{
return(m_startedAt);
}
void cScene::setFinishedAt(const QDateTime& finishedAt)
{
m_finishedAt = finishedAt;
}
QDateTime cScene::finishedAt()
{
return(m_finishedAt);
}
void cScene::setTargetDate(const QDateTime& targetDate)
{
m_targetDate = targetDate;
}
QDateTime cScene::targetDate()
{
return(m_targetDate);
}
void cScene::setFile(const QString& szFile)
{
m_szFile = szFile;
}
QString cScene::file()
{
return(m_szFile);
}
cScene* cSceneList::add(const qint32& iID)
{
cScene* lpScene = find(iID);
if(!lpScene)
{
lpScene = new cScene(iID);
append(lpScene);
}
return(lpScene);
}
cScene* cSceneList::find(const qint32& iID)
{
for(int x = 0;x < count();x++)
{
if(at(x)->id() == iID)
return(at(x));
}
return(0);
}
bool cSceneList::load(cChapterList* lpChapterList)
{
QSqlQuery query;
query.prepare("SELECT id, chapterID, name, sortOrder, description, state, startedAt, finishedAt, targetDate, file FROM scene;");
if(!query.exec())
{
myDebug << query.lastError().text();
return(false);
}
while(query.next())
{
cScene* lpScene = add(query.value("id").toInt());
lpScene->setChapter(lpChapterList->find(query.value("chapterID").toInt()));
lpScene->setName(query.value("name").toString());
lpScene->setSortOrder(query.value("sortOrder").toInt());
lpScene->setDescription(query.value("description").toString());
lpScene->setState((cScene::STATE)query.value("state").toInt());
lpScene->setStartedAt(query.value("startedAt").toDateTime());
lpScene->setFinishedAt(query.value("finishedAt").toDateTime());
lpScene->setTargetDate(query.value("targetDate").toDateTime());
lpScene->setFile(query.value("file").toString());
}
return(true);
}
bool cSceneList::save()
{
return(true);
}
+82
View File
@@ -0,0 +1,82 @@
#ifndef CSCENE_H
#define CSCENE_H
#include "cchapter.h"
#include <QMetaType>
#include <QList>
#include <QString>
#include <QDateTime>
class cScene
{
public:
enum STATE
{
STATE_unknown = 0,
STATE_init = 1,
STATE_progress = 2,
STATE_delayed = 3,
STATE_finished = 4,
};
cScene(qint32 iID = -1);
void setID(const qint32& iID);
qint32 id();
void setChapter(cChapter *lpChapter);
cChapter* chapter();
void setName(const QString& szName);
QString name();
void setSortOrder(const qint32& iSortOrder);
qint32 sortOrder();
void setDescription(const QString& szDescription);
QString description();
void setState(const STATE state);
STATE state();
void setStartedAt(const QDateTime& startedAt);
QDateTime startedAt();
void setFinishedAt(const QDateTime& finishedAt);
QDateTime finishedAt();
void setTargetDate(const QDateTime& targetDate);
QDateTime targetDate();
void setFile(const QString& szFile);
QString file();
private:
qint32 m_iID;
cChapter* m_lpChapter;
QString m_szName;
qint32 m_iSortOrder;
QString m_szDescription;
STATE m_state;
QDateTime m_startedAt;
QDateTime m_finishedAt;
QDateTime m_targetDate;
QString m_szFile;
};
Q_DECLARE_METATYPE(cScene*)
class cSceneList : public QList<cScene*>
{
public:
bool load(cChapterList *lpChapterList);
bool save();
cScene* add(const qint32& iID);
cScene* find(const qint32& iID);
};
#endif // CSCENE_H
+90 -20
View File
@@ -6,6 +6,10 @@
#include <QSqlQuery>
#include <QSqlError>
#include <QStandardItem>
#include <QMap>
#include <QDir>
@@ -19,6 +23,15 @@ cStoryBook::cStoryBook(const QString &szProjectPath) :
if(!loadBook())
return;
if(!loadPartList())
return;
if(!loadChapterList())
return;
if(!loadSceneList())
return;
m_bIsOpen = true;
}
@@ -101,9 +114,9 @@ bool cStoryBook::createDatabase()
" shortDescription TEXT, "
" description TEXT, "
" author TEXT, "
" startedAt DATE, "
" finishedAt DATE, "
" targetDate DATE "
" startedAt DATETIME, "
" finishedAt DATETIME, "
" targetDate DATETIME "
");"))
return(false);
@@ -244,9 +257,9 @@ bool cStoryBook::createDatabase()
" [order] INTEGER, "
" description TEXT, "
" state INTEGER, "
" startedAt DATE, "
" finishedAt DATE, "
" targetDate DATE, "
" startedAt DATETIME, "
" finishedAt DATETIME, "
" targetDate DATETIME, "
" file TEXT "
");"))
return(false);
@@ -287,25 +300,82 @@ bool cStoryBook::verify()
bool cStoryBook::loadBook()
{
QSqlQuery query;
return(m_book.load());
}
query.prepare("SELECT title, subTitle, shortDescription, description, author, startedAt, finishedAt, targetDate FROM book;");
if(!query.exec())
bool cStoryBook::loadPartList()
{
return(m_partList.load());
}
bool cStoryBook::loadChapterList()
{
return(m_chapterList.load(&m_partList));
}
bool cStoryBook::loadSceneList()
{
return(m_sceneList.load(&m_chapterList));
}
QString cStoryBook::title()
{
if(!m_bIsOpen)
return("Untitled");
else
return(m_book.title());
}
QString cStoryBook::author()
{
if(!m_bIsOpen)
return("");
else
return(m_book.author());
}
bool cStoryBook::fillOutlineList(QStandardItemModel* lpModel)
{
QMap<qint32, QStandardItem*> part;
QMap<qint32, QStandardItem*> chapter;
lpModel->clear();
for(int x = 0;x < m_partList.count();x++)
{
myDebug << query.lastError().text();
return(false);
cPart* lpPart = m_partList.at(x);
QStandardItem* lpItem = new QStandardItem(lpPart->name());
lpItem->setData(QVariant::fromValue(lpPart));
part.insert(lpPart->id(), lpItem);
lpModel->appendRow(lpItem);
}
query.first();
for(int x = 0;x < m_chapterList.count();x++)
{
cChapter* lpChapter = m_chapterList.at(x);
QStandardItem* lpRoot = part.value(lpChapter->part()->id());
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());
if(lpRoot)
{
QStandardItem* lpItem = new QStandardItem(lpChapter->name());
lpItem->setData(QVariant::fromValue(lpChapter));
chapter.insert(lpChapter->id(), lpItem);
lpRoot->appendRow(lpItem);
}
}
for(int x = 0;x < m_sceneList.count();x++)
{
cScene* lpScene = m_sceneList.at(x);
QStandardItem* lpRoot = chapter.value(lpScene->chapter()->id());
if(lpRoot)
{
QStandardItem* lpItem = new QStandardItem(lpScene->name());
lpItem->setData(QVariant::fromValue(lpScene));
lpRoot->appendRow(lpItem);
}
}
return(true);
}
+16
View File
@@ -3,9 +3,14 @@
#include "cbook.h"
#include "cpart.h"
#include "cchapter.h"
#include "cscene.h"
#include <QString>
#include <QStandardItemModel>
#include <QSqlDatabase>
@@ -17,17 +22,28 @@ public:
bool openDatabase();
bool verify();
QString title();
QString author();
bool fillOutlineList(QStandardItemModel* lpModel);
private:
QString m_szProjectPath;
bool m_bIsOpen;
QSqlDatabase m_db;
cBook m_book;
cPartList m_partList;
cChapterList m_chapterList;
cSceneList m_sceneList;
bool createDatabase();
bool updateDatabase();
bool createTable(const QString& szSQL);
bool loadBook();
bool loadPartList();
bool loadChapterList();
bool loadSceneList();
};
#endif // CSTORYBOOK_H
+13 -1
View File
@@ -1,11 +1,23 @@
#include "cmainwindow.h"
#include <QApplication>
#include <QSettings>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("WIN-DESIGN");
QCoreApplication::setOrganizationDomain("windesign.at");
QCoreApplication::setApplicationName("qtStoryWriter");
QSettings settings;
cMainWindow w;
w.show();
if(settings.value("main/maximized").toBool())
w.showMaximized();
else
w.show();
return a.exec();
}
+8 -2
View File
@@ -63,7 +63,10 @@ SOURCES += \
cstructurewindow.cpp \
cwidget.cpp \
cstorybook.cpp \
cbook.cpp
cbook.cpp \
cpart.cpp \
cchapter.cpp \
cscene.cpp
HEADERS += \
cmainwindow.h \
@@ -76,7 +79,10 @@ HEADERS += \
cwidget.h \
cstorybook.h \
common.h \
cbook.h
cbook.h \
cpart.h \
cchapter.h \
cscene.h
FORMS += \
cmainwindow.ui \