From 5b6f27be7f5a1749137b1044a20e9c4db1599e98 Mon Sep 17 00:00:00 2001 From: birkeh Date: Thu, 19 Apr 2018 19:04:19 +0200 Subject: [PATCH] . --- ccharacter.cpp | 47 ++++++++++++++++++++++++++++++++--------------- ccharacter.h | 4 ++-- cmainwindow.cpp | 8 +++----- cmainwindow.ui | 13 ++++++++----- common.h | 10 +++++++--- cstorybook.cpp | 15 ++++++++------- 6 files changed, 60 insertions(+), 37 deletions(-) diff --git a/ccharacter.cpp b/ccharacter.cpp index 55a1f3a..6f0883e 100644 --- a/ccharacter.cpp +++ b/ccharacter.cpp @@ -2,8 +2,8 @@ cCharacter::cCharacter(qint32 iID, QObject *parent) : - m_id(id), QObject(parent), + m_id(iID), m_bMainCharacter(false), m_szCreature(QString("")), m_gender(GENDER::GENDER_undefined), @@ -34,7 +34,7 @@ cCharacter::cCharacter(qint32 iID, QObject *parent) : void cCharacter::setID(const qint32& iID) { - m_id = id; + m_id = iID; } qint32 cCharacter::id() @@ -67,9 +67,9 @@ void cCharacter::setGender(GENDER gender) m_gender = gender; } -GENDER cCharacter::gender() +cCharacter::GENDER cCharacter::gender() { - return(gender); + return(m_gender); } void cCharacter::setTitle(const QString& szTitle) @@ -157,7 +157,7 @@ void cCharacter::setDateOfBirth(const QDate& dateOfBirth) m_dateOfBirth = dateOfBirth; } -QDateTime cCharacter::dateOfBirth() +QDate cCharacter::dateOfBirth() { return(m_dateOfBirth); } @@ -177,7 +177,7 @@ void cCharacter::setDateOfDeath(const QDate& dateOfDeath) m_dateOfDeath = dateOfDeath; } -QDateTime cCharacter::dateOfDeath() +QDate cCharacter::dateOfDeath() { return(m_dateOfDeath); } @@ -292,19 +292,36 @@ QString cCharacter::description() return(m_szDescription); } -bool cCharacterList::load() +cCharacter* cCharacterList::add(const qint32& iID) { - cScene* lpScene = find(iID); + cCharacter* lpCharacter = find(iID); - if(!lpScene) + if(!lpCharacter) { - lpScene = new cScene(iID); - append(lpScene); + lpCharacter = new cCharacter(iID); + append(lpCharacter); } - return(lpScene); + return(lpCharacter); } -bool cCharacterList::save(); -cCharacter* cCharacterList::add(const qint32& iID); -cCharacter* cCharacterList::find(const qint32& iID); +cCharacter* cCharacterList::find(const qint32& iID) +{ + for(int x = 0;x < count();x++) + { + if(at(x)->id() == iID) + return(at(x)); + } + + return(0); +} + +bool cCharacterList::load() +{ + return(true); +} + +bool cCharacterList::save() +{ + return(true); +} diff --git a/ccharacter.h b/ccharacter.h index a2a7589..0c3ee09 100644 --- a/ccharacter.h +++ b/ccharacter.h @@ -60,13 +60,13 @@ public: qreal age(); void setDateOfBirth(const QDate& dateOfBirth); - QDateTime dateOfBirth(); + QDate dateOfBirth(); void setPlaceOfBirth(const QString& szPlaceOfBirth); QString placeOfBirth(); void setDateOfDeath(const QDate& dateOfDeath); - QDateTime dateOfDeath(); + QDate dateOfDeath(); void setPlaceOfDeath(const QString& szPlaceOfDeath); QString placeOfDeath(); diff --git a/cmainwindow.cpp b/cmainwindow.cpp index bea28bd..9478c3d 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -13,10 +13,11 @@ #include #include - +#include #include + cMainWindow::cMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::cMainWindow), @@ -30,9 +31,6 @@ 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); - ui->m_lpOutline->expandAll(); - ui->m_lpOutline->resizeColumnToContents(0); - ui->m_lpOutline->resizeColumnToContents(1); updateWindowTitle(); @@ -125,7 +123,7 @@ void cMainWindow::updateWindowTitle() setWindowTitle(QString("%1 by %2 - qtStoryWriter").arg(szTitle).arg(szAuthor)); } -void cMainWindow::onMainTabCurrentChanged(int index) +void cMainWindow::onMainTabCurrentChanged(int /*index*/) { if(m_bUpdatingTab) return; diff --git a/cmainwindow.ui b/cmainwindow.ui index 68905b3..d068b0c 100644 --- a/cmainwindow.ui +++ b/cmainwindow.ui @@ -35,7 +35,7 @@ 0 0 - 194 + 147 477 @@ -49,7 +49,7 @@ QAbstractItemView::NoEditTriggers - false + true true @@ -57,6 +57,9 @@ false + + true + @@ -66,7 +69,7 @@ 0 0 - 194 + 147 477 @@ -79,7 +82,7 @@ 0 0 - 194 + 147 477 @@ -92,7 +95,7 @@ 0 0 - 194 + 147 477 diff --git a/common.h b/common.h index d4e2cb9..f136ab2 100644 --- a/common.h +++ b/common.h @@ -4,8 +4,12 @@ #include - -#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":" - +#ifdef __GNUC__ + #define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":" +#elif __MINGW32__ + #define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":" +#else + #define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __FUNCTION__ << ":" +#endif #endif // COMMON_H diff --git a/cstorybook.cpp b/cstorybook.cpp index 97e1aed..4939f41 100644 --- a/cstorybook.cpp +++ b/cstorybook.cpp @@ -367,10 +367,6 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView) QStringList headerLabels = QStringList() << tr("name") << tr("state"); lpModel->setHorizontalHeaderLabels(headerLabels); - lpView->header()->setStretchLastSection(false); - lpView->header()->setSectionResizeMode(0, QHeaderView::Stretch); - lpView->header()->setSectionResizeMode(1, QHeaderView::Interactive); - fontPart.setBold(true); fontChapter.setItalic(true); @@ -385,7 +381,6 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView) part.insert(lpPart->id(), lpItem); lpModel->appendRow(lpItem); lpView->setFirstColumnSpanned(lpModel->rowCount()-1, lpRootItem->index(), true); - QThread::msleep(50); } for(int x = 0;x < m_chapterList.count();x++) @@ -404,7 +399,6 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView) chapter.insert(lpChapter->id(), lpItem); lpRoot->appendRow(lpItem); lpView->setFirstColumnSpanned(lpRoot->rowCount()-1, lpRoot->index(), true); - QThread::msleep(50); } } @@ -432,8 +426,15 @@ bool cStoryBook::fillOutlineList(QTreeView* lpView) lpChapterItem->appendRow(lpItems); } - QThread::msleep(50); } + lpView->header()->setStretchLastSection(false); + lpView->header()->setSectionResizeMode(0, QHeaderView::Stretch); + lpView->header()->setSectionResizeMode(1, QHeaderView::Interactive); + + lpView->expandAll(); + lpView->resizeColumnToContents(0); + lpView->resizeColumnToContents(1); + return(true); }