New feature. Custom measurement name.

This commit is contained in:
Roman Telezhynskyi 2023-10-19 17:35:29 +03:00
parent 4ea992cb87
commit 2dae3816a6
38 changed files with 1341 additions and 171 deletions

View File

@ -48,6 +48,7 @@
- Puzzle app. Fix piece position move when update layout data.
- Puzzle app. Fix losing selection by piece.
- Puzzle app. Fix updating layout when file already opened.
- Tape app. Custom measurement name.
# Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru.

View File

@ -28,7 +28,9 @@
#include "tmainwindow.h"
#include "../ifc/ifcdef.h"
#include "../ifc/xml/utils.h"
#include "../ifc/xml/vpatternconverter.h"
#include "../ifc/xml/vpatternimage.h"
#include "../ifc/xml/vvitconverter.h"
#include "../ifc/xml/vvstconverter.h"
#include "../qmuparser/qmudef.h"
@ -46,6 +48,7 @@
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/vcontainer.h"
#include "../vtools/dialogs/support/dialogeditwrongformula.h"
#include "../vwidgets/vaspectratiopixmaplabel.h"
#include "def.h"
#include "dialogs/dialogabouttape.h"
#include "dialogs/dialogdimensioncustomnames.h"
@ -78,9 +81,12 @@
#endif
#include <QComboBox>
#include <QDesktopServices>
#include <QFileDialog>
#include <QFileInfo>
#include <QMessageBox>
#include <QMimeType>
#include <QPixmap>
#include <QProcess>
#include <QTimer>
#include <QtNumeric>
@ -269,6 +275,8 @@ TMainWindow::TMainWindow(QWidget *parent)
VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
ui->labelDiagram->setText(UnknownMeasurementImage());
ui->lineEditName->setClearButtonEnabled(true);
ui->lineEditFullName->setClearButtonEnabled(true);
ui->lineEditCustomerName->setClearButtonEnabled(true);
@ -785,6 +793,8 @@ void TMainWindow::changeEvent(QEvent *event)
InitMeasurementUnits();
RetranslateMDiagram();
if (m_mType == MeasurementsType::Multisize)
{
ui->labelMType->setText(tr("Multisize measurements"));
@ -1315,7 +1325,7 @@ void TMainWindow::SavePMSystem(int index)
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::Remove()
{
ShowMDiagram(QString());
ShowMDiagram(QSharedPointer<VMeasurement>());
const int row = ui->tableWidget->currentRow();
if (row == -1)
@ -1524,6 +1534,206 @@ void TMainWindow::Fx()
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::AddImage()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
ui->toolButtonAddImage->setDisabled(true);
return;
}
VTapeSettings *settings = MApplication::VApp()->TapeSettings();
const QString filePath =
QFileDialog::getOpenFileName(this, tr("Measurement image"), settings->GetPathCustomImage(),
PrepareImageFilters(), nullptr, VAbstractApplication::VApp()->NativeFileDialog());
if (!filePath.isEmpty())
{
if (QFileInfo::exists(filePath))
{
settings->SetPathCustomImage(QFileInfo(filePath).absolutePath());
}
VPatternImage image = VPatternImage::FromFile(filePath);
if (not image.IsValid())
{
qCritical() << tr("Invalid image. Error: %1").arg(image.ErrorString());
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
m_m->SetMImage(nameField->data(Qt::UserRole).toString(), image);
MeasurementsWereSaved(false);
RefreshData();
m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
ShowNewMData(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RemoveImage()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
ui->toolButtonRemoveImage->setDisabled(true);
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
m_m->SetMImage(nameField->data(Qt::UserRole).toString(), VPatternImage());
MeasurementsWereSaved(false);
RefreshData();
m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
ShowNewMData(false);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveImage()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
ui->toolButtonSaveImage->setDisabled(true);
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); // name
SCASSERT(nameField != nullptr)
QSharedPointer<VMeasurement> meash;
try
{
// Translate to internal look.
meash = m_data->GetVariable<VMeasurement>(nameField->data(Qt::UserRole).toString());
}
catch (const VExceptionBadId &e)
{
Q_UNUSED(e)
qCritical() << "Unable to get measurement";
return;
}
const VPatternImage image = meash->GetImage();
if (not image.IsValid())
{
qCritical() << tr("Unable to save image. Error: %1").arg(image.ErrorString());
return;
}
VTapeSettings *settings = MApplication::VApp()->TapeSettings();
QMimeType mime = image.MimeTypeFromData();
QString path = settings->GetPathCustomImage() + QDir::separator() + tr("untitled");
QStringList suffixes = mime.suffixes();
if (not suffixes.isEmpty())
{
path += '.'_L1 + suffixes.at(0);
}
QString filter = mime.filterString();
QString filename = QFileDialog::getSaveFileName(this, tr("Save Image"), path, filter, nullptr,
VAbstractApplication::VApp()->NativeFileDialog());
if (not filename.isEmpty())
{
if (QFileInfo::exists(filename))
{
settings->SetPathCustomImage(QFileInfo(filename).absolutePath());
}
QFile file(filename);
if (file.open(QIODevice::WriteOnly))
{
file.write(QByteArray::fromBase64(image.ContentData()));
}
else
{
qCritical() << tr("Unable to save image. Error: %1").arg(file.errorString());
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowImage()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
ui->toolButtonSaveImage->setDisabled(true);
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); // name
SCASSERT(nameField != nullptr)
QSharedPointer<VMeasurement> meash;
try
{
// Translate to internal look.
meash = m_data->GetVariable<VMeasurement>(nameField->data(Qt::UserRole).toString());
}
catch (const VExceptionBadId &e)
{
Q_UNUSED(e)
qCritical() << "Unable to get measurement";
return;
}
const VPatternImage image = meash->GetImage();
if (not image.IsValid())
{
qCritical() << tr("Unable to show image. Error: %1").arg(image.ErrorString());
return;
}
QMimeType mime = image.MimeTypeFromData();
QString name = QDir::tempPath() + QDir::separator() + QStringLiteral("image.XXXXXX");
QStringList suffixes = mime.suffixes();
if (not suffixes.isEmpty())
{
name += '.'_L1 + suffixes.at(0);
}
delete m_tmpImage;
m_tmpImage = new QTemporaryFile(name, this);
if (m_tmpImage->open())
{
m_tmpImage->write(QByteArray::fromBase64(image.ContentData()));
m_tmpImage->flush();
QDesktopServices::openUrl(QUrl::fromLocalFile(m_tmpImage->fileName()));
}
else
{
qCritical() << "Unable to open temp file";
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::AddCustom()
{
@ -1829,7 +2039,11 @@ void TMainWindow::ShowNewMData(bool fresh)
return;
}
ShowMDiagram(meash->GetName());
ShowMDiagram(meash);
ui->toolButtonAddImage->setEnabled(meash->IsCustom());
ui->toolButtonRemoveImage->setEnabled(meash->IsCustom() && !meash->GetImage().IsNull());
ui->toolButtonSaveImage->setEnabled(meash->IsCustom() && !meash->GetImage().IsNull());
ui->labelFullName->setVisible(meash->GetType() == VarType::Measurement);
ui->lineEditFullName->setVisible(meash->GetType() == VarType::Measurement);
@ -1963,21 +2177,48 @@ void TMainWindow::ShowNewMData(bool fresh)
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowMDiagram(const QString &name)
void TMainWindow::ShowMDiagram(const QSharedPointer<VMeasurement> &m)
{
const VTranslateVars *trv = VAbstractApplication::VApp()->TrVars();
const QString number = trv->MNumber(name);
ui->labelDiagram->setPixmap(QPixmap());
ui->labelDiagram->setCursor(QCursor());
ui->labelDiagram->disconnect();
if (number.isEmpty())
if (m.isNull())
{
ui->labelDiagram->setText(tr("<html><head/><body><p><span style=\" font-size:340pt;\">?</span></p>"
"<p align=\"center\">Unknown measurement</p></body></html>"));
ui->labelDiagram->setText(UnknownMeasurementImage());
return;
}
if (m->IsCustom())
{
VPatternImage image = m->GetImage();
if (image.IsValid())
{
ui->labelDiagram->setCursor(Qt::PointingHandCursor);
ui->labelDiagram->setPixmap(image.GetPixmap());
connect(ui->labelDiagram, &VAspectRatioPixmapLabel::clicked, this, &TMainWindow::ShowImage,
Qt::UniqueConnection);
}
else
{
ui->labelDiagram->setText(UnknownMeasurementImage());
}
}
else
{
ui->labelDiagram->setText(u"<html><head/><body><p align=\"center\">%1</p>"
u"<p align=\"center\"><b>%2</b>. <i>%3</i></p></body></html>"_s.arg(
DialogMDataBase::ImgTag(number), number, trv->GuiText(name)));
const VTranslateVars *trv = VAbstractApplication::VApp()->TrVars();
const QString number = trv->MNumber(m->GetName());
if (number.isEmpty())
{
ui->labelDiagram->setText(UnknownMeasurementImage());
}
else
{
ui->labelDiagram->setText(u"<html><head/><body><p align=\"center\">%1</p>"
u"<p align=\"center\"><b>%2</b>. <i>%3</i></p></body></html>"_s.arg(
DialogMDataBase::ImgTag(number), number, trv->GuiText(m->GetName())));
}
}
}
@ -2861,6 +3102,14 @@ void TMainWindow::InitWindow()
connect(ui->toolButtonDown, &QToolButton::clicked, this, &TMainWindow::MoveDown);
connect(ui->toolButtonBottom, &QToolButton::clicked, this, &TMainWindow::MoveBottom);
ui->toolButtonAddImage->setDisabled(true);
ui->toolButtonRemoveImage->setDisabled(true);
ui->toolButtonSaveImage->setDisabled(true);
connect(ui->toolButtonAddImage, &QToolButton::clicked, this, &TMainWindow::AddImage);
connect(ui->toolButtonRemoveImage, &QToolButton::clicked, this, &TMainWindow::RemoveImage);
connect(ui->toolButtonSaveImage, &QToolButton::clicked, this, &TMainWindow::SaveImage);
connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName);
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMDescription);
connect(ui->lineEditFullName, &QLineEdit::textEdited, this, &TMainWindow::SaveMFullName);
@ -4408,12 +4657,47 @@ void TMainWindow::InitIcons()
{
QString iconResource = QStringLiteral("icon");
ui->toolButtonExpr->setIcon(VTheme::GetIconResource(iconResource, QStringLiteral("24x24/fx.png")));
ui->toolButtonAddImage->setIcon(VTheme::GetIconResource(iconResource, QStringLiteral("16x16/insert-image.png")));
ui->toolButtonRemoveImage->setIcon(VTheme::GetIconResource(iconResource, QStringLiteral("16x16/remove-image.png")));
QString tapeIconResource = QStringLiteral("tapeicon");
ui->actionMeasurementDiagram->setIcon(
VTheme::GetIconResource(tapeIconResource, QStringLiteral("24x24/mannequin.png")));
}
//---------------------------------------------------------------------------------------------------------------------
auto TMainWindow::UnknownMeasurementImage() -> QString
{
return u"<html><head/><body><p><span style=\" font-size:340pt;\">?</span></p>"
u"<p align=\"center\">%1</p></body></html>"_s.arg(tr("Unknown measurement"));
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RetranslateMDiagram()
{
if (ui->tableWidget->rowCount() <= 0 || ui->tableWidget->currentRow() == -1)
{
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); // name
SCASSERT(nameField != nullptr)
QSharedPointer<VMeasurement> meash;
try
{
// Translate to internal look.
meash = m_data->GetVariable<VMeasurement>(nameField->data(Qt::UserRole).toString());
}
catch (const VExceptionBadId &e)
{
Q_UNUSED(e)
return;
}
ShowMDiagram(meash);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetDecimals()
{

View File

@ -29,7 +29,9 @@
#ifndef TMAINWINDOW_H
#define TMAINWINDOW_H
#include <QPointer>
#include <QTableWidget>
#include <QTemporaryFile>
#include "../vformat/vmeasurements.h"
#include "../vmisc/def.h"
@ -108,6 +110,11 @@ private slots:
void MoveBottom();
void Fx();
void AddImage();
void RemoveImage();
void SaveImage();
void ShowImage();
void AddCustom();
void AddKnown();
void AddSeparator();
@ -179,6 +186,8 @@ private:
QVector<QObject *> m_hackedWidgets{};
QPointer<QTemporaryFile> m_tmpImage{};
struct MultisizeMeasurement
{
MultisizeMeasurement() = default;
@ -235,7 +244,7 @@ private:
static auto ClearCustomName(const QString &name) -> QString;
auto EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool specialUnits) -> bool;
void ShowMDiagram(const QString &name);
void ShowMDiagram(const QSharedPointer<VMeasurement> &m);
auto Open(const QString &pathTo, const QString &filter) -> QString;
void UpdatePadlock(bool ro);
@ -278,6 +287,10 @@ private:
auto OrderedMeasurments() const -> QMap<int, QSharedPointer<VMeasurement>>;
void InitIcons();
static auto UnknownMeasurementImage() -> QString;
void RetranslateMDiagram();
};
#endif // TMAINWINDOW_H

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1463</width>
<width>1102</width>
<height>899</height>
</rect>
</property>
@ -1142,7 +1142,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1463</width>
<width>1102</width>
<height>22</height>
</rect>
</property>
@ -1258,12 +1258,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="features">
<set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Measurement diagram</string>
</property>
@ -1278,8 +1272,75 @@
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="QLabel" name="labelDiagram">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="toolButtonAddImage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Add image</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/light/16x16/insert-image.png</normaloff>:/icon/light/16x16/insert-image.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonRemoveImage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Remove image</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/light/16x16/remove-image.png</normaloff>:/icon/light/16x16/remove-image.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonSaveImage">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Save image</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="document-save-as"/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="VAspectRatioPixmapLabel" name="labelDiagram">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -1287,7 +1348,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:340pt;&quot;&gt;?&lt;/span&gt;&lt;/p&gt;&lt;p align=\&quot;center\&quot;&gt;Unknown measurement&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:340pt;&quot;&gt;?&lt;/span&gt;&lt;/p&gt;&lt;p align=\&quot;center\&quot;&gt;Unknown measurement&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
@ -1657,6 +1718,11 @@
<extends>QPlainTextEdit</extends>
<header>../vwidgets/vplaintextedit.h</header>
</customwidget>
<customwidget>
<class>VAspectRatioPixmapLabel</class>
<extends>QLabel</extends>
<header>../vwidgets/vaspectratiopixmaplabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="share/resources/tapeicon.qrc"/>
@ -1665,7 +1731,7 @@
<connections>
<connection>
<sender>actionMeasurementDiagram</sender>
<signal>toggled(bool)</signal>
<signal>triggered(bool)</signal>
<receiver>dockWidgetDiagram</receiver>
<slot>setVisible(bool)</slot>
<hints>

View File

@ -43,6 +43,7 @@
#include <QUrl>
#include "../core/vapplication.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/vvalentinasettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../xml/vpattern.h"
@ -418,11 +419,18 @@ void DialogPatternProperties::InitImage()
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ChangeImage()
{
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
const QString fileName =
QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), PrepareImageFilters(), nullptr,
VAbstractApplication::VApp()->NativeFileDialog());
QFileDialog::getOpenFileName(this, tr("Image for pattern"), settings->GetPathCustomImage(),
PrepareImageFilters(), nullptr, VAbstractApplication::VApp()->NativeFileDialog());
if (not fileName.isEmpty())
{
if (QFileInfo::exists(fileName))
{
settings->SetPathCustomImage(QFileInfo(fileName).absolutePath());
}
VPatternImage image = VPatternImage::FromFile(fileName);
if (not image.IsValid())
@ -454,13 +462,15 @@ void DialogPatternProperties::SaveImage()
return;
}
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
QMimeType mime = image.MimeTypeFromData();
QString path = QDir::homePath() + QDir::separator() + tr("untitled");
QString path = settings->GetPathCustomImage() + QDir::separator() + tr("untitled");
QStringList suffixes = mime.suffixes();
if (not suffixes.isEmpty())
{
path += '.' + suffixes.at(0);
path += '.'_L1 + suffixes.at(0);
}
QString filter = mime.filterString();
@ -468,6 +478,11 @@ void DialogPatternProperties::SaveImage()
VAbstractApplication::VApp()->NativeFileDialog());
if (not filename.isEmpty())
{
if (QFileInfo::exists(filename))
{
settings->SetPathCustomImage(QFileInfo(filename).absolutePath());
}
QFile file(filename);
if (file.open(QIODevice::WriteOnly))
{
@ -497,7 +512,7 @@ void DialogPatternProperties::ShowImage()
QStringList suffixes = mime.suffixes();
if (not suffixes.isEmpty())
{
name += '.' + suffixes.at(0);
name += '.'_L1 + suffixes.at(0);
}
delete m_tmpImage;
@ -510,7 +525,7 @@ void DialogPatternProperties::ShowImage()
}
else
{
qCritical() << tr("Unable to open temp file");
qCritical() << "Unable to open temp file";
}
}

View File

@ -5011,13 +5011,13 @@ void MainWindow::SaveBackgroundImage(const QUuid &id)
QStringList suffixes = mime.suffixes();
if (not suffixes.isEmpty())
{
path += '.' + suffixes.at(0);
path += '.'_L1 + suffixes.at(0);
}
filters.append(mime.filterString());
}
filters.append(tr("All files") + QStringLiteral(" (*.*)"));
filters.append(tr("All files") + " (*.*)"_L1);
QString filter = filters.join(QStringLiteral(";;"));

View File

@ -80,6 +80,7 @@
<file>schema/multisize_measurements/v0.5.2.xsd</file>
<file>schema/multisize_measurements/v0.5.3.xsd</file>
<file>schema/multisize_measurements/v0.5.4.xsd</file>
<file>schema/multisize_measurements/v0.6.0.xsd</file>
<file>schema/individual_measurements/v0.2.0.xsd</file>
<file>schema/individual_measurements/v0.3.0.xsd</file>
<file>schema/individual_measurements/v0.3.1.xsd</file>
@ -89,6 +90,7 @@
<file>schema/individual_measurements/v0.5.0.xsd</file>
<file>schema/individual_measurements/v0.5.1.xsd</file>
<file>schema/individual_measurements/v0.5.2.xsd</file>
<file>schema/individual_measurements/v0.6.0.xsd</file>
<file>schema/label_template/v1.0.0.xsd</file>
<file>schema/watermark/v1.0.0.xsd</file>
<file>schema/watermark/v1.1.0.xsd</file>

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="vit">
<xs:complexType>
<xs:sequence>
<xs:element name="version" type="formatVersion"/>
<xs:element name="read-only" type="xs:boolean"/>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="unit" type="units"/>
<xs:element name="pm_system" type="psCode"/>
<xs:element name="personal">
<xs:complexType>
<xs:sequence>
<xs:element name="customer" type="xs:string"/>
<xs:element name="birth-date" type="xs:date"/>
<xs:element name="gender" type="gender"/>
<xs:element name="email" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="body-measurements">
<xs:complexType>
<xs:sequence>
<xs:element name="m" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="image" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="contentType" type="contentType"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="shortName" use="required"/>
<xs:attribute name="value" type="xs:string"/>
<xs:attribute name="full_name" type="xs:string"/>
<xs:attribute name="description" type="xs:string"/>
<xs:attribute name="specialUnits" type="xs:boolean"/>
<xs:attribute name="dimension" type="dimensionType"/>
<xs:attribute name="type" type="measurementType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="template" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="measurementName">
<xs:selector xpath="body-measurements/m"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="([^\p{Nd}\p{Zs}*\\/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;'\\&quot;]){1,1}([^\p{Zs}*\\/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;\\&quot;]){0,}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="gender">
<xs:restriction base="xs:string">
<xs:enumeration value="unknown"/>
<xs:enumeration value="male"/>
<xs:enumeration value="female"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="psCode">
<xs:restriction base="xs:string">
<xs:pattern value="(([0-9]|[1-4][0-9]|5[0-4])|998)"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dimensionType">
<xs:restriction base="xs:string">
<xs:enumeration value="n"/>
<xs:enumeration value="x"/>
<xs:enumeration value="y"/>
<xs:enumeration value="w"/>
<xs:enumeration value="z"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementType">
<xs:restriction base="xs:string">
<xs:enumeration value="measurement"/>
<xs:enumeration value="separator"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="contentType">
<xs:restriction base="xs:string">
<xs:pattern value="image/[-\w]+(\.[-\w]+)*([+][-\w]+)?"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="vst">
<xs:complexType>
<xs:sequence>
<xs:element name="version" type="formatVersion"/>
<xs:element name="read-only" type="xs:boolean"/>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="unit" type="units"/>
<xs:element name="pm_system" type="psCode"/>
<xs:element name="dimensions">
<xs:complexType>
<xs:sequence>
<xs:element name="dimension" minOccurs="1" maxOccurs="3">
<xs:complexType>
<xs:sequence>
<xs:element name="labels" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="label" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="value" type="dimesionValue" use="required"/>
<xs:attribute name="label" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type" type="dimensionType" use="required"/>
<xs:attribute name="base" type="dimesionValue" use="required"/>
<xs:attribute name="min" type="dimesionValue" use="required"/>
<xs:attribute name="max" type="dimesionValue" use="required"/>
<xs:attribute name="step" type="dimensionStep" use="required"/>
<xs:attribute name="measurement" type="xs:boolean"/>
<xs:attribute name="customName" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="fullCircumference" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="restrictions">
<xs:complexType>
<xs:sequence>
<xs:element name="restriction" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="coordinates" type="xs:string" use="required"/>
<xs:attribute name="min" type="dimesionValue"/>
<xs:attribute name="max" type="dimesionValue"/>
<xs:attribute name="exclude" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="body-measurements">
<xs:complexType>
<xs:sequence>
<xs:element name="m" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="corrections" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="correction" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="coordinates" type="xs:string" use="required"/>
<xs:attribute name="correction" type="xs:double" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="image" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="contentType" type="contentType"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="name" type="shortName" use="required"/>
<xs:attribute name="base" type="xs:double"/>
<xs:attribute name="shiftA" type="xs:double"/>
<xs:attribute name="shiftB" type="xs:double"/>
<xs:attribute name="shiftC" type="xs:double"/>
<xs:attribute name="full_name" type="xs:string"/>
<xs:attribute name="description" type="xs:string"/>
<xs:attribute name="specialUnits" type="xs:boolean"/>
<xs:attribute name="type" type="measurementType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="measurementName">
<xs:selector xpath="body-measurements/m"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="([^\p{Nd}\p{Zs}*\\/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;'\\&quot;]){1,1}([^\p{Zs}*\\/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;\\&quot;]){0,}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="psCode">
<xs:restriction base="xs:string">
<xs:pattern value="(([0-9]|[1-4][0-9]|5[0-4])|998)"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dimensionType">
<xs:restriction base="xs:string">
<xs:enumeration value="x"/>
<xs:enumeration value="y"/>
<xs:enumeration value="w"/>
<xs:enumeration value="z"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dimesionValue">
<xs:restriction base="xs:double">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="2720"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dimensionStep">
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="80"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementType">
<xs:restriction base="xs:string">
<xs:enumeration value="measurement"/>
<xs:enumeration value="separator"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="contentType">
<xs:restriction base="xs:string">
<xs:pattern value="image/[-\w]+(\.[-\w]+)*([+][-\w]+)?"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -55,8 +55,8 @@ using namespace Qt::Literals::StringLiterals;
*/
const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.2");
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.2.xsd");
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.6.0");
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.6.0.xsd");
// VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
// VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -96,7 +96,8 @@ auto VVITConverter::XSDSchemas() -> QHash<unsigned int, QString>
std::make_pair(FormatVersion(0, 4, 0), QStringLiteral("://schema/individual_measurements/v0.4.0.xsd")),
std::make_pair(FormatVersion(0, 5, 0), QStringLiteral("://schema/individual_measurements/v0.5.0.xsd")),
std::make_pair(FormatVersion(0, 5, 1), QStringLiteral("://schema/individual_measurements/v0.5.1.xsd")),
std::make_pair(FormatVersion(0, 5, 2), CurrentSchema),
std::make_pair(FormatVersion(0, 5, 2), QStringLiteral("://schema/individual_measurements/v0.5.2.xsd")),
std::make_pair(FormatVersion(0, 6, 0), CurrentSchema),
};
return schemas;
@ -125,10 +126,11 @@ void VVITConverter::ApplyPatches()
case (FormatVersion(0, 4, 0)):
case (FormatVersion(0, 5, 0)):
case (FormatVersion(0, 5, 1)):
ToV0_5_2();
case (FormatVersion(0, 5, 2)):
ToV0_6_0();
ValidateXML(CurrentSchema);
Q_FALLTHROUGH();
case (FormatVersion(0, 5, 2)):
case (FormatVersion(0, 6, 0)):
break;
default:
InvalidVersion(m_ver);
@ -147,7 +149,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
auto VVITConverter::IsReadOnly() const -> bool
{
// Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FormatVersion(0, 5, 2), "Check attribute read-only.");
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FormatVersion(0, 6, 0), "Check attribute read-only.");
// Possibly in future attribute read-only will change position etc.
// For now position is the same for all supported format versions.
@ -409,11 +411,11 @@ void VVITConverter::ToV0_4_0()
}
//---------------------------------------------------------------------------------------------------------------------
void VVITConverter::ToV0_5_2()
void VVITConverter::ToV0_6_0()
{
// TODO. Delete if minimal supported version is 0.5.2
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 5, 2), "Time to refactor the code.");
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
SetVersion(QStringLiteral("0.5.2"));
SetVersion(QStringLiteral("0.6.0"));
Save();
}

