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:
co-authored by
elecpower
raphaelcoeffic
parent
7264b28e62
commit
9e86a3ea84
@@ -32,7 +32,7 @@ set(${PROJECT_NAME}_HDRS
|
||||
)
|
||||
|
||||
# AUTOMOC does not detect so manually process
|
||||
qt5_wrap_cpp(${PROJECT_NAME}_SRCS
|
||||
qt_wrap_cpp(${PROJECT_NAME}_SRCS
|
||||
${${PROJECT_NAME}_HDRS}
|
||||
)
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class AutoBitMappedComboBox : public QComboBox, public AutoWidget
|
||||
void setField(RawSwitch & field, GenericPanel * panel = nullptr);
|
||||
|
||||
void setAutoIndexes();
|
||||
void setModel(QAbstractItemModel * model);
|
||||
void setModel(QAbstractItemModel * model) override;
|
||||
|
||||
signals:
|
||||
void currentDataChanged(int value);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,15 @@
|
||||
#include "autowidget.h"
|
||||
#include "rawsource.h"
|
||||
#include "rawswitch.h"
|
||||
#include "curvedata.h"
|
||||
#include "boards.h"
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
/*
|
||||
NOTE: Q_OBJECT classes cannot be templated and since we use signals we have no choice but to
|
||||
take this approach or create a class per data type
|
||||
*/
|
||||
class AutoComboBox : public QComboBox, public AutoWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -48,9 +54,12 @@ class AutoComboBox : public QComboBox, public AutoWidget
|
||||
void setField(int & field, GenericPanel * panel = nullptr);
|
||||
void setField(RawSource & field, GenericPanel * panel = nullptr);
|
||||
void setField(RawSwitch & field, GenericPanel * panel = nullptr);
|
||||
void setField(CurveData::CurveType & field, GenericPanel * panel = nullptr);
|
||||
void setField(Board::FlexType & field, GenericPanel * panel = nullptr);
|
||||
void setField(Board::SwitchType & field, GenericPanel * panel = nullptr);
|
||||
|
||||
void setAutoIndexes();
|
||||
void setModel(QAbstractItemModel * model);
|
||||
void setModel(QAbstractItemModel * model) override;
|
||||
|
||||
signals:
|
||||
void currentDataChanged(int value);
|
||||
@@ -59,11 +68,15 @@ class AutoComboBox : public QComboBox, public AutoWidget
|
||||
void onCurrentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
int *m_field;
|
||||
int m_next;
|
||||
bool m_hasModel;
|
||||
int *m_field;
|
||||
RawSource *m_rawSource;
|
||||
RawSwitch *m_rawSwitch;
|
||||
CurveData::CurveType *m_curveType;
|
||||
Board::FlexType *m_flexType;
|
||||
Board::SwitchType *m_switchType;
|
||||
|
||||
void initField();
|
||||
void setFieldInit(GenericPanel * panel);
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "autohexspinbox.h"
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
AutoHexSpinBox::AutoHexSpinBox(QWidget * parent):
|
||||
QSpinBox(parent),
|
||||
@@ -56,7 +57,7 @@ void AutoHexSpinBox::setRange(const unsigned int min, const unsigned int max)
|
||||
|
||||
m_length = QString("%1").arg(max, 0, 16).size();
|
||||
|
||||
m_validator = new QRegExpValidator(QRegExp(QString("[0-9A-Fa-f]{1,%1}").arg(m_length)), this);
|
||||
m_validator = new QRegularExpressionValidator(QRegularExpression(QString("[0-9A-Fa-f]{1,%1}").arg(m_length)), this);
|
||||
}
|
||||
|
||||
void AutoHexSpinBox::updateValue()
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <QSpinBox>
|
||||
#include <QString>
|
||||
|
||||
class QRegExpValidator;
|
||||
class QRegularExpressionValidator;
|
||||
|
||||
class AutoHexSpinBox : public QSpinBox, public AutoWidget
|
||||
{
|
||||
@@ -57,6 +57,6 @@ class AutoHexSpinBox : public QSpinBox, public AutoWidget
|
||||
|
||||
private:
|
||||
unsigned int *m_field;
|
||||
QRegExpValidator *m_validator;
|
||||
QRegularExpressionValidator *m_validator;
|
||||
unsigned int m_length;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "autowidget.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
class AutoLineEdit: public QLineEdit, public AutoWidget
|
||||
{
|
||||
|
||||
@@ -144,7 +144,7 @@ CurveDialog::CurveDialog(QWidget * parent, ModelData & model, const int curveIdx
|
||||
int id = dialogFilterFactory->registerItemModel(new FilteredItemModel(CurveData::typeItemModel()),
|
||||
"Curve Type");
|
||||
ui->curveType->setModel(dialogFilterFactory->getItemModel(id));
|
||||
ui->curveType->setField((int &)curve.type);
|
||||
ui->curveType->setField(curve.type);
|
||||
connect(ui->curveType, &AutoComboBox::currentDataChanged, this, [&] () { on_curveTypeChanged(ui->curveType->currentIndex()) ;});
|
||||
|
||||
id = dialogFilterFactory->registerItemModel(new FilteredItemModel(CurveData::pointsItemModel()),
|
||||
|
||||
@@ -81,7 +81,7 @@ void CurveImageWidget::draw()
|
||||
|
||||
QImage image = curveImage->get();
|
||||
if (index < 0)
|
||||
image = image.mirrored(true, false);
|
||||
image = image.flipped(Qt::Horizontal);
|
||||
setPixmap(QPixmap::fromImage(image.scaled(height(), width())));
|
||||
|
||||
delete curveImage;
|
||||
|
||||
Reference in New Issue
Block a user