.
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
#define CBOOK_H
|
||||
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class cBook
|
||||
class cBook : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
cBook(const QString& szTitle = "");
|
||||
|
||||
@@ -48,4 +51,6 @@ private:
|
||||
QDateTime m_targetDate;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cBook*)
|
||||
|
||||
#endif // CBOOK_H
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ bool cChapterList::load(cPartList* lpPartList)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, partID, name, sortOrder, description, file FROM chapter;");
|
||||
query.prepare("SELECT id, partID, name, sortOrder, description, file FROM chapter ORDER BY sortOrder;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class cChapter
|
||||
|
||||
+9
-3
@@ -13,19 +13,25 @@
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
m_lpOutlineModel(0),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpOutlineModel(0),
|
||||
m_bUpdatingTab(false),
|
||||
m_lpStoryBook(0)
|
||||
{
|
||||
initUI();
|
||||
createActions();
|
||||
|
||||
m_lpStoryBook = new cStoryBook("c:/temp/qtStoryWriter/DerAdler");
|
||||
m_lpStoryBook->fillOutlineList(m_lpOutlineModel);
|
||||
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);
|
||||
ui->m_lpOutline->expandAll();
|
||||
ui->m_lpOutline->resizeColumnToContents(0);
|
||||
ui->m_lpOutline->resizeColumnToContents(1);
|
||||
|
||||
updateWindowTitle();
|
||||
|
||||
|
||||
+8
-4
@@ -44,7 +44,11 @@
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpOutline"/>
|
||||
<widget class="QTreeView" name="m_lpOutline">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -53,7 +57,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<width>79</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -66,7 +70,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<width>79</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -79,7 +83,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<width>79</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
@@ -93,7 +93,7 @@ bool cPartList::load()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, name, sortOrder, description, file FROM part;");
|
||||
query.prepare("SELECT id, name, sortOrder, description, file FROM part ORDER BY sortOrder;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class cPart
|
||||
class cPart : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
cPart(qint32 iID = -1);
|
||||
|
||||
|
||||
+47
-1
@@ -117,6 +117,52 @@ QString cScene::file()
|
||||
return(m_szFile);
|
||||
}
|
||||
|
||||
QString cScene::stateText()
|
||||
{
|
||||
return(stateText(m_state));
|
||||
}
|
||||
|
||||
QString cScene::stateText(STATE state) const
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case cScene::STATE::STATE_unknown:
|
||||
return(tr("unknown"));
|
||||
case cScene::STATE::STATE_init:
|
||||
return(tr("initialized"));
|
||||
case cScene::STATE::STATE_progress:
|
||||
return(tr("progress"));
|
||||
case cScene::STATE::STATE_delayed:
|
||||
return(tr("delayed"));
|
||||
case cScene::STATE::STATE_finished:
|
||||
return(tr("finished"));
|
||||
}
|
||||
return("unknown");
|
||||
}
|
||||
|
||||
QColor cScene::stateColor()
|
||||
{
|
||||
return(stateColor(m_state));
|
||||
}
|
||||
|
||||
QColor cScene::stateColor(STATE state) const
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case cScene::STATE::STATE_unknown:
|
||||
return(Qt::red);
|
||||
case cScene::STATE::STATE_init:
|
||||
return(QColor(127, 127, 255));
|
||||
case cScene::STATE::STATE_progress:
|
||||
return(QColor(127, 255, 127));
|
||||
case cScene::STATE::STATE_delayed:
|
||||
return(Qt::yellow);
|
||||
case cScene::STATE::STATE_finished:
|
||||
return(Qt::green);
|
||||
}
|
||||
return(Qt::darkRed);
|
||||
}
|
||||
|
||||
cScene* cSceneList::add(const qint32& iID)
|
||||
{
|
||||
cScene* lpScene = find(iID);
|
||||
@@ -145,7 +191,7 @@ bool cSceneList::load(cChapterList* lpChapterList)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT id, chapterID, name, sortOrder, description, state, startedAt, finishedAt, targetDate, file FROM scene;");
|
||||
query.prepare("SELECT id, chapterID, name, sortOrder, description, state, startedAt, finishedAt, targetDate, file FROM scene ORDER BY sortOrder;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class cScene
|
||||
class cScene : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum STATE
|
||||
{
|
||||
@@ -54,6 +58,10 @@ public:
|
||||
void setFile(const QString& szFile);
|
||||
QString file();
|
||||
|
||||
QString stateText();
|
||||
QString stateText(STATE state) const;
|
||||
QColor stateColor();
|
||||
QColor stateColor(STATE state) const;
|
||||
private:
|
||||
qint32 m_iID;
|
||||
cChapter* m_lpChapter;
|
||||
|
||||
+46
-6
@@ -7,9 +7,11 @@
|
||||
#include <QSqlError>
|
||||
|
||||
#include <QStandardItem>
|
||||
#include <QListView>
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
|
||||
@@ -43,9 +45,18 @@ cStoryBook::~cStoryBook()
|
||||
|
||||
bool cStoryBook::openDatabase()
|
||||
{
|
||||
QString szDatabase = QString("%1%2storyBook.project").arg(m_szProjectPath).arg(QDir::separator());
|
||||
QFile file(szDatabase);
|
||||
|
||||
if(!file.exists())
|
||||
{
|
||||
myDebug << QObject::tr("project does not exist");
|
||||
return(false);
|
||||
|
||||
}
|
||||
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
m_db.setHostName("localhost");
|
||||
m_db.setDatabaseName(QString("%1%2storyBook.project").arg(m_szProjectPath).arg(QDir::separator()));
|
||||
m_db.setDatabaseName(szDatabase);
|
||||
|
||||
if(!m_db.open())
|
||||
{
|
||||
@@ -334,20 +345,36 @@ QString cStoryBook::author()
|
||||
return(m_book.author());
|
||||
}
|
||||
|
||||
bool cStoryBook::fillOutlineList(QStandardItemModel* lpModel)
|
||||
bool cStoryBook::fillOutlineList(QTreeView* lpView)
|
||||
{
|
||||
QMap<qint32, QStandardItem*> part;
|
||||
QMap<qint32, QStandardItem*> chapter;
|
||||
QStandardItemModel* lpModel = (QStandardItemModel*)lpView->model();
|
||||
QStandardItem* lpRootItem = lpModel->invisibleRootItem();
|
||||
QFont fontPart = lpRootItem->font();
|
||||
QFont fontChapter = lpRootItem->font();
|
||||
QFont fontScene = lpRootItem->font();
|
||||
QColor background(241, 241, 241);
|
||||
|
||||
lpModel->clear();
|
||||
|
||||
QStringList headerLabels = QStringList() << tr("") << tr("");
|
||||
lpModel->setHorizontalHeaderLabels(headerLabels);
|
||||
|
||||
fontPart.setBold(true);
|
||||
fontChapter.setItalic(true);
|
||||
|
||||
for(int x = 0;x < m_partList.count();x++)
|
||||
{
|
||||
cPart* lpPart = m_partList.at(x);
|
||||
QStandardItem* lpItem = new QStandardItem(lpPart->name());
|
||||
QStandardItem* lpItem = new QStandardItem(lpPart->name());
|
||||
lpItem->setData(QVariant::fromValue(lpPart));
|
||||
lpItem->setFont(fontPart);
|
||||
lpItem->setBackground(QBrush(background));
|
||||
part.insert(lpPart->id(), lpItem);
|
||||
lpModel->appendRow(lpItem);
|
||||
qint16 z = lpRootItem->rowCount();
|
||||
lpView->setFirstColumnSpanned(lpModel->rowCount()-1, lpRootItem->index(), true);
|
||||
}
|
||||
|
||||
for(int x = 0;x < m_chapterList.count();x++)
|
||||
@@ -359,8 +386,12 @@ bool cStoryBook::fillOutlineList(QStandardItemModel* lpModel)
|
||||
{
|
||||
QStandardItem* lpItem = new QStandardItem(lpChapter->name());
|
||||
lpItem->setData(QVariant::fromValue(lpChapter));
|
||||
lpItem->setFont(fontChapter);
|
||||
lpItem->setForeground(QBrush(Qt::darkBlue));
|
||||
lpItem->setBackground(QBrush(background));
|
||||
chapter.insert(lpChapter->id(), lpItem);
|
||||
lpRoot->appendRow(lpItem);
|
||||
lpView->setFirstColumnSpanned(lpRoot->rowCount()-1, lpRoot->index(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,9 +402,18 @@ bool cStoryBook::fillOutlineList(QStandardItemModel* lpModel)
|
||||
|
||||
if(lpRoot)
|
||||
{
|
||||
QStandardItem* lpItem = new QStandardItem(lpScene->name());
|
||||
lpItem->setData(QVariant::fromValue(lpScene));
|
||||
lpRoot->appendRow(lpItem);
|
||||
QList<QStandardItem*> lpItems;
|
||||
|
||||
lpItems << new QStandardItem(lpScene->name());
|
||||
lpItems[0]->setData(QVariant::fromValue(lpScene));
|
||||
lpItems[0]->setFont(fontScene);
|
||||
lpItems[0]->setForeground(QBrush(Qt::blue));
|
||||
|
||||
lpItems << new QStandardItem(lpScene->stateText());
|
||||
lpItems[1]->setData(QVariant::fromValue(lpScene));
|
||||
lpItems[1]->setBackground(QBrush(lpScene->stateColor()));
|
||||
lpItems[1]->setTextAlignment(Qt::AlignCenter);
|
||||
lpRoot->appendRow(lpItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -8,14 +8,17 @@
|
||||
#include "cscene.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <QSqlDatabase>
|
||||
|
||||
|
||||
class cStoryBook
|
||||
class cStoryBook : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
cStoryBook(const QString& szProjectPath);
|
||||
~cStoryBook();
|
||||
@@ -26,7 +29,7 @@ public:
|
||||
QString title();
|
||||
QString author();
|
||||
|
||||
bool fillOutlineList(QStandardItemModel* lpModel);
|
||||
bool fillOutlineList(QTreeView* lpView);
|
||||
private:
|
||||
QString m_szProjectPath;
|
||||
bool m_bIsOpen;
|
||||
|
||||
Reference in New Issue
Block a user