added functionality to add characters, objects and places to recherche

and scene
This commit is contained in:
Herwig Birke
2018-05-29 15:00:11 +02:00
parent b0d368be77
commit 0f915c02d6
18 changed files with 1319 additions and 386 deletions
+2 -2
View File
@@ -1066,8 +1066,8 @@ void cMainWindow::onShowRechercheWindow(cRecherche* lpRecherche)
}
}
cRechercheWindow* lpRechercheWindow = new cRechercheWindow(this);
lpRechercheWindow->setRecherche(lpRecherche);
cRechercheWindow* lpRechercheWindow = new cRechercheWindow(this);
lpRechercheWindow->setRecherche(lpRecherche, m_lpStoryBook->characterList(), m_lpStoryBook->placeList(), m_lpStoryBook->objectList());
cWidget* lpWidget1 = new cWidget(lpRechercheWindow);
lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpRechercheWindow));
ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpRechercheWindow->windowTitle());
+89
View File
@@ -0,0 +1,89 @@
#include "cobjectselectdialog.h"
#include "ui_cobjectselectdialog.h"
cObjectSelectDialog::cObjectSelectDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cObjectSelectDialog)
{
ui->setupUi(this);
m_lpObjectListModel = new QStandardItemModel(0, 1);
ui->m_lpObjectList->setModel(m_lpObjectListModel);
connect(ui->m_lpObjectList, &QTreeView::doubleClicked, this, &cObjectSelectDialog::onObjectDoubleClicked);
}
cObjectSelectDialog::~cObjectSelectDialog()
{
delete ui;
}
void cObjectSelectDialog::setObjectList(cObjectList* lpObjectList, QList<cObjectDescription *> objectDescriptionList)
{
QStandardItemModel* lpModel = m_lpObjectListModel;
lpModel->clear();
QStringList headerLabels = QStringList() << tr("name") << tr("type");
m_lpObjectListModel->setHorizontalHeaderLabels(headerLabels);
for(int x = 0;x < lpObjectList->count();x++)
{
bool bFound = false;
cObject* lpObject = lpObjectList->at(x);
for(int y = 0;y < objectDescriptionList.count();y++)
{
if(lpObject == objectDescriptionList.at(y)->object())
{
bFound = true;
break;
}
}
if(bFound)
continue;
QList<QStandardItem*> lpItems;
lpItems.append(new QStandardItem(lpObject->name()));
lpItems.append(new QStandardItem(lpObject->type()));
for(int i = 0;i < headerLabels.count();i++)
{
lpItems[i]->setData(QVariant::fromValue(lpObject));
if(lpObject->description())
lpItems[i]->setToolTip(lpObject->description()->toPlainText());
}
m_lpObjectListModel->appendRow(lpItems);
}
ui->m_lpObjectList->header()->setStretchLastSection(true);
ui->m_lpObjectList->expandAll();
for(int i = 0;i < headerLabels.count();i++)
ui->m_lpObjectList->resizeColumnToContents(i);
ui->m_lpObjectList->setCurrentIndex(m_lpObjectListModel->index(0, 0));
}
void cObjectSelectDialog::onObjectDoubleClicked(const QModelIndex& /*index*/)
{
this->accept();
}
cObject* cObjectSelectDialog::selected()
{
if(!ui->m_lpObjectList->currentIndex().isValid())
return(0);
QStandardItem* lpItem = m_lpObjectListModel->itemFromIndex(ui->m_lpObjectList->currentIndex());
if(!lpItem)
return(0);
return(qvariant_cast<cObject*>(lpItem->data()));
}
+70
View File
@@ -0,0 +1,70 @@
#ifndef COBJECTSELECTDIALOG_H
#define COBJECTSELECTDIALOG_H
#include "cobject.h"
#include <QList>
#include <QStandardItemModel>
#include <QDialog>
namespace Ui {
class cObjectSelectDialog;
}
/*!
\brief
\class cObjectSelectDialog cobjectselectdialog.h "cobjectselectdialog.h"
*/
class cObjectSelectDialog : public QDialog
{
Q_OBJECT
public:
/*!
\brief
\fn cObjectSelectDialog
\param parent
*/
explicit cObjectSelectDialog(QWidget *parent = 0);
/*!
\brief
\fn ~cObjectSelectDialog
*/
~cObjectSelectDialog();
/*!
\brief
\fn setObjectList
\param lpObjectList
\param objectDescriptionList
*/
void setObjectList(cObjectList* lpObjectList, QList<cObjectDescription *> objectDescriptionList);
/*!
\brief
\fn selected
\return cObject
*/
cObject* selected();
private:
Ui::cObjectSelectDialog* ui; /*!< TODO: describe */
QStandardItemModel* m_lpObjectListModel; /*!< TODO: describe */
private slots:
/*!
\brief
\fn onObjectDoubleClicked
\param index
*/
void onObjectDoubleClicked(const QModelIndex& index);
};
#endif // COBJECTSELECTDIALOG_H
+67
View File
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cObjectSelectDialog</class>
<widget class="QDialog" name="cObjectSelectDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpObjectList"/>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>cObjectSelectDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>cObjectSelectDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+1
View File
@@ -40,5 +40,6 @@ QByteArray textDocument2Blob(cTextDocument* lpTextDocument)
return(ba);
ba = compressText(lpTextDocument->toHtml());
return(ba);
}
+90
View File
@@ -0,0 +1,90 @@
#include "cplaceselectdialog.h"
#include "ui_cplaceselectdialog.h"
cPlaceSelectDialog::cPlaceSelectDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cPlaceSelectDialog)
{
ui->setupUi(this);
m_lpPlaceListModel = new QStandardItemModel(0, 1);
ui->m_lpPlaceList->setModel(m_lpPlaceListModel);
connect(ui->m_lpPlaceList, &QTreeView::doubleClicked, this, &cPlaceSelectDialog::onPlaceDoubleClicked);
}
cPlaceSelectDialog::~cPlaceSelectDialog()
{
delete ui;
}
void cPlaceSelectDialog::setPlaceList(cPlaceList* lpPlaceList, QList<cPlaceDescription *> placeDescriptionList)
{
QStandardItemModel* lpModel = m_lpPlaceListModel;
lpModel->clear();
QStringList headerLabels = QStringList() << tr("name") << tr("location") << tr("type");
m_lpPlaceListModel->setHorizontalHeaderLabels(headerLabels);
for(int x = 0;x < lpPlaceList->count();x++)
{
bool bFound = false;
cPlace* lpPlace = lpPlaceList->at(x);
for(int y = 0;y < placeDescriptionList.count();y++)
{
if(lpPlace == placeDescriptionList.at(y)->place())
{
bFound = true;
break;
}
}
if(bFound)
continue;
QList<QStandardItem*> lpItems;
lpItems.append(new QStandardItem(lpPlace->name()));
lpItems.append(new QStandardItem(lpPlace->location()));
lpItems.append(new QStandardItem(lpPlace->type()));
for(int i = 0;i < headerLabels.count();i++)
{
lpItems[i]->setData(QVariant::fromValue(lpPlace));
if(lpPlace->description())
lpItems[i]->setToolTip(lpPlace->description()->toPlainText());
}
m_lpPlaceListModel->appendRow(lpItems);
}
ui->m_lpPlaceList->header()->setStretchLastSection(true);
ui->m_lpPlaceList->expandAll();
for(int i = 0;i < headerLabels.count();i++)
ui->m_lpPlaceList->resizeColumnToContents(i);
ui->m_lpPlaceList->setCurrentIndex(m_lpPlaceListModel->index(0, 0));
}
void cPlaceSelectDialog::onPlaceDoubleClicked(const QModelIndex& /*index*/)
{
this->accept();
}
cPlace* cPlaceSelectDialog::selected()
{
if(!ui->m_lpPlaceList->currentIndex().isValid())
return(0);
QStandardItem* lpItem = m_lpPlaceListModel->itemFromIndex(ui->m_lpPlaceList->currentIndex());
if(!lpItem)
return(0);
return(qvariant_cast<cPlace*>(lpItem->data()));
}
+70
View File
@@ -0,0 +1,70 @@
#ifndef CPLACESELECTDIALOG_H
#define CPLACESELECTDIALOG_H
#include "cplace.h"
#include <QList>
#include <QStandardItemModel>
#include <QDialog>
namespace Ui {
class cPlaceSelectDialog;
}
/*!
\brief
\class cPlaceSelectDialog cplaceselectdialog.h "cplaceselectdialog.h"
*/
class cPlaceSelectDialog : public QDialog
{
Q_OBJECT
public:
/*!
\brief
\fn cPlaceSelectDialog
\param parent
*/
explicit cPlaceSelectDialog(QWidget *parent = 0);
/*!
\brief
\fn ~cPlaceSelectDialog
*/
~cPlaceSelectDialog();
/*!
\brief
\fn setPlaceList
\param lpPlaceList
\param placeDescriptionList
*/
void setPlaceList(cPlaceList* lpPlaceList, QList<cPlaceDescription *> placeDescriptionList);
/*!
\brief
\fn selected
\return cPlace
*/
cPlace* selected();
private:
Ui::cPlaceSelectDialog* ui; /*!< TODO: describe */
QStandardItemModel* m_lpPlaceListModel; /*!< TODO: describe */
private slots:
/*!
\brief
\fn onPlaceDoubleClicked
\param index
*/
void onPlaceDoubleClicked(const QModelIndex& index);
};
#endif // CPLACESELECTDIALOG_H
+67
View File
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cPlaceSelectDialog</class>
<widget class="QDialog" name="cPlaceSelectDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpPlaceList"/>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>cPlaceSelectDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>cPlaceSelectDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+43 -28
View File
@@ -91,16 +91,31 @@ void cRecherche::addCharacter(cCharacter* lpCharacter, cTextDocument* lpDescript
m_characterList.append(new cCharacterDescription(lpCharacter, lpDescription));
}
void cRecherche::removeCharacter(cCharacterDescription* lpCharacter)
{
m_characterList.removeOne(lpCharacter);
}
void cRecherche::addObject(cObject* lpObject, cTextDocument* lpDescription)
{
m_objectList.append(new cObjectDescription(lpObject, lpDescription));
}
void cRecherche::removeObject(cObjectDescription* lpObject)
{
m_objectList.removeOne(lpObject);
}
void cRecherche::addPlace(cPlace* lpPlace, cTextDocument* lpDescription)
{
m_placeList.append(new cPlaceDescription(lpPlace, lpDescription));
}
void cRecherche::removePlace(cPlaceDescription* lpPlace)
{
m_placeList.removeOne(lpPlace);
}
QList<cImageDescription*> cRecherche::images()
{
return(m_imageList);
@@ -340,6 +355,34 @@ bool cRechercheList::save()
{
cRecherche* lpRecherche = at(x);
imageDelete.bindValue(":rechercheID", lpRecherche->id());
if(!imageDelete.exec())
{
myDebug << imageDelete.lastError().text();
return(false);
}
characterDelete.bindValue(":rechercheID", lpRecherche->id());
if(!characterDelete.exec())
{
myDebug << characterDelete.lastError().text();
return(false);
}
objectDelete.bindValue(":rechercheID", lpRecherche->id());
if(!objectDelete.exec())
{
myDebug << objectDelete.lastError().text();
return(false);
}
placeDelete.bindValue(":rechercheID", lpRecherche->id());
if(!placeDelete.exec())
{
myDebug << placeDelete.lastError().text();
return(false);
}
if(lpRecherche->deleted())
{
queryDelete.bindValue(":id", lpRecherche->id());
@@ -385,34 +428,6 @@ bool cRechercheList::save()
lpRecherche->setID(querySelect.value("id").toInt());
}
imageDelete.bindValue(":rechercheID", lpRecherche->id());
if(!imageDelete.exec())
{
myDebug << imageDelete.lastError().text();
return(false);
}
characterDelete.bindValue(":rechercheID", lpRecherche->id());
if(!imageDelete.exec())
{
myDebug << characterDelete.lastError().text();
return(false);
}
objectDelete.bindValue(":rechercheID", lpRecherche->id());
if(!imageDelete.exec())
{
myDebug << objectDelete.lastError().text();
return(false);
}
placeDelete.bindValue(":rechercheID", lpRecherche->id());
if(!imageDelete.exec())
{
myDebug << placeDelete.lastError().text();
return(false);
}
QList<cImageDescription*> images = lpRecherche->images();
for(int x = 0;x < images.count();x++)
+44 -21
View File
@@ -115,6 +115,21 @@ public:
\param lpDescription
*/
void addCharacter(cCharacter* lpCharacter, cTextDocument* lpDescription);
/*!
\brief
\fn removeCharacter
\param lpCharacter
*/
void removeCharacter(cCharacterDescription* lpCharacter);
/*!
\brief
\fn characterList
\return QList<cCharacter *>
*/
QList<cCharacterDescription*> characterList();
/*!
\brief
@@ -123,6 +138,21 @@ public:
\param lpDescription
*/
void addObject(cObject* lpObject, cTextDocument* lpDescription);
/*!
\brief
\fn removeObject
\param lpObject
*/
void removeObject(cObjectDescription* lpObject);
/*!
\brief
\fn objectList
\return QList<cObject *>
*/
QList<cObjectDescription*> objectList();
/*!
\brief
@@ -131,6 +161,20 @@ public:
\param lpDescription
*/
void addPlace(cPlace* lpPlace, cTextDocument* lpDescription);
/*!
\brief
\fn removePlace
\param lpPlace
*/
void removePlace(cPlaceDescription* lpPlace);
/*!
\brief
\fn placeList
\return QList<cPlace *>
*/
QList<cPlaceDescription*> placeList();
/*!
\brief
@@ -139,27 +183,6 @@ public:
\return QList<cImageDescription *>
*/
QList<cImageDescription*> images();
/*!
\brief
\fn characterList
\return QList<cCharacterDescription *>
*/
QList<cCharacterDescription*> characterList();
/*!
\brief
\fn objectList
\return QList<cObjectDescription *>
*/
QList<cObjectDescription*> objectList();
/*!
\brief
\fn placeList
\return QList<cPlaceDescription *>
*/
QList<cPlaceDescription*> placeList();
/*!
\brief
+301 -144
View File
@@ -10,52 +10,55 @@
#include "cmainwindow.h"
#include "ccharacterselectdialog.h"
#include "cplaceselectdialog.h"
#include "cobjectselectdialog.h"
#include "common.h"
#include <QStandardItem>
#include <QMessageBox>
cRechercheWindow::cRechercheWindow(QWidget *parent) :
cMDISubWindow(parent),
ui(new Ui::cRechercheWindow),
m_lpMainWindow((cMainWindow*)parent),
m_lpRecherche(0)
m_lpRecherche(0),
m_lpCharacterList(0),
m_lpPlaceList(0),
m_lpObjectList(0)
{
ui->setupUi(this);
ui->m_lpTab->setCurrentIndex(0);
m_lpCharacterModel = new QStandardItemModel(0, 1);
ui->m_lpCharacterList->setModel(m_lpCharacterModel);
connect(ui->m_lpName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus);
connect(ui->m_lpName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus);
m_lpPlaceModel = new QStandardItemModel(0, 1);
ui->m_lpPlaceList->setModel(m_lpPlaceModel);
connect(ui->m_lpLink, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus);
connect(ui->m_lpLink, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus);
m_lpObjectModel = new QStandardItemModel(0, 1);
ui->m_lpObjectList->setModel(m_lpObjectModel);
connect(ui->m_lpDescription, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus);
connect(ui->m_lpDescription, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus);
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_lpCharacterList, &cComboBox::gotFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxGotFocus);
connect(ui->m_lpCharacterList, &cComboBox::lostFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxLostFocus);
connect(ui->m_lpName, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus);
connect(ui->m_lpName, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus);
connect(ui->m_lpPlaceList, &cComboBox::gotFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxGotFocus);
connect(ui->m_lpPlaceList, &cComboBox::lostFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxLostFocus);
connect(ui->m_lpLink, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus);
connect(ui->m_lpLink, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus);
connect(ui->m_lpObjectList, &cComboBox::gotFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxGotFocus);
connect(ui->m_lpObjectList, &cComboBox::lostFocus, (cMainWindow*)parent, &cMainWindow::onComboBoxLostFocus);
connect(ui->m_lpDescription, &cTextEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onTextEditGotFocus);
connect(ui->m_lpDescription, &cTextEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onTextEditLostFocus);
connect(ui->m_lpCaracterAdd, &QPushButton::clicked, this, &cRechercheWindow::onAddCharacterToList);
connect(ui->m_lpCharacterRemove, &QPushButton::clicked, this, &cRechercheWindow::onRemoveCharacterFromList);
connect(ui->m_lpCharacterList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus);
connect(ui->m_lpCharacterList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus);
connect(ui->m_lpPlaceAdd, &QPushButton::clicked, this, &cRechercheWindow::onAddPlaceToList);
connect(ui->m_lpPlaceRemove, &QPushButton::clicked, this, &cRechercheWindow::onRemovePlaceFromList);
connect(ui->m_lpObjectList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus);
connect(ui->m_lpObjectList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus);
connect(ui->m_lpPlaceList, &cTreeView::gotFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewGotFocus);
connect(ui->m_lpPlaceList, &cTreeView::lostFocus, (cMainWindow*)parent, &cMainWindow::onTreeViewLostFocus);
connect(ui->m_lpObjectAdd, &QPushButton::clicked, this, &cRechercheWindow::onAddObjectToList);
connect(ui->m_lpObjectRemove, &QPushButton::clicked, this, &cRechercheWindow::onRemoveObjectFromList);
}
cRechercheWindow::~cRechercheWindow()
@@ -63,9 +66,12 @@ cRechercheWindow::~cRechercheWindow()
delete ui;
}
void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
void cRechercheWindow::setRecherche(cRecherche* lpRecherche, cCharacterList* lpCharacterList, cPlaceList* lpPlaceList, cObjectList* lpObjectList)
{
m_lpRecherche = lpRecherche;
m_lpRecherche = lpRecherche;
m_lpCharacterList = lpCharacterList;
m_lpPlaceList = lpPlaceList;
m_lpObjectList = lpObjectList;
ui->m_lpName->setText(lpRecherche->name());
ui->m_lpLink->setText(lpRecherche->link());
@@ -83,101 +89,13 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
ui->m_lpLayout->addWidget(lpImageWidget);
}
QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
ui->m_lpLayout->addItem(lpSpacer);
fillCharacterList();
fillPlaceList();
fillObjectList();
QList<cCharacterDescription*> characterList = lpRecherche->characterList();
QList<cPlaceDescription*> placeList = lpRecherche->placeList();
QList<cObjectDescription*> 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++)
{
cCharacterDescription* lpCharacterDescription = characterList[x];
cCharacter* lpCharacter = lpCharacterDescription->character();
QList<QStandardItem*> 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++)
{
cPlaceDescription* lpPlaceDescription = placeList[x];
cPlace* lpPlace = lpPlaceDescription->place();
QList<QStandardItem*> 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++)
{
cObjectDescription* lpObjectDescription = objectList[x];
cObject* lpObject = lpObjectDescription->object();
QList<QStandardItem*> 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);
connect(ui->m_lpCharacterList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cRechercheWindow::onCharacterIndexChanged);
connect(ui->m_lpPlaceList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cRechercheWindow::onPlaceIndexChanged);
connect(ui->m_lpObjectList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cRechercheWindow::onObjectIndexChanged);
setWindowTitle(tr("[recherche] - ") + lpRecherche->name());
@@ -191,30 +109,6 @@ cRecherche* cRechercheWindow::recherche()
return(m_lpRecherche);
}
void cRechercheWindow::onCharacterDoubleClicked(const QModelIndex& index)
{
QStandardItem* lpItem = m_lpCharacterModel->itemFromIndex(index);
cCharacter* lpCharacter = qvariant_cast<cCharacter*>(lpItem->data());
if(lpCharacter)
showCharacterWindow(lpCharacter);
}
void cRechercheWindow::onPlaceDoubleClicked(const QModelIndex& index)
{
QStandardItem* lpItem = m_lpPlaceModel->itemFromIndex(index);
cPlace* lpPlace = qvariant_cast<cPlace*>(lpItem->data());
if(lpPlace)
showPlaceWindow(lpPlace);
}
void cRechercheWindow::onObjectDoubleClicked(const QModelIndex& index)
{
QStandardItem* lpItem = m_lpObjectModel->itemFromIndex(index);
cObject* lpObject = qvariant_cast<cObject*>(lpItem->data());
if(lpObject)
showObjectWindow(lpObject);
}
void cRechercheWindow::onNameChanged(const QString& szName)
{
m_lpRecherche->setName(szName);
@@ -243,3 +137,266 @@ void cRechercheWindow::onDescriptionChanged()
{
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onCharacterIndexChanged(int index)
{
ui->m_lpCharacterDetails->setCurrentIndex(index);
}
void cRechercheWindow::onPlaceIndexChanged(int index)
{
ui->m_lpPlaceDetails->setCurrentIndex(index);
}
void cRechercheWindow::onObjectIndexChanged(int index)
{
ui->m_lpObjectDetails->setCurrentIndex(index);
}
void cRechercheWindow::onCharacterDescriptionChanged()
{
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onPlaceDescriptionChanged()
{
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onObjectDescriptionChanged()
{
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onAddCharacterToList()
{
cCharacterSelectDialog* lpDialog = new cCharacterSelectDialog(this);
lpDialog->setCharacterList(m_lpCharacterList, m_lpRecherche->characterList());
if(lpDialog->exec() == QDialog::Rejected)
{
delete lpDialog;
return;
}
cCharacter* lpCharacterNew = lpDialog->selected();
delete lpDialog;
if(!lpCharacterNew)
return;
m_lpRecherche->addCharacter(lpCharacterNew, new cTextDocument);
fillCharacterList(lpCharacterNew);
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onRemoveCharacterFromList()
{
cCharacterDescription* lpCharacterDescription = qvariant_cast<cCharacterDescription*>(ui->m_lpCharacterList->currentData());
if(!lpCharacterDescription)
return;
if(QMessageBox::question(this, "Scene", QString(tr("Do you want to delete \"%1\" from list?")).arg(lpCharacterDescription->character()->name())) == QMessageBox::No)
return;
m_lpRecherche->removeCharacter(lpCharacterDescription);
fillCharacterList();
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onAddPlaceToList()
{
cPlaceSelectDialog* lpDialog = new cPlaceSelectDialog(this);
lpDialog->setPlaceList(m_lpPlaceList, m_lpRecherche->placeList());
if(lpDialog->exec() == QDialog::Rejected)
{
delete lpDialog;
return;
}
cPlace* lpPlaceNew = lpDialog->selected();
delete lpDialog;
if(!lpPlaceNew)
return;
m_lpRecherche->addPlace(lpPlaceNew, new cTextDocument);
fillPlaceList(lpPlaceNew);
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onRemovePlaceFromList()
{
cPlaceDescription* lpPlaceDescription = qvariant_cast<cPlaceDescription*>(ui->m_lpPlaceList->currentData());
if(!lpPlaceDescription)
return;
if(QMessageBox::question(this, "Scene", QString(tr("Do you want to delete \"%1\" from list?")).arg(lpPlaceDescription->place()->name())) == QMessageBox::No)
return;
m_lpRecherche->removePlace(lpPlaceDescription);
fillPlaceList();
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onAddObjectToList()
{
cObjectSelectDialog* lpDialog = new cObjectSelectDialog(this);
lpDialog->setObjectList(m_lpObjectList, m_lpRecherche->objectList());
if(lpDialog->exec() == QDialog::Rejected)
{
delete lpDialog;
return;
}
cObject* lpObjectNew = lpDialog->selected();
delete lpDialog;
if(!lpObjectNew)
return;
m_lpRecherche->addObject(lpObjectNew, new cTextDocument);
fillObjectList(lpObjectNew);
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::onRemoveObjectFromList()
{
cObjectDescription* lpObjectDescription = qvariant_cast<cObjectDescription*>(ui->m_lpObjectList->currentData());
if(!lpObjectDescription)
return;
if(QMessageBox::question(this, "Scene", QString(tr("Do you want to delete \"%1\" from list?")).arg(lpObjectDescription->object()->name())) == QMessageBox::No)
return;
m_lpRecherche->removeObject(lpObjectDescription);
fillObjectList();
m_lpMainWindow->somethingChanged();
}
void cRechercheWindow::fillCharacterList(cCharacter* lpCharacterNew)
{
QList<cCharacterDescription*> characterList = m_lpRecherche->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, &cRechercheWindow::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 cRechercheWindow::fillPlaceList(cPlace* lpPlaceNew)
{
QList<cPlaceDescription*> placeList = m_lpRecherche->placeList();
ui->m_lpPlaceList->clear();
for(int x = ui->m_lpPlaceDetails->count()-1;x >= 0;x--)
ui->m_lpPlaceDetails->removeWidget(ui->m_lpPlaceDetails->widget(x));
qint16 index = 0;
for(int x = 0;x < placeList.count();x++)
{
cPlaceDescription* lpPlaceDescription = placeList[x];
cPlace* lpPlace = lpPlaceDescription->place();
ui->m_lpPlaceList->addItem(lpPlace->name(), QVariant::fromValue(lpPlaceDescription));
cTextEdit* lpTextEdit = new cTextEdit(ui->m_lpPlaceDetails);
lpTextEdit->setDocument(lpPlaceDescription->description());
ui->m_lpPlaceDetails->addWidget(lpTextEdit);
connect(lpTextEdit, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus);
connect(lpTextEdit, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus);
connect(lpTextEdit, &cTextEdit::textChanged, this, &cRechercheWindow::onPlaceDescriptionChanged);
if(lpPlace == lpPlaceNew)
index = x;
}
ui->m_lpPlaceList->setCurrentIndex(index);
ui->m_lpPlaceDetails->setCurrentIndex(index);
ui->m_lpPlaceRemove->setEnabled((ui->m_lpPlaceList->count() > 0));
ui->m_lpPlaceShowDetails->setEnabled((ui->m_lpPlaceList->count() > 0));
}
void cRechercheWindow::fillObjectList(cObject* lpObjectNew)
{
QList<cObjectDescription*> objectList = m_lpRecherche->objectList();
ui->m_lpObjectList->clear();
for(int x = ui->m_lpObjectDetails->count()-1;x >= 0;x--)
ui->m_lpObjectDetails->removeWidget(ui->m_lpObjectDetails->widget(x));
qint16 index = 0;
for(int x = 0;x < objectList.count();x++)
{
cObjectDescription* lpObjectDescription = objectList[x];
cObject* lpObject = lpObjectDescription->object();
ui->m_lpObjectList->addItem(lpObject->name(), QVariant::fromValue(lpObjectDescription));
cTextEdit* lpTextEdit = new cTextEdit(ui->m_lpObjectDetails);
lpTextEdit->setDocument(lpObjectDescription->description());
ui->m_lpObjectDetails->addWidget(lpTextEdit);
connect(lpTextEdit, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus);
connect(lpTextEdit, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus);
connect(lpTextEdit, &cTextEdit::textChanged, this, &cRechercheWindow::onObjectDescriptionChanged);
if(lpObject == lpObjectNew)
index = x;
}
ui->m_lpObjectList->setCurrentIndex(index);
ui->m_lpObjectDetails->setCurrentIndex(index);
ui->m_lpObjectRemove->setEnabled((ui->m_lpObjectList->count() > 0));
ui->m_lpObjectShowDetails->setEnabled((ui->m_lpObjectList->count() > 0));
}
+109 -25
View File
@@ -45,7 +45,7 @@ public:
\fn setRecherche
\param lpRecherche
*/
void setRecherche(cRecherche* lpRecherche);
void setRecherche(cRecherche* lpRecherche, cCharacterList* lpCharacterList, cPlaceList* lpPlaceList, cObjectList* lpObjectList);
/*!
\brief
@@ -54,28 +54,30 @@ public:
*/
cRecherche* recherche();
private:
/*!
\brief
\fn fillCharacterList
\param bSelectFirst
*/
void fillCharacterList(cCharacter* lpCharacterNew = 0);
/*!
\brief
\fn fillPlaceList
\param bSelectFirst
*/
void fillPlaceList(cPlace* lpPlaceNew = 0);
/*!
\brief
\fn fillObjectList
\param bSelectFirst
*/
void fillObjectList(cObject* lpObjectNew = 0);
private slots:
/*!
\brief
\fn onCharacterDoubleClicked
\param index
*/
void onCharacterDoubleClicked(const QModelIndex& index);
/*!
\brief
\fn onPlaceDoubleClicked
\param index
*/
void onPlaceDoubleClicked(const QModelIndex& index);
/*!
\brief
\fn onObjectDoubleClicked
\param index
*/
void onObjectDoubleClicked(const QModelIndex& index);
/*!
\brief
@@ -98,6 +100,88 @@ private slots:
*/
void onDescriptionChanged();
/*!
\brief
\fn onCharacterDescriptionChanged
*/
void onCharacterDescriptionChanged();
/*!
\brief
\fn onPlaceDescriptionChanged
*/
void onPlaceDescriptionChanged();
/*!
\brief
\fn onPlaceDescriptionChanged
*/
void onObjectDescriptionChanged();
/*!
\brief
\fn onCharacterIndexChanged
\param index
*/
void onCharacterIndexChanged(int index);
/*!
\brief
\fn onPlaceIndexChanged
\param index
*/
void onPlaceIndexChanged(int index);
/*!
\brief
\fn onObjectIndexChanged
\param index
*/
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:
/*!
\brief
@@ -124,10 +208,10 @@ 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 */
cRecherche* m_lpRecherche; /*!< TODO: describe */
cCharacterList* m_lpCharacterList; /*!< TODO: describe */
cPlaceList* m_lpPlaceList; /*!< TODO: describe */
cObjectList* m_lpObjectList; /*!< TODO: describe */
};
#endif // CRECHERCHEWINDOW_H
+120 -28
View File
@@ -17,7 +17,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="m_lpTab">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="m_lpBasic">
<attribute name="title">
@@ -117,25 +117,43 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="cTreeView" name="m_lpCharacterList">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_lpObject">
<attribute name="title">
<string>Object</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="cTreeView" name="m_lpObjectList">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,0,0,0">
<item>
<widget class="cComboBox" name="m_lpCharacterList"/>
</item>
<item>
<widget class="QPushButton" name="m_lpCharacterShowDetails">
<property name="text">
<string>details...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpCaracterAdd">
<property name="text">
<string>add...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpCharacterRemove">
<property name="text">
<string>remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="m_lpCharacterDetails">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@@ -145,11 +163,85 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="cTreeView" name="m_lpPlaceList">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0,0">
<item>
<widget class="cComboBox" name="m_lpPlaceList"/>
</item>
<item>
<widget class="QPushButton" name="m_lpPlaceShowDetails">
<property name="text">
<string>details...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpPlaceAdd">
<property name="text">
<string>add...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpPlaceRemove">
<property name="text">
<string>remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="m_lpPlaceDetails">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_lpObject">
<attribute name="title">
<string>Object</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0,0">
<item>
<widget class="cComboBox" name="m_lpObjectList"/>
</item>
<item>
<widget class="QPushButton" name="m_lpObjectShowDetails">
<property name="text">
<string>details...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpObjectAdd">
<property name="text">
<string>add...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpObjectRemove">
<property name="text">
<string>remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="m_lpObjectDetails"/>
</item>
</layout>
</item>
</layout>
</widget>
@@ -169,9 +261,9 @@
<header>clineedit.h</header>
</customwidget>
<customwidget>
<class>cTreeView</class>
<extends>QTreeView</extends>
<header>ctreeview.h</header>
<class>cComboBox</class>
<extends>QComboBox</extends>
<header>ccombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
+35 -21
View File
@@ -146,6 +146,11 @@ void cScene::addObject(cObject* lpObject, cTextDocument* lpDescription)
m_objectList.append(new cObjectDescription(lpObject, lpDescription));
}
void cScene::removeObject(cObjectDescription* lpObject)
{
m_objectList.removeOne(lpObject);
}
QList<cObjectDescription*> cScene::objectList()
{
return(m_objectList);
@@ -156,6 +161,11 @@ void cScene::addPlace(cPlace* lpPlace, cTextDocument* lpDescription)
m_placeList.append(new cPlaceDescription(lpPlace, lpDescription));
}
void cScene::removePlace(cPlaceDescription* lpPlace)
{
m_placeList.removeOne(lpPlace);
}
QList<cPlaceDescription*> cScene::placeList()
{
return(m_placeList);
@@ -461,10 +471,32 @@ bool cSceneList::save()
objectDelete.prepare("DELETE FROM sceneObject WHERE sceneID=:sceneID;");
objectAdd.prepare("INSERT INTO sceneObject (sceneID, objectID, description) VALUES (:sceneID, :objectID, :description);");
myDebug;
for(int x = 0;x < count();x++)
{
cScene* lpScene = at(x);
characterDelete.bindValue(":sceneID", lpScene->id());
if(!characterDelete.exec())
{
myDebug << characterDelete.lastError().text();
return(false);
}
placeDelete.bindValue(":sceneID", lpScene->id());
if(!placeDelete.exec())
{
myDebug << placeDelete.lastError().text();
return(false);
}
objectDelete.bindValue(":sceneID", lpScene->id());
if(!objectDelete.exec())
{
myDebug << objectDelete.lastError().text();
return(false);
}
if(lpScene->deleted())
{
queryDelete.bindValue(":id", lpScene->id());
@@ -522,13 +554,6 @@ bool cSceneList::save()
lpScene->setID(querySelect.value("id").toInt());
}
characterDelete.bindValue(":sceneID", lpScene->id());
if(!characterDelete.exec())
{
myDebug << characterDelete.lastError().text();
return(false);
}
QList<cCharacterDescription*> character = lpScene->characterList();
for(int x = 0;x < character.count();x++)
@@ -538,6 +563,7 @@ bool cSceneList::save()
characterAdd.bindValue(":sceneID", lpScene->id());
characterAdd.bindValue(":characterID", lpCharacter->character()->id());
characterAdd.bindValue(":description", textDocument2Blob(lpCharacter->description()));
if(!characterAdd.exec())
{
myDebug << characterAdd.lastError().text();
@@ -545,13 +571,6 @@ bool cSceneList::save()
}
}
placeDelete.bindValue(":sceneID", lpScene->id());
if(!placeDelete.exec())
{
myDebug << placeDelete.lastError().text();
return(false);
}
QList<cPlaceDescription*> place = lpScene->placeList();
for(int x = 0;x < place.count();x++)
@@ -561,6 +580,7 @@ bool cSceneList::save()
placeAdd.bindValue(":sceneID", lpScene->id());
placeAdd.bindValue(":placeID", lpPlace->place()->id());
placeAdd.bindValue(":description", textDocument2Blob(lpPlace->description()));
if(!placeAdd.exec())
{
myDebug << placeAdd.lastError().text();
@@ -568,13 +588,6 @@ bool cSceneList::save()
}
}
objectDelete.bindValue(":sceneID", lpScene->id());
if(!objectDelete.exec())
{
myDebug << objectDelete.lastError().text();
return(false);
}
QList<cObjectDescription*> object = lpScene->objectList();
for(int x = 0;x < object.count();x++)
@@ -584,6 +597,7 @@ bool cSceneList::save()
objectAdd.bindValue(":sceneID", lpScene->id());
objectAdd.bindValue(":objectID", lpObject->object()->id());
objectAdd.bindValue(":description", textDocument2Blob(lpObject->description()));
if(!objectAdd.exec())
{
myDebug << objectAdd.lastError().text();
+15 -2
View File
@@ -215,9 +215,8 @@ public:
/*!
\brief
\fn addCharacter
\fn removeCharacter
\param lpCharacter
\param lpDescription
*/
void removeCharacter(cCharacterDescription* lpCharacter);
/*!
@@ -239,6 +238,13 @@ public:
/*!
\brief
\fn removeObject
\param lpObject
*/
void removeObject(cObjectDescription* lpObject);
/*!
\brief
\fn objectList
\return QList<cObject *>
*/
@@ -255,6 +261,13 @@ public:
/*!
\brief
\fn removePlace
\param lpPlace
*/
void removePlace(cPlaceDescription* lpPlace);
/*!
\brief
\fn placeList
\return QList<cPlace *>
*/
+164 -112
View File
@@ -7,6 +7,8 @@
#include "ui_cscenewindow.h"
#include "ccharacterselectdialog.h"
#include "cplaceselectdialog.h"
#include "cobjectselectdialog.h"
#include "cmainwindow.h"
@@ -127,72 +129,9 @@ void cSceneWindow::setScene(cScene* lpScene, cCharacterList* lpCharacterList, cP
ui->m_lpTargetDate->setDateTime(lpScene->targetDate());
ui->m_lpText->setDocument(lpScene->text());
QList<cCharacterDescription*> characterList = lpScene->characterList();
QList<cPlaceDescription*> placeList = lpScene->placeList();
QList<cObjectDescription*> objectList = lpScene->objectList();
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);
}
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];
cPlace* lpPlace = lpPlaceDescription->place();
ui->m_lpPlaceList->addItem(lpPlace->name(), QVariant::fromValue(lpPlaceDescription));
cTextEdit* lpTextEdit = new cTextEdit(ui->m_lpPlaceDetails);
lpTextEdit->setDocument(lpPlaceDescription->description());
ui->m_lpPlaceDetails->addWidget(lpTextEdit);
connect(lpTextEdit, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus);
connect(lpTextEdit, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus);
connect(lpTextEdit, &cTextEdit::textChanged, this, &cSceneWindow::onPlaceDescriptionChanged);
}
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];
cObject* lpObject = lpObjectDescription->object();
ui->m_lpObjectList->addItem(lpObject->name(), QVariant::fromValue(lpObjectDescription));
cTextEdit* lpTextEdit = new cTextEdit(ui->m_lpObjectDetails);
lpTextEdit->setDocument(lpObjectDescription->description());
ui->m_lpObjectDetails->addWidget(lpTextEdit);
connect(lpTextEdit, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus);
connect(lpTextEdit, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus);
connect(lpTextEdit, &cTextEdit::textChanged, this, &cSceneWindow::onObjectDescriptionChanged);
}
ui->m_lpObjectList->setCurrentText(0);
ui->m_lpObjectDetails->setCurrentIndex(0);
ui->m_lpObjectRemove->setEnabled((characterList.count() > 0));
ui->m_lpObjectShowDetails->setEnabled((characterList.count() > 0));
fillCharacterList();
fillPlaceList();
fillObjectList();
connect(ui->m_lpCharacterList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onCharacterIndexChanged);
connect(ui->m_lpPlaceList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onPlaceIndexChanged);
@@ -360,8 +299,116 @@ void cSceneWindow::onAddCharacterToList()
if(!lpCharacterNew)
return;
m_lpScene->addCharacter(lpCharacterNew, new cTextDocument(this));
m_lpScene->addCharacter(lpCharacterNew, new cTextDocument);
fillCharacterList(lpCharacterNew);
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::onRemoveCharacterFromList()
{
cCharacterDescription* lpCharacterDescription = qvariant_cast<cCharacterDescription*>(ui->m_lpCharacterList->currentData());
if(!lpCharacterDescription)
return;
if(QMessageBox::question(this, "Scene", QString(tr("Do you want to delete \"%1\" from list?")).arg(lpCharacterDescription->character()->name())) == QMessageBox::No)
return;
m_lpScene->removeCharacter(lpCharacterDescription);
fillCharacterList();
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::onAddPlaceToList()
{
cPlaceSelectDialog* lpDialog = new cPlaceSelectDialog(this);
lpDialog->setPlaceList(m_lpPlaceList, m_lpScene->placeList());
if(lpDialog->exec() == QDialog::Rejected)
{
delete lpDialog;
return;
}
cPlace* lpPlaceNew = lpDialog->selected();
delete lpDialog;
if(!lpPlaceNew)
return;
m_lpScene->addPlace(lpPlaceNew, new cTextDocument);
fillPlaceList(lpPlaceNew);
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::onRemovePlaceFromList()
{
cPlaceDescription* lpPlaceDescription = qvariant_cast<cPlaceDescription*>(ui->m_lpPlaceList->currentData());
if(!lpPlaceDescription)
return;
if(QMessageBox::question(this, "Scene", QString(tr("Do you want to delete \"%1\" from list?")).arg(lpPlaceDescription->place()->name())) == QMessageBox::No)
return;
m_lpScene->removePlace(lpPlaceDescription);
QList<cPlaceDescription*> placeList = m_lpScene->placeList();
fillPlaceList();
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::onAddObjectToList()
{
cObjectSelectDialog* lpDialog = new cObjectSelectDialog(this);
lpDialog->setObjectList(m_lpObjectList, m_lpScene->objectList());
if(lpDialog->exec() == QDialog::Rejected)
{
delete lpDialog;
return;
}
cObject* lpObjectNew = lpDialog->selected();
delete lpDialog;
if(!lpObjectNew)
return;
m_lpScene->addObject(lpObjectNew, new cTextDocument);
fillObjectList(lpObjectNew);
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::onRemoveObjectFromList()
{
cObjectDescription* lpObjectDescription = qvariant_cast<cObjectDescription*>(ui->m_lpObjectList->currentData());
if(!lpObjectDescription)
return;
if(QMessageBox::question(this, "Scene", QString(tr("Do you want to delete \"%1\" from list?")).arg(lpObjectDescription->object()->name())) == QMessageBox::No)
return;
m_lpScene->removeObject(lpObjectDescription);
fillObjectList();
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::fillCharacterList(cCharacter* lpCharacterNew)
{
QList<cCharacterDescription*> characterList = m_lpScene->characterList();
ui->m_lpCharacterList->clear();
@@ -389,78 +436,83 @@ void cSceneWindow::onAddCharacterToList()
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));
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::onRemoveCharacterFromList()
void cSceneWindow::fillPlaceList(cPlace* lpPlaceNew)
{
cCharacterDescription* lpCharacterDescription = qvariant_cast<cCharacterDescription*>(ui->m_lpCharacterList->currentData());
QList<cPlaceDescription*> placeList = m_lpScene->placeList();
if(!lpCharacterDescription)
return;
ui->m_lpPlaceList->clear();
if(QMessageBox::question(this, "Scene", QString(tr("Do you want to delete \"%1\" from list?")).arg(lpCharacterDescription->character()->name())) == QMessageBox::No)
return;
for(int x = ui->m_lpPlaceDetails->count()-1;x >= 0;x--)
ui->m_lpPlaceDetails->removeWidget(ui->m_lpPlaceDetails->widget(x));
m_lpScene->removeCharacter(lpCharacterDescription);
qint16 index = 0;
QList<cCharacterDescription*> 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));
for(int x = 0;x < characterList.count();x++)
for(int x = 0;x < placeList.count();x++)
{
cCharacterDescription* lpCharacterDescription = characterList[x];
cCharacter* lpCharacter = lpCharacterDescription->character();
cPlaceDescription* lpPlaceDescription = placeList[x];
cPlace* lpPlace = lpPlaceDescription->place();
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);
ui->m_lpPlaceList->addItem(lpPlace->name(), QVariant::fromValue(lpPlaceDescription));
cTextEdit* lpTextEdit = new cTextEdit(ui->m_lpPlaceDetails);
lpTextEdit->setDocument(lpPlaceDescription->description());
ui->m_lpPlaceDetails->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);
connect(lpTextEdit, &cTextEdit::textChanged, this, &cSceneWindow::onPlaceDescriptionChanged);
if(lpPlace == lpPlaceNew)
index = x;
}
ui->m_lpCharacterList->setCurrentIndex(0);
ui->m_lpCharacterDetails->setCurrentIndex(0);
ui->m_lpCharacterRemove->setEnabled((ui->m_lpCharacterList->count() > 0));
ui->m_lpCharacterShowDetails->setEnabled((ui->m_lpCharacterList->count() > 0));
ui->m_lpPlaceList->setCurrentIndex(index);
ui->m_lpPlaceDetails->setCurrentIndex(index);
m_lpMainWindow->somethingChanged();
}
void cSceneWindow::onAddPlaceToList()
{
ui->m_lpPlaceRemove->setEnabled((ui->m_lpPlaceList->count() > 0));
ui->m_lpPlaceShowDetails->setEnabled((ui->m_lpPlaceList->count() > 0));
}
void cSceneWindow::onRemovePlaceFromList()
void cSceneWindow::fillObjectList(cObject* lpObjectNew)
{
ui->m_lpPlaceRemove->setEnabled((ui->m_lpPlaceList->count() > 0));
ui->m_lpPlaceShowDetails->setEnabled((ui->m_lpPlaceList->count() > 0));
}
QList<cObjectDescription*> objectList = m_lpScene->objectList();
ui->m_lpObjectList->clear();
for(int x = ui->m_lpObjectDetails->count()-1;x >= 0;x--)
ui->m_lpObjectDetails->removeWidget(ui->m_lpObjectDetails->widget(x));
qint16 index = 0;
for(int x = 0;x < objectList.count();x++)
{
cObjectDescription* lpObjectDescription = objectList[x];
cObject* lpObject = lpObjectDescription->object();
ui->m_lpObjectList->addItem(lpObject->name(), QVariant::fromValue(lpObjectDescription));
cTextEdit* lpTextEdit = new cTextEdit(ui->m_lpObjectDetails);
lpTextEdit->setDocument(lpObjectDescription->description());
ui->m_lpObjectDetails->addWidget(lpTextEdit);
connect(lpTextEdit, &cTextEdit::gotFocus, m_lpMainWindow, &cMainWindow::onTextEditGotFocus);
connect(lpTextEdit, &cTextEdit::lostFocus, m_lpMainWindow, &cMainWindow::onTextEditLostFocus);
connect(lpTextEdit, &cTextEdit::textChanged, this, &cSceneWindow::onObjectDescriptionChanged);
if(lpObject == lpObjectNew)
index = x;
}
ui->m_lpObjectList->setCurrentIndex(index);
ui->m_lpObjectDetails->setCurrentIndex(index);
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));
}
+23
View File
@@ -56,6 +56,29 @@ public:
*/
cScene* scene();
private:
/*!
\brief
\fn fillCharacterList
\param bSelectFirst
*/
void fillCharacterList(cCharacter* lpCharacterNew = 0);
/*!
\brief
\fn fillPlaceList
\param bSelectFirst
*/
void fillPlaceList(cPlace* lpPlaceNew = 0);
/*!
\brief
\fn fillObjectList
\param bSelectFirst
*/
void fillObjectList(cObject* lpObjectNew = 0);
private slots:
/*!
\brief
+9 -3
View File
@@ -76,7 +76,9 @@ SOURCES += \
cdatetimeedit.cpp \
cpropertieswindow.cpp \
ccharacterselectdialog.cpp \
csplashscreen.cpp
csplashscreen.cpp \
cplaceselectdialog.cpp \
cobjectselectdialog.cpp
HEADERS += \
cmainwindow.h \
@@ -114,7 +116,9 @@ HEADERS += \
cdatetimeedit.h \
cpropertieswindow.h \
ccharacterselectdialog.h \
csplashscreen.h
csplashscreen.h \
cplaceselectdialog.h \
cobjectselectdialog.h
FORMS += \
cmainwindow.ui \
@@ -127,7 +131,9 @@ FORMS += \
cplacewindow.ui \
crecherchewindow.ui \
cpropertieswindow.ui \
ccharacterselectdialog.ui
ccharacterselectdialog.ui \
cplaceselectdialog.ui \
cobjectselectdialog.ui
DISTFILES += \
Doxyfile \