|
|
@ -8,8 +8,7 @@
|
|
|
|
* @brief CUIConfig::CUIConfig 构造函数
|
|
|
|
* @brief CUIConfig::CUIConfig 构造函数
|
|
|
|
* @param property 组件的属性
|
|
|
|
* @param property 组件的属性
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
CUIConfig::CUIConfig(QMap<QString, QVariant> property)
|
|
|
|
CUIConfig::CUIConfig(QMap<QString, QVariant> property) {
|
|
|
|
{
|
|
|
|
|
|
|
|
setDefault();
|
|
|
|
setDefault();
|
|
|
|
this->property = property;
|
|
|
|
this->property = property;
|
|
|
|
this->m_sigsCenter = CUISigsCenter::getInstance();
|
|
|
|
this->m_sigsCenter = CUISigsCenter::getInstance();
|
|
|
@ -70,12 +69,11 @@ CUIConfig::CUIConfig(QMap<QString, QVariant> property)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @subsection RadioButton 圆形选择按钮
|
|
|
|
* @subsection RadioButton 圆形选择按钮
|
|
|
|
* - "name" : 组件名
|
|
|
|
* - "name" : 组件名
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param property 组件的属性
|
|
|
|
* @param property 组件的属性
|
|
|
|
* @param sub 该组件的子组件配置的列表
|
|
|
|
* @param sub 该组件的子组件配置的列表
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig *> sub)
|
|
|
|
CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig*> sub) {
|
|
|
|
{
|
|
|
|
|
|
|
|
setDefault();
|
|
|
|
setDefault();
|
|
|
|
this->property = property;
|
|
|
|
this->property = property;
|
|
|
|
this->sub = sub;
|
|
|
|
this->sub = sub;
|
|
|
@ -85,8 +83,7 @@ CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig *> sub)
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief CUIConfig::printConfig 打印当前配置信息
|
|
|
|
* @brief CUIConfig::printConfig 打印当前配置信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
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();
|
|
|
@ -97,29 +94,59 @@ void CUIConfig::printConfig()
|
|
|
|
// qDebug() << "}";
|
|
|
|
// qDebug() << "}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CUIConfig::setValue(QVariant value)
|
|
|
|
QString CUIConfig::getOriginValueString() {
|
|
|
|
{
|
|
|
|
QVariant pValue = property["value_origin"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果没有设置原始值
|
|
|
|
|
|
|
|
if (pValue == QVariant::Invalid) {
|
|
|
|
|
|
|
|
return QString("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (property["value_type"] == CUI_DATA_TYPE_INT) {
|
|
|
|
|
|
|
|
int* ptr = qvariant_cast<int*>(pValue);
|
|
|
|
|
|
|
|
return QString::number(*ptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (property["value_type"] == CUI_DATA_TYPE_DOUBLE) {
|
|
|
|
|
|
|
|
double* ptr = qvariant_cast<double*>(pValue);
|
|
|
|
|
|
|
|
return QString::number(*ptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (property["value_type"] == CUI_DATA_TYPE_STRING) {
|
|
|
|
|
|
|
|
QString* ptr = qvariant_cast<QString*>(pValue);
|
|
|
|
|
|
|
|
return *ptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return QString("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CUIConfig::setValue(QVariant value) {
|
|
|
|
bool changed = false;
|
|
|
|
bool changed = false;
|
|
|
|
QVariant pValue = property["value_origin"];
|
|
|
|
QVariant pValue = property["value_origin"];
|
|
|
|
|
|
|
|
|
|
|
|
if (property["value_type"] == CUI_DATA_TYPE_INT) {
|
|
|
|
if (property["value_type"] == CUI_DATA_TYPE_INT) {
|
|
|
|
int* ptr = qvariant_cast<int*>(pValue);
|
|
|
|
int* ptr = qvariant_cast<int*>(pValue);
|
|
|
|
|
|
|
|
|
|
|
|
if (*ptr != value.toInt()) {
|
|
|
|
if (*ptr != value.toInt()) {
|
|
|
|
*ptr = value.toInt();
|
|
|
|
*ptr = value.toInt();
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (property["value_type"] == CUI_DATA_TYPE_DOUBLE) {
|
|
|
|
} else if (property["value_type"] == CUI_DATA_TYPE_DOUBLE) {
|
|
|
|
double* ptr = qvariant_cast<double*>(pValue);
|
|
|
|
double* ptr = qvariant_cast<double*>(pValue);
|
|
|
|
|
|
|
|
|
|
|
|
if (*ptr != value.toDouble()) {
|
|
|
|
if (*ptr != value.toDouble()) {
|
|
|
|
*ptr = value.toDouble();
|
|
|
|
*ptr = value.toDouble();
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (property["value_type"] == CUI_DATA_TYPE_STRING) {
|
|
|
|
} else if (property["value_type"] == CUI_DATA_TYPE_STRING) {
|
|
|
|
double* ptr = qvariant_cast<double*>(pValue);
|
|
|
|
QString* ptr = qvariant_cast<QString*>(pValue);
|
|
|
|
if (*ptr != value.toDouble()) {
|
|
|
|
|
|
|
|
*ptr = value.toDouble();
|
|
|
|
if (*ptr != value.toString()) {
|
|
|
|
|
|
|
|
*ptr = value.toString();
|
|
|
|
changed = true;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果需要通知,则通知参数值发生修改
|
|
|
|
// 如果需要通知,则通知参数值发生修改
|
|
|
|
if (changed && this->getPropertyOriginValue("semaphore") != QVariant::Invalid) {
|
|
|
|
if (changed && this->getPropertyOriginValue("semaphore") != QVariant::Invalid) {
|
|
|
|
QTimer::singleShot(50, m_sigsCenter, [ = ]() {
|
|
|
|
QTimer::singleShot(50, m_sigsCenter, [ = ]() {
|
|
|
@ -134,11 +161,11 @@ void CUIConfig::setValue(QVariant value)
|
|
|
|
* @param key 属性名
|
|
|
|
* @param key 属性名
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
QString CUIConfig::getPropertyValue(QString key)
|
|
|
|
QString CUIConfig::getPropertyValue(QString key) {
|
|
|
|
{
|
|
|
|
if (property.contains(key)) {
|
|
|
|
if(property.contains(key)) {
|
|
|
|
|
|
|
|
return qvariant_cast<QString>(property[key]);
|
|
|
|
return qvariant_cast<QString>(property[key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -147,16 +174,15 @@ QString CUIConfig::getPropertyValue(QString key)
|
|
|
|
* @param key 属性名
|
|
|
|
* @param key 属性名
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
QVariant CUIConfig::getPropertyOriginValue(QString key)
|
|
|
|
QVariant CUIConfig::getPropertyOriginValue(QString key) {
|
|
|
|
{
|
|
|
|
if (property.contains(key)) {
|
|
|
|
if(property.contains(key)) {
|
|
|
|
|
|
|
|
return property[key];
|
|
|
|
return property[key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return QVariant::Invalid;
|
|
|
|
return QVariant::Invalid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<CUIConfig *> CUIConfig::getSub()
|
|
|
|
QVector<CUIConfig*> CUIConfig::getSub() {
|
|
|
|
{
|
|
|
|
|
|
|
|
return this->sub;
|
|
|
|
return this->sub;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -164,10 +190,10 @@ QVector<CUIConfig *> CUIConfig::getSub()
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief CUIConfig::setDefault 初始化属性
|
|
|
|
* @brief CUIConfig::setDefault 初始化属性
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void CUIConfig::setDefault()
|
|
|
|
void CUIConfig::setDefault() {
|
|
|
|
{
|
|
|
|
|
|
|
|
QString type = qvariant_cast<QString>(property["type"]);
|
|
|
|
QString type = qvariant_cast<QString>(property["type"]);
|
|
|
|
if(type == "LineEdit") {
|
|
|
|
|
|
|
|
|
|
|
|
if (type == "LineEdit") {
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("data_type", "string"); // 数据类型
|
|
|
|
setDefault("data_type", "string"); // 数据类型
|
|
|
|
setDefault("initial_value_", ""); // 初始值
|
|
|
|
setDefault("initial_value_", ""); // 初始值
|
|
|
@ -177,16 +203,20 @@ void CUIConfig::setDefault()
|
|
|
|
setDefault("inclusive_min", true); // 左范围是否包括
|
|
|
|
setDefault("inclusive_min", true); // 左范围是否包括
|
|
|
|
setDefault("inclusive_max", true); // 右范围是否包括
|
|
|
|
setDefault("inclusive_max", true); // 右范围是否包括
|
|
|
|
setDefault("required_", true); // 是否为必选
|
|
|
|
setDefault("required_", true); // 是否为必选
|
|
|
|
} else if(type == "Widget") {
|
|
|
|
|
|
|
|
|
|
|
|
} else if (type == "Widget") {
|
|
|
|
setDefault("layout", "QVBoxLayout");
|
|
|
|
setDefault("layout", "QVBoxLayout");
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("name", "");
|
|
|
|
} else if(type == "GroupBox") {
|
|
|
|
|
|
|
|
|
|
|
|
} else if (type == "GroupBox") {
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("layout", "QVBoxLayout");
|
|
|
|
setDefault("layout", "QVBoxLayout");
|
|
|
|
} else if(type == "TabWidget") {
|
|
|
|
|
|
|
|
} else if(type == "ComboBox") {
|
|
|
|
} else if (type == "TabWidget") {
|
|
|
|
|
|
|
|
} else if (type == "ComboBox") {
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("name", "");
|
|
|
|
} else if(type == "Item") {
|
|
|
|
|
|
|
|
|
|
|
|
} else if (type == "Item") {
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("name", "");
|
|
|
|
setDefault("data_type", "string");
|
|
|
|
setDefault("data_type", "string");
|
|
|
|
setDefault("data", "");
|
|
|
|
setDefault("data", "");
|
|
|
@ -199,9 +229,8 @@ void CUIConfig::setDefault()
|
|
|
|
* @param key
|
|
|
|
* @param key
|
|
|
|
* @param val
|
|
|
|
* @param val
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void CUIConfig::setDefault(QString key, QVariant val)
|
|
|
|
void CUIConfig::setDefault(QString key, QVariant val) {
|
|
|
|
{
|
|
|
|
if (!property.contains(key)) {
|
|
|
|
if(!property.contains(key)) {
|
|
|
|
|
|
|
|
property[key] = val;
|
|
|
|
property[key] = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|