Refactoring.

Fix code style.
This commit is contained in:
Roman Telezhynskyi 2023-05-16 19:20:49 +03:00
parent 3ce8e6e5a7
commit 7320c1c5df
12 changed files with 877 additions and 773 deletions

View File

@ -27,11 +27,12 @@
*************************************************************************/ *************************************************************************/
#include "preferencesconfigurationpage.h" #include "preferencesconfigurationpage.h"
#include "ui_preferencesconfigurationpage.h"
#include "../../core/vapplication.h" #include "../../core/vapplication.h"
#include "../vpatterndb/pmsystems.h"
#include "../vmisc/vvalentinasettings.h"
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
#include "../vmisc/vvalentinasettings.h"
#include "../vpatterndb/pmsystems.h"
#include "def.h"
#include "ui_preferencesconfigurationpage.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
@ -55,10 +56,8 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
ui->autoSaveCheck->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveState()); ui->autoSaveCheck->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveState());
InitLanguages(ui->langCombo); InitLanguages(ui->langCombo);
connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
{ [this]() { m_langChanged = true; });
m_langChanged = true;
});
//-------------------- Decimal separator setup //-------------------- Decimal separator setup
ui->osOptionCheck->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator()); ui->osOptionCheck->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator());
@ -71,10 +70,8 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
ui->unitCombo->setCurrentIndex(indexUnit); ui->unitCombo->setCurrentIndex(indexUnit);
} }
connect(ui->unitCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() connect(ui->unitCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
{ [this]() { m_unitChanged = true; });
m_unitChanged = true;
});
//----------------------- Label language //----------------------- Label language
SetLabelComboBox(VApplication::LabelLanguages()); SetLabelComboBox(VApplication::LabelLanguages());
@ -84,18 +81,17 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
{ {
ui->labelCombo->setCurrentIndex(index); ui->labelCombo->setCurrentIndex(index);
} }
connect(ui->labelCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() connect(ui->labelCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
{ [this]() { m_labelLangChanged = true; });
m_labelLangChanged = true;
});
//---------------------- Pattern making system //---------------------- Pattern making system
ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing()); ui->systemBookValueLabel->setFixedHeight(4 * QFontMetrics(ui->systemBookValueLabel->font()).lineSpacing());
connect(ui->systemCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() connect(ui->systemCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
[this]()
{ {
m_systemChanged = true; m_systemChanged = true;
QString text = VAbstractApplication::VApp()->TrVars() QString text =
->PMSystemAuthor(ui->systemCombo->currentData().toString()); VAbstractApplication::VApp()->TrVars()->PMSystemAuthor(ui->systemCombo->currentData().toString());
ui->systemAuthorValueLabel->setText(text); ui->systemAuthorValueLabel->setText(text);
ui->systemAuthorValueLabel->setToolTip(text); ui->systemAuthorValueLabel->setToolTip(text);
@ -111,7 +107,8 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
} }
//----------------------------- Pattern Editing //----------------------------- Pattern Editing
connect(ui->resetWarningsButton, &QPushButton::released, this, []() connect(ui->resetWarningsButton, &QPushButton::released, this,
[]()
{ {
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();

View File

@ -31,8 +31,6 @@
#include <QWidget> #include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class PreferencesConfigurationPage; class PreferencesConfigurationPage;
@ -42,13 +40,14 @@ class PreferencesConfigurationPage : public QWidget
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public : explicit PreferencesConfigurationPage(QWidget *parent = nullptr);
explicit PreferencesConfigurationPage(QWidget *parent = nullptr);
~PreferencesConfigurationPage() override; ~PreferencesConfigurationPage() override;
auto Apply() -> QStringList; auto Apply() -> QStringList;
protected: protected:
void changeEvent(QEvent *event) override; void changeEvent(QEvent *event) override;
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(PreferencesConfigurationPage) // NOLINT Q_DISABLE_COPY_MOVE(PreferencesConfigurationPage) // NOLINT

View File

@ -26,28 +26,29 @@
** **
*************************************************************************/ *************************************************************************/
#include <QApplication>
#include <QDate> #include <QDate>
#include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QFlags> // QFlags<Qt::Alignment>
#include <QFontMetrics> #include <QFontMetrics>
#include <QGlobalStatic>
#include <QLatin1String> #include <QLatin1String>
#include <QRegularExpression> #include <QRegularExpression>
#include <QApplication>
#include <QDebug>
#include <QFlags> // QFlags<Qt::Alignment>
#include <QtMath> #include <QtMath>
#include <QGlobalStatic> #include <QGlobalStatic>
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vabstractvalapplication.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 9, 0)
#include "../vmisc/vdatastreamenum.h" #include "../vmisc/vdatastreamenum.h"
#endif #endif
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/calculator.h" #include "../vpatterndb/calculator.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/vcontainer.h"
#include "vtextmanager.h" #include "vtextmanager.h"
const quint32 TextLine::streamHeader = 0xA3881E49; // CRC-32Q string "TextLine" const quint32 TextLine::streamHeader = 0xA3881E49; // CRC-32Q string "TextLine"
@ -93,7 +94,8 @@ auto operator>>(QDataStream &dataStream, TextLine &data) -> QDataStream&
{ {
QString message = QCoreApplication::tr("TextLine compatibility error: actualClassVersion = %1 and " QString message = QCoreApplication::tr("TextLine compatibility error: actualClassVersion = %1 and "
"classVersion = %2") "classVersion = %2")
.arg(actualClassVersion).arg(TextLine::classVersion); .arg(actualClassVersion)
.arg(TextLine::classVersion);
throw VException(message); throw VException(message);
} }
@ -156,7 +158,8 @@ auto operator>>(QDataStream &dataStream, VTextManager &data) -> QDataStream&
{ {
QString message = QCoreApplication::tr("VTextManager compatibility error: actualClassVersion = %1 and " QString message = QCoreApplication::tr("VTextManager compatibility error: actualClassVersion = %1 and "
"classVersion = %2") "classVersion = %2")
.arg(actualClassVersion).arg(VTextManager::classVersion); .arg(actualClassVersion)
.arg(VTextManager::classVersion);
throw VException(message); throw VException(message);
} }
@ -205,8 +208,8 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data) ->
{ {
placeholders.insert(pl_customer, VAbstractValApplication::VApp()->GetCustomerName()); placeholders.insert(pl_customer, VAbstractValApplication::VApp()->GetCustomerName());
const QString birthDate = locale.toString(VAbstractValApplication::VApp()->GetCustomerBirthDate(), const QString birthDate =
doc->GetLabelDateFormat()); locale.toString(VAbstractValApplication::VApp()->GetCustomerBirthDate(), doc->GetLabelDateFormat());
placeholders.insert(pl_birthDate, birthDate); placeholders.insert(pl_birthDate, birthDate);
placeholders.insert(pl_email, VAbstractValApplication::VApp()->CustomerEmail()); placeholders.insert(pl_email, VAbstractValApplication::VApp()->CustomerEmail());
@ -256,7 +259,8 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data) ->
} }
placeholders.insert(pl_mExt, VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize placeholders.insert(pl_mExt, VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize
? QStringLiteral("vst") : QStringLiteral("vit")); ? QStringLiteral("vst")
: QStringLiteral("vit"));
const QMap<int, QString> materials = doc->GetPatternMaterials(); const QMap<int, QString> materials = doc->GetPatternMaterials();
for (int i = 0; i < userMaterialPlaceholdersQuantity; ++i) for (int i = 0; i < userMaterialPlaceholdersQuantity; ++i)
@ -304,9 +308,12 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data) ->
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at " const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at "
"line %1: %2.").arg(i+1).arg(e.GetMsg()); "line %1: %2.")
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : .arg(i + 1)
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; .arg(e.GetMsg());
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
} }
@ -362,8 +369,9 @@ void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
const QString errorMsg = QObject::tr("Failed to prepare full piece area placeholder. %2.").arg(e.GetMsg()); const QString errorMsg = QObject::tr("Failed to prepare full piece area placeholder. %2.").arg(e.GetMsg());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
try try
@ -375,8 +383,9 @@ void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
const QString errorMsg = QObject::tr("Failed to prepare piece seam line area placeholder. %2.").arg(e.GetMsg()); const QString errorMsg = QObject::tr("Failed to prepare piece seam line area placeholder. %2.").arg(e.GetMsg());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
@ -389,8 +398,9 @@ auto ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString lin
{ {
if (line.contains(per + placeholder + per) && placeholders.value(placeholder) == QChar('0')) if (line.contains(per + placeholder + per) && placeholders.value(placeholder) == QChar('0'))
{ {
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
}; };
@ -593,8 +603,7 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
fnt.setPixelSize(iFS + maxLine.m_iFontSize); fnt.setPixelSize(iFS + maxLine.m_iFontSize);
QFontMetrics fm(fnt); QFontMetrics fm(fnt);
lineLength = TextWidth(fm, maxLine.m_qsText); lineLength = TextWidth(fm, maxLine.m_qsText);
} } while (lineLength > fW && iFS > MIN_FONT_SIZE);
while (lineLength > fW && iFS > MIN_FONT_SIZE);
} }
SetFontSize(iFS); SetFontSize(iFS);
} }

View File

