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

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

@ -16,7 +16,6 @@ namespace ModelOper
CFDOperatorsTimeModeManager::CFDOperatorsTimeModeManager()
{
qDebug() << "build Time Mode Manager";
}
CFDOperatorsTimeModeManager::~CFDOperatorsTimeModeManager()
@ -26,12 +25,14 @@ namespace ModelOper
bool CFDOperatorsTimeModeManager::execGUI()
{
QWidget* widget = nullptr;
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();
if (propertyWidget == nullptr)return false;
if (propertyWidget == nullptr) {
return false;
}
// switch (_operType){
// case ModelOper::OperManagerBase::Edit:
// {
@ -39,16 +40,15 @@ namespace ModelOper
// break;
// }
// }
qDebug() << " ---------------------- senderName: " << _senderName;
qDebug() << "Time Mode Manager11111111111";
widget = new QLabel("Time Mode Manager11111");
CUI* cui = new CUI(new CUIConfig({
{"type", "Widget"}
}, {
new CUIConfig({
{"type", "ComboBox"},
{"name","Time Mode"}
{"name", "Time Mode"},
}, {
new CUIConfig({
{"type", "Item"},
@ -68,7 +68,6 @@ namespace ModelOper
// if (mainWindow->getPropertyWidget() && widget) {
propertyWidget->setWidget(widget);
// }
return false;
}

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

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

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

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

@ -1,16 +1,15 @@
#include "CUIConfig.h"
#include <QDebug>
#include "CFDStructDataManager/CFDStructDataDefine.h"
/**
* @brief CUIConfig::CUIConfig
* @param property
*/
CUIConfig::CUIConfig(QMap<QString, QString> property)
CUIConfig::CUIConfig(QMap<QString, QVariant> property)
{
this->property = property;
setDefault();
this->property = property;
}
/**
@ -70,12 +69,11 @@ CUIConfig::CUIConfig(QMap<QString, QString> property)
* @param property
* @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->sub = sub;
setDefault();
}
/**
@ -84,12 +82,39 @@ CUIConfig::CUIConfig(QMap<QString, QString> property, QVector<CUIConfig *> sub)
void CUIConfig::printConfig()
{
qDebug() << "{";
for(auto it = property.begin();it!=property.end();it++)
for(auto it = property.begin(); it != property.end(); it++) {
qDebug() << it.key() << ' ' << it.value();
for(auto it : sub)
}
for(auto it : sub) {
it->printConfig();
}
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,7 +123,8 @@ void CUIConfig::printConfig()
*/
void CUIConfig::setDefault()
{
if(property["type"] == "LineEdit"){
QString type = QVA_FROM_QS(property["type"]);
if(type == "LineEdit") {
setDefault("name", "");
setDefault("data_type", "string"); //数据类型
setDefault("initial_value_", ""); //初始值
@ -107,22 +133,16 @@ void CUIConfig::setDefault()
setDefault("range_max_", ""); //最大值
setDefault("inclusive_", "true"); //范围是否包括
setDefault("required_", "false"); //是否为必选
}
if(property["type"] == "Widget"){
} else if(type == "Widget") {
setDefault("layout", "QVBoxLayout");
setDefault("name", "");
}
if(property["type"] == "GroupBox"){
} else if(type == "GroupBox") {
setDefault("name", "");
setDefault("layout", "QVBoxLayout");
}
if(property["type"] == "TabWidget"){
}
if(property["type"] == "ComboBox"){
} else if(type == "TabWidget") {
} else if(type == "ComboBox") {
setDefault("name", "");
}
if(property["type"] == "Item"){
} else if(type == "Item") {
setDefault("name", "");
setDefault("data_type", "string");
setDefault("data", "");
@ -135,9 +155,10 @@ void CUIConfig::setDefault()
* @param key
* @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;
}
}

@ -3,22 +3,26 @@
#include<QString>
#include<QMap>
#include<QVariant>
class CUIConfig
{
public:
CUIConfig(QMap<QString,QString> property);
CUIConfig(QMap<QString,QString> property,QVector<CUIConfig*> sub);
CUIConfig(QMap<QString, QVariant> temp);
CUIConfig(QMap<QString, QVariant> temp, QVector<CUIConfig*> sub);
void printConfig();
QMap<QString,QString> property;
QVector<CUIConfig*> sub;
static int labelMinWidth;
void setValue(QVariant);
QString getPropertyValue(QString);
QVariant getPropertyOriginValue(QString);
private:
// QString p;
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

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

Loading…
Cancel
Save