mirror of
https://gitlab.com/smart-pattern/valentina.git
synced 2024-09-08 01:54:37 +02:00
Unit type for increments.
This commit is contained in:
parent
f005b78ecc
commit
74da6b8e1e
|
@ -14,6 +14,7 @@
|
||||||
- Fix updating dimension labels in Valentina app.
|
- Fix updating dimension labels in Valentina app.
|
||||||
- Fix menu on Mac OS X.
|
- Fix menu on Mac OS X.
|
||||||
- Add function's argument template with name in the Formula Wizard.
|
- Add function's argument template with name in the Formula Wizard.
|
||||||
|
- Unit type for increments.
|
||||||
|
|
||||||
# Valentina 0.7.51 April 18, 2022
|
# Valentina 0.7.51 April 18, 2022
|
||||||
- Z value change for a layout piece.
|
- Z value change for a layout piece.
|
||||||
|
|
|
@ -4400,7 +4400,7 @@ void TMainWindow::InitMeasurementUnits()
|
||||||
units = tr("Centimeters");
|
units = tr("Centimeters");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
units = "<Invalid>";
|
units = QStringLiteral("<Invalid>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,11 @@
|
||||||
|
|
||||||
#define DIALOG_MAX_FORMULA_HEIGHT 64
|
#define DIALOG_MAX_FORMULA_HEIGHT 64
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
enum class IncrUnits : qint8 {Pattern, Degrees};
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief DialogIncrements create dialog
|
* @brief DialogIncrements create dialog
|
||||||
|
@ -89,6 +94,20 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
qCDebug(vDialog, "Showing variables.");
|
qCDebug(vDialog, "Showing variables.");
|
||||||
ShowUnits();
|
ShowUnits();
|
||||||
|
|
||||||
|
InitIncrementUnits(ui->comboBoxIncrementUnits);
|
||||||
|
InitIncrementUnits(ui->comboBoxPreviewCalculationUnits);
|
||||||
|
|
||||||
|
ui->comboBoxIncrementUnits->blockSignals(true);
|
||||||
|
ui->comboBoxIncrementUnits->setCurrentIndex(-1);
|
||||||
|
ui->comboBoxIncrementUnits->blockSignals(true);
|
||||||
|
|
||||||
|
ui->comboBoxPreviewCalculationUnits->blockSignals(true);
|
||||||
|
ui->comboBoxPreviewCalculationUnits->setCurrentIndex(-1);
|
||||||
|
ui->comboBoxPreviewCalculationUnits->blockSignals(true);
|
||||||
|
|
||||||
|
connect(ui->comboBoxIncrementUnits, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&DialogIncrements::SaveIncrUnits);
|
||||||
|
|
||||||
FillIncrements();
|
FillIncrements();
|
||||||
FillPreviewCalculations();
|
FillPreviewCalculations();
|
||||||
FillLengthsLines();
|
FillLengthsLines();
|
||||||
|
@ -101,7 +120,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
|
connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
|
||||||
|
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
auto validator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|")+NameRegExp()), this);
|
auto *validator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|")+NameRegExp()), this);
|
||||||
ui->lineEditName->setValidator(validator);
|
ui->lineEditName->setValidator(validator);
|
||||||
ui->lineEditNamePC->setValidator(validator);
|
ui->lineEditNamePC->setValidator(validator);
|
||||||
|
|
||||||
|
@ -330,51 +349,57 @@ QString DialogIncrements::ClearIncrementName(const QString &name) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label)
|
auto DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label,
|
||||||
|
bool special) -> bool
|
||||||
{
|
{
|
||||||
const QString postfix =
|
QString postfix;
|
||||||
UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch)
|
if (special)
|
||||||
|
{
|
||||||
|
postfix = degreeSymbol;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch)
|
||||||
|
}
|
||||||
if (formula.isEmpty())
|
if (formula.isEmpty())
|
||||||
{
|
{
|
||||||
label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
|
label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
|
||||||
label->setToolTip(tr("Empty field"));
|
label->setToolTip(tr("Empty field"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
QString f;
|
||||||
|
// Replace line return character with spaces for calc if exist
|
||||||
|
if (fromUser)
|
||||||
{
|
{
|
||||||
QString f;
|
f = VAbstractApplication::VApp()->TrVars()
|
||||||
// Replace line return character with spaces for calc if exist
|
->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||||
if (fromUser)
|
|
||||||
{
|
|
||||||
f = VAbstractApplication::VApp()->TrVars()
|
|
||||||
->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f = formula;
|
|
||||||
}
|
|
||||||
QScopedPointer<Calculator> cal(new Calculator());
|
|
||||||
const qreal result = cal->EvalFormula(data->DataVariables(), f);
|
|
||||||
|
|
||||||
if (qIsInf(result) || qIsNaN(result))
|
|
||||||
{
|
|
||||||
label->setText(tr("Error") + " (" + postfix + ").");
|
|
||||||
label->setToolTip(tr("Invalid result. Value is infinite or NaN. Please, check your calculations."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix);
|
|
||||||
label->setToolTip(tr("Value"));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (qmu::QmuParserError &e)
|
else
|
||||||
{
|
{
|
||||||
label->setText(tr("Error") + " (" + postfix + "). " + tr("Parser error: %1").arg(e.GetMsg()));
|
f = formula;
|
||||||
label->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
}
|
||||||
|
QScopedPointer<Calculator> cal(new Calculator());
|
||||||
|
const qreal result = cal->EvalFormula(data->DataVariables(), f);
|
||||||
|
|
||||||
|
if (qIsInf(result) || qIsNaN(result))
|
||||||
|
{
|
||||||
|
label->setText(tr("Error") + " (" + postfix + ").");
|
||||||
|
label->setToolTip(tr("Invalid result. Value is infinite or NaN. Please, check your calculations."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix);
|
||||||
|
label->setToolTip(tr("Value"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (qmu::QmuParserError &e)
|
||||||
|
{
|
||||||
|
label->setText(tr("Error") + " (" + postfix + "). " + tr("Parser error: %1").arg(e.GetMsg()));
|
||||||
|
label->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,6 +524,10 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
||||||
ui->lineEditName->clear();
|
ui->lineEditName->clear();
|
||||||
ui->lineEditName->blockSignals(false);
|
ui->lineEditName->blockSignals(false);
|
||||||
|
|
||||||
|
ui->comboBoxIncrementUnits->blockSignals(true);
|
||||||
|
ui->comboBoxIncrementUnits->setCurrentIndex(-1);
|
||||||
|
ui->comboBoxIncrementUnits->blockSignals(false);
|
||||||
|
|
||||||
ui->plainTextEditDescription->blockSignals(true);
|
ui->plainTextEditDescription->blockSignals(true);
|
||||||
ui->plainTextEditDescription->clear();
|
ui->plainTextEditDescription->clear();
|
||||||
ui->plainTextEditDescription->blockSignals(false);
|
ui->plainTextEditDescription->blockSignals(false);
|
||||||
|
@ -517,6 +546,10 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
||||||
ui->lineEditNamePC->clear();
|
ui->lineEditNamePC->clear();
|
||||||
ui->lineEditNamePC->blockSignals(false);
|
ui->lineEditNamePC->blockSignals(false);
|
||||||
|
|
||||||
|
ui->comboBoxPreviewCalculationUnits->blockSignals(true);
|
||||||
|
ui->comboBoxPreviewCalculationUnits->setCurrentIndex(-1);
|
||||||
|
ui->comboBoxPreviewCalculationUnits->blockSignals(false);
|
||||||
|
|
||||||
ui->plainTextEditDescriptionPC->blockSignals(true);
|
ui->plainTextEditDescriptionPC->blockSignals(true);
|
||||||
ui->plainTextEditDescriptionPC->clear();
|
ui->plainTextEditDescriptionPC->clear();
|
||||||
ui->plainTextEditDescriptionPC->blockSignals(false);
|
ui->plainTextEditDescriptionPC->blockSignals(false);
|
||||||
|
@ -536,6 +569,7 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
||||||
ui->pushButtonGrow->setEnabled(enabled);
|
ui->pushButtonGrow->setEnabled(enabled);
|
||||||
ui->toolButtonExpr->setEnabled(enabled);
|
ui->toolButtonExpr->setEnabled(enabled);
|
||||||
ui->lineEditName->setEnabled(enabled);
|
ui->lineEditName->setEnabled(enabled);
|
||||||
|
ui->comboBoxIncrementUnits->setEnabled(enabled);
|
||||||
ui->plainTextEditDescription->setEnabled(enabled);
|
ui->plainTextEditDescription->setEnabled(enabled);
|
||||||
ui->plainTextEditFormula->setEnabled(enabled);
|
ui->plainTextEditFormula->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
@ -544,6 +578,7 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
||||||
ui->pushButtonGrowPC->setEnabled(enabled);
|
ui->pushButtonGrowPC->setEnabled(enabled);
|
||||||
ui->toolButtonExprPC->setEnabled(enabled);
|
ui->toolButtonExprPC->setEnabled(enabled);
|
||||||
ui->lineEditNamePC->setEnabled(enabled);
|
ui->lineEditNamePC->setEnabled(enabled);
|
||||||
|
ui->comboBoxPreviewCalculationUnits->setEnabled(enabled);
|
||||||
ui->plainTextEditDescriptionPC->setEnabled(enabled);
|
ui->plainTextEditDescriptionPC->setEnabled(enabled);
|
||||||
ui->plainTextEditFormulaPC->setEnabled(enabled);
|
ui->plainTextEditFormulaPC->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
@ -563,6 +598,8 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
||||||
ui->plainTextEditFormula->setVisible(not isSeparator);
|
ui->plainTextEditFormula->setVisible(not isSeparator);
|
||||||
ui->pushButtonGrow->setVisible(not isSeparator);
|
ui->pushButtonGrow->setVisible(not isSeparator);
|
||||||
ui->toolButtonExpr->setVisible(not isSeparator);
|
ui->toolButtonExpr->setVisible(not isSeparator);
|
||||||
|
ui->labelIncrementUnits->setVisible(not isSeparator);
|
||||||
|
ui->comboBoxIncrementUnits->setVisible(not isSeparator);
|
||||||
}
|
}
|
||||||
else if (table == ui->tableWidgetPC)
|
else if (table == ui->tableWidgetPC)
|
||||||
{
|
{
|
||||||
|
@ -572,6 +609,8 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
||||||
ui->plainTextEditFormulaPC->setVisible(not isSeparator);
|
ui->plainTextEditFormulaPC->setVisible(not isSeparator);
|
||||||
ui->pushButtonGrowPC->setVisible(not isSeparator);
|
ui->pushButtonGrowPC->setVisible(not isSeparator);
|
||||||
ui->toolButtonExprPC->setVisible(not isSeparator);
|
ui->toolButtonExprPC->setVisible(not isSeparator);
|
||||||
|
ui->labelPreviewCalculationUnits->setVisible(not isSeparator);
|
||||||
|
ui->comboBoxPreviewCalculationUnits->setVisible(not isSeparator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -652,6 +691,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
||||||
QPlainTextEdit *plainTextEditDescription = nullptr;
|
QPlainTextEdit *plainTextEditDescription = nullptr;
|
||||||
QPlainTextEdit *plainTextEditFormula = nullptr;
|
QPlainTextEdit *plainTextEditFormula = nullptr;
|
||||||
QLabel *labelCalculatedValue = nullptr;
|
QLabel *labelCalculatedValue = nullptr;
|
||||||
|
QComboBox *comboboxUnits = nullptr;
|
||||||
|
|
||||||
if (table == ui->tableWidgetIncrement)
|
if (table == ui->tableWidgetIncrement)
|
||||||
{
|
{
|
||||||
|
@ -659,6 +699,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
||||||
plainTextEditDescription = ui->plainTextEditDescription;
|
plainTextEditDescription = ui->plainTextEditDescription;
|
||||||
plainTextEditFormula = ui->plainTextEditFormula;
|
plainTextEditFormula = ui->plainTextEditFormula;
|
||||||
labelCalculatedValue = ui->labelCalculatedValue;
|
labelCalculatedValue = ui->labelCalculatedValue;
|
||||||
|
comboboxUnits = ui->comboBoxIncrementUnits;
|
||||||
}
|
}
|
||||||
else if (table == ui->tableWidgetPC)
|
else if (table == ui->tableWidgetPC)
|
||||||
{
|
{
|
||||||
|
@ -666,6 +707,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
||||||
plainTextEditDescription = ui->plainTextEditDescriptionPC;
|
plainTextEditDescription = ui->plainTextEditDescriptionPC;
|
||||||
plainTextEditFormula = ui->plainTextEditFormulaPC;
|
plainTextEditFormula = ui->plainTextEditFormulaPC;
|
||||||
labelCalculatedValue = ui->labelCalculatedValuePC;
|
labelCalculatedValue = ui->labelCalculatedValuePC;
|
||||||
|
comboboxUnits = ui->comboBoxPreviewCalculationUnits;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -695,11 +737,16 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
||||||
lineEditName->setText(ClearIncrementName(incr->GetName()));
|
lineEditName->setText(ClearIncrementName(incr->GetName()));
|
||||||
lineEditName->blockSignals(false);
|
lineEditName->blockSignals(false);
|
||||||
|
|
||||||
|
comboboxUnits->blockSignals(true);
|
||||||
|
comboboxUnits->setCurrentIndex(comboboxUnits->findData(
|
||||||
|
static_cast<int>(incr->IsSpecialUnits() ? IncrUnits::Degrees : IncrUnits::Pattern)));
|
||||||
|
comboboxUnits->blockSignals(false);
|
||||||
|
|
||||||
plainTextEditDescription->blockSignals(true);
|
plainTextEditDescription->blockSignals(true);
|
||||||
plainTextEditDescription->setPlainText(incr->GetDescription());
|
plainTextEditDescription->setPlainText(incr->GetDescription());
|
||||||
plainTextEditDescription->blockSignals(false);
|
plainTextEditDescription->blockSignals(false);
|
||||||
|
|
||||||
EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue);
|
EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue, incr->IsSpecialUnits());
|
||||||
plainTextEditFormula->blockSignals(true);
|
plainTextEditFormula->blockSignals(true);
|
||||||
|
|
||||||
QString formula =
|
QString formula =
|
||||||
|
@ -1124,6 +1171,49 @@ void DialogIncrements::UpdateSearchControlsTooltips()
|
||||||
UpdateToolTip(ui->toolButtonFindNextPC);
|
UpdateToolTip(ui->toolButtonFindNextPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogIncrements::InitIncrementUnits(QComboBox *combo)
|
||||||
|
{
|
||||||
|
SCASSERT(combo != nullptr)
|
||||||
|
|
||||||
|
combo->blockSignals(true);
|
||||||
|
|
||||||
|
int current = -1;
|
||||||
|
if (combo->currentIndex() != -1)
|
||||||
|
{
|
||||||
|
current = combo->currentData().toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString units;
|
||||||
|
switch (VAbstractValApplication::VApp()->patternUnits())
|
||||||
|
{
|
||||||
|
case Unit::Mm:
|
||||||
|
units = tr("Millimeters");
|
||||||
|
break;
|
||||||
|
case Unit::Inch:
|
||||||
|
units = tr("Inches");
|
||||||
|
break;
|
||||||
|
case Unit::Cm:
|
||||||
|
units = tr("Centimeters");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
units = QStringLiteral("<Invalid>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
combo->clear();
|
||||||
|
combo->addItem(units, QVariant(static_cast<int>(IncrUnits::Pattern)));
|
||||||
|
combo->addItem(tr("Degrees"), QVariant(static_cast<int>(IncrUnits::Degrees)));
|
||||||
|
|
||||||
|
int i = combo->findData(current);
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
combo->setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
combo->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief FullUpdateFromFile update information in tables form file
|
* @brief FullUpdateFromFile update information in tables form file
|
||||||
|
@ -1222,9 +1312,13 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
|
||||||
if (incr->GetType() == VarType::Increment)
|
if (incr->GetType() == VarType::Increment)
|
||||||
{
|
{
|
||||||
AddCell(table, incr->GetName(), currentRow, 0, Qt::AlignVCenter); // name
|
AddCell(table, incr->GetName(), currentRow, 0, Qt::AlignVCenter); // name
|
||||||
AddCell(table, VAbstractApplication::VApp()->
|
|
||||||
LocaleToString(*incr->GetValue()), currentRow, 1, Qt::AlignCenter,
|
QString calculatedValue = VAbstractApplication::VApp()->LocaleToString(*incr->GetValue());
|
||||||
incr->IsFormulaOk()); // calculated value
|
if (incr->IsSpecialUnits())
|
||||||
|
{
|
||||||
|
calculatedValue = calculatedValue + degreeSymbol;
|
||||||
|
}
|
||||||
|
AddCell(table, calculatedValue, currentRow, 1, Qt::AlignCenter, incr->IsFormulaOk()); // calculated value
|
||||||
|
|
||||||
QString formula =
|
QString formula =
|
||||||
VTranslateVars::TryFormulaToUser(incr->GetFormula(),
|
VTranslateVars::TryFormulaToUser(incr->GetFormula(),
|
||||||
|
@ -1270,7 +1364,7 @@ void DialogIncrements::AddSeparator()
|
||||||
*/
|
*/
|
||||||
void DialogIncrements::RemoveIncrement()
|
void DialogIncrements::RemoveIncrement()
|
||||||
{
|
{
|
||||||
QToolButton *button = qobject_cast<QToolButton *>(sender());
|
auto *button = qobject_cast<QToolButton *>(sender());
|
||||||
|
|
||||||
QTableWidget *table = nullptr;
|
QTableWidget *table = nullptr;
|
||||||
|
|
||||||
|
@ -1469,10 +1563,50 @@ void DialogIncrements::SaveIncrName(const QString &text)
|
||||||
table->blockSignals(false);
|
table->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogIncrements::SaveIncrUnits()
|
||||||
|
{
|
||||||
|
auto *combo = qobject_cast<QComboBox *>(sender());
|
||||||
|
|
||||||
|
QTableWidget *table = nullptr;
|
||||||
|
|
||||||
|
if (combo == ui->comboBoxIncrementUnits)
|
||||||
|
{
|
||||||
|
table = ui->tableWidgetIncrement;
|
||||||
|
}
|
||||||
|
else if (combo == ui->comboBoxPreviewCalculationUnits)
|
||||||
|
{
|
||||||
|
table = ui->tableWidgetPC;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int row = table->currentRow();
|
||||||
|
|
||||||
|
if (row == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QTableWidgetItem *nameField = table->item(row, 0);
|
||||||
|
|
||||||
|
const IncrUnits units = static_cast<IncrUnits>(combo->currentData().toInt());
|
||||||
|
doc->SetIncrementSpecialUnits(nameField->text(), units == IncrUnits::Degrees);
|
||||||
|
LocalUpdateTree();
|
||||||
|
|
||||||
|
table->blockSignals(true);
|
||||||
|
table->selectRow(row);
|
||||||
|
table->blockSignals(false);
|
||||||
|
|
||||||
|
ShowTableIncrementDetails(table);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogIncrements::SaveIncrDescription()
|
void DialogIncrements::SaveIncrDescription()
|
||||||
{
|
{
|
||||||
QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit *>(sender());
|
auto *textEdit = qobject_cast<QPlainTextEdit *>(sender());
|
||||||
|
|
||||||
QTableWidget *table = nullptr;
|
QTableWidget *table = nullptr;
|
||||||
|
|
||||||
|
@ -1541,32 +1675,46 @@ void DialogIncrements::SaveIncrFormula()
|
||||||
const QTableWidgetItem *nameField = table->item(row, 0);
|
const QTableWidgetItem *nameField = table->item(row, 0);
|
||||||
|
|
||||||
QString text = textEdit->toPlainText();
|
QString text = textEdit->toPlainText();
|
||||||
|
QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(nameField->text());
|
||||||
|
|
||||||
QTableWidgetItem *formulaField = table->item(row, 2);
|
QTableWidgetItem *formulaField = table->item(row, 2);
|
||||||
if (formulaField->text() == text)
|
if (formulaField->text() == text)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *result = table->item(row, 1);
|
QTableWidgetItem *result = table->item(row, 1);
|
||||||
//Show unit in dialog lable (cm, mm or inch)
|
if (incr->IsSpecialUnits())
|
||||||
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
{
|
||||||
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix);
|
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) + degreeSymbol);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Show unit in dialog lable (cm, mm or inch)
|
||||||
|
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
||||||
|
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
{
|
{
|
||||||
//Show unit in dialog lable (cm, mm or inch)
|
if (incr->IsSpecialUnits())
|
||||||
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
{
|
||||||
labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
|
labelCalculatedValue->setText(tr("Error") + " (" + degreeSymbol + "). " + tr("Empty field."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Show unit in dialog lable (cm, mm or inch)
|
||||||
|
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
||||||
|
labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(nameField->text());
|
|
||||||
if (incr->GetIncrementType() == IncrementType::Separator)
|
if (incr->GetIncrementType() == IncrementType::Separator)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not EvalIncrementFormula(text, true, incr->GetData(), labelCalculatedValue))
|
if (not EvalIncrementFormula(text, true, incr->GetData(), labelCalculatedValue, incr->IsSpecialUnits()))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ private slots:
|
||||||
void MoveUp();
|
void MoveUp();
|
||||||
void MoveDown();
|
void MoveDown();
|
||||||
void SaveIncrName(const QString &text);
|
void SaveIncrName(const QString &text);
|
||||||
|
void SaveIncrUnits();
|
||||||
void SaveIncrDescription();
|
void SaveIncrDescription();
|
||||||
void SaveIncrFormula();
|
void SaveIncrFormula();
|
||||||
void DeployFormula();
|
void DeployFormula();
|
||||||
|
@ -136,7 +137,7 @@ private:
|
||||||
QString GetCustomName() const;
|
QString GetCustomName() const;
|
||||||
QString ClearIncrementName(const QString &name) const;
|
QString ClearIncrementName(const QString &name) const;
|
||||||
|
|
||||||
bool EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label);
|
bool EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool special);
|
||||||
void Controls(QTableWidget *table);
|
void Controls(QTableWidget *table);
|
||||||
void EnableDetails(QTableWidget *table, bool enabled);
|
void EnableDetails(QTableWidget *table, bool enabled);
|
||||||
|
|
||||||
|
@ -158,6 +159,7 @@ private:
|
||||||
void SaveIncrementsSearchRequest();
|
void SaveIncrementsSearchRequest();
|
||||||
void SavePreviewCalculationsSearchRequest();
|
void SavePreviewCalculationsSearchRequest();
|
||||||
void UpdateSearchControlsTooltips();
|
void UpdateSearchControlsTooltips();
|
||||||
|
void InitIncrementUnits(QComboBox *combo);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGINCREMENTS_H
|
#endif // DIALOGINCREMENTS_H
|
||||||
|
|
|
@ -119,7 +119,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<italic>false</italic>
|
<italic>false</italic>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -152,7 +151,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@ -187,7 +185,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@ -219,7 +216,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@ -508,27 +504,34 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="labelIncrementUnits">
|
||||||
|
<property name="text">
|
||||||
|
<string>Units:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="labelCalculated">
|
<widget class="QLabel" name="labelCalculated">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Calculated value:</string>
|
<string>Calculated value:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QLabel" name="labelCalculatedValue">
|
<widget class="QLabel" name="labelCalculatedValue">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QLabel" name="labelFormula">
|
<widget class="QLabel" name="labelFormula">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Formula:</string>
|
<string>Formula:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="8" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayoutValue">
|
<layout class="QHBoxLayout" name="horizontalLayoutValue">
|
||||||
<item>
|
<item>
|
||||||
<widget class="VPlainTextEdit" name="plainTextEditFormula">
|
<widget class="VPlainTextEdit" name="plainTextEditFormula">
|
||||||
|
@ -624,14 +627,14 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="10" column="0">
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="label_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Description:</string>
|
<string>Description:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="VPlainTextEdit" name="plainTextEditDescription">
|
<widget class="VPlainTextEdit" name="plainTextEditDescription">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
@ -650,7 +653,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="13" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_3">
|
<spacer name="horizontalSpacer_3">
|
||||||
|
@ -677,6 +680,16 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBoxIncrementUnits">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -761,7 +774,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<italic>false</italic>
|
<italic>false</italic>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -794,7 +806,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@ -829,7 +840,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@ -861,7 +871,6 @@
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>14</pointsize>
|
<pointsize>14</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1149,28 +1158,28 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="labelCalculatedPC">
|
<widget class="QLabel" name="labelCalculatedPC">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Calculated value:</string>
|
<string>Calculated value:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QLabel" name="labelCalculatedValuePC">
|
<widget class="QLabel" name="labelCalculatedValuePC">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="labelFormulaPC">
|
<widget class="QLabel" name="labelFormulaPC">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Formula:</string>
|
<string>Formula:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="7" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayoutValue_2">
|
<layout class="QHBoxLayout" name="horizontalLayoutValue_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="VPlainTextEdit" name="plainTextEditFormulaPC">
|
<widget class="VPlainTextEdit" name="plainTextEditFormulaPC">
|
||||||
|
@ -1266,14 +1275,14 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Description:</string>
|
<string>Description:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="VPlainTextEdit" name="plainTextEditDescriptionPC">
|
<widget class="VPlainTextEdit" name="plainTextEditDescriptionPC">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
@ -1292,7 +1301,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="12" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_6">
|
<spacer name="horizontalSpacer_6">
|
||||||
|
@ -1319,6 +1328,20 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="labelPreviewCalculationUnits">
|
||||||
|
<property name="text">
|
||||||
|
<string>Units:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBoxPreviewCalculationUnits">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -1585,7 +1608,7 @@
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>VPlainTextEdit</class>
|
<class>VPlainTextEdit</class>
|
||||||
<extends>QPlainTextEdit</extends>
|
<extends>QPlainTextEdit</extends>
|
||||||
<header location="global">vplaintextedit.h</header>
|
<header>vplaintextedit.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
|
|
@ -4038,14 +4038,16 @@ void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &pars
|
||||||
strTypeIncrement));
|
strTypeIncrement));
|
||||||
const QString formula = (type == IncrementType::Separator) ?
|
const QString formula = (type == IncrementType::Separator) ?
|
||||||
QChar('0') : GetParametrString(domElement, AttrFormula, QChar('0'));
|
QChar('0') : GetParametrString(domElement, AttrFormula, QChar('0'));
|
||||||
|
const bool specialUnits = GetParametrBool(domElement, AttrSpecialUnits, falseStr);
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const qreal value = EvalFormula(data, formula, &ok);
|
const qreal value = EvalFormula(data, formula, &ok);
|
||||||
|
|
||||||
VIncrement *increment = new VIncrement(data, name, type);
|
auto *increment = new VIncrement(data, name, type);
|
||||||
increment->SetIndex(static_cast<quint32>(index++));
|
increment->SetIndex(static_cast<quint32>(index++));
|
||||||
increment->SetFormula(value, formula, ok);
|
increment->SetFormula(value, formula, ok);
|
||||||
increment->SetDescription(desc);
|
increment->SetDescription(desc);
|
||||||
|
increment->SetSpecialUnits(specialUnits);
|
||||||
increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations);
|
increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations);
|
||||||
data->AddUniqueVariable(increment);
|
data->AddUniqueVariable(increment);
|
||||||
}
|
}
|
||||||
|
@ -4150,6 +4152,21 @@ void VPattern::SetIncrementDescription(const QString &name, const QString &text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPattern::SetIncrementSpecialUnits(const QString &name, bool special)
|
||||||
|
{
|
||||||
|
QDomElement node = FindIncrement(name);
|
||||||
|
if (not node.isNull())
|
||||||
|
{
|
||||||
|
SetAttributeOrRemoveIf<bool>(node, AttrSpecialUnits, special, [](bool special) noexcept {return not special;});
|
||||||
|
emit patternChanged(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << tr("Can't find increment '%1'").arg(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPattern::ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName)
|
void VPattern::ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,6 +93,7 @@ public:
|
||||||
void SetIncrementName(const QString &name, const QString &text);
|
void SetIncrementName(const QString &name, const QString &text);
|
||||||
void SetIncrementFormula(const QString &name, const QString &text);
|
void SetIncrementFormula(const QString &name, const QString &text);
|
||||||
void SetIncrementDescription(const QString &name, const QString &text);
|
void SetIncrementDescription(const QString &name, const QString &text);
|
||||||
|
void SetIncrementSpecialUnits(const QString &name, bool special);
|
||||||
|
|
||||||
void ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName);
|
void ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName);
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
<file>schema/pattern/v0.8.12.xsd</file>
|
<file>schema/pattern/v0.8.12.xsd</file>
|
||||||
<file>schema/pattern/v0.8.13.xsd</file>
|
<file>schema/pattern/v0.8.13.xsd</file>
|
||||||
<file>schema/pattern/v0.9.0.xsd</file>
|
<file>schema/pattern/v0.9.0.xsd</file>
|
||||||
|
<file>schema/pattern/v0.9.1.xsd</file>
|
||||||
<file>schema/multisize_measurements/v0.3.0.xsd</file>
|
<file>schema/multisize_measurements/v0.3.0.xsd</file>
|
||||||
<file>schema/multisize_measurements/v0.4.0.xsd</file>
|
<file>schema/multisize_measurements/v0.4.0.xsd</file>
|
||||||
<file>schema/multisize_measurements/v0.4.1.xsd</file>
|
<file>schema/multisize_measurements/v0.4.1.xsd</file>
|
||||||
|
|
1166
src/libs/ifc/schema/pattern/v0.9.1.xsd
Normal file
1166
src/libs/ifc/schema/pattern/v0.9.1.xsd
Normal file
File diff suppressed because it is too large
Load diff
|
@ -150,8 +150,9 @@ const QString VAbstractPattern::AttrImageId = QStringLiteral("imageId"
|
||||||
|
|
||||||
const QString VAbstractPattern::AttrContentType = QStringLiteral("contentType");
|
const QString VAbstractPattern::AttrContentType = QStringLiteral("contentType");
|
||||||
|
|
||||||
const QString VAbstractPattern::AttrFormula = QStringLiteral("formula");
|
const QString VAbstractPattern::AttrFormula = QStringLiteral("formula");
|
||||||
const QString VAbstractPattern::AttrDescription = QStringLiteral("description");
|
const QString VAbstractPattern::AttrDescription = QStringLiteral("description");
|
||||||
|
const QString VAbstractPattern::AttrSpecialUnits = QStringLiteral("specialUnits");
|
||||||
|
|
||||||
const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc");
|
const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc");
|
||||||
const QString VAbstractPattern::NodeElArc = QStringLiteral("NodeElArc");
|
const QString VAbstractPattern::NodeElArc = QStringLiteral("NodeElArc");
|
||||||
|
|
|
@ -337,6 +337,7 @@ public:
|
||||||
|
|
||||||
static const QString AttrFormula;
|
static const QString AttrFormula;
|
||||||
static const QString AttrDescription;
|
static const QString AttrDescription;
|
||||||
|
static const QString AttrSpecialUnits;
|
||||||
|
|
||||||
static const QString NodeArc;
|
static const QString NodeArc;
|
||||||
static const QString NodeElArc;
|
static const QString NodeElArc;
|
||||||
|
|
|
@ -60,8 +60,8 @@ class QDomElement;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
|
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
|
||||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.0");
|
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.1");
|
||||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.0.xsd");
|
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.1.xsd");
|
||||||
|
|
||||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
|
@ -265,7 +265,8 @@ auto VPatternConverter::XSDSchema(unsigned ver) const -> QString
|
||||||
std::make_pair(FormatVersion(0, 8, 11), QStringLiteral("://schema/pattern/v0.8.11.xsd")),
|
std::make_pair(FormatVersion(0, 8, 11), QStringLiteral("://schema/pattern/v0.8.11.xsd")),
|
||||||
std::make_pair(FormatVersion(0, 8, 12), QStringLiteral("://schema/pattern/v0.8.12.xsd")),
|
std::make_pair(FormatVersion(0, 8, 12), QStringLiteral("://schema/pattern/v0.8.12.xsd")),
|
||||||
std::make_pair(FormatVersion(0, 8, 13), QStringLiteral("://schema/pattern/v0.8.13.xsd")),
|
std::make_pair(FormatVersion(0, 8, 13), QStringLiteral("://schema/pattern/v0.8.13.xsd")),
|
||||||
std::make_pair(FormatVersion(0, 9, 0), CurrentSchema)
|
std::make_pair(FormatVersion(0, 9, 0), QStringLiteral("://schema/pattern/v0.9.0.xsd")),
|
||||||
|
std::make_pair(FormatVersion(0, 9, 1), CurrentSchema)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (schemas.contains(ver))
|
if (schemas.contains(ver))
|
||||||
|
@ -367,9 +368,12 @@ void VPatternConverter::ApplyPatches()
|
||||||
case (FormatVersion(0, 8, 12)):
|
case (FormatVersion(0, 8, 12)):
|
||||||
case (FormatVersion(0, 8, 13)):
|
case (FormatVersion(0, 8, 13)):
|
||||||
ToV0_9_0();
|
ToV0_9_0();
|
||||||
ValidateXML(CurrentSchema);
|
|
||||||
Q_FALLTHROUGH();
|
Q_FALLTHROUGH();
|
||||||
case (FormatVersion(0, 9, 0)):
|
case (FormatVersion(0, 9, 0)):
|
||||||
|
ToV0_9_1();
|
||||||
|
ValidateXML(CurrentSchema);
|
||||||
|
Q_FALLTHROUGH();
|
||||||
|
case (FormatVersion(0, 9, 1)):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
InvalidVersion(m_ver);
|
InvalidVersion(m_ver);
|
||||||
|
@ -387,7 +391,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
|
||||||
bool VPatternConverter::IsReadOnly() const
|
bool VPatternConverter::IsReadOnly() const
|
||||||
{
|
{
|
||||||
// Check if attribute readOnly was not changed in file format
|
// Check if attribute readOnly was not changed in file format
|
||||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 0),
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 1),
|
||||||
"Check attribute readOnly.");
|
"Check attribute readOnly.");
|
||||||
|
|
||||||
// Possibly in future attribute readOnly will change position etc.
|
// Possibly in future attribute readOnly will change position etc.
|
||||||
|
@ -546,6 +550,17 @@ void VPatternConverter::ToV0_9_0()
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPatternConverter::ToV0_9_1()
|
||||||
|
{
|
||||||
|
// TODO. Delete if minimal supported version is 0.9.1
|
||||||
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1),
|
||||||
|
"Time to refactor the code.");
|
||||||
|
|
||||||
|
SetVersion(QStringLiteral("0.9.1"));
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPatternConverter::TagUnitToV0_2_0()
|
void VPatternConverter::TagUnitToV0_2_0()
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
static const QString PatternMaxVerStr;
|
static const QString PatternMaxVerStr;
|
||||||
static const QString CurrentSchema;
|
static const QString CurrentSchema;
|
||||||
static Q_DECL_CONSTEXPR const unsigned PatternMinVer = FormatVersion(0, 1, 4);
|
static Q_DECL_CONSTEXPR const unsigned PatternMinVer = FormatVersion(0, 1, 4);
|
||||||
static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 0);
|
static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 1);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Save() override;
|
void Save() override;
|
||||||
|
@ -85,6 +85,7 @@ private:
|
||||||
void ToV0_6_2();
|
void ToV0_6_2();
|
||||||
void ToV0_8_8();
|
void ToV0_8_8();
|
||||||
void ToV0_9_0();
|
void ToV0_9_0();
|
||||||
|
void ToV0_9_1();
|
||||||
|
|
||||||
void TagUnitToV0_2_0();
|
void TagUnitToV0_2_0();
|
||||||
void TagIncrementToV0_2_0();
|
void TagIncrementToV0_2_0();
|
||||||
|
|
|
@ -149,3 +149,15 @@ void VIncrement::SetPreviewCalculation(bool value)
|
||||||
{
|
{
|
||||||
d->previewCalculation = value;
|
d->previewCalculation = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VIncrement::IsSpecialUnits() const
|
||||||
|
{
|
||||||
|
return d->specialUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VIncrement::SetSpecialUnits(bool special)
|
||||||
|
{
|
||||||
|
d->specialUnits = special;
|
||||||
|
}
|
||||||
|
|
|
@ -71,6 +71,9 @@ public:
|
||||||
bool IsPreviewCalculation() const;
|
bool IsPreviewCalculation() const;
|
||||||
void SetPreviewCalculation(bool value);
|
void SetPreviewCalculation(bool value);
|
||||||
|
|
||||||
|
bool IsSpecialUnits() const;
|
||||||
|
void SetSpecialUnits(bool special);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VIncrementData> d;
|
QSharedDataPointer<VIncrementData> d;
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,8 @@ public:
|
||||||
formulaOk(incr.formulaOk),
|
formulaOk(incr.formulaOk),
|
||||||
previewCalculation(incr.previewCalculation),
|
previewCalculation(incr.previewCalculation),
|
||||||
data(incr.data),
|
data(incr.data),
|
||||||
incrType(incr.incrType)
|
incrType(incr.incrType),
|
||||||
|
specialUnits(incr.specialUnits)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~VIncrementData();
|
virtual ~VIncrementData();
|
||||||
|
@ -82,6 +83,7 @@ public:
|
||||||
bool previewCalculation{false};
|
bool previewCalculation{false};
|
||||||
QSharedPointer<VContainer> data;
|
QSharedPointer<VContainer> data;
|
||||||
IncrementType incrType{IncrementType::Increment};
|
IncrementType incrType{IncrementType::Increment};
|
||||||
|
bool specialUnits{false};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_ASSIGN(VIncrementData)
|
Q_DISABLE_ASSIGN(VIncrementData)
|
||||||
|
|
|
@ -197,17 +197,10 @@ void DialogEditWrongFormula::ValChanged(int row)
|
||||||
const QSharedPointer<VMeasurement> stable = m_data->GetVariable<VMeasurement>(name);
|
const QSharedPointer<VMeasurement> stable = m_data->GetVariable<VMeasurement>(name);
|
||||||
SetDescription(item->text(), *stable->GetValue(), stable->IsSpecialUnits(), stable->GetGuiText());
|
SetDescription(item->text(), *stable->GetValue(), stable->IsSpecialUnits(), stable->GetGuiText());
|
||||||
}
|
}
|
||||||
else if (ui->radioButtonIncrements->isChecked())
|
else if (ui->radioButtonIncrements->isChecked() || ui->radioButtonPC->isChecked())
|
||||||
{
|
{
|
||||||
const QSharedPointer<VIncrement> incr = m_data->GetVariable<VIncrement>(name);
|
const QSharedPointer<VIncrement> incr = m_data->GetVariable<VIncrement>(name);
|
||||||
const bool specialUnits = false;
|
SetDescription(item->text(), *incr->GetValue(), incr->IsSpecialUnits(), incr->GetDescription());
|
||||||
SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription());
|
|
||||||
}
|
|
||||||
else if (ui->radioButtonPC->isChecked())
|
|
||||||
{
|
|
||||||
const QSharedPointer<VIncrement> incr = m_data->GetVariable<VIncrement>(name);
|
|
||||||
const bool specialUnits = false;
|
|
||||||
SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription());
|
|
||||||
}
|
}
|
||||||
else if (ui->radioButtonLengthLine->isChecked())
|
else if (ui->radioButtonLengthLine->isChecked())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue