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

148 lines
3.9 KiB
C++

#include "CUIPropertyWidget.h"
3 weeks ago
#include<CUIConfig.h>
#include<CUIContainerWidget.h>
#include<CUIContainerGroupBox.h>
#include<CUIComponentILineEdit.h>
#include<CUIContainerTabWidget.h>
#include<CUIComponentComboBox.h>
#include<CUIComponentPushButton.h>
#include<CUIComponentCheckBox.h>
#include<CUIComponentRadioButton.h>
#include<CUIComponentRadioGroup.h>
3 weeks ago
#include<QDebug>
#include<QVBoxLayout>
#include"CUIComponentMultiTableWidget.h"
#include"CUIComponentBaseWidget.h"
3 weeks ago
3 weeks ago
/**
* @brief CUIPropertyWidget::CUI
3 weeks ago
* @param conf
*/
CUIPropertyWidget::CUIPropertyWidget(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 CUIPropertyWidget::buildUI
3 weeks ago
*/
void CUIPropertyWidget::buildUI()
3 weeks ago
{
QString type = conf->getPropertyValue("type");
if(type == "") {
3 weeks ago
return;
}
if(type == "Widget") {
m_mainWidget = new CUIContainerWidget(conf, subCUI);
} else if(type == "GroupBox") {
m_mainWidget = new CUIContainerGroupBox(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 == "RadioComponent") {
m_mainWidget = new CUIComponentRadioGroup(conf, subCUI);
} else if(type == "MultiTableWidget") {
m_mainWidget = new CUIComponentMultiTableWidget(conf, subCUI);
} else {
m_mainWidget = new CUIComponentBaseWidget;
}
if (m_mainWidget) {
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
layout->addWidget(m_mainWidget);
this->setLayout(layout);
3 weeks ago
}
}
/**
* @brief CUIPropertyWidget::check
3 weeks ago
*/
void CUIPropertyWidget::check()
3 weeks ago
{
}
/**
* @brief CUIPropertyWidget::getUI
3 weeks ago
* @return QWidget,
*/
QWidget *CUIPropertyWidget::getUI()
3 weeks ago
{
QString type = conf->getPropertyValue("type");
if(type == "Item") {
return NULL;
3 weeks ago
}
return this;
3 weeks ago
}
/**
* @brief CUIPropertyWidget::getProperty
3 weeks ago
* @param key
* @return val
*/
QString CUIPropertyWidget::getProperty(QString s)
3 weeks ago
{
// return conf->property[s];
return conf->getPropertyValue(s);
3 weeks ago
}
/**
* @brief CUIPropertyWidget::autoArrangeWidgets
3 weeks ago
*/
void CUIPropertyWidget::autoArrangeWidgets()
3 weeks ago
{
qint32 labelMaxWidth = INT_MIN;
labelMaxWidth = getMaxLabelWidth();
setLabelWidth(labelMaxWidth);
}
/**
* @brief CUIPropertyWidget::getMaxLabelWidth
3 weeks ago
* @return
*/
qint32 CUIPropertyWidget::getMaxLabelWidth()
3 weeks ago
{
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 CUIPropertyWidget::setLabelWidth(qint32 width)
3 weeks ago
{
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);
}
}
}