Use the init-statement to declare a variable inside the if statement.

This commit is contained in:
Roman Telezhynskyi 2024-04-04 10:27:15 +03:00
parent f50aec80c3
commit b3e6365e92
10 changed files with 76 additions and 110 deletions

View File

@ -4612,8 +4612,7 @@ void TMainWindow::SetDimensionBases()
{ {
SCASSERT(control != nullptr) SCASSERT(control != nullptr)
const qint32 i = control->findData(value); if (const qint32 i = control->findData(value); i != -1)
if (i != -1)
{ {
control->setCurrentIndex(i); control->setCurrentIndex(i);
} }

View File

@ -379,8 +379,7 @@ auto DialogIncrements::GetCustomName() const -> QString
auto DialogIncrements::ClearIncrementName(const QString &name) -> QString auto DialogIncrements::ClearIncrementName(const QString &name) -> QString
{ {
QString clear = name; QString clear = name;
const auto index = clear.indexOf(CustomIncrSign); if (const auto index = clear.indexOf(CustomIncrSign); index == 0)
if (index == 0)
{ {
clear.remove(0, 1); clear.remove(0, 1);
} }
@ -1296,8 +1295,7 @@ void DialogIncrements::InitIncrementUnits(QComboBox *combo)
combo->addItem(units, QVariant(static_cast<int>(IncrUnits::Pattern))); combo->addItem(units, QVariant(static_cast<int>(IncrUnits::Pattern)));
combo->addItem(tr("Degrees"), QVariant(static_cast<int>(IncrUnits::Degrees))); combo->addItem(tr("Degrees"), QVariant(static_cast<int>(IncrUnits::Degrees)));
int const i = combo->findData(current); if (int const i = combo->findData(current); i != -1)
if (i != -1)
{ {
combo->setCurrentIndex(i); combo->setCurrentIndex(i);
} }
@ -1787,8 +1785,7 @@ void DialogIncrements::SaveIncrFormula()
QString const text = textEdit->toPlainText(); QString const text = textEdit->toPlainText();
QSharedPointer<VIncrement> const incr = m_data->GetVariable<VIncrement>(nameField->text()); QSharedPointer<VIncrement> const incr = m_data->GetVariable<VIncrement>(nameField->text());
QTableWidgetItem *formulaField = table->item(row, 2); if (QTableWidgetItem *formulaField = table->item(row, 2); formulaField->text() == text)
if (formulaField->text() == text)
{ {
QTableWidgetItem *result = table->item(row, 1); QTableWidgetItem *result = table->item(row, 1);
if (incr->IsSpecialUnits()) if (incr->IsSpecialUnits())
@ -2065,8 +2062,7 @@ void DialogIncrements::showEvent(QShowEvent *event)
} }
// do your init stuff here // do your init stuff here
const QSize sz = VAbstractApplication::VApp()->Settings()->GetIncrementsDialogSize(); if (const QSize sz = VAbstractApplication::VApp()->Settings()->GetIncrementsDialogSize(); not sz.isEmpty())
if (not sz.isEmpty())
{ {
resize(sz); resize(sz);
} }

View File

@ -457,8 +457,7 @@ void DialogLayoutSettings::FindTemplate()
if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize) if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize)
{ {
ui->comboBoxTemplates->blockSignals(true); ui->comboBoxTemplates->blockSignals(true);
const int index = ui->comboBoxTemplates->findData(i); if (const int index = ui->comboBoxTemplates->findData(i); index != -1)
if (index != -1)
{ {
ui->comboBoxTemplates->setCurrentIndex(index); ui->comboBoxTemplates->setCurrentIndex(index);
} }
@ -468,8 +467,7 @@ void DialogLayoutSettings::FindTemplate()
} }
ui->comboBoxTemplates->blockSignals(true); ui->comboBoxTemplates->blockSignals(true);
const int index = ui->comboBoxTemplates->findData(max); if (const int index = ui->comboBoxTemplates->findData(max); index != -1)
if (index != -1)
{ {
ui->comboBoxTemplates->setCurrentIndex(index); ui->comboBoxTemplates->setCurrentIndex(index);
} }
@ -573,8 +571,7 @@ void DialogLayoutSettings::showEvent(QShowEvent *event)
} }
// do your init stuff here // do your init stuff here
const QSize sz = VAbstractApplication::VApp()->Settings()->GetLayoutSettingsDialogSize(); if (const QSize sz = VAbstractApplication::VApp()->Settings()->GetLayoutSettingsDialogSize(); not sz.isEmpty())
if (not sz.isEmpty())
{ {
resize(sz); resize(sz);
} }
@ -689,8 +686,8 @@ void DialogLayoutSettings::DialogAccepted()
} }
else else
{ {
QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText()); if (QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
if (printer.isNull()) printer.isNull())
{ {
m_generator->SetPrinterFields(true, GetFields()); m_generator->SetPrinterFields(true, GetFields());
} }
@ -701,11 +698,10 @@ void DialogLayoutSettings::DialogAccepted()
if (fields.left() < minFields.left() || fields.right() < minFields.right() || if (fields.left() < minFields.left() || fields.right() < minFields.right() ||
fields.top() < minFields.top() || fields.bottom() < minFields.bottom()) fields.top() < minFields.top() || fields.bottom() < minFields.bottom())
{ {
QMessageBox::StandardButton answer; if (QMessageBox::StandardButton answer = QMessageBox::question(
answer = QMessageBox::question(this, tr("Wrong fields."), this, tr("Wrong fields."), tr("Margins go beyond printing. \n\nApply settings anyway?"),
tr("Margins go beyond printing. \n\nApply settings anyway?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
QMessageBox::Yes | QMessageBox::No, QMessageBox::No); answer == QMessageBox::No)
if (answer == QMessageBox::No)
{ {
SetMinMargins(fields, minFields); SetMinMargins(fields, minFields);
m_generator->SetPrinterFields(true, GetFields()); m_generator->SetPrinterFields(true, GetFields());
@ -764,8 +760,8 @@ void DialogLayoutSettings::RestoreDefaults()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::PrinterMargins() void DialogLayoutSettings::PrinterMargins()
{ {
QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText()); if (QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
if (not printer.isNull()) not printer.isNull())
{ {
SetFields(GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer)))); SetFields(GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer))));
} }
@ -958,8 +954,8 @@ auto DialogLayoutSettings::GetTemplateSize(const PaperSizeTemplate &tmpl, const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogLayoutSettings::MinPrinterFields() const -> QMarginsF auto DialogLayoutSettings::MinPrinterFields() const -> QMarginsF
{ {
QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText()); if (QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
if (not printer.isNull()) not printer.isNull())
{ {
return GetMinPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer))); return GetMinPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer)));
} }
@ -970,8 +966,8 @@ auto DialogLayoutSettings::MinPrinterFields() const -> QMarginsF
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogLayoutSettings::GetDefPrinterFields() const -> QMarginsF auto DialogLayoutSettings::GetDefPrinterFields() const -> QMarginsF
{ {
QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText()); if (QPrinterInfo const printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
if (not printer.isNull()) not printer.isNull())
{ {
return GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer))); return GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer)));
} }