View File

@ -29,19 +29,19 @@
#ifndef VVITCONVERTER_H
#define VVITCONVERTER_H
#include <QCoreApplication>
#include <QString>
#include <QtGlobal>
#include "vabstractmconverter.h"
#include "../vmisc/projectversion.h"
#include "vabstractmconverter.h"
class QDomElement;
class VVITConverter final : public VAbstractMConverter
{
Q_DECLARE_TR_FUNCTIONS(VVITConverter) // NOLINT
public:
explicit VVITConverter(const QString &fileName);
virtual ~VVITConverter() = default;
@ -49,9 +49,9 @@ public:
static const QString MeasurementMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const unsigned MeasurementMinVer = FormatVersion(0, 2, 0);
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 2);
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 6, 0);
static auto XSDSchemas() -> QHash <unsigned, QString>;
static auto XSDSchemas() -> QHash<unsigned, QString>;
protected:
virtual auto MinVer() const -> unsigned override;
@ -64,7 +64,7 @@ protected:
virtual void DowngradeToCurrentMaxVersion() override;
virtual auto IsReadOnly() const -> bool override;
auto Schemas() const -> QHash <unsigned, QString> override;
auto Schemas() const -> QHash<unsigned, QString> override;
private:
Q_DISABLE_COPY_MOVE(VVITConverter) // NOLINT
@ -84,7 +84,7 @@ private:
void ToV0_3_2();
void ToV0_3_3();
void ToV0_4_0();
void ToV0_5_2();
void ToV0_6_0();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -56,8 +56,8 @@ using namespace Qt::Literals::StringLiterals;
*/
const QString VVSTConverter::MeasurementMinVerStr = QStringLiteral("0.3.0");
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.4");
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.5.4.xsd");
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.6.0");
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.6.0.xsd");
// VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
// VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -96,7 +96,8 @@ auto VVSTConverter::XSDSchemas() -> QHash<unsigned int, QString>
std::make_pair(FormatVersion(0, 5, 1), QStringLiteral("://schema/multisize_measurements/v0.5.1.xsd")),
std::make_pair(FormatVersion(0, 5, 2), QStringLiteral("://schema/multisize_measurements/v0.5.2.xsd")),
std::make_pair(FormatVersion(0, 5, 3), QStringLiteral("://schema/multisize_measurements/v0.5.3.xsd")),
std::make_pair(FormatVersion(0, 5, 4), CurrentSchema),
std::make_pair(FormatVersion(0, 5, 4), QStringLiteral("://schema/multisize_measurements/v0.5.4.xsd")),
std::make_pair(FormatVersion(0, 6, 0), CurrentSchema),
};
return schemas;
@ -126,9 +127,12 @@ void VVSTConverter::ApplyPatches()
case (FormatVersion(0, 5, 2)):
case (FormatVersion(0, 5, 3)):
ToV0_5_4();
ValidateXML(CurrentSchema);
Q_FALLTHROUGH();
case (FormatVersion(0, 5, 4)):
ToV0_6_0();
ValidateXML(CurrentSchema);
Q_FALLTHROUGH();
case (FormatVersion(0, 6, 0)):
break;
default:
InvalidVersion(m_ver);
@ -147,7 +151,7 @@ void VVSTConverter::DowngradeToCurrentMaxVersion()
auto VVSTConverter::IsReadOnly() const -> bool
{
// Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 4), "Check attribute read-only.");
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 6, 0), "Check attribute read-only.");
// Possibly in future attribute read-only will change position etc.
// For now position is the same for all supported format versions.
@ -493,3 +497,13 @@ void VVSTConverter::ToV0_5_4()
ConvertCircumferenceAttreibuteToV0_5_4();
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VVSTConverter::ToV0_6_0()
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
SetVersion(QStringLiteral("0.6.0"));
Save();
}

