1、CUICconfig的value修改为QVariant类型;

feature/struct-menu-20241023
simonyan 3 weeks ago
parent 11db795dc0
commit afe316c995

@ -15,8 +15,7 @@ namespace ModelOper
{ {
CFDOperatorsTimeModeManager::CFDOperatorsTimeModeManager() CFDOperatorsTimeModeManager::CFDOperatorsTimeModeManager()
{ {
qDebug()<<"build Time Mode Manager"; qDebug() << "build Time Mode Manager";
} }
CFDOperatorsTimeModeManager::~CFDOperatorsTimeModeManager() CFDOperatorsTimeModeManager::~CFDOperatorsTimeModeManager()
@ -26,12 +25,14 @@ namespace ModelOper
bool CFDOperatorsTimeModeManager::execGUI() bool CFDOperatorsTimeModeManager::execGUI()
{ {
QWidget* widget = nullptr; QWidget* widget = nullptr;
GUI::MainWindow* mainWindow = dynamic_cast<GUI::MainWindow*>(FITKAPP->getGlobalData()->getMainWindow()); GUI::MainWindow* mainWindow = dynamic_cast<GUI::MainWindow*>(FITKAPP->getGlobalData()->getMainWindow());
if (mainWindow == nullptr)return false; if (mainWindow == nullptr) {
return false;
}
GUI::PropertyWidget* propertyWidget = mainWindow->getPropertyWidget(); GUI::PropertyWidget* propertyWidget = mainWindow->getPropertyWidget();
if (propertyWidget == nullptr)return false; if (propertyWidget == nullptr) {
return false;
}
// switch (_operType){ // switch (_operType){
// case ModelOper::OperManagerBase::Edit: // case ModelOper::OperManagerBase::Edit:
// { // {
@ -39,41 +40,39 @@ namespace ModelOper
// break; // break;
// } // }
// } // }
qDebug() << " ---------------------- senderName: " << _senderName;
qDebug()<<"Time Mode Manager11111111111"; qDebug() << "Time Mode Manager11111111111";
widget = new QLabel("Time Mode Manager11111"); widget = new QLabel("Time Mode Manager11111");
CUI* cui = new CUI(new CUIConfig({ CUI* cui = new CUI(new CUIConfig({
{"type","Widget"} {"type", "Widget"}
},{ }, {
new CUIConfig({ new CUIConfig({
{"type","ComboBox"}, {"type", "ComboBox"},
{"name","Time Mode"} {"name", "Time Mode"},
},{ }, {
new CUIConfig({ new CUIConfig({
{"type","Item"}, {"type", "Item"},
{"name","steady"} {"name", "steady"}
}), }),
new CUIConfig({ new CUIConfig({
{"type","Item"}, {"type", "Item"},
{"name","unsteady"} {"name", "unsteady"}
}) })
}), }),
new CUIConfig({ new CUIConfig({
{"type","LineEdit"}, {"type", "LineEdit"},
{"name","iteration count"} {"name", "iteration count"}
},{}) }, {})
})); }));
widget = cui->getUI(); widget = cui->getUI();
// if (mainWindow->getPropertyWidget() && widget) { // if (mainWindow->getPropertyWidget() && widget) {
propertyWidget->setWidget(widget); propertyWidget->setWidget(widget);
// } // }
return false; return false;
} }
bool CFDOperatorsTimeModeManager::execProfession() bool CFDOperatorsTimeModeManager::execProfession()
{ {
return true; return true;
} }
} }

