diff --git a/cchapter.h b/cchapter.h index 5e8f40e..fa29b54 100644 --- a/cchapter.h +++ b/cchapter.h @@ -156,14 +156,14 @@ public: bool deleted(); private: - qint32 m_iID; /*!< TODO: describe */ - cPart* m_lpPart; /*!< TODO: describe */ - QString m_szName; /*!< TODO: describe */ - qint32 m_iSortOrder; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ - cTextDocument* m_lpText; /*!< TODO: describe */ - QStandardItem* m_lpItem; /*!< TODO: describe */ - bool m_bDeleted; /*!< TODO: describe */ + qint32 m_iID; /*!< TODO: describe */ + cPart* m_lpPart; /*!< TODO: describe */ + QString m_szName; /*!< TODO: describe */ + qint32 m_iSortOrder; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ + cTextDocument* m_lpText; /*!< TODO: describe */ + QStandardItem* m_lpItem; /*!< TODO: describe */ + bool m_bDeleted; /*!< TODO: describe */ }; Q_DECLARE_METATYPE(cChapter*) diff --git a/cchapterwindow.h b/cchapterwindow.h index 5430d3c..16411eb 100644 --- a/cchapterwindow.h +++ b/cchapterwindow.h @@ -96,11 +96,11 @@ signals: void showSceneWindow(cScene* lpScene); private: - Ui::cChapterWindow* ui; /*!< TODO: describe */ - cMainWindow* m_lpMainWindow; /*!< TODO: describe */ - cChapter* m_lpChapter; /*!< TODO: describe */ - cSceneList* m_lpSceneList; /*!< TODO: describe */ - QStandardItemModel* m_lpSceneModel; /*!< TODO: describe */ + Ui::cChapterWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ + cChapter* m_lpChapter; /*!< TODO: describe */ + cSceneList* m_lpSceneList; /*!< TODO: describe */ + QStandardItemModel* m_lpSceneModel; /*!< TODO: describe */ }; #endif // CCHAPTERWINDOW_H diff --git a/ccharacter.h b/ccharacter.h index 6fd0851..17f7af4 100644 --- a/ccharacter.h +++ b/ccharacter.h @@ -476,33 +476,33 @@ public: */ QList images(); private: - qint32 m_id; /*!< TODO: describe */ - bool m_bMainCharacter; /*!< TODO: describe */ - QString m_szCreature; /*!< TODO: describe */ - GENDER m_gender; /*!< TODO: describe */ - QString m_szTitle; /*!< TODO: describe */ - QString m_szFirstName; /*!< TODO: describe */ - QString m_szMiddleName; /*!< TODO: describe */ - QString m_szLastName; /*!< TODO: describe */ - QString m_szNickName; /*!< TODO: describe */ - qreal m_dHeight; /*!< TODO: describe */ - qreal m_dWeight; /*!< TODO: describe */ - qreal m_dAge; /*!< TODO: describe */ - QDate m_dateOfBirth; /*!< TODO: describe */ - QString m_szPlaceOfBirth; /*!< TODO: describe */ - QDate m_dateOfDeath; /*!< TODO: describe */ - QString m_szPlaceOfDeath; /*!< TODO: describe */ - QString m_szHairColor; /*!< TODO: describe */ - QString m_szHairCut; /*!< TODO: describe */ - QString m_szHairLength; /*!< TODO: describe */ - QString m_szFigure; /*!< TODO: describe */ - QString m_szNature; /*!< TODO: describe */ - QString m_szSpokenLanguages; /*!< TODO: describe */ - QString m_szSkin; /*!< TODO: describe */ - QString m_szSchool; /*!< TODO: describe */ - QString m_szJob; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ - QList m_imageList; /*!< TODO: describe */ + qint32 m_id; /*!< TODO: describe */ + bool m_bMainCharacter; /*!< TODO: describe */ + QString m_szCreature; /*!< TODO: describe */ + GENDER m_gender; /*!< TODO: describe */ + QString m_szTitle; /*!< TODO: describe */ + QString m_szFirstName; /*!< TODO: describe */ + QString m_szMiddleName; /*!< TODO: describe */ + QString m_szLastName; /*!< TODO: describe */ + QString m_szNickName; /*!< TODO: describe */ + qreal m_dHeight; /*!< TODO: describe */ + qreal m_dWeight; /*!< TODO: describe */ + qreal m_dAge; /*!< TODO: describe */ + QDate m_dateOfBirth; /*!< TODO: describe */ + QString m_szPlaceOfBirth; /*!< TODO: describe */ + QDate m_dateOfDeath; /*!< TODO: describe */ + QString m_szPlaceOfDeath; /*!< TODO: describe */ + QString m_szHairColor; /*!< TODO: describe */ + QString m_szHairCut; /*!< TODO: describe */ + QString m_szHairLength; /*!< TODO: describe */ + QString m_szFigure; /*!< TODO: describe */ + QString m_szNature; /*!< TODO: describe */ + QString m_szSpokenLanguages; /*!< TODO: describe */ + QString m_szSkin; /*!< TODO: describe */ + QString m_szSchool; /*!< TODO: describe */ + QString m_szJob; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ + QList m_imageList; /*!< TODO: describe */ signals: public slots: @@ -549,8 +549,8 @@ public: */ cTextDocument* description(); private: - cCharacter* m_lpCharacter; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ + cCharacter* m_lpCharacter; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ }; Q_DECLARE_METATYPE(cCharacter*) diff --git a/ccharacterselectdialog.cpp b/ccharacterselectdialog.cpp new file mode 100644 index 0000000..28fc4ff --- /dev/null +++ b/ccharacterselectdialog.cpp @@ -0,0 +1,100 @@ +#include "ccharacterselectdialog.h" +#include "ui_ccharacterselectdialog.h" + + +cCharacterSelectDialog::cCharacterSelectDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::cCharacterSelectDialog) +{ + ui->setupUi(this); + + m_lpCharacterListModel = new QStandardItemModel(0, 1); + ui->m_lpCharacterList->setModel(m_lpCharacterListModel); + + connect(ui->m_lpCharacterList, &QTreeView::doubleClicked, this, &cCharacterSelectDialog::onCharacterDoubleClicked); +} + +cCharacterSelectDialog::~cCharacterSelectDialog() +{ + delete ui; +} + +void cCharacterSelectDialog::setCharacterList(cCharacterList* lpCharacterList, QList characterDescriptionList) +{ + QStandardItemModel* lpModel = m_lpCharacterListModel; + QStandardItem* lpRootItem = lpModel->invisibleRootItem(); + QFont fontMainCharacter = lpRootItem->font(); + QFont fontNonMainCharacter = lpRootItem->font(); + + lpModel->clear(); + + QStringList headerLabels = QStringList() << tr("name") << tr("creature") << tr("gender"); + m_lpCharacterListModel->setHorizontalHeaderLabels(headerLabels); + + fontMainCharacter.setBold(true); + fontNonMainCharacter.setItalic(true); + + for(int x = 0;x < lpCharacterList->count();x++) + { + bool bFound = false; + cCharacter* lpCharacter = lpCharacterList->at(x); + + for(int y = 0;y < characterDescriptionList.count();y++) + { + if(lpCharacter == characterDescriptionList.at(y)->character()) + { + bFound = true; + break; + } + } + + if(bFound) + continue; + + QList lpItems; + + lpItems.append(new QStandardItem(lpCharacter->name())); + lpItems.append(new QStandardItem(lpCharacter->creature())); + lpItems.append(new QStandardItem(lpCharacter->genderText())); + + for(int i = 0;i < headerLabels.count();i++) + { + lpItems[i]->setData(QVariant::fromValue(lpCharacter)); + if(lpCharacter->mainCharacter()) + lpItems[i]->setFont(fontMainCharacter); + else + lpItems[i]->setFont(fontNonMainCharacter); + + if(lpCharacter->description()) + lpItems[i]->setToolTip(lpCharacter->description()->toPlainText()); + } + + m_lpCharacterListModel->appendRow(lpItems); + } + + ui->m_lpCharacterList->header()->setStretchLastSection(true); + + ui->m_lpCharacterList->expandAll(); + + for(int i = 0;i < headerLabels.count();i++) + ui->m_lpCharacterList->resizeColumnToContents(i); + + ui->m_lpCharacterList->setCurrentIndex(m_lpCharacterListModel->index(0, 0)); +} + +void cCharacterSelectDialog::onCharacterDoubleClicked(const QModelIndex& /*index*/) +{ + this->accept(); +} + +cCharacter* cCharacterSelectDialog::selected() +{ + if(!ui->m_lpCharacterList->currentIndex().isValid()) + return(0); + + QStandardItem* lpItem = m_lpCharacterListModel->itemFromIndex(ui->m_lpCharacterList->currentIndex()); + if(!lpItem) + return(0); + + return(qvariant_cast(lpItem->data())); +} diff --git a/ccharacterselectdialog.h b/ccharacterselectdialog.h new file mode 100644 index 0000000..25722e2 --- /dev/null +++ b/ccharacterselectdialog.h @@ -0,0 +1,69 @@ +#ifndef CCHARACTERSELECTDIALOG_H +#define CCHARACTERSELECTDIALOG_H + + +#include "ccharacter.h" + +#include +#include +#include + + +namespace Ui { +class cCharacterSelectDialog; +} + +/*! + \brief + + \class cCharacterSelectDialog ccharacterselectdialog.h "ccharacterselectdialog.h" +*/ +class cCharacterSelectDialog : public QDialog +{ + Q_OBJECT + +public: + /*! + \brief + + \fn cCharacterSelectDialog + \param parent + */ + explicit cCharacterSelectDialog(QWidget *parent = 0); + /*! + \brief + + \fn ~cCharacterSelectDialog + */ + ~cCharacterSelectDialog(); + + /*! + \brief + + \fn setCharacterList + \param lpCharacterList + \param characterDescriptionList + */ + void setCharacterList(cCharacterList* lpCharacterList, QList characterDescriptionList); + /*! + \brief + + \fn selected + \return cCharacter + */ + cCharacter* selected(); +private: + Ui::cCharacterSelectDialog* ui; /*!< TODO: describe */ + QStandardItemModel* m_lpCharacterListModel; /*!< TODO: describe */ + +private slots: + /*! + \brief + + \fn onCharacterDoubleClicked + \param index + */ + void onCharacterDoubleClicked(const QModelIndex& index); +}; + +#endif // CCHARACTERSELECTDIALOG_H diff --git a/ccharacterselectdialog.ui b/ccharacterselectdialog.ui new file mode 100644 index 0000000..b659c0b --- /dev/null +++ b/ccharacterselectdialog.ui @@ -0,0 +1,77 @@ + + + cCharacterSelectDialog + + + + 0 + 0 + 400 + 300 + + + + Select Character + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + cCharacterSelectDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + cCharacterSelectDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/ccharacterwindow.h b/ccharacterwindow.h index fda2156..f8ee7d2 100644 --- a/ccharacterwindow.h +++ b/ccharacterwindow.h @@ -235,9 +235,9 @@ private slots: void onDescriptionChanged(); private: - Ui::cCharacterWindow* ui; /*!< TODO: describe */ - cMainWindow* m_lpMainWindow; /*!< TODO: describe */ - cCharacter* m_lpCharacter; /*!< TODO: describe */ + Ui::cCharacterWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ + cCharacter* m_lpCharacter; /*!< TODO: describe */ }; #endif // CCHARACTERWINDOW_H diff --git a/cobject.h b/cobject.h index fd147b9..66890c1 100644 --- a/cobject.h +++ b/cobject.h @@ -111,11 +111,11 @@ public: QList images(); private: - qint32 m_iID; /*!< TODO: describe */ - QString m_szName; /*!< TODO: describe */ - QString m_szType; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ - QList m_imageList; /*!< TODO: describe */ + qint32 m_iID; /*!< TODO: describe */ + QString m_szName; /*!< TODO: describe */ + QString m_szType; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ + QList m_imageList; /*!< TODO: describe */ signals: @@ -163,8 +163,8 @@ public: */ cTextDocument* description(); private: - cObject* m_lpObject; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ + cObject* m_lpObject; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ }; Q_DECLARE_METATYPE(cObject*) diff --git a/cobjectwindow.h b/cobjectwindow.h index 243cbed..8ade01a 100644 --- a/cobjectwindow.h +++ b/cobjectwindow.h @@ -77,9 +77,9 @@ private slots: void onDescriptionChanged(); private: - Ui::cObjectWindow* ui; /*!< TODO: describe */ - cMainWindow* m_lpMainWindow; /*!< TODO: describe */ - cObject* m_lpObject; /*!< TODO: describe */ + Ui::cObjectWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ + cObject* m_lpObject; /*!< TODO: describe */ }; #endif // COBJECTWINDOW_H diff --git a/cpart.h b/cpart.h index a376971..02cad2d 100644 --- a/cpart.h +++ b/cpart.h @@ -140,13 +140,13 @@ public: bool deleted(); private: - qint32 m_iID; /*!< TODO: describe */ - QString m_szName; /*!< TODO: describe */ - qint32 m_iSortOrder; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ - cTextDocument* m_lpText; /*!< TODO: describe */ - QStandardItem* m_lpItem; /*!< TODO: describe */ - bool m_bDeleted; /*!< TODO: describe */ + qint32 m_iID; /*!< TODO: describe */ + QString m_szName; /*!< TODO: describe */ + qint32 m_iSortOrder; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ + cTextDocument* m_lpText; /*!< TODO: describe */ + QStandardItem* m_lpItem; /*!< TODO: describe */ + bool m_bDeleted; /*!< TODO: describe */ }; Q_DECLARE_METATYPE(cPart*) diff --git a/cpartwindow.h b/cpartwindow.h index 43d9e6a..a822a99 100644 --- a/cpartwindow.h +++ b/cpartwindow.h @@ -95,11 +95,11 @@ signals: void showChapterWindow(cChapter* lpChapter); private: - 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 */ + 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/cplace.h b/cplace.h index c0787d5..8fa3db5 100644 --- a/cplace.h +++ b/cplace.h @@ -126,12 +126,12 @@ public: QList images(); private: - qint32 m_iID; /*!< TODO: describe */ - QString m_szName; /*!< TODO: describe */ - QString m_szLocation; /*!< TODO: describe */ - QString m_szType; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ - QList m_imageList; /*!< TODO: describe */ + qint32 m_iID; /*!< TODO: describe */ + QString m_szName; /*!< TODO: describe */ + QString m_szLocation; /*!< TODO: describe */ + QString m_szType; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ + QList m_imageList; /*!< TODO: describe */ signals: @@ -179,8 +179,8 @@ public: */ cTextDocument* description(); private: - cPlace* m_lpPlace; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ + cPlace* m_lpPlace; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ }; Q_DECLARE_METATYPE(cPlace*) diff --git a/cplacewindow.h b/cplacewindow.h index 8618dcf..6dec7f2 100644 --- a/cplacewindow.h +++ b/cplacewindow.h @@ -84,9 +84,9 @@ private slots: void onDescriptionChanged(); private: - Ui::cPlaceWindow* ui; /*!< TODO: describe */ - cMainWindow* m_lpMainWindow; /*!< TODO: describe */ - cPlace* m_lpPlace; /*!< TODO: describe */ + Ui::cPlaceWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ + cPlace* m_lpPlace; /*!< TODO: describe */ }; #endif // CPLACEWINDOW_H diff --git a/cpropertieswindow.h b/cpropertieswindow.h index e05f3a1..30aa31c 100644 --- a/cpropertieswindow.h +++ b/cpropertieswindow.h @@ -111,9 +111,9 @@ private slots: void onTargetDateChanged(const QDateTime& dateTime); private: - Ui::cPropertiesWindow* ui; /*!< TODO: describe */ - cMainWindow* m_lpMainWindow; /*!< TODO: describe */ - cBook* m_lpBook; /*!< TODO: describe */ + Ui::cPropertiesWindow* ui; /*!< TODO: describe */ + cMainWindow* m_lpMainWindow; /*!< TODO: describe */ + cBook* m_lpBook; /*!< TODO: describe */ }; #endif // CPROPERTIESWINDOW_H diff --git a/crecherche.h b/crecherche.h index 550bf3f..0a43ba0 100644 --- a/crecherche.h +++ b/crecherche.h @@ -160,14 +160,14 @@ public: QList placeList(); private: - qint32 m_iID; /*!< TODO: describe */ - QString m_szName; /*!< TODO: describe */ - QString m_szLink; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ - QList m_imageList; /*!< TODO: describe */ - QList m_characterList; /*!< TODO: describe */ - QList m_objectList; /*!< TODO: describe */ - QList m_placeList; /*!< TODO: describe */ + qint32 m_iID; /*!< TODO: describe */ + QString m_szName; /*!< TODO: describe */ + QString m_szLink; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ + QList m_imageList; /*!< TODO: describe */ + QList m_characterList; /*!< TODO: describe */ + QList m_objectList; /*!< TODO: describe */ + QList m_placeList; /*!< TODO: describe */ signals: diff --git a/crecherchewindow.h b/crecherchewindow.h index 4406211..aeee27c 100644 --- a/crecherchewindow.h +++ b/crecherchewindow.h @@ -122,12 +122,12 @@ signals: void showObjectWindow(cObject* lpObject); 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 */ - cRecherche* m_lpRecherche; /*!< TODO: describe */ + 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 */ + cRecherche* m_lpRecherche; /*!< TODO: describe */ }; #endif // CRECHERCHEWINDOW_H diff --git a/cscene.h b/cscene.h index b19345a..271cfef 100644 --- a/cscene.h +++ b/cscene.h @@ -329,22 +329,22 @@ public: bool deleted(); private: - qint32 m_iID; /*!< TODO: describe */ - cChapter* m_lpChapter; /*!< TODO: describe */ - QString m_szName; /*!< TODO: describe */ - qint32 m_iSortOrder; /*!< TODO: describe */ - cTextDocument* m_lpDescription; /*!< TODO: describe */ - STATE m_state; /*!< TODO: describe */ - QDateTime m_startedAt; /*!< TODO: describe */ - QDateTime m_finishedAt; /*!< TODO: describe */ - QDateTime m_targetDate; /*!< TODO: describe */ - cTextDocument* m_lpText; /*!< TODO: describe */ - QList m_characterList; /*!< TODO: describe */ - QList m_objectList; /*!< TODO: describe */ - QList m_placeList; /*!< TODO: describe */ - QStandardItem* m_lpItem; /*!< TODO: describe */ - QStandardItem* m_lpStateItem; /*!< TODO: describe */ - bool m_bDeleted; /*!< TODO: describe */ + qint32 m_iID; /*!< TODO: describe */ + cChapter* m_lpChapter; /*!< TODO: describe */ + QString m_szName; /*!< TODO: describe */ + qint32 m_iSortOrder; /*!< TODO: describe */ + cTextDocument* m_lpDescription; /*!< TODO: describe */ + STATE m_state; /*!< TODO: describe */ + QDateTime m_startedAt; /*!< TODO: describe */ + QDateTime m_finishedAt; /*!< TODO: describe */ + QDateTime m_targetDate; /*!< TODO: describe */ + cTextDocument* m_lpText; /*!< TODO: describe */ + QList m_characterList; /*!< TODO: describe */ + QList m_objectList; /*!< TODO: describe */ + QList m_placeList; /*!< TODO: describe */ + QStandardItem* m_lpItem; /*!< TODO: describe */ + QStandardItem* m_lpStateItem; /*!< TODO: describe */ + bool m_bDeleted; /*!< TODO: describe */ }; Q_DECLARE_METATYPE(cScene*) diff --git a/cscenewindow.cpp b/cscenewindow.cpp index 316d299..fabbd20 100644 --- a/cscenewindow.cpp +++ b/cscenewindow.cpp @@ -6,6 +6,8 @@ #include "cscenewindow.h" #include "ui_cscenewindow.h" +#include "ccharacterselectdialog.h" + #include "cmainwindow.h" #include "common.h" @@ -146,6 +148,9 @@ void cSceneWindow::setScene(cScene* lpScene, cCharacterList* lpCharacterList, cP ui->m_lpCharacterList->setCurrentText(0); ui->m_lpCharacterDetails->setCurrentIndex(0); + ui->m_lpCharacterRemove->setEnabled((characterList.count() > 0)); + ui->m_lpCharacterShowDetails->setEnabled((characterList.count() > 0)); + for(int x = 0;x < placeList.count();x++) { cPlaceDescription* lpPlaceDescription = placeList[x]; @@ -164,6 +169,9 @@ void cSceneWindow::setScene(cScene* lpScene, cCharacterList* lpCharacterList, cP ui->m_lpPlaceList->setCurrentText(0); ui->m_lpPlaceDetails->setCurrentIndex(0); + ui->m_lpPlaceRemove->setEnabled((characterList.count() > 0)); + ui->m_lpPlaceShowDetails->setEnabled((characterList.count() > 0)); + for(int x = 0;x < objectList.count();x++) { cObjectDescription* lpObjectDescription = objectList[x]; @@ -182,6 +190,9 @@ void cSceneWindow::setScene(cScene* lpScene, cCharacterList* lpCharacterList, cP ui->m_lpObjectList->setCurrentText(0); ui->m_lpObjectDetails->setCurrentIndex(0); + ui->m_lpObjectRemove->setEnabled((characterList.count() > 0)); + ui->m_lpObjectShowDetails->setEnabled((characterList.count() > 0)); + connect(ui->m_lpCharacterList, QOverload::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onCharacterIndexChanged); connect(ui->m_lpPlaceList, QOverload::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onPlaceIndexChanged); connect(ui->m_lpObjectList, QOverload::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onObjectIndexChanged); @@ -333,24 +344,83 @@ void cSceneWindow::onObjectIndexChanged(int index) void cSceneWindow::onAddCharacterToList() { + cCharacterSelectDialog* lpDialog = new cCharacterSelectDialog(this); + lpDialog->setCharacterList(m_lpCharacterList, m_lpScene->characterList()); + + if(lpDialog->exec() == QDialog::Rejected) + { + delete lpDialog; + return; + } + + cCharacter* lpCharacterNew = lpDialog->selected(); + delete lpDialog; + + if(!lpCharacterNew) + return; + + m_lpScene->addCharacter(lpCharacterNew, new cTextDocument(this)); + + QList characterList = m_lpScene->characterList(); + + ui->m_lpCharacterList->clear(); + + for(int x = ui->m_lpCharacterDetails->count()-1;x >= 0;x--) + ui->m_lpCharacterDetails->removeWidget(ui->m_lpCharacterDetails->widget(x)); + + qint16 index = 0; + + for(int x = 0;x < characterList.count();x++) + { + cCharacterDescription* lpCharacterDescription = characterList[x]; + cCharacter* lpCharacter = lpCharacterDescription->character(); + + ui->m_lpCharacterList->addItem(lpCharacter->name(), QVariant::fromValue(lpCharacterDescription)); + cTextEdit* lpTextEdit = new cTextEdit(ui->m_lpCharacterDetails); + lpTextEdit->setDocument(lpCharacterDescription->description()); + ui->m_lpCharacterDetails->addWidget(lpTextEdit); + + connect(lpTextEdit, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus); + connect(lpTextEdit, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus); + + connect(lpTextEdit, &cTextEdit::textChanged, this, &cSceneWindow::onCharacterDescriptionChanged); + + if(lpCharacter == lpCharacterNew) + index = x; + } + ui->m_lpCharacterList->setCurrentIndex(index); + ui->m_lpCharacterDetails->setCurrentIndex(index); + + ui->m_lpCharacterRemove->setEnabled((ui->m_lpCharacterList->count() > 0)); + ui->m_lpCharacterShowDetails->setEnabled((ui->m_lpCharacterList->count() > 0)); } void cSceneWindow::onRemoveCharacterFromList() { + ui->m_lpCharacterRemove->setEnabled((ui->m_lpCharacterList->count() > 0)); + ui->m_lpCharacterShowDetails->setEnabled((ui->m_lpCharacterList->count() > 0)); } void cSceneWindow::onAddPlaceToList() { + ui->m_lpPlaceRemove->setEnabled((ui->m_lpPlaceList->count() > 0)); + ui->m_lpPlaceShowDetails->setEnabled((ui->m_lpPlaceList->count() > 0)); } void cSceneWindow::onRemovePlaceFromList() { + ui->m_lpPlaceRemove->setEnabled((ui->m_lpPlaceList->count() > 0)); + ui->m_lpPlaceShowDetails->setEnabled((ui->m_lpPlaceList->count() > 0)); } void cSceneWindow::onAddObjectToList() { + ui->m_lpObjectRemove->setEnabled((ui->m_lpObjectList->count() > 0)); + ui->m_lpObjectShowDetails->setEnabled((ui->m_lpObjectList->count() > 0)); } void cSceneWindow::onRemoveObjectFromList() { + ui->m_lpObjectRemove->setEnabled((ui->m_lpObjectList->count() > 0)); + ui->m_lpObjectShowDetails->setEnabled((ui->m_lpObjectList->count() > 0)); } diff --git a/cscenewindow.h b/cscenewindow.h index f50b161..a571df3 100644 --- a/cscenewindow.h +++ b/cscenewindow.h @@ -169,13 +169,43 @@ private slots: */ void onObjectIndexChanged(int index); + /*! + \brief + + \fn onAddCharacterToList + */ void onAddCharacterToList(); + /*! + \brief + + \fn onRemoveCharacterFromList + */ void onRemoveCharacterFromList(); + /*! + \brief + + \fn onAddPlaceToList + */ void onAddPlaceToList(); + /*! + \brief + + \fn onRemovePlaceFromList + */ void onRemovePlaceFromList(); + /*! + \brief + + \fn onAddObjectToList + */ void onAddObjectToList(); + /*! + \brief + + \fn onRemoveObjectFromList + */ void onRemoveObjectFromList(); signals: diff --git a/cstorybook.h b/cstorybook.h index 1bc3197..6eb50e6 100644 --- a/cstorybook.h +++ b/cstorybook.h @@ -278,18 +278,18 @@ public: bool hasScene(cChapter* lpChapter); private: - QString m_szProject; /*!< TODO: describe */ - bool m_bIsOpen; /*!< TODO: describe */ - QSqlDatabase m_db; /*!< TODO: describe */ - cBook m_book; /*!< TODO: describe */ - cPartList m_partList; /*!< TODO: describe */ - cChapterList m_chapterList; /*!< TODO: describe */ - cSceneList m_sceneList; /*!< TODO: describe */ - cCharacterList m_characterList; /*!< TODO: describe */ - cPlaceList m_placeList; /*!< TODO: describe */ - cObjectList m_objectList; /*!< TODO: describe */ - cRechercheList m_rechercheList; /*!< TODO: describe */ - cImageList m_imageList; /*!< TODO: describe */ + QString m_szProject; /*!< TODO: describe */ + bool m_bIsOpen; /*!< TODO: describe */ + QSqlDatabase m_db; /*!< TODO: describe */ + cBook m_book; /*!< TODO: describe */ + cPartList m_partList; /*!< TODO: describe */ + cChapterList m_chapterList; /*!< TODO: describe */ + cSceneList m_sceneList; /*!< TODO: describe */ + cCharacterList m_characterList; /*!< TODO: describe */ + cPlaceList m_placeList; /*!< TODO: describe */ + cObjectList m_objectList; /*!< TODO: describe */ + cRechercheList m_rechercheList; /*!< TODO: describe */ + cImageList m_imageList; /*!< TODO: describe */ /*! \brief diff --git a/qtStoryWriter.pro b/qtStoryWriter.pro index 1f3cec4..fad823d 100644 --- a/qtStoryWriter.pro +++ b/qtStoryWriter.pro @@ -74,7 +74,8 @@ SOURCES += \ cdoublespinbox.cpp \ ccombobox.cpp \ cdatetimeedit.cpp \ - cpropertieswindow.cpp + cpropertieswindow.cpp \ + ccharacterselectdialog.cpp HEADERS += \ cmainwindow.h \ @@ -110,7 +111,8 @@ HEADERS += \ cdoublespinbox.h \ ccombobox.h \ cdatetimeedit.h \ - cpropertieswindow.h + cpropertieswindow.h \ + ccharacterselectdialog.h FORMS += \ cmainwindow.ui \ @@ -122,7 +124,8 @@ FORMS += \ cobjectwindow.ui \ cplacewindow.ui \ crecherchewindow.ui \ - cpropertieswindow.ui + cpropertieswindow.ui \ + ccharacterselectdialog.ui DISTFILES += \ storyBook.project \