|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|