@ -33,9 +33,12 @@
#include <QColor> #include <QColor>
#include <QComboBox> #include <QComboBox>
#include <QCursor> #include <QCursor>
#include <QDesktopServices>
#include <QDir> #include <QDir>
#include <QDirIterator> #include <QDirIterator>
#include <QFileInfo> #include <QFileInfo>
#include <QGlobalStatic>
#include <QGraphicsItem>
#include <QGuiApplication> #include <QGuiApplication>
#include <QImage> #include <QImage>
#include <QLatin1Char> #include <QLatin1Char>
@ -44,15 +47,12 @@
#include <QMessageLogger> #include <QMessageLogger>
#include <QObject> #include <QObject>
#include <QPixmap> #include <QPixmap>
#include <QPixmapCache>
#include <QPrinterInfo> #include <QPrinterInfo>
#include <QProcess> #include <QProcess>
#include <QRgb> #include <QRgb>
#include <QtDebug>
#include <QPixmapCache>
#include <QGraphicsItem>
#include <QGlobalStatic>
#include <QDesktopServices>
#include <QUrl> #include <QUrl>
#include <QtDebug>
#include "vabstractapplication.h" #include "vabstractapplication.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
@ -95,27 +95,8 @@ void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int h
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto SupportedLocales() -> QStringList auto SupportedLocales() -> QStringList
{ {
return QStringList return QStringList{"uk_UA", "de_DE", "cs_CZ", "he_IL", "fr_FR", "it_IT", "nl_NL", "id_ID", "es_ES",
{ "fi_FI", "en_US", "en_CA", "en_IN", "ro_RO", "zh_CN", "pt_BR", "el_GR", "pl_PL"};
"uk_UA",
"de_DE",
"cs_CZ",
"he_IL",
"fr_FR",
"it_IT",
"nl_NL",
"id_ID",
"es_ES",
"fi_FI",
"en_US",
"en_CA",
"en_IN",
"ro_RO",
"zh_CN",
"pt_BR",
"el_GR",
"pl_PL"
};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -224,12 +205,10 @@ auto darkenPixmap(const QPixmap &pixmap) -> QPixmap
void ShowInGraphicalShell(const QString &filePath) void ShowInGraphicalShell(const QString &filePath)
{ {
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
QStringList args{ QStringList args{"-e", "tell application \"Finder\"",
"-e", "tell application \"Finder\"",
"-e", "activate", "-e", "activate",
"-e", "select POSIX file \"" + filePath + "\"", "-e", "select POSIX file \"" + filePath + "\"",
"-e", "end tell" "-e", "end tell"};
};
QProcess::startDetached(QStringLiteral("osascript"), args); QProcess::startDetached(QStringLiteral("osascript"), args);
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
QProcess::startDetached(QStringLiteral("explorer"), QStringList{"/select", QDir::toNativeSeparators(filePath)}); QProcess::startDetached(QStringLiteral("explorer"), QStringList{"/select", QDir::toNativeSeparators(filePath)});
@ -238,7 +217,8 @@ void ShowInGraphicalShell(const QString &filePath)
QString command = QStringLiteral("dbus-send --reply-timeout=%1 --session --dest=org.freedesktop.FileManager1 " QString command = QStringLiteral("dbus-send --reply-timeout=%1 --session --dest=org.freedesktop.FileManager1 "
"--type=method_call /org/freedesktop/FileManager1 " "--type=method_call /org/freedesktop/FileManager1 "
"org.freedesktop.FileManager1.ShowItems array:string:\"%2\" string:\"\"") "org.freedesktop.FileManager1.ShowItems array:string:\"%2\" string:\"\"")
.arg(timeout).arg(QUrl::fromLocalFile(filePath).toString()); .arg(timeout)
.arg(QUrl::fromLocalFile(filePath).toString());
// Sending message through dbus will highlighting file // Sending message through dbus will highlighting file
QProcess dbus; QProcess dbus;
@ -449,7 +429,6 @@ auto StringToPassmarkAngleType(const QString &value) -> PassmarkAngleType
return PassmarkAngleType::Straightforward; return PassmarkAngleType::Straightforward;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto StrToUnits(const QString &unit) -> Unit auto StrToUnits(const QString &unit) -> Unit
{ {
@ -603,7 +582,8 @@ auto operator>>(QDataStream &in, CustomSARecord &record) -> QDataStream &
{ {
QString message = QCoreApplication::tr("CustomSARecord compatibility error: actualClassVersion = %1 and " QString message = QCoreApplication::tr("CustomSARecord compatibility error: actualClassVersion = %1 and "
"classVersion = %2") "classVersion = %2")
.arg(actualClassVersion).arg(CustomSARecord::classVersion); .arg(actualClassVersion)
.arg(CustomSARecord::classVersion);
throw VException(message); throw VException(message);
} }
@ -703,8 +683,7 @@ auto SplitFilePaths(const QString &path) -> QStringList
result.prepend(lastFileName); result.prepend(lastFileName);
subPath = fileInfo.path(); subPath = fileInfo.path();
} }
} } while (not lastFileName.isEmpty());
while(not lastFileName.isEmpty());
return result; return result;
} }

View File

