.
This commit is contained in:
@@ -145,5 +145,56 @@ bool cChapterList::load(cPartList* lpPartList)
|
||||
|
||||
bool cChapterList::save()
|
||||
{
|
||||
QSqlQuery queryUpdate;
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
|
||||
queryUpdate.prepare("UPDATE chapter SET name=:name, partID=:partID, sortOrder=:sortOrder, description=:description, text=:text WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO chapter (name, partID, sortOrder, description, text) VALUES (:name, :partID, :sortOrder, :description, :text);");
|
||||
querySelect.prepare("SELECT id FROM chapter WHERE _rowid_=(SELECT MAX(_rowid_) FROM chapter);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
cChapter* lpChapter = at(x);
|
||||
|
||||
if(lpChapter->id() != -1)
|
||||
{
|
||||
queryUpdate.bindValue(":id", lpChapter->id());
|
||||
queryUpdate.bindValue(":name", lpChapter->name());
|
||||
queryUpdate.bindValue(":partID", lpChapter->part()->id());
|
||||
queryUpdate.bindValue(":sortOrder", lpChapter->sortOrder());
|
||||
queryUpdate.bindValue(":description", textDocument2Blob(lpChapter->description()));
|
||||
queryUpdate.bindValue(":text", textDocument2Blob(lpChapter->text()));
|
||||
|
||||
if(!queryUpdate.exec())
|
||||
{
|
||||
myDebug << queryUpdate.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryInsert.bindValue(":name", lpChapter->name());
|
||||
queryInsert.bindValue(":partID", lpChapter->part()->id());
|
||||
queryInsert.bindValue(":sortOrder", lpChapter->sortOrder());
|
||||
queryInsert.bindValue(":description", textDocument2Blob(lpChapter->description()));
|
||||
queryInsert.bindValue(":text", textDocument2Blob(lpChapter->text()));
|
||||
|
||||
if(!queryInsert.exec())
|
||||
{
|
||||
myDebug << queryInsert.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!querySelect.exec())
|
||||
{
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
lpChapter->setID(querySelect.value("id").toInt());
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
+3
-2
@@ -454,7 +454,7 @@ bool cCharacterList::save()
|
||||
QSqlQuery imageDelete;
|
||||
QSqlQuery imageAdd;
|
||||
|
||||
imageDelete.prepare("DELETE FOM characterImage WHERE characterID=:characterID;");
|
||||
imageDelete.prepare("DELETE FROM characterImage WHERE characterID=:characterID;");
|
||||
imageAdd.prepare("INSERT INTO characterImage (characterID, imageID) VALUES (:characterID, :imageID);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
@@ -531,10 +531,11 @@ bool cCharacterList::save()
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
lpCharacter->setID(querySelect.value("id").toInt());
|
||||
}
|
||||
|
||||
imageDelete.bindValue("characterID", lpCharacter->id());
|
||||
imageDelete.bindValue(":characterID", lpCharacter->id());
|
||||
if(!imageDelete.exec())
|
||||
{
|
||||
myDebug << imageDelete.lastError().text();
|
||||
|
||||
@@ -148,7 +148,7 @@ void cCharacterWindow::setCharacter(cCharacter* lpCharacter)
|
||||
for(int x = 0;x < images.count();x++)
|
||||
{
|
||||
cImage* lpImage = images[x];
|
||||
QPixmap pixmap = lpImage->load();
|
||||
QPixmap pixmap = lpImage->image();
|
||||
cImageWidget* lpImageWidget = new cImageWidget;
|
||||
|
||||
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
|
||||
|
||||
+37
-33
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
#include <QBuffer>
|
||||
|
||||
|
||||
cImage::cImage(qint32 iID, QObject *parent) :
|
||||
@@ -60,36 +61,14 @@ cTextDocument* cImage::description()
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
QPixmap cImage::load()
|
||||
void cImage::setImage(const QPixmap& image)
|
||||
{
|
||||
QSqlQuery query;
|
||||
QPixmap image;
|
||||
m_image = image;
|
||||
}
|
||||
|
||||
query.prepare("SELECT image FROM image WHERE id = :id;");
|
||||
query.bindValue(":id", m_iID);
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(image);
|
||||
}
|
||||
|
||||
if(!query.first())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(image);
|
||||
}
|
||||
|
||||
QByteArray ba = query.value("image").toByteArray();
|
||||
if(!ba.isEmpty())
|
||||
{
|
||||
if(!image.loadFromData(ba))
|
||||
{
|
||||
myDebug << "image load error.";
|
||||
return(image);
|
||||
}
|
||||
}
|
||||
|
||||
return(image);
|
||||
QPixmap cImage::image()
|
||||
{
|
||||
return(m_image);
|
||||
}
|
||||
|
||||
cImage* cImageList::add(const qint32& iID)
|
||||
@@ -119,8 +98,9 @@ cImage* cImageList::find(const qint32& iID)
|
||||
bool cImageList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
QPixmap image;
|
||||
|
||||
query.prepare("SELECT id, name, type, description FROM image ORDER BY name, type;");
|
||||
query.prepare("SELECT id, name, type, description, image FROM image ORDER BY name, type;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
@@ -134,6 +114,17 @@ bool cImageList::load()
|
||||
lpImage->setName(query.value("name").toString());
|
||||
lpImage->setType(query.value("type").toString());
|
||||
lpImage->setDescription(blob2TextDocument(query.value("description").toByteArray()));
|
||||
|
||||
QByteArray ba = query.value("image").toByteArray();
|
||||
if(!ba.isEmpty())
|
||||
{
|
||||
if(!image.loadFromData(ba))
|
||||
{
|
||||
myDebug << "image load error.";
|
||||
return(false);
|
||||
}
|
||||
lpImage->setImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
@@ -145,8 +136,8 @@ bool cImageList::save()
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
|
||||
queryUpdate.prepare("UPDATE image SET type=:type, name=:name, description=:description WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO image (type, name, description) VALUES (:type, :name, :description);");
|
||||
queryUpdate.prepare("UPDATE image SET type=:type, name=:name, description=:description, image=:image WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO image (type, name, description, image) VALUES (:type, :name, :description, :image);");
|
||||
querySelect.prepare("SELECT id FROM image WHERE _rowid_=(SELECT MAX(_rowid_) FROM image);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
@@ -159,18 +150,31 @@ bool cImageList::save()
|
||||
queryUpdate.bindValue(":type", lpImage->type());
|
||||
queryUpdate.bindValue(":name", lpImage->name());
|
||||
queryUpdate.bindValue(":description", textDocument2Blob(lpImage->description()));
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
lpImage->image().save(&buffer, "JPG");
|
||||
queryUpdate.bindValue(":image", ba);
|
||||
|
||||
if(!queryUpdate.exec())
|
||||
{
|
||||
myDebug << queryUpdate.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
// NICHT VOLLSTÄNDIG
|
||||
}
|
||||
else
|
||||
{
|
||||
queryInsert.bindValue(":type", lpImage->type());
|
||||
queryInsert.bindValue(":name", lpImage->name());
|
||||
queryInsert.bindValue(":description", textDocument2Blob(lpImage->description()));
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
lpImage->image().save(&buffer, "JPG");
|
||||
queryInsert.bindValue(":image", ba);
|
||||
|
||||
if(!queryInsert.exec())
|
||||
{
|
||||
myDebug << queryInsert.lastError().text();
|
||||
@@ -182,8 +186,8 @@ bool cImageList::save()
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
lpImage->setID(querySelect.value("id").toInt());
|
||||
// NICHT VOLLSTÄNDIG
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,19 +86,14 @@ public:
|
||||
*/
|
||||
cTextDocument* description();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn load
|
||||
\return QPixmap
|
||||
*/
|
||||
QPixmap load();
|
||||
|
||||
void setImage(const QPixmap& image);
|
||||
QPixmap image();
|
||||
private:
|
||||
qint32 m_iID; /*!< TODO: describe */
|
||||
QString m_szName; /*!< TODO: describe */
|
||||
QString m_szType; /*!< TODO: describe */
|
||||
cTextDocument* m_lpDescription; /*!< TODO: describe */
|
||||
QPixmap m_image;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cImage*)
|
||||
|
||||
@@ -697,6 +697,8 @@ void cMainWindow::onMainTabTabCloseRequested(int index)
|
||||
return;
|
||||
|
||||
m_bUpdatingTab = true;
|
||||
disconnectTextEdit();
|
||||
m_lpOldTextEdit = 0;
|
||||
cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->currentWidget();
|
||||
QMdiSubWindow* lpWindow = lpWidget->window();
|
||||
ui->m_lpMainTab->removeTab(index);
|
||||
@@ -731,6 +733,8 @@ void cMainWindow::onSubWindowClosed(QWidget* lpSubWindow)
|
||||
return;
|
||||
|
||||
m_bUpdatingTab = true;
|
||||
disconnectTextEdit();
|
||||
m_lpOldTextEdit = 0;
|
||||
|
||||
for(int x = 0;x < ui->m_lpMainTab->count();x++)
|
||||
{
|
||||
|
||||
+75
@@ -139,5 +139,80 @@ bool cObjectList::load(cImageList *lpImageList)
|
||||
|
||||
bool cObjectList::save()
|
||||
{
|
||||
QSqlQuery queryUpdate;
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
|
||||
queryUpdate.prepare("UPDATE object SET name=:name, type=:type, description=:description WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO object (name, type, description) VALUES (:name, :type, :description);");
|
||||
querySelect.prepare("SELECT id FROM object WHERE _rowid_=(SELECT MAX(_rowid_) FROM object);");
|
||||
|
||||
QSqlQuery imageDelete;
|
||||
QSqlQuery imageAdd;
|
||||
|
||||
imageDelete.prepare("DELETE FROM objectImage WHERE objectID=:objectID;");
|
||||
imageAdd.prepare("INSERT INTO objectImage (objectID, imageID) VALUES (:objectID, :imageID);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
cObject* lpObject = at(x);
|
||||
|
||||
if(lpObject->id() != -1)
|
||||
{
|
||||
queryUpdate.bindValue(":id", lpObject->id());
|
||||
queryUpdate.bindValue(":name", lpObject->name());
|
||||
queryUpdate.bindValue(":type", lpObject->type());
|
||||
queryUpdate.bindValue(":description", textDocument2Blob(lpObject->description()));
|
||||
|
||||
if(!queryUpdate.exec())
|
||||
{
|
||||
myDebug << queryUpdate.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryInsert.bindValue(":name", lpObject->name());
|
||||
queryInsert.bindValue(":type", lpObject->type());
|
||||
queryInsert.bindValue(":description", textDocument2Blob(lpObject->description()));
|
||||
|
||||
if(!queryInsert.exec())
|
||||
{
|
||||
myDebug << queryInsert.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!querySelect.exec())
|
||||
{
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
lpObject->setID(querySelect.value("id").toInt());
|
||||
}
|
||||
|
||||
imageDelete.bindValue(":objectID", lpObject->id());
|
||||
if(!imageDelete.exec())
|
||||
{
|
||||
myDebug << imageDelete.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
QList<cImage*> images = lpObject->images();
|
||||
|
||||
for(int x = 0;x < images.count();x++)
|
||||
{
|
||||
cImage* lpImage = images.at(x);
|
||||
|
||||
imageAdd.bindValue(":objectID", lpObject->id());
|
||||
imageAdd.bindValue(":imageID", lpImage->id());
|
||||
if(!imageAdd.exec())
|
||||
{
|
||||
myDebug << imageAdd.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ void cObjectWindow::setObject(cObject* lpObject)
|
||||
for(int x = 0;x < images.count();x++)
|
||||
{
|
||||
cImage* lpImage = images[x];
|
||||
QPixmap pixmap = lpImage->load();
|
||||
QPixmap pixmap = lpImage->image();
|
||||
cImageWidget* lpImageWidget = new cImageWidget;
|
||||
|
||||
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
|
||||
|
||||
@@ -23,7 +23,10 @@ cTextDocument* blob2TextDocument(const QByteArray& ba)
|
||||
{
|
||||
cTextDocument* lpTextDocument = new cTextDocument;
|
||||
if(ba.isEmpty())
|
||||
{
|
||||
lpTextDocument->setHtml("");
|
||||
return(lpTextDocument);
|
||||
}
|
||||
|
||||
lpTextDocument->setHtml(uncompressText(ba));
|
||||
return(lpTextDocument);
|
||||
@@ -33,6 +36,9 @@ QByteArray textDocument2Blob(cTextDocument* lpTextDocument)
|
||||
{
|
||||
QByteArray ba;
|
||||
|
||||
if(!lpTextDocument)
|
||||
return(ba);
|
||||
|
||||
ba = compressText(lpTextDocument->toHtml());
|
||||
return(ba);
|
||||
}
|
||||
|
||||
@@ -98,6 +98,18 @@ cPart* cPartList::find(const qint32& iID)
|
||||
return(0);
|
||||
}
|
||||
|
||||
qint32 cPartList::nextSort()
|
||||
{
|
||||
qint32 iSort = -1;
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(iSort < at(x)->sortOrder())
|
||||
iSort = at(x)->sortOrder();
|
||||
}
|
||||
return(iSort+1);
|
||||
}
|
||||
|
||||
bool cPartList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
@@ -123,5 +135,54 @@ bool cPartList::load()
|
||||
|
||||
bool cPartList::save()
|
||||
{
|
||||
QSqlQuery queryUpdate;
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
|
||||
queryUpdate.prepare("UPDATE part SET name=:name, sortOrder=:sortOrder, description=:description, text=:text WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO part (name, sortOrder, description, text) VALUES (:name, :sortOrder, :description, :text);");
|
||||
querySelect.prepare("SELECT id FROM part WHERE _rowid_=(SELECT MAX(_rowid_) FROM part);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
cPart* lpPart = at(x);
|
||||
|
||||
if(lpPart->id() != -1)
|
||||
{
|
||||
queryUpdate.bindValue(":id", lpPart->id());
|
||||
queryUpdate.bindValue(":name", lpPart->name());
|
||||
queryUpdate.bindValue(":sortOrder", lpPart->sortOrder());
|
||||
queryUpdate.bindValue(":description", textDocument2Blob(lpPart->description()));
|
||||
queryUpdate.bindValue(":text", textDocument2Blob(lpPart->text()));
|
||||
|
||||
if(!queryUpdate.exec())
|
||||
{
|
||||
myDebug << queryUpdate.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryInsert.bindValue(":name", lpPart->name());
|
||||
queryInsert.bindValue(":sortOrder", lpPart->sortOrder());
|
||||
queryInsert.bindValue(":description", textDocument2Blob(lpPart->description()));
|
||||
queryInsert.bindValue(":text", textDocument2Blob(lpPart->text()));
|
||||
|
||||
if(!queryInsert.exec())
|
||||
{
|
||||
myDebug << queryInsert.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!querySelect.exec())
|
||||
{
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
lpPart->setID(querySelect.value("id").toInt());
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -157,6 +157,8 @@ public:
|
||||
\return cPart
|
||||
*/
|
||||
cPart* find(const qint32& iID);
|
||||
|
||||
qint32 nextSort();
|
||||
};
|
||||
|
||||
#endif // CPART_H
|
||||
|
||||
+77
@@ -151,5 +151,82 @@ bool cPlaceList::load(cImageList *lpImageList)
|
||||
|
||||
bool cPlaceList::save()
|
||||
{
|
||||
QSqlQuery queryUpdate;
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
|
||||
queryUpdate.prepare("UPDATE place SET name=:name, location=:location, type=:type, description=:description WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO place (name, location, type, description) VALUES (:name, :location, :type, :description);");
|
||||
querySelect.prepare("SELECT id FROM place WHERE _rowid_=(SELECT MAX(_rowid_) FROM place);");
|
||||
|
||||
QSqlQuery imageDelete;
|
||||
QSqlQuery imageAdd;
|
||||
|
||||
imageDelete.prepare("DELETE FROM placeImage WHERE placeID=:placeID;");
|
||||
imageAdd.prepare("INSERT INTO placeImage (placeID, imageID) VALUES (:placeID, :imageID);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
cPlace* lpPlace = at(x);
|
||||
|
||||
if(lpPlace->id() != -1)
|
||||
{
|
||||
queryUpdate.bindValue(":id", lpPlace->id());
|
||||
queryUpdate.bindValue(":name", lpPlace->name());
|
||||
queryUpdate.bindValue(":location", lpPlace->location());
|
||||
queryUpdate.bindValue(":type", lpPlace->type());
|
||||
queryUpdate.bindValue(":description", textDocument2Blob(lpPlace->description()));
|
||||
|
||||
if(!queryUpdate.exec())
|
||||
{
|
||||
myDebug << queryUpdate.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryInsert.bindValue(":name", lpPlace->name());
|
||||
queryInsert.bindValue(":location", lpPlace->location());
|
||||
queryInsert.bindValue(":type", lpPlace->type());
|
||||
queryInsert.bindValue(":description", textDocument2Blob(lpPlace->description()));
|
||||
|
||||
if(!queryInsert.exec())
|
||||
{
|
||||
myDebug << queryInsert.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!querySelect.exec())
|
||||
{
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
lpPlace->setID(querySelect.value("id").toInt());
|
||||
}
|
||||
|
||||
imageDelete.bindValue(":placeID", lpPlace->id());
|
||||
if(!imageDelete.exec())
|
||||
{
|
||||
myDebug << imageDelete.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
QList<cImage*> images = lpPlace->images();
|
||||
|
||||
for(int x = 0;x < images.count();x++)
|
||||
{
|
||||
cImage* lpImage = images.at(x);
|
||||
|
||||
imageAdd.bindValue(":placeID", lpPlace->id());
|
||||
imageAdd.bindValue(":imageID", lpImage->id());
|
||||
if(!imageAdd.exec())
|
||||
{
|
||||
myDebug << imageAdd.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ void cPlaceWindow::setPlace(cPlace* lpPlace)
|
||||
for(int x = 0;x < images.count();x++)
|
||||
{
|
||||
cImage* lpImage = images[x];
|
||||
QPixmap pixmap = lpImage->load();
|
||||
QPixmap pixmap = lpImage->image();
|
||||
cImageWidget* lpImageWidget = new cImageWidget;
|
||||
|
||||
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
|
||||
|
||||
+155
@@ -229,5 +229,160 @@ bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterLi
|
||||
|
||||
bool cRechercheList::save()
|
||||
{
|
||||
QSqlQuery queryUpdate;
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
|
||||
queryUpdate.prepare("UPDATE recherche SET name=:name, description=:description, link=:link WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO recherche (name, description, link) VALUES (:name, :description, :link);");
|
||||
querySelect.prepare("SELECT id FROM recherche WHERE _rowid_=(SELECT MAX(_rowid_) FROM recherche);");
|
||||
|
||||
QSqlQuery imageDelete;
|
||||
QSqlQuery imageAdd;
|
||||
imageDelete.prepare("DELETE FROM rechercheImage WHERE rechercheID=:rechercheID;");
|
||||
imageAdd.prepare("INSERT INTO rechercheImage (rechercheID, imageID) VALUES (:rechercheID, :imageID);");
|
||||
|
||||
QSqlQuery characterDelete;
|
||||
QSqlQuery characterAdd;
|
||||
characterDelete.prepare("DELETE FROM rechercheCharacter WHERE rechercheID=:rechercheID;");
|
||||
characterAdd.prepare("INSERT INTO rechercheCharacter (rechercheID, characterID) VALUES (:rechercheID, :characterID);");
|
||||
|
||||
QSqlQuery objectDelete;
|
||||
QSqlQuery objectAdd;
|
||||
objectDelete.prepare("DELETE FROM rechercheObject WHERE rechercheID=:rechercheID;");
|
||||
objectAdd.prepare("INSERT INTO rechercheObject (rechercheID, ObjectID) VALUES (:rechercheID, :objectID);");
|
||||
|
||||
QSqlQuery placeDelete;
|
||||
QSqlQuery placeAdd;
|
||||
placeDelete.prepare("DELETE FROM recherchePlace WHERE rechercheID=:rechercheID;");
|
||||
placeAdd.prepare("INSERT INTO recherchePlace (rechercheID, placeID) VALUES (:rechercheID, :placeID);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
cRecherche* lpRecherche = at(x);
|
||||
|
||||
if(lpRecherche->id() != -1)
|
||||
{
|
||||
queryUpdate.bindValue(":id", lpRecherche->id());
|
||||
queryUpdate.bindValue(":name", lpRecherche->name());
|
||||
queryUpdate.bindValue(":link", lpRecherche->link());
|
||||
queryUpdate.bindValue(":description", textDocument2Blob(lpRecherche->description()));
|
||||
|
||||
if(!queryUpdate.exec())
|
||||
{
|
||||
myDebug << queryUpdate.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryInsert.bindValue(":name", lpRecherche->name());
|
||||
queryInsert.bindValue(":link", lpRecherche->link());
|
||||
queryInsert.bindValue(":description", textDocument2Blob(lpRecherche->description()));
|
||||
|
||||
if(!queryInsert.exec())
|
||||
{
|
||||
myDebug << queryInsert.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!querySelect.exec())
|
||||
{
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
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<cImage*> images = lpRecherche->images();
|
||||
|
||||
for(int x = 0;x < images.count();x++)
|
||||
{
|
||||
cImage* lpImage = images.at(x);
|
||||
|
||||
imageAdd.bindValue(":rechercheID", lpRecherche->id());
|
||||
imageAdd.bindValue(":imageID", lpImage->id());
|
||||
if(!imageAdd.exec())
|
||||
{
|
||||
myDebug << imageAdd.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
QList<cCharacter*> characters = lpRecherche->characterList();
|
||||
|
||||
for(int x = 0;x < characters.count();x++)
|
||||
{
|
||||
cCharacter* lpCharacter = characters.at(x);
|
||||
|
||||
characterAdd.bindValue(":rechercheID", lpRecherche->id());
|
||||
characterAdd.bindValue(":characterID", lpCharacter->id());
|
||||
if(!characterAdd.exec())
|
||||
{
|
||||
myDebug << characterAdd.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
QList<cObject*> objects = lpRecherche->objectList();
|
||||
|
||||
for(int x = 0;x < objects.count();x++)
|
||||
{
|
||||
cObject* lpObject = objects.at(x);
|
||||
|
||||
objectAdd.bindValue(":rechercheID", lpRecherche->id());
|
||||
objectAdd.bindValue(":objectID", lpObject->id());
|
||||
if(!objectAdd.exec())
|
||||
{
|
||||
myDebug << objectAdd.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
QList<cPlace*> places = lpRecherche->placeList();
|
||||
|
||||
for(int x = 0;x < places.count();x++)
|
||||
{
|
||||
cPlace* lpPlace = places.at(x);
|
||||
|
||||
placeAdd.bindValue(":rechercheID", lpRecherche->id());
|
||||
placeAdd.bindValue(":placeID", lpPlace->id());
|
||||
if(!placeAdd.exec())
|
||||
{
|
||||
myDebug << placeAdd.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche)
|
||||
for(int x = 0;x < images.count();x++)
|
||||
{
|
||||
cImage* lpImage = images[x];
|
||||
QPixmap pixmap = lpImage->load();
|
||||
QPixmap pixmap = lpImage->image();
|
||||
cImageWidget* lpImageWidget = new cImageWidget;
|
||||
|
||||
lpImageWidget->setValues(lpImage->name(), lpImage->type(), lpImage->description(), pixmap);
|
||||
|
||||
+60
-5
@@ -264,11 +264,7 @@ bool cSceneList::load(cChapterList* lpChapterList, cCharacterList *lpCharacterLi
|
||||
lpScene->setStartedAt(query.value("startedAt").toDateTime());
|
||||
lpScene->setFinishedAt(query.value("finishedAt").toDateTime());
|
||||
lpScene->setTargetDate(query.value("targetDate").toDateTime());
|
||||
|
||||
QByteArray ba = query.value("text").toByteArray();
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
if(!ba.isEmpty())
|
||||
lpText->setHtml(qUncompress(ba));
|
||||
lpScene->setText(blob2TextDocument(query.value("text").toByteArray()));
|
||||
}
|
||||
|
||||
query.prepare("SELECT sceneID, characterID FROM sceneCharacter;");
|
||||
@@ -330,5 +326,64 @@ bool cSceneList::load(cChapterList* lpChapterList, cCharacterList *lpCharacterLi
|
||||
|
||||
bool cSceneList::save()
|
||||
{
|
||||
QSqlQuery queryUpdate;
|
||||
QSqlQuery queryInsert;
|
||||
QSqlQuery querySelect;
|
||||
|
||||
queryUpdate.prepare("UPDATE scene SET name=:name, chapterID=:chapterID, sortOrder=:sortOrder, description=:description, state=:state, startedAt=:startedAt, finishedAt=:finishedAt, targetDate=:targetDate, text=:text WHERE id=:id;");
|
||||
queryInsert.prepare("INSERT INTO scene (name, chapterID, sortOrder, description, state, startedAt, finishedAt, targetDate, text) VALUES (:name, :chapterID, :sortOrder, :description, :state, :startedAt, :finishedAt, :targetDate, :text);");
|
||||
querySelect.prepare("SELECT id FROM scene WHERE _rowid_=(SELECT MAX(_rowid_) FROM part);");
|
||||
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
cScene* lpScene = at(x);
|
||||
|
||||
if(lpScene->id() != -1)
|
||||
{
|
||||
queryUpdate.bindValue(":id", lpScene->id());
|
||||
queryUpdate.bindValue(":name", lpScene->name());
|
||||
queryUpdate.bindValue(":chapterID", lpScene->chapter()->id());
|
||||
queryUpdate.bindValue(":sortOrder", lpScene->sortOrder());
|
||||
queryUpdate.bindValue(":description", textDocument2Blob(lpScene->description()));
|
||||
queryUpdate.bindValue(":state", lpScene->state());
|
||||
queryUpdate.bindValue(":startedAt", lpScene->startedAt());
|
||||
queryUpdate.bindValue(":finishedAt", lpScene->finishedAt());
|
||||
queryUpdate.bindValue(":targetDate", lpScene->targetDate());
|
||||
queryUpdate.bindValue(":text", textDocument2Blob(lpScene->text()));
|
||||
|
||||
if(!queryUpdate.exec())
|
||||
{
|
||||
myDebug << queryUpdate.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryInsert.bindValue(":name", lpScene->name());
|
||||
queryInsert.bindValue(":chapterID", lpScene->chapter()->id());
|
||||
queryInsert.bindValue(":sortOrder", lpScene->sortOrder());
|
||||
queryInsert.bindValue(":description", textDocument2Blob(lpScene->description()));
|
||||
queryInsert.bindValue(":state", lpScene->state());
|
||||
queryInsert.bindValue(":startedAt", lpScene->startedAt());
|
||||
queryInsert.bindValue(":finishedAt", lpScene->finishedAt());
|
||||
queryInsert.bindValue(":targetDate", lpScene->targetDate());
|
||||
queryInsert.bindValue(":text", textDocument2Blob(lpScene->text()));
|
||||
|
||||
if(!queryInsert.exec())
|
||||
{
|
||||
myDebug << queryInsert.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!querySelect.exec())
|
||||
{
|
||||
myDebug << querySelect.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
querySelect.next();
|
||||
lpScene->setID(querySelect.value("id").toInt());
|
||||
}
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -489,6 +489,8 @@ bool cStoryBook::addPart(const QString& szPartName)
|
||||
{
|
||||
cPart* lpPart = m_partList.add(-1);
|
||||
lpPart->setName(szPartName);
|
||||
lpPart->setSortOrder(m_partList.nextSort());
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user