1、CUIConfig,提供获取属性方法;

2、CUI组件,修改属性获取方式;
feature/struct-menu-20241023
mzh 3 weeks ago
parent 3904743136
commit 64511c138f

@ -1,9 +1,7 @@
SOURCES += \
CFDStructDataManager.cpp \
CFDStructTimeModeDataManager.cpp \
HEADERS += \
$$PWD/CFDStructDataDefine.h \
CFDStructDataManager_global.h \
CFDStructDataManager.h \
CFDStructTimeModeDataManager.h
CFDStructDataManager.h

@ -1,7 +0,0 @@
#include "CFDStructTimeModeDataManager.h"
CFDStructTimeModeDataManager &CFDStructTimeModeDataManager::GetInstance()
{
static CFDStructTimeModeDataManager res;
return res;
}

@ -1,15 +0,0 @@
#include "CFDStructDataManager_global.h"
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructTimeModeDataManager{
public:
static int timeMode;
static int iterationSteps;
static CFDStructTimeModeDataManager& GetInstance();
int& getTimeModeAddr();
int& getIterationoStepsAddr();
private:
CFDStructTimeModeDataManager();
~CFDStructTimeModeDataManager();
};

@ -28,15 +28,14 @@ CUI::CUI(CUIConfig *conf)
*/
void CUI::buildUI()
{
QString type = conf->property["type"];
// QString type = conf->property["type"];
QString type = conf->getPropertyValue("type");
if(type == "")
return;
// qDebug()<<"start_build";
if(type == "Widget")
{
// qDebug()<<"build widget";
uiWidget = new CUIWidget(conf,subCUI);
}
if(type == "GroupBox")
@ -81,34 +80,35 @@ void CUI::check()
*/
QWidget *CUI::getUI()
{
if(conf->property["type"] == "Widget"){
QString type = conf->getPropertyValue("type");
if(type == "Widget"){
return uiWidget;
}
if(conf->property["type"] == "GroupBox"){
if(type == "GroupBox"){
return uiGroupBox;
}
if(conf->property["type"] == "LineEdit"){
if(type == "LineEdit"){
return uiLineEdit;
}
if(conf->property["type"] == "TabWidget"){
if(type == "TabWidget"){
return uiTabWidget;
}
if(conf->property["type"] == "ComboBox"){
if(type == "ComboBox"){
return uiComboBox;
}
if(conf->property["type"] == "Item"){
if(type == "Item"){
return NULL;
}
if(conf->property["type"] == "PushButton"){
if(type == "PushButton"){
return uiPushButton;
}
if(conf->property["type"] == "CheckBox"){
if(type == "CheckBox"){
return uiCheckBox;
}
if(conf->property["type"] == "ButtonBox"){
if(type == "ButtonBox"){
return uiButtonBox;
}
if(conf->property["type"] == "RadioButton"){
if(type == "RadioButton"){
return uiRadioButton;
}
@ -122,7 +122,8 @@ QWidget *CUI::getUI()
*/
QString CUI::getProperty(QString s)
{
return conf->property[s];
// return conf->property[s];
return conf->getPropertyValue(s);
}
/**
@ -142,10 +143,11 @@ void CUI::autoArrangeWidgets()
qint32 CUI::getMaxLabelWidth()
{
qint32 res = INT_MIN;
if(conf->property["type"] == "LineEdit"){
QString type = conf->getPropertyValue("type");
if(type == "LineEdit"){
res = uiLineEdit->getLabelWidth();
}
else if(conf->property["type"] == "ComboBox"){
else if(type == "ComboBox"){
res = uiComboBox->getLabelWidth();
}else{
for(auto &ui:subCUI){
@ -157,10 +159,11 @@ qint32 CUI::getMaxLabelWidth()
void CUI::setLabelWidth(qint32 width)
{
if(conf->property["type"] == "LineEdit"){
QString type = conf->getPropertyValue("type");
if(type == "LineEdit"){
uiLineEdit->setLabelWidth(width);
}
else if(conf->property["type"] == "ComboBox"){
else if(type == "ComboBox"){
uiComboBox->setLabelWidth(width);
}else{
for(auto &ui:subCUI){

@ -11,5 +11,5 @@ CUICheckBox::CUICheckBox(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent
void CUICheckBox::iniUI(QVector<CUI*> &subCUI)
{
this->setText(conf->property["name"]);
this->setText(conf->getPropertyValue("name"));
}

@ -43,7 +43,7 @@ void CUIComboBox::setLabelWidth(qint32 width)
*/
void CUIComboBox::iniUI(QVector<CUI*> &subCUI)
{
label = new QLabel(conf->property["name"]);
label = new QLabel(conf->getPropertyValue("name"));
comboBox = new QComboBox;
layout = new QHBoxLayout;
this->setLayout(layout);
@ -69,8 +69,9 @@ void CUIComboBox::iniUI(QVector<CUI*> &subCUI)
*/
void CUIComboBox::iniComoboBox()
{
for(auto cui:conf->sub){
if(cui->property["type"] != "Item"){
for(auto cui:conf->getSub()){
QString type = cui->getPropertyValue("type");
if(type != "Item"){
qDebug()<<"wrong type!!!";
return;
}

@ -19,7 +19,8 @@
QLayout* CUICommon::appLayout(CUIConfig* conf)
{
QLayout* res_layout;
QString confLayout = conf->property["layout"];
// QString confLayout = conf->property["layout"];
QString confLayout = conf->getPropertyValue("layout");
if(confLayout == "QVBoxLayout")
res_layout = new QVBoxLayout;
else if (confLayout == "QHBoxLayout") {

@ -101,6 +101,11 @@ void CUIConfig::setValue(QVariant value)
}
}
/**
* @brief CUIConfig::getPropertyValue
* @param key
* @return
*/
QString CUIConfig::getPropertyValue(QString key)
{
if(property.contains(key)) {
@ -109,6 +114,11 @@ QString CUIConfig::getPropertyValue(QString key)
return QString();
}
/**
* @brief CUIConfig::getPropertyOriginValue
* @param key
* @return
*/
QVariant CUIConfig::getPropertyOriginValue(QString key)
{
if(property.contains(key)) {
@ -117,6 +127,11 @@ QVariant CUIConfig::getPropertyOriginValue(QString key)
return QVariant::Invalid;
}
QVector<CUIConfig *> CUIConfig::getSub()
{
return this->sub;
}
/**
* @brief CUIConfig::setDefault

@ -15,6 +15,7 @@ public:
void setValue(QVariant);
QString getPropertyValue(QString);
QVariant getPropertyOriginValue(QString);
QVector<CUIConfig*> getSub();
private:
void setDefault();
void setDefault(QString key, QVariant val);

@ -23,13 +23,13 @@ CUIGroupBox::CUIGroupBox(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent
*/
void CUIGroupBox::iniUI(QVector<CUI*> &subCUI)
{
this->setTitle(conf->property["name"]);
this->setTitle(conf->getPropertyValue("name"));
// appLayout();
layout = appLayout(conf);
this->setLayout(layout);
qDebug()<<this->conf->sub.size();
for(auto conf : this->conf->sub){
qDebug()<<this->conf->getSub().size();
for(auto conf : this->conf->getSub()){
CUI* tmp = new CUI(conf);
subCUI.push_back(tmp);

@ -77,12 +77,11 @@ void CUILineEdit::setLabelWidth(qint32 width)
void CUILineEdit::iniUI(QVector<CUI*> &subCUI)
{
layout = new QHBoxLayout();
label = new QLabel(conf->property["name"]);
label = new QLabel(conf->getPropertyValue("name"));
lineedit = new QLineEdit(initial_value_);
layout->addWidget(label);
layout->addWidget(lineedit);
this->setLayout(layout);
// qDebug()<<"new lineedit";
connect(lineedit, &QLineEdit::textEdited, this, &CUILineEdit::onTextChanged);
}
@ -92,22 +91,20 @@ void CUILineEdit::iniUI(QVector<CUI*> &subCUI)
*/
void CUILineEdit::appSetting()
{
data_type = conf->property["data_type"];
initial_value_ = conf->property["initial_value_"];
data_type = conf->getPropertyValue("data_type");
initial_value_ = conf->getPropertyValue("initial_value_");
qDebug()<< initial_value_;
if(data_type == "string"){
check_range_ = 0;
}
if(data_type == "int"){
if(conf->property["check_range_"] == "true")
if(conf->getPropertyValue("check_range_") == "true")
{
check_range_ = true;
range_min_ = conf->property["range_min_"].toInt();
range_max_ = conf->property["range_max_"].toInt();
range_min_ = conf->getPropertyValue("range_min_").toInt();
range_max_ = conf->getPropertyValue("range_max_").toInt();
qDebug()<<conf->property["name"]<<' '<<range_min_<<' '<<range_max_;
if(conf->property["inclusive_"] == "true")
if(conf->getPropertyValue("inclusive_") == "true")
inclusive_ = true;
else
inclusive_ = false;
@ -116,11 +113,12 @@ void CUILineEdit::appSetting()
}
}
if(data_type == "double"){
if(conf->property["check_range_"] == "true"){
if(conf->getPropertyValue("check_range_") == "true"){
check_range_ = true;
range_min_ = conf->property["range_min_"].toDouble();
range_max_ = conf->property["range_max_"].toDouble();
if(conf->property["inclusive_"] == "true")
range_min_ = conf->getPropertyValue("range_min_").toDouble();
range_max_ = conf->getPropertyValue("range_max_").toDouble();
if(conf->getPropertyValue("inclusive_") == "true")
inclusive_ = true;
else
inclusive_ = false;
@ -128,7 +126,7 @@ void CUILineEdit::appSetting()
check_range_ = false;
}
}
if(conf->property["required_"] == "false")
if(conf->getPropertyValue("required_") == "false")
required_ = false;
else
required_ = true;

@ -23,6 +23,7 @@ win32{
Release:OBJECTS_DIR = ../../generate/CUIProperty/release/obj
Release:LIBS += \
-L../../output/bin \
-lCFDStructDataManager
@ -34,6 +35,8 @@ win32{
Debug:OBJECTS_DIR = ../../generate/CUIProperty/debug/obj
Debug:LIBS += \
-L../../output/bin_d \
-lCFDStructDataManager
@ -55,6 +58,8 @@ unix{
OBJECTS_DIR = ../../generate/CUIProperty/release/obj
LIBS += \
-L../../output/bin \
-lCFDStructDataManager
message("Linux CUIProperty generated")

@ -11,6 +11,6 @@ CUIPushButton::CUIPushButton(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *pa
void CUIPushButton::iniUI(QVector<CUI*> &subCUI)
{
this->setText(conf->property["name"]);
this->setText(conf->getPropertyValue("name"));
}

@ -13,7 +13,5 @@ CUIRadioButton::CUIRadioButton(CUIConfig* conf, QVector<CUI*> subCUI,QWidget *pa
void CUIRadioButton::iniUI()
{
this->setText(conf->property["name"]);
// qDebug()<<"Radio ini "<<conf->property["name"];
this->setText(conf->getPropertyValue("name"));
}

@ -20,9 +20,9 @@ CUITabWidget::CUITabWidget(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *pare
*/
void CUITabWidget::iniUI(QVector<CUI*> &subCUI)
{
for(auto conf:conf->sub){
for(auto conf:conf->getSub()){
CUI* subui = new CUI(conf);
subCUI.push_back(subui);
this->addTab(subui->getUI(),conf->property["name"]);
this->addTab(subui->getUI(),conf->getPropertyValue("name"));
}
}

@ -28,7 +28,7 @@ void CUIWidget::iniUI(QVector<CUI*> &subCUI)
// qDebug()<<"widget add layout";
for(auto &conf : this->conf->sub){
for(auto &conf : this->conf->getSub()){
CUI* tmp = new CUI(conf);
subCUI.push_back(tmp);
layout->addWidget(tmp->getUI());
@ -42,7 +42,7 @@ void CUIWidget::iniUI(QVector<CUI*> &subCUI)
*/
QString CUIWidget::getProperty(QString key)
{
return conf->property[key];
return conf->getPropertyValue(key);
}

Loading…
Cancel
Save