chore(cpn): upgrade to Ubuntu 22.04 and Qt 6.9.0 (#5986)

Co-authored-by: elecpower <elecpower@users.noreply.github.com>
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
This commit is contained in:
Neil Horne
2025-07-23 14:04:19 +02:00
committed by GitHub
co-authored by elecpower raphaelcoeffic
parent 7264b28e62
commit 9e86a3ea84
117 changed files with 4221 additions and 5155 deletions
+88 -62
View File
@@ -24,12 +24,10 @@
AutoComboBox::AutoComboBox(QWidget * parent):
QComboBox(parent),
AutoWidget(),
m_field(nullptr),
m_next(0),
m_hasModel(false),
m_rawSource(nullptr),
m_rawSwitch(nullptr)
m_hasModel(false)
{
initField();
connect(this, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AutoComboBox::onCurrentIndexChanged);
}
@@ -37,82 +35,104 @@ AutoComboBox::~AutoComboBox()
{
}
void AutoComboBox::initField()
{
m_field = nullptr;
m_rawSource = nullptr;
m_rawSwitch = nullptr;
m_curveType = nullptr;
m_flexType = nullptr;
m_switchType = nullptr;
}
void AutoComboBox::clear()
{
if (m_hasModel)
return;
setLock(true);
QComboBox::clear();
m_next = 0;
setLock(false);
if (!m_hasModel) {
setLock(true);
QComboBox::clear();
m_next = 0;
setLock(false);
}
}
void AutoComboBox::insertItems(int index, const QStringList & items)
{
if (m_hasModel)
return;
if (!m_hasModel) {
foreach(QString item, items)
addItem(item);
foreach(QString item, items) {
addItem(item);
}
}
void AutoComboBox::addItem(const QString & item)
{
if (m_hasModel)
return;
addItem(item, m_next++);
if (!m_hasModel)
addItem(item, m_next++);
}
void AutoComboBox::addItem(const QString & item, int value)
{
if (m_hasModel)
return;
setLock(true);
QComboBox::addItem(item, value);
setLock(false);
updateValue();
if (!m_hasModel) {
setLock(true);
QComboBox::addItem(item, value);
setLock(false);
updateValue();
}
}
void AutoComboBox::setField(unsigned int & field, GenericPanel * panel)
{
m_field = (int *)&field;
m_rawSource = nullptr;
m_rawSwitch = nullptr;
setFieldInit(panel);
m_field = (int *)&field;
updateValue();
}
void AutoComboBox::setField(int & field, GenericPanel * panel)
{
m_field = &field;
m_rawSource = nullptr;
m_rawSwitch = nullptr;
setFieldInit(panel);
m_field = &field;
updateValue();
}
void AutoComboBox::setField(RawSource & field, GenericPanel * panel)
{
m_rawSource = &field;
m_rawSwitch = nullptr;
m_field = nullptr;
setFieldInit(panel);
m_rawSource = &field;
updateValue();
}
void AutoComboBox::setField(RawSwitch & field, GenericPanel * panel)
{
m_rawSwitch = &field;
m_rawSource = nullptr;
m_field = nullptr;
setFieldInit(panel);
m_rawSwitch = &field;
updateValue();
}
void AutoComboBox::setField(CurveData::CurveType & field, GenericPanel * panel)
{
setFieldInit(panel);
m_curveType = &field;
updateValue();
}
void AutoComboBox::setField(Board::FlexType & field, GenericPanel * panel)
{
setFieldInit(panel);
m_flexType = &field;
updateValue();
}
void AutoComboBox::setField(Board::SwitchType & field, GenericPanel * panel)
{
setFieldInit(panel);
m_switchType = &field;
updateValue();
}
void AutoComboBox::setFieldInit(GenericPanel * panel)
{
initField();
setPanel(panel);
updateValue();
}
void AutoComboBox::setModel(QAbstractItemModel * model)
@@ -126,19 +146,16 @@ void AutoComboBox::setModel(QAbstractItemModel * model)
void AutoComboBox::setAutoIndexes()
{
if (m_hasModel)
return;
if (!m_hasModel) {
for (int i = 0; i < count(); ++i)
setItemData(i, i);
for (int i = 0; i < count(); ++i)
setItemData(i, i);
updateValue();
updateValue();
}
}
void AutoComboBox::updateValue()
{
if (!m_field && !m_rawSource && !m_rawSwitch)
return;
setLock(true);
if (m_field)
@@ -147,6 +164,12 @@ void AutoComboBox::updateValue()
setCurrentIndex(findData(m_rawSource->toValue()));
else if (m_rawSwitch)
setCurrentIndex(findData(m_rawSwitch->toValue()));
else if (m_curveType)
setCurrentIndex(findData(*m_curveType));
else if (m_flexType)
setCurrentIndex(findData(*m_flexType));
else if (m_switchType)
setCurrentIndex(findData(*m_switchType));
setLock(false);
}
@@ -158,21 +181,24 @@ void AutoComboBox::onCurrentIndexChanged(int index)
bool ok;
const int val = itemData(index).toInt(&ok);
if (!ok)
return;
if (m_field && *m_field != val) {
*m_field = val;
}
else if (m_rawSource && m_rawSource->toValue() != val) {
*m_rawSource = RawSource(val);
}
else if (m_rawSwitch && m_rawSwitch->toValue() != val) {
*m_rawSwitch = RawSwitch(val);
}
else
return;
if (ok) {
if (m_field && *m_field != val)
*m_field = val;
else if (m_rawSource && m_rawSource->toValue() != val)
*m_rawSource = RawSource(val);
else if (m_rawSwitch && m_rawSwitch->toValue() != val)
*m_rawSwitch = RawSwitch(val);
else if (m_curveType && *m_curveType != val)
*m_curveType = (CurveData::CurveType)val;
else if (m_flexType && *m_flexType != val)
*m_flexType = (Board::FlexType)val;
else if (m_switchType && *m_switchType != val)
*m_switchType = (Board::SwitchType)val;
else
return;
emit currentDataChanged(val);
dataChanged();
emit currentDataChanged(val);
dataChanged();
}
}