Implementation of character deletion.
This commit is contained in:
+27
-2
@@ -38,7 +38,8 @@ cCharacter::cCharacter(qint32 iID, QObject *parent) :
|
||||
m_szSkin(QString("")),
|
||||
m_szSchool(QString("")),
|
||||
m_szJob(QString("")),
|
||||
m_lpDescription(0)
|
||||
m_lpDescription(0),
|
||||
m_bDeleted(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -344,6 +345,17 @@ cTextDocument* cCharacter::description()
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
|
||||
void cCharacter::setDeleted(bool bDeleted)
|
||||
{
|
||||
m_bDeleted = bDeleted;
|
||||
}
|
||||
|
||||
bool cCharacter::deleted()
|
||||
{
|
||||
return(m_bDeleted);
|
||||
}
|
||||
|
||||
void cCharacter::addImage(cImage* lpImage, cTextDocument* lpDescription)
|
||||
{
|
||||
m_imageList.append(new cImageDescription(lpImage, lpDescription));
|
||||
@@ -475,10 +487,12 @@ bool cCharacterList::save()
|
||||
QSqlQuery queryUpdate;
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
QSqlQuery queryDelete;
|
||||
|
||||
queryUpdate.prepare("UPDATE character SET mainCharacter=:mainCharacter, creature=:creature, gender=:gender, title=:title, firstName=:firstName, middleName=:middleName, lastName=:lastName, nickName=:nickName, height=:height, weight=:weight, dateOfBirth=:dateOfBirth, dateOfDeath=:dateOfDeath, placeOfBirth=:placeOfBirth, placeOfDeath=:placeOfDeath, hairColor=:hairColor, hairCut=:hairCut, hairLength=:hairLength, figure=:figure, nature=:nature, spokenLanguages=:spokenLanguages, skin=:skin, school=:school, job=:job, description=:description WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO character (mainCharacter, creature, gender, title, firstName, middleName, lastName, nickName, height, weight, dateOfBirth, dateOfDeath, placeOfBirth, placeOfDeath, hairColor, hairCut, hairLength, figure, nature, spokenLanguages, skin, school, job, description) VALUES (:mainCharacter, :creature, :gender, :title, :firstName, :middleName, :lastName, :nickName, :height, :weight,:dateOfBirth, :dateOfDeath, :placeOfBirth, :placeOfDeath, :hairColor, :hairCut, :hairLength, :figure, :nature, :spokenLanguages, :skin, :school, :job, :description);");
|
||||
querySelect.prepare("SELECT id FROM character WHERE _rowid_=(SELECT MAX(_rowid_) FROM character);");
|
||||
queryDelete.prepare("DELETE FROM character WHERE id=:id;");
|
||||
|
||||
QSqlQuery imageDelete;
|
||||
QSqlQuery imageAdd;
|
||||
@@ -490,7 +504,18 @@ bool cCharacterList::save()
|
||||
{
|
||||
cCharacter* lpCharacter = at(x);
|
||||
|
||||
if(lpCharacter->id() != -1)
|
||||
if(lpCharacter->deleted())
|
||||
{
|
||||
queryDelete.bindValue(":id", lpCharacter->id());
|
||||
|
||||
if(!queryDelete.exec())
|
||||
{
|
||||
myDebug << queryDelete.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
this->removeOne(lpCharacter);
|
||||
}
|
||||
else if(lpCharacter->id() != -1)
|
||||
{
|
||||
queryUpdate.bindValue(":id", lpCharacter->id());
|
||||
queryUpdate.bindValue(":mainCharacter", lpCharacter->mainCharacter());
|
||||
|
||||
+100
-84
@@ -54,14 +54,14 @@ public:
|
||||
\fn setID
|
||||
\param iID
|
||||
*/
|
||||
void setID(const qint32& iID);
|
||||
void setID(const qint32& iID);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn id
|
||||
\return qint32
|
||||
*/
|
||||
qint32 id();
|
||||
qint32 id();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -69,14 +69,14 @@ public:
|
||||
\fn setMainCharacter
|
||||
\param bMainCharacter
|
||||
*/
|
||||
void setMainCharacter(bool bMainCharacter);
|
||||
void setMainCharacter(bool bMainCharacter);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn mainCharacter
|
||||
\return bool
|
||||
*/
|
||||
bool mainCharacter();
|
||||
bool mainCharacter();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -84,14 +84,14 @@ public:
|
||||
\fn setCreature
|
||||
\param szCreature
|
||||
*/
|
||||
void setCreature(const QString& szCreature);
|
||||
void setCreature(const QString& szCreature);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn creature
|
||||
\return QString
|
||||
*/
|
||||
QString creature();
|
||||
QString creature();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -99,21 +99,21 @@ public:
|
||||
\fn setGender
|
||||
\param gender
|
||||
*/
|
||||
void setGender(GENDER gender);
|
||||
void setGender(GENDER gender);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn gender
|
||||
\return GENDER
|
||||
*/
|
||||
GENDER gender();
|
||||
GENDER gender();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn genderText
|
||||
\return QString
|
||||
*/
|
||||
QString genderText();
|
||||
QString genderText();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
\param gender
|
||||
\return QString
|
||||
*/
|
||||
QString genderText(GENDER gender) const;
|
||||
QString genderText(GENDER gender) const;
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -129,14 +129,14 @@ public:
|
||||
\fn setTitle
|
||||
\param szTitle
|
||||
*/
|
||||
void setTitle(const QString& szTitle);
|
||||
void setTitle(const QString& szTitle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn title
|
||||
\return QString
|
||||
*/
|
||||
QString title();
|
||||
QString title();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -144,14 +144,14 @@ public:
|
||||
\fn setFirstName
|
||||
\param szFirstName
|
||||
*/
|
||||
void setFirstName(const QString& szFirstName);
|
||||
void setFirstName(const QString& szFirstName);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn firstName
|
||||
\return QString
|
||||
*/
|
||||
QString firstName();
|
||||
QString firstName();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -159,14 +159,14 @@ public:
|
||||
\fn setMiddleName
|
||||
\param szMiddleName
|
||||
*/
|
||||
void setMiddleName(const QString& szMiddleName);
|
||||
void setMiddleName(const QString& szMiddleName);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn middleName
|
||||
\return QString
|
||||
*/
|
||||
QString middleName();
|
||||
QString middleName();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -174,14 +174,14 @@ public:
|
||||
\fn setLastName
|
||||
\param szLastName
|
||||
*/
|
||||
void setLastName(const QString& szLastName);
|
||||
void setLastName(const QString& szLastName);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn lastName
|
||||
\return QString
|
||||
*/
|
||||
QString lastName();
|
||||
QString lastName();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
\fn name
|
||||
\return QString
|
||||
*/
|
||||
QString name();
|
||||
QString name();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -197,14 +197,14 @@ public:
|
||||
\fn setNickName
|
||||
\param szNickName
|
||||
*/
|
||||
void setNickName(const QString& szNickName);
|
||||
void setNickName(const QString& szNickName);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn nickName
|
||||
\return QString
|
||||
*/
|
||||
QString nickName();
|
||||
QString nickName();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -212,14 +212,14 @@ public:
|
||||
\fn setHeight
|
||||
\param dHeight
|
||||
*/
|
||||
void setHeight(qreal dHeight);
|
||||
void setHeight(qreal dHeight);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn height
|
||||
\return qreal
|
||||
*/
|
||||
qreal height();
|
||||
qreal height();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -227,14 +227,14 @@ public:
|
||||
\fn setWeight
|
||||
\param dWeight
|
||||
*/
|
||||
void setWeight(qreal dWeight);
|
||||
void setWeight(qreal dWeight);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn weight
|
||||
\return qreal
|
||||
*/
|
||||
qreal weight();
|
||||
qreal weight();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -242,14 +242,14 @@ public:
|
||||
\fn setAge
|
||||
\param dAge
|
||||
*/
|
||||
void setAge(qreal dAge);
|
||||
void setAge(qreal dAge);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn age
|
||||
\return qreal
|
||||
*/
|
||||
qreal age();
|
||||
qreal age();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -257,14 +257,14 @@ public:
|
||||
\fn setDateOfBirth
|
||||
\param dateOfBirth
|
||||
*/
|
||||
void setDateOfBirth(const QDate& dateOfBirth);
|
||||
void setDateOfBirth(const QDate& dateOfBirth);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn dateOfBirth
|
||||
\return QDate
|
||||
*/
|
||||
QDate dateOfBirth();
|
||||
QDate dateOfBirth();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -272,14 +272,14 @@ public:
|
||||
\fn setPlaceOfBirth
|
||||
\param szPlaceOfBirth
|
||||
*/
|
||||
void setPlaceOfBirth(const QString& szPlaceOfBirth);
|
||||
void setPlaceOfBirth(const QString& szPlaceOfBirth);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn placeOfBirth
|
||||
\return QString
|
||||
*/
|
||||
QString placeOfBirth();
|
||||
QString placeOfBirth();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -287,14 +287,14 @@ public:
|
||||
\fn setDateOfDeath
|
||||
\param dateOfDeath
|
||||
*/
|
||||
void setDateOfDeath(const QDate& dateOfDeath);
|
||||
void setDateOfDeath(const QDate& dateOfDeath);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn dateOfDeath
|
||||
\return QDate
|
||||
*/
|
||||
QDate dateOfDeath();
|
||||
QDate dateOfDeath();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -302,14 +302,14 @@ public:
|
||||
\fn setPlaceOfDeath
|
||||
\param szPlaceOfDeath
|
||||
*/
|
||||
void setPlaceOfDeath(const QString& szPlaceOfDeath);
|
||||
void setPlaceOfDeath(const QString& szPlaceOfDeath);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn placeOfDeath
|
||||
\return QString
|
||||
*/
|
||||
QString placeOfDeath();
|
||||
QString placeOfDeath();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -317,14 +317,14 @@ public:
|
||||
\fn setHairColor
|
||||
\param szHairColor
|
||||
*/
|
||||
void setHairColor(const QString& szHairColor);
|
||||
void setHairColor(const QString& szHairColor);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn hairColor
|
||||
\return QString
|
||||
*/
|
||||
QString hairColor();
|
||||
QString hairColor();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -332,14 +332,14 @@ public:
|
||||
\fn setHairCut
|
||||
\param szHairCut
|
||||
*/
|
||||
void setHairCut(const QString& szHairCut);
|
||||
void setHairCut(const QString& szHairCut);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn hairCut
|
||||
\return QString
|
||||
*/
|
||||
QString hairCut();
|
||||
QString hairCut();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -347,14 +347,14 @@ public:
|
||||
\fn setHairLength
|
||||
\param szHairLength
|
||||
*/
|
||||
void setHairLength(const QString& szHairLength);
|
||||
void setHairLength(const QString& szHairLength);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn hairLength
|
||||
\return QString
|
||||
*/
|
||||
QString hairLength();
|
||||
QString hairLength();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -362,14 +362,14 @@ public:
|
||||
\fn setFigure
|
||||
\param szFigure
|
||||
*/
|
||||
void setFigure(const QString& szFigure);
|
||||
void setFigure(const QString& szFigure);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn figure
|
||||
\return QString
|
||||
*/
|
||||
QString figure();
|
||||
QString figure();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -377,14 +377,14 @@ public:
|
||||
\fn setNature
|
||||
\param szNature
|
||||
*/
|
||||
void setNature(const QString& szNature);
|
||||
void setNature(const QString& szNature);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn nature
|
||||
\return QString
|
||||
*/
|
||||
QString nature();
|
||||
QString nature();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -392,14 +392,14 @@ public:
|
||||
\fn setSpokenLanguages
|
||||
\param szSpokenLanguages
|
||||
*/
|
||||
void setSpokenLanguages(const QString& szSpokenLanguages);
|
||||
void setSpokenLanguages(const QString& szSpokenLanguages);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn spokenLanguages
|
||||
\return QString
|
||||
*/
|
||||
QString spokenLanguages();
|
||||
QString spokenLanguages();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -407,14 +407,14 @@ public:
|
||||
\fn setSkin
|
||||
\param szSkin
|
||||
*/
|
||||
void setSkin(const QString& szSkin);
|
||||
void setSkin(const QString& szSkin);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn skin
|
||||
\return QString
|
||||
*/
|
||||
QString skin();
|
||||
QString skin();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -422,14 +422,14 @@ public:
|
||||
\fn setSchool
|
||||
\param szSchool
|
||||
*/
|
||||
void setSchool(const QString& szSchool);
|
||||
void setSchool(const QString& szSchool);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn school
|
||||
\return QString
|
||||
*/
|
||||
QString school();
|
||||
QString school();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -437,14 +437,14 @@ public:
|
||||
\fn setJob
|
||||
\param szJob
|
||||
*/
|
||||
void setJob(const QString& szJob);
|
||||
void setJob(const QString& szJob);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn job
|
||||
\return QString
|
||||
*/
|
||||
QString job();
|
||||
QString job();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -452,14 +452,14 @@ public:
|
||||
\fn setDescription
|
||||
\param lpDescription
|
||||
*/
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn description
|
||||
\return cTextDocument
|
||||
*/
|
||||
cTextDocument* description();
|
||||
cTextDocument* description();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
@@ -467,42 +467,58 @@ public:
|
||||
\fn addImage
|
||||
\param lpImage
|
||||
*/
|
||||
void addImage(cImage* lpImage, cTextDocument* lpDescription);
|
||||
void addImage(cImage* lpImage, cTextDocument* lpDescription);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn images
|
||||
\return QList<cImage *>
|
||||
*/
|
||||
QList<cImageDescription*> images();
|
||||
QList<cImageDescription*> images();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setDeleted
|
||||
\param bDeleted
|
||||
*/
|
||||
void setDeleted(bool bDeleted);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn deleted
|
||||
\return bool
|
||||
*/
|
||||
bool deleted();
|
||||
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<cImageDescription*> 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<cImageDescription*> m_imageList; /*!< TODO: describe */
|
||||
bool m_bDeleted; /*!< TODO: describe */
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
+40
-3
@@ -1440,7 +1440,7 @@ void cMainWindow::onDeletePart()
|
||||
|
||||
}
|
||||
|
||||
if(QMessageBox::question(this, "Delete Part", tr("Are you sure you want to delete this part:<br>") + "<b><center>" + lpPart->name() + "</center></b>") != QMessageBox::Yes)
|
||||
if(QMessageBox::question(this, "Delete Part", tr("Are you sure you want to delete this part:<br>") + "<b>" + lpPart->name() + "</b>") != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
lpPart->setDeleted(true);
|
||||
@@ -1542,7 +1542,7 @@ void cMainWindow::onDeleteChapter()
|
||||
|
||||
}
|
||||
|
||||
if(QMessageBox::question(this, "Delete Chapter", tr("Are you sure you want to delete this chapter:<br>") + "<b><center>" + lpChapter->name() + "</center></b>" + tr("<br>from part <br>") + "<b><center>" + lpChapter->part()->name() + "</center></b>") != QMessageBox::Yes)
|
||||
if(QMessageBox::question(this, "Delete Chapter", tr("Are you sure you want to delete this chapter:<br>") + "<b>" + lpChapter->name() + "</b>" + tr("<br>from part <br>") + "<b>" + lpChapter->part()->name() + "</b>") != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
lpChapter->setDeleted(true);
|
||||
@@ -1643,7 +1643,7 @@ void cMainWindow::onDeleteScene()
|
||||
if(!lpScene)
|
||||
return;
|
||||
|
||||
if(QMessageBox::question(this, "Delete Scene", tr("Are you sure you want to delete this scene:<br>") + "<b><center>" + lpScene->name() + "</center></b>" + tr("<br>from chapter <br>") + "<b><center>" + lpScene->chapter()->name() + "</center></b>") != QMessageBox::Yes)
|
||||
if(QMessageBox::question(this, "Delete Scene", tr("Are you sure you want to delete this scene:<br>") + "<b>" + lpScene->name() + "</b>" + tr("<br>from chapter <br>") + "<b>" + lpScene->chapter()->name() + "</b>") != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
lpScene->setDeleted(true);
|
||||
@@ -1716,6 +1716,43 @@ void cMainWindow::onEditCharacter()
|
||||
|
||||
void cMainWindow::onDeleteCharacter()
|
||||
{
|
||||
QStandardItem* lpItem = m_lpCharacterModel->itemFromIndex(ui->m_lpCharacterList->currentIndex());
|
||||
if(!lpItem)
|
||||
return;
|
||||
|
||||
cCharacter* lpCharacter = qvariant_cast<cCharacter*>(lpItem->data());
|
||||
|
||||
if(!lpCharacter)
|
||||
return;
|
||||
|
||||
if(m_lpStoryBook->characterInUse(lpCharacter))
|
||||
{
|
||||
QMessageBox::critical(this, "Delete Character", tr("This character is still in use.\nPlease delete the usage before deleting the character."));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if(QMessageBox::question(this, "Delete Character", tr("Are you sure you want to delete this character:<br>") + "<b>" + lpCharacter->name() + "</b>?") != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
lpCharacter->setDeleted(true);
|
||||
m_lpStoryBook->fillCharacterList(ui->m_lpCharacterList);
|
||||
m_bSomethingChanged = true;
|
||||
updateWindowTitle();
|
||||
|
||||
for(int x = 0;x < ui->m_lpMainTab->count();x++)
|
||||
{
|
||||
cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->widget(x);
|
||||
if(lpWidget->type() == cWidget::TYPE_character)
|
||||
{
|
||||
cCharacterWindow* lpCharacterWindow = (cCharacterWindow*)lpWidget->widget();
|
||||
if(lpCharacterWindow->character() == lpCharacter)
|
||||
{
|
||||
onMainTabTabCloseRequested(x);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cMainWindow::onAddPlace()
|
||||
|
||||
@@ -127,6 +127,26 @@ cRecherche* cRechercheList::find(const qint32& iID)
|
||||
return(0);
|
||||
}
|
||||
|
||||
QList<cRecherche*> cRechercheList::find(cCharacter* lpCharacter)
|
||||
{
|
||||
QList<cRecherche*> rechercheList;
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
QList<cCharacterDescription*> list = at(x)->characterList();
|
||||
|
||||
for(int y = 0;y < list.count();y++)
|
||||
{
|
||||
if(list.at(y)->character() == lpCharacter)
|
||||
{
|
||||
rechercheList.append(at(x));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(rechercheList);
|
||||
}
|
||||
|
||||
bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterList, cObjectList *lpObjectList, cPlaceList *lpPlaceList)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
@@ -219,6 +219,15 @@ public:
|
||||
\return cRecherche
|
||||
*/
|
||||
cRecherche* find(const qint32& iID);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn find
|
||||
\param lpCharacter
|
||||
\return QList<cCharacter *>
|
||||
*/
|
||||
QList<cRecherche *> find(cCharacter* lpCharacter);
|
||||
};
|
||||
|
||||
#endif // CRECHERCHE_H
|
||||
|
||||
+20
@@ -276,6 +276,26 @@ QList<cScene*> cSceneList::find(cChapter* lpChapter)
|
||||
return(sceneList);
|
||||
}
|
||||
|
||||
QList<cScene*> cSceneList::find(cCharacter* lpCharacter)
|
||||
{
|
||||
QList<cScene*> sceneList;
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
QList<cCharacterDescription*> list = at(x)->characterList();
|
||||
|
||||
for(int y = 0;y < list.count();y++)
|
||||
{
|
||||
if(list.at(y)->character() == lpCharacter)
|
||||
{
|
||||
sceneList.append(at(x));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(sceneList);
|
||||
}
|
||||
|
||||
qint32 cSceneList::nextSort(cChapter* lpChapter)
|
||||
{
|
||||
qint32 iSort = -1;
|
||||
|
||||
@@ -401,6 +401,15 @@ public:
|
||||
*/
|
||||
cScene* find(const qint32& iID);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn find
|
||||
\param lpCharacter
|
||||
\return QList<cCharacter *>
|
||||
*/
|
||||
QList<cScene *> find(cCharacter* lpCharacter);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
|
||||
@@ -666,6 +666,17 @@ bool cStoryBook::hasScene(cChapter* lpChapter)
|
||||
return(m_sceneList.find(lpChapter).count() > 0);
|
||||
}
|
||||
|
||||
bool cStoryBook::characterInUse(cCharacter* lpCharacter)
|
||||
{
|
||||
if(m_sceneList.find(lpCharacter).count() > 0)
|
||||
return(true);
|
||||
|
||||
if(m_rechercheList.find(lpCharacter).count() > 0)
|
||||
return(true);
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool cStoryBook::fillOutlineList(QTreeView* lpView)
|
||||
{
|
||||
QMap<qint32, QStandardItem*> part;
|
||||
@@ -797,6 +808,9 @@ bool cStoryBook::fillCharacterList(QTreeView* lpView)
|
||||
cCharacter* lpCharacter = m_characterList.at(x);
|
||||
QList<QStandardItem*> lpItems;
|
||||
|
||||
if(lpCharacter->deleted())
|
||||
continue;
|
||||
|
||||
lpItems.append(new QStandardItem(lpCharacter->name()));
|
||||
lpItems.append(new QStandardItem(lpCharacter->creature()));
|
||||
lpItems.append(new QStandardItem(lpCharacter->genderText()));
|
||||
|
||||
@@ -277,6 +277,15 @@ public:
|
||||
*/
|
||||
bool hasScene(cChapter* lpChapter);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn characterInUse
|
||||
\param lpCharacter
|
||||
\return bool
|
||||
*/
|
||||
bool characterInUse(cCharacter* lpCharacter);
|
||||
|
||||
private:
|
||||
QString m_szProject; /*!< TODO: describe */
|
||||
bool m_bIsOpen; /*!< TODO: describe */
|
||||
|
||||
Reference in New Issue
Block a user