View File

@ -101,9 +101,9 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *patt
ui->comboBoxLabelLanguage->addItem(QLocale(name).nativeLanguageName(), name); ui->comboBoxLabelLanguage->addItem(QLocale(name).nativeLanguageName(), name);
} }
int const index = if (int const index = ui->comboBoxLabelLanguage->findData(
ui->comboBoxLabelLanguage->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetLabelLanguage()); VAbstractValApplication::VApp()->ValentinaSettings()->GetLabelLanguage());
if (index != -1) index != -1)
{ {
ui->comboBoxLabelLanguage->setCurrentIndex(index); ui->comboBoxLabelLanguage->setCurrentIndex(index);
} }
@ -288,10 +288,10 @@ void DialogPatternProperties::SaveDescription()
m_doc->SetPassmarkWidthVariable(ui->lineEditPassmarkWidth->text()); m_doc->SetPassmarkWidthVariable(ui->lineEditPassmarkWidth->text());
m_doc->SetDefaultPieceLabelPath(ui->lineEditPieceLabelPath->text()); m_doc->SetDefaultPieceLabelPath(ui->lineEditPieceLabelPath->text());
const bool lengthChanged = m_oldPassmarkLength != ui->lineEditPassmarkLength->text();
const bool widthChanged = m_oldPassmarkWidth != ui->lineEditPassmarkWidth->text(); const bool widthChanged = m_oldPassmarkWidth != ui->lineEditPassmarkWidth->text();
if (lengthChanged || widthChanged) if (const bool lengthChanged = m_oldPassmarkLength != ui->lineEditPassmarkLength->text();
lengthChanged || widthChanged)
{ {
emit UpddatePieces(); emit UpddatePieces();

View File

@ -608,8 +608,8 @@ void VWidgetBackgroundImages::ResetImageTransformationSettings()
} }
else if (ui->tabWidgetImageTransformation->indexOf(ui->tabScale) == index) else if (ui->tabWidgetImageTransformation->indexOf(ui->tabScale) == index)
{ // scale { // scale
int const unitIndex = ui->comboBoxScaleUnit->findData(QVariant(static_cast<int>(ScaleUnit::Percent))); if (int const unitIndex = ui->comboBoxScaleUnit->findData(QVariant(static_cast<int>(ScaleUnit::Percent)));
if (unitIndex != -1) unitIndex != -1)
{ {
ui->comboBoxScaleUnit->setCurrentIndex(unitIndex); ui->comboBoxScaleUnit->setCurrentIndex(unitIndex);
} }
@ -725,8 +725,7 @@ void VWidgetBackgroundImages::ImagePositionChanged(const QUuid &id)
QTableWidgetItem *item = ui->tableWidget->item(row, 0); QTableWidgetItem *item = ui->tableWidget->item(row, 0);
if (item != nullptr) if (item != nullptr)
{ {
QUuid const curentId = item->data(Qt::UserRole).toUuid(); if (QUuid const curentId = item->data(Qt::UserRole).toUuid(); curentId != id)
if (curentId != id)
{ {
return; return;
} }
@ -972,8 +971,7 @@ auto VWidgetBackgroundImages::ImageWidth() const -> qreal
{ {
qreal width = 0; qreal width = 0;
int const row = ui->tableWidget->currentRow(); if (int const row = ui->tableWidget->currentRow(); row != -1)
if (row != -1)
{ {
QTableWidgetItem *item = ui->tableWidget->item(row, 0); QTableWidgetItem *item = ui->tableWidget->item(row, 0);
if (item != nullptr) if (item != nullptr)
@ -992,8 +990,7 @@ auto VWidgetBackgroundImages::ImageHeight() const -> qreal
{ {
qreal height = 0; qreal height = 0;
int const row = ui->tableWidget->currentRow(); if (int const row = ui->tableWidget->currentRow(); row != -1)
if (row != -1)
{ {
QTableWidgetItem *item = ui->tableWidget->item(row, 0); QTableWidgetItem *item = ui->tableWidget->item(row, 0);
if (item != nullptr) if (item != nullptr)

View File

@ -305,8 +305,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
QAction *actionDeletePiece = nullptr; QAction *actionDeletePiece = nullptr;
VToolSeamAllowance *toolPiece = nullptr; VToolSeamAllowance *toolPiece = nullptr;
QTableWidgetItem *selectedItem = ui->tableWidget->itemAt(pos); if (QTableWidgetItem *selectedItem = ui->tableWidget->itemAt(pos); selectedItem)
if (selectedItem)
{ {
QTableWidgetItem *item = ui->tableWidget->item(selectedItem->row(), PieceColumn::InLayout); QTableWidgetItem *item = ui->tableWidget->item(selectedItem->row(), PieceColumn::InLayout);
const quint32 id = item->data(Qt::UserRole).toUInt(); const quint32 id = item->data(Qt::UserRole).toUInt();

View File

@ -104,8 +104,7 @@ void VWidgetGroups::SetMultipleGroupsVisibility(const QVector<vidtype> &groups,
continue; continue;
} }
QTableWidgetItem *item = ui->tableWidget->item(row, 0); if (QTableWidgetItem *item = ui->tableWidget->item(row, 0); item)
if (item)
{ {
const QString resource = QStringLiteral("icon"); const QString resource = QStringLiteral("icon");
item->setIcon(i.value() item->setIcon(i.value()
@ -134,8 +133,8 @@ auto VWidgetGroups::FilterGroups(const QMap<quint32, VGroupData> &groups) -> QMa
while (i != groups.constEnd()) while (i != groups.constEnd())
{ {
const VGroupData &data = i.value(); const VGroupData &data = i.value();
QSet<QString> const groupCategories = ConvertToSet<QString>(data.tags); if (QSet<QString> const groupCategories = ConvertToSet<QString>(data.tags);
if (filterCategories.intersects(groupCategories)) filterCategories.intersects(groupCategories))
{ {
filtered.insert(i.key(), data); filtered.insert(i.key(), data);
} }

View File

@ -310,8 +310,7 @@ void WarningNotUniquePieceName(const QHash<quint32, VPiece> *allDetails)
while (i != allDetails->constEnd()) while (i != allDetails->constEnd())
{ {
const QString pieceName = i.value().GetName(); if (const QString pieceName = i.value().GetName(); not uniqueNames.contains(pieceName))
if (not uniqueNames.contains(pieceName))
{ {
uniqueNames.insert(pieceName); uniqueNames.insert(pieceName);
} }
@ -419,11 +418,11 @@ MainWindow::MainWindow(QWidget *parent)
asking = true; asking = true;
m_mChangesAsked = true; m_mChangesAsked = true;
m_measurementsSyncTimer->stop(); m_measurementsSyncTimer->stop();
const auto answer = QMessageBox::question( if (const auto answer = QMessageBox::question(
this, tr("Measurements"), this, tr("Measurements"),
tr("Measurements were changed. Do you want to sync measurements now?"), tr("Measurements were changed. Do you want to sync measurements now?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::Yes) answer == QMessageBox::Yes)
{ {
SyncMeasurements(); SyncMeasurements();
} }
@ -564,8 +563,7 @@ void MainWindow::AddPP(const QString &PPName)
SetEnableTool(true); SetEnableTool(true);
SetEnableWidgets(true); SetEnableWidgets(true);
const qint32 index = m_comboBoxDraws->findText(PPName); if (const qint32 index = m_comboBoxDraws->findText(PPName); index != -1)
if (index != -1)
{ // -1 for not found { // -1 for not found
m_comboBoxDraws->setCurrentIndex(index); m_comboBoxDraws->setCurrentIndex(index);
} }
@ -836,8 +834,8 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
emit EnableItemMove(false); emit EnableItemMove(false);
m_currentTool = m_lastUsedTool = t; m_currentTool = m_lastUsedTool = t;
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); if (VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
if (settings->GetPointerMode() == VToolPointerMode::ToolIcon) settings->GetPointerMode() == VToolPointerMode::ToolIcon)
{ {
const QString resource = QStringLiteral("toolcursor"); const QString resource = QStringLiteral("toolcursor");
auto cursorResource = VTheme::GetResourceName(resource, cursor); auto cursorResource = VTheme::GetResourceName(resource, cursor);
@ -2203,8 +2201,7 @@ void MainWindow::ShowMeasurements()
void MainWindow::MeasurementsChanged(const QString &path) void MainWindow::MeasurementsChanged(const QString &path)
{ {
m_mChanges = false; m_mChanges = false;
QFileInfo const checkFile(path); if (QFileInfo const checkFile(path); checkFile.exists())
if (checkFile.exists())
{ {
m_mChanges = true; m_mChanges = true;
m_mChangesAsked = false; m_mChangesAsked = false;
@ -2498,8 +2495,7 @@ void MainWindow::SetDimensionBases()
control->blockSignals(true); control->blockSignals(true);
const qint32 i = control->findData(value); if (const qint32 i = control->findData(value); i != -1)
if (i != -1)
{ {
control->setCurrentIndex(i); control->setCurrentIndex(i);
} }
@ -2684,8 +2680,7 @@ auto MainWindow::SavePatternAs(const QString &fileName) -> bool
return result; return result;
} }
const QString oldFilePath = VAbstractValApplication::VApp()->GetPatternPath(); if (const QString oldFilePath = VAbstractValApplication::VApp()->GetPatternPath(); not oldFilePath.isEmpty())
if (not oldFilePath.isEmpty())
{ {
qCDebug(vMainWindow, "Updating restore file list."); qCDebug(vMainWindow, "Updating restore file list.");
QStringList restoreFiles = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); QStringList restoreFiles = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList();
@ -2941,8 +2936,7 @@ void MainWindow::ToolBarDraws()
[this]() [this]()
{ {
QString draw = doc->GetNameActivPP(); QString draw = doc->GetNameActivPP();
bool const ok = PatternPieceName(draw); if (bool const ok = PatternPieceName(draw); not ok)
if (not ok)
{ {
return; return;
} }
@ -4251,9 +4245,8 @@ void MainWindow::on_actionCreateManualLayout_triggered()
DialogLayoutScale layoutScale(false, this); DialogLayoutScale layoutScale(false, this);
layoutScale.SetXScale(1); layoutScale.SetXScale(1);
layoutScale.SetYScale(1); layoutScale.SetYScale(1);
int const res = layoutScale.exec();
if (res == QDialog::Rejected) if (int const res = layoutScale.exec(); res == QDialog::Rejected)
{ {
return; return;
} }
@ -4378,8 +4371,7 @@ void MainWindow::ActionExportFontCorrections()
const QString dirPath = settings->GetPathFontCorrections(); const QString dirPath = settings->GetPathFontCorrections();
bool usedNotExistedDir = false; bool usedNotExistedDir = false;
QDir const directory(dirPath); if (QDir const directory(dirPath); not directory.exists())
if (not directory.exists())
{ {
usedNotExistedDir = directory.mkpath(QChar('.')); usedNotExistedDir = directory.mkpath(QChar('.'));
} }
@ -4503,8 +4495,7 @@ void MainWindow::FileClosedCorrect()
VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(restoreFiles); VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(restoreFiles);
// Remove autosave file // Remove autosave file
QFile autofile(VAbstractValApplication::VApp()->GetPatternPath() + *autosavePrefix); if (QFile autofile(VAbstractValApplication::VApp()->GetPatternPath() + *autosavePrefix); autofile.exists())
if (autofile.exists())
{ {
autofile.remove(); autofile.remove();
} }
@ -4752,8 +4743,7 @@ void MainWindow::on_actionNew_triggered()
qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName));
qCDebug(vMainWindow, "First PP"); qCDebug(vMainWindow, "First PP");
DialogNewPattern newPattern(pattern, patternPieceName, this); if (DialogNewPattern newPattern(pattern, patternPieceName, this); newPattern.exec() == QDialog::Accepted)
if (newPattern.exec() == QDialog::Accepted)
{ {
patternPieceName = newPattern.name(); patternPieceName = newPattern.name();
VAbstractValApplication::VApp()->SetPatternUnits(newPattern.PatternUnit()); VAbstractValApplication::VApp()->SetPatternUnits(newPattern.PatternUnit());
@ -4813,8 +4803,7 @@ void MainWindow::DimensionABaseChanged()
if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionA)) if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionA))
{ {
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.size() > 1)
if (dimensions.size() > 1)
{ {
MeasurementDimension_p dimension = dimensions.at(1); MeasurementDimension_p dimension = dimensions.at(1);
InitDimensionGradation(1, dimension, m_dimensionB); InitDimensionGradation(1, dimension, m_dimensionB);
@ -4839,9 +4828,7 @@ void MainWindow::DimensionBBaseChanged()
if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionB)) if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionB))
{ {
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.size() > 2)
if (dimensions.size() > 2)
{ {
const MeasurementDimension_p &dimension = dimensions.at(2); const MeasurementDimension_p &dimension = dimensions.at(2);
InitDimensionGradation(2, dimension, m_dimensionC); InitDimensionGradation(2, dimension, m_dimensionC);
@ -6635,8 +6622,8 @@ auto MainWindow::GetUnlokedRestoreFileList() -> QStringList
{ {
QStringList restoreFiles; QStringList restoreFiles;
// Take all files that need to be restored // Take all files that need to be restored
QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); if (QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList();
if (not files.empty()) not files.empty())
{ {
restoreFiles.reserve(files.size()); restoreFiles.reserve(files.size());
for (auto &file : files) for (auto &file : files)
@ -6779,8 +6766,7 @@ void MainWindow::ExportDrawAs(bool checked)
return; return;
} }
QFileInfo const f(fileName); if (QFileInfo const f(fileName); f.suffix().isEmpty() || f.suffix() != "svg"_L1)
if (f.suffix().isEmpty() || f.suffix() != "svg"_L1)
{ {
fileName += ".svg"_L1; fileName += ".svg"_L1;
} }
@ -6977,9 +6963,10 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri
const QString text = tr("The measurements file <br/><br/> <b>%1</b> <br/><br/> could not be found. Do you " const QString text = tr("The measurements file <br/><br/> <b>%1</b> <br/><br/> could not be found. Do you "
"want to update the file location?") "want to update the file location?")
.arg(path); .arg(path);
QMessageBox::StandardButton const res = QMessageBox::question(this, tr("Loading measurements file"), text,
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (QMessageBox::StandardButton const res = QMessageBox::question(
if (res == QMessageBox::No) this, tr("Loading measurements file"), text, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
res == QMessageBox::No)
{ {
return {}; return {};
} }
@ -6998,8 +6985,7 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri
{ {
QString dirPath; QString dirPath;
const QDir patternDir = QFileInfo(patternPath).absoluteDir(); const QDir patternDir = QFileInfo(patternPath).absoluteDir();
QString measurements = table.fileName(); if (QString measurements = table.fileName(); patternDir.exists(measurements))
if (patternDir.exists(measurements))
{ {
selectedName = measurements; selectedName = measurements;
dirPath = patternDir.absolutePath(); dirPath = patternDir.absolutePath();
@ -7209,8 +7195,7 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool
} }
listDetails = PrepareDetailsForLayout(details); listDetails = PrepareDetailsForLayout(details);
const bool exportOnlyDetails = expParams->IsExportOnlyDetails(); if (const bool exportOnlyDetails = expParams->IsExportOnlyDetails(); exportOnlyDetails)
if (exportOnlyDetails)
{ {
try try
{ {
@ -7314,8 +7299,7 @@ auto MainWindow::DoFMExport(const VCommandLinePtr &expParams) -> bool
return false; return false;
} }
QFileInfo const info(filePath); if (QFileInfo const info(filePath); info.isRelative())
if (info.isRelative())
{ {
filePath = QDir::currentPath() + '/'_L1 + filePath; filePath = QDir::currentPath() + '/'_L1 + filePath;
} }
@ -7496,9 +7480,7 @@ void MainWindow::ProcessCMD()
VAbstractValApplication::VApp()->SetUserMaterials(cmd->OptUserMaterials()); VAbstractValApplication::VApp()->SetUserMaterials(cmd->OptUserMaterials());
const bool loaded = LoadPattern(args.constFirst(), cmd->OptMeasurePath()); if (const bool loaded = LoadPattern(args.constFirst(), cmd->OptMeasurePath()); not loaded)
if (not loaded)
{ {
return; // process only one input file return; // process only one input file
} }

View File

@ -499,9 +499,8 @@ void MainWindowsNoGUI::ExportFMeasurementsToCSV()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails) void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails)
{ {
const LayoutExportFormats format = m_dialogSaveLayout->Format(); if (const LayoutExportFormats format = m_dialogSaveLayout->Format();
format == LayoutExportFormats::DXF_AAMA || format == LayoutExportFormats::DXF_ASTM ||
if (format == LayoutExportFormats::DXF_AAMA || format == LayoutExportFormats::DXF_ASTM ||
format == LayoutExportFormats::RLD || format == LayoutExportFormats::HPGL || format == LayoutExportFormats::RLD || format == LayoutExportFormats::HPGL ||
format == LayoutExportFormats::HPGL2) format == LayoutExportFormats::HPGL2)
{ {
@ -554,9 +553,9 @@ void MainWindowsNoGUI::ExportFlatLayout(const QList<QGraphicsScene *> &scenes, c
} }
VAbstractValApplication::VApp()->ValentinaSettings()->SetPathLayout(path); VAbstractValApplication::VApp()->ValentinaSettings()->SetPathLayout(path);
const LayoutExportFormats format = m_dialogSaveLayout->Format();
if (format == LayoutExportFormats::PDFTiled && m_dialogSaveLayout->Mode() == Draw::Layout) if (const LayoutExportFormats format = m_dialogSaveLayout->Format();
format == LayoutExportFormats::PDFTiled && m_dialogSaveLayout->Mode() == Draw::Layout)
{ {
const QString name = path + '/'_L1 + m_dialogSaveLayout->FileName() + '1'_L1; const QString name = path + '/'_L1 + m_dialogSaveLayout->FileName() + '1'_L1;
PdfTiledFile(name); PdfTiledFile(name);
@ -927,8 +926,8 @@ auto MainWindowsNoGUI::RecentFileList() const -> QStringList
auto MainWindowsNoGUI::ScenePreview(int i, QSize iconSize, PreviewQuatilty quality) const -> QIcon auto MainWindowsNoGUI::ScenePreview(int i, QSize iconSize, PreviewQuatilty quality) const -> QIcon
{ {
QImage image; QImage image;
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutSettings->LayoutPapers().at(i));
if (paper) if (auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutSettings->LayoutPapers().at(i)); paper)
{ {
if (quality == PreviewQuatilty::Fast) if (quality == PreviewQuatilty::Fast)
{ {

View File

@ -1070,7 +1070,7 @@ void DialogSeamAllowance::DetailUUIDChanged()
if (edit) if (edit)
{ {
static QRegularExpression const re("^$|^{[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-" static QRegularExpression const re("^$|^{[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-"
"[0-9a-fA-F]{12}}$"); "[0-9a-fA-F]{12}}$");
QRegularExpressionMatch const match = re.match(edit->text()); QRegularExpressionMatch const match = re.match(edit->text());
if (match.hasMatch()) if (match.hasMatch())
@ -5428,12 +5428,11 @@ void DialogSeamAllowance::EditPatternLabel()
{ {
if (m_patternLabelDataChanged && m_askSavePatternLabelData) if (m_patternLabelDataChanged && m_askSavePatternLabelData)
{ {
QMessageBox::StandardButton const answer = QMessageBox::question( if (QMessageBox::StandardButton const answer = QMessageBox::question(
this, tr("Save label data."), this, tr("Save label data."),
tr("Label data were changed. Do you want to save them before editing label template?"), tr("Label data were changed. Do you want to save them before editing label template?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
answer == QMessageBox::Yes)
if (answer == QMessageBox::Yes)
{ {
SavePatternLabelData(); SavePatternLabelData();
} }