diff --git a/cchapter.cpp b/cchapter.cpp index a3d22f5..ebdb38e 100644 --- a/cchapter.cpp +++ b/cchapter.cpp @@ -101,6 +101,18 @@ cChapter* cChapterList::find(const qint32& iID) return(0); } +QList cChapterList::find(cPart* lpPart) +{ + QList chapterList; + + for(int x = 0;x < count();x++) + { + if(at(x)->part() == lpPart) + chapterList.append(at(x)); + } + return(chapterList); +} + bool cChapterList::load(cPartList* lpPartList) { QSqlQuery query; diff --git a/cchapter.h b/cchapter.h index 413fcf9..7edc2a0 100644 --- a/cchapter.h +++ b/cchapter.h @@ -18,31 +18,31 @@ class cChapter : public QObject public: explicit cChapter(qint32 iID = -1, QObject *parent = nullptr); - void setID(const qint32& iID); - qint32 id(); + void setID(const qint32& iID); + qint32 id(); - void setPart(cPart *lpPart); - cPart* part(); + void setPart(cPart *lpPart); + cPart* part(); - void setName(const QString& szName); - QString name(); + void setName(const QString& szName); + QString name(); - void setSortOrder(const qint32& iSortOrder); - qint32 sortOrder(); + void setSortOrder(const qint32& iSortOrder); + qint32 sortOrder(); - void setDescription(cTextDocument* lpDescription); - cTextDocument* description(); + void setDescription(cTextDocument* lpDescription); + cTextDocument* description(); - void setText(cTextDocument* lpText); - cTextDocument* text(); + void setText(cTextDocument* lpText); + cTextDocument* text(); private: - qint32 m_iID; - cPart* m_lpPart; - QString m_szName; - qint32 m_iSortOrder; - cTextDocument* m_lpDescription; - cTextDocument* m_lpText; + qint32 m_iID; + cPart* m_lpPart; + QString m_szName; + qint32 m_iSortOrder; + cTextDocument* m_lpDescription; + cTextDocument* m_lpText; }; Q_DECLARE_METATYPE(cChapter*) @@ -50,11 +50,13 @@ Q_DECLARE_METATYPE(cChapter*) class cChapterList : public QList { public: - bool load(cPartList *lpPartList); - bool save(); + bool load(cPartList *lpPartList); + bool save(); - cChapter* add(const qint32& iID); - cChapter* find(const qint32& iID); + cChapter* add(const qint32& iID); + cChapter* find(const qint32& iID); + + QList find(cPart* lpPart); }; #endif // CCHAPTER_H diff --git a/cmainwindow.cpp b/cmainwindow.cpp index f2f084a..6b0e71f 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -4,7 +4,6 @@ #include "ctextdocument.h" #include "cpartwindow.h" -#include "cstructurewindow.h" #include "cwidget.h" #include @@ -18,6 +17,8 @@ #include +#include + cMainWindow::cMainWindow(QWidget *parent) : QMainWindow(parent), @@ -134,6 +135,8 @@ void cMainWindow::createActions() connect(ui->m_lpMainTab, SIGNAL(currentChanged(int)), this, SLOT(onMainTabCurrentChanged(int))); connect(ui->m_lpMainTab, SIGNAL(tabCloseRequested(int)), this,SLOT(onMainTabTabCloseRequested(int))); connect(ui->m_lpMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onMdiAreaSubWindowActivated(QMdiSubWindow*))); + + connect(ui->m_lpOutlineList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onOutlineDoubleClicked(QModelIndex))); } void cMainWindow::updateWindowTitle() @@ -148,9 +151,9 @@ void cMainWindow::updateWindowTitle() QString szAuthor = m_lpStoryBook->author(); if(szAuthor.isEmpty()) - setWindowTitle(QString("%1 - qtStoryWriter").arg(szTitle)); + setWindowTitle(QString("\"%1\" - qtStoryWriter").arg(szTitle)); else - setWindowTitle(QString("%1 by %2 - qtStoryWriter").arg(szTitle).arg(szAuthor)); + setWindowTitle(QString("\"%1\" by %2 - qtStoryWriter").arg(szTitle).arg(szAuthor)); } void cMainWindow::onMainTabCurrentChanged(int /*index*/) @@ -198,3 +201,57 @@ void cMainWindow::onMdiAreaSubWindowActivated(QMdiSubWindow *arg1) } m_bUpdatingTab = false; } + +void cMainWindow::onOutlineDoubleClicked(const QModelIndex& index) +{ + QStandardItem* lpItem = m_lpOutlineModel->itemFromIndex(index); + cPart* lpPart = qvariant_cast(lpItem->data()); + cChapter* lpChapter = qvariant_cast(lpItem->data()); + cScene* lpScene = qvariant_cast(lpItem->data()); + + if(lpPart) + showPartWindow(lpPart); + else if(lpChapter) + showChapterWindow(lpChapter); + else if(lpScene) + showSceneWindow(lpScene); + else + QMessageBox::information(this, "DoubleClicked", "outline"); +} + +void cMainWindow::showPartWindow(cPart* lpPart) +{ + for(int x = 0;x < ui->m_lpMainTab->count();x++) + { + cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->widget(x); + if(lpWidget->type() == cWidget::TYPE_part) + { + cPartWindow* lpPartWindow = (cPartWindow*)lpWidget->widget(); + if(lpPartWindow->part() == lpPart) + { + ui->m_lpMainTab->setCurrentIndex(x); + ui->m_lpMdiArea->setActiveSubWindow(lpWidget->window()); + m_bUpdatingTab = false; + return; + } + } + } + + cPartWindow* lpPartWindow = new cPartWindow(this); + lpPartWindow->setPart(lpPart, m_lpStoryBook->chapterList()); + cWidget* lpWidget1 = new cWidget(lpPartWindow); + lpWidget1->setWindow(ui->m_lpMdiArea->addSubWindow(lpPartWindow)); + ui->m_lpMainTab->addTab((QWidget*)lpWidget1, lpPartWindow->windowTitle()); + + lpPartWindow->show(); +} + +void cMainWindow::showChapterWindow(cChapter* lpChapter) +{ + QMessageBox::information(this, "CHAPTER", lpChapter->name()); +} + +void cMainWindow::showSceneWindow(cScene* lpScene) +{ + QMessageBox::information(this, "SCENE", lpScene->name()); +} diff --git a/cmainwindow.h b/cmainwindow.h index c1cad10..74e5f88 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -31,6 +31,7 @@ private slots: void onMainTabTabCloseRequested(int index); void onMdiAreaSubWindowActivated(QMdiSubWindow *arg1); + void onOutlineDoubleClicked(const QModelIndex& index); private: Ui::cMainWindow* ui; QStandardItemModel* m_lpOutlineModel; @@ -44,6 +45,9 @@ private: void initUI(); void createActions(); + void showPartWindow(cPart* lpPart); + void showChapterWindow(cChapter* lpChapter); + void showSceneWindow(cScene* lpScene); protected: void closeEvent(QCloseEvent *event); }; diff --git a/cmainwindow.ui b/cmainwindow.ui index 0dadbd0..6cbc777 100644 --- a/cmainwindow.ui +++ b/cmainwindow.ui @@ -28,7 +28,7 @@ QFrame::Sunken - 4 + 0 @@ -48,6 +48,9 @@ QAbstractItemView::NoEditTriggers + + true + true @@ -85,6 +88,9 @@ QAbstractItemView::NoEditTriggers + + true + false @@ -119,6 +125,9 @@ QAbstractItemView::NoEditTriggers + + true + false @@ -153,6 +162,9 @@ QAbstractItemView::NoEditTriggers + + true + false @@ -187,6 +199,9 @@ QAbstractItemView::NoEditTriggers + + true + false diff --git a/cpartwindow.cpp b/cpartwindow.cpp index d5bc3ee..6baf440 100644 --- a/cpartwindow.cpp +++ b/cpartwindow.cpp @@ -1,13 +1,19 @@ #include "cpartwindow.h" #include "ui_cpartwindow.h" +#include + cPartWindow::cPartWindow(QWidget *parent) : QWidget(parent), ui(new Ui::cPartWindow), - m_lpPart(0) + m_lpPart(0), + m_lpChapterList(0) { ui->setupUi(this); + + m_lpChapterModel = new QStandardItemModel(0, 1); + ui->m_lpChapterList->setModel(m_lpChapterModel); } cPartWindow::~cPartWindow() @@ -15,12 +21,35 @@ cPartWindow::~cPartWindow() delete ui; } -void cPartWindow::setPart(cPart* lpPart) +void cPartWindow::setPart(cPart* lpPart, cChapterList* lpChapterList) { m_lpPart = lpPart; + m_lpChapterList = lpChapterList; + ui->m_lpName->setText(lpPart->name()); ui->m_lpDescription->setDocument(lpPart->description()); ui->m_lpText->setDocument(lpPart->text()); + QStringList headerLabels = QStringList() << tr("name"); + m_lpChapterModel->setHorizontalHeaderLabels(headerLabels); + + QList chapterList = m_lpChapterList->find(lpPart); + for(int x = 0;x < chapterList.count();x++) + { + cChapter* lpChapter = chapterList.at(x); + + QStandardItem* lpItem = new QStandardItem(lpChapter->name()); + lpItem->setData(QVariant::fromValue(lpChapter)); + lpItem->setToolTip(lpChapter->description()->toPlainText()); + m_lpChapterModel->appendRow(lpItem); + } + + ui->m_lpChapterList->resizeColumnToContents(0); + setWindowTitle(tr("[part] - ") + lpPart->name()); } + +cPart* cPartWindow::part() +{ + return(m_lpPart); +} diff --git a/cpartwindow.h b/cpartwindow.h index 9edc951..67d4389 100644 --- a/cpartwindow.h +++ b/cpartwindow.h @@ -3,8 +3,10 @@ #include "cpart.h" +#include "cchapter.h" #include +#include namespace Ui { @@ -19,10 +21,13 @@ public: explicit cPartWindow(QWidget *parent = 0); ~cPartWindow(); - void setPart(cPart* lpPart); + void setPart(cPart* lpPart, cChapterList* lpChapterList); + cPart* part(); private: Ui::cPartWindow* ui; cPart* m_lpPart; + cChapterList* m_lpChapterList; + QStandardItemModel* m_lpChapterModel; }; #endif // CPARTWINDOW_H diff --git a/cpartwindow.ui b/cpartwindow.ui index b666fe8..c011f08 100644 --- a/cpartwindow.ui +++ b/cpartwindow.ui @@ -15,10 +15,20 @@ - + + + + + Description: + + + + + + @@ -26,18 +36,31 @@ - - + + + + + - Description: + Chapters: - - - - - + + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + false + + @@ -50,6 +73,12 @@
ctextedit.h
+ + m_lpName + m_lpDescription + m_lpChapterList + m_lpText + diff --git a/crecherche.cpp b/crecherche.cpp index 93f5c37..3ce8dfc 100644 --- a/crecherche.cpp +++ b/crecherche.cpp @@ -62,6 +62,27 @@ void cRecherche::addImage(cImage* lpImage) m_imageList.append(lpImage); } +void cRecherche::addCharacter(cCharacter* lpCharacter) +{ + if(m_characterList.contains(lpCharacter)) + return; + m_characterList.append(lpCharacter); +} + +void cRecherche::addObject(cObject* lpObject) +{ + if(m_objectList.contains(lpObject)) + return; + m_objectList.append(lpObject); +} + +void cRecherche::addPlace(cPlace* lpPlace) +{ + if(m_placeList.contains(lpPlace)) + return; + m_placeList.append(lpPlace); +} + cRecherche* cRechercheList::add(const qint32& iID) { cRecherche* lpRecherche = find(iID); @@ -86,7 +107,7 @@ cRecherche* cRechercheList::find(const qint32& iID) return(0); } -bool cRechercheList::load(cImageList *lpImageList) +bool cRechercheList::load(cImageList *lpImageList, cCharacterList *lpCharacterList, cObjectList *lpObjectList, cPlaceList *lpPlaceList) { QSqlQuery query; @@ -124,6 +145,60 @@ bool cRechercheList::load(cImageList *lpImageList) } } + query.prepare("SELECT rechercheID, characterID FROM rechercheCharacter;"); + if(!query.exec()) + { + myDebug << query.lastError().text(); + return(false); + } + + while(query.next()) + { + cRecherche* lpRecherche = find(query.value("rechercheID").toInt()); + if(lpRecherche) + { + cCharacter* lpCharacter = lpCharacterList->find(query.value("characterID").toInt()); + if(lpCharacter) + lpRecherche->addCharacter(lpCharacter); + } + } + + query.prepare("SELECT rechercheID, objectID FROM rechercheObject;"); + if(!query.exec()) + { + myDebug << query.lastError().text(); + return(false); + } + + while(query.next()) + { + cRecherche* lpRecherche = find(query.value("rechercheID").toInt()); + if(lpRecherche) + { + cObject* lpObject = lpObjectList->find(query.value("objectID").toInt()); + if(lpObject) + lpRecherche->addObject(lpObject); + } + } + + query.prepare("SELECT rechercheID, placeID FROM recherchePlace;"); + if(!query.exec()) + { + myDebug << query.lastError().text(); + return(false); + } + + while(query.next()) + { + cRecherche* lpRecherche = find(query.value("rechercheID").toInt()); + if(lpRecherche) + { + cPlace* lpPlace = lpPlaceList->find(query.value("placeID").toInt()); + if(lpPlace) + lpRecherche->addPlace(lpPlace); + } + } + return(true); } diff --git a/crecherche.h b/crecherche.h index d3646f8..987b5b4 100644 --- a/crecherche.h +++ b/crecherche.h @@ -4,6 +4,9 @@ #include "ctextdocument.h" #include "cimage.h" +#include "ccharacter.h" +#include "cobject.h" +#include "cplace.h" #include #include @@ -17,26 +20,32 @@ class cRecherche : public QObject public: explicit cRecherche(qint32 iID = -1, QObject *parent = nullptr); - void setID(const qint32& iID); - qint32 id(); + void setID(const qint32& iID); + qint32 id(); - void setName(const QString& szName); - QString name(); + void setName(const QString& szName); + QString name(); - void setLink(const QString& szLink); - QString link(); + void setLink(const QString& szLink); + QString link(); - void setDescription(cTextDocument* lpDescription); - cTextDocument* description(); + void setDescription(cTextDocument* lpDescription); + cTextDocument* description(); - void addImage(cImage* lpImage); + void addImage(cImage* lpImage); + void addCharacter(cCharacter* lpCharacter); + void addObject(cObject* lpObject); + void addPlace(cPlace* lpPlace); private: - qint32 m_iID; - QString m_szName; - QString m_szLink; - cTextDocument* m_lpDescription; - QList m_imageList; + qint32 m_iID; + QString m_szName; + QString m_szLink; + cTextDocument* m_lpDescription; + QList m_imageList; + QList m_characterList; + QList m_objectList; + QList m_placeList; signals: @@ -48,11 +57,11 @@ Q_DECLARE_METATYPE(cRecherche*) class cRechercheList : public QList { public: - bool load(cImageList* lpImageList); - bool save(); + bool load(cImageList* lpImageList, cCharacterList* lpCharacterList, cObjectList* lpObjectList, cPlaceList* lpPlaceList); + bool save(); - cRecherche* add(const qint32& iID); - cRecherche* find(const qint32& iID); + cRecherche* add(const qint32& iID); + cRecherche* find(const qint32& iID); }; #endif // CRECHERCHE_H diff --git a/cscene.cpp b/cscene.cpp index 2e0c338..fe84860 100644 --- a/cscene.cpp +++ b/cscene.cpp @@ -118,6 +118,27 @@ cTextDocument* cScene::text() return(m_lpText); } +void cScene::addCharacter(cCharacter* lpCharacter) +{ + if(m_characterList.contains(lpCharacter)) + return; + m_characterList.append(lpCharacter); +} + +void cScene::addObject(cObject* lpObject) +{ + if(m_objectList.contains(lpObject)) + return; + m_objectList.append(lpObject); +} + +void cScene::addPlace(cPlace* lpPlace) +{ + if(m_placeList.contains(lpPlace)) + return; + m_placeList.append(lpPlace); +} + QString cScene::stateText() { return(stateText(m_state)); @@ -188,7 +209,7 @@ cScene* cSceneList::find(const qint32& iID) return(0); } -bool cSceneList::load(cChapterList* lpChapterList) +bool cSceneList::load(cChapterList* lpChapterList, cCharacterList *lpCharacterList, cObjectList *lpObjectList, cPlaceList *lpPlaceList) { QSqlQuery query; @@ -218,6 +239,60 @@ bool cSceneList::load(cChapterList* lpChapterList) lpText->setHtml(qUncompress(ba)); } + query.prepare("SELECT sceneID, characterID FROM sceneCharacter;"); + if(!query.exec()) + { + myDebug << query.lastError().text(); + return(false); + } + + while(query.next()) + { + cScene* lpScene = find(query.value("sceneID").toInt()); + if(lpScene) + { + cCharacter* lpCharacter = lpCharacterList->find(query.value("characterID").toInt()); + if(lpCharacter) + lpScene->addCharacter(lpCharacter); + } + } + + query.prepare("SELECT sceneID, objectID FROM sceneObject;"); + if(!query.exec()) + { + myDebug << query.lastError().text(); + return(false); + } + + while(query.next()) + { + cScene* lpScene = find(query.value("sceneID").toInt()); + if(lpScene) + { + cObject* lpObject = lpObjectList->find(query.value("objectID").toInt()); + if(lpObject) + lpScene->addObject(lpObject); + } + } + + query.prepare("SELECT sceneID, placeID FROM scenePlace;"); + if(!query.exec()) + { + myDebug << query.lastError().text(); + return(false); + } + + while(query.next()) + { + cScene* lpScene = find(query.value("sceneID").toInt()); + if(lpScene) + { + cPlace* lpPlace = lpPlaceList->find(query.value("placeID").toInt()); + if(lpPlace) + lpScene->addPlace(lpPlace); + } + } + return(true); } diff --git a/cscene.h b/cscene.h index 5beeaef..f87f279 100644 --- a/cscene.h +++ b/cscene.h @@ -4,6 +4,9 @@ #include "cchapter.h" #include "ctextdocument.h" +#include "ccharacter.h" +#include "cobject.h" +#include "cplace.h" #include #include @@ -29,51 +32,58 @@ public: explicit cScene(qint32 iID = -1, QObject *parent = nullptr); - void setID(const qint32& iID); - qint32 id(); + void setID(const qint32& iID); + qint32 id(); - void setChapter(cChapter *lpChapter); - cChapter* chapter(); + void setChapter(cChapter *lpChapter); + cChapter* chapter(); - void setName(const QString& szName); - QString name(); + void setName(const QString& szName); + QString name(); - void setSortOrder(const qint32& iSortOrder); - qint32 sortOrder(); + void setSortOrder(const qint32& iSortOrder); + qint32 sortOrder(); - void setDescription(const QString& szDescription); - QString description(); + void setDescription(const QString& szDescription); + QString description(); - void setState(const STATE state); - STATE state(); + void setState(const STATE state); + STATE state(); - void setStartedAt(const QDateTime& startedAt); - QDateTime startedAt(); + void setStartedAt(const QDateTime& startedAt); + QDateTime startedAt(); - void setFinishedAt(const QDateTime& finishedAt); - QDateTime finishedAt(); + void setFinishedAt(const QDateTime& finishedAt); + QDateTime finishedAt(); - void setTargetDate(const QDateTime& targetDate); - QDateTime targetDate(); + void setTargetDate(const QDateTime& targetDate); + QDateTime targetDate(); - void setText(cTextDocument* lpText); - cTextDocument* text(); + void setText(cTextDocument* lpText); + cTextDocument* text(); - QString stateText(); - QString stateText(STATE state) const; - QColor stateColor(); - QColor stateColor(STATE state) const; + void addCharacter(cCharacter* lpCharacter); + void addObject(cObject* lpObject); + void addPlace(cPlace* lpPlace); + + QString stateText(); + QString stateText(STATE state) const; + QColor stateColor(); + QColor stateColor(STATE state) const; private: - qint32 m_iID; - cChapter* m_lpChapter; - QString m_szName; - qint32 m_iSortOrder; - QString m_szDescription; - STATE m_state; - QDateTime m_startedAt; - QDateTime m_finishedAt; - QDateTime m_targetDate; - cTextDocument* m_lpText; + qint32 m_iID; + cChapter* m_lpChapter; + QString m_szName; + qint32 m_iSortOrder; + QString m_szDescription; + STATE m_state; + QDateTime m_startedAt; + QDateTime m_finishedAt; + QDateTime m_targetDate; + cTextDocument* m_lpText; + QList m_characterList; + QList m_objectList; + QList m_placeList; }; Q_DECLARE_METATYPE(cScene*) @@ -81,11 +91,11 @@ Q_DECLARE_METATYPE(cScene*) class cSceneList : public QList { public: - bool load(cChapterList *lpChapterList); - bool save(); + bool load(cChapterList *lpChapterList, cCharacterList* lpCharacterList, cObjectList* lpObjectList, cPlaceList* lpPlaceList); + bool save(); - cScene* add(const qint32& iID); - cScene* find(const qint32& iID); + cScene* add(const qint32& iID); + cScene* find(const qint32& iID); }; #endif // CSCENE_H diff --git a/cstorybook.cpp b/cstorybook.cpp index cde12f5..623ae14 100644 --- a/cstorybook.cpp +++ b/cstorybook.cpp @@ -18,9 +18,6 @@ #include -//rechercheCharacter -//rechercheObject -//recherchePlace //sceneCharacter //sceneObject //scenePlace @@ -354,7 +351,7 @@ bool cStoryBook::loadChapterList() bool cStoryBook::loadSceneList() { - return(m_sceneList.load(&m_chapterList)); + return(m_sceneList.load(&m_chapterList, &m_characterList, &m_objectList, &m_placeList)); } bool cStoryBook::loadCharacterList() @@ -374,7 +371,7 @@ bool cStoryBook::loadObjectList() bool cStoryBook::loadRechercheList() { - return(m_rechercheList.load(&m_imageList)); + return(m_rechercheList.load(&m_imageList, &m_characterList, &m_objectList, &m_placeList)); } bool cStoryBook::loadImageList() @@ -398,6 +395,11 @@ QString cStoryBook::author() return(m_book.author()); } +cChapterList* cStoryBook::chapterList() +{ + return(&m_chapterList); +} + bool cStoryBook::fillOutlineList(QTreeView* lpView) { QMap part; diff --git a/cstorybook.h b/cstorybook.h index e177278..813d12a 100644 --- a/cstorybook.h +++ b/cstorybook.h @@ -40,6 +40,7 @@ public: bool fillObjectList(QTreeView* lpView); bool fillRechercheList(QTreeView* lpView); + cChapterList* chapterList(); private: QString m_szProject; bool m_bIsOpen; diff --git a/cstructurewindow.cpp b/cstructurewindow.cpp deleted file mode 100644 index cd62deb..0000000 --- a/cstructurewindow.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "cstructurewindow.h" -#include "ui_cstructurewindow.h" - -#include - - -cStructureWindow::cStructureWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::cStructureWindow) -{ - ui->setupUi(this); -} - -cStructureWindow::~cStructureWindow() -{ - delete ui; -} - -void cStructureWindow::closeEvent(QCloseEvent *event) -{ - event->ignore(); -} diff --git a/cstructurewindow.h b/cstructurewindow.h deleted file mode 100644 index e469871..0000000 --- a/cstructurewindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CSTRUCTUREWINDOW_H -#define CSTRUCTUREWINDOW_H - -#include - -namespace Ui { -class cStructureWindow; -} - -class cStructureWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit cStructureWindow(QWidget *parent = 0); - ~cStructureWindow(); - -protected: - void closeEvent(QCloseEvent *event) override; - -private: - Ui::cStructureWindow* ui; -}; - -#endif // CSTRUCTUREWINDOW_H diff --git a/cstructurewindow.ui b/cstructurewindow.ui deleted file mode 100644 index 2cedab1..0000000 --- a/cstructurewindow.ui +++ /dev/null @@ -1,49 +0,0 @@ - - - cStructureWindow - - - - 0 - 0 - 800 - 600 - - - - Structure - - - - - - - - - - - - 0 - 0 - 800 - 21 - - - - - Test - - - - - - - - - Test - - - - - - diff --git a/cwidget.cpp b/cwidget.cpp index f7858e9..1e67084 100644 --- a/cwidget.cpp +++ b/cwidget.cpp @@ -1,8 +1,18 @@ #include "cwidget.h" -cWidget::cWidget(QWidget *parent) : +cWidget::cWidget(cPartWindow* parent) : QWidget(parent), + m_type(TYPE_part), + m_lpWidget(parent), + m_lpWindow(0) +{ +} + +cWidget::cWidget(QWidget* parent) : + QWidget(parent), + m_type(TYPE_unknown), + m_lpWidget(0), m_lpWindow(0) { } @@ -12,7 +22,17 @@ void cWidget::setWindow(QMdiSubWindow* lpWindow) m_lpWindow = lpWindow; } -QMdiSubWindow *cWidget::window() +QMdiSubWindow* cWidget::window() { return(m_lpWindow); } + +QWidget* cWidget::widget() +{ + return(m_lpWidget); +} + +cWidget::TYPE cWidget::type() +{ + return(m_type); +} diff --git a/cwidget.h b/cwidget.h index ec0e45d..08ecb71 100644 --- a/cwidget.h +++ b/cwidget.h @@ -1,6 +1,9 @@ #ifndef CWIDGET_H #define CWIDGET_H + +#include "cpartwindow.h" + #include #include @@ -9,15 +12,28 @@ class cWidget : public QWidget { Q_OBJECT public: - explicit cWidget(QWidget *parent = nullptr); + enum TYPE + { + TYPE_unknown = 0, + TYPE_part = 1, + }; + + explicit cWidget(cPartWindow* parent); + explicit cWidget(QWidget* parent); + + QWidget* widget(); + void setWindow(QMdiSubWindow* lpWindow); QMdiSubWindow* window(); + TYPE type(); signals: public slots: private: + TYPE m_type; + QWidget* m_lpWidget; QMdiSubWindow* m_lpWindow; }; diff --git a/qtStoryWriter.pro b/qtStoryWriter.pro index 8b13332..5a300f5 100644 --- a/qtStoryWriter.pro +++ b/qtStoryWriter.pro @@ -46,7 +46,6 @@ SOURCES += \ ctextdocument.cpp \ common.cpp \ ctextedit.cpp \ - cstructurewindow.cpp \ cwidget.cpp \ cstorybook.cpp \ cbook.cpp \ @@ -65,7 +64,6 @@ HEADERS += \ ctextdocument.h \ common.h \ ctextedit.h \ - cstructurewindow.h \ cwidget.h \ cstorybook.h \ common.h \ @@ -82,7 +80,6 @@ HEADERS += \ FORMS += \ cmainwindow.ui \ - cstructurewindow.ui \ cpartwindow.ui DISTFILES += \