View File

@ -29,19 +29,19 @@
#ifndef VMEASUREMENTCONVERTER_H
#define VMEASUREMENTCONVERTER_H
#include <QCoreApplication>
#include <QString>
#include <QtGlobal>
#include "vabstractmconverter.h"
#include "../vmisc/projectversion.h"
#include "vabstractmconverter.h"
class QDomElement;
class VVSTConverter final : public VAbstractMConverter
{
Q_DECLARE_TR_FUNCTIONS(VVSTConverter) // NOLINT
public:
explicit VVSTConverter(const QString &fileName);
virtual ~VVSTConverter() = default;
@ -49,9 +49,9 @@ public:
static const QString MeasurementMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const unsigned MeasurementMinVer = FormatVersion(0, 3, 0);
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 4);
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 6, 0);
static auto XSDSchemas() -> QHash <unsigned, QString>;
static auto XSDSchemas() -> QHash<unsigned, QString>;
protected:
virtual auto MinVer() const -> unsigned override;
@ -64,7 +64,7 @@ protected:
virtual void DowngradeToCurrentMaxVersion() override;
virtual auto IsReadOnly() const -> bool override;
auto Schemas() const -> QHash <unsigned, QString> override;
auto Schemas() const -> QHash<unsigned, QString> override;
private:
Q_DISABLE_COPY_MOVE(VVSTConverter) // NOLINT
@ -88,6 +88,7 @@ private:
void ToV0_4_2();
void ToV0_5_0();
void ToV0_5_4();
void ToV0_6_0();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -42,6 +42,7 @@
#include "../ifc/exception/vexceptionobjecterror.h"
#include "../ifc/ifcdef.h"
#include "../ifc/xml/vpatternimage.h"
#include "../ifc/xml/vvitconverter.h"
#include "../ifc/xml/vvstconverter.h"
#include "../qmuparser/qmuparsererror.h"
@ -80,6 +81,7 @@ const QString VMeasurements::TagCorrections = QStringLiteral("corrections");
const QString VMeasurements::TagCorrection = QStringLiteral("correction");
const QString VMeasurements::TagLabels = QStringLiteral("labels");
const QString VMeasurements::TagLabel = QStringLiteral("label");
const QString VMeasurements::TagImage = QStringLiteral("image");
const QString VMeasurements::AttrBase = QStringLiteral("base");
const QString VMeasurements::AttrValue = QStringLiteral("value");
@ -101,6 +103,7 @@ const QString VMeasurements::AttrFullCircumference = QStringLiteral("fullCircumf
const QString VMeasurements::AttrLabel = QStringLiteral("label");
const QString VMeasurements::AttrDimension = QStringLiteral("dimension");
const QString VMeasurements::AttrCustomName = QStringLiteral("customName");
const QString VMeasurements::AttrContentType = QStringLiteral("contentType");
const QString VMeasurements::GenderMale = QStringLiteral("male");
const QString VMeasurements::GenderFemale = QStringLiteral("female");
@ -351,88 +354,7 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
if (varType != MeasurementType::Separator)
{
const QString fullName = GetParametrEmptyString(dom, AttrFullName);
const bool specialUnits = GetParametrBool(dom, AttrSpecialUnits, falseStr);
if (type == MeasurementsType::Multisize)
{
qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
qreal shiftA = GetParametrDouble(dom, AttrShiftA, QChar('0'));
qreal shiftB = GetParametrDouble(dom, AttrShiftB, QChar('0'));
qreal shiftC = GetParametrDouble(dom, AttrShiftC, QChar('0'));
QMap<QString, qreal> corrections = ReadCorrections(dom);
qreal convertedBaseA = DimensionABase();
qreal convertedBaseB = DimensionBBase();
qreal convertedBaseC = DimensionCBase();
qreal convertedStepA = DimensionAStep();
qreal convertedStepB = DimensionBStep();
qreal convertedStepC = DimensionCStep();
if (not specialUnits)
{
base = UnitConvertor(base, Units(), *data->GetPatternUnit());
shiftA = UnitConvertor(shiftA, Units(), *data->GetPatternUnit());
shiftB = UnitConvertor(shiftB, Units(), *data->GetPatternUnit());
shiftC = UnitConvertor(shiftC, Units(), *data->GetPatternUnit());
QMutableMapIterator<QString, qreal> iterator(corrections);
while (iterator.hasNext())
{
iterator.next();
iterator.setValue(UnitConvertor(iterator.value(), Units(), *data->GetPatternUnit()));
}
convertedBaseA = UnitConvertor(convertedBaseA, Units(), *data->GetPatternUnit());
convertedBaseB = UnitConvertor(convertedBaseB, Units(), *data->GetPatternUnit());
convertedBaseC = UnitConvertor(convertedBaseC, Units(), *data->GetPatternUnit());
convertedStepA = UnitConvertor(convertedStepA, Units(), *data->GetPatternUnit());
convertedStepB = UnitConvertor(convertedStepB, Units(), *data->GetPatternUnit());
convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit());
}
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name, convertedBaseA,
convertedBaseB, convertedBaseC, base);
meash->SetBaseA(baseA);
meash->SetBaseB(baseB);
meash->SetBaseC(baseC);
meash->SetShiftA(shiftA);
meash->SetShiftB(shiftB);
meash->SetShiftC(shiftC);
meash->SetStepA(convertedStepA);
meash->SetStepB(convertedStepB);
meash->SetStepC(convertedStepC);
meash->SetSpecialUnits(specialUnits);
meash->SetCorrections(corrections);
meash->SetGuiText(fullName);
meash->SetDescription(description);
}
else
{
const IMD dimension =
VMeasurements::StrToIMD(GetParametrString(dom, AttrDimension, VMeasurements::IMDToStr(IMD::N)));
const QString formula = GetParametrString(dom, AttrValue, QChar('0'));
bool ok = false;
qreal value = EvalFormula(tempData.data(), formula, &ok);
tempMeash = QSharedPointer<VMeasurement>::create(tempData.data(), static_cast<quint32>(i), name, value,
formula, ok);
if (not specialUnits)
{
value = UnitConvertor(value, Units(), *data->GetPatternUnit());
}
meash = QSharedPointer<VMeasurement>::create(data, static_cast<quint32>(i), name, value, formula, ok);
meash->SetGuiText(fullName);
meash->SetDescription(description);
meash->SetSpecialUnits(specialUnits);
meash->SetDimension(dimension);
}
ReadMeasurement(dom, tempData, meash, tempMeash, i, baseA, baseB, baseC);
}
else
{
@ -888,6 +810,20 @@ void VMeasurements::SetMDimension(const QString &name, IMD type)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMImage(const QString &name, const VPatternImage &image)
{
QDomElement mElement = FindM(name);
if (not mElement.isNull())
{
WriteImage(mElement, image);
}
else
{
qWarning() << tr("Can't find measurement '%1'").arg(name);
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VMeasurements::MeasurementForDimension(IMD type) const -> QString
{
@ -1560,6 +1496,51 @@ void VMeasurements::WriteCorrections(QDomElement &mElement, const QMap<QString,
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VMeasurements::ReadImage(const QDomElement &mElement) -> VPatternImage
{
QDomElement imageTag = mElement.firstChildElement(TagImage);
if (imageTag.isNull())
{
return {};
}
VPatternImage image;
if (not imageTag.isNull())
{
image.SetContentData(imageTag.text().toLatin1(), imageTag.attribute(AttrContentType));
}
return image;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::WriteImage(QDomElement &mElement, const VPatternImage &image)
{
QDomElement imageElement = mElement.firstChildElement(TagImage);
if (not image.IsNull())
{
if (not imageElement.isNull())
{
setTagText(imageElement, image.ContentData());
imageElement.setAttribute(AttrContentType, image.ContentType());
}
else
{
imageElement = createElement(TagImage);
setTagText(imageElement, image.ContentData());
imageElement.setAttribute(AttrContentType, image.ContentType());
mElement.appendChild(imageElement);
}
}
else
{
if (not imageElement.isNull())
{
mElement.removeChild(imageElement);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SaveDimesionLabels(QDomElement &dElement, const DimesionLabels &labels)
{
@ -1650,7 +1631,7 @@ void VMeasurements::ClearDimension(IMD type)
for (int i = 0; i < list.size(); ++i)
{
QDomElement domElement = list.at(i).toElement();
if (domElement.isNull() == false)
if (!domElement.isNull())
{
if (domElement.attribute(AttrDimension) == d)
{
@ -1659,3 +1640,104 @@ void VMeasurements::ClearDimension(IMD type)
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::ReadMeasurement(const QDomElement &dom, QSharedPointer<VContainer> &tempData,
QSharedPointer<VMeasurement> &meash, QSharedPointer<VMeasurement> &tempMeash, int i,
qreal baseA, qreal baseB, qreal baseC) const
{
const QString fullName = GetParametrEmptyString(dom, AttrFullName);
const bool specialUnits = GetParametrBool(dom, AttrSpecialUnits, falseStr);
const QString name = GetParametrString(dom, AttrName).simplified();
const QString description = GetParametrEmptyString(dom, AttrDescription);
if (type == MeasurementsType::Multisize)
{
qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
qreal shiftA = GetParametrDouble(dom, AttrShiftA, QChar('0'));
qreal shiftB = GetParametrDouble(dom, AttrShiftB, QChar('0'));
qreal shiftC = GetParametrDouble(dom, AttrShiftC, QChar('0'));
QMap<QString, qreal> corrections = ReadCorrections(dom);
qreal convertedBaseA = DimensionABase();
qreal convertedBaseB = DimensionBBase();
qreal convertedBaseC = DimensionCBase();
qreal convertedStepA = DimensionAStep();
qreal convertedStepB = DimensionBStep();
qreal convertedStepC = DimensionCStep();
if (not specialUnits)
{
base = UnitConvertor(base, Units(), *data->GetPatternUnit());
shiftA = UnitConvertor(shiftA, Units(), *data->GetPatternUnit());
shiftB = UnitConvertor(shiftB, Units(), *data->GetPatternUnit());
shiftC = UnitConvertor(shiftC, Units(), *data->GetPatternUnit());
QMutableMapIterator<QString, qreal> iterator(corrections);
while (iterator.hasNext())
{
iterator.next();
iterator.setValue(UnitConvertor(iterator.value(), Units(), *data->GetPatternUnit()));
}
convertedBaseA = UnitConvertor(convertedBaseA, Units(), *data->GetPatternUnit());
convertedBaseB = UnitConvertor(convertedBaseB, Units(), *data->GetPatternUnit());
convertedBaseC = UnitConvertor(convertedBaseC, Units(), *data->GetPatternUnit());
convertedStepA = UnitConvertor(convertedStepA, Units(), *data->GetPatternUnit());
convertedStepB = UnitConvertor(convertedStepB, Units(), *data->GetPatternUnit());
convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit());
}
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name, convertedBaseA, convertedBaseB,
convertedBaseC, base);
meash->SetBaseA(baseA);
meash->SetBaseB(baseB);
meash->SetBaseC(baseC);
meash->SetShiftA(shiftA);
meash->SetShiftB(shiftB);
meash->SetShiftC(shiftC);
meash->SetStepA(convertedStepA);
meash->SetStepB(convertedStepB);
meash->SetStepC(convertedStepC);
meash->SetSpecialUnits(specialUnits);
meash->SetCorrections(corrections);
meash->SetGuiText(fullName);
meash->SetDescription(description);
if (meash->IsCustom())
{
meash->SetImage(ReadImage(dom));
}
}
else
{
const IMD dimension =
VMeasurements::StrToIMD(GetParametrString(dom, AttrDimension, VMeasurements::IMDToStr(IMD::N)));
const QString formula = GetParametrString(dom, AttrValue, QChar('0'));
bool ok = false;
qreal value = EvalFormula(tempData.data(), formula, &ok);
tempMeash =
QSharedPointer<VMeasurement>::create(tempData.data(), static_cast<quint32>(i), name, value, formula, ok);
if (not specialUnits)
{
value = UnitConvertor(value, Units(), *data->GetPatternUnit());
}
meash = QSharedPointer<VMeasurement>::create(data, static_cast<quint32>(i), name, value, formula, ok);
meash->SetGuiText(fullName);
meash->SetDescription(description);
meash->SetSpecialUnits(specialUnits);
meash->SetDimension(dimension);
if (meash->IsCustom())
{
meash->SetImage(ReadImage(dom));
}
}
}

View File

@ -29,7 +29,6 @@
#ifndef VMEASUREMENTS_H
#define VMEASUREMENTS_H
#include <QCoreApplication>
#include <QDomElement>
#include <QString>
@ -41,23 +40,30 @@
#include "vdimensions.h"
class VContainer;
class VPatternImage;
class VMeasurement;
enum class GenderType : qint8 { Male, Female, Unknown };
enum class GenderType : qint8
{
Male,
Female,
Unknown
};
using VDimensions = QMap<MeasurementDimension, MeasurementDimension_p>;
class VMeasurements : public VDomDocument
{
Q_DECLARE_TR_FUNCTIONS(VMeasurements) // NOLINT
Q_OBJECT // NOLINT
public:
explicit VMeasurements(VContainer *data);
VMeasurements(Unit unit, VContainer *data);
VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
VContainer *data);
virtual ~VMeasurements() = default;
VMeasurements(Unit unit, const QVector<MeasurementDimension_p> &dimensions, VContainer *data);
~VMeasurements() override = default;
virtual void setXMLContent(const QString &fileName) override;
virtual auto SaveDocument(const QString &fileName, QString &error) -> bool override;
void setXMLContent(const QString &fileName) override;
auto SaveDocument(const QString &fileName, QString &error) -> bool override;
void AddEmpty(const QString &name, const QString &formula = QString());
void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString());
@ -73,7 +79,7 @@ public:
void StoreNames(bool store);
void ReadMeasurements(qreal baseA, qreal baseB=0, qreal baseC=0) const;
void ReadMeasurements(qreal baseA, qreal baseB = 0, qreal baseC = 0) const;
void ClearForExport();
auto Type() const -> MeasurementsType;
@ -86,28 +92,28 @@ public:
auto DimensionCStep() const -> qreal;
auto Notes() const -> QString;
void SetNotes(const QString &text);
void SetNotes(const QString &text);
auto Customer() const -> QString;
void SetCustomer(const QString &text);
void SetCustomer(const QString &text);
auto BirthDate() const -> QDate;
void SetBirthDate(const QDate &date);
void SetBirthDate(const QDate &date);
auto Gender() const -> GenderType;
void SetGender(const GenderType &gender);
void SetGender(const GenderType &gender);
auto PMSystem() const -> QString;
void SetPMSystem(const QString &system);
void SetPMSystem(const QString &system);
auto Email() const -> QString;
void SetEmail(const QString &text);
void SetEmail(const QString &text);
auto IsReadOnly() const -> bool;
void SetReadOnly(bool ro);
void SetReadOnly(bool ro);
auto IsFullCircumference() const -> bool;
void SetFullCircumference(bool fc);
void SetFullCircumference(bool fc);
void SetMName(const QString &name, const QString &text);
void SetMValue(const QString &name, const QString &text);
@ -120,14 +126,15 @@ public:
void SetMDescription(const QString &name, const QString &text);
void SetMFullName(const QString &name, const QString &text);
void SetMDimension(const QString &name, IMD type);
void SetMImage(const QString &name, const VPatternImage &image);
auto MeasurementForDimension(IMD type) const -> QString;
auto Dimensions() const -> VDimensions;
auto GetRestrictions() const -> QMap<QString, VDimensionRestriction >;
void SetRestrictions(const QMap<QString, VDimensionRestriction > &restrictions);
auto Restriction(qreal base, qreal base2=0) const -> VDimensionRestriction;
auto GetRestrictions() const -> QMap<QString, VDimensionRestriction>;
void SetRestrictions(const QMap<QString, VDimensionRestriction> &restrictions);
auto Restriction(qreal base, qreal base2 = 0) const -> VDimensionRestriction;
void SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels);
void SetDimensionCustomNames(const QMap<MeasurementDimension, QString> &names);
@ -152,6 +159,7 @@ public:
static const QString TagCorrection;
static const QString TagLabels;
static const QString TagLabel;
static const QString TagImage;
static const QString AttrBase;
static const QString AttrValue;
@ -173,6 +181,7 @@ public:
static const QString AttrLabel;
static const QString AttrDimension;
static const QString AttrCustomName;
static const QString AttrContentType;
static const QString GenderMale;
static const QString GenderFemale;
@ -206,7 +215,7 @@ private:
Q_DISABLE_COPY_MOVE(VMeasurements) // NOLINT
/** @brief data container with data. */
VContainer *data;
VContainer *data;
MeasurementsType type;
// Cache data to quick access
@ -216,7 +225,7 @@ private:
/** @brief m_keepNames store names in container to check uniqueness. */
bool m_keepNames{true};
void CreateEmptyMultisizeFile(Unit unit, const QVector<MeasurementDimension_p > &dimensions);
void CreateEmptyMultisizeFile(Unit unit, const QVector<MeasurementDimension_p> &dimensions);
void CreateEmptyIndividualFile(Unit unit);
auto CreateDimensions(const QVector<MeasurementDimension_p> &dimensions) -> QDomElement;
@ -234,12 +243,19 @@ private:
auto ClearPMCode(const QString &code) const -> QString;
auto ReadCorrections(const QDomElement &mElement) const -> QMap<QString, qreal>;
void WriteCorrections(QDomElement &mElement, const QMap<QString, qreal> &corrections);
void WriteCorrections(QDomElement &mElement, const QMap<QString, qreal> &corrections);
void SaveDimesionLabels(QDomElement &dElement, const DimesionLabels &labels);
static auto ReadImage(const QDomElement &mElement) -> VPatternImage;
void WriteImage(QDomElement &mElement, const VPatternImage &image);
void SaveDimesionLabels(QDomElement &dElement, const DimesionLabels &labels);
auto ReadDimensionLabels(const QDomElement &dElement) const -> DimesionLabels;
void ClearDimension(IMD type);
void ReadMeasurement(const QDomElement &dom, QSharedPointer<VContainer> &tempData,
QSharedPointer<VMeasurement> &meash, QSharedPointer<VMeasurement> &tempMeash, int i,
qreal baseA, qreal baseB, qreal baseC) const;
};
#endif // VMEASUREMENTS_H

View File

@ -201,5 +201,13 @@
<file>icon/light/32x32/put_after.png</file>
<file>icon/dark/32x32/put_after@2x.png</file>
<file>icon/dark/32x32/put_after.png</file>
<file>icon/light/16x16/remove-image@2x.png</file>
<file>icon/light/16x16/remove-image.png</file>
<file>icon/light/16x16/insert-image@2x.png</file>
<file>icon/light/16x16/insert-image.png</file>
<file>icon/dark/16x16/remove-image@2x.png</file>
<file>icon/dark/16x16/remove-image.png</file>
<file>icon/dark/16x16/insert-image@2x.png</file>
<file>icon/dark/16x16/insert-image.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 16 16"
version="1.1"
id="svg1"
sodipodi:docname="insert-image.svg"
inkscape:export-filename="../../dark/16x16/insert-image@2x.png"
inkscape:export-xdpi="256"
inkscape:export-ydpi="256"
inkscape:version="1.3 (1:1.3+202307231459+0e150ed6c4)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="70.625"
inkscape:cx="8"
inkscape:cy="8"
inkscape:window-width="2560"
inkscape:window-height="1372"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<defs
id="defs3051">
<style
type="text/css"
id="current-color-scheme">&#10; .ColorScheme-Text {&#10; color:#dedede;&#10; }&#10; </style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 2 2 L 2 13.28125 L 2 14 L 8 14 L 8 10 L 7.65625 10.34375 L 6.3125 9 L 6.28125 9 L 3 12.28125 L 3 3 L 13 3 L 13 8 L 14 8 L 14 2 L 2 2 z M 6 4 C 4.8954305 4 4 4.8954305 4 6 C 4 7.1045695 4.8954305 8 6 8 C 7.1045695 8 8 7.1045695 8 6 C 8 4.8954305 7.1045695 4 6 4 z M 11 9 L 11 11 L 9 11 L 9 12 L 11 12 L 11 14 L 12 14 L 12 12 L 14 12 L 14 11 L 12 11 L 12 9 L 11 9 z "
class="ColorScheme-Text"
id="path1" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 16 16"
version="1.1"
id="svg1"
sodipodi:docname="remove-image.svg"
inkscape:version="1.3 (1:1.3+202307231459+0e150ed6c4)"
inkscape:export-filename="../../dark/16x16/remove-image@2x.png"
inkscape:export-xdpi="255.63474"
inkscape:export-ydpi="255.63474"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="70.625"
inkscape:cx="8"
inkscape:cy="8"
inkscape:window-width="2560"
inkscape:window-height="1372"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<defs
id="defs3051">
<style
type="text/css"
id="current-color-scheme">&#10; .ColorScheme-Text {&#10; color:#dedede;&#10; }&#10; </style>
</defs>
<path
class="ColorScheme-NegativeText"
d="m 11.510012,8.9932557 c -1.384654,0 -2.5071341,1.1224793 -2.5071341,2.5071343 0,1.384654 1.1224801,2.507134 2.5071341,2.507134 1.384654,0 2.507134,-1.12248 2.507134,-2.507134 0,-1.384655 -1.12248,-2.5071343 -2.507134,-2.5071343 z m -1.193396,0.716324 1.193396,1.1933953 1.193396,-1.1933953 0.5974,0.5974003 -1.193396,1.193395 1.193396,1.193396 -0.5974,0.5974 -1.193396,-1.193396 -1.193396,1.193396 -0.5973998,-0.5974 1.1933958,-1.193396 -1.1933958,-1.193395 z"
fill="currentColor"
id="path2"
style="color:#da4453;stroke-width:0.716324" />
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 2,2 V 13.28125 14 H 8 V 10 L 7.65625,10.34375 6.3125,9 H 6.28125 L 3,12.28125 V 3 h 10 v 5 h 1 V 2 Z M 6,4 C 4.8954305,4 4,4.8954305 4,6 4,7.1045695 4.8954305,8 6,8 7.1045695,8 8,7.1045695 8,6 8,4.8954305 7.1045695,4 6,4 Z"
class="ColorScheme-Text"
id="path1"
sodipodi:nodetypes="cccccccccccccccsssss" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 16 16"
version="1.1"
id="svg1"
sodipodi:docname="insert-image.svg"
inkscape:export-filename="../../16x16/insert-image@2x.png"
inkscape:export-xdpi="256"
inkscape:export-ydpi="256"
inkscape:version="1.3 (1:1.3+202307231459+0e150ed6c4)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="70.625"
inkscape:cx="8"
inkscape:cy="8"
inkscape:window-width="2560"
inkscape:window-height="1372"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<defs
id="defs3051">
<style
type="text/css"
id="current-color-scheme">&#10; .ColorScheme-Text {&#10; color:#363636;&#10; }&#10; </style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 2 2 L 2 13.28125 L 2 14 L 8 14 L 8 10 L 7.65625 10.34375 L 6.3125 9 L 6.28125 9 L 3 12.28125 L 3 3 L 13 3 L 13 8 L 14 8 L 14 2 L 2 2 z M 6 4 C 4.8954305 4 4 4.8954305 4 6 C 4 7.1045695 4.8954305 8 6 8 C 7.1045695 8 8 7.1045695 8 6 C 8 4.8954305 7.1045695 4 6 4 z M 11 9 L 11 11 L 9 11 L 9 12 L 11 12 L 11 14 L 12 14 L 12 12 L 14 12 L 14 11 L 12 11 L 12 9 L 11 9 z "
class="ColorScheme-Text"
id="path1" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 16 16"
version="1.1"
id="svg1"
sodipodi:docname="remove-image.svg"
inkscape:version="1.3 (1:1.3+202307231459+0e150ed6c4)"
inkscape:export-filename="../../16x16/remove-image@2x.png"
inkscape:export-xdpi="256"
inkscape:export-ydpi="256"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="141.25"
inkscape:cx="10.520354"
inkscape:cy="11.716814"
inkscape:window-width="2560"
inkscape:window-height="1372"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1" />
<defs
id="defs3051">
<style
type="text/css"
id="current-color-scheme">&#10; .ColorScheme-Text {&#10; color:#363636;&#10; }&#10; </style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 2,2 V 13.28125 14 H 8 V 10 L 7.65625,10.34375 6.3125,9 H 6.28125 L 3,12.28125 V 3 h 10 v 5 h 1 V 2 Z M 6,4 C 4.8954305,4 4,4.8954305 4,6 4,7.1045695 4.8954305,8 6,8 7.1045695,8 8,7.1045695 8,6 8,4.8954305 7.1045695,4 6,4 Z"
class="ColorScheme-Text"
id="path1"
sodipodi:nodetypes="cccccccccccccccsssss" />
<path
class="ColorScheme-NegativeText"
d="m 11.448303,8.9553525 c -1.391098,0 -2.5188038,1.1277065 -2.5188038,2.5188065 0,1.391101 1.1277058,2.518807 2.5188038,2.518807 1.391101,0 2.518807,-1.127706 2.518807,-2.518807 0,-1.3911 -1.127706,-2.5188065 -2.518807,-2.5188065 z m -1.19895,0.7196589 1.19895,1.1989516 1.198952,-1.1989516 0.600181,0.6001816 -1.198951,1.198952 1.198951,1.198952 -0.600181,0.600181 -1.198952,-1.198952 -1.19895,1.198952 -0.6001808,-0.600181 1.1989508,-1.198952 -1.1989508,-1.198952 z"
fill="currentColor"
id="path2"
style="color:#da4453;stroke-width:0.719659" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -58,22 +58,22 @@ auto IsCommand(const QChar &ch) -> bool
//---------------------------------------------------------------------------------------------------------------------
auto IsSeparator(const QString &currentToken, const QChar &ch) -> bool
{
if (ch.isSpace() || ch == ',')
if (ch.isSpace() || ch == ','_L1)
{
return true;
}
if (ch == '.' && currentToken.contains(ch))
if (ch == '.'_L1 && currentToken.contains(ch))
{
return true;
}
if (ch == '-' && !currentToken.isEmpty() && Back(currentToken) != 'e' && Back(currentToken) != 'E')
if (ch == '-'_L1 && !currentToken.isEmpty() && Back(currentToken) != 'e'_L1 && Back(currentToken) != 'E'_L1)
{
return true;
}
if (ch == '+' && !currentToken.isEmpty() && Back(currentToken) != 'e' && Back(currentToken) != 'E')
if (ch == '+'_L1 && !currentToken.isEmpty() && Back(currentToken) != 'e'_L1 && Back(currentToken) != 'E'_L1)
{
return true;
}

View File

@ -92,6 +92,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, ("p
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, ("paths/standard_measurements"_L1))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, ("paths/pattern"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, ("paths/manualLayouts"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsCustomImage, ("paths/customImage"_L1)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsSVGFonts, ("paths/svgFonts"_L1)) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsFontCorrections, ("paths/fontCorrections"_L1))
@ -344,6 +345,21 @@ void VCommonSettings::SetPathManualLayouts(const QString &value)
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetPathCustomImage() const -> QString
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingPathsCustomImage, QDir::homePath()).toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetPathCustomImage(const QString &value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingPathsCustomImage, value);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetDefPathSVGFonts() -> QString
{

View File

@ -74,6 +74,9 @@ public:
auto GetPathManualLayouts() const -> QString;
void SetPathManualLayouts(const QString &value);
auto GetPathCustomImage() const -> QString;
void SetPathCustomImage(const QString &value);
static auto GetDefPathSVGFonts() -> QString;
auto GetPathSVGFonts() const -> QString;
void SetPathSVGFonts(const QString &value);

View File

@ -30,7 +30,8 @@ SOURCES += \
$$PWD/dialogs/dialogexporttocsv.cpp \
$$PWD/literals.cpp \
$$PWD/vmodifierkey.cpp \
$$PWD/dialogs/dialogselectlanguage.cpp
$$PWD/dialogs/dialogselectlanguage.cpp \
$$PWD/vaspectratiopixmaplabel.cpp
*msvc*:SOURCES += $$PWD/stable.cpp
@ -123,7 +124,8 @@ HEADERS += \
$$PWD/backport/text.h \
$$PWD/dialogs/dialogselectlanguage.h \
$$PWD/fpm/fixed.hpp \
$$PWD/fpm/math.hpp
$$PWD/fpm/math.hpp \
$$PWD/vaspectratiopixmaplabel.h
contains(DEFINES, APPIMAGE) {
SOURCES += \

View File

@ -33,6 +33,7 @@
#include <QtDebug>
#include "../ifc/ifcdef.h"
#include "../ifc/xml/vpatternimage.h"
#include "vmeasurement_p.h"
#include "vvariable.h"
@ -388,3 +389,15 @@ void VMeasurement::SetCorrections(const QMap<QString, qreal> &corrections)
{
d->corrections = corrections;
}
//---------------------------------------------------------------------------------------------------------------------
auto VMeasurement::GetImage() const -> VPatternImage
{
return d->image;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetImage(const VPatternImage &image)
{
d->image = image;
}

View File

@ -41,6 +41,7 @@
class VContainer;
class VMeasurementData;
class VPatternImage;
/**
* @brief The VMeasurement class keep data row of multisize table
@ -117,6 +118,9 @@ public:
auto GetCorrections() const -> QMap<QString, qreal>;
void SetCorrections(const QMap<QString, qreal> &corrections);
auto GetImage() const -> VPatternImage;
void SetImage(const VPatternImage &image);
static auto CorrectionHash(qreal baseA, qreal baseB = 0, qreal baseC = 0) -> QString;
private:

View File

@ -31,6 +31,7 @@
#include <QSharedData>
#include "../ifc/xml/vpatternimage.h"
#include "../vcontainer.h"
QT_WARNING_PUSH
@ -78,6 +79,8 @@ public:
MeasurementType varType{MeasurementType::Measurement}; // NOLINT(misc-non-private-member-variables-in-classes)
VPatternImage image{}; // NOLINT(misc-non-private-member-variables-in-classes)
private:
Q_DISABLE_ASSIGN_MOVE(VMeasurementData) // NOLINT
};

View File

@ -0,0 +1,105 @@
/************************************************************************
**
** @file vaspectratiopixmaplabel.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2023
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2023 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vaspectratiopixmaplabel.h"
//---------------------------------------------------------------------------------------------------------------------
VAspectRatioPixmapLabel::VAspectRatioPixmapLabel(QWidget *parent, Qt::WindowFlags f)
: QLabel(parent, f)
{
setMinimumSize(1, 1);
setScaledContents(false);
}
//---------------------------------------------------------------------------------------------------------------------
VAspectRatioPixmapLabel::VAspectRatioPixmapLabel(const QString &text, QWidget *parent, Qt::WindowFlags f)
: QLabel(text, parent, f)
{
setMinimumSize(1, 1);
setScaledContents(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VAspectRatioPixmapLabel::setPixmap(const QPixmap &p)
{
m_pix = p;
QLabel::setPixmap(ScaledPixmap());
}
//---------------------------------------------------------------------------------------------------------------------
auto VAspectRatioPixmapLabel::heightForWidth(int width) const -> int
{
if (m_pix.isNull())
{
return QLabel::heightForWidth(width);
}
return static_cast<int>((static_cast<qreal>(m_pix.height()) * width) / m_pix.width());
}
//---------------------------------------------------------------------------------------------------------------------
auto VAspectRatioPixmapLabel::sizeHint() const -> QSize
{
if (m_pix.isNull())
{
return QLabel::sizeHint();
}
int w = m_pix.width();
return {w, heightForWidth(w)};
}
//---------------------------------------------------------------------------------------------------------------------
auto VAspectRatioPixmapLabel::ScaledPixmap() const -> QPixmap
{
if (m_pix.isNull())
{
return m_pix;
}
auto scaled = m_pix.scaled(size() * devicePixelRatioF(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
scaled.setDevicePixelRatio(devicePixelRatioF());
return scaled;
}
//---------------------------------------------------------------------------------------------------------------------
void VAspectRatioPixmapLabel::resizeEvent(QResizeEvent *e)
{
Q_UNUSED(e)
if (!m_pix.isNull())
{
QLabel::setPixmap(ScaledPixmap());
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAspectRatioPixmapLabel::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event)
emit clicked();
}

View File

@ -0,0 +1,63 @@
/************************************************************************
**
** @file vaspectratiopixmaplabel.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 10, 2023
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2023 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VASPECTRATIOPIXMAPLABEL_H
#define VASPECTRATIOPIXMAPLABEL_H
#include <QLabel>
class VAspectRatioPixmapLabel : public QLabel
{
Q_OBJECT // NOLINT
public:
explicit VAspectRatioPixmapLabel(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit VAspectRatioPixmapLabel(const QString &text, QWidget *parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags());
~VAspectRatioPixmapLabel() override = default;
auto heightForWidth(int width) const -> int override;
auto sizeHint() const -> QSize override;
auto ScaledPixmap() const -> QPixmap;
public slots:
void setPixmap(const QPixmap &p);
void resizeEvent(QResizeEvent *e) override;
signals:
void clicked();
protected:
void mousePressEvent(QMouseEvent *event) override;
private:
Q_DISABLE_COPY_MOVE(VAspectRatioPixmapLabel) // NOLINT
QPixmap m_pix;
};
#endif // VASPECTRATIOPIXMAPLABEL_H

View File

@ -14,6 +14,8 @@ VLib {
name: "VWidgetsLib"
files: [
"qtcolorpicker.cpp",
"vaspectratiopixmaplabel.cpp",
"vaspectratiopixmaplabel.h",
"vcomboboxdelegate.cpp",
"vdecorationaligningdelegate.cpp",
"velidedlabel.cpp",