Refactoring.
Use the init-statement to declare a variable inside the if/switch statement.
This commit is contained in:
parent
9ee4cf208b
commit
94dc3bddd5
|
@ -141,8 +141,7 @@ auto VPCarrouselPiece::CreatePieceIcon(const QSize &size, bool isDragIcon) const
|
|||
: style.CarrouselPieceForegroundColor()));
|
||||
|
||||
bool togetherWithNotches = false;
|
||||
VPLayoutPtr const pieceLayout = piece->Layout();
|
||||
if (not pieceLayout.isNull())
|
||||
if (VPLayoutPtr const pieceLayout = piece->Layout(); not pieceLayout.isNull())
|
||||
{
|
||||
togetherWithNotches = pieceLayout->LayoutSettings().IsBoundaryTogetherWithNotches();
|
||||
}
|
||||
|
|
|
@ -62,8 +62,7 @@ PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *
|
|||
|
||||
// Theme
|
||||
SetThemeModeComboBox();
|
||||
int const index = ui->comboBoxThemeMode->findData(static_cast<int>(settings->GetThemeMode()));
|
||||
if (index != -1)
|
||||
if (int const index = ui->comboBoxThemeMode->findData(static_cast<int>(settings->GetThemeMode())); index != -1)
|
||||
{
|
||||
ui->comboBoxThemeMode->setCurrentIndex(index);
|
||||
}
|
||||
|
@ -145,8 +144,8 @@ auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList
|
|||
|
||||
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
|
||||
|
||||
auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt());
|
||||
if (settings->GetThemeMode() != themeMode)
|
||||
if (auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt());
|
||||
settings->GetThemeMode() != themeMode)
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
|
|
|
@ -694,8 +694,7 @@ void PuzzlePreferencesLayoutPage::FindTemplate(QComboBox *box, qreal width, qrea
|
|||
VAbstractLayoutDialog::RoundTemplateSize(height, width, paperUnit) == tmplSize)
|
||||
{
|
||||
box->blockSignals(true);
|
||||
const int index = box->findData(i);
|
||||
if (index != -1)
|
||||
if (const int index = box->findData(i); index != -1)
|
||||
{
|
||||
box->setCurrentIndex(index);
|
||||
}
|
||||
|
@ -705,8 +704,7 @@ void PuzzlePreferencesLayoutPage::FindTemplate(QComboBox *box, qreal width, qrea
|
|||
}
|
||||
|
||||
box->blockSignals(true);
|
||||
const int index = box->findData(max);
|
||||
if (index != -1)
|
||||
if (const int index = box->findData(max); index != -1)
|
||||
{
|
||||
box->setCurrentIndex(index);
|
||||
}
|
||||
|
|
|
@ -128,8 +128,7 @@ void PuzzlePreferencesPathPage::EditPath()
|
|||
}
|
||||
|
||||
bool usedNotExistedDir = false;
|
||||
QDir const directory(path);
|
||||
if (not directory.exists())
|
||||
if (QDir const directory(path); not directory.exists())
|
||||
{
|
||||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
|
|
@ -93,8 +93,7 @@ void DialogPuzzlePreferences::showEvent(QShowEvent *event)
|
|||
}
|
||||
// do your init stuff here
|
||||
|
||||
QSize const sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize();
|
||||
if (not sz.isEmpty())
|
||||
if (QSize const sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize(); not sz.isEmpty())
|
||||
{
|
||||
resize(sz);
|
||||
}
|
||||
|
|
|
@ -468,11 +468,11 @@ void DialogSaveManualLayout::Save()
|
|||
|
||||
if (QFile::exists(name))
|
||||
{
|
||||
QMessageBox::StandardButton const res = QMessageBox::question(
|
||||
this, tr("Name conflict"),
|
||||
tr("Folder already contain file with name %1. Rewrite all conflict file names?").arg(name),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (res == QMessageBox::No)
|
||||
if (QMessageBox::StandardButton const res = QMessageBox::question(
|
||||
this, tr("Name conflict"),
|
||||
tr("Folder already contain file with name %1. Rewrite all conflict file names?").arg(name),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
res == QMessageBox::No)
|
||||
{
|
||||
reject();
|
||||
return;
|
||||
|
@ -591,8 +591,7 @@ void DialogSaveManualLayout::ShowExample()
|
|||
auto DialogSaveManualLayout::SupportPSTest() -> bool
|
||||
{
|
||||
static bool havePdf = false;
|
||||
static bool tested = false;
|
||||
if (!tested)
|
||||
if (static bool tested = false; !tested)
|
||||
{
|
||||
havePdf = VLayoutExporter::SupportPDFConversion();
|
||||
tested = true;
|
||||
|
|
|
@ -303,10 +303,9 @@ auto VPLayout::GetSheets() const -> QList<VPSheetPtr>
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPLayout::GetSheet(const QUuid &uuid) -> VPSheetPtr
|
||||
{
|
||||
auto sheet = std::find_if(m_sheets.begin(), m_sheets.end(),
|
||||
[uuid](const VPSheetPtr &sheet) { return sheet->Uuid() == uuid; });
|
||||
|
||||
if (sheet != m_sheets.end())
|
||||
if (auto sheet = std::find_if(m_sheets.begin(), m_sheets.end(),
|
||||
[uuid](const VPSheetPtr &sheet) { return sheet->Uuid() == uuid; });
|
||||
sheet != m_sheets.end())
|
||||
{
|
||||
return *sheet;
|
||||
}
|
||||
|
|
|
@ -334,14 +334,12 @@ void VPPiece::FlipHorizontally()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPPiece::StickyPosition(qreal &dx, qreal &dy) const -> bool
|
||||
{
|
||||
VPLayoutPtr const layout = Layout();
|
||||
if (layout.isNull() || not layout->LayoutSettings().GetStickyEdges())
|
||||
if (VPLayoutPtr const layout = Layout(); layout.isNull() || not layout->LayoutSettings().GetStickyEdges())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
VPSheetPtr const sheet = Sheet();
|
||||
if (sheet.isNull())
|
||||
if (VPSheetPtr const sheet = Sheet(); sheet.isNull())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -486,11 +484,10 @@ auto VPPiece::StickySheet(VStickyDistance &match) const -> bool
|
|||
}
|
||||
|
||||
const qreal stickyDistance = maxStickyDistance;
|
||||
QRectF const stickyZone =
|
||||
QRectF(boundingRect.topLeft().x() - stickyDistance, boundingRect.topLeft().y() - stickyDistance,
|
||||
boundingRect.width() + stickyDistance * 2, boundingRect.height() + stickyDistance * 2);
|
||||
|
||||
if (!stickyZone.intersects(sheetRect))
|
||||
if (QRectF const stickyZone =
|
||||
QRectF(boundingRect.topLeft().x() - stickyDistance, boundingRect.topLeft().y() - stickyDistance,
|
||||
boundingRect.width() + stickyDistance * 2, boundingRect.height() + stickyDistance * 2);
|
||||
!stickyZone.intersects(sheetRect))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -503,8 +500,8 @@ auto VPPiece::StickySheet(VStickyDistance &match) const -> bool
|
|||
QVector<QPointF> const sheetPath{sheetRect.topLeft(), sheetRect.topRight(), sheetRect.bottomRight(),
|
||||
sheetRect.bottomLeft(), sheetRect.topLeft()};
|
||||
QVector<QPointF> const sheetStickyPath = PrepareStickyPath(sheetPath);
|
||||
QLineF const distance = ClosestDistance(stickyPath, sheetStickyPath);
|
||||
if (match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
if (QLineF const distance = ClosestDistance(stickyPath, sheetStickyPath);
|
||||
match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
{
|
||||
match.m_closestDistance = distance;
|
||||
}
|
||||
|
@ -530,8 +527,8 @@ auto VPPiece::StickySheet(VStickyDistance &match) const -> bool
|
|||
}
|
||||
|
||||
QVector<QPointF> const sheetStickyPath = PrepareStickyPath(sheetPath);
|
||||
QLineF const distance = ClosestDistance(stickyPath, sheetStickyPath);
|
||||
if (match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
if (QLineF const distance = ClosestDistance(stickyPath, sheetStickyPath);
|
||||
match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
{
|
||||
match.m_closestDistance = distance;
|
||||
}
|
||||
|
@ -552,8 +549,8 @@ auto VPPiece::StickySheet(VStickyDistance &match) const -> bool
|
|||
}
|
||||
|
||||
QVector<QPointF> const sheetStickyPath = PrepareStickyPath(sheetPath);
|
||||
QLineF const distance = ClosestDistance(stickyPath, sheetStickyPath);
|
||||
if (match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
if (QLineF const distance = ClosestDistance(stickyPath, sheetStickyPath);
|
||||
match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
{
|
||||
match.m_closestDistance = distance;
|
||||
}
|
||||
|
@ -615,8 +612,8 @@ auto VPPiece::StickyPieces(VStickyDistance &match) const -> bool
|
|||
if (not VPPiece::PathsSuperposition(path, piecePath))
|
||||
{
|
||||
QVector<QPointF> const pieceStickyPath = PrepareStickyPath(piecePath);
|
||||
QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath);
|
||||
if (match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
if (QLineF const distance = ClosestDistance(stickyPath, pieceStickyPath);
|
||||
match.m_closestDistance.isNull() || distance.length() < match.m_closestDistance.length())
|
||||
{
|
||||
match.m_closestDistance = distance;
|
||||
match.m_pieceGap = pieceGap;
|
||||
|
|
|
@ -140,8 +140,7 @@ void VPSheetSceneData::PrepareForExport()
|
|||
m_rotationControls->setVisible(false);
|
||||
m_rotationOrigin->setVisible(false);
|
||||
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
m_showGridTmp = layout->LayoutSettings().GetShowGrid();
|
||||
layout->LayoutSettings().SetShowGrid(false);
|
||||
|
@ -182,8 +181,7 @@ void VPSheetSceneData::CleanAfterExport()
|
|||
|
||||
m_rotationControls->setVisible(true);
|
||||
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
layout->LayoutSettings().SetShowGrid(m_showGridTmp);
|
||||
layout->LayoutSettings().SetShowTiles(m_showTilesTmp);
|
||||
|
@ -234,11 +232,10 @@ auto VPSheetSceneData::RotationControls() const -> VPGraphicsPieceControls *
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPSheetSceneData::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *
|
||||
{
|
||||
auto _graphicsPiece =
|
||||
std::find_if(m_graphicsPieces.begin(), m_graphicsPieces.end(),
|
||||
[piece](VPGraphicsPiece *graphicPiece) { return graphicPiece->GetPiece() == piece; });
|
||||
|
||||
if (_graphicsPiece != m_graphicsPieces.end())
|
||||
if (auto _graphicsPiece =
|
||||
std::find_if(m_graphicsPieces.begin(), m_graphicsPieces.end(),
|
||||
[piece](VPGraphicsPiece *graphicPiece) { return graphicPiece->GetPiece() == piece; });
|
||||
_graphicsPiece != m_graphicsPieces.end())
|
||||
{
|
||||
return *_graphicsPiece;
|
||||
}
|
||||
|
@ -274,8 +271,7 @@ void VPSheetSceneData::SetTextAsPaths(bool textAsPaths) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPSheetSceneData::PrepareTilesScheme()
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
m_showTilesSchemeTmp = layout->LayoutSettings().GetShowTiles();
|
||||
layout->LayoutSettings().SetShowTiles(true);
|
||||
|
@ -290,8 +286,7 @@ void VPSheetSceneData::PrepareTilesScheme()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPSheetSceneData::ClearTilesScheme()
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
layout->LayoutSettings().SetShowTiles(m_showTilesSchemeTmp);
|
||||
layout->LayoutSettings().SetShowWatermark(m_showTilesWatermarkSchemeTmp);
|
||||
|
@ -362,8 +357,7 @@ auto VPSheet::GetLayout() const -> VPLayoutPtr
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPSheet::GetPieces() const -> QList<VPPiecePtr>
|
||||
{
|
||||
VPLayoutPtr const layout = GetLayout();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = GetLayout(); not layout.isNull())
|
||||
{
|
||||
return layout->PiecesForSheet(m_uuid);
|
||||
}
|
||||
|
@ -374,8 +368,7 @@ auto VPSheet::GetPieces() const -> QList<VPPiecePtr>
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPSheet::GetSelectedPieces() const -> QList<VPPiecePtr>
|
||||
{
|
||||
VPLayoutPtr const layout = GetLayout();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = GetLayout(); not layout.isNull())
|
||||
{
|
||||
QList<VPPiecePtr> const list = layout->PiecesForSheet(m_uuid);
|
||||
|
||||
|
@ -692,8 +685,7 @@ void VPSheet::CheckPiecePositionValidity(const VPPiecePtr &piece) const
|
|||
return;
|
||||
}
|
||||
|
||||
QList<VPPiecePtr> const pieces = GetPieces();
|
||||
if (piece.isNull() || not pieces.contains(piece))
|
||||
if (QList<VPPiecePtr> const pieces = GetPieces(); piece.isNull() || not pieces.contains(piece))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -746,8 +738,7 @@ auto VPSheet::GetSheetOrientation() const -> QPageLayout::Orientation
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPSheet::SheetUnits() const -> Unit
|
||||
{
|
||||
VPLayoutPtr const layout = GetLayout();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = GetLayout(); not layout.isNull())
|
||||
{
|
||||
return layout->LayoutSettings().GetUnit();
|
||||
}
|
||||
|
|
|
@ -293,11 +293,9 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
setCursor(Qt::OpenHandCursor);
|
||||
emit HideTransformationHandles(false);
|
||||
|
||||
VPPiecePtr const piece = m_piece.toStrongRef();
|
||||
if (not piece.isNull())
|
||||
if (VPPiecePtr const piece = m_piece.toStrongRef(); not piece.isNull())
|
||||
{
|
||||
VPLayoutPtr const layout = piece->Layout();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = piece->Layout(); not layout.isNull())
|
||||
{
|
||||
if (layout->LayoutSettings().GetStickyEdges() && m_hasStickyPosition)
|
||||
{
|
||||
|
@ -854,17 +852,19 @@ void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece)
|
|||
|
||||
m_passmarks.addPath(passmarkPath);
|
||||
|
||||
QLineF const seamAllowanceMirrorLine = piece->GetMappedSeamAllowanceMirrorLine();
|
||||
if (!seamAllowanceMirrorLine.isNull() && piece->IsShowFullPiece() && !VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), seamAllowanceMirrorLine.p1(), seamAllowanceMirrorLine.p2()))
|
||||
if (QLineF const seamAllowanceMirrorLine = piece->GetMappedSeamAllowanceMirrorLine();
|
||||
!seamAllowanceMirrorLine.isNull() && piece->IsShowFullPiece() &&
|
||||
!VGObject::IsPointOnLineviaPDP(passmark.baseLine.p1(), seamAllowanceMirrorLine.p1(),
|
||||
seamAllowanceMirrorLine.p2()))
|
||||
{
|
||||
QPainterPath mirroredPassmaksPath;
|
||||
for (const auto &line : passmark.lines)
|
||||
{
|
||||
mirroredPassmaksPath.moveTo(line.p1());
|
||||
mirroredPassmaksPath.lineTo(line.p2());
|
||||
}
|
||||
const QTransform matrix = VGObject::FlippingMatrix(seamAllowanceMirrorLine);
|
||||
m_passmarks.addPath(matrix.map(mirroredPassmaksPath));
|
||||
QPainterPath mirroredPassmaksPath;
|
||||
for (const auto &line : passmark.lines)
|
||||
{
|
||||
mirroredPassmaksPath.moveTo(line.p1());
|
||||
mirroredPassmaksPath.lineTo(line.p2());
|
||||
}
|
||||
const QTransform matrix = VGObject::FlippingMatrix(seamAllowanceMirrorLine);
|
||||
m_passmarks.addPath(matrix.map(mirroredPassmaksPath));
|
||||
}
|
||||
|
||||
if (painter != nullptr)
|
||||
|
@ -893,7 +893,8 @@ void VPGraphicsPiece::PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piec
|
|||
for (auto &points : shape)
|
||||
{
|
||||
std::transform(points.begin(), points.end(), points.begin(),
|
||||
[&matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
|
||||
[&matrix](const VLayoutPoint &point)
|
||||
{ return VAbstractPiece::MapPoint(point, matrix); });
|
||||
}
|
||||
|
||||
path.addPath(VAbstractPiece::LabelShapePath(piece->MapPlaceLabelShape(shape)));
|
||||
|
@ -1078,8 +1079,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos)
|
|||
{
|
||||
QList<VPPiecePtr> pieces;
|
||||
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
return sheet->GetSelectedPieces();
|
||||
}
|
||||
|
|
|
@ -58,8 +58,7 @@ const qreal centerRadius2 = 10;
|
|||
auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) -> VPTransformationOrigon
|
||||
{
|
||||
SCASSERT(layout != nullptr)
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
return sheet->TransformationOrigin();
|
||||
}
|
||||
|
@ -170,11 +169,9 @@ void VPGraphicsTransformationOrigin::mousePressEvent(QGraphicsSceneMouseEvent *e
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPGraphicsTransformationOrigin::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
VPTransformationOrigon origin = sheet->TransformationOrigin();
|
||||
origin.origin = event->scenePos();
|
||||
|
@ -420,8 +417,7 @@ void VPGraphicsPieceControls::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
else
|
||||
{
|
||||
QGraphicsView *view = ItemView();
|
||||
if (view != nullptr)
|
||||
if (QGraphicsView *view = ItemView(); view != nullptr)
|
||||
{
|
||||
setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes
|
||||
}
|
||||
|
@ -503,8 +499,7 @@ void VPGraphicsPieceControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
else
|
||||
{
|
||||
QGraphicsView *view = ItemView();
|
||||
if (view != nullptr)
|
||||
if (QGraphicsView *view = ItemView(); view != nullptr)
|
||||
{
|
||||
setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes
|
||||
}
|
||||
|
@ -512,11 +507,9 @@ void VPGraphicsPieceControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (m_originSaved)
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
if (not m_savedOrigin.custom)
|
||||
{
|
||||
|
@ -721,11 +714,9 @@ auto VPGraphicsPieceControls::SelectedPieces() const -> QList<VPPiecePtr>
|
|||
{
|
||||
QList<VPPiecePtr> pieces;
|
||||
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
pieces = sheet->GetSelectedPieces();
|
||||
}
|
||||
|
@ -752,11 +743,9 @@ auto VPGraphicsPieceControls::PiecesBoundingRect(const QList<VPPiecePtr> &select
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPGraphicsPieceControls::ItemView() -> QGraphicsView *
|
||||
{
|
||||
QGraphicsScene *scene = this->scene();
|
||||
if (scene != nullptr)
|
||||
if (QGraphicsScene *scene = this->scene(); scene != nullptr)
|
||||
{
|
||||
QList<QGraphicsView *> const views = scene->views();
|
||||
if (not views.isEmpty())
|
||||
if (QList<QGraphicsView *> const views = scene->views(); not views.isEmpty())
|
||||
{
|
||||
return views.at(0);
|
||||
}
|
||||
|
@ -776,8 +765,7 @@ void VPGraphicsPieceControls::UpdateCursor(VPHandleCorner corner)
|
|||
}
|
||||
else
|
||||
{
|
||||
QGraphicsView *view = ItemView();
|
||||
if (view != nullptr)
|
||||
if (QGraphicsView *view = ItemView(); view != nullptr)
|
||||
{
|
||||
setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes
|
||||
}
|
||||
|
|
|
@ -162,9 +162,8 @@ void VPGraphicsSheet::RefreshBoundingRect()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPGraphicsSheet::PaintVerticalFold(QPainter *painter, const QRectF &sheetRect) const
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
|
||||
if (not layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
not layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
{
|
||||
QString const foldText = FoldText();
|
||||
painter->save();
|
||||
|
@ -223,9 +222,8 @@ void VPGraphicsSheet::PaintVerticalFold(QPainter *painter, const QRectF &sheetRe
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPGraphicsSheet::PaintHorizontalFold(QPainter *painter, const QRectF &sheetRect) const
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
|
||||
if (not layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
not layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
{
|
||||
QString const foldText = FoldText();
|
||||
painter->save();
|
||||
|
@ -299,8 +297,7 @@ void VPGraphicsSheet::PaintMargins(QPainter *painter) const
|
|||
}
|
||||
|
||||
bool ignoreMargins = true;
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (!sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); !sheet.isNull())
|
||||
{
|
||||
ignoreMargins = sheet->IgnoreMargins();
|
||||
}
|
||||
|
@ -333,9 +330,8 @@ void VPGraphicsSheet::PaintBorder(QPainter *painter) const
|
|||
painter->setPen(pen);
|
||||
painter->drawRect(sheetRect);
|
||||
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
|
||||
if (!layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
!layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
{
|
||||
if (sheetRect.width() >= sheetRect.height())
|
||||
{
|
||||
|
@ -354,8 +350,7 @@ void VPGraphicsSheet::PaintBorder(QPainter *painter) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPGraphicsSheet::PaintFold(QPainter *painter) const
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (!layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); !layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
{
|
||||
QRectF const sheetRect = GetSheetRect();
|
||||
QRectF const foldField = m_showBorder ? sheetRect : FoldField(GetMarginsRect());
|
||||
|
@ -387,8 +382,7 @@ void VPGraphicsSheet::PaintGrid(QPainter *painter) const
|
|||
|
||||
QRectF const sheetRect = GetSheetRect();
|
||||
|
||||
qreal const colWidth = layout->LayoutSettings().GetGridColWidth();
|
||||
if (colWidth > 0)
|
||||
if (qreal const colWidth = layout->LayoutSettings().GetGridColWidth(); colWidth > 0)
|
||||
{
|
||||
qreal colX = colWidth;
|
||||
while (colX < sheetRect.right())
|
||||
|
@ -399,8 +393,7 @@ void VPGraphicsSheet::PaintGrid(QPainter *painter) const
|
|||
}
|
||||
}
|
||||
|
||||
qreal const rowHeight = layout->LayoutSettings().GetGridRowHeight();
|
||||
if (rowHeight > 0)
|
||||
if (qreal const rowHeight = layout->LayoutSettings().GetGridRowHeight(); rowHeight > 0)
|
||||
{
|
||||
qreal rowY = rowHeight;
|
||||
|
||||
|
@ -447,9 +440,9 @@ auto VPGraphicsSheet::FoldText() -> QString
|
|||
auto VPGraphicsSheet::boundingRect() const -> QRectF
|
||||
{
|
||||
QRectF boundingRect = GetSheetRect();
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
|
||||
if (not layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
not layout.isNull() && layout->LayoutSettings().IsCutOnFold())
|
||||
{
|
||||
QString const foldText = FoldText();
|
||||
QFont font = QApplication::font();
|
||||
|
|
|
@ -115,8 +115,8 @@ VPGraphicsTileGrid::VPGraphicsTileGrid(const VPLayoutPtr &layout, const QUuid &s
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPGraphicsTileGrid::boundingRect() const -> QRectF
|
||||
{
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull() && layout->LayoutSettings().GetShowTiles())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
not layout.isNull() && layout->LayoutSettings().GetShowTiles())
|
||||
{
|
||||
VPSheetPtr const sheet = layout->GetSheet(m_sheetUuid);
|
||||
|
||||
|
|
|
@ -314,8 +314,7 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
|
|||
return;
|
||||
}
|
||||
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
sheet->SceneData()->RotationControls()->SetIgnorePieceTransformation(false);
|
||||
sheet->SceneData()->RotationControls()->on_UpdateControls();
|
||||
|
@ -331,8 +330,7 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainGraphicsView::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QGraphicsItem *item = itemAt(event->pos());
|
||||
if (item != nullptr && item->type() == VPGraphicsPiece::Type)
|
||||
if (QGraphicsItem *item = itemAt(event->pos()); item != nullptr && item->type() == VPGraphicsPiece::Type)
|
||||
{
|
||||
VMainGraphicsView::contextMenuEvent(event);
|
||||
return;
|
||||
|
@ -429,8 +427,7 @@ void VPMainGraphicsView::RotatePiecesByAngle(qreal angle)
|
|||
auto PreparePieces = [this]()
|
||||
{
|
||||
QList<VPPiecePtr> pieces;
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
|
@ -458,9 +455,7 @@ void VPMainGraphicsView::RotatePiecesByAngle(qreal angle)
|
|||
m_rotationSum = angle;
|
||||
}
|
||||
|
||||
QList<VPPiecePtr> const pieces = PreparePieces();
|
||||
|
||||
if (pieces.size() == 1)
|
||||
if (QList<VPPiecePtr> const pieces = PreparePieces(); pieces.size() == 1)
|
||||
{
|
||||
auto *command = new VPUndoPieceRotate(pieces.constFirst(), origin, angle, m_rotationSum, m_allowChangeMerge);
|
||||
layout->UndoStack()->push(command);
|
||||
|
@ -496,8 +491,7 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
|||
return;
|
||||
}
|
||||
|
||||
VPPiecePtr const piece = graphicsPieces.constFirst()->GetPiece();
|
||||
if (piece.isNull())
|
||||
if (VPPiecePtr const piece = graphicsPieces.constFirst()->GetPiece(); piece.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -505,11 +499,9 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
|||
auto PreparePieces = [this]()
|
||||
{
|
||||
QList<VPPiecePtr> pieces;
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
pieces = sheet->GetSelectedPieces();
|
||||
}
|
||||
|
@ -518,8 +510,7 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
|||
return pieces;
|
||||
};
|
||||
|
||||
QList<VPPiecePtr> const pieces = PreparePieces();
|
||||
if (pieces.size() == 1)
|
||||
if (QList<VPPiecePtr> const pieces = PreparePieces(); pieces.size() == 1)
|
||||
{
|
||||
const VPPiecePtr &p = pieces.constFirst();
|
||||
auto *command = new VPUndoPieceMove(p, dx, dy, m_allowChangeMerge);
|
||||
|
@ -541,8 +532,7 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
|||
m_hasStickyPosition = false;
|
||||
}
|
||||
|
||||
VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p);
|
||||
if (gPiece != nullptr)
|
||||
if (VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p); gPiece != nullptr)
|
||||
{
|
||||
gPiece->SetStickyPoints(path);
|
||||
}
|
||||
|
@ -684,16 +674,15 @@ void VPMainGraphicsView::MovePiece(QKeyEvent *event)
|
|||
return;
|
||||
}
|
||||
|
||||
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
|
||||
if (m_hasStickyPosition && not graphicsPieces.isEmpty())
|
||||
if (const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
|
||||
m_hasStickyPosition && not graphicsPieces.isEmpty())
|
||||
{
|
||||
if (layout->LayoutSettings().GetStickyEdges())
|
||||
{
|
||||
auto PreparePieces = [layout]()
|
||||
{
|
||||
QList<VPPiecePtr> pieces;
|
||||
VPSheetPtr const sheet = layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
pieces = sheet->GetSelectedPieces();
|
||||
}
|
||||
|
@ -701,16 +690,14 @@ void VPMainGraphicsView::MovePiece(QKeyEvent *event)
|
|||
return pieces;
|
||||
};
|
||||
|
||||
QList<VPPiecePtr> const pieces = PreparePieces();
|
||||
if (pieces.size() == 1)
|
||||
if (QList<VPPiecePtr> const pieces = PreparePieces(); pieces.size() == 1)
|
||||
{
|
||||
const VPPiecePtr &p = pieces.constFirst();
|
||||
|
||||
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge);
|
||||
layout->UndoStack()->push(command);
|
||||
|
||||
VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p);
|
||||
if (gPiece != nullptr)
|
||||
if (VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p); gPiece != nullptr)
|
||||
{
|
||||
gPiece->SetStickyPoints(QVector<QPointF>());
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ VPUndoMovePieceOnSheet::VPUndoMovePieceOnSheet(const VPSheetPtr &sheet, const VP
|
|||
|
||||
m_oldSheet = piece->Sheet();
|
||||
|
||||
VPLayoutPtr const layout = piece->Layout();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = piece->Layout(); not layout.isNull())
|
||||
{
|
||||
m_followGrainline = layout->LayoutSettings().GetFollowGrainline();
|
||||
}
|
||||
|
|
|
@ -26,16 +26,16 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
#include "vpundooriginmove.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../layout/vpsheet.h"
|
||||
#include "../layout/vplayout.h"
|
||||
#include "../layout/vpsheet.h"
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPUndoOriginMove::VPUndoOriginMove(const VPSheetPtr &sheet, const VPTransformationOrigon &origin, bool allowMerge,
|
||||
QUndoCommand *parent)
|
||||
: VPUndoCommand(allowMerge, parent),
|
||||
m_sheet(sheet),
|
||||
m_origin(origin)
|
||||
: VPUndoCommand(allowMerge, parent),
|
||||
m_sheet(sheet),
|
||||
m_origin(origin)
|
||||
{
|
||||
SCASSERT(not sheet.isNull())
|
||||
|
||||
|
@ -104,8 +104,8 @@ auto VPUndoOriginMove::mergeWith(const QUndoCommand *command) -> bool
|
|||
const auto *moveCommand = dynamic_cast<const VPUndoOriginMove *>(command);
|
||||
SCASSERT(moveCommand != nullptr)
|
||||
|
||||
VPSheetPtr const sheet = Sheet();
|
||||
if (moveCommand->Sheet().isNull() || sheet.isNull() || not moveCommand->AllowMerge())
|
||||
if (VPSheetPtr const sheet = Sheet();
|
||||
moveCommand->Sheet().isNull() || sheet.isNull() || not moveCommand->AllowMerge())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -26,16 +26,16 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
#include "vpundopiecemove.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../layout/vppiece.h"
|
||||
#include "../layout/vplayout.h"
|
||||
#include "../layout/vppiece.h"
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPUndoPieceMove::VPUndoPieceMove(const VPPiecePtr &piece, qreal dx, qreal dy, bool allowMerge, QUndoCommand *parent)
|
||||
: VPUndoCommand(allowMerge, parent),
|
||||
m_piece(piece),
|
||||
m_dx(dx),
|
||||
m_dy(dy)
|
||||
: VPUndoCommand(allowMerge, parent),
|
||||
m_piece(piece),
|
||||
m_dx(dx),
|
||||
m_dy(dy)
|
||||
{
|
||||
SCASSERT(not piece.isNull())
|
||||
|
||||
|
@ -104,9 +104,8 @@ auto VPUndoPieceMove::mergeWith(const QUndoCommand *command) -> bool
|
|||
const auto *moveCommand = dynamic_cast<const VPUndoPieceMove *>(command);
|
||||
SCASSERT(moveCommand != nullptr)
|
||||
|
||||
VPPiecePtr const piece = Piece();
|
||||
if (moveCommand->Piece().isNull() || piece.isNull() || moveCommand->Piece() != piece ||
|
||||
not moveCommand->AllowMerge())
|
||||
if (VPPiecePtr const piece = Piece(); moveCommand->Piece().isNull() || piece.isNull() ||
|
||||
moveCommand->Piece() != piece || not moveCommand->AllowMerge())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -126,13 +125,13 @@ auto VPUndoPieceMove::id() const -> int
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPUndoPiecesMove::VPUndoPiecesMove(const QList<VPPiecePtr> &pieces, qreal dx, qreal dy, bool allowMerge,
|
||||
QUndoCommand *parent)
|
||||
: VPUndoCommand(allowMerge, parent),
|
||||
m_dx(dx),
|
||||
m_dy(dy)
|
||||
: VPUndoCommand(allowMerge, parent),
|
||||
m_dx(dx),
|
||||
m_dy(dy)
|
||||
{
|
||||
setText(QObject::tr("move pieces"));
|
||||
|
||||
for (const auto& piece : pieces)
|
||||
for (const auto &piece : pieces)
|
||||
{
|
||||
if (not piece.isNull())
|
||||
{
|
||||
|
@ -156,13 +155,12 @@ void VPUndoPiecesMove::undo()
|
|||
return;
|
||||
}
|
||||
|
||||
VPSheetPtr const sheet = Sheet();
|
||||
if (layout->GetFocusedSheet() != sheet)
|
||||
if (VPSheetPtr const sheet = Sheet(); layout->GetFocusedSheet() != sheet)
|
||||
{
|
||||
layout->SetFocusedSheet(sheet);
|
||||
}
|
||||
|
||||
for (const auto& piece : qAsConst(m_pieces))
|
||||
for (const auto &piece : qAsConst(m_pieces))
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
@ -190,13 +188,12 @@ void VPUndoPiecesMove::redo()
|
|||
return;
|
||||
}
|
||||
|
||||
VPSheetPtr const sheet = Sheet();
|
||||
if (layout->GetFocusedSheet() != sheet)
|
||||
if (VPSheetPtr const sheet = Sheet(); layout->GetFocusedSheet() != sheet)
|
||||
{
|
||||
layout->SetFocusedSheet(sheet);
|
||||
}
|
||||
|
||||
for (const auto& piece : qAsConst(m_pieces))
|
||||
for (const auto &piece : qAsConst(m_pieces))
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
@ -244,7 +241,7 @@ auto VPUndoPiecesMove::id() const -> int
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPUndoPiecesMove::Layout() const -> VPLayoutPtr
|
||||
{
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
@ -257,9 +254,9 @@ auto VPUndoPiecesMove::Layout() const -> VPLayoutPtr
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPUndoPiecesMove::Sheet() const -> VPSheetPtr
|
||||
auto VPUndoPiecesMove::Sheet() const -> VPSheetPtr
|
||||
{
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
@ -275,7 +272,7 @@ auto VPUndoPiecesMove::Sheet() const -> VPSheetPtr
|
|||
inline auto VPUndoPiecesMove::PieceIds() const -> QSet<QString>
|
||||
{
|
||||
QSet<QString> ids;
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
|
|
@ -52,8 +52,7 @@ VPUndoPieceRotate::VPUndoPieceRotate(const VPPiecePtr &piece, const VPTransforma
|
|||
|
||||
m_oldTransform = piece->GetMatrix();
|
||||
|
||||
VPLayoutPtr const layout = piece->Layout();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = piece->Layout(); not layout.isNull())
|
||||
{
|
||||
m_followGrainline = layout->LayoutSettings().GetFollowGrainline();
|
||||
}
|
||||
|
@ -147,10 +146,10 @@ auto VPUndoPieceRotate::mergeWith(const QUndoCommand *command) -> bool
|
|||
const auto *moveCommand = dynamic_cast<const VPUndoPieceRotate *>(command);
|
||||
SCASSERT(moveCommand != nullptr)
|
||||
|
||||
VPPiecePtr const piece = Piece();
|
||||
if (not moveCommand->AllowMerge() || (moveCommand->Piece().isNull() || piece.isNull()) ||
|
||||
moveCommand->Piece() != piece || moveCommand->Origin() != m_origin ||
|
||||
moveCommand->FollowGrainline() != m_followGrainline)
|
||||
if (VPPiecePtr const piece = Piece(); not moveCommand->AllowMerge() ||
|
||||
(moveCommand->Piece().isNull() || piece.isNull()) ||
|
||||
moveCommand->Piece() != piece || moveCommand->Origin() != m_origin ||
|
||||
moveCommand->FollowGrainline() != m_followGrainline)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -207,8 +206,7 @@ void VPUndoPiecesRotate::undo()
|
|||
return;
|
||||
}
|
||||
|
||||
VPSheetPtr const sheet = Sheet();
|
||||
if (layout->GetFocusedSheet() != sheet)
|
||||
if (VPSheetPtr const sheet = Sheet(); layout->GetFocusedSheet() != sheet)
|
||||
{
|
||||
layout->SetFocusedSheet(sheet);
|
||||
}
|
||||
|
@ -241,8 +239,7 @@ void VPUndoPiecesRotate::redo()
|
|||
return;
|
||||
}
|
||||
|
||||
VPSheetPtr const sheet = Sheet();
|
||||
if (layout->GetFocusedSheet() != sheet)
|
||||
if (VPSheetPtr const sheet = Sheet(); layout->GetFocusedSheet() != sheet)
|
||||
{
|
||||
layout->SetFocusedSheet(sheet);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
#include "vpundopiecezvaluemove.h"
|
||||
#include "../layout/vppiece.h"
|
||||
#include "../layout/vplayout.h"
|
||||
#include "../layout/vppiece.h"
|
||||
#include "../layout/vpsheet.h"
|
||||
#include "undocommands/vpundocommand.h"
|
||||
|
||||
|
@ -49,19 +49,19 @@ auto CorrectedZValues(const QList<QVector<QString>> &order) -> QHash<QString, qr
|
|||
const QVector<QString> &level = order.at(i);
|
||||
for (const auto &pieceId : level)
|
||||
{
|
||||
correctedZValues.insert(pieceId, i*step);
|
||||
correctedZValues.insert(pieceId, i * step);
|
||||
}
|
||||
}
|
||||
|
||||
return correctedZValues;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPUndoPieceZValueMove::VPUndoPieceZValueMove(const VPPiecePtr &piece, ML::ZValueMove move, QUndoCommand *parent)
|
||||
: VPUndoCommand(parent),
|
||||
m_piece(piece),
|
||||
m_move(move)
|
||||
: VPUndoCommand(parent),
|
||||
m_piece(piece),
|
||||
m_move(move)
|
||||
{
|
||||
setText(QObject::tr("z value move piece"));
|
||||
|
||||
|
@ -69,7 +69,7 @@ VPUndoPieceZValueMove::VPUndoPieceZValueMove(const VPPiecePtr &piece, ML::ZValue
|
|||
if (not sheet.isNull())
|
||||
{
|
||||
const QList<VPPiecePtr> pieces = sheet->GetPieces();
|
||||
for(const auto& p : pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (not p.isNull())
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ void VPUndoPieceZValueMove::undo()
|
|||
|
||||
const QList<VPPiecePtr> pieces = sheet->GetPieces();
|
||||
|
||||
for (const auto &p: pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (not p.isNull())
|
||||
{
|
||||
|
@ -158,7 +158,7 @@ void VPUndoPieceZValueMove::redo()
|
|||
else if (m_move == ML::ZValueMove::Up)
|
||||
{
|
||||
const qreal step = LevelStep(pieces);
|
||||
for (const auto &p: pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (p->GetUniqueID() != piece->GetUniqueID())
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ void VPUndoPieceZValueMove::redo()
|
|||
else if (m_move == ML::ZValueMove::Down)
|
||||
{
|
||||
const qreal step = LevelStep(pieces);
|
||||
for (const auto &p: pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (p->GetUniqueID() != piece->GetUniqueID())
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ void VPUndoPieceZValueMove::redo()
|
|||
}
|
||||
|
||||
QHash<QString, qreal> const correctedZValues = CorrectedZValues(order);
|
||||
for (const auto &p: pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (not p.isNull())
|
||||
{
|
||||
|
@ -215,8 +215,7 @@ auto VPUndoPieceZValueMove::Piece() const -> VPPiecePtr
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPUndoPieceZValueMove::Sheet() const -> VPSheetPtr
|
||||
{
|
||||
VPPiecePtr const p = Piece();
|
||||
if (not p.isNull())
|
||||
if (VPPiecePtr const p = Piece(); not p.isNull())
|
||||
{
|
||||
return p->Sheet();
|
||||
}
|
||||
|
@ -225,7 +224,7 @@ auto VPUndoPieceZValueMove::Sheet() const -> VPSheetPtr
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPUndoPieceZValueMove::Levels(const QList<VPPiecePtr> &pieces, bool skip) const -> QList<QVector<QString> >
|
||||
auto VPUndoPieceZValueMove::Levels(const QList<VPPiecePtr> &pieces, bool skip) const -> QList<QVector<QString>>
|
||||
{
|
||||
VPPiecePtr const piece = Piece();
|
||||
if (piece.isNull())
|
||||
|
@ -235,7 +234,7 @@ auto VPUndoPieceZValueMove::Levels(const QList<VPPiecePtr> &pieces, bool skip) c
|
|||
|
||||
QMap<qreal, QVector<QString>> levels;
|
||||
|
||||
for (const auto &p: pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (p.isNull() || (skip && p->GetUniqueID() == piece->GetUniqueID()))
|
||||
{
|
||||
|
@ -273,13 +272,13 @@ auto VPUndoPieceZValueMove::LevelStep(const QList<VPPiecePtr> &pieces) const ->
|
|||
// Z value pieces
|
||||
VPUndoPiecesZValueMove::VPUndoPiecesZValueMove(const QList<VPPiecePtr> &pieces, ML::ZValueMove move,
|
||||
QUndoCommand *parent)
|
||||
: VPUndoCommand(parent),
|
||||
m_move(move)
|
||||
: VPUndoCommand(parent),
|
||||
m_move(move)
|
||||
{
|
||||
setText(QObject::tr("z value move pieces"));
|
||||
|
||||
m_pieces.reserve(pieces.size());
|
||||
for(const auto& p : pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
m_pieces.append(p);
|
||||
}
|
||||
|
@ -288,7 +287,7 @@ VPUndoPiecesZValueMove::VPUndoPiecesZValueMove(const QList<VPPiecePtr> &pieces,
|
|||
if (not sheet.isNull())
|
||||
{
|
||||
const QList<VPPiecePtr> pieces = sheet->GetPieces();
|
||||
for(const auto& p : pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (not p.isNull())
|
||||
{
|
||||
|
@ -325,7 +324,7 @@ void VPUndoPiecesZValueMove::undo()
|
|||
|
||||
const QList<VPPiecePtr> pieces = sheet->GetPieces();
|
||||
|
||||
for (const auto &p: pieces)
|
||||
for (const auto &p : pieces)
|
||||
{
|
||||
if (not p.isNull())
|
||||
{
|
||||
|
@ -376,7 +375,7 @@ void VPUndoPiecesZValueMove::redo()
|
|||
else if (m_move == ML::ZValueMove::Up)
|
||||
{
|
||||
const qreal step = LevelStep(allPieces);
|
||||
for (const auto &p: allPieces)
|
||||
for (const auto &p : allPieces)
|
||||
{
|
||||
if (not ids.contains(p->GetUniqueID()))
|
||||
{
|
||||
|
@ -389,7 +388,7 @@ void VPUndoPiecesZValueMove::redo()
|
|||
else if (m_move == ML::ZValueMove::Down)
|
||||
{
|
||||
const qreal step = LevelStep(allPieces);
|
||||
for (const auto &p: allPieces)
|
||||
for (const auto &p : allPieces)
|
||||
{
|
||||
if (not ids.contains(p->GetUniqueID()))
|
||||
{
|
||||
|
@ -406,7 +405,7 @@ void VPUndoPiecesZValueMove::redo()
|
|||
}
|
||||
|
||||
QHash<QString, qreal> const correctedZValues = CorrectedZValues(order);
|
||||
for (const auto &p: allPieces)
|
||||
for (const auto &p : allPieces)
|
||||
{
|
||||
if (not p.isNull())
|
||||
{
|
||||
|
@ -427,7 +426,7 @@ auto VPUndoPiecesZValueMove::id() const -> int
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPUndoPiecesZValueMove::Layout() const -> VPLayoutPtr
|
||||
{
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
@ -442,7 +441,7 @@ auto VPUndoPiecesZValueMove::Layout() const -> VPLayoutPtr
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPUndoPiecesZValueMove::Sheet() const -> VPSheetPtr
|
||||
{
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
@ -460,7 +459,7 @@ auto VPUndoPiecesZValueMove::PieceIds() const -> QVector<QString>
|
|||
QVector<QString> ids;
|
||||
ids.reserve(m_pieces.size());
|
||||
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
VPPiecePtr const p = piece.toStrongRef();
|
||||
if (not p.isNull())
|
||||
|
@ -473,12 +472,12 @@ auto VPUndoPiecesZValueMove::PieceIds() const -> QVector<QString>
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPUndoPiecesZValueMove::Levels(const QList<VPPiecePtr> &allPieces, const QVector<QString> &skipPieces,
|
||||
bool skip) -> QList<QVector<QString> >
|
||||
auto VPUndoPiecesZValueMove::Levels(const QList<VPPiecePtr> &allPieces, const QVector<QString> &skipPieces, bool skip)
|
||||
-> QList<QVector<QString>>
|
||||
{
|
||||
QMap<qreal, QVector<QString>> levels;
|
||||
|
||||
for (const auto &p: allPieces)
|
||||
for (const auto &p : allPieces)
|
||||
{
|
||||
if (p.isNull() || (skip && skipPieces.contains(p->GetUniqueID())))
|
||||
{
|
||||
|
|
|
@ -538,9 +538,9 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
|
|||
{
|
||||
const QStringList rawLayouts = cmd->OptionRawLayouts();
|
||||
const QStringList args = cmd->OptionFileNames();
|
||||
bool const success = !args.isEmpty() ? StartWithFiles(cmd, rawLayouts) : SingleStart(cmd, rawLayouts);
|
||||
|
||||
if (not success)
|
||||
if (bool const success = !args.isEmpty() ? StartWithFiles(cmd, rawLayouts) : SingleStart(cmd, rawLayouts);
|
||||
not success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -577,11 +577,9 @@ auto VPApplication::event(QEvent *e) -> bool
|
|||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
|
||||
auto *fileOpenEvent = static_cast<QFileOpenEvent *>(e);
|
||||
const QString macFileOpen = fileOpenEvent->file();
|
||||
if (not macFileOpen.isEmpty())
|
||||
if (const QString macFileOpen = fileOpenEvent->file(); not macFileOpen.isEmpty())
|
||||
{
|
||||
VPMainWindow *mw = MainWindow();
|
||||
if (mw != nullptr)
|
||||
if (VPMainWindow *mw = MainWindow(); mw != nullptr)
|
||||
{
|
||||
mw->LoadFile(macFileOpen); // open file in existing window
|
||||
}
|
||||
|
@ -595,8 +593,7 @@ auto VPApplication::event(QEvent *e) -> bool
|
|||
if (static_cast<QApplicationStateChangeEvent *>(e)->applicationState() == Qt::ApplicationActive)
|
||||
{
|
||||
Clean();
|
||||
VPMainWindow *mw = MainWindow();
|
||||
if (mw && not mw->isMinimized())
|
||||
if (VPMainWindow *mw = MainWindow(); mw && not mw->isMinimized())
|
||||
{
|
||||
mw->show();
|
||||
}
|
||||
|
@ -635,8 +632,7 @@ void VPApplication::NewLocalSocketConnection()
|
|||
}
|
||||
socket->waitForReadyRead(1000);
|
||||
QTextStream stream(socket.data());
|
||||
const QString arg = stream.readAll();
|
||||
if (not arg.isEmpty())
|
||||
if (const QString arg = stream.readAll(); not arg.isEmpty())
|
||||
{
|
||||
ParseCommandLine(SocketConnection::Server, arg.split(QStringLiteral(";;")));
|
||||
}
|
||||
|
|
|
@ -204,8 +204,9 @@ void SetPrinterSheetPageSettings(const QSharedPointer<QPrinter> &printer, const
|
|||
qreal const width = FromPixel(imageRect.width() * xScale + margins.left() + margins.right(), Unit::Mm);
|
||||
qreal const height = FromPixel(imageRect.height() * yScale + margins.top() + margins.bottom(), Unit::Mm);
|
||||
|
||||
QSizeF const pageSize = sheetOrientation == QPageLayout::Portrait ? QSizeF(width, height) : QSizeF(height, width);
|
||||
if (not printer->setPageSize(QPageSize(pageSize, QPageSize::Millimeter)))
|
||||
if (QSizeF const pageSize =
|
||||
(sheetOrientation == QPageLayout::Portrait ? QSizeF(width, height) : QSizeF(height, width));
|
||||
not printer->setPageSize(QPageSize(pageSize, QPageSize::Millimeter)))
|
||||
{
|
||||
qWarning() << QObject::tr("Cannot set printer page size");
|
||||
}
|
||||
|
@ -470,9 +471,9 @@ auto VPMainWindow::LoadFile(const QString &path) -> bool
|
|||
|
||||
// Check if file already opened
|
||||
QList<VPMainWindow *> list = VPApplication::VApp()->MainWindows();
|
||||
auto w =
|
||||
std::find_if(list.begin(), list.end(), [path](VPMainWindow *window) { return window->CurrentFile() == path; });
|
||||
if (w != list.end())
|
||||
if (auto w = std::find_if(list.begin(), list.end(),
|
||||
[path](VPMainWindow *window) { return window->CurrentFile() == path; });
|
||||
w != list.end())
|
||||
{
|
||||
(*w)->activateWindow();
|
||||
if (this != *w)
|
||||
|
@ -520,8 +521,7 @@ auto VPMainWindow::LoadFile(const QString &path) -> bool
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -940,8 +940,7 @@ void VPMainWindow::InitPropertyTabCurrentSheet()
|
|||
ui->comboBoxLayoutUnit->addItem(tr("Pixels"), QVariant(UnitsToStr(Unit::Px)));
|
||||
|
||||
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
||||
const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(UnitsToStr(settings->LayoutUnit()));
|
||||
if (indexUnit != -1)
|
||||
if (const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(UnitsToStr(settings->LayoutUnit())); indexUnit != -1)
|
||||
{
|
||||
ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit);
|
||||
}
|
||||
|
@ -1385,8 +1384,9 @@ void VPMainWindow::SetPropertyTabSheetData()
|
|||
SetLineEditValue(ui->lineEditSheetName, sheet->GetName());
|
||||
|
||||
ui->groupBoxPaperFormat->setDisabled(false);
|
||||
const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(UnitsToStr(m_layout->LayoutSettings().GetUnit()));
|
||||
if (indexUnit != -1)
|
||||
if (const qint32 indexUnit =
|
||||
ui->comboBoxLayoutUnit->findData(UnitsToStr(m_layout->LayoutSettings().GetUnit()));
|
||||
indexUnit != -1)
|
||||
{
|
||||
ui->comboBoxLayoutUnit->blockSignals(true);
|
||||
ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit);
|
||||
|
@ -1819,9 +1819,8 @@ auto VPMainWindow::MaybeSave() -> bool
|
|||
|
||||
messageBox->setWindowModality(Qt::ApplicationModal);
|
||||
messageBox->setFixedSize(300, 85);
|
||||
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
|
||||
|
||||
switch (ret)
|
||||
switch (static_cast<QMessageBox::StandardButton>(messageBox->exec()))
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
if (IsLayoutReadOnly())
|
||||
|
@ -1856,8 +1855,7 @@ void VPMainWindow::CreateWindowMenu(QMenu *menu)
|
|||
VPMainWindow *window = windows.at(i);
|
||||
|
||||
QString title = QStringLiteral("%1. %2").arg(i + 1).arg(window->windowTitle());
|
||||
const vsizetype index = title.lastIndexOf("[*]"_L1);
|
||||
if (index != -1)
|
||||
if (const vsizetype index = title.lastIndexOf("[*]"_L1); index != -1)
|
||||
{
|
||||
window->isWindowModified() ? title.replace(index, 3, '*'_L1) : title.replace(index, 3, QString());
|
||||
}
|
||||
|
@ -2152,8 +2150,7 @@ void VPMainWindow::FindTemplate(QComboBox *box, qreal width, qreal height)
|
|||
VAbstractLayoutDialog::RoundTemplateSize(height, width, paperUnit) == tmplSize)
|
||||
{
|
||||
box->blockSignals(true);
|
||||
const int index = box->findData(i);
|
||||
if (index != -1)
|
||||
if (const int index = box->findData(i); index != -1)
|
||||
{
|
||||
box->setCurrentIndex(index);
|
||||
}
|
||||
|
@ -2163,8 +2160,7 @@ void VPMainWindow::FindTemplate(QComboBox *box, qreal width, qreal height)
|
|||
}
|
||||
|
||||
box->blockSignals(true);
|
||||
const int index = box->findData(max);
|
||||
if (index != -1)
|
||||
if (const int index = box->findData(max); index != -1)
|
||||
{
|
||||
box->setCurrentIndex(index);
|
||||
}
|
||||
|
@ -2875,8 +2871,7 @@ auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const V
|
|||
|
||||
sheet->SceneData()->Scene()->render(painter, target, source, Qt::KeepAspectRatio);
|
||||
|
||||
VWatermarkData const watermarkData = m_layout->TileFactory()->WatermarkData();
|
||||
if (watermarkData.opacity > 0)
|
||||
if (VWatermarkData const watermarkData = m_layout->TileFactory()->WatermarkData(); watermarkData.opacity > 0)
|
||||
{
|
||||
if (watermarkData.showImage && not watermarkData.path.isEmpty())
|
||||
{
|
||||
|
@ -3126,9 +3121,9 @@ void VPMainWindow::PrintLayoutTiledSheets(QPrinter *printer, const QList<VPSheet
|
|||
{
|
||||
vsizetype const index =
|
||||
printer->pageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j : lastPageNumber - j;
|
||||
const VPLayoutPrinterPage &page = pages.at(index);
|
||||
|
||||
if (not PrintLayoutTiledSheetPage(printer, painter, page, firstPage))
|
||||
if (const VPLayoutPrinterPage &page = pages.at(index);
|
||||
not PrintLayoutTiledSheetPage(printer, painter, page, firstPage))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -3274,8 +3269,7 @@ void VPMainWindow::ZValueMove(int move)
|
|||
auto VPMainWindow::ImportRawLayout(const QString &rawLayout) -> bool
|
||||
{
|
||||
VRawLayout rawLayoutReader;
|
||||
VRawLayoutData data;
|
||||
if (rawLayoutReader.ReadFile(rawLayout, data))
|
||||
if (VRawLayoutData data; rawLayoutReader.ReadFile(rawLayout, data))
|
||||
{
|
||||
return AddLayoutPieces(data.pieces);
|
||||
}
|
||||
|
@ -3302,8 +3296,7 @@ auto VPMainWindow::AddLayoutPieces(const QVector<VLayoutPiece> &pieces) -> bool
|
|||
VPPiecePtr const piece(new VPPiece(rawPiece));
|
||||
piece->SetCopyNumber(i);
|
||||
|
||||
QString error;
|
||||
if (not piece->IsValid(error))
|
||||
if (QString error; not piece->IsValid(error))
|
||||
{
|
||||
qCCritical(pWindow) << qPrintable(tr("Piece %1 invalid. %2").arg(piece->GetName(), error));
|
||||
|
||||
|
@ -3594,8 +3587,7 @@ auto VPMainWindow::on_actionSave_triggered() -> bool
|
|||
return false;
|
||||
}
|
||||
|
||||
QString error;
|
||||
if (not SaveLayout(curFile, error))
|
||||
if (QString error; not SaveLayout(curFile, error))
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
|
@ -3638,8 +3630,7 @@ auto VPMainWindow::on_actionSaveAs_triggered() -> bool
|
|||
return false;
|
||||
}
|
||||
|
||||
QFileInfo const f(fileName);
|
||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
if (QFileInfo const f(fileName); f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
{
|
||||
fileName += '.'_L1 + suffix;
|
||||
}
|
||||
|
@ -3667,8 +3658,7 @@ auto VPMainWindow::on_actionSaveAs_triggered() -> bool
|
|||
}
|
||||
|
||||
QString error;
|
||||
bool const result = SaveLayout(fileName, error);
|
||||
if (not result)
|
||||
if (bool const result = SaveLayout(fileName, error); not result)
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
|
@ -3749,8 +3739,7 @@ void VPMainWindow::on_SheetSizeChanged()
|
|||
{
|
||||
if (not m_layout.isNull())
|
||||
{
|
||||
VPSheetPtr const sheet = m_layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = m_layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
sheet->SetSheetSizeConverted(ui->doubleSpinBoxSheetPaperWidth->value(),
|
||||
ui->doubleSpinBoxSheetPaperHeight->value());
|
||||
|
@ -3777,8 +3766,7 @@ void VPMainWindow::on_SheetOrientationChanged(bool checked)
|
|||
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperWidth, height);
|
||||
SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPaperHeight, width);
|
||||
|
||||
VPSheetPtr const sheet = m_layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = m_layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
sheet->SetSheetSizeConverted(height, width); // NOLINT(readability-suspicious-call-argument)
|
||||
}
|
||||
|
@ -3796,8 +3784,7 @@ void VPMainWindow::on_SheetMarginChanged()
|
|||
{
|
||||
if (not m_layout.isNull())
|
||||
{
|
||||
VPSheetPtr const sheet = m_layout->GetFocusedSheet();
|
||||
if (not sheet.isNull())
|
||||
if (VPSheetPtr const sheet = m_layout->GetFocusedSheet(); not sheet.isNull())
|
||||
{
|
||||
sheet->SetSheetMarginsConverted(
|
||||
ui->doubleSpinBoxSheetMarginLeft->value(), ui->doubleSpinBoxSheetMarginTop->value(),
|
||||
|
@ -4711,8 +4698,7 @@ void VPMainWindow::AskDefaultSettings()
|
|||
|
||||
if (settings->IsAskCollectStatistic() || settings->IsAskSendCrashReport())
|
||||
{
|
||||
DialogAskCollectStatistic dialog(this);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
if (DialogAskCollectStatistic dialog(this); dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
settings->SetCollectStatistic(dialog.CollectStatistic());
|
||||
#if defined(CRASH_REPORTING)
|
||||
|
@ -4730,9 +4716,8 @@ void VPMainWindow::AskDefaultSettings()
|
|||
auto *statistic = VGAnalytics::Instance();
|
||||
statistic->SetGUILanguage(settings->GetLocale());
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
bool freshID = false;
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
|
|
@ -48,13 +48,13 @@ auto WatermarkImageFromCache(const VWatermarkData &watermarkData, const QString
|
|||
{
|
||||
QPixmap pixmap;
|
||||
QString const imagePath = AbsoluteMPath(watermarkPath, watermarkData.path);
|
||||
QString const imageCacheKey =
|
||||
QStringLiteral("puzzle=path%1+rotation%3+grayscale%4+xscale%5+yxcale%6")
|
||||
.arg(imagePath, QString::number(watermarkData.imageRotation), watermarkData.grayscale ? trueStr : falseStr)
|
||||
.arg(xScale)
|
||||
.arg(yScale);
|
||||
|
||||
if (not QPixmapCache::find(imageCacheKey, &pixmap))
|
||||
if (QString const imageCacheKey = QStringLiteral("puzzle=path%1+rotation%3+grayscale%4+xscale%5+yxcale%6")
|
||||
.arg(imagePath, QString::number(watermarkData.imageRotation),
|
||||
watermarkData.grayscale ? trueStr : falseStr)
|
||||
.arg(xScale)
|
||||
.arg(yScale);
|
||||
not QPixmapCache::find(imageCacheKey, &pixmap))
|
||||
{
|
||||
QImageReader imageReader(imagePath);
|
||||
QImage watermark = imageReader.read();
|
||||
|
@ -157,12 +157,6 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
|
|||
SCASSERT(painter != nullptr)
|
||||
SCASSERT(printer != nullptr)
|
||||
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (layout.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (sheet.isNull())
|
||||
{
|
||||
return;
|
||||
|
@ -260,8 +254,7 @@ auto VPTileFactory::RowNb(const VPSheetPtr &sheet) const -> int
|
|||
}
|
||||
|
||||
qreal yScale = 1;
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
yScale = layout->LayoutSettings().VerticalScale();
|
||||
}
|
||||
|
@ -279,8 +272,7 @@ auto VPTileFactory::ColNb(const VPSheetPtr &sheet) const -> int
|
|||
}
|
||||
|
||||
qreal xScale = 1;
|
||||
VPLayoutPtr const layout = m_layout.toStrongRef();
|
||||
if (not layout.isNull())
|
||||
if (VPLayoutPtr const layout = m_layout.toStrongRef(); not layout.isNull())
|
||||
{
|
||||
xScale = layout->LayoutSettings().HorizontalScale();
|
||||
}
|
||||
|
@ -700,11 +692,11 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
|
|||
}
|
||||
|
||||
QPixmap watermark;
|
||||
QString const imagePath =
|
||||
QStringLiteral("puzzle=colorScheme%1+path%2+opacity%3_broken")
|
||||
.arg(colorScheme, AbsoluteMPath(watermarkPath, watermarkData.path), QString::number(opacity));
|
||||
|
||||
if (not QPixmapCache::find(imagePath, &watermark))
|
||||
if (QString const imagePath =
|
||||
QStringLiteral("puzzle=colorScheme%1+path%2+opacity%3_broken")
|
||||
.arg(colorScheme, AbsoluteMPath(watermarkPath, watermarkData.path), QString::number(opacity));
|
||||
not QPixmapCache::find(imagePath, &watermark))
|
||||
{
|
||||
QScopedPointer<QSvgRenderer> const svgRenderer(new QSvgRenderer());
|
||||
|
||||
|
@ -734,9 +726,8 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
|
|||
|
||||
if (watermarkImage.isNull())
|
||||
{
|
||||
QPixmap const watermarkPixmap = BrokenImage();
|
||||
|
||||
if (watermarkPixmap.width() < img.width() && watermarkPixmap.height() < img.height())
|
||||
if (QPixmap const watermarkPixmap = BrokenImage();
|
||||
watermarkPixmap.width() < img.width() && watermarkPixmap.height() < img.height())
|
||||
{
|
||||
QRect imagePosition(0, 0, watermarkPixmap.width(), watermarkPixmap.height());
|
||||
imagePosition.translate(img.center().toPoint() - imagePosition.center());
|
||||
|
@ -754,9 +745,8 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
|
|||
qint64 const pixelSize = fileSize / watermarkImage.height() / watermarkImage.width();
|
||||
QSize const scaledSize(qRound(watermarkImage.width() / xScale), qRound(watermarkImage.height() / yScale));
|
||||
qint64 const scaledImageSize = pixelSize * scaledSize.width() * scaledSize.height() / 1024;
|
||||
int const limit = QPixmapCache::cacheLimit();
|
||||
|
||||
if (scaledImageSize > limit && (xScale < 1 || yScale < 1))
|
||||
if (int const limit = QPixmapCache::cacheLimit(); scaledImageSize > limit && (xScale < 1 || yScale < 1))
|
||||
{
|
||||
QScopedPointer<QSvgRenderer> const svgRenderer(new QSvgRenderer());
|
||||
|
||||
|
|
|
@ -65,8 +65,7 @@ namespace
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto StringToTransfrom(const QString &matrix) -> QTransform
|
||||
{
|
||||
QStringList const elements = matrix.split(ML::groupSep);
|
||||
if (elements.count() == 9)
|
||||
if (QStringList const elements = matrix.split(ML::groupSep); elements.count() == 9)
|
||||
{
|
||||
qreal const m11 = elements.at(0).toDouble();
|
||||
qreal const m12 = elements.at(1).toDouble();
|
||||
|
@ -86,8 +85,7 @@ auto StringToTransfrom(const QString &matrix) -> QTransform
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto StringToPoint(const QString &point) -> QPointF
|
||||
{
|
||||
QStringList const coordinates = point.split(ML::coordintatesSep);
|
||||
if (coordinates.count() == 2)
|
||||
if (QStringList const coordinates = point.split(ML::coordintatesSep); coordinates.count() == 2)
|
||||
{
|
||||
return {coordinates.at(0).toDouble(), coordinates.at(1).toDouble()};
|
||||
}
|
||||
|
@ -179,8 +177,7 @@ auto StringToGrainlineArrowDirrection(const QString &dirrection) -> GrainlineArr
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto StringToLine(const QString &string) -> QLineF
|
||||
{
|
||||
QStringList const points = string.split(ML::groupSep);
|
||||
if (points.count() == 2)
|
||||
if (QStringList const points = string.split(ML::groupSep); points.count() == 2)
|
||||
{
|
||||
return {StringToPoint(points.at(0)), StringToPoint(points.at(1))};
|
||||
}
|
||||
|
@ -210,8 +207,7 @@ auto StringToLines(const QString &string) -> QVector<QLineF>
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto StringToRect(const QString &string) -> QRectF
|
||||
{
|
||||
QStringList const points = string.split(ML::groupSep);
|
||||
if (points.count() == 4)
|
||||
if (QStringList const points = string.split(ML::groupSep); points.count() == 4)
|
||||
{
|
||||
return {points.at(0).toDouble(), points.at(1).toDouble(), points.at(2).toDouble(), points.at(3).toDouble()};
|
||||
}
|
||||
|
@ -478,8 +474,7 @@ void VPLayoutFileReader::ReadPieces(const VPLayoutPtr &layout, const VPSheetPtr
|
|||
VPPiecePtr const piece(new VPPiece());
|
||||
ReadPiece(piece);
|
||||
|
||||
QString error;
|
||||
if (not piece->IsValid(error))
|
||||
if (QString error; not piece->IsValid(error))
|
||||
{
|
||||
throw VException(tr("Piece %1 invalid. %2").arg(piece->GetName(), error));
|
||||
}
|
||||
|
@ -889,8 +884,8 @@ auto VPLayoutFileReader::ReadLabelLines() -> VTextManager
|
|||
QXmlStreamAttributes const attribs = attributes();
|
||||
text.SetFont(FontFromString(ReadAttributeEmptyString(attribs, ML::AttrFont)));
|
||||
|
||||
QStringList const svgFontData = ReadAttributeEmptyString(attribs, ML::AttrSVGFont).split(',');
|
||||
if (!svgFontData.isEmpty())
|
||||
if (QStringList const svgFontData = ReadAttributeEmptyString(attribs, ML::AttrSVGFont).split(',');
|
||||
!svgFontData.isEmpty())
|
||||
{
|
||||
text.SetSVGFontFamily(svgFontData.constFirst());
|
||||
|
||||
|
@ -968,8 +963,8 @@ void VPLayoutFileReader::ReadMirrorLines(const VPPiecePtr &piece)
|
|||
piece->SetFoldLineLabel(ReadAttributeEmptyString(attribs, ML::AttrFoldLineLabel));
|
||||
piece->SetFoldLineOutlineFont(FontFromString(ReadAttributeEmptyString(attribs, ML::AttrFont)));
|
||||
|
||||
QStringList const svgFontData = ReadAttributeEmptyString(attribs, ML::AttrSVGFont).split(','_L1);
|
||||
if (!svgFontData.isEmpty())
|
||||
if (QStringList const svgFontData = ReadAttributeEmptyString(attribs, ML::AttrSVGFont).split(','_L1);
|
||||
!svgFontData.isEmpty())
|
||||
{
|
||||
piece->SetFoldLineSVGFontFamily(svgFontData.constFirst());
|
||||
|
||||
|
|
|
@ -380,8 +380,8 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
|
|||
writeEndElement();
|
||||
|
||||
QLineF const seamMirrorLine = piece->GetSeamMirrorLine();
|
||||
QLineF const seamAllowenceMirrorLine = piece->GetSeamAllowanceMirrorLine();
|
||||
if (!seamMirrorLine.isNull() || !seamAllowenceMirrorLine.isNull())
|
||||
if (QLineF const seamAllowenceMirrorLine = piece->GetSeamAllowanceMirrorLine();
|
||||
!seamMirrorLine.isNull() || !seamAllowenceMirrorLine.isNull())
|
||||
{
|
||||
writeStartElement(ML::TagMirrorLine);
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ auto TapePreferencesConfigurationPage::Apply() -> QStringList
|
|||
|
||||
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
|
||||
|
||||
auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt());
|
||||
if (settings->GetThemeMode() != themeMode)
|
||||
if (auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt());
|
||||
settings->GetThemeMode() != themeMode)
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
|
|
|
@ -118,8 +118,7 @@ void TapePreferencesPathPage::EditPath()
|
|||
}
|
||||
|
||||
bool usedNotExistedDir = false;
|
||||
QDir const directory(path);
|
||||
if (not directory.exists())
|
||||
if (QDir const directory(path); not directory.exists())
|
||||
{
|
||||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ void DialogDimensionLabels::changeEvent(QEvent *event)
|
|||
|
||||
InitDimensions();
|
||||
|
||||
int const index = ui->comboBoxDimensionLabels->findData(static_cast<int>(type));
|
||||
if (index != -1)
|
||||
if (int const index = ui->comboBoxDimensionLabels->findData(static_cast<int>(type)); index != -1)
|
||||
{
|
||||
ui->comboBoxDimensionLabels->blockSignals(true);
|
||||
ui->comboBoxDimensionLabels->setCurrentIndex(index);
|
||||
|
|
|
@ -488,8 +488,7 @@ void DialogKnownMeasurementsCSVColumns::CheckStatus()
|
|||
|
||||
QSharedPointer<QxtCsvModel> const csv = DialogKnownMeasurementsCSVColumns::CSVModel();
|
||||
|
||||
const int columns = csv->columnCount();
|
||||
if (columns < MinimumColumns())
|
||||
if (const int columns = csv->columnCount(); columns < MinimumColumns())
|
||||
{
|
||||
SetStatus(false);
|
||||
ui->labelStatus->setText(
|
||||
|
@ -497,8 +496,7 @@ void DialogKnownMeasurementsCSVColumns::CheckStatus()
|
|||
return;
|
||||
}
|
||||
|
||||
const int rows = csv->rowCount();
|
||||
if (rows < 1)
|
||||
if (const int rows = csv->rowCount(); rows < 1)
|
||||
{
|
||||
SetStatus(false);
|
||||
ui->labelStatus->setText(
|
||||
|
|
|
@ -88,8 +88,7 @@ auto DialogMDataBase::GetNewNames() const -> QStringList
|
|||
QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked);
|
||||
while (*it)
|
||||
{
|
||||
const QString name = (*it)->data(0, Qt::UserRole).toString();
|
||||
if (not m_usedMeasurements.contains(name))
|
||||
if (const QString name = (*it)->data(0, Qt::UserRole).toString(); not m_usedMeasurements.contains(name))
|
||||
{
|
||||
newNames.append(name);
|
||||
}
|
||||
|
@ -305,8 +304,8 @@ void DialogMDataBase::InitDataBase(const QStringList &usedMeasurements)
|
|||
VKnownMeasurementsDatabase *db = MApplication::VApp()->KnownMeasurementsDatabase();
|
||||
VKnownMeasurements const knownDB = db->KnownMeasurements(m_knownId);
|
||||
|
||||
QMap<int, VKnownMeasurement> const measurements = knownDB.OrderedGroupMeasurements(QString());
|
||||
if (!measurements.isEmpty())
|
||||
if (QMap<int, VKnownMeasurement> const measurements = knownDB.OrderedGroupMeasurements(QString());
|
||||
!measurements.isEmpty())
|
||||
{
|
||||
m_generalGroup = InitGroup(tr("General", "Measurement section"), measurements, usedMeasurements);
|
||||
m_groups.append(m_generalGroup);
|
||||
|
|
|
@ -840,16 +840,14 @@ void DialogMeasurementsCSVColumns::CheckStatus()
|
|||
|
||||
QSharedPointer<QxtCsvModel> const csv = DialogMeasurementsCSVColumns::CSVModel();
|
||||
|
||||
const int columns = csv->columnCount();
|
||||
if (columns < MinimumColumns())
|
||||
if (const int columns = csv->columnCount(); columns < MinimumColumns())
|
||||
{
|
||||
SetStatus(false);
|
||||
ui->labelStatus->setText(QCoreApplication::translate("DialogMeasurementsCSVColumns", "Not enough columns"));
|
||||
return;
|
||||
}
|
||||
|
||||
const int rows = csv->rowCount();
|
||||
if (rows < 1)
|
||||
if (const int rows = csv->rowCount(); rows < 1)
|
||||
{
|
||||
SetStatus(false);
|
||||
ui->labelStatus->setText(
|
||||
|
|
|
@ -94,8 +94,7 @@ void DialogTapePreferences::showEvent(QShowEvent *event)
|
|||
}
|
||||
// do your init stuff here
|
||||
|
||||
QSize const sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize();
|
||||
if (not sz.isEmpty())
|
||||
if (QSize const sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize(); not sz.isEmpty())
|
||||
{
|
||||
resize(sz);
|
||||
}
|
||||
|
|
|
@ -189,8 +189,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
|
|||
}
|
||||
|
||||
QString logMsg = msg;
|
||||
const bool isWarningMessage = VAbstractApplication::VApp()->IsWarningMessage(msg);
|
||||
if (isWarningMessage)
|
||||
if (const bool isWarningMessage = VAbstractApplication::VApp()->IsWarningMessage(msg); isWarningMessage)
|
||||
{
|
||||
logMsg = logMsg.remove(VAbstractApplication::warningMessageSignature);
|
||||
}
|
||||
|
@ -546,8 +545,7 @@ auto MApplication::event(QEvent *e) -> bool
|
|||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
|
||||
auto *fileOpenEvent = static_cast<QFileOpenEvent *>(e);
|
||||
const QString macFileOpen = fileOpenEvent->file();
|
||||
if (not macFileOpen.isEmpty())
|
||||
if (const QString macFileOpen = fileOpenEvent->file(); not macFileOpen.isEmpty())
|
||||
{
|
||||
if (macFileOpen.endsWith(".vkm"_L1))
|
||||
{
|
||||
|
@ -665,9 +663,8 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
|||
}
|
||||
|
||||
const QStringList args = parser.positionalArguments();
|
||||
bool const success = !args.isEmpty() ? StartWithFiles(parser) : SingleStart(parser);
|
||||
|
||||
if (not success)
|
||||
if (bool const success = !args.isEmpty() ? StartWithFiles(parser) : SingleStart(parser); not success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -867,8 +864,8 @@ void MApplication::NewLocalSocketConnection()
|
|||
}
|
||||
socket->waitForReadyRead(1000);
|
||||
QTextStream stream(socket);
|
||||
const QString arg = stream.readAll();
|
||||
if (not arg.isEmpty())
|
||||
|
||||
if (const QString arg = stream.readAll(); not arg.isEmpty())
|
||||
{
|
||||
ParseCommandLine(SocketConnection::Server, arg.split(QStringLiteral(";;")));
|
||||
}
|
||||
|
|
|
@ -184,9 +184,9 @@ auto TKMMainWindow::LoadFile(const QString &path) -> bool
|
|||
|
||||
// Check if file already opened
|
||||
const QList<TKMMainWindow *> list = MApplication::VApp()->MainKMWindows();
|
||||
auto w =
|
||||
std::find_if(list.begin(), list.end(), [path](TKMMainWindow *window) { return window->CurrentFile() == path; });
|
||||
if (w != list.end())
|
||||
if (auto w = std::find_if(list.begin(), list.end(),
|
||||
[path](TKMMainWindow *window) { return window->CurrentFile() == path; });
|
||||
w != list.end())
|
||||
{
|
||||
(*w)->activateWindow();
|
||||
close();
|
||||
|
@ -211,13 +211,11 @@ auto TKMMainWindow::LoadFile(const QString &path) -> bool
|
|||
m_m = new VKnownMeasurementsDocument();
|
||||
m_m->setXMLContent(converter.Convert());
|
||||
|
||||
VCommonSettings *settings = VAbstractApplication::VApp()->Settings();
|
||||
if (settings->IsCollectStatistic())
|
||||
if (VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); settings->IsCollectStatistic())
|
||||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -296,8 +294,7 @@ void TKMMainWindow::UpdateWindowTitle()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto index = MApplication::VApp()->MainKMWindows().indexOf(this);
|
||||
if (index != -1)
|
||||
if (auto index = MApplication::VApp()->MainKMWindows().indexOf(this); index != -1)
|
||||
{
|
||||
showName = tr("untitled %1").arg(index + 1);
|
||||
}
|
||||
|
@ -384,8 +381,7 @@ void TKMMainWindow::changeEvent(QEvent *event)
|
|||
|
||||
InitMeasurementDiagramList();
|
||||
|
||||
int const i = ui->comboBoxDiagram->findData(current);
|
||||
if (i != -1)
|
||||
if (int const i = ui->comboBoxDiagram->findData(current); i != -1)
|
||||
{
|
||||
ui->comboBoxDiagram->setCurrentIndex(i);
|
||||
}
|
||||
|
@ -554,8 +550,7 @@ auto TKMMainWindow::FileSave() -> bool
|
|||
return false;
|
||||
}
|
||||
|
||||
QString error;
|
||||
if (not SaveKnownMeasurements(m_curFile, error))
|
||||
if (QString error; not SaveKnownMeasurements(m_curFile, error))
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
|
@ -586,8 +581,7 @@ auto TKMMainWindow::FileSaveAs() -> bool
|
|||
VTapeSettings *settings = MApplication::VApp()->TapeSettings();
|
||||
const QString dir = settings->GetPathKnownMeasurements();
|
||||
|
||||
QDir const directory(dir);
|
||||
if (not directory.exists())
|
||||
if (QDir const directory(dir); not directory.exists())
|
||||
{
|
||||
directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
@ -605,8 +599,7 @@ auto TKMMainWindow::FileSaveAs() -> bool
|
|||
return false;
|
||||
}
|
||||
|
||||
QFileInfo const f(fileName);
|
||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
if (QFileInfo const f(fileName); f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
{
|
||||
fileName += '.'_L1 + suffix;
|
||||
}
|
||||
|
@ -630,8 +623,7 @@ auto TKMMainWindow::FileSaveAs() -> bool
|
|||
m_mIsReadOnly = false;
|
||||
|
||||
QString error;
|
||||
bool const result = SaveKnownMeasurements(fileName, error);
|
||||
if (not result)
|
||||
if (bool const result = SaveKnownMeasurements(fileName, error); not result)
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
|
@ -710,8 +702,7 @@ void TKMMainWindow::ImportDataFromCSV()
|
|||
return;
|
||||
}
|
||||
|
||||
QFileInfo const f(fileName);
|
||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
if (QFileInfo const f(fileName); f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
{
|
||||
fileName += '.'_L1 + suffix;
|
||||
}
|
||||
|
@ -1001,8 +992,7 @@ void TKMMainWindow::SaveImage()
|
|||
}
|
||||
QString path = settings->GetPathCustomImage() + QDir::separator() + title;
|
||||
|
||||
QStringList const suffixes = mime.suffixes();
|
||||
if (not suffixes.isEmpty())
|
||||
if (QStringList const suffixes = mime.suffixes(); not suffixes.isEmpty())
|
||||
{
|
||||
path += '.'_L1 + suffixes.at(0);
|
||||
}
|
||||
|
@ -1058,8 +1048,7 @@ void TKMMainWindow::ShowImage()
|
|||
QMimeType const mime = image.MimeTypeFromData();
|
||||
QString name = QDir::tempPath() + QDir::separator() + "image.XXXXXX"_L1;
|
||||
|
||||
QStringList const suffixes = mime.suffixes();
|
||||
if (not suffixes.isEmpty())
|
||||
if (QStringList const suffixes = mime.suffixes(); not suffixes.isEmpty())
|
||||
{
|
||||
name += '.'_L1 + suffixes.at(0);
|
||||
}
|
||||
|
@ -1243,8 +1232,7 @@ void TKMMainWindow::SaveMName()
|
|||
|
||||
QString newName = ui->lineEditName->text().isEmpty() ? GenerateMeasurementName() : ui->lineEditName->text();
|
||||
|
||||
QHash<QString, VKnownMeasurement> const m = m_known.Measurements();
|
||||
if (m.contains(newName))
|
||||
if (QHash<QString, VKnownMeasurement> const m = m_known.Measurements(); m.contains(newName))
|
||||
{
|
||||
qint32 num = 2;
|
||||
QString name = newName;
|
||||
|
@ -1515,8 +1503,7 @@ void TKMMainWindow::AskDefaultSettings()
|
|||
|
||||
if (settings->IsAskCollectStatistic() || settings->IsAskSendCrashReport())
|
||||
{
|
||||
DialogAskCollectStatistic dialog(this);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
if (DialogAskCollectStatistic dialog(this); dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
settings->SetCollectStatistic(dialog.CollectStatistic());
|
||||
#if defined(CRASH_REPORTING)
|
||||
|
@ -1534,9 +1521,8 @@ void TKMMainWindow::AskDefaultSettings()
|
|||
auto *statistic = VGAnalytics::Instance();
|
||||
statistic->SetGUILanguage(settings->GetLocale());
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
bool freshID = false;
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -1948,9 +1934,8 @@ auto TKMMainWindow::MaybeSave() -> bool
|
|||
|
||||
messageBox->setWindowModality(Qt::ApplicationModal);
|
||||
messageBox->setFixedSize(300, 85);
|
||||
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
|
||||
|
||||
switch (ret)
|
||||
switch (static_cast<QMessageBox::StandardButton>(messageBox->exec()))
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
if (m_mIsReadOnly)
|
||||
|
@ -2051,8 +2036,7 @@ void TKMMainWindow::InitIcons()
|
|||
ui->toolButtonAddImage->setIcon(VTheme::GetIconResource(iconResource, QStringLiteral("16x16/insert-image.png")));
|
||||
ui->toolButtonRemoveImage->setIcon(VTheme::GetIconResource(iconResource, QStringLiteral("16x16/remove-image.png")));
|
||||
|
||||
int const index = ui->tabWidget->indexOf(ui->tabImages);
|
||||
if (index != -1)
|
||||
if (int const index = ui->tabWidget->indexOf(ui->tabImages); index != -1)
|
||||
{
|
||||
ui->tabWidget->setTabIcon(index, VTheme::GetIconResource(iconResource, QStringLiteral("16x16/viewimage.png")));
|
||||
}
|
||||
|
@ -2166,8 +2150,7 @@ void TKMMainWindow::CreateWindowMenu(QMenu *menu)
|
|||
TKMMainWindow *window = windows.at(i);
|
||||
|
||||
QString title = QStringLiteral("%1. %2").arg(i + 1).arg(window->windowTitle());
|
||||
const auto index = title.lastIndexOf("[*]"_L1);
|
||||
if (index != -1)
|
||||
if (const auto index = title.lastIndexOf("[*]"_L1); index != -1)
|
||||
{
|
||||
window->isWindowModified() ? title.replace(index, 3, '*'_L1) : title.replace(index, 3, QString());
|
||||
}
|
||||
|
@ -2458,8 +2441,7 @@ void TKMMainWindow::InitMeasurementUnits()
|
|||
ui->comboBoxMUnits->addItem(tr("Length units"), QVariant(static_cast<int>(MUnits::Table)));
|
||||
ui->comboBoxMUnits->addItem(tr("Degrees"), QVariant(static_cast<int>(MUnits::Degrees)));
|
||||
|
||||
int const i = ui->comboBoxMUnits->findData(current);
|
||||
if (i != -1)
|
||||
if (int const i = ui->comboBoxMUnits->findData(current); i != -1)
|
||||
{
|
||||
ui->comboBoxMUnits->setCurrentIndex(i);
|
||||
}
|
||||
|
@ -2527,8 +2509,7 @@ auto TKMMainWindow::CheckMName(const QString &name, const QSet<QString> &importe
|
|||
throw VException(tr("Imported file must not contain the same name twice."));
|
||||
}
|
||||
|
||||
QRegularExpression const rx(NameRegExp(VariableRegex::KnownMeasurement));
|
||||
if (not rx.match(name).hasMatch())
|
||||
if (QRegularExpression const rx(NameRegExp(VariableRegex::KnownMeasurement)); not rx.match(name).hasMatch())
|
||||
{
|
||||
throw VException(tr("Measurement '%1' doesn't match regex pattern.").arg(name));
|
||||
}
|
||||
|
@ -2588,26 +2569,24 @@ auto TKMMainWindow::ReadCSV(const QxtCsvModel &csv, const QVector<int> &map, boo
|
|||
importedNames.insert(mName);
|
||||
measurement.name = mName;
|
||||
|
||||
const int nameGroup = map.at(static_cast<int>(KnownMeasurementsColumns::Group));
|
||||
if (nameGroup >= 0)
|
||||
if (const int nameGroup = map.at(static_cast<int>(KnownMeasurementsColumns::Group)); nameGroup >= 0)
|
||||
{
|
||||
measurement.group = csv.text(i, nameGroup).simplified();
|
||||
}
|
||||
|
||||
const int nameFullName = map.at(static_cast<int>(KnownMeasurementsColumns::FullName));
|
||||
if (nameFullName >= 0)
|
||||
if (const int nameFullName = map.at(static_cast<int>(KnownMeasurementsColumns::FullName));
|
||||
nameFullName >= 0)
|
||||
{
|
||||
measurement.fullName = csv.text(i, nameFullName);
|
||||
}
|
||||
|
||||
const int nameFormula = map.at(static_cast<int>(KnownMeasurementsColumns::Formula));
|
||||
if (nameFormula >= 0)
|
||||
if (const int nameFormula = map.at(static_cast<int>(KnownMeasurementsColumns::Formula)); nameFormula >= 0)
|
||||
{
|
||||
measurement.formula = csv.text(i, nameFormula);
|
||||
}
|
||||
|
||||
const int nameDescription = map.at(static_cast<int>(KnownMeasurementsColumns::Description));
|
||||
if (nameDescription >= 0)
|
||||
if (const int nameDescription = map.at(static_cast<int>(KnownMeasurementsColumns::Description));
|
||||
nameDescription >= 0)
|
||||
{
|
||||
measurement.description = csv.text(i, nameDescription);
|
||||
}
|
||||
|
|
|
@ -333,16 +333,13 @@ auto TMainWindow::CurrentFile() const -> QString
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::SetDimensionABase(qreal base)
|
||||
{
|
||||
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values();
|
||||
|
||||
if (dimensions.isEmpty())
|
||||
if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.isEmpty())
|
||||
{
|
||||
qCWarning(tMainWindow, "%s\n", qPrintable(tr("The table doesn't provide dimensions")));
|
||||
return;
|
||||
}
|
||||
|
||||
const qint32 i = m_gradationDimensionA->findData(base);
|
||||
if (i != -1)
|
||||
if (const qint32 i = m_gradationDimensionA->findData(base); i != -1)
|
||||
{
|
||||
m_gradationDimensionA->setCurrentIndex(i);
|
||||
}
|
||||
|
@ -357,16 +354,13 @@ void TMainWindow::SetDimensionABase(qreal base)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::SetDimensionBBase(qreal base)
|
||||
{
|
||||
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values();
|
||||
|
||||
if (dimensions.size() <= 1)
|
||||
if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.size() <= 1)
|
||||
{
|
||||
qCWarning(tMainWindow, "%s\n", qPrintable(tr("The table doesn't support dimension B")));
|
||||
return;
|
||||
}
|
||||
|
||||
const qint32 i = m_gradationDimensionB->findData(base);
|
||||
if (i != -1)
|
||||
if (const qint32 i = m_gradationDimensionB->findData(base); i != -1)
|
||||
{
|
||||
m_gradationDimensionB->setCurrentIndex(i);
|
||||
}
|
||||
|
@ -381,16 +375,13 @@ void TMainWindow::SetDimensionBBase(qreal base)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::SetDimensionCBase(qreal base)
|
||||
{
|
||||
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values();
|
||||
|
||||
if (dimensions.size() <= 2)
|
||||
if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.size() <= 2)
|
||||
{
|
||||
qCWarning(tMainWindow, "%s\n", qPrintable(tr("The table doesn't support dimension C")));
|
||||
return;
|
||||
}
|
||||
|
||||
const qint32 i = m_gradationDimensionC->findData(base);
|
||||
if (i != -1)
|
||||
if (const qint32 i = m_gradationDimensionC->findData(base); i != -1)
|
||||
{
|
||||
m_gradationDimensionC->setCurrentIndex(i);
|
||||
}
|
||||
|
@ -430,9 +421,9 @@ auto TMainWindow::LoadFile(const QString &path) -> bool
|
|||
|
||||
// Check if file already opened
|
||||
const QList<TMainWindow *> list = MApplication::VApp()->MainTapeWindows();
|
||||
auto w =
|
||||
std::find_if(list.begin(), list.end(), [path](TMainWindow *window) { return window->CurrentFile() == path; });
|
||||
if (w != list.end())
|
||||
if (auto w = std::find_if(list.begin(), list.end(),
|
||||
[path](TMainWindow *window) { return window->CurrentFile() == path; });
|
||||
w != list.end())
|
||||
{
|
||||
(*w)->activateWindow();
|
||||
close();
|
||||
|
@ -475,8 +466,7 @@ auto TMainWindow::LoadFile(const QString &path) -> bool
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -501,8 +491,7 @@ auto TMainWindow::LoadFile(const QString &path) -> bool
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -865,8 +854,7 @@ void TMainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int
|
|||
{
|
||||
columns = 5;
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values();
|
||||
if (dimensions.size() > 1)
|
||||
if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.size() > 1)
|
||||
{
|
||||
columns += qMin(static_cast<int>(dimensions.size()), 2);
|
||||
}
|
||||
|
@ -932,8 +920,7 @@ auto TMainWindow::FileSave() -> bool
|
|||
return false;
|
||||
}
|
||||
|
||||
QString error;
|
||||
if (not SaveMeasurements(m_curFile, error))
|
||||
if (QString error; not SaveMeasurements(m_curFile, error))
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
|
@ -993,8 +980,7 @@ auto TMainWindow::FileSaveAs() -> bool
|
|||
return false;
|
||||
}
|
||||
|
||||
QFileInfo const f(fileName);
|
||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
if (QFileInfo const f(fileName); f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
{
|
||||
fileName += '.'_L1 + suffix;
|
||||
}
|
||||
|
@ -1026,8 +1012,7 @@ auto TMainWindow::FileSaveAs() -> bool
|
|||
m_mIsReadOnly = false;
|
||||
|
||||
QString error;
|
||||
bool const result = SaveMeasurements(fileName, error);
|
||||
if (not result)
|
||||
if (bool const result = SaveMeasurements(fileName, error); not result)
|
||||
{
|
||||
QMessageBox messageBox;
|
||||
messageBox.setIcon(QMessageBox::Warning);
|
||||
|
@ -1114,8 +1099,7 @@ void TMainWindow::ImportDataFromCSV()
|
|||
return;
|
||||
}
|
||||
|
||||
QFileInfo const f(fileName);
|
||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
if (QFileInfo const f(fileName); f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
{
|
||||
fileName += '.'_L1 + suffix;
|
||||
}
|
||||
|
@ -1556,9 +1540,7 @@ void TMainWindow::RemoveImage()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::SaveImage()
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
|
||||
if (row == -1)
|
||||
if (const int row = ui->tableWidget->currentRow(); row == -1)
|
||||
{
|
||||
ui->toolButtonSaveImage->setDisabled(true);
|
||||
return;
|
||||
|
@ -1593,8 +1575,7 @@ void TMainWindow::SaveImage()
|
|||
QMimeType const mime = image.MimeTypeFromData();
|
||||
QString path = settings->GetPathCustomImage() + QDir::separator() + tr("untitled");
|
||||
|
||||
QStringList const suffixes = mime.suffixes();
|
||||
if (not suffixes.isEmpty())
|
||||
if (QStringList const suffixes = mime.suffixes(); not suffixes.isEmpty())
|
||||
{
|
||||
path += '.'_L1 + suffixes.at(0);
|
||||
}
|
||||
|
@ -1624,9 +1605,7 @@ void TMainWindow::SaveImage()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::ShowImage()
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
|
||||
if (row == -1)
|
||||
if (const int row = ui->tableWidget->currentRow(); row == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1658,8 +1637,7 @@ void TMainWindow::ShowImage()
|
|||
QMimeType const mime = image.MimeTypeFromData();
|
||||
QString name = QDir::tempPath() + QDir::separator() + "image.XXXXXX"_L1;
|
||||
|
||||
QStringList const suffixes = mime.suffixes();
|
||||
if (not suffixes.isEmpty())
|
||||
if (QStringList const suffixes = mime.suffixes(); not suffixes.isEmpty())
|
||||
{
|
||||
name += '.'_L1 + suffixes.at(0);
|
||||
}
|
||||
|
@ -1713,8 +1691,7 @@ void TMainWindow::AddKnown()
|
|||
{
|
||||
if (m_m->KnownMeasurements().isNull())
|
||||
{
|
||||
DialogNoKnownMeasurements dialog(this);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
if (DialogNoKnownMeasurements dialog(this); dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
MApplication::VApp()->NewMainKMWindow();
|
||||
}
|
||||
|
@ -1829,8 +1806,7 @@ void TMainWindow::ImportFromPattern()
|
|||
return;
|
||||
}
|
||||
|
||||
VLockGuard<char> const tmp(mPath);
|
||||
if (not tmp.IsLocked())
|
||||
if (VLockGuard<char> const tmp(mPath); not tmp.IsLocked())
|
||||
{
|
||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("This file already opened in another window.")));
|
||||
return;
|
||||
|
@ -1849,8 +1825,7 @@ void TMainWindow::ImportFromPattern()
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -1908,8 +1883,7 @@ void TMainWindow::DimensionABaseChanged()
|
|||
{
|
||||
m_currentDimensionA = m_gradationDimensionA->currentData().toDouble();
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values();
|
||||
if (dimensions.size() > 1)
|
||||
if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.size() > 1)
|
||||
{
|
||||
MeasurementDimension_p dimension = dimensions.at(1);
|
||||
InitDimensionGradation(1, dimension, m_gradationDimensionB);
|
||||
|
@ -1929,9 +1903,7 @@ void TMainWindow::DimensionBBaseChanged()
|
|||
{
|
||||
m_currentDimensionB = m_gradationDimensionB->currentData().toDouble();
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values();
|
||||
|
||||
if (dimensions.size() > 2)
|
||||
if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); dimensions.size() > 2)
|
||||
{
|
||||
const MeasurementDimension_p &dimension = dimensions.at(2);
|
||||
InitDimensionGradation(2, dimension, m_gradationDimensionC);
|
||||
|
@ -2282,8 +2254,7 @@ void TMainWindow::SaveMValue()
|
|||
|
||||
QString const text = ui->plainTextEditFormula->toPlainText();
|
||||
|
||||
QTableWidgetItem *formulaField = ui->tableWidget->item(row, ColumnFormula);
|
||||
if (formulaField->text() == text)
|
||||
if (QTableWidgetItem *formulaField = ui->tableWidget->item(row, ColumnFormula); formulaField->text() == text)
|
||||
{
|
||||
QTableWidgetItem *result = ui->tableWidget->item(row, ColumnCalcValue);
|
||||
const QString postfix = UnitsToStr(m_mUnit); // Show unit in dialog lable (cm, mm or inch)
|
||||
|
@ -2625,8 +2596,7 @@ void TMainWindow::ExportToIndividual()
|
|||
}
|
||||
|
||||
QString const suffix = QStringLiteral("vit");
|
||||
QFileInfo const f(fileName);
|
||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
if (QFileInfo const f(fileName); f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
{
|
||||
fileName += '.'_L1 + suffix;
|
||||
}
|
||||
|
@ -2790,8 +2760,7 @@ void TMainWindow::AskDefaultSettings()
|
|||
|
||||
if (settings->IsAskCollectStatistic() || settings->IsAskSendCrashReport())
|
||||
{
|
||||
DialogAskCollectStatistic dialog(this);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
if (DialogAskCollectStatistic dialog(this); dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
settings->SetCollectStatistic(dialog.CollectStatistic());
|
||||
#if defined(CRASH_REPORTING)
|
||||
|
@ -2809,9 +2778,8 @@ void TMainWindow::AskDefaultSettings()
|
|||
auto *statistic = VGAnalytics::Instance();
|
||||
statistic->SetGUILanguage(settings->GetLocale());
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
bool freshID = false;
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -3142,8 +3110,7 @@ void TMainWindow::InitMenu()
|
|||
separator->setSeparator(true);
|
||||
ui->menuMeasurements->insertAction(ui->actionUseFullCircumference, separator);
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values();
|
||||
if (not dimensions.empty())
|
||||
if (const QList<MeasurementDimension_p> dimensions = m_m->Dimensions().values(); not dimensions.empty())
|
||||
{
|
||||
ui->actionRestrictFirstDimension->setVisible(true);
|
||||
ui->actionRestrictFirstDimension->setEnabled(true);
|
||||
|
@ -3398,8 +3365,7 @@ void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString
|
|||
SCASSERT(table != nullptr)
|
||||
|
||||
QString header = table->horizontalHeaderItem(column)->text();
|
||||
const auto index = header.indexOf('('_L1);
|
||||
if (index != -1)
|
||||
if (const auto index = header.indexOf('('_L1); index != -1)
|
||||
{
|
||||
header.remove(index - 1, 100);
|
||||
}
|
||||
|
@ -3491,9 +3457,8 @@ auto TMainWindow::MaybeSave() -> bool
|
|||
|
||||
messageBox->setWindowModality(Qt::ApplicationModal);
|
||||
messageBox->setFixedSize(300, 85);
|
||||
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
|
||||
|
||||
switch (ret)
|
||||
switch (static_cast<QMessageBox::StandardButton>(messageBox->exec()))
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
if (m_mIsReadOnly)
|
||||
|
@ -3815,8 +3780,7 @@ void TMainWindow::UpdateWindowTitle()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto index = MApplication::VApp()->MainTapeWindows().indexOf(this);
|
||||
if (index != -1)
|
||||
if (auto index = MApplication::VApp()->MainTapeWindows().indexOf(this); index != -1)
|
||||
{
|
||||
showName = tr("untitled %1").arg(index + 1);
|
||||
}
|
||||
|
@ -3923,8 +3887,7 @@ void TMainWindow::SyncKnownMeasurements()
|
|||
auto TMainWindow::ClearCustomName(const QString &name) -> QString
|
||||
{
|
||||
QString clear = name;
|
||||
const auto index = clear.indexOf(CustomMSign);
|
||||
if (index == 0)
|
||||
if (const auto index = clear.indexOf(CustomMSign); index == 0)
|
||||
{
|
||||
clear.remove(0, 1);
|
||||
}
|
||||
|
@ -4122,9 +4085,9 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool
|
|||
|
||||
// Check if file already opened
|
||||
const QList<TMainWindow *> list = MApplication::VApp()->MainTapeWindows();
|
||||
auto w =
|
||||
std::find_if(list.begin(), list.end(), [path](TMainWindow *window) { return window->CurrentFile() == path; });
|
||||
if (w != list.end())
|
||||
if (auto w = std::find_if(list.begin(), list.end(),
|
||||
[path](TMainWindow *window) { return window->CurrentFile() == path; });
|
||||
w != list.end())
|
||||
{
|
||||
(*w)->activateWindow();
|
||||
close();
|
||||
|
@ -4234,8 +4197,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
|
|||
TMainWindow *window = windows.at(i);
|
||||
|
||||
QString title = QStringLiteral("%1. %2").arg(i + 1).arg(window->windowTitle());
|
||||
const auto index = title.lastIndexOf("[*]"_L1);
|
||||
if (index != -1)
|
||||
if (const auto index = title.lastIndexOf("[*]"_L1); index != -1)
|
||||
{
|
||||
window->isWindowModified() ? title.replace(index, 3, '*'_L1) : title.replace(index, 3, QString());
|
||||
}
|
||||
|
@ -4308,8 +4270,7 @@ auto TMainWindow::CheckMName(const QString &name, const QSet<QString> &importedN
|
|||
throw VException(tr("Imported file must not contain the same name twice."));
|
||||
}
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (not rx.match(name).hasMatch())
|
||||
if (QRegularExpression const rx(NameRegExp()); not rx.match(name).hasMatch())
|
||||
{
|
||||
throw VException(tr("Measurement '%1' doesn't match regex pattern.").arg(name));
|
||||
}
|
||||
|
@ -4433,9 +4394,7 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVector<int> &map, bool withHeader)
|
||||
{
|
||||
const int columns = csv.columnCount();
|
||||
|
||||
if (columns < 4)
|
||||
if (const int columns = csv.columnCount(); columns < 4)
|
||||
{
|
||||
ShowError(tr("Multisize measurements require at least 4 columns."));
|
||||
return;
|
||||
|
@ -4576,8 +4535,7 @@ void TMainWindow::SetCurrentPatternUnit()
|
|||
if (m_comboBoxUnits)
|
||||
{
|
||||
m_comboBoxUnits->blockSignals(true);
|
||||
const qint32 indexUnit = m_comboBoxUnits->findData(static_cast<int>(m_pUnit));
|
||||
if (indexUnit != -1)
|
||||
if (const qint32 indexUnit = m_comboBoxUnits->findData(static_cast<int>(m_pUnit)); indexUnit != -1)
|
||||
{
|
||||
m_comboBoxUnits->setCurrentIndex(indexUnit);
|
||||
}
|
||||
|
@ -4796,8 +4754,7 @@ void TMainWindow::InitKnownMeasurements(QComboBox *combo)
|
|||
return;
|
||||
}
|
||||
|
||||
QUuid const kmId = m_m->KnownMeasurements();
|
||||
if (!kmId.isNull() && !known.contains(kmId))
|
||||
if (QUuid const kmId = m_m->KnownMeasurements(); !kmId.isNull() && !known.contains(kmId))
|
||||
{
|
||||
combo->addItem(tr("Invalid link"), kmId);
|
||||
}
|
||||
|
@ -5124,8 +5081,7 @@ void TMainWindow::InitMeasurementUnits()
|
|||
ui->comboBoxMUnits->addItem(units, QVariant(static_cast<int>(MUnits::Table)));
|
||||
ui->comboBoxMUnits->addItem(tr("Degrees"), QVariant(static_cast<int>(MUnits::Degrees)));
|
||||
|
||||
int const i = ui->comboBoxMUnits->findData(current);
|
||||
if (i != -1)
|
||||
if (int const i = ui->comboBoxMUnits->findData(current); i != -1)
|
||||
{
|
||||
ui->comboBoxMUnits->setCurrentIndex(i);
|
||||
}
|
||||
|
@ -5161,8 +5117,7 @@ void TMainWindow::InitMeasurementDimension()
|
|||
ui->comboBoxDimension->addItem(VMeasurements::IMDName(IMD::W), QVariant(static_cast<int>(IMD::W)));
|
||||
ui->comboBoxDimension->addItem(VMeasurements::IMDName(IMD::Z), QVariant(static_cast<int>(IMD::Z)));
|
||||
|
||||
int const i = ui->comboBoxDimension->findData(current);
|
||||
if (i != -1)
|
||||
if (int const i = ui->comboBoxDimension->findData(current); i != -1)
|
||||
{
|
||||
ui->comboBoxDimension->setCurrentIndex(i);
|
||||
}
|
||||
|
|
|
@ -105,9 +105,9 @@ auto AppFilePath(const QString &appName) -> QString
|
|||
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
|
||||
return AppImageRoot() + BINDIR + '/'_L1 + appName;
|
||||
#else
|
||||
QFileInfo const canonicalFile(
|
||||
QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), appName + executableSuffix));
|
||||
if (canonicalFile.exists())
|
||||
if (QFileInfo const canonicalFile(
|
||||
QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), appName + executableSuffix));
|
||||
canonicalFile.exists())
|
||||
{
|
||||
return canonicalFile.absoluteFilePath();
|
||||
}
|
||||
|
@ -730,11 +730,9 @@ auto VApplication::event(QEvent *e) -> bool
|
|||
case QEvent::FileOpen:
|
||||
{
|
||||
auto *fileOpenEvent = dynamic_cast<QFileOpenEvent *>(e);
|
||||
const QString macFileOpen = fileOpenEvent->file();
|
||||
if (not macFileOpen.isEmpty())
|
||||
if (const QString macFileOpen = fileOpenEvent->file(); not macFileOpen.isEmpty())
|
||||
{
|
||||
auto *window = qobject_cast<MainWindow *>(mainWindow);
|
||||
if (window)
|
||||
if (auto *window = qobject_cast<MainWindow *>(mainWindow); window != nullptr)
|
||||
{
|
||||
window->LoadPattern(macFileOpen); // open file in existing window
|
||||
}
|
||||
|
|
|
@ -483,8 +483,7 @@ auto VCommandLine::OptDimensionA() const -> int
|
|||
const QString value = OptionValue(LONG_OPTION_DIMENSION_A);
|
||||
|
||||
bool ok = false;
|
||||
int const dimensionAValue = value.toInt(&ok);
|
||||
if (ok && dimensionAValue > 0)
|
||||
if (int const dimensionAValue = value.toInt(&ok); ok && dimensionAValue > 0)
|
||||
{
|
||||
return dimensionAValue;
|
||||
}
|
||||
|
@ -499,8 +498,7 @@ auto VCommandLine::OptDimensionB() const -> int
|
|||
const QString value = OptionValue(LONG_OPTION_DIMENSION_B);
|
||||
|
||||
bool ok = false;
|
||||
int const dimensionBValue = value.toInt(&ok);
|
||||
if (ok && dimensionBValue > 0)
|
||||
if (int const dimensionBValue = value.toInt(&ok); ok && dimensionBValue > 0)
|
||||
{
|
||||
return dimensionBValue;
|
||||
}
|
||||
|
@ -515,8 +513,7 @@ auto VCommandLine::OptDimensionC() const -> int
|
|||
const QString value = OptionValue(LONG_OPTION_DIMENSION_C);
|
||||
|
||||
bool ok = false;
|
||||
int const dimensionCValue = value.toInt(&ok);
|
||||
if (ok && dimensionCValue > 0)
|
||||
if (int const dimensionCValue = value.toInt(&ok); ok && dimensionCValue > 0)
|
||||
{
|
||||
return dimensionCValue;
|
||||
}
|
||||
|
@ -535,8 +532,8 @@ auto VCommandLine::TiledPageMargins() const -> QMarginsF
|
|||
if (IsOptionSet(LONG_OPTION_SHIFTUNITS))
|
||||
{
|
||||
const QString value = OptionValue(LONG_OPTION_SHIFTUNITS);
|
||||
const QStringList supportedUnits = QStringList() << unitMM << unitCM << unitINCH;
|
||||
if (not supportedUnits.contains(value))
|
||||
if (const QStringList supportedUnits = QStringList() << unitMM << unitCM << unitINCH;
|
||||
not supportedUnits.contains(value))
|
||||
{
|
||||
qCritical() << translate("VCommandLine", "Unsupported paper units.") << "\n";
|
||||
const_cast<VCommandLine *>(this)->parser.showHelp(V_EX_USAGE);
|
||||
|
|
|
@ -29,24 +29,24 @@
|
|||
#include "vformulaproperty.h"
|
||||
#include "vformulapropertyeditor.h"
|
||||
|
||||
#include "../vpropertyexplorer/vproperty_p.h"
|
||||
#include "../vpropertyexplorer/plugins/vstringproperty.h"
|
||||
#include "vformulapropertyeditor.h"
|
||||
#include "../vpatterndb/vformula.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vpatterndb/vformula.h"
|
||||
#include "../vpropertyexplorer/plugins/vstringproperty.h"
|
||||
#include "../vpropertyexplorer/vproperty_p.h"
|
||||
#include "vformulapropertyeditor.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormulaProperty::VFormulaProperty(const QString &name)
|
||||
: VProperty(name,
|
||||
: VProperty(name,
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
static_cast<QMetaType::Type>(VFormula::FormulaTypeId()))
|
||||
static_cast<QMetaType::Type>(VFormula::FormulaTypeId()))
|
||||
#else
|
||||
static_cast<QVariant::Type>(VFormula::FormulaTypeId()))
|
||||
static_cast<QVariant::Type>(VFormula::FormulaTypeId()))
|
||||
#endif
|
||||
{
|
||||
d_ptr->type = VPE::Property::Complex;
|
||||
|
||||
auto* tmpFormula = new VPE::VStringProperty(tr("Formula"));
|
||||
auto *tmpFormula = new VPE::VStringProperty(tr("Formula"));
|
||||
addChild(tmpFormula);
|
||||
tmpFormula->setClearButtonEnable(true);
|
||||
tmpFormula->setUpdateBehaviour(true, false);
|
||||
|
@ -58,7 +58,7 @@ VFormulaProperty::VFormulaProperty(const QString &name)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//! Get the data how it should be displayed
|
||||
auto VFormulaProperty::data (int column, int role) const -> QVariant
|
||||
auto VFormulaProperty::data(int column, int role) const -> QVariant
|
||||
{
|
||||
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
|
||||
{
|
||||
|
@ -81,14 +81,14 @@ auto VFormulaProperty::flags(int column) const -> Qt::ItemFlags
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//! Returns an editor widget, or NULL if it doesn't supply one
|
||||
auto VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options,
|
||||
const QAbstractItemDelegate* delegate) -> QWidget*
|
||||
auto VFormulaProperty::createEditor(QWidget *parent, const QStyleOptionViewItem &options,
|
||||
const QAbstractItemDelegate *delegate) -> QWidget *
|
||||
{
|
||||
Q_UNUSED(options)
|
||||
Q_UNUSED(delegate)
|
||||
|
||||
auto formula = VProperty::d_ptr->VariantValue.value<VFormula>();
|
||||
auto* tmpEditor = new VFormulaPropertyEditor(parent);
|
||||
auto *tmpEditor = new VFormulaPropertyEditor(parent);
|
||||
tmpEditor->setLocale(parent->locale());
|
||||
tmpEditor->SetFormula(formula);
|
||||
VProperty::d_ptr->editor = tmpEditor;
|
||||
|
@ -97,10 +97,9 @@ auto VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem&
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
|
||||
auto VFormulaProperty::setEditorData(QWidget* editor) -> bool
|
||||
auto VFormulaProperty::setEditorData(QWidget *editor) -> bool
|
||||
{
|
||||
auto* tmpWidget = qobject_cast<VFormulaPropertyEditor*>(editor);
|
||||
if (tmpWidget)
|
||||
if (auto *tmpWidget = qobject_cast<VFormulaPropertyEditor *>(editor); tmpWidget != nullptr)
|
||||
{
|
||||
auto formula = VProperty::d_ptr->VariantValue.value<VFormula>();
|
||||
tmpWidget->SetFormula(formula);
|
||||
|
@ -117,8 +116,7 @@ auto VFormulaProperty::setEditorData(QWidget* editor) -> bool
|
|||
//! Gets the data from the widget
|
||||
auto VFormulaProperty::getEditorData(const QWidget *editor) const -> QVariant
|
||||
{
|
||||
const auto* tmpWidget = qobject_cast<const VFormulaPropertyEditor*>(editor);
|
||||
if (tmpWidget)
|
||||
if (const auto *tmpWidget = qobject_cast<const VFormulaPropertyEditor *>(editor); tmpWidget != nullptr)
|
||||
{
|
||||
QVariant value;
|
||||
value.setValue(tmpWidget->GetFormula());
|
||||
|
@ -143,7 +141,7 @@ auto VFormulaProperty::clone(bool include_children, VProperty *container) const
|
|||
|
||||
if (!include_children)
|
||||
{
|
||||
const QList<VProperty*> tmpChildren = container->getChildren();
|
||||
const QList<VProperty *> tmpChildren = container->getChildren();
|
||||
for (auto *tmpChild : tmpChildren)
|
||||
{
|
||||
container->removeChild(tmpChild);
|
||||
|
@ -152,8 +150,7 @@ auto VFormulaProperty::clone(bool include_children, VProperty *container) const
|
|||
}
|
||||
}
|
||||
|
||||
return VProperty::clone(false, container); // Child
|
||||
|
||||
return VProperty::clone(false, container); // Child
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -904,8 +904,8 @@ template <class Tool> void VToolOptionsPropertyBrowser::SetPointName(VPE::VPrope
|
|||
return;
|
||||
}
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch())
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch())
|
||||
{
|
||||
m_idToProperty[AttrName]->setValue(i->name());
|
||||
}
|
||||
|
@ -931,8 +931,8 @@ template <class Tool> void VToolOptionsPropertyBrowser::SetPointName1(VPE::VProp
|
|||
return;
|
||||
}
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch())
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch())
|
||||
{
|
||||
m_idToProperty[AttrName1]->setValue(i->nameP1());
|
||||
}
|
||||
|
@ -958,8 +958,8 @@ template <class Tool> void VToolOptionsPropertyBrowser::SetPointName2(VPE::VProp
|
|||
return;
|
||||
}
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch())
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch())
|
||||
{
|
||||
m_idToProperty[AttrName2]->setValue(i->nameP2());
|
||||
}
|
||||
|
@ -1075,8 +1075,7 @@ template <class Tool> void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(VPE
|
|||
if (auto *i = qgraphicsitem_cast<Tool *>(m_currentItem))
|
||||
{
|
||||
const QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::EditRole);
|
||||
auto type = GetCrossPoint<HCrossCurvesPoint>(value);
|
||||
if (type == i->GetHCrossPoint())
|
||||
if (auto type = GetCrossPoint<HCrossCurvesPoint>(value); type == i->GetHCrossPoint())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -80,8 +80,9 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
|
|||
|
||||
//----------------------- Unit setup
|
||||
// set default unit
|
||||
const qint32 indexUnit = ui->unitCombo->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
|
||||
if (indexUnit != -1)
|
||||
if (const qint32 indexUnit =
|
||||
ui->unitCombo->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
|
||||
indexUnit != -1)
|
||||
{
|
||||
ui->unitCombo->setCurrentIndex(indexUnit);
|
||||
}
|
||||
|
@ -217,8 +218,8 @@ auto PreferencesConfigurationPage::Apply() -> QStringList
|
|||
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
|
||||
settings->SetToolboxIconSizeSmall(ui->radioButtonToolboxIconSizeSmall->isChecked());
|
||||
|
||||
auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt());
|
||||
if (settings->GetThemeMode() != themeMode)
|
||||
if (auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt());
|
||||
settings->GetThemeMode() != themeMode)
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
|
|
|
@ -139,8 +139,7 @@ void PreferencesPathPage::EditPath()
|
|||
}
|
||||
|
||||
bool usedNotExistedDir = false;
|
||||
QDir const directory(path);
|
||||
if (not directory.exists())
|
||||
if (QDir const directory(path); not directory.exists())
|
||||
{
|
||||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
|
|
@ -99,8 +99,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
|
|||
//----------------------- Unit setup
|
||||
// set default unit
|
||||
const Unit defUnit = QLocale().measurementSystem() == QLocale::MetricSystem ? Unit::Mm : Unit::Inch;
|
||||
const qint32 indexUnit = ui->comboBoxLineWidthUnit->findData(static_cast<int>(defUnit));
|
||||
if (indexUnit != -1)
|
||||
if (const qint32 indexUnit = ui->comboBoxLineWidthUnit->findData(static_cast<int>(defUnit)); indexUnit != -1)
|
||||
{
|
||||
ui->comboBoxLineWidthUnit->setCurrentIndex(indexUnit);
|
||||
}
|
||||
|
@ -140,15 +139,13 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
|
|||
ui->fontComboBoxLabelFont->setCurrentFont(labelFont);
|
||||
|
||||
InitLabelFontSizes();
|
||||
const qint32 indexSize = ui->comboBoxLabelFontSize->findData(pointSize);
|
||||
if (indexSize != -1)
|
||||
if (const qint32 indexSize = ui->comboBoxLabelFontSize->findData(pointSize); indexSize != -1)
|
||||
{
|
||||
ui->comboBoxLabelFontSize->setCurrentIndex(indexSize);
|
||||
}
|
||||
|
||||
InitSingleLineFonts();
|
||||
const qint32 indexFont = ui->comboBoxSingleLineFont->findData(settings->GetLabelSVGFont());
|
||||
if (indexFont != -1)
|
||||
if (const qint32 indexFont = ui->comboBoxSingleLineFont->findData(settings->GetLabelSVGFont()); indexFont != -1)
|
||||
{
|
||||
ui->comboBoxSingleLineFont->setCurrentIndex(indexFont);
|
||||
}
|
||||
|
|
|
@ -207,8 +207,7 @@ void DialogFinalMeasurements::showEvent(QShowEvent *event)
|
|||
}
|
||||
// do your init stuff here
|
||||
|
||||
const QSize sz = VAbstractApplication::VApp()->Settings()->GetFinalMeasurementsDialogSize();
|
||||
if (not sz.isEmpty())
|
||||
if (const QSize sz = VAbstractApplication::VApp()->Settings()->GetFinalMeasurementsDialogSize(); not sz.isEmpty())
|
||||
{
|
||||
resize(sz);
|
||||
}
|
||||
|
@ -390,8 +389,7 @@ void DialogFinalMeasurements::SaveFormula()
|
|||
// Replace line return character with spaces for calc if exist
|
||||
QString const text = ui->plainTextEditFormula->toPlainText();
|
||||
|
||||
QTableWidgetItem *formulaField = ui->tableWidget->item(row, 2);
|
||||
if (formulaField->text() == text)
|
||||
if (QTableWidgetItem *formulaField = ui->tableWidget->item(row, 2); formulaField->text() == text)
|
||||
{
|
||||
QTableWidgetItem *result = ui->tableWidget->item(row, 1);
|
||||
// Show unit in dialog lable (cm, mm or inch)
|
||||
|
|
|
@ -118,8 +118,7 @@ DialogHistory::~DialogHistory()
|
|||
*/
|
||||
void DialogHistory::DialogAccepted()
|
||||
{
|
||||
QTableWidgetItem *item = ui->tableWidget->item(m_cursorToolRecordRow, 0);
|
||||
if (item != nullptr)
|
||||
if (QTableWidgetItem *item = ui->tableWidget->item(m_cursorToolRecordRow, 0); item != nullptr)
|
||||
{
|
||||
auto id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
||||
emit ShowHistoryTool(id, false);
|
||||
|
|
|
@ -329,9 +329,9 @@ void DialogPatternProperties::ValidatePassmarkLength() const
|
|||
QPalette palette = ui->lineEditPassmarkLength->palette();
|
||||
const QPalette::ColorRole foregroundRole = ui->lineEditPassmarkLength->foregroundRole();
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (not text.isEmpty())
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
palette.setColor(foregroundRole, rx.match(text).hasMatch() && m_variables.contains(text)
|
||||
? palette.color(QPalette::Text)
|
||||
: Qt::red);
|
||||
|
@ -351,9 +351,9 @@ void DialogPatternProperties::ValidatePassmarkWidth() const
|
|||
QPalette palette = ui->lineEditPassmarkWidth->palette();
|
||||
const QPalette::ColorRole foregroundRole = ui->lineEditPassmarkWidth->foregroundRole();
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (not text.isEmpty())
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
palette.setColor(foregroundRole, rx.match(text).hasMatch() && m_variables.contains(text)
|
||||
? palette.color(QPalette::Text)
|
||||
: Qt::red);
|
||||
|
@ -468,8 +468,7 @@ void DialogPatternProperties::SaveImage()
|
|||
QMimeType const mime = image.MimeTypeFromData();
|
||||
QString path = settings->GetPathCustomImage() + QDir::separator() + tr("untitled");
|
||||
|
||||
QStringList const suffixes = mime.suffixes();
|
||||
if (not suffixes.isEmpty())
|
||||
if (QStringList const suffixes = mime.suffixes(); not suffixes.isEmpty())
|
||||
{
|
||||
path += '.'_L1 + suffixes.at(0);
|
||||
}
|
||||
|
@ -510,8 +509,7 @@ void DialogPatternProperties::ShowImage()
|
|||
QMimeType const mime = image.MimeTypeFromData();
|
||||
QString name = QDir::tempPath() + QDir::separator() + QStringLiteral("image.XXXXXX");
|
||||
|
||||
QStringList const suffixes = mime.suffixes();
|
||||
if (not suffixes.isEmpty())
|
||||
if (QStringList const suffixes = mime.suffixes(); not suffixes.isEmpty())
|
||||
{
|
||||
name += '.'_L1 + suffixes.at(0);
|
||||
}
|
||||
|
|
|
@ -93,8 +93,7 @@ void DialogPreferences::showEvent(QShowEvent *event)
|
|||
}
|
||||
// do your init stuff here
|
||||
|
||||
QSize const sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize();
|
||||
if (not sz.isEmpty())
|
||||
if (QSize const sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize(); not sz.isEmpty())
|
||||
{
|
||||
resize(sz);
|
||||
}
|
||||
|
|
|
@ -429,11 +429,11 @@ void DialogSaveLayout::Save()
|
|||
Path() + '/' + FileName() + QString::number(i + 1) + VLayoutExporter::ExportFormatSuffix(Format());
|
||||
if (QFile::exists(name))
|
||||
{
|
||||
QMessageBox::StandardButton const res = QMessageBox::question(
|
||||
this, tr("Name conflict"),
|
||||
tr("Folder already contain file with name %1. Rewrite all conflict file names?").arg(name),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (res == QMessageBox::No)
|
||||
if (QMessageBox::StandardButton const res = QMessageBox::question(
|
||||
this, tr("Name conflict"),
|
||||
tr("Folder already contain file with name %1. Rewrite all conflict file names?").arg(name),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
res == QMessageBox::No)
|
||||
{
|
||||
reject();
|
||||
return;
|
||||
|
|
|
@ -251,8 +251,7 @@ void LogPatternToolUsed(bool checked, const QString &toolName)
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -4932,8 +4931,7 @@ void MainWindow::AskDefaultSettings()
|
|||
|
||||
if (settings->IsAskCollectStatistic() || settings->IsAskSendCrashReport())
|
||||
{
|
||||
DialogAskCollectStatistic dialog(this);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
if (DialogAskCollectStatistic dialog(this); dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
settings->SetCollectStatistic(dialog.CollectStatistic());
|
||||
#if defined(CRASH_REPORTING)
|
||||
|
@ -4951,9 +4949,8 @@ void MainWindow::AskDefaultSettings()
|
|||
auto *statistic = VGAnalytics::Instance();
|
||||
statistic->SetGUILanguage(settings->GetLocale());
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
bool freshID = false;
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -5030,8 +5027,7 @@ void MainWindow::SaveBackgroundImage(const QUuid &id)
|
|||
|
||||
if (mime.isValid())
|
||||
{
|
||||
QStringList const suffixes = mime.suffixes();
|
||||
if (not suffixes.isEmpty())
|
||||
if (QStringList const suffixes = mime.suffixes(); not suffixes.isEmpty())
|
||||
{
|
||||
path += '.'_L1 + suffixes.at(0);
|
||||
}
|
||||
|
@ -5771,9 +5767,8 @@ auto MainWindow::MaybeSave() -> bool
|
|||
|
||||
messageBox->setWindowModality(Qt::ApplicationModal);
|
||||
messageBox->setFixedSize(300, 85);
|
||||
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
|
||||
|
||||
switch (ret)
|
||||
switch (static_cast<QMessageBox::StandardButton>(messageBox->exec()))
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
if (m_patternReadOnly)
|
||||
|
@ -6470,8 +6465,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString &customMeasureFile)
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -7077,8 +7071,7 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -7101,8 +7094,7 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
|
|
@ -1317,8 +1317,7 @@ auto MainWindowsNoGUI::OpenMeasurementFile(const QString &path) const -> QShared
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
@ -1341,8 +1340,7 @@ auto MainWindowsNoGUI::OpenMeasurementFile(const QString &path) const -> QShared
|
|||
{
|
||||
auto *statistic = VGAnalytics::Instance();
|
||||
|
||||
QString clientID = settings->GetClientID();
|
||||
if (clientID.isEmpty())
|
||||
if (QString clientID = settings->GetClientID(); clientID.isEmpty())
|
||||
{
|
||||
clientID = QUuid::createUuid().toString();
|
||||
settings->SetClientID(clientID);
|
||||
|
|
|
@ -510,9 +510,8 @@ auto WatermarkWindow::MaybeSave() -> bool
|
|||
|
||||
messageBox->setWindowModality(Qt::ApplicationModal);
|
||||
messageBox->setFixedSize(300, 85);
|
||||
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
|
||||
|
||||
switch (ret)
|
||||
switch (static_cast<QMessageBox::StandardButton>(messageBox->exec()))
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
return m_curFile.isEmpty() ? on_actionSaveAs_triggered() : on_actionSave_triggered();
|
||||
|
|
|
@ -178,8 +178,7 @@ auto InitializeCrashpad(const QString &appName) -> bool
|
|||
|
||||
auto MakeDir = [](const QString &path)
|
||||
{
|
||||
QDir const directory(path);
|
||||
if (not directory.exists())
|
||||
if (QDir const directory(path); not directory.exists())
|
||||
{
|
||||
directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
|
|
@ -370,8 +370,8 @@ void CheckPointLabel(QDialog *dialog, QLineEdit *edit, QLabel *labelEditNamePoin
|
|||
SCASSERT(labelEditNamePoint != nullptr)
|
||||
|
||||
const QString name = edit->text();
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (name.isEmpty() || (pointName != name && not data->IsUnique(name)) || not rx.match(name).hasMatch())
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
name.isEmpty() || (pointName != name && not data->IsUnique(name)) || not rx.match(name).hasMatch())
|
||||
{
|
||||
flag = false;
|
||||
ChangeColor(labelEditNamePoint, errorColor);
|
||||
|
|
|
@ -451,10 +451,10 @@ void DialogArc::changeEvent(QEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogArc::ValidateAlias()
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
VArc arc;
|
||||
arc.SetAliasSuffix(GetAliasSuffix());
|
||||
if (not GetAliasSuffix().isEmpty() &&
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not GetAliasSuffix().isEmpty() &&
|
||||
(not rx.match(arc.GetAlias()).hasMatch() ||
|
||||
(m_originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias()))))
|
||||
{
|
||||
|
|
|
@ -495,10 +495,10 @@ void DialogArcWithLength::changeEvent(QEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogArcWithLength::ValidateAlias()
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
VArc arc;
|
||||
arc.SetAliasSuffix(GetAliasSuffix());
|
||||
if (not GetAliasSuffix().isEmpty() &&
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not GetAliasSuffix().isEmpty() &&
|
||||
(not rx.match(arc.GetAlias()).hasMatch() ||
|
||||
(m_originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias()))))
|
||||
{
|
||||
|
|
|
@ -264,10 +264,10 @@ void DialogCubicBezier::SaveData()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCubicBezier::ValidateAlias()
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
VCubicBezier spline = spl;
|
||||
spline.SetAliasSuffix(ui->lineEditAlias->text());
|
||||
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not ui->lineEditAlias->text().isEmpty() &&
|
||||
(not rx.match(spline.GetAlias()).hasMatch() ||
|
||||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(spline.GetAlias()))))
|
||||
{
|
||||
|
|
|
@ -277,10 +277,10 @@ void DialogCubicBezierPath::currentPointChanged(int index)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCubicBezierPath::ValidateAlias()
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
VCubicBezierPath tempPath = path;
|
||||
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
|
||||
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not ui->lineEditAlias->text().isEmpty() &&
|
||||
(not rx.match(tempPath.GetAlias()).hasMatch() ||
|
||||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(tempPath.GetAlias()))))
|
||||
{
|
||||
|
|
|
@ -758,10 +758,10 @@ void DialogEllipticalArc::changeEvent(QEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogEllipticalArc::ValidateAlias()
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
VEllipticalArc arc;
|
||||
arc.SetAliasSuffix(GetAliasSuffix());
|
||||
if (not GetAliasSuffix().isEmpty() &&
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not GetAliasSuffix().isEmpty() &&
|
||||
(not rx.match(arc.GetAlias()).hasMatch() ||
|
||||
(m_originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias()))))
|
||||
{
|
||||
|
|
|
@ -437,12 +437,11 @@ void DialogSpline::EvalLength2()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSpline::ValidateAlias()
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
|
||||
VSpline spline = spl;
|
||||
spline.SetAliasSuffix(ui->lineEditAlias->text());
|
||||
|
||||
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not ui->lineEditAlias->text().isEmpty() &&
|
||||
(not rx.match(spline.GetAlias()).hasMatch() ||
|
||||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(spline.GetAlias()))))
|
||||
{
|
||||
|
|
|
@ -543,12 +543,11 @@ void DialogSplinePath::FXLength2()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSplinePath::ValidateAlias()
|
||||
{
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
|
||||
VSplinePath tempPath = path;
|
||||
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
|
||||
|
||||
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not ui->lineEditAlias->text().isEmpty() &&
|
||||
(not rx.match(tempPath.GetAlias()).hasMatch() ||
|
||||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(tempPath.GetAlias()))))
|
||||
{
|
||||
|
|
|
@ -407,8 +407,8 @@ void DialogTrueDarts::CheckName(QLineEdit *edit, QLabel *labelEditNamePoint, con
|
|||
|
||||
const QString name = edit->text();
|
||||
const QString secondName = secondPointName->text();
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
if (name.isEmpty() || secondName == name ||
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
name.isEmpty() || secondName == name ||
|
||||
(pointD1Name != name && pointD2Name != name && data->IsUnique(name) == false) ||
|
||||
rx.match(name).hasMatch() == false)
|
||||
{
|
||||
|
|
|
@ -476,9 +476,8 @@ void VAbstractSpline::SetAliasSuffix(QString alias)
|
|||
alias = alias.simplified().replace(QChar(QChar::Space), '_'_L1);
|
||||
curve->SetAliasSuffix(alias);
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
|
||||
if (alias.isEmpty() || (rx.match(curve->GetAlias()).hasMatch() && VAbstractTool::data.IsUnique(curve->GetAlias())))
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
alias.isEmpty() || (rx.match(curve->GetAlias()).hasMatch() && VAbstractTool::data.IsUnique(curve->GetAlias())))
|
||||
{
|
||||
QSharedPointer<VGObject> obj = qSharedPointerCast<VGObject>(curve);
|
||||
SaveOption(obj);
|
||||
|
|
|
@ -122,9 +122,8 @@ void VToolCut::SetAliasSuffix1(QString alias)
|
|||
alias = alias.simplified().replace(QChar(QChar::Space), '_'_L1);
|
||||
curve->SetAliasSuffix(alias);
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
|
||||
if (alias.isEmpty() || (rx.match(curve->GetAlias()).hasMatch() && VAbstractTool::data.IsUnique(curve->GetAlias())))
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
alias.isEmpty() || (rx.match(curve->GetAlias()).hasMatch() && VAbstractTool::data.IsUnique(curve->GetAlias())))
|
||||
{
|
||||
m_aliasSuffix1 = alias;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
|
@ -151,9 +150,8 @@ void VToolCut::SetAliasSuffix2(QString alias)
|
|||
alias = alias.simplified().replace(QChar(QChar::Space), '_'_L1);
|
||||
curve->SetAliasSuffix(alias);
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
|
||||
if (alias.isEmpty() || (rx.match(curve->GetAlias()).hasMatch() && VAbstractTool::data.IsUnique(curve->GetAlias())))
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
alias.isEmpty() || (rx.match(curve->GetAlias()).hasMatch() && VAbstractTool::data.IsUnique(curve->GetAlias())))
|
||||
{
|
||||
m_aliasSuffix2 = alias;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
|
|
|
@ -65,8 +65,6 @@ auto SourceAliasValid(const SourceItem &item, const QSharedPointer<VGObject> &ob
|
|||
{
|
||||
SCASSERT(data != nullptr)
|
||||
|
||||
QRegularExpression const rx(NameRegExp());
|
||||
|
||||
QString alias;
|
||||
|
||||
if (obj->getType() == GOType::Point)
|
||||
|
@ -81,7 +79,8 @@ auto SourceAliasValid(const SourceItem &item, const QSharedPointer<VGObject> &ob
|
|||
obj->SetAliasSuffix(oldAlias);
|
||||
}
|
||||
|
||||
if (not alias.isEmpty() && originAlias != alias && (not rx.match(alias).hasMatch() || not data->IsUnique(alias)))
|
||||
if (QRegularExpression const rx(NameRegExp());
|
||||
not alias.isEmpty() && originAlias != alias && (not rx.match(alias).hasMatch() || not data->IsUnique(alias)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -213,8 +213,7 @@ auto VAbstractMainWindow::CSVFilePath() -> QString
|
|||
return fileName;
|
||||
}
|
||||
|
||||
QFileInfo const f(fileName);
|
||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
if (QFileInfo const f(fileName); f.suffix().isEmpty() && f.suffix() != suffix)
|
||||
{
|
||||
fileName += '.'_L1 + suffix;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user