diff --git a/cmainwindow.cpp b/cmainwindow.cpp index b26de04..560c1ea 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -4,9 +4,9 @@ #include "ctextdocument.h" #include "cpartwindow.h" -#include "cchapterwindow.h" -#include "cscenewindow.h" -#include "ccharacterwindow.h" +//#include "cchapterwindow.h" +//#include "cscenewindow.h" +//#include "ccharacterwindow.h" #include "cwidget.h" @@ -127,6 +127,9 @@ void cMainWindow::createActions() connect(ui->m_lpOutlineList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onOutlineDoubleClicked(QModelIndex))); 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_lpRechercheList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onRechercheDoubleClicked(QModelIndex))); } void cMainWindow::createFileActions() @@ -419,11 +422,11 @@ void cMainWindow::onOutlineDoubleClicked(const QModelIndex& index) cScene* lpScene = qvariant_cast(lpItem->data()); if(lpPart) - showPartWindow(lpPart); + onShowPartWindow(lpPart); else if(lpChapter) - showChapterWindow(lpChapter); + onShowChapterWindow(lpChapter); else if(lpScene) - showSceneWindow(lpScene); + onShowSceneWindow(lpScene); else QMessageBox::information(this, "DoubleClicked", "outline"); } @@ -433,10 +436,34 @@ void cMainWindow::onCharacterDoubleClicked(const QModelIndex& index) QStandardItem* lpItem = m_lpCharacterModel->itemFromIndex(index); cCharacter* lpCharacter = qvariant_cast(lpItem->data()); - showCharacterWindow(lpCharacter); + onShowCharacterWindow(lpCharacter); } -void cMainWindow::showPartWindow(cPart* lpPart) +void cMainWindow::onPlaceDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpPlaceModel->itemFromIndex(index); + cPlace* lpPlace = qvariant_cast(lpItem->data()); + + onShowPlaceWindow(lpPlace); +} + +void cMainWindow::onObjectDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpObjectModel->itemFromIndex(index); + cObject* lpObject = qvariant_cast(lpItem->data()); + + onShowObjectWindow(lpObject); +} + +void cMainWindow::onRechercheDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpRechercheModel->itemFromIndex(index); + cRecherche* lpRecherche = qvariant_cast(lpItem->data()); + + onShowRechercheWindow(lpRecherche); +} + +void cMainWindow::onShowPartWindow(cPart* lpPart) { for(int x = 0;x < ui->m_lpMainTab->count();x++) { @@ -463,7 +490,7 @@ void cMainWindow::showPartWindow(cPart* lpPart) lpPartWindow->show(); } -void cMainWindow::showChapterWindow(cChapter* lpChapter) +void cMainWindow::onShowChapterWindow(cChapter* lpChapter) { for(int x = 0;x < ui->m_lpMainTab->count();x++) { @@ -490,7 +517,7 @@ void cMainWindow::showChapterWindow(cChapter* lpChapter) lpChapterWindow->show(); } -void cMainWindow::showSceneWindow(cScene* lpScene) +void cMainWindow::onShowSceneWindow(cScene* lpScene) { for(int x = 0;x < ui->m_lpMainTab->count();x++) { @@ -514,10 +541,14 @@ void cMainWindow::showSceneWindow(cScene* lpScene) lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpSceneWindow)); ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpSceneWindow->windowTitle()); + connect(lpSceneWindow, SIGNAL(showCharacterWindow(cCharacter*)), this, SLOT(onShowCharacterWindow(cCharacter*))); + connect(lpSceneWindow, SIGNAL(showPlaceWindow(cPlace*)), this, SLOT(onShowPlaceWindow(cPlace*))); + connect(lpSceneWindow, SIGNAL(showObjectWindow(cObject*)), this, SLOT(onShowObjectWindow(cObject*))); + lpSceneWindow->show(); } -void cMainWindow::showCharacterWindow(cCharacter* lpCharacter) +void cMainWindow::onShowCharacterWindow(cCharacter* lpCharacter) { for(int x = 0;x < ui->m_lpMainTab->count();x++) { @@ -544,6 +575,91 @@ void cMainWindow::showCharacterWindow(cCharacter* lpCharacter) lpCharacterWindow->show(); } +void cMainWindow::onShowPlaceWindow(cPlace* lpPlace) +{ + for(int x = 0;x < ui->m_lpMainTab->count();x++) + { + cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->widget(x); + if(lpWidget->type() == cWidget::TYPE_place) + { + cPlaceWindow* lpPlaceWindow = (cPlaceWindow*)lpWidget->widget(); + if(lpPlaceWindow->place() == lpPlace) + { + ui->m_lpMainTab->setCurrentIndex(x); + ui->m_lpMdiArea->setActiveSubWindow(lpWidget->window()); + m_bUpdatingTab = false; + return; + } + } + } + + cPlaceWindow* lpPlaceWindow = new cPlaceWindow(this); + lpPlaceWindow->setPlace(lpPlace); + cWidget* lpWidget1 = new cWidget(lpPlaceWindow); + lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpPlaceWindow)); + ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpPlaceWindow->windowTitle()); + + lpPlaceWindow->show(); +} + +void cMainWindow::onShowObjectWindow(cObject* lpObject) +{ + for(int x = 0;x < ui->m_lpMainTab->count();x++) + { + cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->widget(x); + if(lpWidget->type() == cWidget::TYPE_object) + { + cObjectWindow* lpObjectWindow = (cObjectWindow*)lpWidget->widget(); + if(lpObjectWindow->object() == lpObject) + { + ui->m_lpMainTab->setCurrentIndex(x); + ui->m_lpMdiArea->setActiveSubWindow(lpWidget->window()); + m_bUpdatingTab = false; + return; + } + } + } + + cObjectWindow* lpObjectWindow = new cObjectWindow(this); + lpObjectWindow->setObject(lpObject); + cWidget* lpWidget1 = new cWidget(lpObjectWindow); + lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpObjectWindow)); + ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpObjectWindow->windowTitle()); + + lpObjectWindow->show(); +} + +void cMainWindow::onShowRechercheWindow(cRecherche* lpRecherche) +{ + for(int x = 0;x < ui->m_lpMainTab->count();x++) + { + cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->widget(x); + if(lpWidget->type() == cWidget::TYPE_recherche) + { + cRechercheWindow* lpRechercheWindow = (cRechercheWindow*)lpWidget->widget(); + if(lpRechercheWindow->recherche() == lpRecherche) + { + ui->m_lpMainTab->setCurrentIndex(x); + ui->m_lpMdiArea->setActiveSubWindow(lpWidget->window()); + m_bUpdatingTab = false; + return; + } + } + } + + cRechercheWindow* lpRechercheWindow = new cRechercheWindow(this); + lpRechercheWindow->setRecherche(lpRecherche); + cWidget* lpWidget1 = new cWidget(lpRechercheWindow); + lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpRechercheWindow)); + ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpRechercheWindow->windowTitle()); + + connect(lpRechercheWindow, SIGNAL(showCharacterWindow(cCharacter*)), this, SLOT(onShowCharacterWindow(cCharacter*))); + connect(lpRechercheWindow, SIGNAL(showPlaceWindow(cPlace*)), this, SLOT(onShowPlaceWindow(cPlace*))); + connect(lpRechercheWindow, SIGNAL(showObjectWindow(cObject*)), this, SLOT(onShowObjectWindow(cObject*))); + + lpRechercheWindow->show(); +} + void cMainWindow::onFileNew() { } diff --git a/cmainwindow.h b/cmainwindow.h index 8c9a59a..1aed42d 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -36,6 +36,17 @@ private slots: void onOutlineDoubleClicked(const QModelIndex& index); void onCharacterDoubleClicked(const QModelIndex& index); + void onPlaceDoubleClicked(const QModelIndex& index); + void onObjectDoubleClicked(const QModelIndex& index); + void onRechercheDoubleClicked(const QModelIndex& index); + + void onShowPartWindow(cPart* lpPart); + void onShowChapterWindow(cChapter* lpChapter); + void onShowSceneWindow(cScene* lpScene); + void onShowCharacterWindow(cCharacter* lpCharacter); + void onShowPlaceWindow(cPlace* lpPlace); + void onShowObjectWindow(cObject* lpObject); + void onShowRechercheWindow(cRecherche* lpRecherche); void onFileNew(); void onFileOpen(); @@ -102,11 +113,6 @@ private: void createEditActions(); void createTextActions(); - void showPartWindow(cPart* lpPart); - void showChapterWindow(cChapter* lpChapter); - void showSceneWindow(cScene* lpScene); - void showCharacterWindow(cCharacter* lpCharacter); - protected: void closeEvent(QCloseEvent *event); }; diff --git a/cobject.cpp b/cobject.cpp index 0708468..c6775fc 100644 --- a/cobject.cpp +++ b/cobject.cpp @@ -62,6 +62,11 @@ void cObject::addImage(cImage* lpImage) m_imageList.append(lpImage); } +QList cObject::images() +{ + return(m_imageList); +} + cObject* cObjectList::add(const qint32& iID) { cObject* lpObject = find(iID); diff --git a/cobject.h b/cobject.h index 47324fd..52b969d 100644 --- a/cobject.h +++ b/cobject.h @@ -30,6 +30,7 @@ public: cTextDocument* description(); void addImage(cImage* lpImage); + QList images(); private: qint32 m_iID; diff --git a/cobjectwindow.cpp b/cobjectwindow.cpp new file mode 100644 index 0000000..c0ccc47 --- /dev/null +++ b/cobjectwindow.cpp @@ -0,0 +1,50 @@ +#include "cobjectwindow.h" +#include "ui_cobjectwindow.h" + +#include "cimagewidget.h" + +#include + + +cObjectWindow::cObjectWindow(QWidget *parent) : + QWidget(parent), + ui(new Ui::cObjectWindow), + m_lpObject(0) +{ + ui->setupUi(this); +} + +cObjectWindow::~cObjectWindow() +{ + delete ui; +} + +void cObjectWindow::setObject(cObject* lpObject) +{ + m_lpObject = lpObject; + + ui->m_lpName->setText(lpObject->name()); + ui->m_lpType->setText(lpObject->type()); + ui->m_lpDescription->setDocument(lpObject->description()); + + QList images = lpObject->images(); + for(int x = 0;x < images.count();x++) + { + cImage* lpImage = images[x]; + QPixmap pixmap = lpImage->load(); + cImageWidget* lpImageWidget = new cImageWidget; + + lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap); + ui->m_lpLayout->addWidget(lpImageWidget); + } + + QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + ui->m_lpLayout->addItem(lpSpacer); + + setWindowTitle(tr("[object] - ") + lpObject->name()); +} + +cObject* cObjectWindow::object() +{ + return(m_lpObject); +} diff --git a/cobjectwindow.h b/cobjectwindow.h new file mode 100644 index 0000000..a16a279 --- /dev/null +++ b/cobjectwindow.h @@ -0,0 +1,31 @@ +#ifndef COBJECTWINDOW_H +#define COBJECTWINDOW_H + + +#include "cobject.h" + +#include +#include + + +namespace Ui { +class cObjectWindow; +} + +class cObjectWindow : public QWidget +{ + Q_OBJECT + +public: + explicit cObjectWindow(QWidget *parent = 0); + ~cObjectWindow(); + + void setObject(cObject* lpObject); + cObject* object(); + +private: + Ui::cObjectWindow* ui; + cObject* m_lpObject; +}; + +#endif // COBJECTWINDOW_H diff --git a/cobjectwindow.ui b/cobjectwindow.ui new file mode 100644 index 0000000..3a878f8 --- /dev/null +++ b/cobjectwindow.ui @@ -0,0 +1,124 @@ + + + cObjectWindow + + + + 0 + 0 + 725 + 528 + + + + Form + + + + + + 0 + + + + Basic + + + + + + + + + + + + + + Description: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Images + + + + + + true + + + + + 0 + 0 + 681 + 464 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + m_lpName + m_lpDescription + + + + diff --git a/cplace.cpp b/cplace.cpp index b7c7897..4d5d050 100644 --- a/cplace.cpp +++ b/cplace.cpp @@ -73,6 +73,11 @@ void cPlace::addImage(cImage* lpImage) m_imageList.append(lpImage); } +QList cPlace::images() +{ + return(m_imageList); +} + cPlace* cPlaceList::add(const qint32& iID) { cPlace* lpPlace = find(iID); diff --git a/cplace.h b/cplace.h index ff5522b..69b810a 100644 --- a/cplace.h +++ b/cplace.h @@ -33,6 +33,7 @@ public: cTextDocument* description(); void addImage(cImage* lpImage); + QList images(); private: qint32 m_iID; diff --git a/cplacewindow.cpp b/cplacewindow.cpp new file mode 100644 index 0000000..b0736e5 --- /dev/null +++ b/cplacewindow.cpp @@ -0,0 +1,51 @@ +#include "cplacewindow.h" +#include "ui_cplacewindow.h" + +#include "cimagewidget.h" + +#include + + +cPlaceWindow::cPlaceWindow(QWidget *parent) : + QWidget(parent), + ui(new Ui::cPlaceWindow), + m_lpPlace(0) +{ + ui->setupUi(this); +} + +cPlaceWindow::~cPlaceWindow() +{ + delete ui; +} + +void cPlaceWindow::setPlace(cPlace* lpPlace) +{ + m_lpPlace = lpPlace; + + ui->m_lpName->setText(lpPlace->name()); + ui->m_lpType->setText(lpPlace->type()); + ui->m_lpLocation->setText(lpPlace->location()); + ui->m_lpDescription->setDocument(lpPlace->description()); + + QList images = lpPlace->images(); + for(int x = 0;x < images.count();x++) + { + cImage* lpImage = images[x]; + QPixmap pixmap = lpImage->load(); + cImageWidget* lpImageWidget = new cImageWidget; + + lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap); + ui->m_lpLayout->addWidget(lpImageWidget); + } + + QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + ui->m_lpLayout->addItem(lpSpacer); + + setWindowTitle(tr("[place] - ") + lpPlace->name()); +} + +cPlace* cPlaceWindow::place() +{ + return(m_lpPlace); +} diff --git a/cplacewindow.h b/cplacewindow.h new file mode 100644 index 0000000..40a8722 --- /dev/null +++ b/cplacewindow.h @@ -0,0 +1,31 @@ +#ifndef CPLACEWINDOW_H +#define CPLACEWINDOW_H + + +#include "cplace.h" + +#include +#include + + +namespace Ui { +class cPlaceWindow; +} + +class cPlaceWindow : public QWidget +{ + Q_OBJECT + +public: + explicit cPlaceWindow(QWidget *parent = 0); + ~cPlaceWindow(); + + void setPlace(cPlace* lpPlace); + cPlace* place(); + +private: + Ui::cPlaceWindow* ui; + cPlace* m_lpPlace; +}; + +#endif // CPLACEWINDOW_H diff --git a/cplacewindow.ui b/cplacewindow.ui new file mode 100644 index 0000000..8399e82 --- /dev/null +++ b/cplacewindow.ui @@ -0,0 +1,141 @@ + + + cPlaceWindow + + + + 0 + 0 + 725 + 528 + + + + Form + + + + + + 0 + + + + Basic + + + + + + + + Location: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Description: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + Images + + + + + + true + + + + + 0 + 0 + 681 + 464 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + m_lpName + m_lpType + m_lpLocation + m_lpDescription + m_lpTab + m_lpScrollArea + + + + diff --git a/crecherche.cpp b/crecherche.cpp index 3ce8dfc..1fcb120 100644 --- a/crecherche.cpp +++ b/crecherche.cpp @@ -83,6 +83,26 @@ void cRecherche::addPlace(cPlace* lpPlace) m_placeList.append(lpPlace); } +QList cRecherche::images() +{ + return(m_imageList); +} + +QList cRecherche::characterList() +{ + return(m_characterList); +} + +QList cRecherche::objectList() +{ + return(m_objectList); +} + +QList cRecherche::placeList() +{ + return(m_placeList); +} + cRecherche* cRechercheList::add(const qint32& iID) { cRecherche* lpRecherche = find(iID); diff --git a/crecherche.h b/crecherche.h index 987b5b4..c7a1a72 100644 --- a/crecherche.h +++ b/crecherche.h @@ -37,6 +37,11 @@ public: void addObject(cObject* lpObject); void addPlace(cPlace* lpPlace); + QList images(); + QList characterList(); + QList objectList(); + QList placeList(); + private: qint32 m_iID; QString m_szName; diff --git a/crecherchewindow.cpp b/crecherchewindow.cpp new file mode 100644 index 0000000..c31633a --- /dev/null +++ b/crecherchewindow.cpp @@ -0,0 +1,180 @@ +#include "crecherchewindow.h" +#include "ui_crecherchewindow.h" + +#include "cimagewidget.h" + +#include + + + +cRechercheWindow::cRechercheWindow(QWidget *parent) : + QWidget(parent), + ui(new Ui::cRechercheWindow), + m_lpRecherche(0) +{ + ui->setupUi(this); + + ui->m_lpTab->setCurrentIndex(0); + + m_lpCharacterModel = new QStandardItemModel(0, 1); + ui->m_lpCharacterList->setModel(m_lpCharacterModel); + + m_lpPlaceModel = new QStandardItemModel(0, 1); + ui->m_lpPlaceList->setModel(m_lpPlaceModel); + + 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))); +} + +cRechercheWindow::~cRechercheWindow() +{ + delete ui; +} + +void cRechercheWindow::setRecherche(cRecherche* lpRecherche) +{ + m_lpRecherche = lpRecherche; + + ui->m_lpName->setText(lpRecherche->name()); + ui->m_lpLink->setText(lpRecherche->link()); + ui->m_lpDescription->setDocument(lpRecherche->description()); + + QList images = lpRecherche->images(); + for(int x = 0;x < images.count();x++) + { + cImage* lpImage = images[x]; + QPixmap pixmap = lpImage->load(); + cImageWidget* lpImageWidget = new cImageWidget; + + lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap); + ui->m_lpLayout->addWidget(lpImageWidget); + } + + QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + ui->m_lpLayout->addItem(lpSpacer); + + QList characterList = lpRecherche->characterList(); + QList placeList = lpRecherche->placeList(); + QList objectList = lpRecherche->objectList(); + + QStringList headerLabels; + + headerLabels = QStringList() << tr("name") << tr("creature") << tr("gender") << tr("title"); + m_lpCharacterModel->setHorizontalHeaderLabels(headerLabels); + for(int x = 0;x < characterList.count();x++) + { + cCharacter* lpCharacter = characterList[x]; + QList items; + + items.append(new QStandardItem(lpCharacter->name())); + items.append(new QStandardItem(lpCharacter->creature())); + items.append(new QStandardItem(lpCharacter->genderText())); + items.append(new QStandardItem(lpCharacter->title())); + + if(lpCharacter->mainCharacter()) + { + QFont font = items[0]->font(); + font.setBold(true); + + for(int y = 0;y < headerLabels.count();y++) + items[y]->setFont(font); + } + + for(int y = 0;y < headerLabels.count();y++) + { + items[y]->setData(QVariant::fromValue(lpCharacter)); + items[y]->setToolTip(lpCharacter->description()->toPlainText()); + } + + m_lpCharacterModel->appendRow(items); + } + + ui->m_lpCharacterList->header()->setStretchLastSection(true); + + for(int i = 0;i < headerLabels.count();i++) + ui->m_lpCharacterList->resizeColumnToContents(i); + + headerLabels = QStringList() << tr("name") << tr("location") << tr("type"); + m_lpPlaceModel->setHorizontalHeaderLabels(headerLabels); + for(int x = 0;x < placeList.count();x++) + { + cPlace* lpPlace = placeList[x]; + QList items; + + items.append(new QStandardItem(lpPlace->name())); + items.append(new QStandardItem(lpPlace->location())); + items.append(new QStandardItem(lpPlace->type())); + + for(int y = 0;y < headerLabels.count();y++) + { + items[y]->setData(QVariant::fromValue(lpPlace)); + items[y]->setToolTip(lpPlace->description()->toPlainText()); + } + + m_lpPlaceModel->appendRow(items); + } + + ui->m_lpPlaceList->header()->setStretchLastSection(true); + + for(int i = 0;i < headerLabels.count();i++) + ui->m_lpPlaceList->resizeColumnToContents(i); + + headerLabels = QStringList() << tr("name") << tr("type"); + m_lpObjectModel->setHorizontalHeaderLabels(headerLabels); + for(int x = 0;x < objectList.count();x++) + { + cObject* lpObject = objectList[x]; + QList items; + + items.append(new QStandardItem(lpObject->name())); + items.append(new QStandardItem(lpObject->type())); + + for(int y = 0;y < headerLabels.count();y++) + { + items[y]->setData(QVariant::fromValue(lpObject)); + items[y]->setToolTip(lpObject->description()->toPlainText()); + } + + m_lpObjectModel->appendRow(items); + } + + ui->m_lpObjectList->header()->setStretchLastSection(true); + + for(int i = 0;i < headerLabels.count();i++) + ui->m_lpObjectList->resizeColumnToContents(i); + + setWindowTitle(tr("[recherche] - ") + lpRecherche->name()); +} + +cRecherche* cRechercheWindow::recherche() +{ + return(m_lpRecherche); +} + +void cRechercheWindow::onCharacterDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpCharacterModel->itemFromIndex(index); + cCharacter* lpCharacter = qvariant_cast(lpItem->data()); + if(lpCharacter) + showCharacterWindow(lpCharacter); +} + +void cRechercheWindow::onPlaceDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpPlaceModel->itemFromIndex(index); + cPlace* lpPlace = qvariant_cast(lpItem->data()); + if(lpPlace) + showPlaceWindow(lpPlace); +} + +void cRechercheWindow::onObjectDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpObjectModel->itemFromIndex(index); + cObject* lpObject = qvariant_cast(lpItem->data()); + if(lpObject) + showObjectWindow(lpObject); +} diff --git a/crecherchewindow.h b/crecherchewindow.h new file mode 100644 index 0000000..6039adc --- /dev/null +++ b/crecherchewindow.h @@ -0,0 +1,44 @@ +#ifndef CRECHERCHEWINDOW_H +#define CRECHERCHEWINDOW_H + + +#include "crecherche.h" + +#include +#include + + +namespace Ui { +class cRechercheWindow; +} + +class cRechercheWindow : public QWidget +{ + Q_OBJECT + +public: + explicit cRechercheWindow(QWidget *parent = 0); + ~cRechercheWindow(); + + void setRecherche(cRecherche* lpRecherche); + cRecherche* recherche(); + +private slots: + void onCharacterDoubleClicked(const QModelIndex& index); + void onPlaceDoubleClicked(const QModelIndex& index); + void onObjectDoubleClicked(const QModelIndex& index); + +signals: + void showCharacterWindow(cCharacter* lpCharacter); + void showPlaceWindow(cPlace* lpPlace); + void showObjectWindow(cObject* lpObject); + +private: + Ui::cRechercheWindow* ui; + QStandardItemModel* m_lpCharacterModel; + QStandardItemModel* m_lpPlaceModel; + QStandardItemModel* m_lpObjectModel; + cRecherche* m_lpRecherche; +}; + +#endif // CRECHERCHEWINDOW_H diff --git a/crecherchewindow.ui b/crecherchewindow.ui new file mode 100644 index 0000000..51b61eb --- /dev/null +++ b/crecherchewindow.ui @@ -0,0 +1,169 @@ + + + cRechercheWindow + + + + 0 + 0 + 725 + 528 + + + + Form + + + + + + 0 + + + + Basic + + + + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Link: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Description: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Images + + + + + + true + + + + + 0 + 0 + 681 + 464 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Character + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + Object + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + Place + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + + + m_lpName + m_lpLink + m_lpDescription + m_lpTab + m_lpScrollArea + + + + diff --git a/cscenewindow.cpp b/cscenewindow.cpp index 6ec5e5c..c0b7684 100644 --- a/cscenewindow.cpp +++ b/cscenewindow.cpp @@ -36,6 +36,12 @@ 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))); } cSceneWindow::~cSceneWindow() @@ -167,10 +173,34 @@ cScene* cSceneWindow::scene() return(m_lpScene); } -void cSceneWindow::on_m_lpState_currentIndexChanged(int /*index*/) +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); + cCharacter* lpCharacter = qvariant_cast(lpItem->data()); + if(lpCharacter) + showCharacterWindow(lpCharacter); +} + +void cSceneWindow::onPlaceDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpPlaceModel->itemFromIndex(index); + cPlace* lpPlace = qvariant_cast(lpItem->data()); + if(lpPlace) + showPlaceWindow(lpPlace); +} + +void cSceneWindow::onObjectDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpObjectModel->itemFromIndex(index); + cObject* lpObject = qvariant_cast(lpItem->data()); + if(lpObject) + showObjectWindow(lpObject); +} diff --git a/cscenewindow.h b/cscenewindow.h index 56be848..5062cec 100644 --- a/cscenewindow.h +++ b/cscenewindow.h @@ -26,7 +26,15 @@ public: cScene* scene(); private slots: - void on_m_lpState_currentIndexChanged(int index); + void onStateCurrentIndexChanged(int index); + void onCharacterDoubleClicked(const QModelIndex& index); + void onPlaceDoubleClicked(const QModelIndex& index); + void onObjectDoubleClicked(const QModelIndex& index); + +signals: + void showCharacterWindow(cCharacter* lpCharacter); + void showPlaceWindow(cPlace* lpPlace); + void showObjectWindow(cObject* lpObject); private: Ui::cSceneWindow* ui; diff --git a/cscenewindow.ui b/cscenewindow.ui index 4d22dfc..1dc5e37 100644 --- a/cscenewindow.ui +++ b/cscenewindow.ui @@ -19,7 +19,7 @@ - 1 + 3 @@ -38,6 +38,9 @@ + + QAbstractItemView::NoEditTriggers + true @@ -55,6 +58,9 @@ + + QAbstractItemView::NoEditTriggers + true @@ -72,6 +78,9 @@ + + QAbstractItemView::NoEditTriggers + true diff --git a/cwidget.cpp b/cwidget.cpp index 6b98a4a..afca3ea 100644 --- a/cwidget.cpp +++ b/cwidget.cpp @@ -33,6 +33,30 @@ cWidget::cWidget(cCharacterWindow* parent) : { } +cWidget::cWidget(cObjectWindow* parent) : + QWidget(parent), + m_type(TYPE_object), + m_lpWidget(0), + m_lpWindow(0) +{ +} + +cWidget::cWidget(cPlaceWindow* parent) : + QWidget(parent), + m_type(TYPE_place), + m_lpWidget(0), + m_lpWindow(0) +{ +} + +cWidget::cWidget(cRechercheWindow* parent) : + QWidget(parent), + m_type(TYPE_recherche), + m_lpWidget(0), + m_lpWindow(0) +{ +} + cWidget::cWidget(QWidget* parent) : QWidget(parent), m_type(TYPE_unknown), diff --git a/cwidget.h b/cwidget.h index b2e25b8..b802855 100644 --- a/cwidget.h +++ b/cwidget.h @@ -6,6 +6,9 @@ #include "cchapterwindow.h" #include "cscenewindow.h" #include "ccharacterwindow.h" +#include "cobjectwindow.h" +#include "cplacewindow.h" +#include "crecherchewindow.h" #include #include @@ -22,12 +25,18 @@ public: TYPE_chapter = 2, TYPE_scene = 3, TYPE_character = 4, + TYPE_object = 5, + TYPE_place = 6, + TYPE_recherche = 7, }; explicit cWidget(cPartWindow* parent); explicit cWidget(cChapterWindow* parent); explicit cWidget(cSceneWindow* parent); explicit cWidget(cCharacterWindow* parent); + explicit cWidget(cObjectWindow* parent); + explicit cWidget(cPlaceWindow* parent); + explicit cWidget(cRechercheWindow* parent); explicit cWidget(QWidget* parent); QWidget* widget(); diff --git a/qtStoryWriter.pro b/qtStoryWriter.pro index 9e103dc..2f0ff54 100644 --- a/qtStoryWriter.pro +++ b/qtStoryWriter.pro @@ -61,7 +61,10 @@ SOURCES += \ cchapterwindow.cpp \ cscenewindow.cpp \ ccharacterwindow.cpp \ - cimagewidget.cpp + cimagewidget.cpp \ + cobjectwindow.cpp \ + cplacewindow.cpp \ + crecherchewindow.cpp HEADERS += \ cmainwindow.h \ @@ -84,7 +87,10 @@ HEADERS += \ cchapterwindow.h \ cscenewindow.h \ ccharacterwindow.h \ - cimagewidget.h + cimagewidget.h \ + cobjectwindow.h \ + cplacewindow.h \ + crecherchewindow.h FORMS += \ cmainwindow.ui \ @@ -92,7 +98,10 @@ FORMS += \ cchapterwindow.ui \ cscenewindow.ui \ ccharacterwindow.ui \ - cimagewidget.ui + cimagewidget.ui \ + cobjectwindow.ui \ + cplacewindow.ui \ + crecherchewindow.ui DISTFILES += \ storyBook.project