diff --git a/cscene.cpp b/cscene.cpp index fa0e035..4867f8d 100644 --- a/cscene.cpp +++ b/cscene.cpp @@ -118,6 +118,16 @@ QDateTime cScene::targetDate() return(m_targetDate); } +void cScene::setSceneDate(const QDateTime& sceneDate) +{ + m_sceneDate = sceneDate; +} + +QDateTime cScene::sceneDate() +{ + return(m_sceneDate); +} + void cScene::setText(cTextDocument* lpText) { m_lpText = lpText; @@ -364,7 +374,7 @@ bool cSceneList::load(cChapterList* lpChapterList, cCharacterList *lpCharacterLi { QSqlQuery query; - query.prepare("SELECT id, chapterID, name, sortOrder, description, state, startedAt, finishedAt, targetDate, text FROM scene ORDER BY sortOrder;"); + query.prepare("SELECT id, chapterID, name, sortOrder, description, state, startedAt, finishedAt, targetDate, sceneDate, text FROM scene ORDER BY sortOrder;"); if(!query.exec()) { myDebug << query.lastError().text(); @@ -383,6 +393,7 @@ bool cSceneList::load(cChapterList* lpChapterList, cCharacterList *lpCharacterLi lpScene->setStartedAt(query.value("startedAt").toDateTime()); lpScene->setFinishedAt(query.value("finishedAt").toDateTime()); lpScene->setTargetDate(query.value("targetDate").toDateTime()); + lpScene->setSceneDate(query.value("sceneDate").toDateTime()); lpScene->setText(blob2TextDocument(query.value("text").toByteArray())); } @@ -450,8 +461,8 @@ bool cSceneList::save() QSqlQuery querySelect; QSqlQuery queryDelete; - queryUpdate.prepare("UPDATE scene SET name=:name, chapterID=:chapterID, sortOrder=:sortOrder, description=:description, state=:state, startedAt=:startedAt, finishedAt=:finishedAt, targetDate=:targetDate, text=:text WHERE id=:id;"); - queryInsert.prepare("INSERT INTO scene (name, chapterID, sortOrder, description, state, startedAt, finishedAt, targetDate, text) VALUES (:name, :chapterID, :sortOrder, :description, :state, :startedAt, :finishedAt, :targetDate, :text);"); + queryUpdate.prepare("UPDATE scene SET name=:name, chapterID=:chapterID, sortOrder=:sortOrder, description=:description, state=:state, startedAt=:startedAt, finishedAt=:finishedAt, targetDate=:targetDate, sceneDate=:sceneDate, text=:text WHERE id=:id;"); + queryInsert.prepare("INSERT INTO scene (name, chapterID, sortOrder, description, state, startedAt, finishedAt, targetDate, sceneDate, text) VALUES (:name, :chapterID, :sortOrder, :description, :state, :startedAt, :finishedAt, :targetDate, :sceneDate, :text);"); querySelect.prepare("SELECT id FROM scene WHERE _rowid_=(SELECT MAX(_rowid_) FROM scene);"); queryDelete.prepare("DELETE FROM scene WHERE id=:id;"); @@ -522,6 +533,7 @@ bool cSceneList::save() queryUpdate.bindValue(":startedAt", lpScene->startedAt()); queryUpdate.bindValue(":finishedAt", lpScene->finishedAt()); queryUpdate.bindValue(":targetDate", lpScene->targetDate()); + queryUpdate.bindValue(":sceneDate", lpScene->sceneDate()); queryUpdate.bindValue(":text", textDocument2Blob(lpScene->text())); if(!queryUpdate.exec()) @@ -540,6 +552,7 @@ bool cSceneList::save() queryInsert.bindValue(":startedAt", lpScene->startedAt()); queryInsert.bindValue(":finishedAt", lpScene->finishedAt()); queryInsert.bindValue(":targetDate", lpScene->targetDate()); + queryInsert.bindValue(":sceneDate", lpScene->sceneDate()); queryInsert.bindValue(":text", textDocument2Blob(lpScene->text())); if(!queryInsert.exec()) diff --git a/cscene.h b/cscene.h index 6ea21fa..a206be2 100644 --- a/cscene.h +++ b/cscene.h @@ -189,6 +189,21 @@ public: */ QDateTime targetDate(); + /*! + \brief + + \fn setSceneDate + \param sceneDate + */ + void setSceneDate(const QDateTime& sceneDate); + /*! + \brief + + \fn sceneDate + \return QDateTime + */ + QDateTime sceneDate(); + /*! \brief @@ -359,6 +374,7 @@ private: QDateTime m_startedAt; /*!< TODO: describe */ QDateTime m_finishedAt; /*!< TODO: describe */ QDateTime m_targetDate; /*!< TODO: describe */ + QDateTime m_sceneDate; /*!< TODO: describe */ cTextDocument* m_lpText; /*!< TODO: describe */ QList m_characterList; /*!< TODO: describe */ QList m_objectList; /*!< TODO: describe */ diff --git a/cscenewindow.cpp b/cscenewindow.cpp index 496c80b..36e15cb 100644 --- a/cscenewindow.cpp +++ b/cscenewindow.cpp @@ -73,6 +73,9 @@ cSceneWindow::cSceneWindow(QWidget *parent) : connect(ui->m_lpTargetDate, &cDateTimeEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditGotFocus); connect(ui->m_lpTargetDate, &cDateTimeEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditLostFocus); + connect(ui->m_lpSceneDate, &cDateTimeEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditGotFocus); + connect(ui->m_lpSceneDate, &cDateTimeEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditLostFocus); + connect(ui->m_lpText, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); connect(ui->m_lpText, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); @@ -127,6 +130,7 @@ void cSceneWindow::setScene(cScene* lpScene, cCharacterList* lpCharacterList, cP ui->m_lpFinishedAt->setVisible(false); } ui->m_lpTargetDate->setDateTime(lpScene->targetDate()); + ui->m_lpSceneDate->setDateTime(lpScene->sceneDate()); ui->m_lpText->setDocument(lpScene->text()); fillCharacterList(); @@ -145,6 +149,7 @@ void cSceneWindow::setScene(cScene* lpScene, cCharacterList* lpCharacterList, cP connect(ui->m_lpStartedAt, &cDateEdit::dateTimeChanged, this, &cSceneWindow::onStartedChanged); connect(ui->m_lpFinishedAt, &cDateEdit::dateTimeChanged, this, &cSceneWindow::onFinishedChanged); connect(ui->m_lpTargetDate, &cDateEdit::dateTimeChanged, this, &cSceneWindow::onTargetDateChanged); + connect(ui->m_lpSceneDate, &cDateEdit::dateTimeChanged, this, &cSceneWindow::onSceneDateChanged); connect(ui->m_lpText, &cTextEdit::textChanged, this, &cSceneWindow::onTextChanged); } @@ -253,6 +258,12 @@ void cSceneWindow::onTargetDateChanged(const QDateTime& dateTime) m_lpMainWindow->somethingChanged(); } +void cSceneWindow::onSceneDateChanged(const QDateTime& dateTime) +{ + m_lpScene->setSceneDate(dateTime); + m_lpMainWindow->somethingChanged(); +} + void cSceneWindow::onTextChanged() { m_lpMainWindow->somethingChanged(); diff --git a/cscenewindow.h b/cscenewindow.h index 5c5d8c8..8b9b335 100644 --- a/cscenewindow.h +++ b/cscenewindow.h @@ -152,6 +152,13 @@ private slots: /*! \brief + \fn onSceneDateChanged + \param dateTime + */ + void onSceneDateChanged(const QDateTime& dateTime); + /*! + \brief + \fn onTextChanged */ void onTextChanged(); diff --git a/cscenewindow.ui b/cscenewindow.ui index 96b547c..52febe2 100644 --- a/cscenewindow.ui +++ b/cscenewindow.ui @@ -6,7 +6,7 @@ 0 0 - 725 + 740 528 @@ -19,7 +19,7 @@ - 1 + 0 @@ -28,6 +28,89 @@ + + + + Target Date: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + State: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Part: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + true + + + + + + + + + + true + + + + + + + Description: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Chapter: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -35,10 +118,10 @@ - - + + - Chapter: + Started: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -65,89 +148,19 @@ - - - - Started: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - State: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Part: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Target Date: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - true - - - - - - - true - - - - - - - true - - - - - - - - - - + - Description: + Scene Date: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -317,6 +330,31 @@
cdatetimeedit.h
+ + m_lpTab + m_lpPart + m_lpChapter + m_lpName + m_lpState + m_lpStartedAt + m_lpFinishedAt + m_lpTargetDate + m_lpSceneDate + m_lpDescription + m_lpText + m_lpCaracterAdd + m_lpCharacterRemove + m_lpPlaceList + m_lpPlaceShowDetails + m_lpPlaceAdd + m_lpPlaceRemove + m_lpObjectList + m_lpObjectShowDetails + m_lpObjectAdd + m_lpObjectRemove + m_lpCharacterShowDetails + m_lpCharacterList + diff --git a/cstorybook.cpp b/cstorybook.cpp index 3c5a1d2..ff34581 100644 --- a/cstorybook.cpp +++ b/cstorybook.cpp @@ -186,7 +186,6 @@ bool cStoryBook::save() query.prepare("VACUUM;"); if(!query.exec()) myDebug << query.lastError().text(); - query.finish(); return(true); } @@ -438,7 +437,6 @@ bool cStoryBook::openDatabase() updateDatabase01(); else updateDatabase(query.value("version").toInt()); - query.finish(); } return(true); @@ -455,7 +453,6 @@ bool cStoryBook::createTable(const QString& szSQL) myDebug << szSQL << "\n" << query.lastError().text(); return(false); } - query.finish(); return(true); } @@ -525,7 +522,6 @@ bool cStoryBook::createDatabase() " unit INTEGER" "); ")) return(false); - query.finish(); QFont font; QString szDefaultFont = font.family(); @@ -595,7 +591,6 @@ bool cStoryBook::createDatabase() myDebug << query.lastError().text(); return(false); } - query.finish(); if(!createTable("CREATE TABLE book ( " " title TEXT, " @@ -798,7 +793,6 @@ bool cStoryBook::updateDatabase01() myDebug << query.lastError().text(); return(false); } - query.finish(); if(!createTable("CREATE TABLE config ( " " version INTEGER, " @@ -926,10 +920,8 @@ bool cStoryBook::updateDatabase01() myDebug << query.lastError().text(); return(false); } - query.finish(); query.exec("DROP TABLE config_old;"); - query.finish(); return(updateDatabase(1)); } @@ -939,21 +931,18 @@ bool cStoryBook::updateDatabase1() QSqlQuery query; query.exec("DROP TABLE config_old;"); - query.finish(); if(!query.exec("ALTER TABLE scene ADD sceneDate DATETIME;")) { myDebug << query.lastError().text(); return(false); } - query.finish(); if(!query.exec("UPDATE config SET version=2;")) { myDebug << query.lastError().text(); return(false); } - query.finish(); return(true); } @@ -1033,7 +1022,6 @@ bool cStoryBook::loadConfig() m_dTopMargin = query.value("topMargin").toDouble(); m_dBottomMargin = query.value("bottomMargin").toDouble(); m_iUnit = (QPageLayout::Unit)query.value("unit").toInt(); - query.finish(); return(true); } @@ -1154,7 +1142,6 @@ bool cStoryBook::saveConfig() myDebug << query.lastError().text(); return(false); } - query.finish(); return(true); }