diff --git a/.gitignore b/.gitignore index 343709e..cfe4c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ FlowApp/FlowApp_resource.rc *.exp CFDStruct/CFDStructDataManager/debug/ CFDStruct/CFDStructDataManager/release/ +FlowApp.pro.user* diff --git a/CFDStruct/CUIProperty/CUICommon.cpp b/CFDStruct/CUIProperty/CUICommon.cpp deleted file mode 100644 index 2660a20..0000000 --- a/CFDStruct/CUIProperty/CUICommon.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "CUICommon.h" - -#include -#include -#include -#include -#include -#include -//CUICommon::CUICommon() -//{ - -//} - -/** - * @brief CUICommon::appLayout 自动提取layout配置信息,根据设置返回layout - * @param conf 配置信息 - * @return layout的引用 - */ -QLayout* CUICommon::appLayout(CUIConfig* conf) -{ - QLayout* res_layout; -// QString confLayout = conf->property["layout"]; - QString confLayout = conf->getPropertyValue("layout"); - if(confLayout == "QVBoxLayout") - res_layout = new QVBoxLayout; - else if (confLayout == "QHBoxLayout") { - res_layout = new QHBoxLayout; - }else { - res_layout = new QVBoxLayout; - } - return res_layout; -} diff --git a/CFDStruct/CUIProperty/CUICommon.h b/CFDStruct/CUIProperty/CUICommon.h deleted file mode 100644 index 73ac3f9..0000000 --- a/CFDStruct/CUIProperty/CUICommon.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CUICOMMON_H -#define CUICOMMON_H - -class QLayout; -class QString; -class CUIConfig; - -class CUICommon -{ -public: -// CUICommon(); - -protected: - virtual QLayout* appLayout(CUIConfig* conf); -}; - -#endif // CUICOMMON_H diff --git a/CFDStruct/CUIProperty/CUIComponentBase.cpp b/CFDStruct/CUIProperty/CUIComponentBase.cpp index c5a186a..5224218 100644 --- a/CFDStruct/CUIProperty/CUIComponentBase.cpp +++ b/CFDStruct/CUIProperty/CUIComponentBase.cpp @@ -1,6 +1,6 @@ #include "CUIComponentBase.h" -CUIComponentBase::CUIComponentBase(QWidget *parent) : QWidget(parent) +CUIComponentBase::CUIComponentBase() { this->initSetting(); } diff --git a/CFDStruct/CUIProperty/CUIComponentBase.h b/CFDStruct/CUIProperty/CUIComponentBase.h index 6c1f7a7..627d39b 100644 --- a/CFDStruct/CUIProperty/CUIComponentBase.h +++ b/CFDStruct/CUIProperty/CUIComponentBase.h @@ -1,17 +1,16 @@ #ifndef CUICOMPONENTBASE_H #define CUICOMPONENTBASE_H -#include +#include #include #include "CUIPropertyAPI.h" #include "CUIConfig.h" #include "CUIDefine.h" -class CUIPropertyAPI CUIComponentBase : public QWidget +class CUIPropertyAPI CUIComponentBase { - Q_OBJECT public: - explicit CUIComponentBase(QWidget *parent = nullptr); + explicit CUIComponentBase(); protected: // 初始化配置 diff --git a/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.cpp b/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.cpp new file mode 100644 index 0000000..af25780 --- /dev/null +++ b/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.cpp @@ -0,0 +1,26 @@ +#include "CUIComponentBaseContainerWidget.h" +#include "CUIConfig.h" +#include +#include + +CUIComponentBaseContainerWidget::CUIComponentBaseContainerWidget(QWidget *parent) : QWidget(parent) +{ + +} + +QLayout *CUIComponentBaseContainerWidget::getLayout(CUIConfig *conf) +{ + if (!conf) { + return new QVBoxLayout; + } + QLayout* layout; + QString layoutConf = conf->getPropertyValue("layout"); + if (layoutConf == "QVBoxLayout") { + layout = new QVBoxLayout; + } else if (layoutConf == "QVBoxLayout") { + layout = new QHBoxLayout; + } else { + layout = new QHBoxLayout; + } + return layout; +} diff --git a/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.h b/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.h new file mode 100644 index 0000000..2fe4e86 --- /dev/null +++ b/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.h @@ -0,0 +1,21 @@ +#ifndef CUICOMPONENTBASECONTAINERWIDGET_H +#define CUICOMPONENTBASECONTAINERWIDGET_H + +#include +class CUIConfig; +class QLayout; + +class CUIComponentBaseContainerWidget : public QWidget +{ + Q_OBJECT +public: + explicit CUIComponentBaseContainerWidget(QWidget *parent = nullptr); +protected: + virtual QLayout* getLayout(CUIConfig* conf); +protected: + QLayout* m_layout; +signals: + +}; + +#endif // CUICOMPONENTBASECONTAINERWIDGET_H diff --git a/CFDStruct/CUIProperty/CUIComponentBaseWidget.cpp b/CFDStruct/CUIProperty/CUIComponentBaseWidget.cpp new file mode 100644 index 0000000..bb78e09 --- /dev/null +++ b/CFDStruct/CUIProperty/CUIComponentBaseWidget.cpp @@ -0,0 +1,26 @@ +#include "CUIComponentBaseWidget.h" +#include "CUIConfig.h" + +#include +#include + +CUIComponentBaseWidget::CUIComponentBaseWidget(QWidget *parent) : QWidget(parent) +{ +} + +QLayout *CUIComponentBaseWidget::getLayout(CUIConfig *conf) +{ + if (!conf) { + return new QVBoxLayout; + } + QLayout* layout; + QString layoutConf = conf->getPropertyValue("layout"); + if (layoutConf == "QVBoxLayout") { + layout = new QVBoxLayout; + } else if (layoutConf == "QVBoxLayout") { + layout = new QHBoxLayout; + } else { + layout = new QHBoxLayout; + } + return layout; +} diff --git a/CFDStruct/CUIProperty/CUIComponentBaseWidget.h b/CFDStruct/CUIProperty/CUIComponentBaseWidget.h new file mode 100644 index 0000000..8ae1fd2 --- /dev/null +++ b/CFDStruct/CUIProperty/CUIComponentBaseWidget.h @@ -0,0 +1,21 @@ +#ifndef CUICOMPONENTBASEWIDGET_H +#define CUICOMPONENTBASEWIDGET_H + +#include +class CUIConfig; + +class CUIComponentBaseWidget : public QWidget +{ + Q_OBJECT +public: + explicit CUIComponentBaseWidget(QWidget *parent = nullptr); +protected: + virtual QLayout* getLayout(CUIConfig* conf); + +protected: + +signals: + +}; + +#endif // CUICOMPONENTBASEWIDGET_H diff --git a/CFDStruct/CUIProperty/CUIGroupBox.cpp b/CFDStruct/CUIProperty/CUIGroupBox.cpp index 15a9a80..2644b66 100644 --- a/CFDStruct/CUIProperty/CUIGroupBox.cpp +++ b/CFDStruct/CUIProperty/CUIGroupBox.cpp @@ -11,7 +11,7 @@ * @param conf * @param parent */ -CUIGroupBox::CUIGroupBox(CUIConfig* conf, QVector &subCUI, QWidget *parent) : QGroupBox(parent) +CUIGroupBox::CUIGroupBox(CUIConfig* conf, QVector &subCUI, QWidget *parent) : CUIComponentBaseContainerWidget(parent) { this->conf = conf; iniUI(subCUI); @@ -23,27 +23,18 @@ CUIGroupBox::CUIGroupBox(CUIConfig* conf, QVector &subCUI, QWidget *parent */ void CUIGroupBox::iniUI(QVector &subCUI) { - this->setTitle(conf->getPropertyValue("name")); -// appLayout(); - layout = appLayout(conf); - this->setLayout(layout); + m_groupBox = new QGroupBox; + m_groupBox->setTitle(conf->getPropertyValue("name")); + m_layout = this->getLayout(conf); + m_groupBox->setLayout(m_layout); qDebug() << this->conf->getSub().size(); for(auto conf : this->conf->getSub()) { CUI* tmp = new CUI(nullptr, conf); subCUI.push_back(tmp); - layout->addWidget(tmp->getUI()); + m_layout->addWidget(tmp->getUI()); } -} - - -/** - * @brief CUIGroupBox::appLayout 根据配置信息应用layout - */ -//void CUIGroupBox::appLayout() -//{ -// if(conf->property["layout"] == "QVBoxLayout") -// layout = new QVBoxLayout(); -// layout = new QFormLayout(); -// this->setLayout(layout); -//} + QVBoxLayout* mainLayout = new QVBoxLayout; + mainLayout->addWidget(m_groupBox); + this->setLayout(mainLayout); +} diff --git a/CFDStruct/CUIProperty/CUIGroupBox.h b/CFDStruct/CUIProperty/CUIGroupBox.h index 1d7b4af..80fae29 100644 --- a/CFDStruct/CUIProperty/CUIGroupBox.h +++ b/CFDStruct/CUIProperty/CUIGroupBox.h @@ -2,23 +2,23 @@ #define CUIGROUPBOX_H #include -#include +#include class CUI; class CUIConfig; +class QGroupBox; - -class CUIGroupBox : public QGroupBox, public CUICommon +class CUIGroupBox : public CUIComponentBaseContainerWidget { Q_OBJECT public: explicit CUIGroupBox(CUIConfig* conf, QVector &subCUI, QWidget *parent = nullptr); private: CUIConfig* conf; -// void appLayout(); -// QVector subUI; protected: - QLayout* layout; + QLayout* m_layout; + QGroupBox* m_groupBox; +protected: void iniUI(QVector &subCUI); diff --git a/CFDStruct/CUIProperty/CUILineEdit.cpp b/CFDStruct/CUIProperty/CUILineEdit.cpp index 283dbde..20e22c8 100644 --- a/CFDStruct/CUIProperty/CUILineEdit.cpp +++ b/CFDStruct/CUIProperty/CUILineEdit.cpp @@ -13,7 +13,7 @@ * @param conf 配置信息 * @param parent */ -CUILineEdit::CUILineEdit(CUIConfig* conf, QVector &subCUI, QWidget *parent) : CUIComponentBase(parent) +CUILineEdit::CUILineEdit(CUIConfig* conf, QVector &subCUI, QWidget *parent) : CUIComponentBaseWidget(parent) { this->m_conf = conf; this->iniUI(subCUI); diff --git a/CFDStruct/CUIProperty/CUILineEdit.h b/CFDStruct/CUIProperty/CUILineEdit.h index d179ad2..52eaab7 100644 --- a/CFDStruct/CUIProperty/CUILineEdit.h +++ b/CFDStruct/CUIProperty/CUILineEdit.h @@ -1,16 +1,18 @@ #ifndef CUILINEEDIT_H #define CUILINEEDIT_H +#include #include #include "CUIPropertyAPI.h" #include "CUIComponentBase.h" +#include "CUIComponentBaseWidget.h" class CUIConfig; class QLabel; class QHBoxLayout; class CUI; -class CUIPropertyAPI CUILineEdit : public CUIComponentBase +class CUIPropertyAPI CUILineEdit : public CUIComponentBaseWidget, public CUIComponentBase { Q_OBJECT public: diff --git a/CFDStruct/CUIProperty/CUIProperty.pri b/CFDStruct/CUIProperty/CUIProperty.pri index 8c19c26..c0bbedf 100644 --- a/CFDStruct/CUIProperty/CUIProperty.pri +++ b/CFDStruct/CUIProperty/CUIProperty.pri @@ -1,11 +1,12 @@ HEADERS += \ $$PWD/CUIComponentBase.h \ + $$PWD/CUIComponentBaseContainerWidget.h \ + $$PWD/CUIComponentBaseWidget.h \ $$PWD/CUIDefine.h \ CUI.h \ CUIButtonBox.h \ CUICheckBox.h \ CUIComboBox.h \ - CUICommon.h \ CUIGroupBox.h \ CUILineEdit.h \ CUIPushButton.h \ @@ -18,11 +19,12 @@ HEADERS += \ SOURCES += \ $$PWD/CUIComponentBase.cpp \ + $$PWD/CUIComponentBaseContainerWidget.cpp \ + $$PWD/CUIComponentBaseWidget.cpp \ CUI.cpp \ CUIButtonBox.cpp \ CUICheckBox.cpp \ CUIComboBox.cpp \ - CUICommon.cpp \ CUIGroupBox.cpp \ CUILineEdit.cpp \ CUIPushButton.cpp \ diff --git a/CFDStruct/CUIProperty/CUIWidget.cpp b/CFDStruct/CUIProperty/CUIWidget.cpp index 6b29d58..e98d5d7 100644 --- a/CFDStruct/CUIProperty/CUIWidget.cpp +++ b/CFDStruct/CUIProperty/CUIWidget.cpp @@ -2,7 +2,6 @@ #include "CUIConfig.h" #include "QVBoxLayout" #include -#include #include #include @@ -12,9 +11,9 @@ * @param conf 配置信息 * @param parent */ -CUIWidget::CUIWidget(CUIConfig *conf, QVector &subCUI, QWidget *parent): QWidget(parent) +CUIWidget::CUIWidget(CUIConfig *conf, QVector &subCUI, QWidget *parent): CUIComponentBaseContainerWidget(parent) { - this->conf = conf; + this->m_conf = conf; iniUI(subCUI); } @@ -23,24 +22,13 @@ CUIWidget::CUIWidget(CUIConfig *conf, QVector &subCUI, QWidget *parent): Q */ void CUIWidget::iniUI(QVector &subCUI) { - layout = appLayout(conf); - this->setLayout(layout); -// qDebug()<<"widget add layout"; - for(auto &conf : this->conf->getSub()) { + m_layout = this->getLayout(m_conf); + this->setLayout(m_layout); + for(auto &conf : this->m_conf->getSub()) { CUI* tmp = new CUI(nullptr, conf); subCUI.push_back(tmp); - layout->addWidget(tmp->getUI()); + m_layout->addWidget(tmp->getUI()); } } -/** - * @brief CUIWidget::getProperty 获取配置信息 - * @param key - * @return val - */ -QString CUIWidget::getProperty(QString key) -{ - return conf->getPropertyValue(key); -} - diff --git a/CFDStruct/CUIProperty/CUIWidget.h b/CFDStruct/CUIProperty/CUIWidget.h index ac721fd..030832e 100644 --- a/CFDStruct/CUIProperty/CUIWidget.h +++ b/CFDStruct/CUIProperty/CUIWidget.h @@ -1,23 +1,19 @@ #ifndef CUIWIDGET_H #define CUIWIDGET_H -#include class CUIConfig; class CUI; #include +#include "CUIComponentBaseContainerWidget.h" +#include "CUIComponentBase.h" -class CUIWidget : public QWidget, public CUICommon +class CUIWidget : public CUIComponentBaseContainerWidget, CUIComponentBase { Q_OBJECT public: explicit CUIWidget(CUIConfig* conf, QVector &subCUI, QWidget *parent = nullptr); private: void iniUI(QVector &subCUI); -// void appLayout(); - QString getProperty(QString p); - CUIConfig* conf; - QLayout* layout; -// QVector subUI; signals: };