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/CUI.cpp

149 lines
3.6 KiB
C++

#include "CUI.h"
3 weeks ago
#include<CUIConfig.h>
#include<CUIWidget.h>
#include<CUIGroupBox.h>
#include<CUIComponentILineEdit.h>
#include<CUIContainerTabWidget.h>
#include<CUIComponentComboBox.h>
#include<CUIComponentPushButton.h>
#include<CUIComponentCheckBox.h>
#include<CUIComponentRadioButton.h>
#include<CUIRadioComponent.h>
3 weeks ago
#include<QDebug>
#include<CUIButtonBox.h>
#include<QVBoxLayout>
#include"CUIMultiTableWidget.h"
#include"CUIComponentBaseWidget.h"
3 weeks ago
3 weeks ago
/**
* @brief CUI::CUI
* @param conf
*/
CUI::CUI(QWidget *parent, CUIConfig *conf): QWidget(parent)
3 weeks ago
{
this->conf = conf;
buildUI();
if(conf->getPropertyValue("type") == "Widget") {
qDebug() << "new a Widget";
}
3 weeks ago
}
/**
* @brief CUI::buildUI
*/
void CUI::buildUI()
{
QString type = conf->getPropertyValue("type");
if(type == "") {
3 weeks ago
return;
}
if(type == "Widget") {
m_mainWidget = new CUIWidget(conf, subCUI);
} else if(type == "GroupBox") {
m_mainWidget = new CUIGroupBox(conf, subCUI);
} else if(type == "LineEdit") {
m_mainWidget = new CUIComponentLineEdit(conf, subCUI);
} else if(type == "TabWidget") {
m_mainWidget = new CUIContainerTabWidget(conf, subCUI);
} else if(type == "ComboBox") {
m_mainWidget = new CUIComponentComboBox(conf, subCUI);
} else if(type == "PushButton") {
m_mainWidget = new CUIComponentPushButton(conf, subCUI);
} else if(type == "CheckBox") {
m_mainWidget = new CUIComponentCheckBox(conf, subCUI);
} else if(type == "RadioButton") {
m_mainWidget = new CUIComponentRadioButton(conf, subCUI);
} else if(type == "ButtonBox") {
m_mainWidget = new CUIButtonBox(conf, subCUI);
} else if(type == "RadioComponent") {
m_mainWidget = new CUIRadioComponent(conf, subCUI);
} else if(type == "MultiTableWidget") {
m_mainWidget = new CUIMultiTableWidget(conf, subCUI);
}
if (m_mainWidget) {
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
layout->addWidget(m_mainWidget);
this->setLayout(layout);
3 weeks ago
}
}
/**
* @brief CUI::check
*/
void CUI::check()
{
}
/**
* @brief CUI::getUI
* @return QWidget,
*/
QWidget *CUI::getUI()
{
QString type = conf->getPropertyValue("type");
if(type == "Item") {
return NULL;
3 weeks ago
}
return this;
3 weeks ago
}
/**
* @brief CUI::getProperty
* @param key
* @return val
*/
QString CUI::getProperty(QString s)
{
// return conf->property[s];
return conf->getPropertyValue(s);
3 weeks ago
}
/**
* @brief CUI::autoArrangeWidgets
*/
void CUI::autoArrangeWidgets()
{
qint32 labelMaxWidth = INT_MIN;
labelMaxWidth = getMaxLabelWidth();
setLabelWidth(labelMaxWidth);
}
/**
* @brief CUI::getMaxLabelWidth
* @return
*/
qint32 CUI::getMaxLabelWidth()
{
qint32 res = INT_MIN;
QString type = conf->getPropertyValue("type");
if(type == "LineEdit") {
res = m_mainWidget->getLabelWidth();
} else if(type == "ComboBox") {
res = m_mainWidget->getLabelWidth();
} else {
for(auto &ui : subCUI) {
res = qMax(res, ui->getMaxLabelWidth());
3 weeks ago
}
}
return res;
}
void CUI::setLabelWidth(qint32 width)
{
QString type = conf->getPropertyValue("type");
if(type == "LineEdit") {
m_mainWidget->setLabelWidth(width);
} else if(type == "ComboBox") {
m_mainWidget->setLabelWidth(width);
} else {
for(auto &ui : subCUI) {
3 weeks ago
ui->setLabelWidth(width);
}
}
}