|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
#include "CUIComboBox.h"
|
|
|
|
|
#include "CUIComboBox.h"
|
|
|
|
|
|
|
|
|
|
#include<CUIConfig.h>
|
|
|
|
|
#include<QHBoxLayout>
|
|
|
|
@ -12,9 +12,9 @@
|
|
|
|
|
* @param conf 配置信息
|
|
|
|
|
* @param parent
|
|
|
|
|
*/
|
|
|
|
|
CUIComboBox::CUIComboBox(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent) : QWidget(parent)
|
|
|
|
|
CUIComboBox::CUIComboBox(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent) : CUIComponentBaseWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
this->conf = conf;
|
|
|
|
|
this->m_conf = conf;
|
|
|
|
|
initUI(subCUI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -24,7 +24,7 @@ CUIComboBox::CUIComboBox(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent
|
|
|
|
|
*/
|
|
|
|
|
qint32 CUIComboBox::getLabelWidth()
|
|
|
|
|
{
|
|
|
|
|
return label->minimumSizeHint().width();
|
|
|
|
|
return m_label->minimumSizeHint().width();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -33,7 +33,7 @@ qint32 CUIComboBox::getLabelWidth()
|
|
|
|
|
*/
|
|
|
|
|
void CUIComboBox::setLabelWidth(qint32 width)
|
|
|
|
|
{
|
|
|
|
|
label->setMinimumWidth(width);
|
|
|
|
|
m_label->setMinimumWidth(width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -43,18 +43,17 @@ void CUIComboBox::setLabelWidth(qint32 width)
|
|
|
|
|
*/
|
|
|
|
|
void CUIComboBox::initUI(QVector<CUI*> &subCUI)
|
|
|
|
|
{
|
|
|
|
|
label = new QLabel(conf->getPropertyValue("name"));
|
|
|
|
|
comboBox = new QComboBox;
|
|
|
|
|
layout = new QHBoxLayout;
|
|
|
|
|
this->setLayout(layout);
|
|
|
|
|
layout->addWidget(label);
|
|
|
|
|
layout->addWidget(comboBox);
|
|
|
|
|
layout->setStretchFactor(comboBox, 1);
|
|
|
|
|
|
|
|
|
|
m_label = new QLabel(m_conf->getPropertyValue("name"));
|
|
|
|
|
m_label->setFixedWidth(m_labelLength);
|
|
|
|
|
m_comboBox = new QComboBox;
|
|
|
|
|
m_layout = new QHBoxLayout;
|
|
|
|
|
this->setLayout(m_layout);
|
|
|
|
|
m_layout->addWidget(m_label);
|
|
|
|
|
m_layout->addWidget(m_comboBox);
|
|
|
|
|
((QHBoxLayout*)m_layout)->setStretchFactor(m_comboBox, 1);
|
|
|
|
|
iniComoboBox();
|
|
|
|
|
|
|
|
|
|
connect(comboBox, QOverload<int>::of(&QComboBox::activated), [ = ](int idx) {
|
|
|
|
|
this->conf->setValue(idx);
|
|
|
|
|
connect(m_comboBox, QOverload<int>::of(&QComboBox::activated), [ = ](int idx) {
|
|
|
|
|
this->m_conf->setValue(idx);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -63,26 +62,24 @@ void CUIComboBox::initUI(QVector<CUI*> &subCUI)
|
|
|
|
|
*/
|
|
|
|
|
void CUIComboBox::iniComoboBox()
|
|
|
|
|
{
|
|
|
|
|
for(auto cui : conf->getSub()) {
|
|
|
|
|
for(auto cui : m_conf->getSub()) {
|
|
|
|
|
QString type = cui->getPropertyValue("type");
|
|
|
|
|
if(type != "Item") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
CUI* temp = new CUI(nullptr, cui);
|
|
|
|
|
Items.push_back(temp);
|
|
|
|
|
m_items.push_back(temp);
|
|
|
|
|
if(temp->getProperty("data_type") == "int") {
|
|
|
|
|
comboBox->addItem(temp->getProperty("name"), temp->getProperty("data").toInt());
|
|
|
|
|
m_comboBox->addItem(temp->getProperty("name"), temp->getProperty("data").toInt());
|
|
|
|
|
} else if(temp->getProperty("data_type") == "double") {
|
|
|
|
|
comboBox->addItem(temp->getProperty("name"), temp->getProperty("data").toDouble());
|
|
|
|
|
m_comboBox->addItem(temp->getProperty("name"), temp->getProperty("data").toDouble());
|
|
|
|
|
} else {
|
|
|
|
|
comboBox->addItem(temp->getProperty("name"), temp->getProperty("data"));
|
|
|
|
|
m_comboBox->addItem(temp->getProperty("name"), temp->getProperty("data"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
QVariant vOrigin = conf->getPropertyOriginValue("value_origin");
|
|
|
|
|
QVariant vOrigin = m_conf->getPropertyOriginValue("value_origin");
|
|
|
|
|
int *ptr = qvariant_cast<int *>(vOrigin);
|
|
|
|
|
if(ptr!=nullptr)
|
|
|
|
|
{
|
|
|
|
|
comboBox->setCurrentIndex(*ptr);
|
|
|
|
|
if(ptr != nullptr) {
|
|
|
|
|
m_comboBox->setCurrentIndex(*ptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|