This commit is contained in:
Herwig Birke
2018-05-17 15:07:20 +02:00
parent cd95e5e4c2
commit 849a3e1f85
17 changed files with 536 additions and 217 deletions
+22 -11
View File
@@ -16,7 +16,18 @@
/*!
\brief
\brief The cStoryBook class provides basic values of a book project.
With the constructor, the title of the book may be set.
cBook* lpBook = new cBook("My title");
If the database has already been loaded, the book class may be initialized like this:
cBook* lpBook = new cBook;
lpBook->load();
This class should always be initialized by cStoryBook.
\class cBook cbook.h "cbook.h"
*/
@@ -25,7 +36,7 @@ class cBook : public QObject
Q_OBJECT
public:
/*!
\brief constructor of cBook
\brief Creates a new cBook with the given <i>title</i> and <i>parent</i> to hold basic book project values. Use load() to load the values from the database.
\fn cBook
\param szTitle title of the book
@@ -56,7 +67,7 @@ public:
*/
void setTitle(const QString& szTitle);
/*!
\brief Returns the title of the book.
\brief Return the title of the book.
\fn title
\return title of the book
@@ -168,14 +179,14 @@ public:
*/
QDateTime targetDate();
private:
QString m_szTitle; /*!< title of the document */
QString m_szSubtitle; /*!< subtitle of the document */
cTextDocument* m_lpShortDescription; /*!< short description of the document. The text may be formatted */
cTextDocument* m_lpDescription; /*!< description of the document. The text may be formatted */
QString m_szAuthor; /*!< name of the author of the document */
QDateTime m_startedAt; /*!< date and time when the document has been startd */
QDateTime m_finishedAt; /*!< date and time when the document has been finished */
QDateTime m_targetDate; /*!< date and time when the document should be finished */
QString m_szTitle; /*!< This property holds the title of the document.<br>The default value is empty. <br><b>Access functions:</b><br><table><tr><td>QString</td><td><b>title</b>()</td></tr><tr><td>void</td><td><b>setTitle</b>(const QString& szTitle)</td></tr></table> */
QString m_szSubtitle; /*!< subtitle of the document */
cTextDocument* m_lpShortDescription; /*!< short description of the document. The text may be formatted */
cTextDocument* m_lpDescription; /*!< description of the document. The text may be formatted */
QString m_szAuthor; /*!< name of the author of the document */
QDateTime m_startedAt; /*!< date and time when the document has been startd */
QDateTime m_finishedAt; /*!< date and time when the document has been finished */
QDateTime m_targetDate; /*!< date and time when the document should be finished */
};
Q_DECLARE_METATYPE(cBook*)
+37 -11
View File
@@ -344,18 +344,43 @@ cTextDocument* cCharacter::description()
return(m_lpDescription);
}
void cCharacter::addImage(cImage* lpImage)
void cCharacter::addImage(cImage* lpImage, cTextDocument* lpDescription)
{
if(m_imageList.contains(lpImage))
return;
m_imageList.append(lpImage);
m_imageList.append(new cImageDescription(lpImage, lpDescription));
}
QList<cImage*> cCharacter::images()
QList<cImageDescription *> cCharacter::images()
{
return(m_imageList);
}
cCharacterDescription::cCharacterDescription(cCharacter* lpCharacter, cTextDocument* lpDescription, QObject* parent) :
QObject(parent)
{
setCharacter(lpCharacter);
setDescription(lpDescription);
}
void cCharacterDescription::setCharacter(cCharacter* lpCharacter)
{
m_lpCharacter = lpCharacter;
}
cCharacter* cCharacterDescription::character()
{
return(m_lpCharacter);
}
void cCharacterDescription::setDescription(cTextDocument* lpDescription)
{
m_lpDescription = lpDescription;
}
cTextDocument* cCharacterDescription::description()
{
return(m_lpDescription);
}
cCharacter* cCharacterList::add(const qint32& iID)
{
cCharacter* lpCharacter = find(iID);
@@ -424,7 +449,7 @@ bool cCharacterList::load(cImageList *lpImageList)
lpCharacter->setDescription(blob2TextDocument(query.value("description").toByteArray()));
}
query.prepare("SELECT characterID, imageID FROM characterImage;");
query.prepare("SELECT characterID, imageID, description FROM characterImage;");
if(!query.exec())
{
myDebug << query.lastError().text();
@@ -438,7 +463,7 @@ bool cCharacterList::load(cImageList *lpImageList)
{
cImage* lpImage = lpImageList->find(query.value("imageID").toInt());
if(lpImage)
lpCharacter->addImage(lpImage);
lpCharacter->addImage(lpImage, blob2TextDocument(query.value("description").toByteArray()));
}
}
@@ -459,7 +484,7 @@ bool cCharacterList::save()
QSqlQuery imageAdd;
imageDelete.prepare("DELETE FROM characterImage WHERE characterID=:characterID;");
imageAdd.prepare("INSERT INTO characterImage (characterID, imageID) VALUES (:characterID, :imageID);");
imageAdd.prepare("INSERT INTO characterImage (characterID, imageID, description) VALUES (:characterID, :imageID, :description);");
for(int x = 0;x < count();x++)
{
@@ -548,14 +573,15 @@ bool cCharacterList::save()
return(false);
}
QList<cImage*> images = lpCharacter->images();
QList<cImageDescription*> images = lpCharacter->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images.at(x);
cImageDescription* lpImage = images.at(x);
imageAdd.bindValue(":characterID", lpCharacter->id());
imageAdd.bindValue(":imageID", lpImage->id());
imageAdd.bindValue(":imageID", lpImage->image()->id());
imageAdd.bindValue(":description", textDocument2Blob(lpImage->description()));
if(!imageAdd.exec())
{
myDebug << imageAdd.lastError().text();
+74 -29
View File
@@ -467,47 +467,92 @@ public:
\fn addImage
\param lpImage
*/
void addImage(cImage* lpImage);
void addImage(cImage* lpImage, cTextDocument* lpDescription);
/*!
\brief
\fn images
\return QList<cImage *>
*/
QList<cImage*> images();
QList<cImageDescription*> images();
private:
qint32 m_id; /*!< TODO: describe */
bool m_bMainCharacter; /*!< TODO: describe */
QString m_szCreature; /*!< TODO: describe */
GENDER m_gender; /*!< TODO: describe */
QString m_szTitle; /*!< TODO: describe */
QString m_szFirstName; /*!< TODO: describe */
QString m_szMiddleName; /*!< TODO: describe */
QString m_szLastName; /*!< TODO: describe */
QString m_szNickName; /*!< TODO: describe */
qreal m_dHeight; /*!< TODO: describe */
qreal m_dWeight; /*!< TODO: describe */
qreal m_dAge; /*!< TODO: describe */
QDate m_dateOfBirth; /*!< TODO: describe */
QString m_szPlaceOfBirth; /*!< TODO: describe */
QDate m_dateOfDeath; /*!< TODO: describe */
QString m_szPlaceOfDeath; /*!< TODO: describe */
QString m_szHairColor; /*!< TODO: describe */
QString m_szHairCut; /*!< TODO: describe */
QString m_szHairLength; /*!< TODO: describe */
QString m_szFigure; /*!< TODO: describe */
QString m_szNature; /*!< TODO: describe */
QString m_szSpokenLanguages; /*!< TODO: describe */
QString m_szSkin; /*!< TODO: describe */
QString m_szSchool; /*!< TODO: describe */
QString m_szJob; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
QList<cImage*> 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 */
signals:
public slots:
};
/*!
\brief
\class cCharacterDescription ccharacter.h "ccharacter.h"
*/
class cCharacterDescription : public QObject
{
Q_OBJECT
public:
cCharacterDescription(cCharacter* lpCharacter, cTextDocument* lpDescription, QObject* parent = nullptr);
/*!
\brief
\fn setCharacter
\param lpCharacter
*/
void setCharacter(cCharacter* lpCharacter);
/*!
\brief
\fn character
\return cCharacter
*/
cCharacter* character();
/*!
\brief
\fn setDescription
\param lpDescription
*/
void setDescription(cTextDocument* lpDescription);
/*!
\brief
\fn description
\return cTextDocument
*/
cTextDocument* description();
private:
cCharacter* m_lpCharacter; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
};
Q_DECLARE_METATYPE(cCharacter*)
/*!
+5 -4
View File
@@ -148,12 +148,13 @@ void cCharacterWindow::setCharacter(cCharacter* lpCharacter)
ui->m_lpJob->setHtml(lpCharacter->job());
ui->m_lpDescription->setDocument(lpCharacter->description());
QList<cImage*> images = lpCharacter->images();
QList<cImageDescription*> images = lpCharacter->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images[x];
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
cImageDescription* lpImageDescription = images[x];
cImage* lpImage = lpImageDescription->image();
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
ui->m_lpLayout->addWidget(lpImageWidget);
+27
View File
@@ -71,6 +71,33 @@ QPixmap cImage::image()
return(m_image);
}
cImageDescription::cImageDescription(cImage* lpImage, cTextDocument* lpDescription, QObject* parent) :
QObject(parent)
{
setImage(lpImage);
setDescription(lpDescription);
}
void cImageDescription::setImage(cImage* lpImage)
{
m_lpImage = lpImage;
}
cImage* cImageDescription::image()
{
return(m_lpImage);
}
void cImageDescription::setDescription(cTextDocument* lpDescription)
{
m_lpDescription = lpDescription;
}
cTextDocument* cImageDescription::description()
{
return(m_lpDescription);
}
cImage* cImageList::add(const qint32& iID)
{
cImage* lpImage = find(iID);
+45
View File
@@ -108,6 +108,51 @@ private:
QPixmap m_image; /*!< TODO: describe */
};
/*!
\brief
\class cImageDescription cimage.h "cimage.h"
*/
class cImageDescription : public QObject
{
Q_OBJECT
public:
cImageDescription(cImage* lpImage, cTextDocument* lpDescription, QObject* parent = nullptr);
/*!
\brief
\fn setImage
\param lpImage
*/
void setImage(cImage* lpImage);
/*!
\brief
\fn image
\return cImage
*/
cImage* image();
/*!
\brief
\fn setDescription
\param lpDescription
*/
void setDescription(cTextDocument* lpDescription);
/*!
\brief
\fn description
\return cTextDocument
*/
cTextDocument* description();
private:
cImage* m_lpImage; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
};
Q_DECLARE_METATYPE(cImage*)
/*!
+1
View File
@@ -1969,6 +1969,7 @@ void cMainWindow::openRecentFile()
m_lpStoryBook->fillObjectList(ui->m_lpObjectList);
m_lpStoryBook->fillRechercheList(ui->m_lpRechercheList);
setCurrentFile(szProjectName);
updateWindowTitle();
}
}
+37 -10
View File
@@ -60,18 +60,43 @@ cTextDocument* cObject::description()
return(m_lpDescription);
}
void cObject::addImage(cImage* lpImage)
void cObject::addImage(cImage* lpImage, cTextDocument* lpDescription)
{
if(m_imageList.contains(lpImage))
return;
m_imageList.append(lpImage);
m_imageList.append(new cImageDescription(lpImage, lpDescription));
}
QList<cImage*> cObject::images()
QList<cImageDescription*> cObject::images()
{
return(m_imageList);
}
cObjectDescription::cObjectDescription(cObject* lpObject, cTextDocument* lpDescription, QObject* parent) :
QObject(parent)
{
setObject(lpObject);
setDescription(lpDescription);
}
void cObjectDescription::setObject(cObject* lpObject)
{
m_lpObject = lpObject;
}
cObject* cObjectDescription::object()
{
return(m_lpObject);
}
void cObjectDescription::setDescription(cTextDocument* lpDescription)
{
m_lpDescription = lpDescription;
}
cTextDocument* cObjectDescription::description()
{
return(m_lpDescription);
}
cObject* cObjectList::add(const qint32& iID)
{
cObject* lpObject = find(iID);
@@ -119,7 +144,7 @@ bool cObjectList::load(cImageList *lpImageList)
lpObject->setDescription(blob2TextDocument(query.value("description").toByteArray()));
}
query.prepare("SELECT objectID, imageID FROM objectImage;");
query.prepare("SELECT objectID, imageID, description FROM objectImage;");
if(!query.exec())
{
myDebug << query.lastError().text();
@@ -133,7 +158,7 @@ bool cObjectList::load(cImageList *lpImageList)
{
cImage* lpImage = lpImageList->find(query.value("imageID").toInt());
if(lpImage)
lpObject->addImage(lpImage);
lpObject->addImage(lpImage, blob2TextDocument(query.value(":description").toByteArray()));
}
}
@@ -154,7 +179,7 @@ bool cObjectList::save()
QSqlQuery imageAdd;
imageDelete.prepare("DELETE FROM objectImage WHERE objectID=:objectID;");
imageAdd.prepare("INSERT INTO objectImage (objectID, imageID) VALUES (:objectID, :imageID);");
imageAdd.prepare("INSERT INTO objectImage (objectID, imageID, description) VALUES (:objectID, :imageID, :description);");
for(int x = 0;x < count();x++)
{
@@ -201,14 +226,16 @@ bool cObjectList::save()
return(false);
}
QList<cImage*> images = lpObject->images();
QList<cImageDescription*> images = lpObject->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images.at(x);
cImageDescription* lpImageDescription = images.at(x);
cImage* lpImage = lpImageDescription->image();
imageAdd.bindValue(":objectID", lpObject->id());
imageAdd.bindValue(":imageID", lpImage->id());
imageAdd.bindValue(":description", textDocument2Blob(lpImageDescription->description()));
if(!imageAdd.exec())
{
myDebug << imageAdd.lastError().text();
+62 -16
View File
@@ -40,14 +40,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
@@ -55,14 +55,14 @@ public:
\fn setName
\param szName
*/
void setName(const QString& szName);
void setName(const QString& szName);
/*!
\brief
\fn name
\return QString
*/
QString name();
QString name();
/*!
\brief
@@ -70,14 +70,14 @@ public:
\fn setType
\param szType
*/
void setType(const QString& szType);
void setType(const QString& szType);
/*!
\brief
\fn type
\return QString
*/
QString type();
QString type();
/*!
\brief
@@ -85,42 +85,88 @@ public:
\fn setDescription
\param lpDescription
*/
void setDescription(cTextDocument* lpDescription);
void setDescription(cTextDocument* lpDescription);
/*!
\brief
\fn description
\return cTextDocument
*/
cTextDocument* description();
cTextDocument* description();
/*!
\brief
\fn addImage
\param lpImage
\param lpDescription
*/
void addImage(cImage* lpImage);
void addImage(cImage* lpImage, cTextDocument* lpDescription);
/*!
\brief
\fn images
\return QList<cImage *>
\return QList<cImageDescription *>
*/
QList<cImage*> images();
QList<cImageDescription*> images();
private:
qint32 m_iID; /*!< TODO: describe */
QString m_szName; /*!< TODO: describe */
QString m_szType; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
QList<cImage*> m_imageList; /*!< TODO: describe */
qint32 m_iID; /*!< TODO: describe */
QString m_szName; /*!< TODO: describe */
QString m_szType; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
QList<cImageDescription*> m_imageList; /*!< TODO: describe */
signals:
public slots:
};
/*!
\brief
\class cObjectDescription cobject.h "cobject.h"
*/
class cObjectDescription : public QObject
{
Q_OBJECT
public:
cObjectDescription(cObject* lpObject, cTextDocument* lpDescription, QObject* parent = nullptr);
/*!
\brief
\fn setObject
\param lpObject
*/
void setObject(cObject* lpObject);
/*!
\brief
\fn object
\return cObject
*/
cObject* object();
/*!
\brief
\fn setDescription
\param lpDescription
*/
void setDescription(cTextDocument* lpDescription);
/*!
\brief
\fn description
\return cTextDocument
*/
cTextDocument* description();
private:
cObject* m_lpObject; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
};
Q_DECLARE_METATYPE(cObject*)
/*!
+5 -4
View File
@@ -46,12 +46,13 @@ void cObjectWindow::setObject(cObject* lpObject)
ui->m_lpType->setText(lpObject->type());
ui->m_lpDescription->setDocument(lpObject->description());
QList<cImage*> images = lpObject->images();
QList<cImageDescription*> images = lpObject->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images[x];
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
cImageDescription* lpImageDescription = images[x];
cImage* lpImage = lpImageDescription->image();
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
ui->m_lpLayout->addWidget(lpImageWidget);
+37 -10
View File
@@ -71,18 +71,43 @@ cTextDocument* cPlace::description()
return(m_lpDescription);
}
void cPlace::addImage(cImage* lpImage)
void cPlace::addImage(cImage* lpImage, cTextDocument* lpDescription)
{
if(m_imageList.contains(lpImage))
return;
m_imageList.append(lpImage);
m_imageList.append(new cImageDescription(lpImage, lpDescription));
}
QList<cImage*> cPlace::images()
QList<cImageDescription*> cPlace::images()
{
return(m_imageList);
}
cPlaceDescription::cPlaceDescription(cPlace* lpPlace, cTextDocument* lpDescription, QObject* parent) :
QObject(parent)
{
setPlace(lpPlace);
setDescription(lpDescription);
}
void cPlaceDescription::setPlace(cPlace* lpPlace)
{
m_lpPlace = lpPlace;
}
cPlace* cPlaceDescription::place()
{
return(m_lpPlace);
}
void cPlaceDescription::setDescription(cTextDocument* lpDescription)
{
m_lpDescription = lpDescription;
}
cTextDocument* cPlaceDescription::description()
{
return(m_lpDescription);
}
cPlace* cPlaceList::add(const qint32& iID)
{
cPlace* lpPlace = find(iID);
@@ -131,7 +156,7 @@ bool cPlaceList::load(cImageList *lpImageList)
lpPlace->setDescription(blob2TextDocument(query.value("description").toByteArray()));
}
query.prepare("SELECT placeID, imageID FROM placeImage;");
query.prepare("SELECT placeID, imageID, description FROM placeImage;");
if(!query.exec())
{
myDebug << query.lastError().text();
@@ -145,7 +170,7 @@ bool cPlaceList::load(cImageList *lpImageList)
{
cImage* lpImage = lpImageList->find(query.value("imageID").toInt());
if(lpImage)
lpPlace->addImage(lpImage);
lpPlace->addImage(lpImage, blob2TextDocument(query.value("description").toByteArray()));
}
}
@@ -166,7 +191,7 @@ bool cPlaceList::save()
QSqlQuery imageAdd;
imageDelete.prepare("DELETE FROM placeImage WHERE placeID=:placeID;");
imageAdd.prepare("INSERT INTO placeImage (placeID, imageID) VALUES (:placeID, :imageID);");
imageAdd.prepare("INSERT INTO placeImage (placeID, imageID, description) VALUES (:placeID, :imageID, :description);");
for(int x = 0;x < count();x++)
{
@@ -215,14 +240,16 @@ bool cPlaceList::save()
return(false);
}
QList<cImage*> images = lpPlace->images();
QList<cImageDescription*> images = lpPlace->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images.at(x);
cImageDescription* lpImageDescription = images.at(x);
cImage* lpImage = lpImageDescription->image();
imageAdd.bindValue(":placeID", lpPlace->id());
imageAdd.bindValue(":imageID", lpImage->id());
imageAdd.bindValue(":description", textDocument2Blob(lpImageDescription->description()));
if(!imageAdd.exec())
{
myDebug << imageAdd.lastError().text();
+79 -33
View File
@@ -40,14 +40,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
@@ -55,14 +55,14 @@ public:
\fn setName
\param szName
*/
void setName(const QString& szName);
void setName(const QString& szName);
/*!
\brief
\fn name
\return QString
*/
QString name();
QString name();
/*!
\brief
@@ -70,14 +70,14 @@ public:
\fn setLocation
\param szLocation
*/
void setLocation(const QString& szLocation);
void setLocation(const QString& szLocation);
/*!
\brief
\fn location
\return QString
*/
QString location();
QString location();
/*!
\brief
@@ -85,14 +85,84 @@ public:
\fn setType
\param szType
*/
void setType(const QString& szType);
void setType(const QString& szType);
/*!
\brief
\fn type
\return QString
*/
QString type();
QString type();
/*!
\brief
\fn setDescription
\param lpDescription
*/
void setDescription(cTextDocument* lpDescription);
/*!
\brief
\fn description
\return cTextDocument
*/
cTextDocument* description();
/*!
\brief
\fn addImage
\param lpImage
\param lpDescription
*/
void addImage(cImage* lpImage, cTextDocument* lpDescription);
/*!
\brief
\fn images
\return QList<cImageDescription *>
*/
QList<cImageDescription*> images();
private:
qint32 m_iID; /*!< TODO: describe */
QString m_szName; /*!< TODO: describe */
QString m_szLocation; /*!< TODO: describe */
QString m_szType; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
QList<cImageDescription*> m_imageList; /*!< TODO: describe */
signals:
public slots:
};
/*!
\brief
\class cPlaceDescription cplace.h "cplace.h"
*/
class cPlaceDescription : public QObject
{
Q_OBJECT
public:
cPlaceDescription(cPlace* lpPlace, cTextDocument* lpDescription, QObject* parent = nullptr);
/*!
\brief
\fn setPlace
\param lpPlace
*/
void setPlace(cPlace* lpPlace);
/*!
\brief
\fn place
\return cPlace
*/
cPlace* place();
/*!
\brief
@@ -108,33 +178,9 @@ public:
\return cTextDocument
*/
cTextDocument* description();
/*!
\brief
\fn addImage
\param lpImage
*/
void addImage(cImage* lpImage);
/*!
\brief
\fn images
\return QList<cImage *>
*/
QList<cImage*> images();
private:
qint32 m_iID; /*!< TODO: describe */
QString m_szName; /*!< TODO: describe */
QString m_szLocation; /*!< TODO: describe */
QString m_szType; /*!< TODO: describe */
cPlace* m_lpPlace; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
QList<cImage*> m_imageList; /*!< TODO: describe */
signals:
public slots:
};
Q_DECLARE_METATYPE(cPlace*)
+5 -4
View File
@@ -50,12 +50,13 @@ void cPlaceWindow::setPlace(cPlace* lpPlace)
ui->m_lpLocation->setText(lpPlace->location());
ui->m_lpDescription->setDocument(lpPlace->description());
QList<cImage*> images = lpPlace->images();
QList<cImageDescription*> images = lpPlace->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images[x];
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
cImageDescription* lpImageDescription = images[x];
cImage* lpImage = lpImageDescription->image();
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
ui->m_lpLayout->addWidget(lpImageWidget);
+40 -40
View File
@@ -60,50 +60,42 @@ cTextDocument* cRecherche::description()
return(m_lpDescription);
}
void cRecherche::addImage(cImage* lpImage)
void cRecherche::addImage(cImage* lpImage, cTextDocument* lpDescription)
{
if(m_imageList.contains(lpImage))
return;
m_imageList.append(lpImage);
m_imageList.append(new cImageDescription(lpImage, lpDescription));
}
void cRecherche::addCharacter(cCharacter* lpCharacter)
void cRecherche::addCharacter(cCharacter* lpCharacter, cTextDocument* lpDescription)
{
if(m_characterList.contains(lpCharacter))
return;
m_characterList.append(lpCharacter);
m_characterList.append(new cCharacterDescription(lpCharacter, lpDescription));
}
void cRecherche::addObject(cObject* lpObject)
void cRecherche::addObject(cObject* lpObject, cTextDocument* lpDescription)
{
if(m_objectList.contains(lpObject))
return;
m_objectList.append(lpObject);
m_objectList.append(new cObjectDescription(lpObject, lpDescription));
}
void cRecherche::addPlace(cPlace* lpPlace)
void cRecherche::addPlace(cPlace* lpPlace, cTextDocument* lpDescription)
{
if(m_placeList.contains(lpPlace))
return;
m_placeList.append(lpPlace);
m_placeList.append(new cPlaceDescription(lpPlace, lpDescription));
}
QList<cImage*> cRecherche::images()
QList<cImageDescription*> cRecherche::images()
{
return(m_imageList);
}
QList<cCharacter*> cRecherche::characterList()
QList<cCharacterDescription*> cRecherche::characterList()
{
return(m_characterList);
}
QList<cObject*> cRecherche::objectList()
QList<cObjectDescription*> cRecherche::objectList()
{
return(m_objectList);
}
QList<cPlace*> cRecherche::placeList()
QList<cPlaceDescription*> cRecherche::placeList()
{
return(m_placeList);
}
@@ -155,7 +147,7 @@ bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterLi
lpObject->setDescription(blob2TextDocument(query.value("description").toByteArray()));
}
query.prepare("SELECT rechercheID, imageID FROM rechercheImage;");
query.prepare("SELECT rechercheID, imageID, description FROM rechercheImage;");
if(!query.exec())
{
myDebug << query.lastError().text();
@@ -169,11 +161,11 @@ bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterLi
{
cImage* lpImage = lpImageList->find(query.value("imageID").toInt());
if(lpImage)
lpRecherche->addImage(lpImage);
lpRecherche->addImage(lpImage, blob2TextDocument(query.value("description").toByteArray()));
}
}
query.prepare("SELECT rechercheID, characterID FROM rechercheCharacter;");
query.prepare("SELECT rechercheID, characterID, description FROM rechercheCharacter;");
if(!query.exec())
{
myDebug << query.lastError().text();
@@ -187,11 +179,11 @@ bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterLi
{
cCharacter* lpCharacter = lpCharacterList->find(query.value("characterID").toInt());
if(lpCharacter)
lpRecherche->addCharacter(lpCharacter);
lpRecherche->addCharacter(lpCharacter, blob2TextDocument(query.value("description").toByteArray()));
}
}
query.prepare("SELECT rechercheID, objectID FROM rechercheObject;");
query.prepare("SELECT rechercheID, objectID, description FROM rechercheObject;");
if(!query.exec())
{
myDebug << query.lastError().text();
@@ -205,11 +197,11 @@ bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterLi
{
cObject* lpObject = lpObjectList->find(query.value("objectID").toInt());
if(lpObject)
lpRecherche->addObject(lpObject);
lpRecherche->addObject(lpObject, blob2TextDocument(query.value("description").toByteArray()));
}
}
query.prepare("SELECT rechercheID, placeID FROM recherchePlace;");
query.prepare("SELECT rechercheID, placeID, description FROM recherchePlace;");
if(!query.exec())
{
myDebug << query.lastError().text();
@@ -223,7 +215,7 @@ bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterLi
{
cPlace* lpPlace = lpPlaceList->find(query.value("placeID").toInt());
if(lpPlace)
lpRecherche->addPlace(lpPlace);
lpRecherche->addPlace(lpPlace, blob2TextDocument(query.value("description").toByteArray()));
}
}
@@ -243,22 +235,22 @@ bool cRechercheList::save()
QSqlQuery imageDelete;
QSqlQuery imageAdd;
imageDelete.prepare("DELETE FROM rechercheImage WHERE rechercheID=:rechercheID;");
imageAdd.prepare("INSERT INTO rechercheImage (rechercheID, imageID) VALUES (:rechercheID, :imageID);");
imageAdd.prepare("INSERT INTO rechercheImage (rechercheID, imageID, description) VALUES (:rechercheID, :imageID, :description);");
QSqlQuery characterDelete;
QSqlQuery characterAdd;
characterDelete.prepare("DELETE FROM rechercheCharacter WHERE rechercheID=:rechercheID;");
characterAdd.prepare("INSERT INTO rechercheCharacter (rechercheID, characterID) VALUES (:rechercheID, :characterID);");
characterAdd.prepare("INSERT INTO rechercheCharacter (rechercheID, characterID, description) VALUES (:rechercheID, :characterID, :description);");
QSqlQuery objectDelete;
QSqlQuery objectAdd;
objectDelete.prepare("DELETE FROM rechercheObject WHERE rechercheID=:rechercheID;");
objectAdd.prepare("INSERT INTO rechercheObject (rechercheID, ObjectID) VALUES (:rechercheID, :objectID);");
objectAdd.prepare("INSERT INTO rechercheObject (rechercheID, ObjectID, description) VALUES (:rechercheID, :objectID, :description);");
QSqlQuery placeDelete;
QSqlQuery placeAdd;
placeDelete.prepare("DELETE FROM recherchePlace WHERE rechercheID=:rechercheID;");
placeAdd.prepare("INSERT INTO recherchePlace (rechercheID, placeID) VALUES (:rechercheID, :placeID);");
placeAdd.prepare("INSERT INTO recherchePlace (rechercheID, placeID, description) VALUES (:rechercheID, :placeID, :description);");
for(int x = 0;x < count();x++)
{
@@ -326,14 +318,16 @@ bool cRechercheList::save()
return(false);
}
QList<cImage*> images = lpRecherche->images();
QList<cImageDescription*> images = lpRecherche->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images.at(x);
cImageDescription* lpImageDescription = images.at(x);
cImage* lpImage = lpImageDescription->image();
imageAdd.bindValue(":rechercheID", lpRecherche->id());
imageAdd.bindValue(":imageID", lpImage->id());
imageAdd.bindValue(":description", textDocument2Blob(lpImageDescription->description()));
if(!imageAdd.exec())
{
myDebug << imageAdd.lastError().text();
@@ -341,14 +335,16 @@ bool cRechercheList::save()
}
}
QList<cCharacter*> characters = lpRecherche->characterList();
QList<cCharacterDescription*> characters = lpRecherche->characterList();
for(int x = 0;x < characters.count();x++)
{
cCharacter* lpCharacter = characters.at(x);
cCharacterDescription* lpCharacterDescription = characters.at(x);
cCharacter* lpCharacter = lpCharacterDescription->character();
characterAdd.bindValue(":rechercheID", lpRecherche->id());
characterAdd.bindValue(":characterID", lpCharacter->id());
characterAdd.bindValue(":description", textDocument2Blob(lpCharacterDescription->description()));
if(!characterAdd.exec())
{
myDebug << characterAdd.lastError().text();
@@ -356,14 +352,16 @@ bool cRechercheList::save()
}
}
QList<cObject*> objects = lpRecherche->objectList();
QList<cObjectDescription*> objects = lpRecherche->objectList();
for(int x = 0;x < objects.count();x++)
{
cObject* lpObject = objects.at(x);
cObjectDescription* lpObjectDescription = objects.at(x);
cObject* lpObject = lpObjectDescription->object();
objectAdd.bindValue(":rechercheID", lpRecherche->id());
objectAdd.bindValue(":objectID", lpObject->id());
objectAdd.bindValue(":description", textDocument2Blob(lpObjectDescription->description()));
if(!objectAdd.exec())
{
myDebug << objectAdd.lastError().text();
@@ -371,14 +369,16 @@ bool cRechercheList::save()
}
}
QList<cPlace*> places = lpRecherche->placeList();
QList<cPlaceDescription*> places = lpRecherche->placeList();
for(int x = 0;x < places.count();x++)
{
cPlace* lpPlace = places.at(x);
cPlaceDescription* lpPlaceDescription = places.at(x);
cPlace* lpPlace = lpPlaceDescription->place();
placeAdd.bindValue(":rechercheID", lpRecherche->id());
placeAdd.bindValue(":placeID", lpPlace->id());
placeAdd.bindValue(":description", textDocument2Blob(lpPlaceDescription->description()));
if(!placeAdd.exec())
{
myDebug << placeAdd.lastError().text();
+32 -28
View File
@@ -43,14 +43,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
@@ -58,14 +58,14 @@ public:
\fn setName
\param szName
*/
void setName(const QString& szName);
void setName(const QString& szName);
/*!
\brief
\fn name
\return QString
*/
QString name();
QString name();
/*!
\brief
@@ -73,14 +73,14 @@ public:
\fn setLink
\param szLink
*/
void setLink(const QString& szLink);
void setLink(const QString& szLink);
/*!
\brief
\fn link
\return QString
*/
QString link();
QString link();
/*!
\brief
@@ -88,82 +88,86 @@ public:
\fn setDescription
\param lpDescription
*/
void setDescription(cTextDocument* lpDescription);
void setDescription(cTextDocument* lpDescription);
/*!
\brief
\fn description
\return cTextDocument
*/
cTextDocument* description();
cTextDocument* description();
/*!
\brief
\fn addImage
\param lpImage
\param lpDescription
*/
void addImage(cImage* lpImage);
void addImage(cImage* lpImage, cTextDocument* lpDescription);
/*!
\brief
\fn addCharacter
\param lpCharacter
\param lpDescription
*/
void addCharacter(cCharacter* lpCharacter);
void addCharacter(cCharacter* lpCharacter, cTextDocument* lpDescription);
/*!
\brief
\fn addObject
\param lpObject
\param lpDescription
*/
void addObject(cObject* lpObject);
void addObject(cObject* lpObject, cTextDocument* lpDescription);
/*!
\brief
\fn addPlace
\param lpPlace
\param lpDescription
*/
void addPlace(cPlace* lpPlace);
void addPlace(cPlace* lpPlace, cTextDocument* lpDescription);
/*!
\brief
\fn images
\return QList<cImage *>
\return QList<cImageDescription *>
*/
QList<cImage*> images();
QList<cImageDescription*> images();
/*!
\brief
\fn characterList
\return QList<cCharacter *>
\return QList<cCharacterDescription *>
*/
QList<cCharacter*> characterList();
QList<cCharacterDescription*> characterList();
/*!
\brief
\fn objectList
\return QList<cObject *>
\return QList<cObjectDescription *>
*/
QList<cObject*> objectList();
QList<cObjectDescription*> objectList();
/*!
\brief
\fn placeList
\return QList<cPlace *>
\return QList<cPlaceDescription *>
*/
QList<cPlace*> placeList();
QList<cPlaceDescription*> placeList();
private:
qint32 m_iID; /*!< TODO: describe */
QString m_szName; /*!< TODO: describe */
QString m_szLink; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
QList<cImage*> m_imageList; /*!< TODO: describe */
QList<cCharacter*> m_characterList; /*!< TODO: describe */
QList<cObject*> m_objectList; /*!< TODO: describe */
QList<cPlace*> m_placeList; /*!< TODO: describe */
qint32 m_iID; /*!< TODO: describe */
QString m_szName; /*!< TODO: describe */
QString m_szLink; /*!< TODO: describe */
cTextDocument* m_lpDescription; /*!< TODO: describe */
QList<cImageDescription*> m_imageList; /*!< TODO: describe */
QList<cCharacterDescription*> m_characterList; /*!< TODO: describe */
QList<cObjectDescription*> m_objectList; /*!< TODO: describe */
QList<cPlaceDescription*> m_placeList; /*!< TODO: describe */
signals:
+14 -10
View File
@@ -71,12 +71,13 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
ui->m_lpLink->setText(lpRecherche->link());
ui->m_lpDescription->setDocument(lpRecherche->description());
QList<cImage*> images = lpRecherche->images();
QList<cImageDescription*> images = lpRecherche->images();
for(int x = 0;x < images.count();x++)
{
cImage* lpImage = images[x];
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
cImageDescription* lpImageDescription = images[x];
cImage* lpImage = lpImageDescription->image();
QPixmap pixmap = lpImage->image();
cImageWidget* lpImageWidget = new cImageWidget;
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
ui->m_lpLayout->addWidget(lpImageWidget);
@@ -85,9 +86,9 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
ui->m_lpLayout->addItem(lpSpacer);
QList<cCharacter*> characterList = lpRecherche->characterList();
QList<cPlace*> placeList = lpRecherche->placeList();
QList<cObject*> objectList = lpRecherche->objectList();
QList<cCharacterDescription*> characterList = lpRecherche->characterList();
QList<cPlaceDescription*> placeList = lpRecherche->placeList();
QList<cObjectDescription*> objectList = lpRecherche->objectList();
QStringList headerLabels;
@@ -95,7 +96,8 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
m_lpCharacterModel->setHorizontalHeaderLabels(headerLabels);
for(int x = 0;x < characterList.count();x++)
{
cCharacter* lpCharacter = characterList[x];
cCharacterDescription* lpCharacterDescription = characterList[x];
cCharacter* lpCharacter = lpCharacterDescription->character();
QList<QStandardItem*> items;
items.append(new QStandardItem(lpCharacter->name()));
@@ -130,7 +132,8 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
m_lpPlaceModel->setHorizontalHeaderLabels(headerLabels);
for(int x = 0;x < placeList.count();x++)
{
cPlace* lpPlace = placeList[x];
cPlaceDescription* lpPlaceDescription = placeList[x];
cPlace* lpPlace = lpPlaceDescription->place();
QList<QStandardItem*> items;
items.append(new QStandardItem(lpPlace->name()));
@@ -155,7 +158,8 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
m_lpObjectModel->setHorizontalHeaderLabels(headerLabels);
for(int x = 0;x < objectList.count();x++)
{
cObject* lpObject = objectList[x];
cObjectDescription* lpObjectDescription = objectList[x];
cObject* lpObject = lpObjectDescription->object();
QList<QStandardItem*> items;
items.append(new QStandardItem(lpObject->name()));
+14 -7
View File
@@ -283,7 +283,8 @@ bool cStoryBook::createDatabase()
if(!createTable("CREATE TABLE characterImage ( "
" characterID INTEGER REFERENCES character (id), "
" imageID INTEGER REFERENCES image (id) "
" imageID INTEGER REFERENCES image (id), "
" description BLOB "
"); "))
return(false);
@@ -308,7 +309,8 @@ bool cStoryBook::createDatabase()
if(!createTable("CREATE TABLE objectImage ( "
" objectID INTEGER REFERENCES object (id), "
" imageID INTEGER REFERENCES image (id) "
" imageID INTEGER REFERENCES image (id), "
" description BLOB "
"); "))
return(false);
@@ -334,7 +336,8 @@ bool cStoryBook::createDatabase()
if(!createTable("CREATE TABLE placeImage ( "
" placeID INTEGER REFERENCES place (id), "
" imageID INTEGER REFERENCES image (id) "
" imageID INTEGER REFERENCES image (id), "
" description BLOB "
"); "))
return(false);
@@ -349,25 +352,29 @@ bool cStoryBook::createDatabase()
if(!createTable("CREATE TABLE rechercheCharacter ( "
" rechercheID INTEGER REFERENCES recherche (id), "
" characterID INTEGER REFERENCES character (id) "
" characterID INTEGER REFERENCES character (id), "
" description BLOB "
"); "))
return(false);
if(!createTable("CREATE TABLE rechercheImage ( "
" rechercheID INTEGER REFERENCES recherche (id), "
" imageID INTEGER REFERENCES image (id) "
" imageID INTEGER REFERENCES image (id), "
" description BLOB "
"); "))
return(false);
if(!createTable("CREATE TABLE rechercheObject ( "
" rechercheID INTEGER REFERENCES recherche (id), "
" objectID INTEGER REFERENCES object (id) "
" objectID INTEGER REFERENCES object (id), "
" description BLOB "
"); "))
return(false);
if(!createTable("CREATE TABLE recherchePlace ( "
" rechercheID INTEGER REFERENCES recherche (id), "
" placeID INTEGER REFERENCES place (id) "
" placeID INTEGER REFERENCES place (id), "
" description BLOB "
"); "))
return(false);