From b02734e020dc4feb6e963d4c8c8c8a8050d760f4 Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Wed, 9 May 2018 17:59:27 +0200 Subject: [PATCH] . --- cchapterwindow.cpp | 8 +- cchapterwindow.h | 12 +- ccharacter.cpp | 114 +++++++++++++++++ ccharacterwindow.cpp | 291 +++++++++++++++++++++++++++++++++++-------- ccharacterwindow.h | 175 ++++++++++++++++++++++++++ cimage.cpp | 46 +++++++ cmainwindow.cpp | 9 +- cobjectwindow.cpp | 34 ++++- cobjectwindow.h | 24 ++++ common.cpp | 8 ++ common.h | 8 ++ cpartwindow.cpp | 39 ++++-- cpartwindow.h | 28 ++++- cplacewindow.cpp | 45 +++++-- cplacewindow.h | 31 +++++ crecherchewindow.cpp | 52 +++++--- crecherchewindow.h | 17 +++ cscenewindow.cpp | 134 ++++++++++++++------ cscenewindow.h | 51 ++++++-- cstorybook.cpp | 85 ++++++++++++- cstorybook.h | 60 +++++++++ 21 files changed, 1123 insertions(+), 148 deletions(-) diff --git a/cchapterwindow.cpp b/cchapterwindow.cpp index f787898..1f6f4c4 100644 --- a/cchapterwindow.cpp +++ b/cchapterwindow.cpp @@ -39,10 +39,6 @@ cChapterWindow::cChapterWindow(QWidget *parent) : connect(ui->m_lpText, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus); connect(ui->m_lpText, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus); - - connect(ui->m_lpName, &cLineEdit::textChanged, this, &cChapterWindow::onNameChanged); - connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cChapterWindow::onDescriptionChanged); - connect(ui->m_lpText, &cTextEdit::textChanged, this, &cChapterWindow::onTextChanged); } cChapterWindow::~cChapterWindow() @@ -77,6 +73,10 @@ void cChapterWindow::setChapter(cChapter* lpChapter, cSceneList* lpSceneList) ui->m_lpSceneList->resizeColumnToContents(0); setWindowTitle(tr("[chapter] - ") + lpChapter->name()); + + connect(ui->m_lpName, &cLineEdit::textChanged, this, &cChapterWindow::onNameChanged); + connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cChapterWindow::onDescriptionChanged); + connect(ui->m_lpText, &cTextEdit::textChanged, this, &cChapterWindow::onTextChanged); } cChapter* cChapterWindow::chapter() diff --git a/cchapterwindow.h b/cchapterwindow.h index 891f44a..87264d7 100644 --- a/cchapterwindow.h +++ b/cchapterwindow.h @@ -7,7 +7,6 @@ #include "cscene.h" #include "cmdisubwindow.h" - #include "cmainwindow.h" #include @@ -68,8 +67,19 @@ private slots: void onSceneDoubleClicked(const QModelIndex& index); void onNameChanged(const QString& szName); + /*! + \brief + + \fn onDescriptionChanged + */ void onDescriptionChanged(); + /*! + \brief + + \fn onTextChanged + */ void onTextChanged(); + signals: /*! \brief diff --git a/ccharacter.cpp b/ccharacter.cpp index 91a1fc0..f507c7f 100644 --- a/ccharacter.cpp +++ b/ccharacter.cpp @@ -443,5 +443,119 @@ bool cCharacterList::load(cImageList *lpImageList) bool cCharacterList::save() { + QSqlQuery queryUpdate; + QSqlQuery queryInsert; + QSqlQuery querySelect; + + queryUpdate.prepare("UPDATE character SET mainCharacter=:mainCharacter, creature=:creature, gender=:gender, title=:title, firstName=:firstName, middleName=:middleName, lastName=:lastName, height=:height, weight=:weight, dateOfBirth=:dateOfBirth, dateOfDeath=:dateOfDeath, placeOfBirth=:placeOfBirth, placeOfDeath=:placeOfDeath, hairColor=:hairColor, hairCut=:hairCut, hairLength=:hairLength, figure=:figure, nature=:nature, spokenLanguages=:spokenLanguages, skin=:skin, school=:school, job=:job, description=:description WHERE id=:id;"); + queryInsert.prepare("INSERT INTO character (mainCharacter, creature, gender, title, firstName, middleName, lastName, height, weight, dateOfBirth, dateOfDeath, placeOfBirth, placeOfDeath, hairColor, hairCut, hairLength, figure, nature, spokenLanguages, skin, school, job, description) VALUES (:mainCharacter, :creature, :gender, :title, :firstName,: middleName, :lastName, :height, :weight,:dateOfBirth, :dateOfDeath, :placeOfBirth, :placeOfDeath, :hairColor, :hairCut, :hairLength, :figure, :nature, :spokenLanguages, :skin, :school, :job, :description);"); + querySelect.prepare("SELECT id FROM character WHERE _rowid_=(SELECT MAX(_rowid_) FROM character);"); + + QSqlQuery imageDelete; + QSqlQuery imageAdd; + + imageDelete.prepare("DELETE FOM characterImage WHERE characterID=:characterID;"); + imageAdd.prepare("INSERT INTO characterImage (characterID, imageID) VALUES (:characterID, :imageID);"); + + for(int x = 0;x < count();x++) + { + cCharacter* lpCharacter = at(x); + + if(lpCharacter->id() != -1) + { + queryUpdate.bindValue(":id", lpCharacter->id()); + queryUpdate.bindValue(":mainCharacter", lpCharacter->mainCharacter()); + queryUpdate.bindValue(":creature", lpCharacter->creature()); + queryUpdate.bindValue(":gender", lpCharacter->gender()); + queryUpdate.bindValue(":title", lpCharacter->title()); + queryUpdate.bindValue(":firstName", lpCharacter->firstName()); + queryUpdate.bindValue(":middleName", lpCharacter->middleName()); + queryUpdate.bindValue(":lastName", lpCharacter->lastName()); + queryUpdate.bindValue(":height", lpCharacter->height()); + queryUpdate.bindValue(":weight", lpCharacter->weight()); + queryUpdate.bindValue(":dateOfBirth", lpCharacter->dateOfBirth()); + queryUpdate.bindValue(":dateOfDeath", lpCharacter->dateOfDeath()); + queryUpdate.bindValue(":placeOfBirth", lpCharacter->placeOfBirth()); + queryUpdate.bindValue(":placeOfDeath", lpCharacter->placeOfDeath()); + queryUpdate.bindValue(":hairColor", lpCharacter->hairColor()); + queryUpdate.bindValue(":hairCut", lpCharacter->hairCut()); + queryUpdate.bindValue(":hairLength", lpCharacter->hairLength()); + queryUpdate.bindValue(":figure", lpCharacter->figure()); + queryUpdate.bindValue(":nature", lpCharacter->nature()); + queryUpdate.bindValue(":spokenLanguages", lpCharacter->spokenLanguages()); + queryUpdate.bindValue(":skin", lpCharacter->skin()); + queryUpdate.bindValue(":school", lpCharacter->school()); + queryUpdate.bindValue(":job", lpCharacter->job()); + queryUpdate.bindValue(":description", textDocument2Blob(lpCharacter->description())); + + if(!queryUpdate.exec()) + { + myDebug << queryUpdate.lastError().text(); + return(false); + } + } + else + { + queryInsert.bindValue(":mainCharacter", lpCharacter->mainCharacter()); + queryInsert.bindValue(":creature", lpCharacter->creature()); + queryInsert.bindValue(":gender", lpCharacter->gender()); + queryInsert.bindValue(":title", lpCharacter->title()); + queryInsert.bindValue(":firstName", lpCharacter->firstName()); + queryInsert.bindValue(":middleName", lpCharacter->middleName()); + queryInsert.bindValue(":lastName", lpCharacter->lastName()); + queryInsert.bindValue(":height", lpCharacter->height()); + queryInsert.bindValue(":weight", lpCharacter->weight()); + queryInsert.bindValue(":dateOfBirth", lpCharacter->dateOfBirth()); + queryInsert.bindValue(":dateOfDeath", lpCharacter->dateOfDeath()); + queryInsert.bindValue(":placeOfBirth", lpCharacter->placeOfBirth()); + queryInsert.bindValue(":placeOfDeath", lpCharacter->placeOfDeath()); + queryInsert.bindValue(":hairColor", lpCharacter->hairColor()); + queryInsert.bindValue(":hairCut", lpCharacter->hairCut()); + queryInsert.bindValue(":hairLength", lpCharacter->hairLength()); + queryInsert.bindValue(":figure", lpCharacter->figure()); + queryInsert.bindValue(":nature", lpCharacter->nature()); + queryInsert.bindValue(":spokenLanguages", lpCharacter->spokenLanguages()); + queryInsert.bindValue(":skin", lpCharacter->skin()); + queryInsert.bindValue(":school", lpCharacter->school()); + queryInsert.bindValue(":job", lpCharacter->job()); + queryInsert.bindValue(":description", textDocument2Blob(lpCharacter->description())); + + if(!queryInsert.exec()) + { + myDebug << queryInsert.lastError().text(); + return(false); + } + + if(!querySelect.exec()) + { + myDebug << querySelect.lastError().text(); + return(false); + } + lpCharacter->setID(querySelect.value("id").toInt()); + } + + imageDelete.bindValue("characterID", lpCharacter->id()); + if(!imageDelete.exec()) + { + myDebug << imageDelete.lastError().text(); + return(false); + } + + QList images = lpCharacter->images(); + + for(int x = 0;x < images.count();x++) + { + cImage* lpImage = images.at(x); + + imageAdd.bindValue(":characterID", lpCharacter->id()); + imageAdd.bindValue(":imageID", lpImage->id()); + if(!imageAdd.exec()) + { + myDebug << imageAdd.lastError().text(); + return(false); + } + } + } + return(true); } diff --git a/ccharacterwindow.cpp b/ccharacterwindow.cpp index d22bf88..0ed8399 100644 --- a/ccharacterwindow.cpp +++ b/ccharacterwindow.cpp @@ -18,85 +18,86 @@ cCharacterWindow::cCharacterWindow(QWidget *parent) : cMDISubWindow(parent), ui(new Ui::cCharacterWindow), + m_lpMainWindow((cMainWindow*)parent), m_lpCharacter(0) { ui->setupUi(this); ui->m_lpTab->setCurrentIndex(0); - connect(ui->m_lpFirstName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpFirstName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpFirstName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpFirstName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpMiddleName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpMiddleName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpMiddleName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpMiddleName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpLastName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpLastName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpLastName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpLastName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpMainCharacter, SIGNAL(gotFocus(cCheckBox*)), (cMainWindow*)parent, SLOT(onCheckBoxGotFocus(cCheckBox*))); - connect(ui->m_lpMainCharacter, SIGNAL(lostFocus(cCheckBox*)), (cMainWindow*)parent, SLOT(onCheckBoxLostFocus(cCheckBox*))); + connect(ui->m_lpMainCharacter, &cCheckBox::gotFocus, (cMainWindow*)parent, &cMainWindow::onCheckBoxGotFocus); + connect(ui->m_lpMainCharacter, &cCheckBox::lostFocus, (cMainWindow*)parent, &cMainWindow::onCheckBoxLostFocus); - connect(ui->m_lpCreature, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpCreature, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpCreature, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpCreature, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpTitle, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpTitle, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpTitle, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpTitle, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpMale, SIGNAL(gotFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonGotFocus(cRadioButton*))); - connect(ui->m_lpMale, SIGNAL(lostFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonLostFocus(cRadioButton*))); + connect(ui->m_lpMale, &cRadioButton::gotFocus, (cMainWindow*)parent, &cMainWindow::onRadioButtonGotFocus); + connect(ui->m_lpMale, &cRadioButton::lostFocus, (cMainWindow*)parent, &cMainWindow::onRadioButtonLostFocus); - connect(ui->m_lpFemale, SIGNAL(gotFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonGotFocus(cRadioButton*))); - connect(ui->m_lpFemale, SIGNAL(lostFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonLostFocus(cRadioButton*))); + connect(ui->m_lpFemale, &cRadioButton::gotFocus, (cMainWindow*)parent, &cMainWindow::onRadioButtonGotFocus); + connect(ui->m_lpFemale, &cRadioButton::lostFocus, (cMainWindow*)parent, &cMainWindow::onRadioButtonLostFocus); - connect(ui->m_lpOther, SIGNAL(gotFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonGotFocus(cRadioButton*))); - connect(ui->m_lpOther, SIGNAL(lostFocus(cRadioButton*)), (cMainWindow*)parent, SLOT(onRadioButtonLostFocus(cRadioButton*))); + connect(ui->m_lpOther, &cRadioButton::gotFocus, (cMainWindow*)parent, &cMainWindow::onRadioButtonGotFocus); + connect(ui->m_lpOther, &cRadioButton::lostFocus, (cMainWindow*)parent, &cMainWindow::onRadioButtonLostFocus); - connect(ui->m_lpDayOfBirth, SIGNAL(gotFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditGotFocus(cDateEdit*))); - connect(ui->m_lpDayOfBirth, SIGNAL(lostFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditLostFocus(cDateEdit*))); + connect(ui->m_lpDayOfBirth, &cDateEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onDateEditGotFocus); + connect(ui->m_lpDayOfBirth, &cDateEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onDateEditLostFocus); - connect(ui->m_lpDayOfDeath, SIGNAL(gotFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditGotFocus(cDateEdit*))); - connect(ui->m_lpDayOfDeath, SIGNAL(lostFocus(cDateEdit*)), (cMainWindow*)parent, SLOT(onDateEditLostFocus(cDateEdit*))); + connect(ui->m_lpDayOfDeath, &cDateEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onDateEditGotFocus); + connect(ui->m_lpDayOfDeath, &cDateEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onDateEditLostFocus); - connect(ui->m_lpPlaceOfBirth, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpPlaceOfBirth, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpPlaceOfBirth, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpPlaceOfBirth, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpPlaceOfDeath, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpPlaceOfDeath, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpPlaceOfDeath, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpPlaceOfDeath, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpHeight, SIGNAL(gotFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxGotFocus(cDoubleSpinBox*))); - connect(ui->m_lpHeight, SIGNAL(lostFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxLostFocus(cDoubleSpinBox*))); + connect(ui->m_lpHeight, &cDoubleSpinBox::gotFocus, (cMainWindow*)parent, &cMainWindow::onDoubleSpinBoxGotFocus); + connect(ui->m_lpHeight, &cDoubleSpinBox::lostFocus, (cMainWindow*)parent, &cMainWindow::onDoubleSpinBoxLostFocus); - connect(ui->m_lpWeight, SIGNAL(gotFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxGotFocus(cDoubleSpinBox*))); - connect(ui->m_lpWeight, SIGNAL(lostFocus(cDoubleSpinBox*)), (cMainWindow*)parent, SLOT(onDoubleSpinBoxLostFocus(cDoubleSpinBox*))); + connect(ui->m_lpWeight, &cDoubleSpinBox::gotFocus, (cMainWindow*)parent, &cMainWindow::onDoubleSpinBoxGotFocus); + connect(ui->m_lpWeight, &cDoubleSpinBox::lostFocus, (cMainWindow*)parent, &cMainWindow::onDoubleSpinBoxLostFocus); - connect(ui->m_lpFigure, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpFigure, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpFigure, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpFigure, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpSkin, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpSkin, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpSkin, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpSkin, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpNature, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpNature, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpNature, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpNature, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpHairColor, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpHairColor, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpHairColor, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpHairColor, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpHairCut, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpHairCut, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpHairCut, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpHairCut, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpHairLength, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpHairLength, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpHairLength, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpHairLength, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpSchool, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpSchool, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpSchool, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpSchool, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); - connect(ui->m_lpSpokenLanguages, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpSpokenLanguages, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpSpokenLanguages, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpSpokenLanguages, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); - connect(ui->m_lpJob, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpJob, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpJob, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpJob, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); - connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpDescription, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpDescription, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); } cCharacterWindow::~cCharacterWindow() @@ -158,9 +159,199 @@ void cCharacterWindow::setCharacter(cCharacter* lpCharacter) ui->m_lpLayout->addItem(lpSpacer); setWindowTitle(tr("[character] - ") + lpCharacter->name()); + + connect(ui->m_lpFirstName, &cLineEdit::textChanged, this, &cCharacterWindow::onFirstNameChanged); + connect(ui->m_lpMiddleName, &cLineEdit::textChanged, this, &cCharacterWindow::onMiddleNameChanged); + connect(ui->m_lpLastName, &cLineEdit::textChanged, this, &cCharacterWindow::onLastNameChanged); + connect(ui->m_lpMainCharacter, &cCheckBox::clicked, this, &cCharacterWindow::onMainCharacterClicked); + connect(ui->m_lpCreature, &cLineEdit::textChanged, this, &cCharacterWindow::onCreatureChanged); + connect(ui->m_lpMale, &cCheckBox::clicked, this, &cCharacterWindow::onGenderMaleClicked); + connect(ui->m_lpFemale, &cCheckBox::clicked, this, &cCharacterWindow::onGenderFemaleClicked); + connect(ui->m_lpOther, &cCheckBox::clicked, this, &cCharacterWindow::onGenderOtherClicked); + connect(ui->m_lpTitle, &cLineEdit::textChanged, this, &cCharacterWindow::onTitleChanged); + connect(ui->m_lpDayOfBirth, &cDateEdit::dateChanged, this, &cCharacterWindow::onDateOfBirthChanged); + connect(ui->m_lpDayOfDeath, &cDateEdit::dateChanged, this, &cCharacterWindow::onDateOfDeathChanged); + connect(ui->m_lpPlaceOfBirth, &cLineEdit::textChanged, this, &cCharacterWindow::onPlaceOfBirthChanged); + connect(ui->m_lpPlaceOfDeath, &cLineEdit::textChanged, this, &cCharacterWindow::onPlaceOfDeathChanged); + connect(ui->m_lpHeight, QOverload::of(&cDoubleSpinBox::valueChanged), this, &cCharacterWindow::onHeightChanged); + connect(ui->m_lpWeight, QOverload::of(&cDoubleSpinBox::valueChanged), this, &cCharacterWindow::onWeightChanged); + connect(ui->m_lpFigure, &cLineEdit::textChanged, this, &cCharacterWindow::onFigureChanged); + connect(ui->m_lpSkin, &cLineEdit::textChanged, this, &cCharacterWindow::onSkinChanged); + connect(ui->m_lpNature, &cLineEdit::textChanged, this, &cCharacterWindow::onNatureChanged); + connect(ui->m_lpHairColor, &cLineEdit::textChanged, this, &cCharacterWindow::onHairColorChanged); + connect(ui->m_lpHairCut, &cLineEdit::textChanged, this, &cCharacterWindow::onHairCutChanged); + connect(ui->m_lpHairLength, &cLineEdit::textChanged, this, &cCharacterWindow::onHairLengthChanged); + connect(ui->m_lpSchool, &cTextEdit::textChanged, this, &cCharacterWindow::onSchoolChanged); + connect(ui->m_lpSpokenLanguages, &cTextEdit::textChanged, this, &cCharacterWindow::onSpokenLanguagesChanged); + connect(ui->m_lpJob, &cTextEdit::textChanged, this, &cCharacterWindow::onJobChanged); + connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cCharacterWindow::onDescriptionChanged); } cCharacter* cCharacterWindow::character() { return(m_lpCharacter); } + +void cCharacterWindow::onFirstNameChanged(const QString& szText) +{ + m_lpCharacter->setFirstName(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onMiddleNameChanged(const QString& szText) +{ + m_lpCharacter->setMiddleName(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onLastNameChanged(const QString& szText) +{ + m_lpCharacter->setLastName(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onMainCharacterClicked(bool bChecked) +{ + m_lpCharacter->setMainCharacter(bChecked); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onCreatureChanged(const QString& szText) +{ + m_lpCharacter->setCreature(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onGenderMaleClicked(bool /*bChecked*/) +{ + if(ui->m_lpMale->isChecked()) + m_lpCharacter->setGender(cCharacter::GENDER_male); + else if(ui->m_lpFemale->isChecked()) + m_lpCharacter->setGender(cCharacter::GENDER_female); + else + m_lpCharacter->setGender(cCharacter::GENDER_undefined); + + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onGenderFemaleClicked(bool /*bChecked*/) +{ + if(ui->m_lpMale->isChecked()) + m_lpCharacter->setGender(cCharacter::GENDER_male); + else if(ui->m_lpFemale->isChecked()) + m_lpCharacter->setGender(cCharacter::GENDER_female); + else + m_lpCharacter->setGender(cCharacter::GENDER_undefined); + + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onGenderOtherClicked(bool /*bChecked*/) +{ + if(ui->m_lpMale->isChecked()) + m_lpCharacter->setGender(cCharacter::GENDER_male); + else if(ui->m_lpFemale->isChecked()) + m_lpCharacter->setGender(cCharacter::GENDER_female); + else + m_lpCharacter->setGender(cCharacter::GENDER_undefined); + + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onTitleChanged(const QString& szText) +{ + m_lpCharacter->setTitle(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onDateOfBirthChanged(const QDate& date) +{ + m_lpCharacter->setDateOfBirth(date); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onDateOfDeathChanged(const QDate& date) +{ + m_lpCharacter->setDateOfDeath(date); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onPlaceOfBirthChanged(const QString& szText) +{ + m_lpCharacter->setPlaceOfBirth(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onPlaceOfDeathChanged(const QString& szText) +{ + m_lpCharacter->setPlaceOfDeath(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onHeightChanged(double d) +{ + m_lpCharacter->setHeight(d); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onWeightChanged(double d) +{ + m_lpCharacter->setWeight(d); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onFigureChanged(const QString& szText) +{ + m_lpCharacter->setFigure(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onSkinChanged(const QString& szText) +{ + m_lpCharacter->setSkin(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onNatureChanged(const QString& szText) +{ + m_lpCharacter->setNature(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onHairColorChanged(const QString& szText) +{ + m_lpCharacter->setHairColor(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onHairCutChanged(const QString& szText) +{ + m_lpCharacter->setHairCut(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onHairLengthChanged(const QString& szText) +{ + m_lpCharacter->setHairLength(szText); + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onSchoolChanged() +{ + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onSpokenLanguagesChanged() +{ + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onJobChanged() +{ + m_lpMainWindow->somethingChanged(); +} + +void cCharacterWindow::onDescriptionChanged() +{ + m_lpMainWindow->somethingChanged(); +} diff --git a/ccharacterwindow.h b/ccharacterwindow.h index 30c1186..74b5453 100644 --- a/ccharacterwindow.h +++ b/ccharacterwindow.h @@ -5,6 +5,7 @@ #include "ccharacter.h" #include "cmdisubwindow.h" +#include "cmainwindow.h" #include #include @@ -53,8 +54,182 @@ public: */ cCharacter* character(); +private slots: + /*! + \brief + + \fn onFirstNameChanged + \param szText + */ + void onFirstNameChanged(const QString& szText); + /*! + \brief + + \fn onMiddleNameChanged + \param szText + */ + void onMiddleNameChanged(const QString& szText); + /*! + \brief + + \fn onLastNameChanged + \param szText + */ + void onLastNameChanged(const QString& szText); + /*! + \brief + + \fn onMainCharacterClicked + \param bChecked + */ + void onMainCharacterClicked(bool bChecked); + /*! + \brief + + \fn onCreatureChanged + \param szText + */ + void onCreatureChanged(const QString& szText); + /*! + \brief + + \fn onGenderMaleClicked + \param bChecked + */ + void onGenderMaleClicked(bool bChecked); + /*! + \brief + + \fn onGenderFemaleClicked + \param bChecked + */ + void onGenderFemaleClicked(bool bChecked); + /*! + \brief + + \fn onGenderOtherClicked + \param bChecked + */ + void onGenderOtherClicked(bool bChecked); + /*! + \brief + + \fn onTitleChanged + \param szText + */ + void onTitleChanged(const QString& szText); + /*! + \brief + + \fn onDateOfBirthChanged + \param date + */ + void onDateOfBirthChanged(const QDate& date); + /*! + \brief + + \fn onDateOfDeathChanged + \param date + */ + void onDateOfDeathChanged(const QDate& date); + /*! + \brief + + \fn onPlaceOfBirthChanged + \param szText + */ + void onPlaceOfBirthChanged(const QString& szText); + /*! + \brief + + \fn onPlaceOfDeathChanged + \param szText + */ + void onPlaceOfDeathChanged(const QString& szText); + /*! + \brief + + \fn onHeightChanged + \param d + */ + void onHeightChanged(double d); + /*! + \brief + + \fn onWeightChanged + \param d + */ + void onWeightChanged(double d); + /*! + \brief + + \fn onFigureChanged + \param szText + */ + void onFigureChanged(const QString& szText); + /*! + \brief + + \fn onSkinChanged + \param szText + */ + void onSkinChanged(const QString& szText); + /*! + \brief + + \fn onNatureChanged + \param szText + */ + void onNatureChanged(const QString& szText); + /*! + \brief + + \fn onHairColorChanged + \param szText + */ + void onHairColorChanged(const QString& szText); + /*! + \brief + + \fn onHairCutChanged + \param szText + */ + void onHairCutChanged(const QString& szText); + /*! + \brief + + \fn onHairLengthChanged + \param szText + */ + void onHairLengthChanged(const QString& szText); + /*! + \brief + + \fn onSchoolChanged + */ + void onSchoolChanged(); + /*! + \brief + + \fn onSpokenLanguagesChanged + */ + void onSpokenLanguagesChanged(); + /*! + \brief + + \fn onJobChanged + */ + void onJobChanged(); + /*! + \brief + + \fn onDescriptionChanged + */ + void onDescriptionChanged(); + private: Ui::cCharacterWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ cCharacter* m_lpCharacter; /*!< TODO: describe */ }; diff --git a/cimage.cpp b/cimage.cpp index 25db01c..bf07c52 100644 --- a/cimage.cpp +++ b/cimage.cpp @@ -141,5 +141,51 @@ bool cImageList::load() bool cImageList::save() { + QSqlQuery queryUpdate; + QSqlQuery queryInsert; + QSqlQuery querySelect; + + queryUpdate.prepare("UPDATE image SET type=:type, name=:name, description=:description WHERE id=:id;"); + queryInsert.prepare("INSERT INTO image (type, name, description) VALUES (:type, :name, :description);"); + querySelect.prepare("SELECT id FROM image WHERE _rowid_=(SELECT MAX(_rowid_) FROM image);"); + + for(int x = 0;x < count();x++) + { + cImage* lpImage = at(x); + + if(lpImage->id() != -1) + { + queryUpdate.bindValue(":id", lpImage->id()); + queryUpdate.bindValue(":type", lpImage->type()); + queryUpdate.bindValue(":name", lpImage->name()); + queryUpdate.bindValue(":description", textDocument2Blob(lpImage->description())); + if(!queryUpdate.exec()) + { + myDebug << queryUpdate.lastError().text(); + return(false); + } +// NICHT VOLLSTÄNDIG + } + else + { + queryInsert.bindValue(":type", lpImage->type()); + queryInsert.bindValue(":name", lpImage->name()); + queryInsert.bindValue(":description", textDocument2Blob(lpImage->description())); + if(!queryInsert.exec()) + { + myDebug << queryInsert.lastError().text(); + return(false); + } + + if(!querySelect.exec()) + { + myDebug << querySelect.lastError().text(); + return(false); + } + lpImage->setID(querySelect.value("id").toInt()); +// NICHT VOLLSTÄNDIG + } + } + return(true); } diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 1c3a92f..b87c35e 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -46,6 +46,7 @@ cMainWindow::cMainWindow(QWidget *parent) : m_lpPlaceModel(0), m_lpObjectModel(0), m_bUpdatingTab(false), + m_bSomethingChanged(false), m_lpStoryBook(0), m_lpFileMenu(0), m_lpEditMenu(0), @@ -1138,12 +1139,18 @@ void cMainWindow::onFileOpen() bool cMainWindow::onFileSave() { + if(m_lpStoryBook) + m_lpStoryBook->save(); + m_bSomethingChanged = false; + updateWindowTitle(); + return(true); } bool cMainWindow::onFileSaveAs() { - return(true); + return(onFileSave()); +// return(true); } void cMainWindow::onFilePrint() diff --git a/cobjectwindow.cpp b/cobjectwindow.cpp index 9ba5817..ab148fc 100644 --- a/cobjectwindow.cpp +++ b/cobjectwindow.cpp @@ -18,18 +18,19 @@ cObjectWindow::cObjectWindow(QWidget *parent) : cMDISubWindow(parent), ui(new Ui::cObjectWindow), + m_lpMainWindow((cMainWindow*)parent), m_lpObject(0) { ui->setupUi(this); - connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpType, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpType, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpType, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpType, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpDescription, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpDescription, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); } cObjectWindow::~cObjectWindow() @@ -60,9 +61,30 @@ void cObjectWindow::setObject(cObject* lpObject) ui->m_lpLayout->addItem(lpSpacer); setWindowTitle(tr("[object] - ") + lpObject->name()); + + connect(ui->m_lpName, &cLineEdit::textChanged, this, &cObjectWindow::onNameChanged); + connect(ui->m_lpType, &cLineEdit::textChanged, this, &cObjectWindow::onTypeChanged); + connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cObjectWindow::onDescriptionChanged); } cObject* cObjectWindow::object() { return(m_lpObject); } + +void cObjectWindow::onNameChanged(const QString& szName) +{ + m_lpObject->setName(szName); + m_lpMainWindow->somethingChanged(); +} + +void cObjectWindow::onTypeChanged(const QString& szName) +{ + m_lpObject->setType(szName); + m_lpMainWindow->somethingChanged(); +} + +void cObjectWindow::onDescriptionChanged() +{ + m_lpMainWindow->somethingChanged(); +} diff --git a/cobjectwindow.h b/cobjectwindow.h index c1998f3..243cbed 100644 --- a/cobjectwindow.h +++ b/cobjectwindow.h @@ -5,6 +5,7 @@ #include "cobject.h" #include "cmdisubwindow.h" +#include "cmainwindow.h" #include #include @@ -53,8 +54,31 @@ public: */ cObject* object(); +private slots: + /*! + \brief + + \fn onNameChanged + \param szName + */ + void onNameChanged(const QString& szName); + /*! + \brief + + \fn onTypeChanged + \param szName + */ + void onTypeChanged(const QString& szName); + /*! + \brief + + \fn onDescriptionChanged + */ + void onDescriptionChanged(); + private: Ui::cObjectWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ cObject* m_lpObject; /*!< TODO: describe */ }; diff --git a/common.cpp b/common.cpp index 11fcac3..458af03 100644 --- a/common.cpp +++ b/common.cpp @@ -28,3 +28,11 @@ cTextDocument* blob2TextDocument(const QByteArray& ba) lpTextDocument->setHtml(uncompressText(ba)); return(lpTextDocument); } + +QByteArray textDocument2Blob(cTextDocument* lpTextDocument) +{ + QByteArray ba; + + ba = compressText(lpTextDocument->toHtml()); + return(ba); +} diff --git a/common.h b/common.h index 162d5ba..0d8967e 100644 --- a/common.h +++ b/common.h @@ -46,5 +46,13 @@ QByteArray compressText(const QString& uncompressed); \return cTextDocument */ cTextDocument* blob2TextDocument(const QByteArray& ba); +/*! + \brief + + \fn textDocument2Blob + \param lpTextDocument + \return QByteArray +*/ +QByteArray textDocument2Blob(cTextDocument* lpTextDocument); #endif // COMMON_H diff --git a/cpartwindow.cpp b/cpartwindow.cpp index 785cda9..ccd5b02 100644 --- a/cpartwindow.cpp +++ b/cpartwindow.cpp @@ -16,6 +16,7 @@ cPartWindow::cPartWindow(QWidget *parent) : cMDISubWindow(parent), ui(new Ui::cPartWindow), + m_lpMainWindow((cMainWindow*)parent), m_lpPart(0), m_lpChapterList(0) { @@ -24,19 +25,19 @@ cPartWindow::cPartWindow(QWidget *parent) : m_lpChapterModel = new QStandardItemModel(0, 1); ui->m_lpChapterList->setModel(m_lpChapterModel); - connect(ui->m_lpChapterList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onChapterDoubleClicked(QModelIndex))); + connect(ui->m_lpChapterList, &cTreeView::doubleClicked, this, &cPartWindow::onChapterDoubleClicked); - connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpName, &cLineEdit::gotFocus, m_lpMainWindow, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpName, &cLineEdit::lostFocus, m_lpMainWindow, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpText, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpText, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpChapterList, &cTreeView::gotFocus, m_lpMainWindow, &cMainWindow::onTreeViewGotFocus); + connect(ui->m_lpChapterList, &cTreeView::lostFocus, m_lpMainWindow, &cMainWindow::onTreeViewLostFocus); - connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpDescription, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpDescription, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus); - connect(ui->m_lpChapterList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); - connect(ui->m_lpChapterList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + connect(ui->m_lpText, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpText, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus); } cPartWindow::~cPartWindow() @@ -70,6 +71,10 @@ void cPartWindow::setPart(cPart* lpPart, cChapterList* lpChapterList) ui->m_lpChapterList->resizeColumnToContents(0); setWindowTitle(tr("[part] - ") + lpPart->name()); + + connect(ui->m_lpName, &cLineEdit::textChanged, this, &cPartWindow::onNameChanged); + connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cPartWindow::onDescriptionChanged); + connect(ui->m_lpText, &cTextEdit::textChanged, this, &cPartWindow::onTextChanged); } cPart* cPartWindow::part() @@ -84,3 +89,19 @@ void cPartWindow::onChapterDoubleClicked(const QModelIndex& index) if(lpChapter) showChapterWindow(lpChapter); } + +void cPartWindow::onNameChanged(const QString& szName) +{ + m_lpPart->setName(szName); + m_lpMainWindow->somethingChanged(); +} + +void cPartWindow::onDescriptionChanged() +{ + m_lpMainWindow->somethingChanged(); +} + +void cPartWindow::onTextChanged() +{ + m_lpMainWindow->somethingChanged(); +} diff --git a/cpartwindow.h b/cpartwindow.h index 83b49f6..6e22a25 100644 --- a/cpartwindow.h +++ b/cpartwindow.h @@ -6,6 +6,7 @@ #include "cchapter.h" #include "cmdisubwindow.h" +#include "cmainwindow.h" #include #include @@ -46,14 +47,14 @@ public: \param lpPart \param lpChapterList */ - void setPart(cPart* lpPart, cChapterList* lpChapterList); + void setPart(cPart* lpPart, cChapterList* lpChapterList); /*! \brief \fn part \return cPart */ - cPart* part(); + cPart* part(); private slots: /*! @@ -64,6 +65,20 @@ private slots: */ void onChapterDoubleClicked(const QModelIndex& index); + void onNameChanged(const QString& szName); + /*! + \brief + + \fn onDescriptionChanged + */ + void onDescriptionChanged(); + /*! + \brief + + \fn onTextChanged + */ + void onTextChanged(); + signals: /*! \brief @@ -74,10 +89,11 @@ signals: void showChapterWindow(cChapter* lpChapter); private: - Ui::cPartWindow* ui; /*!< TODO: describe */ - cPart* m_lpPart; /*!< TODO: describe */ - cChapterList* m_lpChapterList; /*!< TODO: describe */ - QStandardItemModel* m_lpChapterModel; /*!< TODO: describe */ + Ui::cPartWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ + cPart* m_lpPart; /*!< TODO: describe */ + cChapterList* m_lpChapterList; /*!< TODO: describe */ + QStandardItemModel* m_lpChapterModel; /*!< TODO: describe */ }; #endif // CPARTWINDOW_H diff --git a/cplacewindow.cpp b/cplacewindow.cpp index eb64b56..5de1bc3 100644 --- a/cplacewindow.cpp +++ b/cplacewindow.cpp @@ -18,21 +18,22 @@ cPlaceWindow::cPlaceWindow(QWidget *parent) : cMDISubWindow(parent), ui(new Ui::cPlaceWindow), + m_lpMainWindow((cMainWindow*)parent), m_lpPlace(0) { ui->setupUi(this); - connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpType, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpType, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpType, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpType, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpLocation, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpLocation, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpLocation, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpLocation, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpDescription, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpDescription, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); } cPlaceWindow::~cPlaceWindow() @@ -64,9 +65,37 @@ void cPlaceWindow::setPlace(cPlace* lpPlace) ui->m_lpLayout->addItem(lpSpacer); setWindowTitle(tr("[place] - ") + lpPlace->name()); + + connect(ui->m_lpName, &cLineEdit::textChanged, this, &cPlaceWindow::onNameChanged); + connect(ui->m_lpType, &cLineEdit::textChanged, this, &cPlaceWindow::onTypeChanged); + connect(ui->m_lpLocation, &cLineEdit::textChanged, this, &cPlaceWindow::onLocationChanged); + connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cPlaceWindow::onDescriptionChanged); } cPlace* cPlaceWindow::place() { return(m_lpPlace); } + +void cPlaceWindow::onNameChanged(const QString& szName) +{ + m_lpPlace->setName(szName); + m_lpMainWindow->somethingChanged(); +} + +void cPlaceWindow::onTypeChanged(const QString& szName) +{ + m_lpPlace->setType(szName); + m_lpMainWindow->somethingChanged(); +} + +void cPlaceWindow::onLocationChanged(const QString& szName) +{ + m_lpPlace->setLocation(szName); + m_lpMainWindow->somethingChanged(); +} + +void cPlaceWindow::onDescriptionChanged() +{ + m_lpMainWindow->somethingChanged(); +} diff --git a/cplacewindow.h b/cplacewindow.h index e1dd961..8618dcf 100644 --- a/cplacewindow.h +++ b/cplacewindow.h @@ -5,6 +5,7 @@ #include "cplace.h" #include "cmdisubwindow.h" +#include "cmainwindow.h" #include #include @@ -53,8 +54,38 @@ public: */ cPlace* place(); +private slots: + /*! + \brief + + \fn onNameChanged + \param szName + */ + void onNameChanged(const QString& szName); + /*! + \brief + + \fn onTypeChanged + \param szName + */ + void onTypeChanged(const QString& szName); + /*! + \brief + + \fn onLocationChanged + \param szName + */ + void onLocationChanged(const QString& szName); + /*! + \brief + + \fn onDescriptionChanged + */ + void onDescriptionChanged(); + private: Ui::cPlaceWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ cPlace* m_lpPlace; /*!< TODO: describe */ }; diff --git a/crecherchewindow.cpp b/crecherchewindow.cpp index ef12dd3..52f78cc 100644 --- a/crecherchewindow.cpp +++ b/crecherchewindow.cpp @@ -19,6 +19,7 @@ cRechercheWindow::cRechercheWindow(QWidget *parent) : cMDISubWindow(parent), ui(new Ui::cRechercheWindow), + m_lpMainWindow((cMainWindow*)parent), m_lpRecherche(0) { ui->setupUi(this); @@ -34,27 +35,27 @@ cRechercheWindow::cRechercheWindow(QWidget *parent) : m_lpObjectModel = new QStandardItemModel(0, 1); ui->m_lpObjectList->setModel(m_lpObjectModel); - connect(ui->m_lpCharacterList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onCharacterDoubleClicked(QModelIndex))); - connect(ui->m_lpPlaceList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onPlaceDoubleClicked(QModelIndex))); - connect(ui->m_lpObjectList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onObjectDoubleClicked(QModelIndex))); + connect(ui->m_lpCharacterList, &cTreeView::doubleClicked, this, &cRechercheWindow::onCharacterDoubleClicked); + connect(ui->m_lpPlaceList, &cTreeView::doubleClicked, this, &cRechercheWindow::onPlaceDoubleClicked); + connect(ui->m_lpObjectList, &cTreeView::doubleClicked, this, &cRechercheWindow::onObjectDoubleClicked); - connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpLink, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpLink, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpLink, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpLink, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpDescription, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpDescription, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); - connect(ui->m_lpCharacterList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); - connect(ui->m_lpCharacterList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + connect(ui->m_lpCharacterList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus); + connect(ui->m_lpCharacterList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus); - connect(ui->m_lpObjectList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); - connect(ui->m_lpObjectList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + connect(ui->m_lpObjectList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus); + connect(ui->m_lpObjectList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus); - connect(ui->m_lpPlaceList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); - connect(ui->m_lpPlaceList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + connect(ui->m_lpPlaceList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus); + connect(ui->m_lpPlaceList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus); } cRechercheWindow::~cRechercheWindow() @@ -175,6 +176,10 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche) ui->m_lpObjectList->resizeColumnToContents(i); setWindowTitle(tr("[recherche] - ") + lpRecherche->name()); + + connect(ui->m_lpName, &cLineEdit::textChanged, this, &cRechercheWindow::onNameChanged); + connect(ui->m_lpLink, &cLineEdit::textChanged, this, &cRechercheWindow::onLinkChanged); + connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cRechercheWindow::onDescriptionChanged); } cRecherche* cRechercheWindow::recherche() @@ -205,3 +210,20 @@ void cRechercheWindow::onObjectDoubleClicked(const QModelIndex& index) if(lpObject) showObjectWindow(lpObject); } + +void cRechercheWindow::onNameChanged(const QString& szName) +{ + m_lpRecherche->setName(szName); + m_lpMainWindow->somethingChanged(); +} + +void cRechercheWindow::onLinkChanged(const QString& szName) +{ + m_lpRecherche->setLink(szName); + m_lpMainWindow->somethingChanged(); +} + +void cRechercheWindow::onDescriptionChanged() +{ + m_lpMainWindow->somethingChanged(); +} diff --git a/crecherchewindow.h b/crecherchewindow.h index 8c9b7fc..17a0b0a 100644 --- a/crecherchewindow.h +++ b/crecherchewindow.h @@ -5,6 +5,7 @@ #include "crecherche.h" #include "cmdisubwindow.h" +#include "cmainwindow.h" #include #include @@ -76,6 +77,21 @@ private slots: */ void onObjectDoubleClicked(const QModelIndex& index); + void onNameChanged(const QString& szName); + /*! + \brief + + \fn onLinkChanged + \param szName + */ + void onLinkChanged(const QString& szName); + /*! + \brief + + \fn onDescriptionChanged + */ + void onDescriptionChanged(); + signals: /*! \brief @@ -101,6 +117,7 @@ signals: private: Ui::cRechercheWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ QStandardItemModel* m_lpCharacterModel; /*!< TODO: describe */ QStandardItemModel* m_lpPlaceModel; /*!< TODO: describe */ QStandardItemModel* m_lpObjectModel; /*!< TODO: describe */ diff --git a/cscenewindow.cpp b/cscenewindow.cpp index 6155a8b..8f3269c 100644 --- a/cscenewindow.cpp +++ b/cscenewindow.cpp @@ -16,6 +16,7 @@ cSceneWindow::cSceneWindow(QWidget *parent) : cMDISubWindow(parent), ui(new Ui::cSceneWindow), + m_lpMainWindow((cMainWindow*)parent), m_lpScene(0) { ui->setupUi(this); @@ -46,47 +47,46 @@ cSceneWindow::cSceneWindow(QWidget *parent) : ui->m_lpState->addItem(cScene::stateText(cScene::STATE_unknown), cScene::STATE_unknown); ui->m_lpState->setItemData(4, QBrush(cScene::stateColor(cScene::STATE_unknown)), Qt::BackgroundColorRole); - connect(ui->m_lpState, SIGNAL(currentIndexChanged(int)), this, SLOT(onStateCurrentIndexChanged(int))); - connect(ui->m_lpCharacterList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onCharacterDoubleClicked(QModelIndex))); - connect(ui->m_lpPlaceList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onPlaceDoubleClicked(QModelIndex))); - connect(ui->m_lpObjectList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onObjectDoubleClicked(QModelIndex))); + connect(ui->m_lpCharacterList, &cTreeView::doubleClicked, this, &cSceneWindow::onCharacterDoubleClicked); + connect(ui->m_lpPlaceList, &cTreeView::doubleClicked, this, &cSceneWindow::onPlaceDoubleClicked); + connect(ui->m_lpObjectList, &cTreeView::doubleClicked, this, &cSceneWindow::onObjectDoubleClicked); - connect(ui->m_lpPart, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpPart, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpPart, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpPart, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpChapter, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpChapter, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpChapter, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpChapter, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpName, SIGNAL(gotFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditGotFocus(cLineEdit*))); - connect(ui->m_lpName, SIGNAL(lostFocus(cLineEdit*)), (cMainWindow*)parent, SLOT(onLineEditLostFocus(cLineEdit*))); + connect(ui->m_lpName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); + connect(ui->m_lpName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); - connect(ui->m_lpDescription, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpDescription, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpDescription, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpDescription, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); - connect(ui->m_lpCharacterList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); - connect(ui->m_lpCharacterList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + connect(ui->m_lpCharacterList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus); + connect(ui->m_lpCharacterList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus); - connect(ui->m_lpObjectList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); - connect(ui->m_lpObjectList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + connect(ui->m_lpObjectList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus); + connect(ui->m_lpObjectList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus); - connect(ui->m_lpPlaceList, SIGNAL(gotFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewGotFocus(cTreeView*))); - connect(ui->m_lpPlaceList, SIGNAL(lostFocus(cTreeView*)), (cMainWindow*)parent, SLOT(onTreeViewLostFocus(cTreeView*))); + connect(ui->m_lpPlaceList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus); + connect(ui->m_lpPlaceList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus); - connect(ui->m_lpState, SIGNAL(gotFocus(cComboBox*)), (cMainWindow*)parent, SLOT(onComboBoxGotFocus(cComboBox*))); - connect(ui->m_lpState, SIGNAL(lostFocus(cComboBox*)), (cMainWindow*)parent, SLOT(onComboBoxLostFocus(cComboBox*))); + connect(ui->m_lpState, &cComboBox::gotFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxGotFocus); + connect(ui->m_lpState, &cComboBox::lostFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxLostFocus); - connect(ui->m_lpStartedAt, SIGNAL(gotFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditGotFocus(cDateTimeEdit*))); - connect(ui->m_lpStartedAt, SIGNAL(lostFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditLostFocus(cDateTimeEdit*))); + connect(ui->m_lpStartedAt, &cDateTimeEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditGotFocus); + connect(ui->m_lpStartedAt, &cDateTimeEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditLostFocus); - connect(ui->m_lpFinishedAt, SIGNAL(gotFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditGotFocus(cDateTimeEdit*))); - connect(ui->m_lpFinishedAt, SIGNAL(lostFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditLostFocus(cDateTimeEdit*))); + connect(ui->m_lpFinishedAt, &cDateTimeEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditGotFocus); + connect(ui->m_lpFinishedAt, &cDateTimeEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditLostFocus); - connect(ui->m_lpTargetDate, SIGNAL(gotFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditGotFocus(cDateTimeEdit*))); - connect(ui->m_lpTargetDate, SIGNAL(lostFocus(cDateTimeEdit*)), (cMainWindow*)parent, SLOT(onDateTimeEditLostFocus(cDateTimeEdit*))); + connect(ui->m_lpTargetDate, &cDateTimeEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditGotFocus); + connect(ui->m_lpTargetDate, &cDateTimeEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onDateTimeEditLostFocus); - connect(ui->m_lpText, SIGNAL(gotFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditGotFocus(cTextEdit*))); - connect(ui->m_lpText, SIGNAL(lostFocus(cTextEdit*)), (cMainWindow*)parent, SLOT(onTextEditLostFocus(cTextEdit*))); + connect(ui->m_lpText, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus); + connect(ui->m_lpText, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus); } cSceneWindow::~cSceneWindow() @@ -211,6 +211,14 @@ void cSceneWindow::setScene(cScene* lpScene) ui->m_lpObjectList->resizeColumnToContents(i); setWindowTitle(tr("[scene] - ") + lpScene->name()); + + connect(ui->m_lpName, &cLineEdit::textChanged, this, &cSceneWindow::onNameChanged); + connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cSceneWindow::onDescriptionChanged); + connect(ui->m_lpState, QOverload::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onStateChanged); + 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_lpText, &cTextEdit::textChanged, this, &cSceneWindow::onTextChanged); } cScene* cSceneWindow::scene() @@ -218,14 +226,6 @@ cScene* cSceneWindow::scene() return(m_lpScene); } -void cSceneWindow::onStateCurrentIndexChanged(int /*index*/) -{ - QBrush brush = qvariant_cast(ui->m_lpState->currentData(Qt::BackgroundColorRole)); - QColor color = brush.color(); - - ui->m_lpState->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(color.red()).arg(color.green()).arg(color.blue())); -} - void cSceneWindow::onCharacterDoubleClicked(const QModelIndex& index) { QStandardItem* lpItem = m_lpCharacterModel->itemFromIndex(index); @@ -249,3 +249,65 @@ void cSceneWindow::onObjectDoubleClicked(const QModelIndex& index) if(lpObject) showObjectWindow(lpObject); } + +void cSceneWindow::onNameChanged(const QString& szName) +{ + m_lpScene->setName(szName); + m_lpMainWindow->somethingChanged(); +} + +void cSceneWindow::onDescriptionChanged() +{ + m_lpMainWindow->somethingChanged(); +} + +void cSceneWindow::onStateChanged(int index) +{ + QBrush brush = qvariant_cast(ui->m_lpState->currentData(Qt::BackgroundColorRole)); + QColor color = brush.color(); + + ui->m_lpState->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(color.red()).arg(color.green()).arg(color.blue())); + + switch(index) + { + case 0: + m_lpScene->setState(cScene::STATE_init); + break; + case 1: + m_lpScene->setState(cScene::STATE_progress); + break; + case 2: + m_lpScene->setState(cScene::STATE_delayed); + break; + case 3: + m_lpScene->setState(cScene::STATE_finished); + break; + default: + m_lpScene->setState(cScene::STATE_unknown); + break; + } + m_lpMainWindow->somethingChanged(); +} + +void cSceneWindow::onStartedChanged(const QDateTime& dateTime) +{ + m_lpScene->setStartedAt(dateTime); + m_lpMainWindow->somethingChanged(); +} + +void cSceneWindow::onFinishedChanged(const QDateTime& dateTime) +{ + m_lpScene->setFinishedAt(dateTime); + m_lpMainWindow->somethingChanged(); +} + +void cSceneWindow::onTargetDateChanged(const QDateTime& dateTime) +{ + m_lpScene->setTargetDate(dateTime); + m_lpMainWindow->somethingChanged(); +} + +void cSceneWindow::onTextChanged() +{ + m_lpMainWindow->somethingChanged(); +} diff --git a/cscenewindow.h b/cscenewindow.h index 6ae81e6..9f8df42 100644 --- a/cscenewindow.h +++ b/cscenewindow.h @@ -7,6 +7,7 @@ #include "cscene.h" #include "cmdisubwindow.h" +#include "cmainwindow.h" #include #include @@ -56,13 +57,6 @@ public: cScene* scene(); private slots: - /*! - \brief - - \fn onStateCurrentIndexChanged - \param index - */ - void onStateCurrentIndexChanged(int index); /*! \brief @@ -85,6 +79,48 @@ private slots: */ void onObjectDoubleClicked(const QModelIndex& index); + void onNameChanged(const QString& szName); + /*! + \brief + + \fn onDescriptionChanged + */ + void onDescriptionChanged(); + /*! + \brief + + \fn onStateChanged + \param index + */ + void onStateChanged(int index); + /*! + \brief + + \fn onStartedChanged + \param dateTime + */ + void onStartedChanged(const QDateTime& dateTime); + /*! + \brief + + \fn onFinishedChanged + \param dateTime + */ + void onFinishedChanged(const QDateTime& dateTime); + /*! + \brief + + \fn onTargetDateChanged + \param dateTime + */ + void onTargetDateChanged(const QDateTime& dateTime); + /*! + \brief + + \fn onTextChanged + */ + void onTextChanged(); + signals: /*! \brief @@ -110,6 +146,7 @@ signals: private: Ui::cSceneWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ QStandardItemModel* m_lpCharacterModel; /*!< TODO: describe */ QStandardItemModel* m_lpPlaceModel; /*!< TODO: describe */ QStandardItemModel* m_lpObjectModel; /*!< TODO: describe */ diff --git a/cstorybook.cpp b/cstorybook.cpp index 6e9610f..ee3783a 100644 --- a/cstorybook.cpp +++ b/cstorybook.cpp @@ -23,11 +23,6 @@ #include -//sceneCharacter -//sceneObject -//scenePlace -//config - cStoryBook::cStoryBook(const QString &szProject, QObject *parent) : QObject(parent), m_szProject(szProject), @@ -72,6 +67,41 @@ cStoryBook::~cStoryBook() m_db.close(); } +bool cStoryBook::save() +{ + if(!m_db.isOpen()) + return(false); + + if(!saveImageList()) + return(false); + + if(!saveCharacterList()) + return(false); + + if(!savePlaceList()) + return(false); + + if(!saveObjectList()) + return(false); + + if(!saveBook()) + return(false); + + if(!savePartList()) + return(false); + + if(!saveChapterList()) + return(false); + + if(!saveSceneList()) + return(false); + + if(!saveRechercheList()) + return(false); + + return(true); +} + bool cStoryBook::openDatabase() { QFile file(m_szProject); @@ -384,6 +414,51 @@ bool cStoryBook::loadImageList() return(m_imageList.load()); } +bool cStoryBook::saveBook() +{ + return(m_book.save()); +} + +bool cStoryBook::savePartList() +{ + return(m_partList.save()); +} + +bool cStoryBook::saveChapterList() +{ + return(m_chapterList.save()); +} + +bool cStoryBook::saveSceneList() +{ + return(m_sceneList.save()); +} + +bool cStoryBook::saveCharacterList() +{ + return(m_characterList.save()); +} + +bool cStoryBook::savePlaceList() +{ + return(m_placeList.save()); +} + +bool cStoryBook::saveObjectList() +{ + return(m_objectList.save()); +} + +bool cStoryBook::saveRechercheList() +{ + return(m_rechercheList.save()); +} + +bool cStoryBook::saveImageList() +{ + return(m_imageList.save()); +} + QString cStoryBook::title() { if(!m_bIsOpen) diff --git a/cstorybook.h b/cstorybook.h index b78c0c8..b8bc536 100644 --- a/cstorybook.h +++ b/cstorybook.h @@ -50,6 +50,8 @@ public: */ ~cStoryBook(); + bool save(); + /*! \brief @@ -244,6 +246,64 @@ private: \return bool */ bool loadImageList(); + + bool saveBook(); + /*! + \brief + + \fn savePartList + \return bool + */ + bool savePartList(); + /*! + \brief + + \fn saveChapterList + \return bool + */ + bool saveChapterList(); + /*! + \brief + + \fn saveSceneList + \return bool + */ + bool saveSceneList(); + /*! + \brief + + \fn saveCharacterList + \return bool + */ + bool saveCharacterList(); + /*! + \brief + + \fn savePlaceList + \return bool + */ + bool savePlaceList(); + /*! + \brief + + \fn saveObjectList + \return bool + */ + bool saveObjectList(); + /*! + \brief + + \fn saveRechercheList + \return bool + */ + bool saveRechercheList(); + /*! + \brief + + \fn saveImageList + \return bool + */ + bool saveImageList(); }; #endif // CSTORYBOOK_H