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