@ -5,13 +5,11 @@
#include "OperatorsModel/OperManagerBase.h" #include "OperatorsModel/OperManagerBase.h"
//#include "CFDStructDataManager/CFDStructDataManager.h" //#include "CFDStructDataManager/CFDStructDataManager.h"
namespace ModelOper namespace ModelOper {
{
class CFDOperatorsTimeModeManager : public OperManagerBase class CFDOperatorsTimeModeManager : public OperManagerBase {
{
Q_OBJECT; Q_OBJECT;
public: public:
/** /**
* @brief Construct a new Operators Mesh Base Manager object * @brief Construct a new Operators Mesh Base Manager object
*/ */
@ -36,6 +34,7 @@ namespace ModelOper
// 按钮注册相关操作 // 按钮注册相关操作
Register2FITKOPeratorRepo(actionTimeModeEdit, CFDOperatorsTimeModeManager); Register2FITKOPeratorRepo(actionTimeModeEdit, CFDOperatorsTimeModeManager);
Register2FITKOPeratorRepo(actionBasicModelEdit, CFDOperatorsTimeModeManager);
} }
#endif #endif

@ -1,5 +1,5 @@
#include "CFDStructDataManager.h" #include "CFDStructDataManager.h"
CFDStructDataManager::CFDStructDataManager() CFDStructDataManager::CFDStructDataManager() {
{ m_pTimeMode = new CFDStructDataTimeMode;
} }

@ -3,10 +3,20 @@
#include "CFDStructDataManager_global.h" #include "CFDStructDataManager_global.h"
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataManager class CFDStructDataTimeModeUIConfig {
{
public: };
class CFDStructDataTimeMode {
int mode = 0;
int step = 5000;
};
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataManager {
public:
CFDStructDataManager(); CFDStructDataManager();
private:
CFDStructDataTimeMode* m_pTimeMode;
}; };
#endif // CFDSTRUCTDATAMANAGER_H #endif // CFDSTRUCTDATAMANAGER_H

@ -21,6 +21,7 @@ SOURCES += \
CFDStructDataManager.cpp CFDStructDataManager.cpp
HEADERS += \ HEADERS += \
CFDStructDataDefine.h \
CFDStructDataManager_global.h \ CFDStructDataManager_global.h \
CFDStructDataManager.h CFDStructDataManager.h

@ -1,16 +1,15 @@
#include "CUIConfig.h" #include "CUIConfig.h"
#include <QDebug> #include <QDebug>
#include "CFDStructDataManager/CFDStructDataDefine.h"
/** /**
* @brief CUIConfig::CUIConfig * @brief CUIConfig::CUIConfig
* @param property * @param property
*/ */
CUIConfig::CUIConfig(QMap<QString, QString> property) CUIConfig::CUIConfig(QMap<QString, QVariant> property)
{ {
this->property = property;
setDefault(); setDefault();
this->property = property;
} }
/** /**
@ -70,12 +69,11 @@ CUIConfig::CUIConfig(QMap<QString, QString> property)
* @param property * @param property
* @param sub * @param sub
*/ */
CUIConfig::CUIConfig(QMap<QString, QString> property, QVector<CUIConfig *> sub) CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig *> sub)
{ {
setDefault();
this->property = property; this->property = property;
this->sub = sub; this->sub = sub;
setDefault();
} }
/** /**
@ -83,13 +81,40 @@ CUIConfig::CUIConfig(QMap<QString, QString> property, QVector<CUIConfig *> sub)
*/ */
void CUIConfig::printConfig() void CUIConfig::printConfig()
{ {
qDebug()<<"{"; qDebug() << "{";
for(auto it = property.begin();it!=property.end();it++) for(auto it = property.begin(); it != property.end(); it++) {
qDebug()<<it.key()<<' '<<it.value(); qDebug() << it.key() << ' ' << it.value();
for(auto it : sub) }
for(auto it : sub) {
it->printConfig(); it->printConfig();
qDebug()<<"}"; }
qDebug() << "}";
}
void CUIConfig::setValue(QVariant value)
{
// TODO
QVariant pValue = property["valueOrigin"];
if (property["valueType"] == "int") {
int* ptr = qvariant_cast<int*>(pValue);
*ptr = value.toInt();
}
}
QString CUIConfig::getPropertyValue(QString key)
{
if(property.contains(key)) {
return QVA_FROM_QS(property[key]);
}
return QString();
}
QVariant CUIConfig::getPropertyOriginValue(QString key)
{
if(property.contains(key)) {
return property[key];
}
return QVariant::Invalid;
} }
@ -98,34 +123,29 @@ void CUIConfig::printConfig()
*/ */
void CUIConfig::setDefault() void CUIConfig::setDefault()
{ {
if(property["type"] == "LineEdit"){ QString type = QVA_FROM_QS(property["type"]);
setDefault("name",""); if(type == "LineEdit") {
setDefault("data_type","string");//数据类型 setDefault("name", "");
setDefault("initial_value_","");//初始值 setDefault("data_type", "string"); //数据类型
setDefault("check_range_","false");//是否检查范围 setDefault("initial_value_", ""); //初始值
setDefault("range_min_","");//最小值 setDefault("check_range_", "false"); //是否检查范围
setDefault("range_max_","");//最大值 setDefault("range_min_", ""); //最小值
setDefault("inclusive_","true");//范围是否包括 setDefault("range_max_", ""); //最大值
setDefault("required_","false");//是否为必选 setDefault("inclusive_", "true"); //范围是否包括
} setDefault("required_", "false"); //是否为必选
if(property["type"] == "Widget"){ } else if(type == "Widget") {
setDefault("layout","QVBoxLayout"); setDefault("layout", "QVBoxLayout");
setDefault("name",""); setDefault("name", "");
} } else if(type == "GroupBox") {
if(property["type"] == "GroupBox"){ setDefault("name", "");
setDefault("name",""); setDefault("layout", "QVBoxLayout");
setDefault("layout","QVBoxLayout"); } else if(type == "TabWidget") {
} } else if(type == "ComboBox") {
if(property["type"] == "TabWidget"){ setDefault("name", "");
} else if(type == "Item") {
} setDefault("name", "");
if(property["type"] == "ComboBox"){ setDefault("data_type", "string");
setDefault("name",""); setDefault("data", "");
}
if(property["type"] == "Item"){
setDefault("name","");
setDefault("data_type","string");
setDefault("data","");
} }
} }
@ -135,9 +155,10 @@ void CUIConfig::setDefault()
* @param key * @param key
* @param val * @param val
*/ */
void CUIConfig::setDefault(QString key, QString val) void CUIConfig::setDefault(QString key, QVariant val)
{ {
if(!property.contains(key)) if(!property.contains(key)) {
property[key] = val; property[key] = val;
}
} }

@ -3,22 +3,26 @@
#include<QString> #include<QString>
#include<QMap> #include<QMap>
#include<QVariant>
class CUIConfig class CUIConfig
{ {
public: public:
CUIConfig(QMap<QString,QString> property); CUIConfig(QMap<QString, QVariant> temp);
CUIConfig(QMap<QString,QString> property,QVector<CUIConfig*> sub); CUIConfig(QMap<QString, QVariant> temp, QVector<CUIConfig*> sub);
void printConfig(); void printConfig();
QMap<QString,QString> property;
QVector<CUIConfig*> sub;
static int labelMinWidth; void setValue(QVariant);
QString getPropertyValue(QString);
QVariant getPropertyOriginValue(QString);
private: private:
// QString p;
void setDefault(); void setDefault();
void setDefault(QString key,QString val); void setDefault(QString key, QVariant val);
private:
QMap<QString, QVariant> property;
QVector<CUIConfig*> sub;
static int labelMinWidth;
}; };
#endif // CUICONFIG_H #endif // CUICONFIG_H

@ -16,9 +16,9 @@
#include <QHash> #include <QHash>
#include <functional> #include <functional>
#include <QString> #include <QString>
#include <QDebug>
namespace Core namespace Core {
{
class FITKAbstractOperator; class FITKAbstractOperator;
class FITKOperatorRepoPrivate; class FITKOperatorRepoPrivate;
class FITKOperatorDeletor; class FITKOperatorDeletor;
@ -28,8 +28,7 @@ namespace Core
* @author LiBaojun (libaojunqd@foxmail.com) * @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04 * @date 2024-03-04
*/ */
class FITKCoreAPI FITKOperatorRepo : public FITKAbstractObject class FITKCoreAPI FITKOperatorRepo : public FITKAbstractObject {
{
friend FITKOperatorDeletor; friend FITKOperatorDeletor;
//声明为单例 //声明为单例
DeclSingleton(FITKOperatorRepo); DeclSingleton(FITKOperatorRepo);
@ -50,12 +49,11 @@ namespace Core
* @author LiBaojun (libaojunqd@foxmail.com) * @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-04 * @date 2024-03-04
*/ */
T* getOperatorT(const QString& key) T* getOperatorT(const QString& key) {
{
return dynamic_cast<T*> (this->getOperator(key)); return dynamic_cast<T*> (this->getOperator(key));
} }
private: private:
/** /**
* @brief * @brief
* @author LiBaojun (libaojunqd@foxmail.com) * @author LiBaojun (libaojunqd@foxmail.com)
@ -69,7 +67,7 @@ namespace Core
*/ */
void finalize(); void finalize();
private: private:
/** /**
* @brief operator * @brief operator
* @author LiBaojun (libaojunqd@foxmail.com) * @author LiBaojun (libaojunqd@foxmail.com)
@ -84,21 +82,20 @@ namespace Core
FITKOperatorRepoPrivate* _private{}; FITKOperatorRepoPrivate* _private{};
public: public:
template < typename T > template < typename T >
/** /**
* @brief * @brief
* @author LiBaojun (libaojunqd@foxmail.com) * @author LiBaojun (libaojunqd@foxmail.com)
* @date 2024-03-03 * @date 2024-03-03
*/ */
class FITKOperatorRepoRegHelper class FITKOperatorRepoRegHelper {
{ public:
public: FITKOperatorRepoRegHelper(QString key) {
FITKOperatorRepoRegHelper(QString key)
{
auto ins = FITKOperatorRepo::getInstance(); auto ins = FITKOperatorRepo::getInstance();
qDebug() << key;
// 注册构造函数T类型必须有默认的无参构造函数 // 注册构造函数T类型必须有默认的无参构造函数
ins->_createFuns.insert( key,[&] { return new T; }); ins->_createFuns.insert( key, [&] { return new T; });
} }
}; };
}; };

Loading…
Cancel
Save