@ -34,14 +34,14 @@
#include <qt_windows.h> #include <qt_windows.h>
#endif /*Q_OS_WIN*/ #endif /*Q_OS_WIN*/
#include <qcompilerdetection.h> #include <QLineF>
#include <QMargins>
#include <QPrinter> #include <QPrinter>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <Qt> #include <Qt>
#include <csignal> #include <csignal>
#include <QMargins> #include <qcompilerdetection.h>
#include <QLineF>
#include "debugbreak.h" #include "debugbreak.h"
#include "defglobal.h" #include "defglobal.h"
@ -83,15 +83,63 @@ constexpr qreal maxCurveApproximationScale = 10.0;
constexpr int minLabelFontSize = 5; constexpr int minLabelFontSize = 5;
constexpr int maxLabelFontSize = 100; constexpr int maxLabelFontSize = 100;
enum class NodeDetail : qint8 { Contour, Modeling }; enum class NodeDetail : qint8
enum class SceneObject : qint8 { Point, Line, Spline, Arc, ElArc, SplinePath, Detail, Unknown }; {
enum class MeasurementsType : qint8 { Multisize, Individual, Unknown}; Contour,
enum class Unit : qint8 { Mm = 0, Cm, Inch, Px, LAST_UNIT_DO_NOT_USE}; Modeling
enum class Source : qint8 { FromGui, FromFile, FromTool }; };
enum class NodeUsage : bool {NotInUse = false, InUse = true}; enum class SceneObject : qint8
enum class SelectionType : bool {ByMousePress, ByMouseRelease}; {
enum class PageOrientation : bool {Portrait = true, Landscape = false}; Point,
enum class Draw : qint8 { Calculation, Modeling, Layout }; Line,
Spline,
Arc,
ElArc,
SplinePath,
Detail,
Unknown
};
enum class MeasurementsType : qint8
{
Multisize,
Individual,
Unknown
};
enum class Unit : qint8
{
Mm = 0,
Cm,
Inch,
Px,
LAST_UNIT_DO_NOT_USE
};
enum class Source : qint8
{
FromGui,
FromFile,
FromTool
};
enum class NodeUsage : bool
{
NotInUse = false,
InUse = true
};
enum class SelectionType : bool
{
ByMousePress,
ByMouseRelease
};
enum class PageOrientation : bool
{
Portrait = true,
Landscape = false
};
enum class Draw : qint8
{
Calculation,
Modeling,
Layout
};
enum class PieceNodeAngle : quint8 enum class PieceNodeAngle : quint8
{ {
@ -147,7 +195,13 @@ enum class PiecePathIncludeType : quint8
AsCustomSA = 1 AsCustomSA = 1
}; };
enum class PiecePathType : quint8 {PiecePath = 0, CustomSeamAllowance = 1, InternalPath = 2, Unknown = 3}; enum class PiecePathType : quint8
{
PiecePath = 0,
CustomSeamAllowance = 1,
InternalPath = 2,
Unknown = 3
};
typedef int ToolVisHolderType; typedef int ToolVisHolderType;
enum class Tool : ToolVisHolderType enum class Tool : ToolVisHolderType
@ -279,16 +333,37 @@ enum class Layout : ToolVisHolderType
LAST_ONE_DO_NOT_USE // add new stuffs above this, this constant must be last and never used LAST_ONE_DO_NOT_USE // add new stuffs above this, this constant must be last and never used
}; };
enum class VarType : qint8 { Measurement, MeasurementSeparator, Increment, IncrementSeparator, LineLength, CurveLength, enum class VarType : qint8
CurveCLength, LineAngle, CurveAngle, ArcRadius, PieceExternalArea, PieceSeamLineArea, {
Unknown }; Measurement,
MeasurementSeparator,
Increment,
IncrementSeparator,
LineLength,
CurveLength,
CurveCLength,
LineAngle,
CurveAngle,
ArcRadius,
PieceExternalArea,
PieceSeamLineArea,
Unknown
};
enum class IncrementType : qint8 { Increment, Separator }; enum class IncrementType : qint8
{
Increment,
Separator
};
auto IncrementTypeToString(IncrementType type) -> QString; auto IncrementTypeToString(IncrementType type) -> QString;
auto StringToIncrementType(const QString &value) -> IncrementType; auto StringToIncrementType(const QString &value) -> IncrementType;
enum class MeasurementType : qint8 { Measurement, Separator }; enum class MeasurementType : qint8
{
Measurement,
Separator
};
auto MeasurementTypeToString(MeasurementType type) -> QString; auto MeasurementTypeToString(MeasurementType type) -> QString;
auto StringToMeasurementType(const QString &value) -> MeasurementType; auto StringToMeasurementType(const QString &value) -> MeasurementType;
@ -330,8 +405,7 @@ enum class IMD: qint8 // Individual measurement dimension
#define SCASSERT(cond) \ #define SCASSERT(cond) \
if (!(cond)) \ if (!(cond)) \
{ \ { \
qCritical("ASSERT: %s in %s (%s:%u)", \ qCritical("ASSERT: %s in %s (%s:%u)", #cond, Q_FUNC_INFO, __FILE__, __LINE__); \
#cond, Q_FUNC_INFO , __FILE__, __LINE__); \
debug_break(); \ debug_break(); \
abort(); \ abort(); \
} }
@ -393,10 +467,9 @@ void InitHighDpiScaling(int argc, char *argv[]);
// We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1. // We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1.
// Feel free to add other versions if needed. // Feel free to add other versions if needed.
#define MACOS_LAYER_BACKING_AFFECTED \ #define MACOS_LAYER_BACKING_AFFECTED \
(QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 11) \ (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 11) || \
|| (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) \ (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) || \
|| (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 1)) \ (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 1)))
)
#if MACOS_LAYER_BACKING_AFFECTED #if MACOS_LAYER_BACKING_AFFECTED
#include <QOperatingSystemVersion> #include <QOperatingSystemVersion>
@ -442,9 +515,18 @@ Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel(double val, const Unit &unit) -> do
return 0; return 0;
} }
template<typename T> constexpr inline auto PixelToInch(T pix) -> T {return pix / PrintDPI;} template <typename T> constexpr inline auto PixelToInch(T pix) -> T
template<typename T> constexpr inline auto PixelToMm(T pix) -> T {return PixelToInch(pix) * 25.4;} {
template<typename T> constexpr inline auto PixelToCm(T pix) -> T {return PixelToInch(pix) * 2.54;} return pix / PrintDPI;
}
template <typename T> constexpr inline auto PixelToMm(T pix) -> T
{
return PixelToInch(pix) * 25.4;
}
template <typename T> constexpr inline auto PixelToCm(T pix) -> T
{
return PixelToInch(pix) * 2.54;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel(double pix, const Unit &unit) -> double Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel(double pix, const Unit &unit) -> double
@ -465,9 +547,18 @@ Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel(double pix, const Unit &unit) ->
return 0; return 0;
} }
template<typename T> constexpr inline auto Inch2ToPixel2(T val) -> T {return val * (PrintDPI * PrintDPI);} template <typename T> constexpr inline auto Inch2ToPixel2(T val) -> T
template<typename T> constexpr inline auto Mm2ToPixel2(T val) -> T {return Inch2ToPixel2(val * 0.001550031);} {
template<typename T> constexpr inline auto Cm2ToPixel2(T val) -> T {return Inch2ToPixel2(val * 0.15500031);} return val * (PrintDPI * PrintDPI);
}
template <typename T> constexpr inline auto Mm2ToPixel2(T val) -> T
{
return Inch2ToPixel2(val * 0.001550031);
}
template <typename T> constexpr inline auto Cm2ToPixel2(T val) -> T
{
return Inch2ToPixel2(val * 0.15500031);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel2(double val, const Unit &unit) -> double Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel2(double val, const Unit &unit) -> double
@ -488,9 +579,18 @@ Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel2(double val, const Unit &unit) -> d
return 0; return 0;
} }
template<typename T> constexpr inline auto Pixel2ToInch2(T pix) -> T { return pix / (PrintDPI * PrintDPI);} template <typename T> constexpr inline auto Pixel2ToInch2(T pix) -> T
template<typename T> constexpr inline auto Pixel2ToMm2(T pix) -> T { return Pixel2ToInch2(pix) / 0.001550031;} {
template<typename T> constexpr inline auto Pixel2ToCm2(T pix) -> T { return Pixel2ToInch2(pix) / 0.15500031;} return pix / (PrintDPI * PrintDPI);
}
template <typename T> constexpr inline auto Pixel2ToMm2(T pix) -> T
{
return Pixel2ToInch2(pix) / 0.001550031;
}
template <typename T> constexpr inline auto Pixel2ToCm2(T pix) -> T
{
return Pixel2ToInch2(pix) / 0.15500031;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel2(double pix, const Unit &unit) -> double Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel2(double pix, const Unit &unit) -> double
@ -587,8 +687,8 @@ Q_DECL_RELAXED_CONSTEXPR inline auto UnitConvertor(qreal value, const Unit &from
* @brief UnitConvertor Converts the values of the given margin from given unit to the new unit. * @brief UnitConvertor Converts the values of the given margin from given unit to the new unit.
* returns a new instand of QMarginsF. * returns a new instand of QMarginsF.
*/ */
Q_DECL_RELAXED_CONSTEXPR inline auto UnitConvertor(const QMarginsF &margins, const Unit &from, Q_DECL_RELAXED_CONSTEXPR inline auto UnitConvertor(const QMarginsF &margins, const Unit &from, const Unit &to)
const Unit &to) -> QMarginsF -> QMarginsF
{ {
const qreal left = UnitConvertor(margins.left(), from, to); const qreal left = UnitConvertor(margins.left(), from, to);
const qreal top = UnitConvertor(margins.top(), from, to); const qreal top = UnitConvertor(margins.top(), from, to);
@ -642,7 +742,8 @@ struct CustomSARecord
endPoint(0), endPoint(0),
reverse(false), reverse(false),
includeType(PiecePathIncludeType::AsCustomSA) includeType(PiecePathIncludeType::AsCustomSA)
{} {
}
friend auto operator<<(QDataStream &out, const CustomSARecord &record) -> QDataStream &; friend auto operator<<(QDataStream &out, const CustomSARecord &record) -> QDataStream &;
friend auto operator>>(QDataStream &in, CustomSARecord &record) -> QDataStream &; friend auto operator>>(QDataStream &in, CustomSARecord &record) -> QDataStream &;
@ -672,7 +773,9 @@ Q_DECLARE_TYPEINFO(CustomSARecord, Q_MOVABLE_TYPE); // NOLINT
** this file shall be copyright (C) 2006-2008 by Adam Higerd. ** this file shall be copyright (C) 2006-2008 by Adam Higerd.
****************************************************************************/ ****************************************************************************/
#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d; #define QXT_DECLARE_PRIVATE(PUB) \
friend class PUB##Private; \
QxtPrivateInterface<PUB, PUB##Private> qxt_d;
#define QXT_DECLARE_PUBLIC(PUB) friend class PUB; #define QXT_DECLARE_PUBLIC(PUB) friend class PUB;
#define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this); #define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this);
#define QXT_D(PUB) PUB##Private &d = qxt_d() #define QXT_D(PUB) PUB##Private &d = qxt_d()
@ -682,18 +785,15 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") QT_WARNING_DISABLE_GCC("-Wsuggest-final-types")
QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
template <typename PUB> template <typename PUB> class QxtPrivate
class QxtPrivate
{ {
public: public:
QxtPrivate(): qxt_p_ptr(nullptr) QxtPrivate()
{} : qxt_p_ptr(nullptr)
virtual ~QxtPrivate()
{}
inline void QXT_setPublic(PUB* pub)
{ {
qxt_p_ptr = pub;
} }
virtual ~QxtPrivate() {}
inline void QXT_setPublic(PUB *pub) { qxt_p_ptr = pub; }
protected: protected:
inline auto qxt_p() -> PUB & { return *qxt_p_ptr; } inline auto qxt_p() -> PUB & { return *qxt_p_ptr; }
@ -709,22 +809,18 @@ private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
QT_WARNING_POP QT_WARNING_POP
template <typename PUB, typename PVT> template <typename PUB, typename PVT> class QxtPrivateInterface
class QxtPrivateInterface
{ {
friend class QxtPrivate<PUB>; friend class QxtPrivate<PUB>;
public:
QxtPrivateInterface() : pvt(new PVT)
{}
~QxtPrivateInterface()
{
delete pvt;
}
inline void setPublic(PUB* pub) public:
QxtPrivateInterface()
: pvt(new PVT)
{ {
pvt->QXT_setPublic(pub);
} }
~QxtPrivateInterface() { delete pvt; }
inline void setPublic(PUB *pub) { pvt->QXT_setPublic(pub); }
inline auto operator()() -> PVT & { return *static_cast<PVT *>(pvt); } inline auto operator()() -> PVT & { return *static_cast<PVT *>(pvt); }
inline auto operator()() const -> const PVT & { return *static_cast<PVT *>(pvt); } inline auto operator()() const -> const PVT & { return *static_cast<PVT *>(pvt); }
inline auto operator->() -> PVT * { return static_cast<PVT *>(pvt); } inline auto operator->() -> PVT * { return static_cast<PVT *>(pvt); }

View File

@ -29,12 +29,14 @@
#include "customevents.h" #include "customevents.h"
#include "vvalentinasettings.h" #include "vvalentinasettings.h"
#include <QTranslator>
#include <QWidget> #include <QWidget>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractValApplication::VAbstractValApplication(int &argc, char **argv) VAbstractValApplication::VAbstractValApplication(int &argc, char **argv)
: VAbstractApplication(argc, argv) : VAbstractApplication(argc, argv)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractValApplication::toPixel(double val) const -> double auto VAbstractValApplication::toPixel(double val) const -> double
@ -71,6 +73,7 @@ void VAbstractValApplication::OpenSettings()
auto VAbstractValApplication::ValentinaSettings() -> VValentinaSettings * auto VAbstractValApplication::ValentinaSettings() -> VValentinaSettings *
{ {
SCASSERT(settings != nullptr) SCASSERT(settings != nullptr)
return qobject_cast<VValentinaSettings *>(settings); return qobject_cast<VValentinaSettings *>(settings);
} }

View File

@ -37,12 +37,13 @@ class VAbstractPattern;
class VMainGraphicsView; class VMainGraphicsView;
class QGraphicsScene; class QGraphicsScene;
class VValentinaSettings; class VValentinaSettings;
class QTranslator;
class VAbstractValApplication : public VAbstractApplication class VAbstractValApplication : public VAbstractApplication
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public:
VAbstractValApplication(int &argc, char **argv); public : VAbstractValApplication(int &argc, char **argv);
virtual ~VAbstractValApplication() = default; virtual ~VAbstractValApplication() = default;
auto GetCustomerName() const -> QString; auto GetCustomerName() const -> QString;

View File

@ -29,16 +29,16 @@
#include "vcommonsettings.h" #include "vcommonsettings.h"
#include <QApplication> #include <QApplication>
#include <QColor>
#include <QDate> #include <QDate>
#include <QDir> #include <QDir>
#include <QFont>
#include <QGlobalStatic>
#include <QLocale> #include <QLocale>
#include <QMarginsF>
#include <QMessageLogger> #include <QMessageLogger>
#include <QVariant> #include <QVariant>
#include <QtDebug> #include <QtDebug>
#include <QFont>
#include <QGlobalStatic>
#include <QMarginsF>
#include <QColor>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "vtextcodec.h" #include "vtextcodec.h"
@ -46,9 +46,9 @@
#include <QTextCodec> #include <QTextCodec>
#endif #endif
#include "compatibility.h"
#include "def.h" #include "def.h"
#include "defglobal.h" #include "defglobal.h"
#include "compatibility.h"
#include "literals.h" #include "literals.h"
const int VCommonSettings::defaultScrollingDuration = 300; const int VCommonSettings::defaultScrollingDuration = 300;
@ -77,60 +77,92 @@ Q_DECLARE_METATYPE(QMarginsF) // NOLINT
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, (QLatin1String("paths/standard_measurements"))) // NOLINT (QLatin1String("paths/individual_measurements"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements,
(QLatin1String("paths/standard_measurements"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, (QLatin1String("paths/manualLayouts"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, (QLatin1String("paths/manualLayouts"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, (QLatin1String("configuration/osSeparator"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState, (QLatin1String("configuration/autosave/state"))) // NOLINT (QLatin1String("configuration/osSeparator"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime , (QLatin1String("configuration/autosave/time"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState,
(QLatin1String("configuration/autosave/state"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime,
(QLatin1String("configuration/autosave/time"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, (QLatin1String("configuration/pmscode"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, (QLatin1String("configuration/pmscode"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, (QLatin1String("configuration/unit"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, (QLatin1String("configuration/unit"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion, (QLatin1String("configuration/confirm_item_deletion"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting, (QLatin1String("configuration/confirm_format_rewriting"))) // NOLINT (QLatin1String("configuration/confirm_item_deletion"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayoutStale, (QLatin1String("configuration/askContinueIfLayoutStale"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, (QLatin1String("configuration/tool_bar_style"))) // NOLINT (QLatin1String("configuration/confirm_format_rewriting"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayoutStale,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP"))) // NOLINT (QLatin1String("configuration/askContinueIfLayoutStale"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationInteractiveTools, (QLatin1String("configuration/interactiveTools"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog, (QLatin1String("configuration/dontUseNativeDialog"))) // NOLINT (QLatin1String("configuration/tool_bar_style"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode,
(QLatin1String("configuration/freeCurveMode"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP,
(QLatin1String("configuration/doubleClickZoomFitBestCurrentPP"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationInteractiveTools,
(QLatin1String("configuration/interactiveTools"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog,
(QLatin1String("configuration/dontUseNativeDialog"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, (QLatin1String("pattern/forceFlipping"))) // NOLINT (QLatin1String("pattern/forbidFlipping"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSewLineOnDrawing, (QLatin1String("pattern/sewLineOnDrawing"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping,
(QLatin1String("pattern/forceFlipping"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSewLineOnDrawing,
(QLatin1String("pattern/sewLineOnDrawing"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, (QLatin1String("pattern/defaultSeamAllowance"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance,
(QLatin1String("pattern/defaultSeamAllowance"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, (QLatin1String("pattern/curveApproximationScale"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin1String("pattern/showCurveDetails"))) // NOLINT (QLatin1String("pattern/curveApproximationScale"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize"))) // NOLINT (QLatin1String("pattern/showCurveDetails"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath,
(QLatin1String("pattern/pieceShowMainPath"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize,
(QLatin1String("pattern/labelFontSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowAccuracyRadius, (QLatin1String("pattern/showAccuracyRadius"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowAccuracyRadius,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender"))) // NOLINT (QLatin1String("pattern/showAccuracyRadius"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender,
(QLatin1String("pattern/useOpenGLRender"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput,
(QLatin1String("pattern/graphicalOutput"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode, (QLatin1String("configuration/dark_mode"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode,
(QLatin1String("configuration/dark_mode"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, (QLatin1String("toolSeamAllowanceDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize"))) // NOLINT (QLatin1String("toolSeamAllowanceDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, (QLatin1String("formulaWizardDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, (QLatin1String("finalMeasurementsDialogSize"))) // NOLINT (QLatin1String("toolIncrementsDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize, (QLatin1String("layoutSettingsDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize,
(QLatin1String("formulaWizardDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize,
(QLatin1String("finalMeasurementsDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize,
(QLatin1String("layoutSettingsDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDialogSplinePathSize, (QLatin1String("splinePathDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDialogSplinePathSize, (QLatin1String("splinePathDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, (QLatin1String("automaticallyCheckUpdates"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, (QLatin1String("lastestSkippedVersion"))) // NOLINT (QLatin1String("automaticallyCheckUpdates"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion,
(QLatin1String("lastestSkippedVersion"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVWithHeader, (QLatin1String("csv/withHeader"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVWithHeader, (QLatin1String("csv/withHeader"))) // NOLINT
@ -138,21 +170,28 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVCodec, (QLatin1String("csv/wi
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, (QLatin1String("csv/withSeparator"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, (QLatin1String("csv/withSeparator"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1String("label/userDateFormats"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats,
(QLatin1String("label/userDateFormats"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats,
(QLatin1String("label/userTimeFormats"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, (QLatin1String("scrolling/sensorMouseScale"))) // NOLINT (QLatin1String("scrolling/updateInterval"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration"))) // NOLINT (QLatin1String("scrolling/sensorMouseScale"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale,
(QLatin1String("scrolling/wheelMouseScale"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration,
(QLatin1String("scrolling/acceleration"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors, (QLatin1String("watermarkCustomColors"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors,
(QLatin1String("watermarkCustomColors"))) // NOLINT
// Reading settings file is very expensive, cache curve approximation to speed up getting value // Reading settings file is very expensive, cache curve approximation to speed up getting value
qreal curveApproximationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) qreal curveApproximationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
@ -284,15 +323,17 @@ auto PrepareStandardFiles(const QString &currentPath, const QString &standardPat
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization, VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application,
const QString &application, QObject *parent) QObject *parent)
: QSettings(format, scope, organization, application, parent) : QSettings(format, scope, organization, application, parent)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCommonSettings::VCommonSettings(const QString &fileName, QSettings::Format format, QObject *parent) VCommonSettings::VCommonSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: QSettings(fileName, format, parent) : QSettings(fileName, format, parent)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::SharePath(const QString &shareItem) -> QString auto VCommonSettings::SharePath(const QString &shareItem) -> QString
@ -596,8 +637,8 @@ void VCommonSettings::SetPMSystemCode(const QString &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetUnit() const -> QString auto VCommonSettings::GetUnit() const -> QString
{ {
return value(*settingConfigurationUnit, return value(*settingConfigurationUnit, QLocale().measurementSystem() == QLocale::MetricSystem ? unitCM : unitINCH)
QLocale().measurementSystem() == QLocale::MetricSystem ? unitCM : unitINCH).toString(); .toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -666,7 +707,6 @@ void VCommonSettings::SetDarkMode(const bool &value)
setValue(*settingConfigurationDarkMode, value); setValue(*settingConfigurationDarkMode, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::IsFreeCurveMode() const -> bool auto VCommonSettings::IsFreeCurveMode() const -> bool
{ {
@ -1102,8 +1142,7 @@ auto VCommonSettings::GetDefaultSeamAllowance() -> double
if (not ok) if (not ok)
{ {
qDebug() << "Could not convert value" << value(*settingPatternDefaultSeamAllowance, 0) qDebug() << "Could not convert value" << value(*settingPatternDefaultSeamAllowance, 0)
<< "to real. Return default value for default seam allowance is " << "to real. Return default value for default seam allowance is " << defaultValue << QChar('.');
<< defaultValue << QChar('.');
val = defaultValue; val = defaultValue;
} }
@ -1188,8 +1227,8 @@ void VCommonSettings::SetShowAccuracyRadius(bool value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetLabelDateFormat() const -> QString auto VCommonSettings::GetLabelDateFormat() const -> QString
{ {
const QString format = value(*settingLabelDateFormat, const QString format =
ConstFirst<QString> (VCommonSettings::PredefinedDateFormats())).toString(); value(*settingLabelDateFormat, ConstFirst<QString>(VCommonSettings::PredefinedDateFormats())).toString();
const QStringList allFormats = VCommonSettings::PredefinedDateFormats() + GetUserDefinedDateFormats(); const QStringList allFormats = VCommonSettings::PredefinedDateFormats() + GetUserDefinedDateFormats();
return allFormats.contains(format) ? format : ConstFirst<QString>(VCommonSettings::PredefinedDateFormats()); return allFormats.contains(format) ? format : ConstFirst<QString>(VCommonSettings::PredefinedDateFormats());
@ -1204,9 +1243,7 @@ void VCommonSettings::SetLabelDateFormat(const QString &format)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::PredefinedDateFormats() -> QStringList auto VCommonSettings::PredefinedDateFormats() -> QStringList
{ {
return QStringList return QStringList{"MM-dd-yyyy",
{
"MM-dd-yyyy",
"d/M/yy", "d/M/yy",
"ddddMMMM dd, yyyy", "ddddMMMM dd, yyyy",
"dd/MM/yy", "dd/MM/yy",
@ -1225,8 +1262,7 @@ auto VCommonSettings::PredefinedDateFormats() -> QStringList
"yyyy-MM-dd", "yyyy-MM-dd",
"MM/yy", "MM/yy",
"MMM dd", "MMM dd",
"MMMM" "MMMM"};
};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1244,8 +1280,8 @@ void VCommonSettings::SetUserDefinedDateFormats(const QStringList &formats)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetLabelTimeFormat() const -> QString auto VCommonSettings::GetLabelTimeFormat() const -> QString
{ {
const QString format = value(*settingLabelTimeFormat, const QString format =
ConstFirst<QString> (VCommonSettings::PredefinedTimeFormats())).toString(); value(*settingLabelTimeFormat, ConstFirst<QString>(VCommonSettings::PredefinedTimeFormats())).toString();
const QStringList allFormats = VCommonSettings::PredefinedTimeFormats() + GetUserDefinedTimeFormats(); const QStringList allFormats = VCommonSettings::PredefinedTimeFormats() + GetUserDefinedTimeFormats();
return allFormats.contains(format) ? format : ConstFirst<QString>(VCommonSettings::PredefinedTimeFormats()); return allFormats.contains(format) ? format : ConstFirst<QString>(VCommonSettings::PredefinedTimeFormats());
@ -1260,13 +1296,7 @@ void VCommonSettings::SetLabelTimeFormat(const QString &format)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::PredefinedTimeFormats() -> QStringList auto VCommonSettings::PredefinedTimeFormats() -> QStringList
{ {
return QStringList return QStringList{"hh:mm:ss", "hh:mm:ss AP", "hh:mm", "hh:mm AP"};
{
"hh:mm:ss",
"hh:mm:ss AP",
"hh:mm",
"hh:mm AP"
};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1512,8 +1542,8 @@ void VCommonSettings::SetGraphicalOutput(const bool &value)
auto VCommonSettings::GetTiledPDFMargins(const Unit &unit) const -> QMarginsF auto VCommonSettings::GetTiledPDFMargins(const Unit &unit) const -> QMarginsF
{ {
// default value is 10mm. We save the margins in mm in the setting. // default value is 10mm. We save the margins in mm in the setting.
return UnitConvertor( return UnitConvertor(ValueOrDef<QMarginsF>(*this, *settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm,
ValueOrDef<QMarginsF>(*this, *settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm, unit); unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -38,17 +38,16 @@
#include <QStringList> #include <QStringList>
#include <QtGlobal> #include <QtGlobal>
#include "../vmisc/def.h"
#include "../vlayout/vlayoutdef.h" #include "../vlayout/vlayoutdef.h"
#include "../vmisc/def.h"
class QMarginsF; class QMarginsF;
class VCommonSettings : public QSettings class VCommonSettings : public QSettings
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public : VCommonSettings(Format format, Scope scope, const QString &organization,
VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), const QString &application = QString(), QObject *parent = nullptr);
QObject *parent = nullptr);
VCommonSettings(const QString &fileName, Format format, QObject *parent = nullptr); VCommonSettings(const QString &fileName, Format format, QObject *parent = nullptr);
~VCommonSettings() override = default; ~VCommonSettings() override = default;
@ -306,7 +305,6 @@ public:
void SetWatermarkCustomColors(QVector<QColor> colors); void SetWatermarkCustomColors(QVector<QColor> colors);
protected: protected:
template <typename T> template <typename T>
static auto GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin, static auto GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin,
T valueMax) -> T; T valueMax) -> T;
@ -359,8 +357,8 @@ inline auto VCommonSettings::ValueOrDef(const QSettings &settings, const QString
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <>
inline auto VCommonSettings::ValueOrDef<Cases>(const QSettings &settings, const QString &setting, inline auto VCommonSettings::ValueOrDef<Cases>(const QSettings &settings, const QString &setting, const Cases &defValue)
const Cases &defValue) -> Cases -> Cases
{ {
const QVariant val = settings.value(setting, QVariant::fromValue(static_cast<int>(defValue))); const QVariant val = settings.value(setting, QVariant::fromValue(static_cast<int>(defValue)));
const int g = val.canConvert<int>() ? val.toInt() : static_cast<int>(defValue); const int g = val.canConvert<int>() ? val.toInt() : static_cast<int>(defValue);

View File

@ -28,26 +28,26 @@
#include "vcontainer.h" #include "vcontainer.h"
#include <climits> #include <QLoggingCategory>
#include <QUuid>
#include <QVector> #include <QVector>
#include <QtDebug> #include <QtDebug>
#include <QUuid> #include <climits>
#include <QLoggingCategory>
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vgeometry/vabstractcubicbezierpath.h" #include "../vgeometry/vabstractcubicbezierpath.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vgeometrydef.h" #include "../vgeometry/vgeometrydef.h"
#include "../vgeometry/vgobject.h" #include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h" #include "../vgeometry/vspline.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
#include "variables/varcradius.h" #include "variables/varcradius.h"
#include "variables/vcurveangle.h" #include "variables/vcurveangle.h"
#include "variables/vcurvelength.h"
#include "variables/vcurveclength.h" #include "variables/vcurveclength.h"
#include "variables/vcurvelength.h"
#include "variables/vincrement.h" #include "variables/vincrement.h"
#include "variables/vlineangle.h" #include "variables/vlineangle.h"
#include "variables/vlinelength.h" #include "variables/vlinelength.h"
@ -119,9 +119,9 @@ auto VContainer::operator=(const VContainer &data) -> VContainer &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VContainer::VContainer(VContainer &&data) Q_DECL_NOTHROW VContainer::VContainer(VContainer &&data) Q_DECL_NOTHROW : d(std::move(data.d))
:d(std::move(data.d)) {
{} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VContainer::operator=(VContainer &&data) Q_DECL_NOTHROW->VContainer & auto VContainer::operator=(VContainer &&data) Q_DECL_NOTHROW->VContainer &
@ -144,7 +144,8 @@ VContainer::VContainer(const VContainer &data)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VContainer::~VContainer() VContainer::~VContainer()
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VContainer::UniqueNamespace() -> QString auto VContainer::UniqueNamespace() -> QString
@ -153,8 +154,7 @@ auto VContainer::UniqueNamespace() -> QString
do do
{ {
candidate = QUuid::createUuid().toString(); candidate = QUuid::createUuid().toString();
} } while (_id.contains(candidate));
while(_id.contains(candidate));
return candidate; return candidate;
} }
@ -204,11 +204,9 @@ auto VContainer::GetPiece(quint32 id) const -> VPiece
{ {
return d->pieces->value(id); return d->pieces->value(id);
} }
else
{
throw VExceptionBadId(tr("Can't find object"), id); throw VExceptionBadId(tr("Can't find object"), id);
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VContainer::GetPiecePath(quint32 id) const -> VPiecePath auto VContainer::GetPiecePath(quint32 id) const -> VPiecePath
@ -392,15 +390,9 @@ void VContainer::ClearForFullParse()
d->pieces->clear(); d->pieces->clear();
d->piecePaths->clear(); d->piecePaths->clear();
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 12, "Check that you used all types"); Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 12, "Check that you used all types");
ClearVariables(QVector<VarType>{VarType::Increment, ClearVariables(QVector<VarType>{VarType::Increment, VarType::IncrementSeparator, VarType::LineAngle,
VarType::IncrementSeparator, VarType::LineLength, VarType::CurveLength, VarType::CurveCLength,
VarType::LineAngle, VarType::ArcRadius, VarType::CurveAngle, VarType::PieceExternalArea,
VarType::LineLength,
VarType::CurveLength,
VarType::CurveCLength,
VarType::ArcRadius,
VarType::CurveAngle,
VarType::PieceExternalArea,
VarType::PieceSeamLineArea}); VarType::PieceSeamLineArea});
ClearGObjects(); ClearGObjects();
ClearUniqueNames(); ClearUniqueNames();
@ -495,9 +487,8 @@ void VContainer::AddArc(const QSharedPointer<VAbstractCurve> &arc, const quint32
void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, quint32 parentId) void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, quint32 parentId)
{ {
const GOType curveType = curve->getType(); const GOType curveType = curve->getType();
if (curveType != GOType::Spline && curveType != GOType::SplinePath && if (curveType != GOType::Spline && curveType != GOType::SplinePath && curveType != GOType::CubicBezier &&
curveType != GOType::CubicBezier && curveType != GOType::CubicBezierPath && curveType != GOType::CubicBezierPath && curveType != GOType::Arc && curveType != GOType::EllipticalArc)
curveType != GOType::Arc && curveType != GOType::EllipticalArc)
{ {
throw VException(tr("Can't create a curve with type '%1'").arg(static_cast<int>(curveType))); throw VException(tr("Can't create a curve with type '%1'").arg(static_cast<int>(curveType)));
} }

View File

@ -27,28 +27,28 @@
*************************************************************************/ *************************************************************************/
#include "dialogeditlabel.h" #include "dialogeditlabel.h"
#include "ui_dialogeditlabel.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "ui_dialogeditlabel.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vformat/vlabeltemplate.h"
#include "../ifc/xml/vlabeltemplateconverter.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vpatterndb/vcontainer.h" #include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/vpiece.h" #include "../ifc/xml/vlabeltemplateconverter.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include "../tools/dialogtool.h"
#include "../vformat/vlabeltemplate.h"
#include "../vpatterndb/calculator.h" #include "../vpatterndb/calculator.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/variables/vpiecearea.h" #include "../vpatterndb/variables/vpiecearea.h"
#include "../tools/dialogtool.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpiece.h"
#include <QDate>
#include <QDir> #include <QDir>
#include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QMenu> #include <QMenu>
#include <QDate> #include <QMessageBox>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogEditLabel::DialogEditLabel(const VAbstractPattern *doc, const VContainer *data, QWidget *parent) DialogEditLabel::DialogEditLabel(const VAbstractPattern *doc, const VContainer *data, QWidget *parent)
@ -77,7 +77,8 @@ DialogEditLabel::DialogEditLabel(const VAbstractPattern *doc, const VContainer *
connect(ui->toolButtonImportLabel, &QToolButton::clicked, this, &DialogEditLabel::ImportTemplate); connect(ui->toolButtonImportLabel, &QToolButton::clicked, this, &DialogEditLabel::ImportTemplate);
connect(ui->spinBoxFontSize, QOverload<int>::of(&QSpinBox::valueChanged), this, connect(ui->spinBoxFontSize, QOverload<int>::of(&QSpinBox::valueChanged), this,
&DialogEditLabel::SaveAdditionalFontSize); &DialogEditLabel::SaveAdditionalFontSize);
connect(ui->toolButtonTop, &QToolButton::clicked, this, [this](){DialogTool::MoveListRowTop(ui->listWidgetEdit);}); connect(ui->toolButtonTop, &QToolButton::clicked, this,
[this]() { DialogTool::MoveListRowTop(ui->listWidgetEdit); });
connect(ui->toolButtonUp, &QToolButton::clicked, this, [this]() { DialogTool::MoveListRowUp(ui->listWidgetEdit); }); connect(ui->toolButtonUp, &QToolButton::clicked, this, [this]() { DialogTool::MoveListRowUp(ui->listWidgetEdit); });
connect(ui->toolButtonDown, &QToolButton::clicked, this, connect(ui->toolButtonDown, &QToolButton::clicked, this,
[this]() { DialogTool::MoveListRowDown(ui->listWidgetEdit); }); [this]() { DialogTool::MoveListRowDown(ui->listWidgetEdit); });
@ -279,7 +280,8 @@ void DialogEditLabel::NewTemplate()
{ {
if (ui->listWidgetEdit->count() > 0) if (ui->listWidgetEdit->count() > 0)
{ {
const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Create new template"), const QMessageBox::StandardButton answer =
QMessageBox::question(this, tr("Create new template"),
tr("Creating new template will overwrite the current, do " tr("Creating new template will overwrite the current, do "
"you want to continue?"), "you want to continue?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
@ -340,7 +342,8 @@ void DialogEditLabel::ImportTemplate()
{ {
if (ui->listWidgetEdit->count() > 0) if (ui->listWidgetEdit->count() > 0)
{ {
const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Import template"), const QMessageBox::StandardButton answer =
QMessageBox::question(this, tr("Import template"),
tr("Import template will overwrite the current, do " tr("Import template will overwrite the current, do "
"you want to continue?"), "you want to continue?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
@ -518,22 +521,22 @@ void DialogEditLabel::InitPlaceholders()
const QString pUnits = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const QString pUnits = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
m_placeholders.insert(pl_pUnits, qMakePair(tr("Pattern units"), pUnits)); m_placeholders.insert(pl_pUnits, qMakePair(tr("Pattern units"), pUnits));
m_placeholders.insert(pl_mSizeUnits, qMakePair(tr("Size units"), m_placeholders.insert(
UnitsToStr(VAbstractValApplication::VApp()->DimensionSizeUnits(), pl_mSizeUnits,
true))); qMakePair(tr("Size units"), UnitsToStr(VAbstractValApplication::VApp()->DimensionSizeUnits(), true)));
m_placeholders.insert(pl_areaUnits, qMakePair(tr("Area units"), pUnits + QStringLiteral("²"))); m_placeholders.insert(pl_areaUnits, qMakePair(tr("Area units"), pUnits + QStringLiteral("²")));
if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Individual) if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Individual)
{ {
m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), m_placeholders.insert(pl_customer,
VAbstractValApplication::VApp()->GetCustomerName())); qMakePair(tr("Customer name"), VAbstractValApplication::VApp()->GetCustomerName()));
const QString birthDate = locale.toString(VAbstractValApplication::VApp()->GetCustomerBirthDate(), const QString birthDate =
m_doc->GetLabelDateFormat()); locale.toString(VAbstractValApplication::VApp()->GetCustomerBirthDate(), m_doc->GetLabelDateFormat());
m_placeholders.insert(pl_birthDate, qMakePair(tr("Customer birth date"), birthDate)); m_placeholders.insert(pl_birthDate, qMakePair(tr("Customer birth date"), birthDate));
m_placeholders.insert(pl_email, qMakePair(tr("Customer email"), m_placeholders.insert(pl_email,
VAbstractValApplication::VApp()->CustomerEmail())); qMakePair(tr("Customer email"), VAbstractValApplication::VApp()->CustomerEmail()));
} }
else else
{ {
@ -571,35 +574,35 @@ void DialogEditLabel::InitPlaceholders()
{ {
QString label = VAbstractValApplication::VApp()->GetDimensionHeightLabel(); QString label = VAbstractValApplication::VApp()->GetDimensionHeightLabel();
m_placeholders.insert(pl_heightLabel, qMakePair(tr("Height label", "dimension"), m_placeholders.insert(pl_heightLabel,
not label.isEmpty() ? label : heightValue)); qMakePair(tr("Height label", "dimension"), not label.isEmpty() ? label : heightValue));
m_placeholders.insert(pl_dimensionX, qMakePair(tr("Dimension X label", "dimension"), m_placeholders.insert(
not label.isEmpty() ? label : heightValue)); pl_dimensionX, qMakePair(tr("Dimension X label", "dimension"), not label.isEmpty() ? label : heightValue));
label = VAbstractValApplication::VApp()->GetDimensionSizeLabel(); label = VAbstractValApplication::VApp()->GetDimensionSizeLabel();
m_placeholders.insert(pl_sizeLabel, qMakePair(tr("Size label", "dimension"), m_placeholders.insert(pl_sizeLabel,
not label.isEmpty() ? label : sizeValue)); qMakePair(tr("Size label", "dimension"), not label.isEmpty() ? label : sizeValue));
m_placeholders.insert(pl_dimensionY, qMakePair(tr("Dimension Y label", "dimension"), m_placeholders.insert(pl_dimensionY,
not label.isEmpty() ? label : sizeValue)); qMakePair(tr("Dimension Y label", "dimension"), not label.isEmpty() ? label : sizeValue));
label = VAbstractValApplication::VApp()->GetDimensionHipLabel(); label = VAbstractValApplication::VApp()->GetDimensionHipLabel();
m_placeholders.insert(pl_hipLabel, qMakePair(tr("Hip label", "dimension"), m_placeholders.insert(pl_hipLabel,
not label.isEmpty() ? label : hipValue)); qMakePair(tr("Hip label", "dimension"), not label.isEmpty() ? label : hipValue));
m_placeholders.insert(pl_dimensionZ, qMakePair(tr("Dimension Z label", "dimension"), m_placeholders.insert(pl_dimensionZ,
not label.isEmpty() ? label : hipValue)); qMakePair(tr("Dimension Z label", "dimension"), not label.isEmpty() ? label : hipValue));
label = VAbstractValApplication::VApp()->GetDimensionWaistLabel(); label = VAbstractValApplication::VApp()->GetDimensionWaistLabel();
m_placeholders.insert(pl_waistLabel, qMakePair(tr("Waist label", "dimension"), m_placeholders.insert(pl_waistLabel,
not label.isEmpty() ? label : waistValue)); qMakePair(tr("Waist label", "dimension"), not label.isEmpty() ? label : waistValue));
m_placeholders.insert(pl_dimensionW, qMakePair(tr("Dimension W label", "dimension"), m_placeholders.insert(
not label.isEmpty() ? label : waistValue)); pl_dimensionW, qMakePair(tr("Dimension W label", "dimension"), not label.isEmpty() ? label : waistValue));
} }
m_placeholders.insert(
m_placeholders.insert(pl_mExt, pl_mExt, qMakePair(tr("Measurments extension"),
qMakePair(tr("Measurments extension"),
VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize
? QStringLiteral("vst") : QStringLiteral("vit"))); ? QStringLiteral("vst")
: QStringLiteral("vit")));
const QString userMaterialStr = tr("User material"); const QString userMaterialStr = tr("User material");
const QMap<int, QString> materials = m_doc->GetPatternMaterials(); const QMap<int, QString> materials = m_doc->GetPatternMaterials();
@ -651,15 +654,18 @@ void DialogEditLabel::InitPlaceholders()
QScopedPointer<Calculator> cal(new Calculator()); QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(completeData.DataVariables(), m.formula); const qreal result = cal->EvalFormula(completeData.DataVariables(), m.formula);
m_placeholders.insert(pl_finalMeasurement + m.name, qMakePair(tr("Final measurement: %1").arg(m.name), m_placeholders.insert(pl_finalMeasurement + m.name,
QString::number(result))); qMakePair(tr("Final measurement: %1").arg(m.name), QString::number(result)));
} }
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at " const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at "
"line %1: %2.").arg(i+1).arg(e.GetMsg()); "line %1: %2.")
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : .arg(i + 1)
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; .arg(e.GetMsg());
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
} }
@ -690,8 +696,9 @@ auto DialogEditLabel::ReplacePlaceholders(QString line) const -> QString
{ {
if (line.contains(per + placeholder + per) && m_placeholders.value(placeholder).second == QChar('0')) if (line.contains(per + placeholder + per) && m_placeholders.value(placeholder).second == QChar('0'))
{ {
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
}; };
@ -803,8 +810,9 @@ void DialogEditLabel::SetPiece(const VPiece &piece)
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
const QString errorMsg = QObject::tr("Failed to prepare full piece area placeholder. %2.").arg(e.GetMsg()); const QString errorMsg = QObject::tr("Failed to prepare full piece area placeholder. %2.").arg(e.GetMsg());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
try try
@ -816,8 +824,9 @@ void DialogEditLabel::SetPiece(const VPiece &piece)
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
const QString errorMsg = QObject::tr("Failed to prepare piece seam line area placeholder. %2.").arg(e.GetMsg()); const QString errorMsg = QObject::tr("Failed to prepare piece seam line area placeholder. %2.").arg(e.GetMsg());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }

View File

@ -70,7 +70,6 @@
#include "nodeDetails/vtoolplacelabel.h" #include "nodeDetails/vtoolplacelabel.h"
#include <QFuture> #include <QFuture>
#include <QtConcurrent/QtConcurrentRun>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QGraphicsView> #include <QGraphicsView>
#include <QKeyEvent> #include <QKeyEvent>
@ -78,6 +77,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QTimer> #include <QTimer>
#include <QUuid> #include <QUuid>
#include <QtConcurrent/QtConcurrentRun>
#include <QtMath> #include <QtMath>
#include <chrono> #include <chrono>
#include <memory> #include <memory>
@ -118,8 +118,7 @@ const QString VToolSeamAllowance::AttrPiecePriority = QStringLiteral("priority")
namespace namespace
{ {
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename T> template <typename T> auto FixLabelPins(T itemData, const QMap<quint32, quint32> &mappedPins) -> T
auto FixLabelPins(T itemData, const QMap<quint32, quint32> &mappedPins) -> T
{ {
itemData.SetCenterPin(mappedPins.value(itemData.CenterPin(), NULL_ID)); itemData.SetCenterPin(mappedPins.value(itemData.CenterPin(), NULL_ID));
itemData.SetTopLeftPin(mappedPins.value(itemData.TopLeftPin(), NULL_ID)); itemData.SetTopLeftPin(mappedPins.value(itemData.TopLeftPin(), NULL_ID));
@ -128,8 +127,7 @@ auto FixLabelPins(T itemData, const QMap<quint32, quint32> &mappedPins) -> T
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename T> template <typename T> auto FixGrainlinePins(T itemData, const QMap<quint32, quint32> &mappedPins) -> T
auto FixGrainlinePins(T itemData, const QMap<quint32, quint32> &mappedPins) -> T
{ {
itemData.SetCenterPin(mappedPins.value(itemData.CenterPin(), NULL_ID)); itemData.SetCenterPin(mappedPins.value(itemData.CenterPin(), NULL_ID));
itemData.SetTopPin(mappedPins.value(itemData.TopPin(), NULL_ID)); itemData.SetTopPin(mappedPins.value(itemData.TopPin(), NULL_ID));
@ -190,9 +188,7 @@ void UpdateLabelItem(VTextGraphicsItem *labelItem, QPointF pos, qreal labelAngle
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolSeamAllowance::Create(const QPointer<DialogTool> &dialog, auto VToolSeamAllowance::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VMainGraphicsScene *scene,
VAbstractPattern *doc,
VContainer *data) -> VToolSeamAllowance * VContainer *data) -> VToolSeamAllowance *
{ {
SCASSERT(not dialog.isNull()); SCASSERT(not dialog.isNull());
@ -222,8 +218,9 @@ auto VToolSeamAllowance::Create(const QPointer<DialogTool> &dialog,
{ {
const QString errorMsg = QObject::tr("Piece '%1'. Unable to load default piece label template.\n%2\n%3") const QString errorMsg = QObject::tr("Piece '%1'. Unable to load default piece label template.\n%2\n%3")
.arg(initData.detail.GetName(), e.ErrorMessage(), e.DetailedInformation()); .arg(initData.detail.GetName(), e.ErrorMessage(), e.DetailedInformation());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
@ -288,9 +285,8 @@ auto VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initData) -> VToolSe
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolSeamAllowance::Duplicate(const QPointer<DialogTool> &dialog, auto VToolSeamAllowance::Duplicate(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc)
VMainGraphicsScene *scene, -> VToolSeamAllowance *
VAbstractPattern *doc) -> VToolSeamAllowance *
{ {
SCASSERT(not dialog.isNull()); SCASSERT(not dialog.isNull());
const QPointer<DialogDuplicateDetail> dialogTool = qobject_cast<DialogDuplicateDetail *>(dialog); const QPointer<DialogDuplicateDetail> dialogTool = qobject_cast<DialogDuplicateDetail *>(dialog);
@ -327,8 +323,8 @@ auto VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData) -> VToo
QMap<quint32, quint32> replacements; QMap<quint32, quint32> replacements;
dupDetail.GetPath().SetNodes(DuplicateNodes(initData.detail.GetPath(), initData, replacements)); dupDetail.GetPath().SetNodes(DuplicateNodes(initData.detail.GetPath(), initData, replacements));
dupDetail.SetCustomSARecords(DuplicateCustomSARecords(initData.detail.GetCustomSARecords(), initData, dupDetail.SetCustomSARecords(
replacements)); DuplicateCustomSARecords(initData.detail.GetCustomSARecords(), initData, replacements));
dupDetail.SetInternalPaths(DuplicateInternalPaths(initData.detail.GetInternalPaths(), initData)); dupDetail.SetInternalPaths(DuplicateInternalPaths(initData.detail.GetInternalPaths(), initData));
dupDetail.SetPlaceLabels(DuplicatePlaceLabels(initData.detail.GetPlaceLabels(), initData)); dupDetail.SetPlaceLabels(DuplicatePlaceLabels(initData.detail.GetPlaceLabels(), initData));
dupDetail.SetUUID(QUuid::createUuid()); dupDetail.SetUUID(QUuid::createUuid());
@ -649,7 +645,10 @@ void VToolSeamAllowance::ReinitInternals(const VPiece &detail, VMainGraphicsScen
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolSeamAllowance::getTagName() const -> QString { return VAbstractPattern::TagDetail; } auto VToolSeamAllowance::getTagName() const -> QString
{
return VAbstractPattern::TagDetail;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::ShowVisualization(bool show) void VToolSeamAllowance::ShowVisualization(bool show)
@ -841,10 +840,10 @@ void VToolSeamAllowance::UpdateGrainline()
if (m_geometryIsReady && not IsGrainlinePositionValid()) if (m_geometryIsReady && not IsGrainlinePositionValid())
{ {
const QString errorMsg = QObject::tr("Piece '%1'. Grainline is not valid.") const QString errorMsg = QObject::tr("Piece '%1'. Grainline is not valid.").arg(detail.GetName());
.arg(detail.GetName()); VAbstractApplication::VApp()->IsPedantic()
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : ? throw VException(errorMsg)
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
else else
@ -909,7 +908,6 @@ void VToolSeamAllowance::SaveRotationDetail(qreal dRot)
VAbstractApplication::VApp()->getUndoStack()->push(rotateCommand); VAbstractApplication::VApp()->getUndoStack()->push(rotateCommand);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief SaveMovePattern saves the pattern label position * @brief SaveMovePattern saves the pattern label position
@ -964,7 +962,6 @@ void VToolSeamAllowance::SaveRotationPattern(qreal dRot)
VAbstractApplication::VApp()->getUndoStack()->push(rotateCommand); VAbstractApplication::VApp()->getUndoStack()->push(rotateCommand);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::SaveMoveGrainline(const QPointF &ptPos) void VToolSeamAllowance::SaveMoveGrainline(const QPointF &ptPos)
{ {
@ -1082,8 +1079,8 @@ void VToolSeamAllowance::AddToFile()
AddPins(doc, domElement, piece.GetPins()); AddPins(doc, domElement, piece.GetPins());
AddPlaceLabels(doc, domElement, piece.GetPlaceLabels()); AddPlaceLabels(doc, domElement, piece.GetPlaceLabels());
VAbstractApplication::VApp()->getUndoStack()->push(new AddPiece(domElement, doc, VAbstractTool::data, VAbstractApplication::VApp()->getUndoStack()->push(
m_sceneDetails, m_drawName)); new AddPiece(domElement, doc, VAbstractTool::data, m_sceneDetails, m_drawName));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1095,8 +1092,7 @@ void VToolSeamAllowance::RefreshDataInFile()
// Refresh only parts that we possibly need to update // Refresh only parts that we possibly need to update
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
const uint version = VAbstractPattern::GetParametrUInt(domElement, AttrVersion, QChar('1')); const uint version = VAbstractPattern::GetParametrUInt(domElement, AttrVersion, QChar('1'));
if (version == 1) if (version == 1)
@ -1133,8 +1129,8 @@ auto VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change, co
// value - this is new position. // value - this is new position.
const QPointF newPos = value.toPointF(); const QPointF newPos = value.toPointF();
VAbstractApplication::VApp()->getUndoStack()->push(new MovePiece(doc, newPos.x(), newPos.y(), m_id, VAbstractApplication::VApp()->getUndoStack()->push(
scene())); new MovePiece(doc, newPos.x(), newPos.y(), m_id, scene()));
const QList<QGraphicsView *> viewList = scene()->views(); const QList<QGraphicsView *> viewList = scene()->views();
if (not viewList.isEmpty()) if (not viewList.isEmpty())
@ -1187,7 +1183,8 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (selectionType == SelectionType::ByMouseRelease) if (selectionType == SelectionType::ByMouseRelease)
{ {
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event event
->accept(); // Special for not selectable item first need to call standard mousePressEvent then accept event
} }
else else
{ {
@ -1458,15 +1455,16 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
if (detail.IsSeamAllowance()) if (detail.IsSeamAllowance())
{ {
futureSeamAllowance = QtConcurrent::run([this, detail]() { return detail.SeamAllowancePoints(getData()); }); futureSeamAllowance = QtConcurrent::run([this, detail]() { return detail.SeamAllowancePoints(getData()); });
futureSeamAllowanceValid = QtConcurrent::run([this, detail](){return detail.IsSeamAllowanceValid(getData());}); futureSeamAllowanceValid =
QtConcurrent::run([this, detail]() { return detail.IsSeamAllowanceValid(getData()); });
} }
this->setPos(detail.GetMx(), detail.GetMy()); this->setPos(detail.GetMx(), detail.GetMy());
QPainterPath path; QPainterPath path;
if (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not detail.IsHideMainPath() if (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not detail.IsHideMainPath() ||
|| not detail.IsSeamAllowance() || detail.IsSeamAllowanceBuiltIn()) not detail.IsSeamAllowance() || detail.IsSeamAllowanceBuiltIn())
{ {
m_mainPath = QPainterPath(); m_mainPath = QPainterPath();
m_seamAllowance->setBrush(QBrush(Qt::Dense7Pattern)); m_seamAllowance->setBrush(QBrush(Qt::Dense7Pattern));
@ -1488,10 +1486,10 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
{ {
if (not futureSeamAllowanceValid.result()) if (not futureSeamAllowanceValid.result())
{ {
const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.") const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.").arg(detail.GetName());
.arg(detail.GetName()); VAbstractApplication::VApp()->IsPedantic()
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : ? throw VException(errorMsg)
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
path.addPath(detail.SeamAllowancePath(futureSeamAllowance.result())); path.addPath(detail.SeamAllowancePath(futureSeamAllowance.result()));
path.setFillRule(Qt::OddEvenFill); path.setFillRule(Qt::OddEvenFill);
@ -1508,7 +1506,8 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
if (VAbstractApplication::VApp()->IsAppInGUIMode()) if (VAbstractApplication::VApp()->IsAppInGUIMode())
{ {
QTimer::singleShot(V_MSECONDS(100), Qt::CoarseTimer, this, [this, updateChildren]() QTimer::singleShot(V_MSECONDS(100), Qt::CoarseTimer, this,
[this, updateChildren]()
{ {
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
UpdateDetailLabel(); UpdateDetailLabel();
@ -1583,8 +1582,8 @@ void VToolSeamAllowance::SaveDialogChange(const QString &undoText)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::ShowOptions() void VToolSeamAllowance::ShowOptions()
{ {
QPointer<DialogSeamAllowance> dialog = new DialogSeamAllowance(getData(), doc, m_id, QPointer<DialogSeamAllowance> dialog =
VAbstractValApplication::VApp()->getMainWindow()); new DialogSeamAllowance(getData(), doc, m_id, VAbstractValApplication::VApp()->getMainWindow());
dialog->EnableApply(true); dialog->EnableApply(true);
m_dialog = dialog; m_dialog = dialog;
m_dialog->setModal(true); m_dialog->setModal(true);
@ -1605,17 +1604,15 @@ void VToolSeamAllowance::ToggleInLayout(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::ToggleForbidFlipping(bool checked) void VToolSeamAllowance::ToggleForbidFlipping(bool checked)
{ {
VAbstractApplication::VApp()->getUndoStack()->push( VAbstractApplication::VApp()->getUndoStack()->push(new TogglePieceForceForbidFlipping(
new TogglePieceForceForbidFlipping(m_id, checked, ForceForbidFlippingType::ForbidFlipping, m_id, checked, ForceForbidFlippingType::ForbidFlipping, &(VAbstractTool::data), doc));
&(VAbstractTool::data), doc));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::ToggleForceFlipping(bool checked) void VToolSeamAllowance::ToggleForceFlipping(bool checked)
{ {
VAbstractApplication::VApp()->getUndoStack()->push( VAbstractApplication::VApp()->getUndoStack()->push(new TogglePieceForceForbidFlipping(
new TogglePieceForceForbidFlipping(m_id, checked, ForceForbidFlippingType::ForceFlipping, m_id, checked, ForceForbidFlippingType::ForceFlipping, &(VAbstractTool::data), doc));
&(VAbstractTool::data), doc));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1766,19 +1763,17 @@ void VToolSeamAllowance::ResetPieceLabelTemplate()
{ {
const QString errorMsg = QObject::tr("Piece '%1'. Unable to load default piece label template.\n%2\n%3") const QString errorMsg = QObject::tr("Piece '%1'. Unable to load default piece label template.\n%2\n%3")
.arg(newDet.GetName(), e.ErrorMessage(), e.DetailedInformation()); .arg(newDet.GetName(), e.ErrorMessage(), e.DetailedInformation());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData &labelData, auto VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData &labelData, const QVector<quint32> &pins,
const QVector<quint32> &pins, qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos)
qreal &rotationAngle, -> VPieceItem::MoveTypes
qreal &labelWidth,
qreal &labelHeight,
QPointF &pos) -> VPieceItem::MoveTypes
{ {
VPieceItem::MoveTypes restrictions = VPieceItem::AllModifications; VPieceItem::MoveTypes restrictions = VPieceItem::AllModifications;
@ -1801,16 +1796,16 @@ auto VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData &labelData,
const quint32 topLeftPin = labelData.TopLeftPin(); const quint32 topLeftPin = labelData.TopLeftPin();
const quint32 bottomRightPin = labelData.BottomRightPin(); const quint32 bottomRightPin = labelData.BottomRightPin();
if (topLeftPin != NULL_ID && pins.contains(topLeftPin) && bottomRightPin != NULL_ID if (topLeftPin != NULL_ID && pins.contains(topLeftPin) && bottomRightPin != NULL_ID &&
&& pins.contains(bottomRightPin)) pins.contains(bottomRightPin))
{ {
try try
{ {
const auto topLeftPinPoint = VAbstractTool::data.GeometricObject<VPointF>(topLeftPin); const auto topLeftPinPoint = VAbstractTool::data.GeometricObject<VPointF>(topLeftPin);
const auto bottomRightPinPoint = VAbstractTool::data.GeometricObject<VPointF>(bottomRightPin); const auto bottomRightPinPoint = VAbstractTool::data.GeometricObject<VPointF>(bottomRightPin);
const QRectF labelRect = QRectF(static_cast<QPointF>(*topLeftPinPoint), const QRectF labelRect =
static_cast<QPointF>(*bottomRightPinPoint)); QRectF(static_cast<QPointF>(*topLeftPinPoint), static_cast<QPointF>(*bottomRightPinPoint));
labelWidth = FromPixel(qAbs(labelRect.width()), *VDataTool::data.GetPatternUnit()); labelWidth = FromPixel(qAbs(labelRect.width()), *VDataTool::data.GetPatternUnit());
labelHeight = FromPixel(qAbs(labelRect.height()), *VDataTool::data.GetPatternUnit()); labelHeight = FromPixel(qAbs(labelRect.height()), *VDataTool::data.GetPatternUnit());
@ -1877,11 +1872,8 @@ auto VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData &labelData,
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineData &geom, auto VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineData &geom, const QVector<quint32> &pins, qreal &length,
const QVector<quint32> &pins, qreal &rotationAngle, QPointF &pos) -> VPieceItem::MoveTypes
qreal &length,
qreal &rotationAngle,
QPointF &pos) -> VPieceItem::MoveTypes
{ {
const quint32 topPin = geom.TopPin(); const quint32 topPin = geom.TopPin();
const quint32 bottomPin = geom.BottomPin(); const quint32 bottomPin = geom.BottomPin();
@ -1945,8 +1937,8 @@ auto VToolSeamAllowance::FindGrainlineGeometry(const VGrainlineData &geom,
const auto centerPinPoint = VAbstractTool::data.GeometricObject<VPointF>(centerPin); const auto centerPinPoint = VAbstractTool::data.GeometricObject<VPointF>(centerPin);
const qreal cLength = ToPixel(length, *VDataTool::data.GetPatternUnit()); const qreal cLength = ToPixel(length, *VDataTool::data.GetPatternUnit());
QLineF grainline(centerPinPoint->x(), centerPinPoint->y(), QLineF grainline(centerPinPoint->x(), centerPinPoint->y(), centerPinPoint->x() + cLength / 2.0,
centerPinPoint->x() + cLength / 2.0, centerPinPoint->y()); centerPinPoint->y());
grainline.setAngle(rotationAngle); grainline.setAngle(rotationAngle);
grainline = QLineF(grainline.p2(), grainline.p1()); grainline = QLineF(grainline.p2(), grainline.p1());
@ -2014,8 +2006,8 @@ void VToolSeamAllowance::InitNode(const VPieceNode &node, VMainGraphicsScene *sc
connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem, Qt::UniqueConnection); connect(tool, &VNodePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem, Qt::UniqueConnection);
connect(tool, &VNodePoint::TogglePassmarkAngleType, parent, connect(tool, &VNodePoint::TogglePassmarkAngleType, parent,
&VToolSeamAllowance::TogglePassmarkAngleType, Qt::UniqueConnection); &VToolSeamAllowance::TogglePassmarkAngleType, Qt::UniqueConnection);
connect(tool, &VNodePoint::TogglePassmarkLineType, parent, connect(tool, &VNodePoint::TogglePassmarkLineType, parent, &VToolSeamAllowance::TogglePassmarkLineType,
&VToolSeamAllowance::TogglePassmarkLineType, Qt::UniqueConnection); Qt::UniqueConnection);
connect(tool, &VNodePoint::ResetPieceLabelTemplate, parent, connect(tool, &VNodePoint::ResetPieceLabelTemplate, parent,
&VToolSeamAllowance::ResetPieceLabelTemplate, Qt::UniqueConnection); &VToolSeamAllowance::ResetPieceLabelTemplate, Qt::UniqueConnection);
tool->setParentItem(parent); tool->setParentItem(parent);
@ -2114,8 +2106,8 @@ auto VToolSeamAllowance::PrepareLabelData(const VPatternLabelData &labelData, co
qreal labelWidth = 0; qreal labelWidth = 0;
qreal labelHeight = 0; qreal labelHeight = 0;
const VTextGraphicsItem::MoveTypes type = FindLabelGeometry(labelData, pins, labelAngle, labelWidth, labelHeight, const VTextGraphicsItem::MoveTypes type =
pos); FindLabelGeometry(labelData, pins, labelAngle, labelWidth, labelHeight, pos);
if (type & VGrainlineItem::Error) if (type & VGrainlineItem::Error)
{ {
labelItem->hide(); labelItem->hide();
@ -2182,8 +2174,8 @@ void VToolSeamAllowance::AddPointRecords(VAbstractPattern *doc, QDomElement &dom
QDomElement pinsElement = doc->createElement(tag); QDomElement pinsElement = doc->createElement(tag);
for (auto record : records) for (auto record : records)
{ {
pinsElement.appendChild(doc->CreateElementWithText(VToolSeamAllowance::TagRecord, pinsElement.appendChild(
QString().setNum(record))); doc->CreateElementWithText(VToolSeamAllowance::TagRecord, QString().setNum(record)));
} }
domElement.appendChild(pinsElement); domElement.appendChild(pinsElement);
} }