.
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#include "ccharacter.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
cCharacter::cCharacter(qint32 iID, QObject *parent) :
|
||||
QObject(parent),
|
||||
@@ -122,6 +127,29 @@ QString cCharacter::nickName()
|
||||
return(m_szNickName);
|
||||
}
|
||||
|
||||
QString cCharacter::name()
|
||||
{
|
||||
QString szName("");
|
||||
|
||||
if(!m_szFirstName.isEmpty())
|
||||
szName.append(m_szFirstName);
|
||||
|
||||
if(!m_szMiddleName.isEmpty())
|
||||
{
|
||||
if(!szName.isEmpty())
|
||||
szName.append(" ");
|
||||
szName.append(m_szMiddleName);
|
||||
}
|
||||
|
||||
if(!m_szLastName.isEmpty())
|
||||
{
|
||||
if(!szName.isEmpty())
|
||||
szName.append(" ");
|
||||
szName.append(m_szLastName);
|
||||
}
|
||||
return(szName);
|
||||
}
|
||||
|
||||
void cCharacter::setHeight(qreal dHeight)
|
||||
{
|
||||
m_dHeight = dHeight;
|
||||
@@ -318,6 +346,43 @@ cCharacter* cCharacterList::find(const qint32& iID)
|
||||
|
||||
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;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
cCharacter* lpCharacter = add(query.value("id").toInt());
|
||||
|
||||
lpCharacter->setMainCharacter(query.value("mainCharacter").toBool());
|
||||
lpCharacter->setGender((cCharacter::GENDER)query.value("gender").toInt());
|
||||
lpCharacter->setTitle(query.value("title").toString());
|
||||
lpCharacter->setFirstName(query.value("firstName").toString());
|
||||
lpCharacter->setMiddleName(query.value("middleName").toString());
|
||||
lpCharacter->setLastName(query.value("lastName").toString());
|
||||
lpCharacter->setHeight(query.value("height").toDouble());
|
||||
lpCharacter->setWeight(query.value("weight").toDouble());
|
||||
lpCharacter->setDateOfBirth(query.value("dateOfBirth").toDate());
|
||||
lpCharacter->setPlaceOfBirth(query.value("placeOfBirth").toString());
|
||||
lpCharacter->setDateOfDeath(query.value("dateOfDeath").toDate());
|
||||
lpCharacter->setPlaceOfDeath(query.value("placeOfBirth").toString());
|
||||
lpCharacter->setHairColor(query.value("hairColor").toString());
|
||||
lpCharacter->setHairCut(query.value("hairCut").toString());
|
||||
lpCharacter->setHairLength(query.value("hairLength").toString());
|
||||
lpCharacter->setFigure(query.value("figure").toString());
|
||||
lpCharacter->setNature(query.value("nature").toString());
|
||||
lpCharacter->setSpokenLanguages(query.value("spokenLanguages").toString());
|
||||
lpCharacter->setSkin(query.value("skin").toString());
|
||||
lpCharacter->setSchool(query.value("school").toString());
|
||||
lpCharacter->setJob(query.value("job").toString());
|
||||
lpCharacter->setDescription(query.value("description").toString());
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
void setLastName(const QString& szLastName);
|
||||
QString lastName();
|
||||
|
||||
QString name();
|
||||
|
||||
void setNickName(const QString& szNickName);
|
||||
QString nickName();
|
||||
|
||||
|
||||
+6
-2
@@ -30,7 +30,8 @@ cMainWindow::cMainWindow(QWidget *parent) :
|
||||
|
||||
QString szPath = QDir::homePath() + QDir::separator() + "OneDrive - WINDESIGN" + QDir::separator() + "__BOOKS__" + QDir::separator() + "qtStoryWriter" + QDir::separator() + "DerAdler";
|
||||
m_lpStoryBook = new cStoryBook(szPath);
|
||||
m_lpStoryBook->fillOutlineList(ui->m_lpOutline);
|
||||
m_lpStoryBook->fillOutlineList(ui->m_lpOutlineList);
|
||||
m_lpStoryBook->fillCharacterList(ui->m_lpCharacterList);
|
||||
|
||||
updateWindowTitle();
|
||||
|
||||
@@ -78,7 +79,10 @@ void cMainWindow::initUI()
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpOutlineModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpOutline->setModel(m_lpOutlineModel);
|
||||
ui->m_lpOutlineList->setModel(m_lpOutlineModel);
|
||||
|
||||
m_lpCharacterModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpCharacterList->setModel(m_lpCharacterModel);
|
||||
|
||||
QSettings settings;
|
||||
qint16 iX = settings.value("main/x", QVariant::fromValue(-1)).toInt();
|
||||
|
||||
@@ -34,6 +34,7 @@ private slots:
|
||||
private:
|
||||
Ui::cMainWindow* ui;
|
||||
QStandardItemModel* m_lpOutlineModel;
|
||||
QStandardItemModel* m_lpCharacterModel;
|
||||
bool m_bUpdatingTab;
|
||||
cStoryBook* m_lpStoryBook;
|
||||
|
||||
|
||||
+36
-10
@@ -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>477</height>
|
||||
<width>89</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -44,7 +44,7 @@
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpOutline">
|
||||
<widget class="QTreeView" name="m_lpOutlineList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
@@ -69,21 +69,42 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>477</height>
|
||||
<width>89</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Character</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpCharacterList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxPlace">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>477</height>
|
||||
<width>79</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -95,8 +116,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>147</width>
|
||||
<height>477</height>
|
||||
<width>79</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -104,6 +125,11 @@
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2"/>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_lpMainToolBoxRecherche">
|
||||
<attribute name="label">
|
||||
<string>Recherche</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,99999">
|
||||
|
||||
@@ -38,6 +38,9 @@ cStoryBook::cStoryBook(const QString &szProjectPath, QObject *parent) :
|
||||
if(!loadSceneList())
|
||||
return;
|
||||
|
||||
if(!loadCharacterList())
|
||||
return;
|
||||
|
||||
m_bIsOpen = true;
|
||||
}
|
||||
|
||||
@@ -335,6 +338,11 @@ bool cStoryBook::loadSceneList()
|
||||
return(m_sceneList.load(&m_chapterList));
|
||||
}
|
||||
|
||||
bool cStoryBook::loadCharacterList()
|
||||
{
|
||||
return(m_characterList.load());
|
||||
}
|
||||
|
||||
QString cStoryBook::title()
|
||||
{
|
||||
if(!m_bIsOpen)
|
||||
@@ -438,3 +446,41 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView)
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cStoryBook::fillCharacterList(QTreeView* lpView)
|
||||
{
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)lpView->model();
|
||||
QStandardItem* lpRootItem = lpModel->invisibleRootItem();
|
||||
QFont fontMainCharacter = lpRootItem->font();
|
||||
QFont fontNonMainCharacter = lpRootItem->font();
|
||||
|
||||
lpModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("name");
|
||||
lpModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
fontMainCharacter.setBold(true);
|
||||
fontNonMainCharacter.setItalic(true);
|
||||
|
||||
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));
|
||||
|
||||
if(lpCharacter->mainCharacter())
|
||||
lpItem->setFont(fontMainCharacter);
|
||||
else
|
||||
lpItem->setFont(fontNonMainCharacter);
|
||||
|
||||
// lpItem->setToolTip(lpPart->description());
|
||||
lpModel->appendRow(lpItem);
|
||||
}
|
||||
|
||||
lpView->header()->setStretchLastSection(true);
|
||||
|
||||
lpView->expandAll();
|
||||
lpView->resizeColumnToContents(0);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "cpart.h"
|
||||
#include "cchapter.h"
|
||||
#include "cscene.h"
|
||||
#include "ccharacter.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
@@ -30,6 +31,7 @@ public:
|
||||
QString author();
|
||||
|
||||
bool fillOutlineList(QTreeView* lpView);
|
||||
bool fillCharacterList(QTreeView* lpView);
|
||||
private:
|
||||
QString m_szProjectPath;
|
||||
bool m_bIsOpen;
|
||||
@@ -38,6 +40,7 @@ private:
|
||||
cPartList m_partList;
|
||||
cChapterList m_chapterList;
|
||||
cSceneList m_sceneList;
|
||||
cCharacterList m_characterList;
|
||||
|
||||
bool createDatabase();
|
||||
bool updateDatabase();
|
||||
@@ -47,6 +50,7 @@ private:
|
||||
bool loadPartList();
|
||||
bool loadChapterList();
|
||||
bool loadSceneList();
|
||||
bool loadCharacterList();
|
||||
};
|
||||
|
||||
#endif // CSTORYBOOK_H
|
||||
|
||||
Reference in New Issue
Block a user