.
This commit is contained in:
+7
-10
@@ -12,7 +12,7 @@ cChapter::cChapter(qint32 iID, QObject *parent) :
|
||||
m_lpPart(0),
|
||||
m_szName(""),
|
||||
m_iSortOrder(-1),
|
||||
m_szDescription(""),
|
||||
m_lpDescription(0),
|
||||
m_lpText(0)
|
||||
{
|
||||
}
|
||||
@@ -57,14 +57,14 @@ qint32 cChapter::sortOrder()
|
||||
return(m_iSortOrder);
|
||||
}
|
||||
|
||||
void cChapter::setDescription(const QString& szDescription)
|
||||
void cChapter::setDescription(cTextDocument* lpDescription)
|
||||
{
|
||||
m_szDescription = szDescription;
|
||||
m_lpDescription = lpDescription;
|
||||
}
|
||||
|
||||
QString cChapter::description()
|
||||
cTextDocument* cChapter::description()
|
||||
{
|
||||
return(m_szDescription);
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
void cChapter::setText(cTextDocument* lpText)
|
||||
@@ -119,11 +119,8 @@ bool cChapterList::load(cPartList* lpPartList)
|
||||
lpChapter->setPart(lpPartList->find(query.value("partID").toInt()));
|
||||
lpChapter->setName(query.value("name").toString());
|
||||
lpChapter->setSortOrder(query.value("sortOrder").toInt());
|
||||
lpChapter->setDescription(query.value("description").toString());
|
||||
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
lpText->setHtml(uncompressText(query.value("text").toByteArray()));
|
||||
lpChapter->setText(lpText);
|
||||
lpChapter->setDescription(blob2TextDocument(query.value("description").toByteArray()));
|
||||
lpChapter->setText(blob2TextDocument(query.value("text").toByteArray()));
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
+3
-3
@@ -30,8 +30,8 @@ public:
|
||||
void setSortOrder(const qint32& iSortOrder);
|
||||
qint32 sortOrder();
|
||||
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
cTextDocument* description();
|
||||
|
||||
void setText(cTextDocument* lpText);
|
||||
cTextDocument* text();
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
cPart* m_lpPart;
|
||||
QString m_szName;
|
||||
qint32 m_iSortOrder;
|
||||
QString m_szDescription;
|
||||
cTextDocument* m_lpDescription;
|
||||
cTextDocument* m_lpText;
|
||||
};
|
||||
|
||||
|
||||
+22
-5
@@ -77,6 +77,25 @@ cCharacter::GENDER cCharacter::gender()
|
||||
return(m_gender);
|
||||
}
|
||||
|
||||
QString cCharacter::genderText()
|
||||
{
|
||||
return(genderText(m_gender));
|
||||
}
|
||||
|
||||
QString cCharacter::genderText(GENDER gender) const
|
||||
{
|
||||
switch(gender)
|
||||
{
|
||||
case GENDER::GENDER_female:
|
||||
return(tr("female"));
|
||||
case GENDER::GENDER_male:
|
||||
return(tr("male"));
|
||||
case GENDER::GENDER_undefined:
|
||||
return(tr("undefined"));
|
||||
}
|
||||
return(tr("undefined"));
|
||||
}
|
||||
|
||||
void cCharacter::setTitle(const QString& szTitle)
|
||||
{
|
||||
m_szTitle = szTitle;
|
||||
@@ -348,7 +367,7 @@ bool cCharacterList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, mainCharacter, gender, title, firstName, middleName, lastName, height, weight, dateOfBirth, placeOfBirth, dateOfDeath, placeOfDeath, hairColor, hairCut, hairLength, figure, nature, spokenLanguages, skin, school, job, description FROM character ORDER BY mainCharacter DESC, lastName, middleName, firstName;");
|
||||
query.prepare("SELECT id, mainCharacter, creature, gender, title, firstName, middleName, lastName, height, weight, dateOfBirth, placeOfBirth, dateOfDeath, placeOfDeath, hairColor, hairCut, hairLength, figure, nature, spokenLanguages, skin, school, job, description FROM character ORDER BY mainCharacter DESC, lastName, middleName, firstName;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
@@ -360,6 +379,7 @@ bool cCharacterList::load()
|
||||
cCharacter* lpCharacter = add(query.value("id").toInt());
|
||||
|
||||
lpCharacter->setMainCharacter(query.value("mainCharacter").toBool());
|
||||
lpCharacter->setCreature(query.value("creature").toString());
|
||||
lpCharacter->setGender((cCharacter::GENDER)query.value("gender").toInt());
|
||||
lpCharacter->setTitle(query.value("title").toString());
|
||||
lpCharacter->setFirstName(query.value("firstName").toString());
|
||||
@@ -380,10 +400,7 @@ bool cCharacterList::load()
|
||||
lpCharacter->setSkin(query.value("skin").toString());
|
||||
lpCharacter->setSchool(query.value("school").toString());
|
||||
lpCharacter->setJob(query.value("job").toString());
|
||||
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
lpText->setHtml(uncompressText(query.value("description").toByteArray()));
|
||||
lpCharacter->setDescription(lpText);
|
||||
lpCharacter->setDescription(blob2TextDocument(query.value("description").toByteArray()));
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
@@ -36,6 +36,8 @@ public:
|
||||
|
||||
void setGender(GENDER gender);
|
||||
GENDER gender();
|
||||
QString genderText();
|
||||
QString genderText(GENDER gender) const;
|
||||
|
||||
void setTitle(const QString& szTitle);
|
||||
QString title();
|
||||
|
||||
+23
-8
@@ -23,28 +23,34 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpOutlineModel(0),
|
||||
m_lpCharacterModel(0),
|
||||
m_lpPlaceModel(0),
|
||||
m_lpObjectModel(0),
|
||||
m_bUpdatingTab(false),
|
||||
m_lpStoryBook(0)
|
||||
{
|
||||
initUI();
|
||||
createActions();
|
||||
|
||||
QString szPath = QDir::homePath() + QDir::separator() + "OneDrive - WINDESIGN" + QDir::separator() + "__BOOKS__" + QDir::separator() + "qtStoryWriter" + QDir::separator() + "DerAdler";
|
||||
QString szPath = QDir::homePath() + QDir::separator() + "OneDrive - WINDESIGN" + QDir::separator() + "__BOOKS__" + QDir::separator() + "qtStoryWriter" + QDir::separator() + "rückwärts.storyWriter" ;
|
||||
m_lpStoryBook = new cStoryBook(szPath);
|
||||
m_lpStoryBook->fillOutlineList(ui->m_lpOutlineList);
|
||||
m_lpStoryBook->fillCharacterList(ui->m_lpCharacterList);
|
||||
m_lpStoryBook->fillPlaceList(ui->m_lpPlaceList);
|
||||
m_lpStoryBook->fillObjectList(ui->m_lpObjectList);
|
||||
m_lpStoryBook->fillRechercheList(ui->m_lpRechercheList);
|
||||
|
||||
updateWindowTitle();
|
||||
|
||||
cPartWindow* lpPartWindow = new cPartWindow(this);
|
||||
// cPartWindow* lpPartWindow = new cPartWindow(this);
|
||||
|
||||
QStandardItem* lpItem = m_lpOutlineModel->item(0, 0);
|
||||
cPart* lpPart = qvariant_cast<cPart*>(lpItem->data());
|
||||
// QStandardItem* lpItem = m_lpOutlineModel->item(0, 0);
|
||||
// cPart* lpPart = qvariant_cast<cPart*>(lpItem->data());
|
||||
|
||||
lpPartWindow->setPart(lpPart);
|
||||
cWidget* lpWidget1 = new cWidget(lpPartWindow);
|
||||
lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpPartWindow));
|
||||
ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpPartWindow->windowTitle());
|
||||
// lpPartWindow->setPart(lpPart);
|
||||
// cWidget* lpWidget1 = new cWidget(lpPartWindow);
|
||||
// lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpPartWindow));
|
||||
// ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpPartWindow->windowTitle());
|
||||
|
||||
// cStructureWindow* lpStructureWindow = new cStructureWindow(this);
|
||||
// cWidget* lpWidget1 = new cWidget(lpStructureWindow);
|
||||
@@ -95,6 +101,15 @@ void cMainWindow::initUI()
|
||||
m_lpCharacterModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpCharacterList->setModel(m_lpCharacterModel);
|
||||
|
||||
m_lpPlaceModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpPlaceList->setModel(m_lpPlaceModel);
|
||||
|
||||
m_lpObjectModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpObjectList->setModel(m_lpObjectModel);
|
||||
|
||||
m_lpRechercheModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpRechercheList->setModel(m_lpRechercheModel);
|
||||
|
||||
QSettings settings;
|
||||
qint16 iX = settings.value("main/x", QVariant::fromValue(-1)).toInt();
|
||||
qint16 iY = settings.value("main/y", QVariant::fromValue(-1)).toInt();
|
||||
|
||||
@@ -35,6 +35,9 @@ private:
|
||||
Ui::cMainWindow* ui;
|
||||
QStandardItemModel* m_lpOutlineModel;
|
||||
QStandardItemModel* m_lpCharacterModel;
|
||||
QStandardItemModel* m_lpPlaceModel;
|
||||
QStandardItemModel* m_lpObjectModel;
|
||||
QStandardItemModel* m_lpRechercheModel;
|
||||
bool m_bUpdatingTab;
|
||||
cStoryBook* m_lpStoryBook;
|
||||
|
||||
|
||||
+74
-15
@@ -28,15 +28,15 @@
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxOutline">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>450</height>
|
||||
<width>89</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -72,8 +72,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>450</height>
|
||||
<width>89</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -94,9 +94,6 @@
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
@@ -109,40 +106,102 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>450</height>
|
||||
<width>89</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Place</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpPlaceList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxObject">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>450</height>
|
||||
<width>89</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Object</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2"/>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpObjectList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxRecherche">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>450</height>
|
||||
<width>89</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Recherche</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpRechercheList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#include "cobject.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
cObject::cObject(qint32 iID, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_iID(iID),
|
||||
m_szName(""),
|
||||
m_szType(""),
|
||||
m_lpDescription(0)
|
||||
{
|
||||
}
|
||||
|
||||
void cObject::setID(const qint32& iID)
|
||||
{
|
||||
m_iID = iID;
|
||||
}
|
||||
|
||||
qint32 cObject::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
void cObject::setName(const QString& szName)
|
||||
{
|
||||
m_szName = szName;
|
||||
}
|
||||
|
||||
QString cObject::name()
|
||||
{
|
||||
return(m_szName);
|
||||
}
|
||||
|
||||
void cObject::setType(const QString& szType)
|
||||
{
|
||||
m_szType = szType;
|
||||
}
|
||||
|
||||
QString cObject::type()
|
||||
{
|
||||
return(m_szType);
|
||||
}
|
||||
|
||||
void cObject::setDescription(cTextDocument* lpDescription)
|
||||
{
|
||||
m_lpDescription = lpDescription;
|
||||
}
|
||||
|
||||
cTextDocument* cObject::description()
|
||||
{
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
cObject* cObjectList::add(const qint32& iID)
|
||||
{
|
||||
cObject* lpObject = find(iID);
|
||||
|
||||
if(!lpObject)
|
||||
{
|
||||
lpObject = new cObject(iID);
|
||||
append(lpObject);
|
||||
}
|
||||
|
||||
return(lpObject);
|
||||
}
|
||||
|
||||
cObject* cObjectList::find(const qint32& iID)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->id() == iID)
|
||||
return(at(x));
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
bool cObjectList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, name, type, description FROM object ORDER BY name, type;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cObject* lpObject = add(query.value("id").toInt());
|
||||
|
||||
lpObject->setName(query.value("name").toString());
|
||||
lpObject->setType(query.value("type").toString());
|
||||
lpObject->setDescription(blob2TextDocument(query.value("description").toByteArray()));
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cObjectList::save()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef COBJECT_H
|
||||
#define COBJECT_H
|
||||
|
||||
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class cObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cObject(qint32 iID = -1, QObject *parent = nullptr);
|
||||
|
||||
void setID(const qint32& iID);
|
||||
qint32 id();
|
||||
|
||||
void setName(const QString& szName);
|
||||
QString name();
|
||||
|
||||
void setType(const QString& szType);
|
||||
QString type();
|
||||
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
cTextDocument* description();
|
||||
|
||||
private:
|
||||
qint32 m_iID;
|
||||
QString m_szName;
|
||||
QString m_szType;
|
||||
cTextDocument* m_lpDescription;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cObject*)
|
||||
|
||||
class cObjectList : public QList<cObject*>
|
||||
{
|
||||
public:
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
cObject* add(const qint32& iID);
|
||||
cObject* find(const qint32& iID);
|
||||
};
|
||||
|
||||
#endif // COBJECT_H
|
||||
+11
-1
@@ -12,4 +12,14 @@ QByteArray compressText(const QString& uncompressed)
|
||||
if(uncompressed.isNull() || uncompressed.isEmpty())
|
||||
return(QByteArray());
|
||||
return(qCompress(uncompressed.toUtf8()));
|
||||
}
|
||||
}
|
||||
|
||||
cTextDocument* blob2TextDocument(const QByteArray& ba)
|
||||
{
|
||||
cTextDocument* lpTextDocument = new cTextDocument;
|
||||
if(ba.isEmpty())
|
||||
return(lpTextDocument);
|
||||
|
||||
lpTextDocument->setHtml(uncompressText(ba));
|
||||
return(lpTextDocument);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
@@ -17,5 +19,6 @@
|
||||
|
||||
QString uncompressText(const QByteArray& compressed);
|
||||
QByteArray compressText(const QString& uncompressed);
|
||||
cTextDocument* blob2TextDocument(const QByteArray& ba);
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
@@ -11,7 +11,7 @@ cPart::cPart(qint32 iID, QObject *parent) :
|
||||
m_iID(iID),
|
||||
m_szName(""),
|
||||
m_iSortOrder(-1),
|
||||
m_szDescription(""),
|
||||
m_lpDescription(0),
|
||||
m_lpText(0)
|
||||
{
|
||||
}
|
||||
@@ -46,14 +46,14 @@ qint32 cPart::sortOrder()
|
||||
return(m_iSortOrder);
|
||||
}
|
||||
|
||||
void cPart::setDescription(const QString& szDescription)
|
||||
void cPart::setDescription(cTextDocument* lpDescription)
|
||||
{
|
||||
m_szDescription = szDescription;
|
||||
m_lpDescription = lpDescription;
|
||||
}
|
||||
|
||||
QString cPart::description()
|
||||
cTextDocument* cPart::description()
|
||||
{
|
||||
return(m_szDescription);
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
void cPart::setText(cTextDocument* lpText)
|
||||
@@ -106,13 +106,8 @@ bool cPartList::load()
|
||||
cPart* lpPart = add(query.value("id").toInt());
|
||||
lpPart->setName(query.value("name").toString());
|
||||
lpPart->setSortOrder(query.value("sortOrder").toInt());
|
||||
lpPart->setDescription(query.value("description").toString());
|
||||
|
||||
QByteArray ba = query.value("text").toByteArray();
|
||||
cTextDocument* lpText = new cTextDocument;
|
||||
if(!ba.isEmpty())
|
||||
lpText->setHtml(qUncompress(ba));
|
||||
lpPart->setText(lpText);
|
||||
lpPart->setDescription(blob2TextDocument(query.value("description").toByteArray()));
|
||||
lpPart->setText(blob2TextDocument(query.value("text").toByteArray()));
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
||||
@@ -25,8 +25,8 @@ public:
|
||||
void setSortOrder(const qint32& iSortOrder);
|
||||
qint32 sortOrder();
|
||||
|
||||
void setDescription(const QString& szDescription);
|
||||
QString description();
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
cTextDocument* description();
|
||||
|
||||
void setText(cTextDocument* lpText);
|
||||
cTextDocument* text();
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
qint32 m_iID;
|
||||
QString m_szName;
|
||||
qint32 m_iSortOrder;
|
||||
QString m_szDescription;
|
||||
cTextDocument* m_lpDescription;
|
||||
cTextDocument* m_lpText;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ void cPartWindow::setPart(cPart* lpPart)
|
||||
{
|
||||
m_lpPart = lpPart;
|
||||
ui->m_lpName->setText(lpPart->name());
|
||||
ui->m_lpDescription->document()->setPlainText(lpPart->description());
|
||||
ui->m_lpDescription->setDocument(lpPart->description());
|
||||
ui->m_lpText->setDocument(lpPart->text());
|
||||
|
||||
setWindowTitle(tr("[part] - ") + lpPart->name());
|
||||
|
||||
+3
-3
@@ -33,12 +33,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPlainTextEdit" name="m_lpDescription"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="cTextEdit" name="m_lpText"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QTextEdit" name="m_lpDescription"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cPartWindow</class>
|
||||
<widget class="QMainWindow" name="cPartWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>580</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="1,1,99">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="m_lpName"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPlainTextEdit" name="m_lpDescription"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="cTextEdit" name="m_lpText"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>cTextEdit</class>
|
||||
<extends>QTextEdit</extends>
|
||||
<header>ctextedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_lpName</tabstop>
|
||||
<tabstop>m_lpDescription</tabstop>
|
||||
<tabstop>m_lpText</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
#include "cplace.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
cPlace::cPlace(qint32 iID, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_iID(iID),
|
||||
m_szName(""),
|
||||
m_szLocation(""),
|
||||
m_szType(""),
|
||||
m_lpDescription(0)
|
||||
{
|
||||
}
|
||||
|
||||
void cPlace::setID(const qint32& iID)
|
||||
{
|
||||
m_iID = iID;
|
||||
}
|
||||
|
||||
qint32 cPlace::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
void cPlace::setName(const QString& szName)
|
||||
{
|
||||
m_szName = szName;
|
||||
}
|
||||
|
||||
QString cPlace::name()
|
||||
{
|
||||
return(m_szName);
|
||||
}
|
||||
|
||||
void cPlace::setLocation(const QString& szLocation)
|
||||
{
|
||||
m_szLocation = szLocation;
|
||||
}
|
||||
|
||||
QString cPlace::location()
|
||||
{
|
||||
return(m_szLocation);
|
||||
}
|
||||
|
||||
void cPlace::setType(const QString& szType)
|
||||
{
|
||||
m_szType = szType;
|
||||
}
|
||||
|
||||
QString cPlace::type()
|
||||
{
|
||||
return(m_szType);
|
||||
}
|
||||
|
||||
void cPlace::setDescription(cTextDocument* lpDescription)
|
||||
{
|
||||
m_lpDescription = lpDescription;
|
||||
}
|
||||
|
||||
cTextDocument* cPlace::description()
|
||||
{
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
cPlace* cPlaceList::add(const qint32& iID)
|
||||
{
|
||||
cPlace* lpPlace = find(iID);
|
||||
|
||||
if(!lpPlace)
|
||||
{
|
||||
lpPlace = new cPlace(iID);
|
||||
append(lpPlace);
|
||||
}
|
||||
|
||||
return(lpPlace);
|
||||
}
|
||||
|
||||
cPlace* cPlaceList::find(const qint32& iID)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->id() == iID)
|
||||
return(at(x));
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
bool cPlaceList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, name, location, type, description FROM place ORDER BY name, location, type;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cPlace* lpPlace = add(query.value("id").toInt());
|
||||
|
||||
lpPlace->setName(query.value("name").toString());
|
||||
lpPlace->setLocation(query.value("location").toString());
|
||||
lpPlace->setType(query.value("type").toString());
|
||||
lpPlace->setDescription(blob2TextDocument(query.value("description").toByteArray()));
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPlaceList::save()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef CPLACE_H
|
||||
#define CPLACE_H
|
||||
|
||||
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class cPlace : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cPlace(qint32 iID = -1, QObject *parent = nullptr);
|
||||
|
||||
void setID(const qint32& iID);
|
||||
qint32 id();
|
||||
|
||||
void setName(const QString& szName);
|
||||
QString name();
|
||||
|
||||
void setLocation(const QString& szLocation);
|
||||
QString location();
|
||||
|
||||
void setType(const QString& szType);
|
||||
QString type();
|
||||
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
cTextDocument* description();
|
||||
|
||||
private:
|
||||
qint32 m_iID;
|
||||
QString m_szName;
|
||||
QString m_szLocation;
|
||||
QString m_szType;
|
||||
cTextDocument* m_lpDescription;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cPlace*)
|
||||
|
||||
class cPlaceList : public QList<cPlace*>
|
||||
{
|
||||
public:
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
cPlace* add(const qint32& iID);
|
||||
cPlace* find(const qint32& iID);
|
||||
};
|
||||
|
||||
#endif // CPLACE_H
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#include "crecherche.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
cRecherche::cRecherche(qint32 iID, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_iID(iID),
|
||||
m_szName(""),
|
||||
m_szLink(""),
|
||||
m_lpDescription(0)
|
||||
{
|
||||
}
|
||||
|
||||
void cRecherche::setID(const qint32& iID)
|
||||
{
|
||||
m_iID = iID;
|
||||
}
|
||||
|
||||
qint32 cRecherche::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
void cRecherche::setName(const QString& szName)
|
||||
{
|
||||
m_szName = szName;
|
||||
}
|
||||
|
||||
QString cRecherche::name()
|
||||
{
|
||||
return(m_szName);
|
||||
}
|
||||
|
||||
void cRecherche::setLink(const QString& szLink)
|
||||
{
|
||||
m_szLink = szLink;
|
||||
}
|
||||
|
||||
QString cRecherche::link()
|
||||
{
|
||||
return(m_szLink);
|
||||
}
|
||||
|
||||
void cRecherche::setDescription(cTextDocument* lpDescription)
|
||||
{
|
||||
m_lpDescription = lpDescription;
|
||||
}
|
||||
|
||||
cTextDocument* cRecherche::description()
|
||||
{
|
||||
return(m_lpDescription);
|
||||
}
|
||||
|
||||
cRecherche* cRechercheList::add(const qint32& iID)
|
||||
{
|
||||
cRecherche* lpRecherche = find(iID);
|
||||
|
||||
if(!lpRecherche)
|
||||
{
|
||||
lpRecherche = new cRecherche(iID);
|
||||
append(lpRecherche);
|
||||
}
|
||||
|
||||
return(lpRecherche);
|
||||
}
|
||||
|
||||
cRecherche* cRechercheList::find(const qint32& iID)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->id() == iID)
|
||||
return(at(x));
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
bool cRechercheList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, name, link, description FROM recherche ORDER BY name, link;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cRecherche* lpObject = add(query.value("id").toInt());
|
||||
|
||||
lpObject->setName(query.value("name").toString());
|
||||
lpObject->setLink(query.value("link").toString());
|
||||
lpObject->setDescription(blob2TextDocument(query.value("description").toByteArray()));
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cRechercheList::save()
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef CRECHERCHE_H
|
||||
#define CRECHERCHE_H
|
||||
|
||||
|
||||
#include "ctextdocument.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class cRecherche : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cRecherche(qint32 iID = -1, QObject *parent = nullptr);
|
||||
|
||||
void setID(const qint32& iID);
|
||||
qint32 id();
|
||||
|
||||
void setName(const QString& szName);
|
||||
QString name();
|
||||
|
||||
void setLink(const QString& szLink);
|
||||
QString link();
|
||||
|
||||
void setDescription(cTextDocument* lpDescription);
|
||||
cTextDocument* description();
|
||||
|
||||
private:
|
||||
qint32 m_iID;
|
||||
QString m_szName;
|
||||
QString m_szLink;
|
||||
cTextDocument* m_lpDescription;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cRecherche*)
|
||||
|
||||
class cRechercheList : public QList<cRecherche*>
|
||||
{
|
||||
public:
|
||||
bool load();
|
||||
bool save();
|
||||
|
||||
cRecherche* add(const qint32& iID);
|
||||
cRecherche* find(const qint32& iID);
|
||||
};
|
||||
|
||||
#endif // CRECHERCHE_H
|
||||
+170
-26
@@ -18,9 +18,9 @@
|
||||
#include <QThread>
|
||||
|
||||
|
||||
cStoryBook::cStoryBook(const QString &szProjectPath, QObject *parent) :
|
||||
cStoryBook::cStoryBook(const QString &szProject, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_szProjectPath(szProjectPath),
|
||||
m_szProject(szProject),
|
||||
m_bIsOpen(false)
|
||||
{
|
||||
if(!openDatabase())
|
||||
@@ -41,6 +41,15 @@ cStoryBook::cStoryBook(const QString &szProjectPath, QObject *parent) :
|
||||
if(!loadCharacterList())
|
||||
return;
|
||||
|
||||
if(!loadPlaceList())
|
||||
return;
|
||||
|
||||
if(!loadObjectList())
|
||||
return;
|
||||
|
||||
if(!loadRechercheList())
|
||||
return;
|
||||
|
||||
m_bIsOpen = true;
|
||||
}
|
||||
|
||||
@@ -52,8 +61,7 @@ cStoryBook::~cStoryBook()
|
||||
|
||||
bool cStoryBook::openDatabase()
|
||||
{
|
||||
QString szDatabase = QString("%1%2storyBook.project").arg(m_szProjectPath).arg(QDir::separator());
|
||||
QFile file(szDatabase);
|
||||
QFile file(m_szProject);
|
||||
|
||||
if(!file.exists())
|
||||
{
|
||||
@@ -63,7 +71,7 @@ bool cStoryBook::openDatabase()
|
||||
}
|
||||
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
m_db.setHostName("localhost");
|
||||
m_db.setDatabaseName(szDatabase);
|
||||
m_db.setDatabaseName(m_szProject);
|
||||
|
||||
if(!m_db.open())
|
||||
{
|
||||
@@ -144,7 +152,7 @@ bool cStoryBook::createDatabase()
|
||||
" partID INTEGER REFERENCES part (id), "
|
||||
" name TEXT, "
|
||||
" sortOrder INTEGER, "
|
||||
" description TEXT, "
|
||||
" description BLOB, "
|
||||
" text BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
@@ -190,7 +198,7 @@ bool cStoryBook::createDatabase()
|
||||
" UNIQUE, "
|
||||
" type TEXT, "
|
||||
" name TEXT, "
|
||||
" description TEXT, "
|
||||
" description BLOB, "
|
||||
" image BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
@@ -200,7 +208,7 @@ bool cStoryBook::createDatabase()
|
||||
" UNIQUE, "
|
||||
" name TEXT, "
|
||||
" type TEXT, "
|
||||
" description TEXT "
|
||||
" description BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -215,7 +223,7 @@ bool cStoryBook::createDatabase()
|
||||
" UNIQUE, "
|
||||
" name TEXT, "
|
||||
" [order] INTEGER, "
|
||||
" description TEXT, "
|
||||
" description BLOB, "
|
||||
" text BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
@@ -240,7 +248,7 @@ bool cStoryBook::createDatabase()
|
||||
" id INTEGER PRIMARY KEY AUTOINCREMENT "
|
||||
" UNIQUE, "
|
||||
" name TEXT, "
|
||||
" description TEXT, "
|
||||
" description BLOB, "
|
||||
" link TEXT "
|
||||
");"))
|
||||
return(false);
|
||||
@@ -287,7 +295,7 @@ bool cStoryBook::createDatabase()
|
||||
if(!createTable("CREATE TABLE sceneCharacter ( "
|
||||
" sceneID INTEGER REFERENCES scene (id), "
|
||||
" characterID INTEGER REFERENCES character (id), "
|
||||
" description TEXT "
|
||||
" description BLOB "
|
||||
");"))
|
||||
return(false);
|
||||
|
||||
@@ -343,6 +351,21 @@ bool cStoryBook::loadCharacterList()
|
||||
return(m_characterList.load());
|
||||
}
|
||||
|
||||
bool cStoryBook::loadPlaceList()
|
||||
{
|
||||
return(m_placeList.load());
|
||||
}
|
||||
|
||||
bool cStoryBook::loadObjectList()
|
||||
{
|
||||
return(m_objectList.load());
|
||||
}
|
||||
|
||||
bool cStoryBook::loadRechercheList()
|
||||
{
|
||||
return(m_rechercheList.load());
|
||||
}
|
||||
|
||||
QString cStoryBook::title()
|
||||
{
|
||||
if(!m_bIsOpen)
|
||||
@@ -385,7 +408,7 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView)
|
||||
lpItem->setData(QVariant::fromValue(lpPart));
|
||||
lpItem->setFont(fontPart);
|
||||
lpItem->setBackground(QBrush(background));
|
||||
lpItem->setToolTip(lpPart->description());
|
||||
lpItem->setToolTip(lpPart->description()->toPlainText());
|
||||
part.insert(lpPart->id(), lpItem);
|
||||
lpModel->appendRow(lpItem);
|
||||
|
||||
@@ -404,7 +427,7 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView)
|
||||
lpItem->setFont(fontChapter);
|
||||
lpItem->setForeground(QBrush(Qt::darkBlue));
|
||||
lpItem->setBackground(QBrush(background));
|
||||
lpItem->setToolTip(lpChapter->description());
|
||||
lpItem->setToolTip(lpChapter->description()->toPlainText());
|
||||
chapter.insert(lpChapter->id(), lpItem);
|
||||
lpRoot->appendRow(lpItem);
|
||||
lpView->setFirstColumnSpanned(lpRoot->rowCount()-1, lpRoot->index(), true);
|
||||
@@ -442,8 +465,10 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView)
|
||||
lpView->header()->setSectionResizeMode(1, QHeaderView::Interactive);
|
||||
|
||||
lpView->expandAll();
|
||||
lpView->resizeColumnToContents(0);
|
||||
lpView->resizeColumnToContents(1);
|
||||
|
||||
|
||||
for(int i = 0;i < headerLabels.count();i++)
|
||||
lpView->resizeColumnToContents(i);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@@ -457,7 +482,7 @@ bool cStoryBook::fillCharacterList(QTreeView* lpView)
|
||||
|
||||
lpModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("name");
|
||||
QStringList headerLabels = QStringList() << tr("name") << tr("creature") << tr("gender");
|
||||
lpModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
fontMainCharacter.setBold(true);
|
||||
@@ -465,23 +490,142 @@ bool cStoryBook::fillCharacterList(QTreeView* lpView)
|
||||
|
||||
for(int x = 0;x < m_characterList.count();x++)
|
||||
{
|
||||
cCharacter* lpCharacter = m_characterList.at(x);
|
||||
QStandardItem* lpItem = new QStandardItem(lpCharacter->name());
|
||||
lpItem->setData(QVariant::fromValue(lpCharacter));
|
||||
cCharacter* lpCharacter = m_characterList.at(x);
|
||||
QList<QStandardItem*> lpItems;
|
||||
|
||||
if(lpCharacter->mainCharacter())
|
||||
lpItem->setFont(fontMainCharacter);
|
||||
else
|
||||
lpItem->setFont(fontNonMainCharacter);
|
||||
lpItems.append(new QStandardItem(lpCharacter->name()));
|
||||
lpItems.append(new QStandardItem(lpCharacter->creature()));
|
||||
lpItems.append(new QStandardItem(lpCharacter->genderText()));
|
||||
|
||||
// lpItem->setToolTip(lpPart->description());
|
||||
lpModel->appendRow(lpItem);
|
||||
for(int i = 0;i < headerLabels.count();i++)
|
||||
{
|
||||
lpItems[i]->setData(QVariant::fromValue(lpCharacter));
|
||||
if(lpCharacter->mainCharacter())
|
||||
lpItems[i]->setFont(fontMainCharacter);
|
||||
else
|
||||
lpItems[i]->setFont(fontNonMainCharacter);
|
||||
|
||||
lpItems[i]->setToolTip(lpCharacter->description()->toPlainText());
|
||||
}
|
||||
|
||||
lpModel->appendRow(lpItems);
|
||||
}
|
||||
|
||||
lpView->header()->setStretchLastSection(true);
|
||||
|
||||
lpView->expandAll();
|
||||
lpView->resizeColumnToContents(0);
|
||||
|
||||
for(int i = 0;i < headerLabels.count();i++)
|
||||
lpView->resizeColumnToContents(i);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::fillPlaceList(QTreeView* lpView)
|
||||
{
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)lpView->model();
|
||||
|
||||
lpModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("name") << tr("location") << tr("type");
|
||||
lpModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
for(int x = 0;x < m_placeList.count();x++)
|
||||
{
|
||||
cPlace* lpPlace = m_placeList.at(x);
|
||||
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));
|
||||
lpItems[i]->setToolTip(lpPlace->description()->toPlainText());
|
||||
}
|
||||
|
||||
lpModel->appendRow(lpItems);
|
||||
}
|
||||
|
||||
lpView->header()->setStretchLastSection(true);
|
||||
|
||||
lpView->expandAll();
|
||||
|
||||
for(int i = 0;i < headerLabels.count();i++)
|
||||
lpView->resizeColumnToContents(i);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::fillObjectList(QTreeView* lpView)
|
||||
{
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)lpView->model();
|
||||
|
||||
lpModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("name") << tr("type");
|
||||
lpModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
for(int x = 0;x < m_objectList.count();x++)
|
||||
{
|
||||
cObject* lpObject = m_objectList.at(x);
|
||||
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));
|
||||
lpItems[i]->setToolTip(lpObject->description()->toPlainText());
|
||||
}
|
||||
|
||||
lpModel->appendRow(lpItems);
|
||||
}
|
||||
|
||||
lpView->header()->setStretchLastSection(true);
|
||||
|
||||
lpView->expandAll();
|
||||
|
||||
for(int i = 0;i < headerLabels.count();i++)
|
||||
lpView->resizeColumnToContents(i);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::fillRechercheList(QTreeView* lpView)
|
||||
{
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)lpView->model();
|
||||
|
||||
lpModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("name") << tr("link");
|
||||
lpModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
for(int x = 0;x < m_rechercheList.count();x++)
|
||||
{
|
||||
cRecherche* lpRecherche = m_rechercheList.at(x);
|
||||
QList<QStandardItem*> lpItems;
|
||||
|
||||
lpItems.append(new QStandardItem(lpRecherche->name()));
|
||||
lpItems.append(new QStandardItem(lpRecherche->link()));
|
||||
|
||||
for(int i = 0;i < headerLabels.count();i++)
|
||||
{
|
||||
lpItems[i]->setData(QVariant::fromValue(lpRecherche));
|
||||
lpItems[i]->setToolTip(lpRecherche->description()->toPlainText());
|
||||
}
|
||||
|
||||
lpModel->appendRow(lpItems);
|
||||
}
|
||||
|
||||
lpView->header()->setStretchLastSection(true);
|
||||
|
||||
lpView->expandAll();
|
||||
|
||||
for(int i = 0;i < headerLabels.count();i++)
|
||||
lpView->resizeColumnToContents(i);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
+15
-2
@@ -7,6 +7,9 @@
|
||||
#include "cchapter.h"
|
||||
#include "cscene.h"
|
||||
#include "ccharacter.h"
|
||||
#include "cplace.h"
|
||||
#include "cobject.h"
|
||||
#include "crecherche.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
@@ -21,7 +24,7 @@ class cStoryBook : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cStoryBook(const QString& szProjectPath, QObject *parent = nullptr);
|
||||
explicit cStoryBook(const QString& szProject, QObject *parent = nullptr);
|
||||
~cStoryBook();
|
||||
|
||||
bool openDatabase();
|
||||
@@ -32,8 +35,12 @@ public:
|
||||
|
||||
bool fillOutlineList(QTreeView* lpView);
|
||||
bool fillCharacterList(QTreeView* lpView);
|
||||
bool fillPlaceList(QTreeView* lpView);
|
||||
bool fillObjectList(QTreeView* lpView);
|
||||
bool fillRechercheList(QTreeView* lpView);
|
||||
|
||||
private:
|
||||
QString m_szProjectPath;
|
||||
QString m_szProject;
|
||||
bool m_bIsOpen;
|
||||
QSqlDatabase m_db;
|
||||
cBook m_book;
|
||||
@@ -41,6 +48,9 @@ private:
|
||||
cChapterList m_chapterList;
|
||||
cSceneList m_sceneList;
|
||||
cCharacterList m_characterList;
|
||||
cPlaceList m_placeList;
|
||||
cObjectList m_objectList;
|
||||
cRechercheList m_rechercheList;
|
||||
|
||||
bool createDatabase();
|
||||
bool updateDatabase();
|
||||
@@ -51,6 +61,9 @@ private:
|
||||
bool loadChapterList();
|
||||
bool loadSceneList();
|
||||
bool loadCharacterList();
|
||||
bool loadPlaceList();
|
||||
bool loadObjectList();
|
||||
bool loadRechercheList();
|
||||
};
|
||||
|
||||
#endif // CSTORYBOOK_H
|
||||
|
||||
+8
-3
@@ -54,7 +54,10 @@ SOURCES += \
|
||||
cchapter.cpp \
|
||||
cscene.cpp \
|
||||
ccharacter.cpp \
|
||||
cpartwindow.cpp
|
||||
cpartwindow.cpp \
|
||||
cplace.cpp \
|
||||
cobject.cpp \
|
||||
crecherche.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h \
|
||||
@@ -70,12 +73,14 @@ HEADERS += \
|
||||
cchapter.h \
|
||||
cscene.h \
|
||||
ccharacter.h \
|
||||
cpartwindow.h
|
||||
cpartwindow.h \
|
||||
cplace.h \
|
||||
cobject.h \
|
||||
crecherche.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui \
|
||||
cstructurewindow.ui \
|
||||
cpartwindow1.ui \
|
||||
cpartwindow.ui
|
||||
|
||||
DISTFILES += \
|
||||
|
||||
Reference in New Issue
Block a user