You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/CFDStruct/CUIProperty/CUIConfig.cpp

144 lines
3.8 KiB
C++

3 weeks ago
#include "CUIConfig.h"
#include <QDebug>
/**
* @brief CUIConfig::CUIConfig
* @param property
*/
CUIConfig::CUIConfig(QMap<QString, QString> property)
{
this->property = property;
setDefault();
}
/**
* @brief CUIConfig::CUIConfig
*
* @details {key:val},{CUIConfig*}
*
* map :
*
* vector :
*
* {"type",""}:Widget, GroupBox, LineEdit, TabWidget, ComboBox, Item, PushButton
*
* @subsection LineEdit
* - "name" (string) : ,label
* - "data_type" (string) : ,"string" "int" "double"
* - "initial_value_" (string) :
* - "check_range_" ("true"/"false") :
* - "range_min_" (int/double) : ,string,
* - "range_max_" (int/double) : ,string,
* - "inclusive_" ("true"/"false") :
* - "required_" ("true"/"false") :
*
* @subsection Widget
* - "layout" (string):
* - "name" (string):,TabWidgetTab
*
* @subsection GroupBox
* - "name" :
* - "layout" :
* - sub :
*
* @subsection TabWidget
* - sub : ,"name"
*
* @subsection ComboBox
* - "name" : ,label
* - sub : ,"type""Item"
*
* @subsubsection Item
* - "name" :
* - "data_type" : "string"(default) "int" "double"
* - "data" :
*
* @subsection PushButton
* - "name" :
*
* @subsection CheckBox
* - "name" :
*
* @subsection ButtonBox
* groupboxbuttongroup
* - "name" :
* - sub :
*
*
* @param property
* @param sub
*/
CUIConfig::CUIConfig(QMap<QString, QString> property, QVector<CUIConfig *> sub)
{
this->property = property;
this->sub = sub;
setDefault();
}
/**
* @brief CUIConfig::printConfig
*/
void CUIConfig::printConfig()
{
qDebug()<<"{";
for(auto it = property.begin();it!=property.end();it++)
qDebug()<<it.key()<<' '<<it.value();
for(auto it : sub)
it->printConfig();
qDebug()<<"}";
}
/**
* @brief CUIConfig::setDefault
*/
void CUIConfig::setDefault()
{
if(property["type"] == "LineEdit"){
setDefault("name","");
setDefault("data_type","string");//数据类型
setDefault("initial_value_","");//初始值
setDefault("check_range_","false");//是否检查范围
setDefault("range_min_","");//最小值
setDefault("range_max_","");//最大值
setDefault("inclusive_","true");//范围是否包括
setDefault("required_","false");//是否为必选
}
if(property["type"] == "Widget"){
setDefault("layout","QVBoxLayout");
setDefault("name","");
}
if(property["type"] == "GroupBox"){
setDefault("name","");
setDefault("layout","QVBoxLayout");
}
if(property["type"] == "TabWidget"){
}
if(property["type"] == "ComboBox"){
setDefault("name","");
}
if(property["type"] == "Item"){
setDefault("name","");
setDefault("data_type","string");
setDefault("data","");
}
}
/**
* @brief CUIConfig::setDefault
* @param key
* @param val
*/
void CUIConfig::setDefault(QString key, QString val)
{
if(!property.contains(key))
property[key] = val;
}