Merge with feature.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-08-21 14:26:33 +03:00
commit a27c97b6ad
99 changed files with 5147 additions and 1297 deletions

View File

@ -2,6 +2,7 @@
/usr/share/valentina/translations
/usr/share/valentina/tables/multisize
/usr/share/valentina/tables/templates
/usr/share/valentina/labels
/usr/share/mime/packages
/usr/share/applications

View File

@ -4,5 +4,6 @@ usr/share/valentina/*
usr/share/valentina/translations/*
usr/share/valentina/tables/multisize/*
usr/share/valentina/tables/templates/*
usr/share/valentina/labels/*
usr/share/pixmaps/*
usr/share/applications/*

View File

@ -76,8 +76,8 @@
<comment xml:lang="st">Valentina pattern</comment>
<comment xml:lang="sv">Valentina pattern</comment>
<comment xml:lang="ta">Valentina pattern</comment>
<comment xml:lang="te">OValentina pattern</comment>
<comment xml:lang="tg">OValentina pattern</comment>
<comment xml:lang="te">Valentina pattern</comment>
<comment xml:lang="tg">Valentina pattern</comment>
<comment xml:lang="th">Valentina pattern</comment>
<comment xml:lang="tn">Valentina pattern</comment>
<comment xml:lang="tr">Valentina pattern</comment>
@ -170,8 +170,8 @@
<comment xml:lang="st">Valentina individual measurments</comment>
<comment xml:lang="sv">Valentina individual measurments</comment>
<comment xml:lang="ta">Valentina individual measurments</comment>
<comment xml:lang="te">OValentina individual measurments</comment>
<comment xml:lang="tg">OValentina individual measurments</comment>
<comment xml:lang="te">Valentina individual measurments</comment>
<comment xml:lang="tg">Valentina individual measurments</comment>
<comment xml:lang="th">Valentina individual measurments</comment>
<comment xml:lang="tn">Valentina individual measurments</comment>
<comment xml:lang="tr">Valentina individual measurments</comment>
@ -264,8 +264,8 @@
<comment xml:lang="st">Valentina standard measurments</comment>
<comment xml:lang="sv">Valentina standard measurments</comment>
<comment xml:lang="ta">Valentina standard measurments</comment>
<comment xml:lang="te">OValentina standard measurments</comment>
<comment xml:lang="tg">OValentina standard measurments</comment>
<comment xml:lang="te">Valentina standard measurments</comment>
<comment xml:lang="tg">Valentina standard measurments</comment>
<comment xml:lang="th">Valentina standard measurments</comment>
<comment xml:lang="tn">Valentina standard measurments</comment>
<comment xml:lang="tr">Valentina standard measurments</comment>

View File

@ -2,6 +2,7 @@
/usr/share/valentina/translations
/usr/share/valentina/tables/multisize
/usr/share/valentina/tables/templates
/usr/share/valentina/labels
/usr/share/mime/packages
/usr/share/applications

View File

@ -4,5 +4,6 @@ usr/share/valentina/*
usr/share/valentina/translations/*
usr/share/valentina/tables/multisize/*
usr/share/valentina/tables/templates/*
usr/share/valentina/labels/*
usr/share/pixmaps/*
usr/share/applications/*

View File

@ -76,8 +76,8 @@
<comment xml:lang="st">Valentina pattern</comment>
<comment xml:lang="sv">Valentina pattern</comment>
<comment xml:lang="ta">Valentina pattern</comment>
<comment xml:lang="te">OValentina pattern</comment>
<comment xml:lang="tg">OValentina pattern</comment>
<comment xml:lang="te">Valentina pattern</comment>
<comment xml:lang="tg">Valentina pattern</comment>
<comment xml:lang="th">Valentina pattern</comment>
<comment xml:lang="tn">Valentina pattern</comment>
<comment xml:lang="tr">Valentina pattern</comment>
@ -170,8 +170,8 @@
<comment xml:lang="st">Valentina individual measurments</comment>
<comment xml:lang="sv">Valentina individual measurments</comment>
<comment xml:lang="ta">Valentina individual measurments</comment>
<comment xml:lang="te">OValentina individual measurments</comment>
<comment xml:lang="tg">OValentina individual measurments</comment>
<comment xml:lang="te">Valentina individual measurments</comment>
<comment xml:lang="tg">Valentina individual measurments</comment>
<comment xml:lang="th">Valentina individual measurments</comment>
<comment xml:lang="tn">Valentina individual measurments</comment>
<comment xml:lang="tr">Valentina individual measurments</comment>
@ -264,8 +264,8 @@
<comment xml:lang="st">Valentina standard measurments</comment>
<comment xml:lang="sv">Valentina standard measurments</comment>
<comment xml:lang="ta">Valentina standard measurments</comment>
<comment xml:lang="te">OValentina standard measurments</comment>
<comment xml:lang="tg">OValentina standard measurments</comment>
<comment xml:lang="te">Valentina standard measurments</comment>
<comment xml:lang="tg">Valentina standard measurments</comment>
<comment xml:lang="th">Valentina standard measurments</comment>
<comment xml:lang="tn">Valentina standard measurments</comment>
<comment xml:lang="tr">Valentina standard measurments</comment>

View File

@ -154,6 +154,8 @@ fi
%{_datadir}/%{name}/tables/multisize/*.vst
%dir %{_datadir}/%{name}/tables/templates
%{_datadir}/%{name}/tables/templates/*.vit
%dir %{_datadir}/%{name}/labels
%{_datadir}/%{name}/labels/*.xml
%clean
rm -f dist/debian/%{name}.1.gz dist/debian/tape.1.gz dist/debian/%{name}.xml dist/debian/%{name}

View File

@ -213,6 +213,7 @@ Source: ".\valentina\iconengines\*"; DestDir: "{app}\iconengines"; Flags: recurs
Source: ".\valentina\platforms\*"; DestDir: "{app}\platforms"; Flags: recursesubdirs createallsubdirs
Source: ".\valentina\printsupport\*"; DestDir: "{app}\printsupport"; Flags: recursesubdirs createallsubdirs
Source: ".\valentina\tables\*"; DestDir: "{app}\tables"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\valentina\labels\*"; DestDir: "{app}\labels"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: ".\valentina\*.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\valentina\*.dll"; DestDir: "{app}"
Source: ".\valentina\*.txt"; DestDir: "{app}"; Flags: ignoreversion

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<version>1.0.0</version>
<lines>
<line alignment="0" bold="true" italic="false" sfIncrement="4" text="%author%"/>
<line alignment="0" bold="false" italic="false" sfIncrement="2" text="%patternName%"/>
<line alignment="0" bold="false" italic="false" sfIncrement="0" text="%patternNumber%"/>
<line alignment="0" bold="false" italic="true" sfIncrement="0" text="%customer%"/>
<line alignment="0" bold="false" italic="true" sfIncrement="0" text="%date%"/>
</lines>
</template>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<version>1.0.0</version>
<lines>
<line alignment="4" bold="true" italic="false" sfIncrement="6" text="%pLetter%"/>
<line alignment="4" bold="true" italic="false" sfIncrement="2" text="%pName%"/>
<line alignment="4" bold="false" italic="false" sfIncrement="0" text="%mFabric%, %wCut% %pQuantity%"/>
</lines>
</template>

View File

@ -6,4 +6,9 @@ INSTALL_STANDARD_TEMPLATES += \
$$PWD/share/tables/templates/template_all_measurements.vit \
$$PWD/share/tables/templates/t_Aldrich_Women.vit
# Keep path to all label templates we provide right now
INSTALL_LABEL_TEMPLATES += $$PWD/share/labels/def_pattern_label.xml \
$$PWD/share/labels/def_piece_label.xml
copyToDestdir($$INSTALL_MULTISIZE_MEASUREMENTS, $$shell_path($${OUT_PWD}/$$DESTDIR/tables/multisize))
copyToDestdir($$INSTALL_LABEL_TEMPLATES, $$shell_path($${OUT_PWD}/$$DESTDIR/labels))

View File

@ -63,6 +63,7 @@ void PreferencesPathPage::Apply()
settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
settings->SetPathLayout(ui->pathTable->item(3, 1)->text());
settings->SetPathTemplate(ui->pathTable->item(4, 1)->text());
settings->SetPathLabelTemplate(ui->pathTable->item(5, 1)->text());
}
//---------------------------------------------------------------------------------------------------------------------
@ -91,6 +92,9 @@ void PreferencesPathPage::DefaultPath()
case 4: // templates
path = VCommonSettings::GetDefPathTemplate();
break;
case 5: // label templates
path = VSettings::GetDefPathLabelTemplate();
break;
default:
break;
}
@ -125,6 +129,9 @@ void PreferencesPathPage::EditPath()
case 4: // templates
path = qApp->ValentinaSettings()->GetPathTemplate();
break;
case 5: // label templates
path = qApp->ValentinaSettings()->GetPathLabelTemplate();
break;
default:
break;
}
@ -164,7 +171,7 @@ void PreferencesPathPage::EditPath()
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPathPage::InitTable()
{
ui->pathTable->setRowCount(5);
ui->pathTable->setRowCount(6);
ui->pathTable->setColumnCount(2);
const VSettings *settings = qApp->ValentinaSettings();
@ -204,6 +211,13 @@ void PreferencesPathPage::InitTable()
ui->pathTable->setItem(4, 1, item);
}
{
ui->pathTable->setItem(5, 0, new QTableWidgetItem(tr("My label templates")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathLabelTemplate());
item->setToolTip(settings->GetPathLabelTemplate());
ui->pathTable->setItem(5, 1, item);
}
ui->pathTable->verticalHeader()->setDefaultSectionSize(20);
ui->pathTable->resizeColumnsToContents();
ui->pathTable->resizeRowsToContents();

View File

@ -30,8 +30,27 @@
#include "ui_preferencespatternpage.h"
#include "../../core/vapplication.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../dialogdatetimeformats.h"
#include <QMessageBox>
#include <QDate>
#include <QTime>
namespace
{
QStringList ComboBoxAllStrings(QComboBox *combo)
{
SCASSERT(combo != nullptr)
QStringList itemsInComboBox;
for (int index = 0; index < combo->count(); ++index)
{
itemsInComboBox << combo->itemText(index);
}
return itemsInComboBox;
}
}
//---------------------------------------------------------------------------------------------------------------------
PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
@ -39,20 +58,11 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
ui(new Ui::PreferencesPatternPage)
{
ui->setupUi(this);
ui->userName->setText(qApp->ValentinaSettings()->GetUser());
ui->graphOutputCheck->setChecked(qApp->ValentinaSettings()->GetGraphicalOutput());
ui->undoCount->setValue(qApp->ValentinaSettings()->GetUndoCount());
connect(ui->userMaterialClearButton, &QPushButton::clicked, this, [this]()
{
VSettings* pSet = qApp->ValentinaSettings();
pSet->ClearUserDefinedMaterial();
pSet->sync();
QString qsMsg = tr("All user defined materials have been deleted!");
QMessageBox::information(this, QCoreApplication::applicationName(), qsMsg);
});
InitDefaultSeamAllowance();
InitLabelDateTimeFormats();
ui->forbidFlippingCheck->setChecked(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping());
ui->doublePassmarkCheck->setChecked(qApp->ValentinaSettings()->IsDoublePassmark());
@ -70,7 +80,6 @@ PreferencesPatternPage::~PreferencesPatternPage()
void PreferencesPatternPage::Apply()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetUser(ui->userName->text());
// Scene antialiasing
settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked());
@ -86,13 +95,19 @@ void PreferencesPatternPage::Apply()
settings->SetForbidWorkpieceFlipping(ui->forbidFlippingCheck->isChecked());
settings->SetHideMainPath(ui->checkBoxHideMainPath->isChecked());
qApp->ValentinaSettings()->SetLabelFont(ui->fontComboBoxLabelFont->currentFont());
settings->SetLabelFont(ui->fontComboBoxLabelFont->currentFont());
if (settings->IsDoublePassmark() != ui->doublePassmarkCheck->isChecked())
{
settings->SetDoublePassmark(ui->doublePassmarkCheck->isChecked());
qApp->getCurrentDocument()->LiteParseTree(Document::LiteParse);
}
settings->SetLabelDateFormat(ui->comboBoxDateFormats->currentText());
settings->SetLabelTimeFormat(ui->comboBoxTimeFormats->currentText());
settings->SetUserDefinedDateFormats(ComboBoxAllStrings(ui->comboBoxDateFormats));
settings->SetUserDefinedTimeFormats(ComboBoxAllStrings(ui->comboBoxTimeFormats));
}
//---------------------------------------------------------------------------------------------------------------------
@ -101,3 +116,81 @@ void PreferencesPatternPage::InitDefaultSeamAllowance()
ui->defaultSeamAllowance->setValue(qApp->ValentinaSettings()->GetDefaultSeamAllowance());
ui->defaultSeamAllowance->setSuffix(UnitsToStr(StrToUnits(qApp->ValentinaSettings()->GetUnit()), true));
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::EditDateTimeFormats()
{
VSettings *settings = qApp->ValentinaSettings();
QPushButton *button = qobject_cast<QPushButton *>(sender());
if (button == ui->pushButtonEditDateFormats)
{
CallDateTimeFormatEditor(QDate::currentDate(), settings->PredefinedDateFormats(),
settings->GetUserDefinedDateFormats(), ui->comboBoxDateFormats);
}
else if (button == ui->pushButtonEditTimeFormats)
{
CallDateTimeFormatEditor(QTime::currentTime(), settings->PredefinedTimeFormats(),
settings->GetUserDefinedTimeFormats(), ui->comboBoxTimeFormats);
}
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::InitLabelDateTimeFormats()
{
VSettings *settings = qApp->ValentinaSettings();
InitComboBoxFormats(ui->comboBoxDateFormats,
VSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(),
settings->GetLabelDateFormat());
InitComboBoxFormats(ui->comboBoxTimeFormats,
VSettings::PredefinedTimeFormats() + settings->GetUserDefinedTimeFormats(),
settings->GetLabelTimeFormat());
connect(ui->pushButtonEditDateFormats, &QPushButton::clicked, this, &PreferencesPatternPage::EditDateTimeFormats);
connect(ui->pushButtonEditTimeFormats, &QPushButton::clicked, this, &PreferencesPatternPage::EditDateTimeFormats);
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString &currentFormat)
{
SCASSERT(box != nullptr)
box->addItems(items);
int index = box->findText(currentFormat);
if (index != -1)
{
box->setCurrentIndex(index);
}
else
{
box->setCurrentIndex(0);
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void PreferencesPatternPage::CallDateTimeFormatEditor(const T &type, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QComboBox *box)
{
SCASSERT(box != nullptr)
DialogDateTimeFormats dialog(type, predefinedFormats, userDefinedFormats);
if (QDialog::Accepted == dialog.exec())
{
const QString currentFormat = box->currentText();
box->clear();
box->addItems(dialog.GetFormats());
int index = box->findText(currentFormat);
if (index != -1)
{
box->setCurrentIndex(index);
}
else
{
box->setCurrentIndex(0);
}
}
}

View File

@ -36,6 +36,8 @@ namespace Ui
class PreferencesPatternPage;
}
class QComboBox;
class PreferencesPatternPage : public QWidget
{
Q_OBJECT
@ -47,9 +49,19 @@ public:
void Apply();
void InitDefaultSeamAllowance();
private slots:
void EditDateTimeFormats();
private:
Q_DISABLE_COPY(PreferencesPatternPage)
Ui::PreferencesPatternPage *ui;
void InitLabelDateTimeFormats();
void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString &currentFormat);
template <typename T>
void CallDateTimeFormatEditor(const T &type, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QComboBox *box);
};
#endif // PREFERENCESPATTERNPAGE_H

View File

@ -7,36 +7,13 @@
<x>0</x>
<y>0</y>
<width>381</width>
<height>444</height>
<height>705</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Pattern</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>User</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>User name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="userName">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
@ -75,28 +52,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>User defined materials</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="userMaterialClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete all</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
@ -182,6 +137,60 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Label data/time format</string>
</property>
<layout class="QFormLayout" name="formLayout_4">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Date:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="comboBoxDateFormats"/>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditDateFormats">
<property name="text">
<string>Edit formats</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Time:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="comboBoxTimeFormats"/>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditTimeFormats">
<property name="text">
<string>Edit formats</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -0,0 +1,218 @@
/************************************************************************
**
** @file dialogdatetimeformats.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/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 "dialogdatetimeformats.h"
#include "ui_dialogdatetimeformats.h"
//---------------------------------------------------------------------------------------------------------------------
DialogDateTimeFormats::DialogDateTimeFormats(const QDate &date, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QWidget *parent)
: QDialog(parent),
ui(new Ui::DialogDateTimeFormats),
m_dateMode(true),
m_date(date),
m_time(),
m_predefined(predefinedFormats)
{
ui->setupUi(this);
Init(predefinedFormats, userDefinedFormats);
}
//---------------------------------------------------------------------------------------------------------------------
DialogDateTimeFormats::DialogDateTimeFormats(const QTime &time, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QWidget *parent)
: QDialog(parent),
ui(new Ui::DialogDateTimeFormats),
m_dateMode(false),
m_date(),
m_time(time),
m_predefined(predefinedFormats)
{
ui->setupUi(this);
Init(predefinedFormats, userDefinedFormats);
}
//---------------------------------------------------------------------------------------------------------------------
DialogDateTimeFormats::~DialogDateTimeFormats()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList DialogDateTimeFormats::GetFormats() const
{
QStringList formats;
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *lineItem = ui->listWidget->item(i))
{
const QString format = lineItem->data(Qt::UserRole).toString();
if (not format.isEmpty())
{
formats.append(lineItem->data(Qt::UserRole).toString());
}
}
}
return formats;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDateTimeFormats::AddLine()
{
int row = ui->listWidget->count();
ui->listWidget->insertItem(++row, new QListWidgetItem(tr("<empty>")));
ui->listWidget->setCurrentRow(row);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDateTimeFormats::RemoveLine()
{
ui->listWidget->blockSignals(true);
if (QListWidgetItem *curLine = ui->listWidget->currentItem())
{
if (not m_predefined.contains(curLine->data(Qt::UserRole).toString()))
{
delete ui->listWidget->takeItem(ui->listWidget->currentRow());
}
}
ui->listWidget->blockSignals(false);
ShowFormatDetails();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDateTimeFormats::SaveFormat(const QString &text)
{
if (QListWidgetItem *curLine = ui->listWidget->currentItem())
{
if (not GetFormats().contains(text))
{
const QString preview = m_dateMode ? m_date.toString(text) : m_time.toString(text);
curLine->setText(preview);
curLine->setData(Qt::UserRole, text);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDateTimeFormats::ShowFormatDetails()
{
if (ui->listWidget->count() > 0)
{
if (const QListWidgetItem *line = ui->listWidget->currentItem())
{
ui->lineEditFormat->blockSignals(true);
ui->lineEditFormat->setText(line->data(Qt::UserRole).toString());
ui->lineEditFormat->blockSignals(false);
}
}
SetupControls();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDateTimeFormats::Init(const QStringList &predefined, const QStringList &userDefined)
{
SetFormatLines(predefined, userDefined);
ui->lineEditFormat->setClearButtonEnabled(true);
connect(ui->toolButtonRemove, &QToolButton::clicked, this, &DialogDateTimeFormats::RemoveLine);
connect(ui->toolButtonAdd, &QToolButton::clicked, this, &DialogDateTimeFormats::AddLine);
connect(ui->lineEditFormat, &QLineEdit::textEdited, this, &DialogDateTimeFormats::SaveFormat);
connect(ui->listWidget, &QListWidget::itemSelectionChanged, this, &DialogDateTimeFormats::ShowFormatDetails);
ui->listWidget->setCurrentRow(0);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDateTimeFormats::SetFormatLines(const QStringList &predefined, const QStringList &userDefined)
{
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
int row = -1;
for (int i=0; i<predefined.size(); ++i)
{
ui->listWidget->insertItem(++row, AddListLine(predefined.at(i)));
}
for (int i=0; i<userDefined.size(); ++i)
{
ui->listWidget->insertItem(++row, AddListLine(userDefined.at(i)));
}
ui->listWidget->blockSignals(false);
if (ui->listWidget->count() > 0)
{
ui->listWidget->setCurrentRow(0);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogDateTimeFormats::SetupControls()
{
const bool enabled = ui->listWidget->count() > 0;
if (not enabled)
{
ui->lineEditFormat->blockSignals(true);
ui->lineEditFormat->clear();
ui->lineEditFormat->blockSignals(false);
}
ui->toolButtonAdd->setEnabled(true);
ui->lineEditFormat->setEnabled(enabled);
const QListWidgetItem *line = ui->listWidget->currentItem();
if (line != nullptr && m_predefined.contains(line->data(Qt::UserRole).toString()))
{
ui->toolButtonRemove->setEnabled(false);
ui->lineEditFormat->setReadOnly(true);
}
else
{
ui->toolButtonRemove->setEnabled(enabled);
ui->lineEditFormat->setReadOnly(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
QListWidgetItem *DialogDateTimeFormats::AddListLine(const QString &format)
{
const QString preview = m_dateMode ? m_date.toString(format) : m_time.toString(format);
QListWidgetItem *item = new QListWidgetItem(preview);
item->setData(Qt::UserRole, format);
return item;
}

View File

@ -0,0 +1,79 @@
/************************************************************************
**
** @file dialogdatetimeformats.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 19 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/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 DIALOGDATETIMEFORMATS_H
#define DIALOGDATETIMEFORMATS_H
#include <QDialog>
#include <QDate>
#include <QTime>
namespace Ui
{
class DialogDateTimeFormats;
}
class QListWidgetItem;
class DialogDateTimeFormats : public QDialog
{
Q_OBJECT
public:
DialogDateTimeFormats(const QDate &date, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QWidget *parent = nullptr);
DialogDateTimeFormats(const QTime &time, const QStringList &predefinedFormats,
const QStringList &userDefinedFormats, QWidget *parent = nullptr);
virtual ~DialogDateTimeFormats();
QStringList GetFormats() const;
private slots:
void AddLine();
void RemoveLine();
void SaveFormat(const QString &text);
void ShowFormatDetails();
private:
Q_DISABLE_COPY(DialogDateTimeFormats)
Ui::DialogDateTimeFormats *ui;
bool m_dateMode;
QDate m_date;
QTime m_time;
QStringList m_predefined;
void Init(const QStringList &predefined, const QStringList &userDefined);
void SetFormatLines(const QStringList &predefined, const QStringList &userDefined);
void SetupControls();
bool IsPredefined() const;
QListWidgetItem *AddListLine(const QString &format);
};
#endif // DIALOGDATETIMEFORMATS_H

View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogDateTimeFormats</class>
<widget class="QDialog" name="DialogDateTimeFormats">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<height>381</height>
</rect>
</property>
<property name="windowTitle">
<string>Label date time editor</string>
</property>
<property name="windowIcon">
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Format:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFormat">
<property name="enabled">
<bool>false</bool>
</property>
<property name="statusTip">
<string/>
</property>
<property name="placeholderText">
<string>Insert a format</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonAdd">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">Add</string>
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonRemove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">Remove</string>
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogDateTimeFormats</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogDateTimeFormats</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -33,9 +33,12 @@
#include <QFileDialog>
#include <QMenu>
#include <QDate>
#include <QMessageBox>
#include "../xml/vpattern.h"
#include "../vpatterndb/vcontainer.h"
#include "../core/vapplication.h"
#include "../vtools/dialogs/support/dialogeditlabel.h"
// calc how many combinations we have
static const int heightsCount = (static_cast<int>(GHeights::H200) -
@ -43,8 +46,7 @@ static const int heightsCount = (static_cast<int>(GHeights::H200) -
static const int sizesCount = (static_cast<int>(GSizes::S72) - (static_cast<int>(GSizes::S22) - sizeStep))/sizeStep;
//---------------------------------------------------------------------------------------------------------------------
DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPattern *doc, VContainer *pattern,
QWidget *parent)
DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent)
: QDialog(parent),
ui(new Ui::DialogPatternProperties),
doc(doc),
@ -58,22 +60,23 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
gradationChanged(false),
defaultChanged(false),
securityChanged(false),
generalInfoChanged(false),
labelDataChanged(false),
askSaveLabelData(false),
templateDataChanged(false),
deleteAction(nullptr),
changeImageAction(nullptr),
saveImageAction(nullptr),
showImageAction(nullptr),
m_filePath(filePath)
templateLines()
{
ui->setupUi(this);
ui->lineEditAuthor->setClearButtonEnabled(true);
SCASSERT(doc != nullptr)
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
VSettings *settings = qApp->ValentinaSettings();
settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
if (m_filePath.isEmpty())
if (qApp->GetPPath().isEmpty())
{
ui->lineEditPathToFile->setText(tr("<Empty>"));
ui->lineEditPathToFile->setToolTip(tr("File was not saved yet."));
@ -81,23 +84,20 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
}
else
{
ui->lineEditPathToFile->setText(QDir::toNativeSeparators(m_filePath));
ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(m_filePath));
ui->lineEditPathToFile->setText(QDir::toNativeSeparators(qApp->GetPPath()));
ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(qApp->GetPPath()));
ui->pushButtonShowInExplorer->setEnabled(true);
}
ui->lineEditPathToFile->setCursorPosition(0);
connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]()
{
ShowInGraphicalShell(m_filePath);
ShowInGraphicalShell(qApp->GetPPath());
});
#if defined(Q_OS_MAC)
ui->pushButtonShowInExplorer->setText(tr("Show in Finder"));
#endif //defined(Q_OS_MAC)
ui->lineEditAuthor->setText(doc->GetAuthor());
connect(ui->lineEditAuthor, &QLineEdit::editingFinished, this, &DialogPatternProperties::DescEdited);
ui->plainTextEditDescription->setPlainText(doc->GetDescription());
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
@ -175,32 +175,24 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
ui->lineEditPatternNumber->setText(doc->GetPatternNumber());
ui->lineEditCompanyName->setText(doc->GetCompanyName());
ui->lineEditCustomerName->setText(doc->GetCustomerName());
ui->checkBoxShowDate->setText(ui->checkBoxShowDate->text()
.arg(QDate::currentDate().toString(Qt::SystemLocaleLongDate)));
ui->lineEditSize->setText(doc->GetPatternSize());
const QString plSize = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_size) + QLatin1String("%");
const QString plHeight = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_height) + QLatin1String("%");
ui->lineEditSize->setToolTip(tr("Use %1 and %2 to insert pattern size and height").arg(plSize, plHeight));
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel);
ui->checkBoxShowDate->setChecked(doc->IsDateVisible());
if (doc->MPath().isEmpty() == true)
{
ui->checkBoxShowMeasurements->setChecked(false);
ui->checkBoxShowMeasurements->setEnabled(false);
}
else
{
ui->checkBoxShowMeasurements->setChecked(doc->IsMeasurementsVisible());
}
InitComboBoxFormats(ui->comboBoxDateFormat,
VSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(),
doc->GetLabelDateFormat());
InitComboBoxFormats(ui->comboBoxTimeFormat,
VSettings::PredefinedTimeFormats() + settings->GetUserDefinedTimeFormats(),
doc->GetLabelTimeFormat());
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditSize, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->checkBoxShowDate, &QCheckBox::stateChanged, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->checkBoxShowMeasurements, &QCheckBox::stateChanged, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->comboBoxDateFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &DialogPatternProperties::LabelDataChanged);
connect(ui->comboBoxTimeFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &DialogPatternProperties::LabelDataChanged);
}
//---------------------------------------------------------------------------------------------------------------------
@ -216,27 +208,18 @@ void DialogPatternProperties::Apply()
{
case 0:
SaveDescription();
descriptionChanged = false;
emit doc->patternChanged(false);
break;
case 1:
SaveGradation();
gradationChanged = false;
SaveDefValues();
defaultChanged = false;
emit doc->patternChanged(false);
break;
case 2:
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked());
securityChanged = false;
emit doc->patternChanged(false);
SaveReadOnlyState();
break;
case 3:
SaveGeneralInfo();
generalInfoChanged = false;
emit doc->patternChanged(false);
SaveLabelData();
SaveTemplateData();
break;
default:
break;
}
@ -245,40 +228,12 @@ void DialogPatternProperties::Apply()
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::Ok()
{
if (descriptionChanged)
{
SaveDescription();
descriptionChanged = false;
emit doc->patternChanged(false);
}
if (gradationChanged)
{
SaveGradation();
gradationChanged = false;
emit doc->patternChanged(false);
}
if (defaultChanged)
{
SaveDefValues();
defaultChanged = false;
emit doc->patternChanged(false);
}
if (securityChanged)
{
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked());
securityChanged = false;
emit doc->patternChanged(false);
}
if (generalInfoChanged == true)
{
SaveGeneralInfo();
generalInfoChanged = false;
emit doc->patternChanged(false);
}
SaveReadOnlyState();
SaveLabelData();
SaveTemplateData();
close();
}
@ -421,9 +376,10 @@ void DialogPatternProperties::DefValueChanged()
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::GeneralInfoChanged()
void DialogPatternProperties::LabelDataChanged()
{
generalInfoChanged = true;
labelDataChanged = true;
askSaveLabelData = true;
}
//---------------------------------------------------------------------------------------------------------------------
@ -554,6 +510,24 @@ void DialogPatternProperties::InitSizes()
Init(ui->checkBoxS72, static_cast<int>(GSizes::S72), &DialogPatternProperties::CheckStateSize);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::InitComboBoxFormats(QComboBox *box, const QStringList &items,
const QString &currentFormat)
{
SCASSERT(box != nullptr)
box->addItems(items);
int index = box->findText(currentFormat);
if (index != -1)
{
box->setCurrentIndex(index);
}
else
{
box->setCurrentIndex(0);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::CheckApplyOk()
{
@ -565,22 +539,35 @@ void DialogPatternProperties::CheckApplyOk()
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveDescription()
{
if (descriptionChanged)
{
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText());
doc->SetAuthor(ui->lineEditAuthor->text());
descriptionChanged = false;
emit doc->patternChanged(false);
emit doc->UpdatePatternLabel();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveGradation()
{
if (gradationChanged)
{
doc->SetGradationHeights(heights);
doc->SetGradationSizes(sizes);
emit UpdateGradation();
gradationChanged = false;
emit doc->patternChanged(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveDefValues()
{
if (defaultChanged)
{
if (ui->radioButtonDefFromM->isChecked())
{
doc->SetDefCustom(false);
@ -592,18 +579,50 @@ void DialogPatternProperties::SaveDefValues()
doc->SetDefCustomSize(ui->comboBoxSize->currentText().toInt());
}
defaultChanged = false;
emit doc->patternChanged(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveGeneralInfo()
void DialogPatternProperties::SaveLabelData()
{
if (labelDataChanged)
{
doc->SetPatternName(ui->lineEditPatternName->text());
doc->SetPatternNumber(ui->lineEditPatternNumber->text());
doc->SetCompanyName(ui->lineEditCompanyName->text());
doc->SetCustomerName(ui->lineEditCustomerName->text());
doc->SetPatternSize(ui->lineEditSize->text());
doc->SetDateVisible(ui->checkBoxShowDate->isChecked());
doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked());
doc->SetLabelDateFormat(ui->comboBoxDateFormat->currentText());
doc->SetLabelTimeFormat(ui->comboBoxTimeFormat->currentText());
labelDataChanged = false;
askSaveLabelData = false;
emit doc->patternChanged(false);
emit doc->UpdatePatternLabel();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveTemplateData()
{
if (templateDataChanged)
{
doc->SetPatternLabelTemplate(templateLines);
templateDataChanged = false;
emit doc->patternChanged(false);
emit doc->UpdatePatternLabel();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveReadOnlyState()
{
if (securityChanged)
{
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked());
securityChanged = false;
emit doc->patternChanged(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -849,3 +868,33 @@ void DialogPatternProperties::SaveImage()
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::EditLabel()
{
if (labelDataChanged && askSaveLabelData)
{
QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Save label data."),
tr("Label data were changed. Do you want to save them before editing label template?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::Yes)
{
SaveLabelData();
}
else
{
askSaveLabelData = false;
}
}
DialogEditLabel editor(doc);
templateDataChanged ? editor.SetTemplate(templateLines) : editor.SetTemplate(doc->GetPatternLabelTemplate());
if (QDialog::Accepted == editor.exec())
{
templateLines = editor.GetTemplate();
templateDataChanged = true;
}
}

View File

@ -33,6 +33,8 @@
#include "../options.h"
#include <QMap>
#include "../vformat/vlabeltemplate.h"
class VPattern;
class VContainer;
class QCheckBox;
@ -46,14 +48,13 @@ class DialogPatternProperties : public QDialog
{
Q_OBJECT
public:
explicit DialogPatternProperties(const QString &filePath, VPattern *doc, VContainer *pattern,
QWidget *parent = nullptr);
explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr);
virtual ~DialogPatternProperties() Q_DECL_OVERRIDE;
signals:
void UpdateGradation();
private slots:
void DefValueChanged();
void GeneralInfoChanged();
void LabelDataChanged();
void Apply();
void Ok();
void SelectAll(int state);
@ -62,6 +63,7 @@ private slots:
void DescEdited();
void ChangeImage();
void SaveImage();
void EditLabel();
private:
Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui;
@ -76,12 +78,15 @@ private:
bool gradationChanged;
bool defaultChanged;
bool securityChanged;
bool generalInfoChanged;
bool labelDataChanged;
bool askSaveLabelData;
bool templateDataChanged;
QAction *deleteAction;
QAction *changeImageAction;
QAction *saveImageAction;
QAction *showImageAction;
const QString &m_filePath;
QVector<VLabelTemplateLine> templateLines;
void SetHeightsChecked(bool enabled);
void SetSizesChecked(bool enabled);
@ -93,11 +98,14 @@ private:
void SetOptions(const QMap<GVal, bool> &option);
template<typename GVal>
void InitComboBox(QComboBox *box, const QMap<GVal, bool> &option);
void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString &currentFormat);
void CheckApplyOk();
void SaveDescription();
void SaveGradation();
void SaveDefValues();
void SaveGeneralInfo();
void SaveLabelData();
void SaveTemplateData();
void SaveReadOnlyState();
void SetDefaultHeight(const QString &def);
void SetDefaultSize(const QString &def);

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>727</width>
<width>655</width>
<height>532</height>
</rect>
</property>
@ -21,11 +21,11 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Description</string>
<string>Pattern</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
@ -80,20 +80,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Author name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditAuthor"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
@ -183,7 +169,7 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>For technical notes.</string>
<string>For technical notes</string>
</property>
</widget>
</item>
@ -1205,11 +1191,58 @@
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>General info</string>
<string>Label data</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_12">
<layout class="QVBoxLayout" name="verticalLayout_32">
<item>
<layout class="QFormLayout" name="formLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Label template:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditPatternLabel">
<property name="toolTip">
<string>Edit pattern label</string>
</property>
<property name="text">
<string>Edit template</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<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>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Label data</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@ -1267,33 +1300,26 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="label">
<property name="text">
<string>Pattern size:</string>
<string>Date format:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditSize">
<property name="maxLength">
<number>40</number>
<widget class="QComboBox" name="comboBoxDateFormat"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Time format:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboBoxTimeFormat"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxShowDate">
<property name="text">
<string>Show date of layout creation (%1)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxShowMeasurements">
<property name="text">
<string>Show measurements file</string>
</property>
</widget>
</item>
</layout>

View File

@ -16,7 +16,8 @@ HEADERS += \
$$PWD/dialogpreferences.h \
$$PWD/configpages/preferencesconfigurationpage.h \
$$PWD/configpages/preferencespatternpage.h \
$$PWD/configpages/preferencespathpage.h
$$PWD/configpages/preferencespathpage.h \
$$PWD/dialogdatetimeformats.h
SOURCES += \
$$PWD/dialogincrements.cpp \
@ -32,7 +33,8 @@ SOURCES += \
$$PWD/dialogpreferences.cpp \
$$PWD/configpages/preferencesconfigurationpage.cpp \
$$PWD/configpages/preferencespatternpage.cpp \
$$PWD/configpages/preferencespathpage.cpp
$$PWD/configpages/preferencespathpage.cpp \
$$PWD/dialogdatetimeformats.cpp
FORMS += \
$$PWD/dialogincrements.ui \
@ -48,4 +50,5 @@ FORMS += \
$$PWD/dialogpreferences.ui \
$$PWD/configpages/preferencesconfigurationpage.ui \
$$PWD/configpages/preferencespatternpage.ui \
$$PWD/configpages/preferencespathpage.ui
$$PWD/configpages/preferencespathpage.ui \
$$PWD/dialogdatetimeformats.ui

View File

@ -62,7 +62,9 @@
#include "../vtools/undocommands/addgroup.h"
#include "dialogs/vwidgetdetails.h"
#include "../vpatterndb/vpiecepath.h"
#include "../vpatterndb/measurements.h"
#include "../qmuparser/qmuparsererror.h"
#include "../vtools/dialogs/support/dialogeditlabel.h"
#include <QInputDialog>
#include <QtDebug>
@ -451,12 +453,6 @@ bool MainWindow::LoadMeasurements(const QString &path)
return false;
}
if (m->Type() == MeasurementsType::Multisize)
{
VContainer::SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()));
VContainer::SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()));
}
try
{
qApp->setPatternType(m->Type());
@ -474,6 +470,18 @@ bool MainWindow::LoadMeasurements(const QString &path)
}
return false;
}
if (m->Type() == MeasurementsType::Multisize)
{
VContainer::SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()));
VContainer::SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()));
}
else if (m->Type() == MeasurementsType::Individual)
{
VContainer::SetSize(*pattern->DataVariables()->value(size_M)->GetValue());
VContainer::SetHeight(*pattern->DataVariables()->value(height_M)->GetValue());
}
return true;
}
@ -497,12 +505,6 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
return false;
}
if (m->Type() == MeasurementsType::Multisize)
{
VContainer::SetSize(size);
VContainer::SetHeight(height);
}
try
{
pattern->ClearVariables(VarType::Measurement);
@ -518,6 +520,18 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
}
return false;
}
if (m->Type() == MeasurementsType::Multisize)
{
VContainer::SetSize(size);
VContainer::SetHeight(height);
}
else if (m->Type() == MeasurementsType::Individual)
{
VContainer::SetSize(*pattern->DataVariables()->value(size_M)->GetValue());
VContainer::SetHeight(*pattern->DataVariables()->value(height_M)->GetValue());
}
return true;
}
@ -1519,10 +1533,10 @@ void MainWindow::LoadIndividual()
{
if (not doc->MPath().isEmpty())
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath()));
}
ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath));
doc->SetMPath(RelativeMPath(qApp->GetPPath(), mPath));
watcher->addPath(mPath);
PatternChangesWereSaved(false);
ui->actionEditCurrent->setEnabled(true);
@ -1568,10 +1582,10 @@ void MainWindow::LoadMultisize()
{
if (not doc->MPath().isEmpty())
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath()));
}
ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath));
doc->SetMPath(RelativeMPath(qApp->GetPPath(), mPath));
watcher->addPath(mPath);
PatternChangesWereSaved(false);
ui->actionEditCurrent->setEnabled(true);
@ -1607,8 +1621,13 @@ void MainWindow::UnloadMeasurements()
if (doc->ListMeasurements().isEmpty())
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
doc->SetPath(QString());
watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath()));
if (qApp->patternType() == MeasurementsType::Multisize)
{
ToolBarOption();
}
qApp->setPatternType(MeasurementsType::Unknown);
doc->SetMPath(QString());
PatternChangesWereSaved(false);
ui->actionEditCurrent->setEnabled(false);
ui->actionUnloadMeasurements->setDisabled(true);
@ -1628,7 +1647,7 @@ void MainWindow::ShowMeasurements()
{
if (not doc->MPath().isEmpty())
{
const QString absoluteMPath = AbsoluteMPath(curFile, doc->MPath());
const QString absoluteMPath = AbsoluteMPath(qApp->GetPPath(), doc->MPath());
QStringList arguments;
if (qApp->patternType() == MeasurementsType::Multisize)
@ -1700,7 +1719,7 @@ void MainWindow::SyncMeasurements()
{
if (mChanges)
{
const QString path = AbsoluteMPath(curFile, doc->MPath());
const QString path = AbsoluteMPath(qApp->GetPPath(), doc->MPath());
if(UpdateMeasurements(path, static_cast<int>(VContainer::size()), static_cast<int>(VContainer::height())))
{
if (not watcher->files().contains(path))
@ -2530,7 +2549,14 @@ bool MainWindow::SaveAs()
{
QString filters(tr("Pattern files") + QLatin1String("(*.val)"));
QString dir;
curFile.isEmpty() ? dir = qApp->ValentinaSettings()->GetPathPattern() : dir = QFileInfo(curFile).absolutePath();
if (qApp->GetPPath().isEmpty())
{
dir = qApp->ValentinaSettings()->GetPathPattern();
}
else
{
dir = QFileInfo(qApp->GetPPath()).absolutePath();
}
bool usedNotExistedDir = false;
QDir directory(dir);
@ -2632,7 +2658,7 @@ bool MainWindow::SaveAs()
*/
bool MainWindow::Save()
{
if (curFile.isEmpty() || patternReadOnly)
if (qApp->GetPPath().isEmpty() || patternReadOnly)
{
return SaveAs();
}
@ -2646,7 +2672,7 @@ bool MainWindow::Save()
#ifdef Q_OS_WIN32
qt_ntfs_permission_lookup++; // turn checking on
#endif /*Q_OS_WIN32*/
const bool isFileWritable = QFileInfo(curFile).isWritable();
const bool isFileWritable = QFileInfo(qApp->GetPPath()).isWritable();
#ifdef Q_OS_WIN32
qt_ntfs_permission_lookup--; // turn it off again
#endif /*Q_OS_WIN32*/
@ -2665,8 +2691,8 @@ bool MainWindow::Save()
#ifdef Q_OS_WIN32
qt_ntfs_permission_lookup++; // turn checking on
#endif /*Q_OS_WIN32*/
bool changed = QFile::setPermissions(curFile,
QFileInfo(curFile).permissions() | QFileDevice::WriteUser);
bool changed = QFile::setPermissions(qApp->GetPPath(),
QFileInfo(qApp->GetPPath()).permissions() | QFileDevice::WriteUser);
#ifdef Q_OS_WIN32
qt_ntfs_permission_lookup--; // turn it off again
#endif /*Q_OS_WIN32*/
@ -2675,7 +2701,7 @@ bool MainWindow::Save()
{
QMessageBox messageBox(this);
messageBox.setIcon(QMessageBox::Warning);
messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(curFile));
messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(qApp->GetPPath()));
messageBox.setInformativeText(tr("Could not save the file."));
messageBox.setDefaultButton(QMessageBox::Ok);
messageBox.setStandardButtons(QMessageBox::Ok);
@ -2690,10 +2716,10 @@ bool MainWindow::Save()
}
QString error;
bool result = SavePattern(curFile, error);
bool result = SavePattern(qApp->GetPPath(), error);
if (result)
{
QFile::remove(curFile + autosavePrefix);
QFile::remove(qApp->GetPPath() + autosavePrefix);
m_curFileFormatVersion = VPatternConverter::PatternMaxVer;
m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr;
}
@ -2754,9 +2780,9 @@ void MainWindow::Clear()
qCDebug(vMainWindow, "Returned to Draw mode.");
pattern->Clear();
qCDebug(vMainWindow, "Clearing pattern.");
if (not curFile.isEmpty() && not doc->MPath().isEmpty())
if (not qApp->GetPPath().isEmpty() && not doc->MPath().isEmpty())
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath()));
}
doc->clear();
setCurrentFile(QString());
@ -2807,16 +2833,16 @@ void MainWindow::FileClosedCorrect()
//File was closed correct.
QStringList restoreFiles = qApp->ValentinaSettings()->GetRestoreFileList();
restoreFiles.removeAll(curFile);
restoreFiles.removeAll(qApp->GetPPath());
qApp->ValentinaSettings()->SetRestoreFileList(restoreFiles);
// Remove autosave file
QFile autofile(curFile + autosavePrefix);
QFile autofile(qApp->GetPPath() + autosavePrefix);
if (autofile.exists())
{
autofile.remove();
}
qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(curFile));
qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(qApp->GetPPath()));
}
//---------------------------------------------------------------------------------------------------------------------
@ -3161,7 +3187,8 @@ void MainWindow::PatternChangesWereSaved(bool saved)
void MainWindow::ChangedSize(const QString & text)
{
const int size = static_cast<int>(VContainer::size());
if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), text.toInt(), static_cast<int>(VContainer::height())))
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPPath(), doc->MPath()), text.toInt(),
static_cast<int>(VContainer::height())))
{
doc->LiteParseTree(Document::LiteParse);
emit sceneDetails->DimensionsChanged();
@ -3190,7 +3217,8 @@ void MainWindow::ChangedSize(const QString & text)
void MainWindow::ChangedHeight(const QString &text)
{
const int height = static_cast<int>(VContainer::height());
if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), static_cast<int>(VContainer::size()), text.toInt()))
if (UpdateMeasurements(AbsoluteMPath(qApp->GetPPath(), doc->MPath()), static_cast<int>(VContainer::size()),
text.toInt()))
{
doc->LiteParseTree(Document::LiteParse);
emit sceneDetails->DimensionsChanged();
@ -3374,10 +3402,10 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error)
qCDebug(vMainWindow, "Saving pattern file %s.", qUtf8Printable(fileName));
QFileInfo tempInfo(fileName);
const QString mPath = AbsoluteMPath(curFile, doc->MPath());
if (not mPath.isEmpty() && curFile != fileName)
const QString mPath = AbsoluteMPath(qApp->GetPPath(), doc->MPath());
if (not mPath.isEmpty() && qApp->GetPPath() != fileName)
{
doc->SetPath(RelativeMPath(fileName, mPath));
doc->SetMPath(RelativeMPath(fileName, mPath));
}
const bool result = doc->SaveDocument(fileName, error);
@ -3393,7 +3421,7 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error)
}
else
{
doc->SetPath(mPath);
doc->SetMPath(mPath);
qCDebug(vMainWindow, "Could not save file %s. %s.", qUtf8Printable(fileName), qUtf8Printable(error));
}
return result;
@ -3407,9 +3435,9 @@ void MainWindow::AutoSavePattern()
{
qCDebug(vMainWindow, "Autosaving pattern.");
if (curFile.isEmpty() == false && this->isWindowModified() == true)
if (qApp->GetPPath().isEmpty() == false && this->isWindowModified() == true)
{
QString autofile = curFile + autosavePrefix;
QString autofile = qApp->GetPPath() + autosavePrefix;
QString error;
SavePattern(autofile, error);
}
@ -3424,10 +3452,11 @@ void MainWindow::AutoSavePattern()
void MainWindow::setCurrentFile(const QString &fileName)
{
qCDebug(vMainWindow, "Set current name to \"%s\"", qUtf8Printable(fileName));
curFile = fileName;
qApp->SetPPath(fileName);
emit doc->UpdatePatternLabel();
qApp->getUndoStack()->setClean();
if (not curFile.isEmpty() && VApplication::IsGUIMode())
if (not qApp->GetPPath().isEmpty() && VApplication::IsGUIMode())
{
qCDebug(vMainWindow, "Updating recent file list.");
VSettings *settings = qApp->ValentinaSettings();
@ -3512,7 +3541,7 @@ bool MainWindow::MaybeSave()
messageBox->setEscapeButton(QMessageBox::Cancel);
messageBox->setButtonText(QMessageBox::Yes,
curFile.isEmpty() || patternReadOnly ? tr("Save...") : tr("Save"));
qApp->GetPPath().isEmpty() || patternReadOnly ? tr("Save...") : tr("Save"));
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
messageBox->setWindowModality(Qt::ApplicationModal);
@ -3849,7 +3878,7 @@ void MainWindow::InitDocksContain()
//---------------------------------------------------------------------------------------------------------------------
bool MainWindow::OpenNewValentina(const QString &fileName) const
{
if (this->isWindowModified() || curFile.isEmpty() == false)
if (this->isWindowModified() || qApp->GetPPath().isEmpty() == false)
{
VApplication::NewValentina(fileName);
return true;
@ -3972,7 +4001,7 @@ void MainWindow::CreateActions()
connect(ui->actionPattern_properties, &QAction::triggered, this, [this]()
{
DialogPatternProperties proper(curFile, doc, pattern, this);
DialogPatternProperties proper(doc, pattern, this);
connect(&proper, &DialogPatternProperties::UpdateGradation, this, [this]()
{
UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit()));
@ -4042,6 +4071,12 @@ void MainWindow::CreateActions()
connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements);
connect(ui->actionUnloadMeasurements, &QAction::triggered, this, &MainWindow::UnloadMeasurements);
connect(ui->actionLabelTemplateEditor, &QAction::triggered, this, [this]()
{
DialogEditLabel editor(doc);
editor.exec();
});
}
//---------------------------------------------------------------------------------------------------------------------
@ -4191,7 +4226,7 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
doc->setXMLContent(converter.Convert());
if (!customMeasureFile.isEmpty())
{
doc->SetPath(RelativeMPath(fileName, customMeasureFile));
doc->SetMPath(RelativeMPath(fileName, customMeasureFile));
}
qApp->setPatternUnit(doc->MUnit());
const QString path = AbsoluteMPath(fileName, doc->MPath());
@ -4663,9 +4698,9 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
CheckRequiredMeasurements(m.data());
doc->SetPath(RelativeMPath(patternPath, mPath));
PatternChangesWereSaved(false);
qApp->setPatternType(patternType);
doc->SetMPath(RelativeMPath(patternPath, mPath));
PatternChangesWereSaved(false);
return mPath;
}
}
@ -4813,7 +4848,7 @@ bool MainWindow::SetSize(const QString &text)
{
if (not VApplication::IsGUIMode())
{
if (this->isWindowModified() || not curFile.isEmpty())
if (this->isWindowModified() || not qApp->GetPPath().isEmpty())
{
if (qApp->patternType() == MeasurementsType::Multisize)
{
@ -4856,7 +4891,7 @@ bool MainWindow::SetHeight(const QString &text)
{
if (not VApplication::IsGUIMode())
{
if (this->isWindowModified() || not curFile.isEmpty())
if (this->isWindowModified() || not qApp->GetPPath().isEmpty())
{
if (qApp->patternType() == MeasurementsType::Multisize)
{
@ -4969,9 +5004,9 @@ void MainWindow::ProcessCMD()
QString MainWindow::GetPatternFileName()
{
QString shownName = tr("untitled.val");
if(not curFile.isEmpty())
if(not qApp->GetPPath().isEmpty())
{
shownName = StrippedName(curFile);
shownName = StrippedName(qApp->GetPPath());
}
shownName += QLatin1String("[*]");
return shownName;
@ -4987,7 +5022,7 @@ QString MainWindow::GetMeasurementFileName()
else
{
QString shownName(" [");
shownName += StrippedName(AbsoluteMPath(curFile, doc->MPath()));
shownName += StrippedName(AbsoluteMPath(qApp->GetPPath(), doc->MPath()));
if(mChanges)
{
@ -5003,12 +5038,12 @@ QString MainWindow::GetMeasurementFileName()
void MainWindow::UpdateWindowTitle()
{
bool isFileWritable = true;
if (not curFile.isEmpty())
if (not qApp->GetPPath().isEmpty())
{
#ifdef Q_OS_WIN32
qt_ntfs_permission_lookup++; // turn checking on
#endif /*Q_OS_WIN32*/
isFileWritable = QFileInfo(curFile).isWritable();
isFileWritable = QFileInfo(qApp->GetPPath()).isWritable();
#ifdef Q_OS_WIN32
qt_ntfs_permission_lookup--; // turn it off again
#endif /*Q_OS_WIN32*/
@ -5023,7 +5058,7 @@ void MainWindow::UpdateWindowTitle()
setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + QLatin1String(" (") + tr("read only") +
QLatin1String(")"));
}
setWindowFilePath(curFile);
setWindowFilePath(qApp->GetPPath());
#if defined(Q_OS_MAC)
static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() +

View File

@ -55,8 +55,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>126</width>
<height>351</height>
<width>127</width>
<height>358</height>
</rect>
</property>
<property name="sizePolicy">
@ -402,7 +402,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>108</height>
<height>110</height>
</rect>
</property>
<property name="sizePolicy">
@ -511,7 +511,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>243</height>
<height>248</height>
</rect>
</property>
<property name="sizePolicy">
@ -773,7 +773,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>243</height>
<height>248</height>
</rect>
</property>
<property name="sizePolicy">
@ -1038,7 +1038,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>102</height>
<height>104</height>
</rect>
</property>
<property name="sizePolicy">
@ -1121,7 +1121,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>326</height>
<height>328</height>
</rect>
</property>
<attribute name="icon">
@ -1325,7 +1325,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>192</height>
<height>196</height>
</rect>
</property>
<property name="sizePolicy">
@ -1535,7 +1535,7 @@
<x>0</x>
<y>0</y>
<width>140</width>
<height>326</height>
<height>328</height>
</rect>
</property>
<attribute name="icon">
@ -1635,7 +1635,7 @@
<x>0</x>
<y>0</y>
<width>1100</width>
<height>19</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -1664,6 +1664,8 @@
<addaction name="actionPreferences"/>
<addaction name="actionPattern_properties"/>
<addaction name="separator"/>
<addaction name="actionLabelTemplateEditor"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuHelp">
@ -2668,6 +2670,11 @@
<enum>QAction::NoRole</enum>
</property>
</action>
<action name="actionLabelTemplateEditor">
<property name="text">
<string>Label template editor</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View File

@ -101,7 +101,6 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
redoAction(nullptr),
actionDockWidgetToolOptions(nullptr),
actionDockWidgetGroups(nullptr),
curFile(),
isNoScaling(false),
isLayoutStale(true),
ignorePrinterFields(false),
@ -1512,7 +1511,7 @@ void MainWindowsNoGUI::ExportScene(const DialogSaveLayout &dialog, const QList<Q
QString MainWindowsNoGUI::FileName() const
{
QString fileName;
curFile.isEmpty() ? fileName = tr("unnamed") : fileName = curFile;
qApp->GetPPath().isEmpty() ? fileName = tr("unnamed") : fileName = qApp->GetPPath();
return QFileInfo(fileName).baseName();
}

View File

@ -82,9 +82,6 @@ protected:
QAction *actionDockWidgetToolOptions;
QAction *actionDockWidgetGroups;
/** @brief fileName name current pattern file. */
QString curFile;
bool isNoScaling;
bool isLayoutStale;
bool ignorePrinterFields;

View File

@ -167,6 +167,10 @@ unix{
templates.path = /usr/share/$${TARGET}/tables/templates/
templates.files = $$INSTALL_STANDARD_TEMPLATES
# Path to label templates after installation
label.path = /usr/share/$${TARGET}/labels/
label.files = $$INSTALL_LABEL_TEMPLATES
INSTALLS += \
target \
tape \
@ -174,7 +178,8 @@ unix{
pixmaps \
translations \
multisize \
templates
templates \
label
}
macx{
# Some macx stuff
@ -234,6 +239,10 @@ unix{
templates.path = $$RESOURCES_DIR/tables/templates/
templates.files = $$INSTALL_STANDARD_TEMPLATES
# Path to label templates after installation
label.path = /usr/share/$${TARGET}/labels/
label.files = $$INSTALL_LABEL_TEMPLATES
icns_resources.path = $$RESOURCES_DIR/
icns_resources.files += $$PWD/../../../dist/macx/i-measurements.icns
icns_resources.files += $$PWD/../../../dist/macx/s-measurements.icns
@ -246,6 +255,7 @@ unix{
QMAKE_BUNDLE_DATA += \
templates \
multisize \
label \
libraries \
tape \
xpdf \
@ -316,6 +326,10 @@ win32:*g++* {
package_templates.files += $$INSTALL_STANDARD_TEMPLATES
INSTALLS += package_templates
package_labels.path = $${OUT_PWD}/../../../package/valentina/labels
package_labels.files += $$INSTALL_LABEL_TEMPLATES
INSTALLS += package_labels
package_translations.path = $${OUT_PWD}/../../../package/valentina/translations
package_translations.files += \
$$INSTALL_TRANSLATIONS \ # Valentina

View File

@ -106,7 +106,6 @@ void VPattern::CreateEmptyFile()
unit.appendChild(newNodeText);
patternElement.appendChild(unit);
patternElement.appendChild(createElement(TagAuthor));
patternElement.appendChild(createElement(TagDescription));
patternElement.appendChild(createElement(TagNotes));
@ -149,10 +148,10 @@ void VPattern::Parse(const Document &parse)
SCASSERT(sceneDraw != nullptr)
SCASSERT(sceneDetail != nullptr)
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
QStringList tags = QStringList() << TagDraw << TagIncrements << TagDescription << TagNotes
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
<< TagSize << TagShowDate << TagShowMeasurements;
<< TagPatternLabel;
PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false)
@ -188,50 +187,41 @@ void VPattern::Parse(const Document &parse)
qCDebug(vXML, "Tag increments.");
ParseIncrementsElement(domElement);
break;
case 2: // TagAuthor
qCDebug(vXML, "Tag author.");
break;
case 3: // TagDescription
case 2: // TagDescription
qCDebug(vXML, "Tag description.");
break;
case 4: // TagNotes
case 3: // TagNotes
qCDebug(vXML, "Tag notes.");
break;
case 5: // TagMeasurements
case 4: // TagMeasurements
qCDebug(vXML, "Tag measurements.");
break;
case 6: // TagVersion
case 5: // TagVersion
qCDebug(vXML, "Tag version.");
break;
case 7: // TagGradation
case 6: // TagGradation
qCDebug(vXML, "Tag gradation.");
break;
case 8: // TagImage
case 7: // TagImage
qCDebug(vXML, "Tag image.");
break;
case 9: // TagUnit
case 8: // TagUnit
qCDebug(vXML, "Tag unit.");
break;
case 10: // TagPatternName
case 9: // TagPatternName
qCDebug(vXML, "Pattern name.");
break;
case 11: // TagPatternNumber
case 10: // TagPatternNumber
qCDebug(vXML, "Pattern number.");
break;
case 12: // TagCompanyName
case 11: // TagCompanyName
qCDebug(vXML, "Company name.");
break;
case 13: // TagCustomerName
case 12: // TagCustomerName
qCDebug(vXML, "Customer name.");
break;
case 14: // TagSize
qCDebug(vXML, "Size");
break;
case 15:
qCDebug(vXML, "Show creation date");
break;
case 16:
qCDebug(vXML, "Show measurements");
case 13: // TagPatternLabel
qCDebug(vXML, "Pattern label.");
break;
default:
qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
@ -903,16 +893,14 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
{
VPieceLabelData &ppData = detail.GetPatternPieceData();
ppData.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
try
{
QString qsLetter = GetParametrString(domElement, AttrLetter, "");
ppData.SetLetter(qsLetter);
}
catch(const VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
ppData.SetLetter("");
}
ppData.SetLetter(GetParametrEmptyString(domElement, AttrLetter));
ppData.SetAnnotation(GetParametrEmptyString(domElement, AttrAnnotation));
ppData.SetOrientation(GetParametrEmptyString(domElement, AttrOrientation));
ppData.SetRotation(GetParametrEmptyString(domElement, AttrRotation));
ppData.SetTilt(GetParametrEmptyString(domElement, AttrTilt));
ppData.SetFoldPosition(GetParametrEmptyString(domElement, AttrFoldPosition));
ppData.SetQuantity(static_cast<int>(GetParametrUInt(domElement, AttrQuantity, "1")));
ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr));
ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
ppData.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1"));
@ -921,21 +909,7 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
QDomNodeList nodeListMCP = domElement.childNodes();
for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP)
{
MaterialCutPlacement mcp;
QDomElement domMCP = nodeListMCP.at(iMCP).toElement();
mcp.m_eMaterial = MaterialType(GetParametrUInt(domMCP, AttrMaterial, 0));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, "");
}
mcp.m_iCutNumber = static_cast<int>(GetParametrUInt(domMCP, AttrCutNumber, 0));
mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0));
ppData.Append(mcp);
}
ppData.SetLabelTemplate(GetLabelTemplate(domElement));
}
//---------------------------------------------------------------------------------------------------------------------
@ -3393,21 +3367,6 @@ void VPattern::ParseIncrementsElement(const QDomNode &node)
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GetAuthor() const
{
return UniqueTagText(TagAuthor, qApp->ValentinaSettings()->GetUser());
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetAuthor(const QString &text)
{
CheckTagExists(TagAuthor);
setTagText(TagAuthor, text);
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::AddEmptyIncrement(const QString &name)
{

View File

@ -66,9 +66,6 @@ public:
QRectF ActiveDrawBoundingRect() const;
QString GetAuthor() const;
void SetAuthor(const QString &text);
void AddEmptyIncrement(const QString &name);
void AddEmptyIncrementAfter(const QString &after, const QString &name);
void RemoveIncrement(const QString &name);

View File

@ -213,4 +213,18 @@ extern const QString currentSeamAllowance;
extern const QStringList builInVariables;
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
struct VLabelTemplateLine
{
QString line;
bool bold;
bool italic;
int alignment;
int fontSizeIncrement;
};
QT_WARNING_POP
#endif // IFCDEF_H

View File

@ -34,6 +34,7 @@
<file>schema/pattern/v0.4.8.xsd</file>
<file>schema/pattern/v0.5.0.xsd</file>
<file>schema/pattern/v0.5.1.xsd</file>
<file>schema/pattern/v0.6.0.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>
@ -45,5 +46,6 @@
<file>schema/individual_measurements/v0.3.1.xsd</file>
<file>schema/individual_measurements/v0.3.2.xsd</file>
<file>schema/individual_measurements/v0.3.3.xsd</file>
<file>schema/label_template/v1.0.0.xsd</file>
</qresource>
</RCC>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="template">
<xs:complexType>
<xs:sequence>
<xs:element name="version" type="formatVersion"/>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="text" type="xs:string" use="required"/>
<xs:attribute name="bold" type="xs:boolean"/>
<xs:attribute name="italic" type="xs:boolean"/>
<xs:attribute name="alignment" type="alignmentType"/>
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="alignmentType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--default (no aligns)-->
<xs:enumeration value="1"/><!--aligns with the left edge-->
<xs:enumeration value="2"/><!--aligns with the right edge-->
<xs:enumeration value="4"/><!--Centers horizontally in the available space-->
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -0,0 +1,937 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document-->
<xs:element name="pattern">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="version" type="formatVersion"/>
<xs:element name="unit" type="units"/>
<xs:element name="image" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="extension" type="imageExtension"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="heights">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"/>
<xs:attribute name="h50" type="xs:boolean"/>
<xs:attribute name="h56" type="xs:boolean"/>
<xs:attribute name="h62" type="xs:boolean"/>
<xs:attribute name="h68" type="xs:boolean"/>
<xs:attribute name="h74" type="xs:boolean"/>
<xs:attribute name="h80" type="xs:boolean"/>
<xs:attribute name="h86" type="xs:boolean"/>
<xs:attribute name="h92" type="xs:boolean"/>
<xs:attribute name="h98" type="xs:boolean"/>
<xs:attribute name="h104" type="xs:boolean"/>
<xs:attribute name="h110" type="xs:boolean"/>
<xs:attribute name="h116" type="xs:boolean"/>
<xs:attribute name="h122" type="xs:boolean"/>
<xs:attribute name="h128" type="xs:boolean"/>
<xs:attribute name="h134" type="xs:boolean"/>
<xs:attribute name="h140" type="xs:boolean"/>
<xs:attribute name="h146" type="xs:boolean"/>
<xs:attribute name="h152" type="xs:boolean"/>
<xs:attribute name="h158" type="xs:boolean"/>
<xs:attribute name="h164" type="xs:boolean"/>
<xs:attribute name="h170" type="xs:boolean"/>
<xs:attribute name="h176" type="xs:boolean"/>
<xs:attribute name="h182" type="xs:boolean"/>
<xs:attribute name="h188" type="xs:boolean"/>
<xs:attribute name="h194" type="xs:boolean"/>
<xs:attribute name="h200" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"/>
<xs:attribute name="s22" type="xs:boolean"/>
<xs:attribute name="s24" type="xs:boolean"/>
<xs:attribute name="s26" type="xs:boolean"/>
<xs:attribute name="s28" type="xs:boolean"/>
<xs:attribute name="s30" type="xs:boolean"/>
<xs:attribute name="s32" type="xs:boolean"/>
<xs:attribute name="s34" type="xs:boolean"/>
<xs:attribute name="s36" type="xs:boolean"/>
<xs:attribute name="s38" type="xs:boolean"/>
<xs:attribute name="s40" type="xs:boolean"/>
<xs:attribute name="s42" type="xs:boolean"/>
<xs:attribute name="s44" type="xs:boolean"/>
<xs:attribute name="s46" type="xs:boolean"/>
<xs:attribute name="s48" type="xs:boolean"/>
<xs:attribute name="s50" type="xs:boolean"/>
<xs:attribute name="s52" type="xs:boolean"/>
<xs:attribute name="s54" type="xs:boolean"/>
<xs:attribute name="s56" type="xs:boolean"/>
<xs:attribute name="s58" type="xs:boolean"/>
<xs:attribute name="s60" type="xs:boolean"/>
<xs:attribute name="s62" type="xs:boolean"/>
<xs:attribute name="s64" type="xs:boolean"/>
<xs:attribute name="s66" type="xs:boolean"/>
<xs:attribute name="s68" type="xs:boolean"/>
<xs:attribute name="s70" type="xs:boolean"/>
<xs:attribute name="s72" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"/>
<xs:attribute name="defHeight" type="baseHeight"/>
<xs:attribute name="defSize" type="baseSize"/>
</xs:complexType>
</xs:element>
<xs:element name="patternName" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="patternLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="text" type="xs:string" use="required"/>
<xs:attribute name="bold" type="xs:boolean"/>
<xs:attribute name="italic" type="xs:boolean"/>
<xs:attribute name="alignment" type="alignmentType"/>
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="dateFormat" type="xs:string"/>
<xs:attribute name="timeFormat" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="measurements" type="xs:string"/>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="description" type="xs:string" use="required"/>
<xs:attribute name="name" type="shortName" use="required"/>
<xs:attribute name="formula" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="incrementName">
<xs:selector xpath="increment"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="x" type="xs:double"/>
<xs:attribute name="y" type="xs:double"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="name" type="shortName"/>
<xs:attribute name="firstPoint" type="xs:unsignedInt"/>
<xs:attribute name="secondPoint" type="xs:unsignedInt"/>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"/>
<xs:attribute name="basePoint" type="xs:unsignedInt"/>
<xs:attribute name="pShoulder" type="xs:unsignedInt"/>
<xs:attribute name="p1Line" type="xs:unsignedInt"/>
<xs:attribute name="p2Line" type="xs:unsignedInt"/>
<xs:attribute name="length" type="xs:string"/>
<xs:attribute name="angle" type="xs:string"/>
<xs:attribute name="typeLine" type="linePenStyle"/>
<xs:attribute name="splinePath" type="xs:unsignedInt"/>
<xs:attribute name="spline" type="xs:unsignedInt"/>
<xs:attribute name="p1Line1" type="xs:unsignedInt"/>
<xs:attribute name="p1Line2" type="xs:unsignedInt"/>
<xs:attribute name="p2Line1" type="xs:unsignedInt"/>
<xs:attribute name="p2Line2" type="xs:unsignedInt"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="radius" type="xs:string"/>
<xs:attribute name="axisP1" type="xs:unsignedInt"/>
<xs:attribute name="axisP2" type="xs:unsignedInt"/>
<xs:attribute name="arc" type="xs:unsignedInt"/>
<xs:attribute name="elArc" type="xs:unsignedInt"/>
<xs:attribute name="curve" type="xs:unsignedInt"/>
<xs:attribute name="curve1" type="xs:unsignedInt"/>
<xs:attribute name="curve2" type="xs:unsignedInt"/>
<xs:attribute name="lineColor" type="colors"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="firstArc" type="xs:unsignedInt"/>
<xs:attribute name="secondArc" type="xs:unsignedInt"/>
<xs:attribute name="crossPoint" type="crossType"/>
<xs:attribute name="vCrossPoint" type="crossType"/>
<xs:attribute name="hCrossPoint" type="crossType"/>
<xs:attribute name="c1Center" type="xs:unsignedInt"/>
<xs:attribute name="c2Center" type="xs:unsignedInt"/>
<xs:attribute name="c1Radius" type="xs:string"/>
<xs:attribute name="c2Radius" type="xs:string"/>
<xs:attribute name="cRadius" type="xs:string"/>
<xs:attribute name="tangent" type="xs:unsignedInt"/>
<xs:attribute name="cCenter" type="xs:unsignedInt"/>
<xs:attribute name="name1" type="shortName"/>
<xs:attribute name="mx1" type="xs:double"/>
<xs:attribute name="my1" type="xs:double"/>
<xs:attribute name="name2" type="shortName"/>
<xs:attribute name="mx2" type="xs:double"/>
<xs:attribute name="my2" type="xs:double"/>
<xs:attribute name="point1" type="xs:unsignedInt"/>
<xs:attribute name="point2" type="xs:unsignedInt"/>
<xs:attribute name="dartP1" type="xs:unsignedInt"/>
<xs:attribute name="dartP2" type="xs:unsignedInt"/>
<xs:attribute name="dartP3" type="xs:unsignedInt"/>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"/>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="firstPoint" type="xs:unsignedInt"/>
<xs:attribute name="secondPoint" type="xs:unsignedInt"/>
<xs:attribute name="typeLine" type="linePenStyle"/>
<xs:attribute name="lineColor" type="colors"/>
</xs:complexType>
</xs:element>
<xs:element name="operation" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="source" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="destination" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="angle" type="xs:string"/>
<xs:attribute name="length" type="xs:string"/>
<xs:attribute name="suffix" type="xs:string"/>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="p1Line" type="xs:unsignedInt"/>
<xs:attribute name="p2Line" type="xs:unsignedInt"/>
<xs:attribute name="axisType" type="axisType"/>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="radius" type="xs:string"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="penStyle" type="curvePenStyle"/>
<xs:attribute name="length" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="elArc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="rotationAngle" type="xs:string"/>
<xs:attribute name="radius1" type="xs:string"/>
<xs:attribute name="radius2" type="xs:string"/>
<xs:attribute name="center" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="penStyle" type="curvePenStyle"/>
<xs:attribute name="length" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="kAsm2" type="xs:string"/>
<xs:attribute name="pSpline" type="xs:unsignedInt"/>
<xs:attribute name="angle" type="xs:string"/>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="length1" type="xs:string"/>
<xs:attribute name="length2" type="xs:string"/>
<xs:attribute name="kAsm1" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="kCurve" type="xs:double"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="kAsm1" type="xs:double"/>
<xs:attribute name="kAsm2" type="xs:double"/>
<xs:attribute name="angle1" type="xs:string"/>
<xs:attribute name="angle2" type="xs:string"/>
<xs:attribute name="length1" type="xs:string"/>
<xs:attribute name="length2" type="xs:string"/>
<xs:attribute name="point1" type="xs:unsignedInt"/>
<xs:attribute name="point2" type="xs:unsignedInt"/>
<xs:attribute name="point3" type="xs:unsignedInt"/>
<xs:attribute name="point4" type="xs:unsignedInt"/>
<xs:attribute name="color" type="colors"/>
<xs:attribute name="penStyle" type="curvePenStyle"/>
<xs:attribute name="duplicate" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="elArc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="path" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="excluded" type="xs:boolean"/>
<xs:attribute name="before" type="xs:double"/>
<xs:attribute name="after" type="xs:double"/>
<xs:attribute name="angle" type="nodeAngle"/>
<xs:attribute name="passmark" type="xs:boolean"/>
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="type" type="piecePathType"/>
<xs:attribute name="idTool" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="typeLine" type="curvePenStyle"/>
<xs:attribute name="cut" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="det" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="excluded" type="xs:boolean"/>
<xs:attribute name="before" type="xs:string"/>
<xs:attribute name="after" type="xs:string"/>
<xs:attribute name="angle" type="nodeAngle"/>
<xs:attribute name="passmark" type="xs:boolean"/>
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="csa" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="start" type="xs:unsignedInt"/>
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
<xs:attribute name="end" type="xs:unsignedInt"/>
<xs:attribute name="reverse" type="xs:boolean"/>
<xs:attribute name="includeAs" type="piecePathIncludeType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pins" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="children" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="nodes" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="csa" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pins" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="indexD1" type="xs:unsignedInt"/>
<xs:attribute name="indexD2" type="xs:unsignedInt"/>
<xs:attribute name="inUse" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="data" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="text" type="xs:string" use="required"/>
<xs:attribute name="bold" type="xs:boolean"/>
<xs:attribute name="italic" type="xs:boolean"/>
<xs:attribute name="alignment" type="alignmentType"/>
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="letter" type="xs:string"/>
<xs:attribute name="annotation" type="xs:string"/>
<xs:attribute name="orientation" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="tilt" type="xs:string"/>
<xs:attribute name="foldPosition" type="xs:string"/>
<xs:attribute name="visible" type="xs:boolean"/>
<xs:attribute name="onFold" type="xs:boolean"/>
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="height" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
<xs:attribute name="quantity" type="xs:unsignedInt"/>
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="visible" type="xs:boolean"/>
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="height" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="grainline" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="visible" type="xs:boolean"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="length" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="arrows" type="arrowType"/>
<xs:attribute name="centerPin" type="xs:unsignedInt"/>
<xs:attribute name="topPin" type="xs:unsignedInt"/>
<xs:attribute name="bottomPin" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="node" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="excluded" type="xs:boolean"/>
<xs:attribute name="before" type="xs:string"/>
<xs:attribute name="after" type="xs:string"/>
<xs:attribute name="angle" type="nodeAngle"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="passmark" type="xs:boolean"/>
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="csa" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="start" type="xs:unsignedInt"/>
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
<xs:attribute name="end" type="xs:unsignedInt"/>
<xs:attribute name="reverse" type="xs:boolean"/>
<xs:attribute name="includeAs" type="piecePathIncludeType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="iPaths" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="path" type="xs:unsignedInt" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pins" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="record" type="xs:unsignedInt" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="version" type="pieceVersion"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="inLayout" type="xs:boolean"/>
<xs:attribute name="forbidFlipping" type="xs:boolean"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="seamAllowance" type="xs:boolean"/>
<xs:attribute name="seamAllowanceBuiltIn" type="xs:boolean"/>
<xs:attribute name="united" type="xs:boolean"/>
<xs:attribute name="closed" type="xs:unsignedInt"/>
<xs:attribute name="hideMainPath" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="groups" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="object" type="xs:unsignedInt"/>
<xs:attribute name="tool" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="visible" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^\p{Nd}\p{Zs}*/&amp;|!&lt;&gt;^\()\-+.,٫, ٬.=?:;'\&quot;]){1,1}([^\p{Zs}*/&amp;|!&lt;&gt;^\()\-+.,٫, ٬.=?:;\&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="measurementsTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="standard"/>
<xs:enumeration value="individual"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="imageExtension">
<xs:restriction base="xs:string">
<xs:enumeration value="PNG"/>
<xs:enumeration value="JPG"/>
<xs:enumeration value="BMP"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="colors">
<xs:restriction base="xs:string">
<xs:enumeration value="black"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
<xs:enumeration value="darkRed"/>
<xs:enumeration value="darkGreen"/>
<xs:enumeration value="darkBlue"/>
<xs:enumeration value="yellow"/>
<xs:enumeration value="lightsalmon"/>
<xs:enumeration value="goldenrod"/>
<xs:enumeration value="orange"/>
<xs:enumeration value="deeppink"/>
<xs:enumeration value="violet"/>
<xs:enumeration value="darkviolet"/>
<xs:enumeration value="mediumseagreen"/>
<xs:enumeration value="lime"/>
<xs:enumeration value="deepskyblue"/>
<xs:enumeration value="cornflowerblue"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="linePenStyle">
<xs:restriction base="xs:string">
<xs:enumeration value="none"/>
<xs:enumeration value="hair"/>
<xs:enumeration value="dashLine"/>
<xs:enumeration value="dotLine"/>
<xs:enumeration value="dashDotLine"/>
<xs:enumeration value="dashDotDotLine"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="curvePenStyle">
<xs:restriction base="xs:string">
<xs:enumeration value="hair"/>
<xs:enumeration value="dashLine"/>
<xs:enumeration value="dotLine"/>
<xs:enumeration value="dashDotLine"/>
<xs:enumeration value="dashDotDotLine"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseHeight">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="50"/>
<xs:enumeration value="56"/>
<xs:enumeration value="62"/>
<xs:enumeration value="68"/>
<xs:enumeration value="74"/>
<xs:enumeration value="80"/>
<xs:enumeration value="86"/>
<xs:enumeration value="92"/>
<xs:enumeration value="98"/>
<xs:enumeration value="104"/>
<xs:enumeration value="110"/>
<xs:enumeration value="116"/>
<xs:enumeration value="122"/>
<xs:enumeration value="128"/>
<xs:enumeration value="134"/>
<xs:enumeration value="140"/>
<xs:enumeration value="146"/>
<xs:enumeration value="152"/>
<xs:enumeration value="158"/>
<xs:enumeration value="164"/>
<xs:enumeration value="170"/>
<xs:enumeration value="176"/>
<xs:enumeration value="182"/>
<xs:enumeration value="188"/>
<xs:enumeration value="194"/>
<xs:enumeration value="200"/>
<xs:enumeration value="500"/>
<xs:enumeration value="560"/>
<xs:enumeration value="620"/>
<xs:enumeration value="680"/>
<xs:enumeration value="740"/>
<xs:enumeration value="800"/>
<xs:enumeration value="860"/>
<xs:enumeration value="920"/>
<xs:enumeration value="980"/>
<xs:enumeration value="1040"/>
<xs:enumeration value="1100"/>
<xs:enumeration value="1160"/>
<xs:enumeration value="1220"/>
<xs:enumeration value="1280"/>
<xs:enumeration value="1340"/>
<xs:enumeration value="1400"/>
<xs:enumeration value="1460"/>
<xs:enumeration value="1520"/>
<xs:enumeration value="1580"/>
<xs:enumeration value="1640"/>
<xs:enumeration value="1700"/>
<xs:enumeration value="1760"/>
<xs:enumeration value="1820"/>
<xs:enumeration value="1880"/>
<xs:enumeration value="1940"/>
<xs:enumeration value="2000"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseSize">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="22"/>
<xs:enumeration value="24"/>
<xs:enumeration value="26"/>
<xs:enumeration value="28"/>
<xs:enumeration value="30"/>
<xs:enumeration value="32"/>
<xs:enumeration value="34"/>
<xs:enumeration value="36"/>
<xs:enumeration value="38"/>
<xs:enumeration value="40"/>
<xs:enumeration value="42"/>
<xs:enumeration value="44"/>
<xs:enumeration value="46"/>
<xs:enumeration value="48"/>
<xs:enumeration value="50"/>
<xs:enumeration value="52"/>
<xs:enumeration value="54"/>
<xs:enumeration value="56"/>
<xs:enumeration value="58"/>
<xs:enumeration value="60"/>
<xs:enumeration value="62"/>
<xs:enumeration value="64"/>
<xs:enumeration value="66"/>
<xs:enumeration value="68"/>
<xs:enumeration value="70"/>
<xs:enumeration value="72"/>
<xs:enumeration value="220"/>
<xs:enumeration value="240"/>
<xs:enumeration value="260"/>
<xs:enumeration value="280"/>
<xs:enumeration value="300"/>
<xs:enumeration value="320"/>
<xs:enumeration value="340"/>
<xs:enumeration value="360"/>
<xs:enumeration value="380"/>
<xs:enumeration value="400"/>
<xs:enumeration value="420"/>
<xs:enumeration value="440"/>
<xs:enumeration value="460"/>
<xs:enumeration value="480"/>
<xs:enumeration value="500"/>
<xs:enumeration value="520"/>
<xs:enumeration value="540"/>
<xs:enumeration value="560"/>
<xs:enumeration value="580"/>
<xs:enumeration value="600"/>
<xs:enumeration value="620"/>
<xs:enumeration value="640"/>
<xs:enumeration value="660"/>
<xs:enumeration value="680"/>
<xs:enumeration value="700"/>
<xs:enumeration value="720"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="crossType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="axisType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="arrowType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--Both-->
<xs:enumeration value="1"/>
<!--Front-->
<xs:enumeration value="2"/>
<!--Rear-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="pieceVersion">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<!--Old version-->
<xs:enumeration value="2"/>
<!--New version-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="nodeAngle">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--by length-->
<xs:enumeration value="1"/>
<!--by points intersections-->
<xs:enumeration value="2"/>
<!--by second edge symmetry-->
<xs:enumeration value="3"/>
<!--by first edge symmetry-->
<xs:enumeration value="4"/>
<!--by first edge right angle-->
<xs:enumeration value="5"/>
<!--by first edge right angle-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="piecePathType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<!--custom seam allowance-->
<xs:enumeration value="2"/>
<!--internal path-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="piecePathIncludeType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--as main path-->
<xs:enumeration value="1"/>
<!--as custom seam allowance-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="passmarkLineType">
<xs:restriction base="xs:string">
<xs:enumeration value="one"/>
<xs:enumeration value="two"/>
<xs:enumeration value="three"/>
<xs:enumeration value="tMark"/>
<xs:enumeration value="vMark"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="passmarkAngleType">
<xs:restriction base="xs:string">
<xs:enumeration value="straightforward"/>
<xs:enumeration value="bisector"/>
<xs:enumeration value="intersection"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="alignmentType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--default (no aligns)-->
<xs:enumeration value="1"/><!--aligns with the left edge-->
<xs:enumeration value="2"/><!--aligns with the right edge-->
<xs:enumeration value="4"/><!--Centers horizontally in the available space-->
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -51,6 +51,7 @@
#include "vpatternconverter.h"
#include "vdomdocument.h"
#include "vtoolrecord.h"
#include "../vmisc/vabstractapplication.h"
class QDomElement;
@ -59,7 +60,6 @@ const QString VAbstractPattern::TagCalculation = QStringLiteral("calculatio
const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
const QString VAbstractPattern::TagDetails = QStringLiteral("details");
const QString VAbstractPattern::TagDetail = QStringLiteral("detail");
const QString VAbstractPattern::TagAuthor = QStringLiteral("author");
const QString VAbstractPattern::TagDescription = QStringLiteral("description");
const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
const QString VAbstractPattern::TagImage = QStringLiteral("image");
@ -82,14 +82,11 @@ const QString VAbstractPattern::TagHeights = QStringLiteral("heights");
const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
const QString VAbstractPattern::TagData = QStringLiteral("data");
const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInfo");
const QString VAbstractPattern::TagMCP = QStringLiteral("mcp");
const QString VAbstractPattern::TagPatternName = QStringLiteral("patternName");
const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber");
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagSize = QStringLiteral("size");
const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate");
const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements");
const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline");
const QString VAbstractPattern::TagPath = QStringLiteral("path");
const QString VAbstractPattern::TagNodes = QStringLiteral("nodes");
@ -101,10 +98,15 @@ const QString VAbstractPattern::AttrObject = QStringLiteral("object")
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrMaterial = QStringLiteral("material");
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
const QString VAbstractPattern::AttrAnnotation = QStringLiteral("annotation");
const QString VAbstractPattern::AttrOrientation = QStringLiteral("orientation");
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrTilt = QStringLiteral("tilt");
const QString VAbstractPattern::AttrFoldPosition = QStringLiteral("foldPosition");
const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity");
const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold");
const QString VAbstractPattern::AttrDateFormat = QStringLiteral("dateFormat");
const QString VAbstractPattern::AttrTimeFormat = QStringLiteral("timeFormat");
const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows");
const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse");
const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded");
@ -119,7 +121,6 @@ const QString VAbstractPattern::AttrPath = QStringLiteral("path");
const QString VAbstractPattern::AttrEnd = QStringLiteral("end");
const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs");
const QString VAbstractPattern::AttrWidth = QStringLiteral("width");
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
@ -193,6 +194,8 @@ const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath");
QHash<quint32, VDataTool*> VAbstractPattern::tools = QHash<quint32, VDataTool*>();
QVector<VLabelTemplateLine> VAbstractPattern::patternLabelLines = QVector<VLabelTemplateLine>();
bool VAbstractPattern::patternLabelWasChanged = false;
namespace
{
@ -790,11 +793,12 @@ QString VAbstractPattern::MPath() const
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPath(const QString &path)
void VAbstractPattern::SetMPath(const QString &path)
{
if (setTagText(TagMeasurements, path))
{
emit patternChanged(false);
emit UpdatePatternLabel();
}
else
{
@ -1330,48 +1334,94 @@ void VAbstractPattern::SetCustomerName(const QString& qsName)
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetPatternSize() const
QString VAbstractPattern::GetLabelDateFormat() const
{
return UniqueTagText(TagSize);
QString globalLabelDateFormat = qApp->Settings()->GetLabelDateFormat();
const QDomNodeList list = elementsByTagName(TagPatternLabel);
if (list.isEmpty())
{
return globalLabelDateFormat;
}
QDomElement tag = list.at(0).toElement();
return GetParametrString(tag, AttrDateFormat, globalLabelDateFormat);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPatternSize(const QString& qsSize)
void VAbstractPattern::SetLabelDateFormat(const QString &format)
{
CheckTagExists(TagSize);
setTagText(TagSize, qsSize);
QDomElement tag = CheckTagExists(TagPatternLabel);
SetAttribute(tag, AttrDateFormat, format);
patternLabelWasChanged = true;
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsDateVisible() const
QString VAbstractPattern::GetLabelTimeFormat() const
{
return UniqueTagText(TagShowDate) != falseStr;
QString globalLabelTimeFormat = qApp->Settings()->GetLabelTimeFormat();
const QDomNodeList list = elementsByTagName(TagPatternLabel);
if (list.isEmpty())
{
return globalLabelTimeFormat;
}
QDomElement tag = list.at(0).toElement();
return GetParametrString(tag, AttrTimeFormat, globalLabelTimeFormat);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetDateVisible(bool bVisible)
void VAbstractPattern::SetLabelTimeFormat(const QString &format)
{
CheckTagExists(TagShowDate);
setTagText(TagShowDate, bVisible == true? trueStr : falseStr);
QDomElement tag = CheckTagExists(TagPatternLabel);
SetAttribute(tag, AttrTimeFormat, format);
patternLabelWasChanged = true;
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsMeasurementsVisible() const
void VAbstractPattern::SetPatternLabelTemplate(const QVector<VLabelTemplateLine> &lines)
{
return UniqueTagText(TagShowMeasurements) == trueStr;
QDomElement tag = CheckTagExists(TagPatternLabel);
RemoveAllChildren(tag);
SetLabelTemplate(tag, lines);
patternLabelLines = lines;
patternLabelWasChanged = true;
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetMesurementsVisible(bool bVisible)
QVector<VLabelTemplateLine> VAbstractPattern::GetPatternLabelTemplate() const
{
CheckTagExists(TagShowMeasurements);
setTagText(TagShowMeasurements, bVisible == true? trueStr : falseStr);
modified = true;
emit patternChanged(false);
if (patternLabelLines.isEmpty())
{
const QDomNodeList list = elementsByTagName(TagPatternLabel);
if (list.isEmpty())
{
return QVector<VLabelTemplateLine>();
}
patternLabelLines = GetLabelTemplate(list.at(0).toElement());
}
return patternLabelLines;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPatternWasChanged(bool changed)
{
patternLabelWasChanged = changed;
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::GetPatternWasChanged() const
{
return patternLabelWasChanged;
}
//---------------------------------------------------------------------------------------------------------------------
@ -1514,24 +1564,21 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
QDomElement element;
if (list.isEmpty())
{
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
const QStringList tags = QStringList() << TagUnit << TagImage << TagDescription << TagNotes
<< TagGradation << TagPatternName << TagPatternNum << TagCompanyName
<< TagCustomerName << TagSize << TagShowDate << TagShowMeasurements;
<< TagCustomerName << TagPatternLabel;
switch (tags.indexOf(tag))
{
case 1: //TagImage
element = createElement(TagImage);
break;
case 2: //TagAuthor
element = createElement(TagAuthor);
break;
case 3: //TagDescription
case 2: //TagDescription
element = createElement(TagDescription);
break;
case 4: //TagNotes
case 3: //TagNotes
element = createElement(TagNotes);
break;
case 5: //TagGradation
case 4: //TagGradation
{
element = createElement(TagGradation);
@ -1544,26 +1591,20 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element.appendChild(sizes);
break;
}
case 6: // TagPatternName
case 5: // TagPatternName
element = createElement(TagPatternName);
break;
case 7: // TagPatternNum
case 6: // TagPatternNum
element = createElement(TagPatternNum);
break;
case 8: // TagCompanyName
case 7: // TagCompanyName
element = createElement(TagCompanyName);
break;
case 9: // TagCustomerName
case 8: // TagCustomerName
element = createElement(TagCustomerName);
break;
case 10: // TagSize
element = createElement(TagSize);
break;
case 11: // TagShowDate
element = createElement(TagShowDate);
break;
case 12: // TagShowMeasurements
element = createElement(TagShowMeasurements);
case 9: // TagPatternLabel
element = createElement(TagPatternLabel);
break;
case 0: //TagUnit (Mandatory tag)
default:

View File

@ -121,7 +121,7 @@ public:
QVector<VToolRecord> getLocalHistory() const;
QString MPath() const;
void SetPath(const QString &path);
void SetMPath(const QString &path);
quint32 SiblingNodeId(const quint32 &nodeId) const;
@ -141,18 +141,27 @@ public:
QString GetPatternName() const;
void SetPatternName(const QString& qsName);
QString GetCompanyName() const;
void SetCompanyName(const QString& qsName);
QString GetPatternNumber() const;
void SetPatternNumber(const QString &qsNum);
QString GetCustomerName() const;
void SetCustomerName(const QString& qsName);
QString GetPatternSize() const;
void SetPatternSize(const QString &qsSize);
bool IsDateVisible() const;
void SetDateVisible(bool bVisible);
bool IsMeasurementsVisible() const;
void SetMesurementsVisible(bool bVisible);
QString GetLabelDateFormat() const;
void SetLabelDateFormat(const QString &format);
QString GetLabelTimeFormat() const;
void SetLabelTimeFormat(const QString &format);
void SetPatternLabelTemplate(const QVector<VLabelTemplateLine> &lines);
QVector<VLabelTemplateLine> GetPatternLabelTemplate() const;
void SetPatternWasChanged(bool changed);
bool GetPatternWasChanged() const;
QString GetImage() const;
QString GetImageExtension() const;
@ -181,7 +190,6 @@ public:
static const QString TagModeling;
static const QString TagDetails;
static const QString TagDetail;
static const QString TagAuthor;
static const QString TagDescription;
static const QString TagImage;
static const QString TagNotes;
@ -204,14 +212,11 @@ public:
static const QString TagSizes;
static const QString TagData;
static const QString TagPatternInfo;
static const QString TagMCP;
static const QString TagPatternName;
static const QString TagPatternNum;
static const QString TagCompanyName;
static const QString TagCustomerName;
static const QString TagSize;
static const QString TagShowDate;
static const QString TagShowMeasurements;
static const QString TagPatternLabel;
static const QString TagGrainline;
static const QString TagPath;
static const QString TagNodes;
@ -223,10 +228,15 @@ public:
static const QString AttrTool;
static const QString AttrType;
static const QString AttrLetter;
static const QString AttrMaterial;
static const QString AttrUserDefined;
static const QString AttrCutNumber;
static const QString AttrPlacement;
static const QString AttrAnnotation;
static const QString AttrOrientation;
static const QString AttrRotation;
static const QString AttrTilt;
static const QString AttrFoldPosition;
static const QString AttrQuantity;
static const QString AttrOnFold;
static const QString AttrDateFormat;
static const QString AttrTimeFormat;
static const QString AttrArrows;
static const QString AttrNodeReverse;
static const QString AttrNodeExcluded;
@ -241,7 +251,6 @@ public:
static const QString AttrEnd;
static const QString AttrIncludeAs;
static const QString AttrWidth;
static const QString AttrRotation;
static const QString AttrAll;
@ -341,6 +350,7 @@ signals:
* @brief patternChanged emit if we have unsaved change.
*/
void patternChanged(bool saved);
void UpdatePatternLabel();
/**
* @brief ShowTool highlight tool.
* @param id tool id.
@ -383,6 +393,9 @@ protected:
/** @brief tools list with pointer on tools. */
static QHash<quint32, VDataTool*> tools;
/** @brief patternLabelLines list to speed up reading a template by many pieces. */
static QVector<VLabelTemplateLine> patternLabelLines;
static bool patternLabelWasChanged;
static void ToolExists(const quint32 &id);
static VPiecePath ParsePathNodes(const QDomElement &domElement);

View File

@ -179,8 +179,15 @@ void MessageHandler::handleMessage(QtMsgType type, const QString &description, c
Q_LOGGING_CATEGORY(vXML, "v.xml")
const QString VDomDocument::AttrId = QStringLiteral("id");
const QString VDomDocument::AttrText = QStringLiteral("text");
const QString VDomDocument::AttrBold = QStringLiteral("bold");
const QString VDomDocument::AttrItalic = QStringLiteral("italic");
const QString VDomDocument::AttrAlignment = QStringLiteral("alignment");
const QString VDomDocument::AttrFSIncrement = QStringLiteral("sfIncrement");
const QString VDomDocument::TagVersion = QStringLiteral("version");
const QString VDomDocument::TagUnit = QStringLiteral("unit");
const QString VDomDocument::TagLine = QStringLiteral("line");
//---------------------------------------------------------------------------------------------------------------------
VDomDocument::VDomDocument()
@ -446,6 +453,21 @@ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QSt
return parameter;
}
//---------------------------------------------------------------------------------------------------------------------
QString VDomDocument::GetParametrEmptyString(const QDomElement &domElement, const QString &name)
{
QString result;
try
{
result = GetParametrString(domElement, name, "");
}
catch(const VExceptionEmptyParameter &)
{
// do nothing
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the double value of the given attribute.
@ -899,3 +921,55 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
return result;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VLabelTemplateLine> VDomDocument::GetLabelTemplate(const QDomElement &element) const
{
// We use implicit conversion. That's why check if values are still the same as excpected.
Q_STATIC_ASSERT(Qt::AlignLeft == 1);
Q_STATIC_ASSERT(Qt::AlignRight == 2);
Q_STATIC_ASSERT(Qt::AlignHCenter == 4);
QVector<VLabelTemplateLine> lines;
if (not element.isNull())
{
QDomElement tagLine = element.firstChildElement();
while (tagLine.isNull() == false)
{
if (tagLine.tagName() == TagLine)
{
VLabelTemplateLine line;
line.line = GetParametrString(tagLine, AttrText, tr("<empty>"));
line.bold = GetParametrBool(tagLine, AttrBold, falseStr);
line.italic = GetParametrBool(tagLine, AttrItalic, falseStr);
line.alignment = GetParametrUInt(tagLine, AttrAlignment, "0");
line.fontSizeIncrement = GetParametrUInt(tagLine, AttrFSIncrement, "0");
lines.append(line);
}
tagLine = tagLine.nextSiblingElement(TagLine);
}
}
return lines;
}
//---------------------------------------------------------------------------------------------------------------------
void VDomDocument::SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines)
{
if (not element.isNull())
{
for (int i=0; i < lines.size(); ++i)
{
QDomElement tagLine = createElement(TagLine);
SetAttribute(tagLine, AttrText, lines.at(i).line);
SetAttribute(tagLine, AttrBold, lines.at(i).bold);
SetAttribute(tagLine, AttrItalic, lines.at(i).italic);
SetAttribute(tagLine, AttrAlignment, lines.at(i).alignment);
SetAttribute(tagLine, AttrFSIncrement, lines.at(i).fontSizeIncrement);
element.appendChild(tagLine);
}
}
}

View File

@ -83,8 +83,15 @@ class VDomDocument : public QDomDocument
Q_DECLARE_TR_FUNCTIONS(VDomDocument)
public:
static const QString AttrId;
static const QString AttrText;
static const QString AttrBold;
static const QString AttrItalic;
static const QString AttrAlignment;
static const QString AttrFSIncrement;
static const QString TagVersion;
static const QString TagUnit;
static const QString TagLine;
VDomDocument();
virtual ~VDomDocument() Q_DECL_EQ_DEFAULT;
@ -101,6 +108,7 @@ public:
static QString GetParametrString(const QDomElement& domElement, const QString &name,
const QString &defValue = QString());
static QString GetParametrEmptyString(const QDomElement& domElement, const QString &name);
static qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue);
static quint32 GetParametrId(const QDomElement& domElement);
@ -122,6 +130,9 @@ public:
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
QVector<VLabelTemplateLine> GetLabelTemplate(const QDomElement &element) const;
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
protected:
bool setTagText(const QString &tag, const QString &text);
bool setTagText(const QDomElement &domElement, const QString &text);

View File

@ -0,0 +1,109 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/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 "vlabeltemplateconverter.h"
/*
* Version rules:
* 1. Version have three parts "major.minor.patch";
* 2. major part only for stable releases;
* 3. minor - 10 or more patch changes, or one big change;
* 4. patch - little change.
*/
const QString VLabelTemplateConverter::LabelTemplateMinVerStr = QStringLiteral("1.0.0");
const QString VLabelTemplateConverter::LabelTemplateMaxVerStr = QStringLiteral("1.0.0");
const QString VLabelTemplateConverter::CurrentSchema = QStringLiteral("://schema/label_template/v1.0.0.xsd");
//VLabelTemplateConverter::LabelTemplateMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VLabelTemplateConverter::LabelTemplateMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//---------------------------------------------------------------------------------------------------------------------
VLabelTemplateConverter::VLabelTemplateConverter(const QString &fileName)
: VAbstractConverter(fileName)
{
ValidateInputFile(CurrentSchema);
}
//---------------------------------------------------------------------------------------------------------------------
int VLabelTemplateConverter::MinVer() const
{
return LabelTemplateMinVer;
}
//---------------------------------------------------------------------------------------------------------------------
int VLabelTemplateConverter::MaxVer() const
{
return LabelTemplateMaxVer;
}
//---------------------------------------------------------------------------------------------------------------------
QString VLabelTemplateConverter::MinVerStr() const
{
return LabelTemplateMinVerStr;
}
//---------------------------------------------------------------------------------------------------------------------
QString VLabelTemplateConverter::MaxVerStr() const
{
return LabelTemplateMaxVerStr;
}
//---------------------------------------------------------------------------------------------------------------------
QString VLabelTemplateConverter::XSDSchema(int ver) const
{
switch (ver)
{
case (0x010000):
return CurrentSchema;
default:
InvalidVersion(ver);
break;
}
return QString();//unreachable code
}
//---------------------------------------------------------------------------------------------------------------------
void VLabelTemplateConverter::ApplyPatches()
{
switch (m_ver)
{
case (0x010000):
break;
default:
InvalidVersion(m_ver);
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VLabelTemplateConverter::DowngradeToCurrentMaxVersion()
{
SetVersion(LabelTemplateMaxVerStr);
Save();
}

View File

@ -0,0 +1,63 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/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 VLABELTEMPLATECONVERTER_H
#define VLABELTEMPLATECONVERTER_H
#include "vabstractconverter.h"
class VLabelTemplateConverter : public VAbstractConverter
{
public:
explicit VLabelTemplateConverter(const QString &fileName);
virtual ~VLabelTemplateConverter() Q_DECL_EQ_DEFAULT;
static const QString LabelTemplateMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int LabelTemplateMinVer = CONVERTER_VERSION_CHECK(1, 0, 0);
static Q_DECL_CONSTEXPR const int LabelTemplateMaxVer = CONVERTER_VERSION_CHECK(1, 0, 0);
protected:
virtual int MinVer() const Q_DECL_OVERRIDE;
virtual int MaxVer() const Q_DECL_OVERRIDE;
virtual QString MinVerStr() const Q_DECL_OVERRIDE;
virtual QString MaxVerStr() const Q_DECL_OVERRIDE;
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE;
virtual void ApplyPatches() Q_DECL_OVERRIDE;
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
virtual bool IsReadOnly() const Q_DECL_OVERRIDE {return false;}
private:
Q_DISABLE_COPY(VLabelTemplateConverter)
static const QString LabelTemplateMinVerStr;
};
#endif // VLABELTEMPLATECONVERTER_H

View File

@ -58,8 +58,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.5.1");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.5.1.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.6.0");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.6.0.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -135,6 +135,30 @@ static const QString strNodeType = QStringLiteral("nodeType");
static const QString strDet = QStringLiteral("det");
static const QString strTypeObject = QStringLiteral("typeObject");
static const QString strReadOnly = QStringLiteral("readOnly");
static const QString strPatternLabel = QStringLiteral("patternLabel");
static const QString strImage = QStringLiteral("image");
static const QString strAuthor = QStringLiteral("author");
static const QString strDescription = QStringLiteral("description");
static const QString strNotes = QStringLiteral("notes");
static const QString strGradation = QStringLiteral("gradation");
static const QString strPatternName = QStringLiteral("patternName");
static const QString strPatternNum = QStringLiteral("patternNumber");
static const QString strCompanyName = QStringLiteral("company");
static const QString strCustomerName = QStringLiteral("customer");
static const QString strLine = QStringLiteral("line");
static const QString strText = QStringLiteral("text");
static const QString strBold = QStringLiteral("bold");
static const QString strItalic = QStringLiteral("italic");
static const QString strAlignment = QStringLiteral("alignment");
static const QString strFSIncrement = QStringLiteral("sfIncrement");
static const QString strShowDate = QStringLiteral("showDate");
static const QString strShowMeasurements = QStringLiteral("showMeasurements");
static const QString strSize = QStringLiteral("size");
static const QString strMCP = QStringLiteral("mcp");
static const QString strLetter = QStringLiteral("letter");
static const QString strMaterial = QStringLiteral("material");
static const QString strUserDefined = QStringLiteral("userDef");
static const QString strPlacement = QStringLiteral("placement");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -215,6 +239,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000500):
return QStringLiteral("://schema/pattern/v0.5.0.xsd");
case (0x000501):
return QStringLiteral("://schema/pattern/v0.5.1.xsd");
case (0x000600):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -361,6 +387,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000501), m_convertedFileName);
V_FALLTHROUGH
case (0x000501):
ToV0_6_0();
ValidateXML(XSDSchema(0x000600), m_convertedFileName);
V_FALLTHROUGH
case (0x000600):
break;
default:
InvalidVersion(m_ver);
@ -379,7 +409,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 5, 1),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 6, 0),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -768,6 +798,20 @@ void VPatternConverter::ToV0_5_1()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_6_0()
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.6.0"));
QDomElement label = AddTagPatternLabelV0_5_1();
PortPatternLabeltoV0_6_0(label);
PortPieceLabelstoV0_6_0();
RemoveUnusedTagsV0_6_0();
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{
@ -2040,6 +2084,214 @@ void VPatternConverter::LabelTagToV0_4_4(const QString &tagName)
}
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VPatternConverter::AddTagPatternLabelV0_5_1()
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0),
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(strPatternLabel);
if (list.isEmpty())
{
const QStringList tags = QStringList() << strUnit
<< strImage
<< strAuthor
<< strDescription
<< strNotes
<< strGradation
<< strPatternName
<< strPatternNum
<< strCompanyName
<< strCustomerName
<< strPatternLabel;
QDomElement element = createElement(strPatternLabel);
QDomElement pattern = documentElement();
for (int i = tags.indexOf(element.tagName())-1; i >= 0; --i)
{
const QDomNodeList list = elementsByTagName(tags.at(i));
if (not list.isEmpty())
{
pattern.insertAfter(element, list.at(0));
break;
}
}
return element;
}
return list.at(0).toElement();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::PortPatternLabeltoV0_6_0(QDomElement &label)
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0),
"Time to refactor the code.");
if (not UniqueTagText(strCompanyName).isEmpty())
{
AddLabelTemplateLineV0_6_0(label, "%author%", true, false, 0, 4);
}
else
{
const QString author = UniqueTagText(strAuthor);
if (not author.isEmpty())
{
AddLabelTemplateLineV0_6_0(label, author, true, false, 0, 4);
}
}
if (not UniqueTagText(strPatternName).isEmpty())
{
AddLabelTemplateLineV0_6_0(label, "%patternName%", false, false, 0, 2);
}
if (not UniqueTagText(strPatternNum).isEmpty())
{
AddLabelTemplateLineV0_6_0(label, "%patternNumber%", false, false, 0, 0);
}
if (not UniqueTagText(strCustomerName).isEmpty())
{
AddLabelTemplateLineV0_6_0(label, "%customer%", false, true, 0, 0);
}
const QString sizeField = UniqueTagText(strSize);
if (not sizeField.isEmpty())
{
AddLabelTemplateLineV0_6_0(label, sizeField, false, false, 0, 0);
}
if (UniqueTagText(strShowMeasurements) == trueStr)
{
AddLabelTemplateLineV0_6_0(label, "%mFileName%.%mExt%", false, false, 0, 0);
}
if (UniqueTagText(strShowDate) == trueStr)
{
AddLabelTemplateLineV0_6_0(label, "%date%", false, true, 0, 0);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::AddLabelTemplateLineV0_6_0(QDomElement &label, const QString &text, bool bold, bool italic,
int alignment, int fontSizeIncrement)
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0),
"Time to refactor the code.");
QDomElement tagLine = createElement(strLine);
SetAttribute(tagLine, strText, text);
SetAttribute(tagLine, strBold, bold);
SetAttribute(tagLine, strItalic, italic);
SetAttribute(tagLine, strAlignment, alignment);
SetAttribute(tagLine, strFSIncrement, fontSizeIncrement);
label.appendChild(tagLine);
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::PortPieceLabelstoV0_6_0()
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0),
"Time to refactor the code.");
const QDomNodeList nodeList = elementsByTagName(strData);
for (int i = 0; i < nodeList.size(); ++i)
{
QDomElement dataTag = nodeList.at(i).toElement();
QDomNodeList nodeListMCP = dataTag.childNodes();
const int count = nodeListMCP.count();
try
{
if (not GetParametrString(dataTag, strLetter, "").isEmpty())
{
AddLabelTemplateLineV0_6_0(dataTag, "%pLetter%", true, false, Qt::AlignHCenter, 6);
}
}
catch(const VExceptionEmptyParameter &)
{}
AddLabelTemplateLineV0_6_0(dataTag, "%pName%", true, false, Qt::AlignHCenter, 2);
for (int iMCP = 0; iMCP < count; ++iMCP)
{
QDomElement domMCP = nodeListMCP.at(iMCP).toElement();
QString line;
const int material = GetParametrUInt(domMCP, strMaterial, "0");
switch(material)
{
case 0:
line.append("%mFabric%");
break;
case 1:
line.append("%mLining%");
break;
case 2:
line.append("%mInterfacing%");
break;
case 3:
line.append("%mInterlining%");
break;
case 4:
default:
line.append(GetParametrString(domMCP, strUserDefined, "User material"));
break;
}
line.append(", %wCut% %pQuantity%");
if (GetParametrUInt(domMCP, strPlacement, "0") == 1)
{
line.append(" %wOnFold%");
}
AddLabelTemplateLineV0_6_0(dataTag, line, false, false, Qt::AlignHCenter, 0);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::RemoveUnusedTagsV0_6_0()
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0),
"Time to refactor the code.");
RemoveUniqueTagV0_6_0(strAuthor);
RemoveUniqueTagV0_6_0(strSize);
RemoveUniqueTagV0_6_0(strShowDate);
RemoveUniqueTagV0_6_0(strShowMeasurements);
const QDomNodeList nodeList = elementsByTagName(strMCP);
for (int i = 0; i < nodeList.size(); ++i)
{
nodeList.at(i).parentNode().removeChild(nodeList.at(i));
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::RemoveUniqueTagV0_6_0(const QString &tag)
{
// TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 6, 0),
"Time to refactor the code.");
const QDomNodeList nodeList = elementsByTagName(tag);
if (nodeList.isEmpty())
{
return;
}
QDomElement pattern = documentElement();
pattern.removeChild(nodeList.at(0));
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnionDetailsToV0_4_0()
{

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 5, 1);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 6, 0);
protected:
virtual int MinVer() const Q_DECL_OVERRIDE;
@ -105,6 +105,7 @@ private:
void ToV0_4_8();
void ToV0_5_0();
void ToV0_5_1();
void ToV0_6_0();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();
@ -147,6 +148,14 @@ private:
QDomElement GetUnionChildrenNodesV0_4_0(const QDomElement &detail);
void LabelTagToV0_4_4(const QString &tagName);
QDomElement AddTagPatternLabelV0_5_1();
void PortPatternLabeltoV0_6_0(QDomElement &label);
void AddLabelTemplateLineV0_6_0(QDomElement &label, const QString &text, bool bold, bool italic, int alignment,
int fontSizeIncrement);
void PortPieceLabelstoV0_6_0();
void RemoveUnusedTagsV0_6_0();
void RemoveUniqueTagV0_6_0(const QString &tag);
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -9,7 +9,8 @@ HEADERS += \
$$PWD/vabstractpattern.h \
$$PWD/vvstconverter.h \
$$PWD//vvitconverter.h \
$$PWD//vabstractmconverter.h
$$PWD//vabstractmconverter.h \
$$PWD/vlabeltemplateconverter.h
SOURCES += \
$$PWD/vabstractconverter.cpp \
@ -19,4 +20,5 @@ SOURCES += \
$$PWD/vabstractpattern.cpp \
$$PWD/vvstconverter.cpp \
$$PWD//vvitconverter.cpp \
$$PWD//vabstractmconverter.cpp
$$PWD//vabstractmconverter.cpp \
$$PWD/vlabeltemplateconverter.cpp

View File

@ -2,10 +2,12 @@
# This need for corect working file translations.pro
SOURCES += \
$$PWD/vmeasurements.cpp
$$PWD/vmeasurements.cpp \
$$PWD/vlabeltemplate.cpp
*msvc*:SOURCES += $$PWD/stable.cpp
HEADERS += \
$$PWD/vmeasurements.h \
$$PWD/stable.h
$$PWD/stable.h \
$$PWD/vlabeltemplate.h

View File

@ -0,0 +1,80 @@
/************************************************************************
**
** @file vlabeltemplate.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 8, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/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 "vlabeltemplate.h"
#include "../ifc/xml/vlabeltemplateconverter.h"
const QString VLabelTemplate::TagTemplate = QStringLiteral("template");
const QString VLabelTemplate::TagLines = QStringLiteral("lines");
//---------------------------------------------------------------------------------------------------------------------
VLabelTemplate::VLabelTemplate()
: VDomDocument()
{}
//---------------------------------------------------------------------------------------------------------------------
void VLabelTemplate::CreateEmptyTemplate()
{
clear();
QDomElement templateElement = this->createElement(TagTemplate);
QDomElement version = createElement(TagVersion);
QDomText newNodeText = createTextNode(VLabelTemplateConverter::LabelTemplateMaxVerStr);
version.appendChild(newNodeText);
templateElement.appendChild(version);
templateElement.appendChild(createElement(TagLines));
this->appendChild(templateElement);
insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild());
}
//---------------------------------------------------------------------------------------------------------------------
void VLabelTemplate::AddLines(const QVector<VLabelTemplateLine> &lines)
{
const QDomNodeList listLines = elementsByTagName(TagLines);
if (listLines.size() == 0)
{
return;
}
QDomElement tag = listLines.at(0).toElement();
VDomDocument::SetLabelTemplate(tag, lines);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VLabelTemplateLine> VLabelTemplate::ReadLines() const
{
const QDomNodeList listLines = elementsByTagName(TagLines);
if (listLines.size() == 0)
{
return QVector<VLabelTemplateLine>();
}
return VDomDocument::GetLabelTemplate(listLines.at(0).toElement());
}

View File

@ -0,0 +1,51 @@
/************************************************************************
**
** @file vlabeltemplate.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 8, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/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 VLABELTEMPLATE_H
#define VLABELTEMPLATE_H
#include "../ifc/xml/vdomdocument.h"
class VLabelTemplate : public VDomDocument
{
public:
VLabelTemplate();
virtual ~VLabelTemplate() Q_DECL_EQ_DEFAULT;
static const QString TagTemplate;
static const QString TagLines;
void CreateEmptyTemplate();
void AddLines(const QVector<VLabelTemplateLine> &lines);
QVector<VLabelTemplateLine> ReadLines() const;
private:
Q_DISABLE_COPY(VLabelTemplate)
};
#endif // VLABELTEMPLATE_H

View File

@ -400,8 +400,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
if (geom.IsVisible() == true)
{
VAbstractPattern* pDoc = qApp->getCurrentDocument();
det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), VContainer::size(), VContainer::height(),
pattern);
det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), pattern);
}
const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry();
@ -544,8 +543,8 @@ QStringList VLayoutPiece::GetPatternText() const
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont &font,
qreal dSize, qreal dHeight, const VContainer *pattern)
void VLayoutPiece::SetPatternInfo(VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont &font,
const VContainer *pattern)
{
QPointF ptPos;
qreal labelWidth = 0;
@ -578,7 +577,7 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa
d->m_tmPattern.SetFont(font);
d->m_tmPattern.SetFontSize(geom.GetFontSize());
d->m_tmPattern.Update(pDoc, dSize, dHeight);
d->m_tmPattern.Update(pDoc);
// generate lines of text
d->m_tmPattern.SetFontSize(geom.GetFontSize());
@ -1026,8 +1025,8 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
const TextLine& tl = tm.GetSourceLine(i);
QFont fnt = tm.GetFont();
fnt.setPixelSize(tm.GetFont().pixelSize() + tl.m_iFontSize);
fnt.setWeight(tl.m_eFontWeight);
fnt.setStyle(tl.m_eStyle);
fnt.setBold(tl.bold);
fnt.setItalic(tl.italic);
QFontMetrics fm(fnt);

View File

@ -95,8 +95,8 @@ public:
QPointF GetPatternTextPosition() const;
QStringList GetPatternText() const;
void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont& font,
qreal dSize, qreal dHeight, const VContainer *pattern);
void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData& geom, const QFont& font,
const VContainer *pattern);
void SetGrainline(const VGrainlineData& geom, const VContainer *pattern);
QVector<QPointF> GetGrainline() const;

View File

@ -38,6 +38,7 @@
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vmath.h"
#include "../vpatterndb/vcontainer.h"
#include "vtextmanager.h"
//---------------------------------------------------------------------------------------------------------------------
@ -47,11 +48,134 @@
TextLine::TextLine()
: m_qsText(),
m_iFontSize(MIN_FONT_SIZE),
m_eFontWeight(QFont::Normal),
m_eStyle(QFont::StyleNormal),
bold(false),
italic(false),
m_eAlign(Qt::AlignCenter)
{}
QList<TextLine> VTextManager::m_patternLabelLines = QList<TextLine>();
namespace
{
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
{
SCASSERT(doc != nullptr)
QMap<QString, QString> placeholders;
// Pattern tags
QLocale locale(qApp->Settings()->GetLocale());
const QString date = locale.toString(QDate::currentDate(), doc->GetLabelDateFormat());
placeholders.insert(pl_date, date);
const QString time = locale.toString(QTime::currentTime(), doc->GetLabelTimeFormat());
placeholders.insert(pl_time, time);
placeholders.insert(pl_patternName, doc->GetPatternName());
placeholders.insert(pl_patternNumber, doc->GetPatternNumber());
placeholders.insert(pl_author, doc->GetCompanyName());
placeholders.insert(pl_customer, doc->GetCustomerName());
placeholders.insert(pl_pExt, QString("val"));
placeholders.insert(pl_pFileName, QFileInfo(qApp->GetPPath()).baseName());
placeholders.insert(pl_mFileName, QFileInfo(doc->MPath()).baseName());
QString curSize;
QString curHeight;
QString mExt;
if (qApp->patternType() == MeasurementsType::Multisize)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
mExt = "vst";
}
else if (qApp->patternType() == MeasurementsType::Individual)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
mExt = "vit";
}
placeholders.insert(pl_size, curSize);
placeholders.insert(pl_height, curHeight);
placeholders.insert(pl_mExt, mExt);
// Piece tags
placeholders.insert(pl_pLetter, "");
placeholders.insert(pl_pAnnotation, "");
placeholders.insert(pl_pOrientation, "");
placeholders.insert(pl_pRotation, "");
placeholders.insert(pl_pTilt, "");
placeholders.insert(pl_pFoldPosition, "");
placeholders.insert(pl_pName, "");
placeholders.insert(pl_pQuantity, "");
placeholders.insert(pl_wOnFold, "");
placeholders.insert(pl_mFabric, QObject::tr("Fabric"));
placeholders.insert(pl_mLining, QObject::tr("Lining"));
placeholders.insert(pl_mInterfacing, QObject::tr("Interfacing"));
placeholders.insert(pl_mInterlining, QObject::tr("Interlining"));
placeholders.insert(pl_wCut, QObject::tr("Cut"));
return placeholders;
}
//---------------------------------------------------------------------------------------------------------------------
void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &name, const VPieceLabelData& data)
{
placeholders[pl_pLetter] = data.GetLetter();
placeholders[pl_pAnnotation] = data.GetAnnotation();
placeholders[pl_pOrientation] = data.GetOrientation();
placeholders[pl_pRotation] = data.GetRotation();
placeholders[pl_pTilt] = data.GetTilt();
placeholders[pl_pFoldPosition] = data.GetFoldPosition();
placeholders[pl_pName] = name;
placeholders[pl_pQuantity] = QString::number(data.GetQuantity());
if (data.IsOnFold())
{
placeholders[pl_wOnFold] = QObject::tr("on fold");
}
}
//---------------------------------------------------------------------------------------------------------------------
QString ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString line)
{
QChar per('%');
auto i = placeholders.constBegin();
while (i != placeholders.constEnd())
{
line.replace(per+i.key()+per, i.value());
++i;
}
return line;
}
//---------------------------------------------------------------------------------------------------------------------
QList<TextLine> PrepareLines(const QVector<VLabelTemplateLine> &lines)
{
QList<TextLine> textLines;
for (int i=0; i < lines.size(); ++i)
{
if (not lines.at(i).line.isEmpty())
{
TextLine tl;
tl.m_qsText = lines.at(i).line;
tl.m_eAlign = static_cast<Qt::Alignment>(lines.at(i).alignment);
tl.m_iFontSize = lines.at(i).fontSizeIncrement;
tl.bold = lines.at(i).bold;
tl.italic = lines.at(i).italic;
textLines << tl;
}
}
return textLines;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VTextManager::VTextManager constructor
@ -60,13 +184,6 @@ VTextManager::VTextManager()
: m_font(), m_liLines()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VTextManager::~VTextManager destructor
*/
VTextManager::~VTextManager()
{}
//---------------------------------------------------------------------------------------------------------------------
VTextManager::VTextManager(const VTextManager &text)
: m_font(text.GetFont()), m_liLines(text.GetAllSourceLines())
@ -130,25 +247,6 @@ QList<TextLine> VTextManager::GetAllSourceLines() const
return m_liLines;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddSourceLine add new text line to the list
* @param tl text line object to be added
*/
void VTextManager::AddSourceLine(const TextLine& tl)
{
m_liLines << tl;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ClearSourceLines deletes the list of texts
*/
void VTextManager::ClearSourceLines()
{
m_liLines.clear();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VTextManager::GetSourceLinesCount returns the number of input text lines
@ -202,8 +300,8 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
const TextLine& tl = GetSourceLine(i);
fnt = m_font;
fnt.setPixelSize(iFS + tl.m_iFontSize);
fnt.setWeight(tl.m_eFontWeight);
fnt.setStyle(tl.m_eStyle);
fnt.setBold(tl.bold);
fnt.setItalic(tl.italic);
QFontMetrics fm(fnt);
const int iTW = fm.width(tl.m_qsText);
if (iTW > iMaxLen)
@ -215,8 +313,8 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
if (iMaxLen > fW)
{
QFont fnt = m_font;
fnt.setWeight(maxLine.m_eFontWeight);
fnt.setStyle(maxLine.m_eStyle);
fnt.setBold(maxLine.bold);
fnt.setItalic(maxLine.italic);
int lineLength = 0;
do
@ -240,58 +338,19 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
*/
void VTextManager::Update(const QString& qsName, const VPieceLabelData& data)
{
ClearSourceLines();
TextLine tl;
// all text must be centered and normal style!
tl.m_eAlign = Qt::AlignCenter;
tl.m_eStyle = QFont::StyleNormal;
m_liLines.clear();
// letter
tl.m_qsText = data.GetLetter();
if (tl.m_qsText.isEmpty() == false)
QMap<QString, QString> placeholders = PreparePlaceholders(qApp->getCurrentDocument());
InitPiecePlaceholders(placeholders, qsName, data);
QVector<VLabelTemplateLine> lines = data.GetLabelTemplate();
for (int i=0; i<lines.size(); ++i)
{
tl.m_eFontWeight = QFont::Bold;
tl.m_iFontSize = 6;
AddSourceLine(tl);
}
// name
tl.m_qsText = qsName;
if (tl.m_qsText.isEmpty() == false)
{
tl.m_eFontWeight = QFont::DemiBold;
tl.m_iFontSize = 2;
AddSourceLine(tl);
}
// MCP
QStringList qslMaterials;
qslMaterials << QApplication::translate("Detail", "Fabric", nullptr)
<< QApplication::translate("Detail", "Lining", nullptr)
<< QApplication::translate("Detail", "Interfacing", nullptr)
<< QApplication::translate("Detail", "Interlining", nullptr);
QString qsText = QLatin1String("%1, ") + tr("cut") + QLatin1String(" %2%3");
QStringList qslPlace;
qslPlace << "" << QLatin1String(" ") + tr("on fold");
tl.m_eFontWeight = QFont::Normal;
tl.m_iFontSize = 0;
for (int i = 0; i < data.GetMCPCount(); ++i)
{
MaterialCutPlacement mcp = data.GetMCP(i);
if (mcp.m_iCutNumber > 0)//Not gonna happen because min value is 1 now, but decided to left
{
QString qsMat;
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
qsMat = mcp.m_qsMaterialUserDef;
}
else
{
qsMat = qslMaterials[int(mcp.m_eMaterial)];
}
tl.m_qsText = qsText.arg(qsMat).arg(mcp.m_iCutNumber).
arg(qslPlace[int(mcp.m_ePlacement)]);
AddSourceLine(tl);
}
lines[i].line = ReplacePlaceholders(placeholders, lines.at(i).line);
}
m_liLines = PrepareLines(lines);
}
//---------------------------------------------------------------------------------------------------------------------
@ -299,89 +358,28 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data)
* @brief VTextManager::Update updates the text lines with pattern info
* @param pDoc pointer to the abstract pattern object
*/
void VTextManager::Update(const VAbstractPattern *pDoc, qreal dSize, qreal dHeight)
void VTextManager::Update(VAbstractPattern *pDoc)
{
ClearSourceLines();
TextLine tl;
// all information must be centered
tl.m_eAlign = Qt::AlignCenter;
m_liLines.clear();
// Company name
tl.m_qsText = pDoc->GetCompanyName();
if (tl.m_qsText.isEmpty() == false)
if (m_patternLabelLines.isEmpty() || pDoc->GetPatternWasChanged())
{
tl.m_eFontWeight = QFont::DemiBold;
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 4;
AddSourceLine(tl);
QVector<VLabelTemplateLine> lines = pDoc->GetPatternLabelTemplate();
if (lines.isEmpty() && m_patternLabelLines.isEmpty())
{
return; // Nothing to parse
}
// Pattern name
tl.m_qsText = pDoc->GetPatternName();
if (tl.m_qsText.isEmpty() == false)
{
tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 2;
AddSourceLine(tl);
}
// Pattern number
tl.m_qsText = pDoc->GetPatternNumber();
if (tl.m_qsText.isEmpty() == false)
{
tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 0;
AddSourceLine(tl);
}
// Customer name
tl.m_qsText = pDoc->GetCustomerName();
if (tl.m_qsText.isEmpty() == false)
{
tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleItalic;
tl.m_iFontSize = 0;
AddSourceLine(tl);
}
// Size
tl.m_qsText = pDoc->GetPatternSize();
if (tl.m_qsText.isEmpty() == false)
{
// Such describing placeholders will help avoid mistake of localization.
// Translators very often remove '%'.
QString placeholder = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_size) + QLatin1String("%");
tl.m_qsText.replace(placeholder, QString::number(dSize));
placeholder = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_height) + QLatin1String("%");
tl.m_qsText.replace(placeholder, QString::number(dHeight));
const QMap<QString, QString> placeholders = PreparePlaceholders(pDoc);
tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 0;
AddSourceLine(tl);
}
// Measurements
tl.m_qsText = QFileInfo(pDoc->MPath()).fileName();
if (tl.m_qsText.isEmpty() == false && pDoc->IsMeasurementsVisible() == true)
for (int i=0; i<lines.size(); ++i)
{
tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 0;
AddSourceLine(tl);
lines[i].line = ReplacePlaceholders(placeholders, lines.at(i).line);
}
// Date
QDate date;
if (pDoc->IsDateVisible() == true)
{
date = QDate::currentDate();
}
if (date.isValid() == true)
{
QLocale locale(qApp->Settings()->GetLocale());
tl.m_qsText = locale.toString(date, "dd MMMM yyyy");
tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 0;
AddSourceLine(tl);
pDoc->SetPatternWasChanged(false);
m_patternLabelLines = PrepareLines(lines);
}
m_liLines = m_patternLabelLines;
}

View File

@ -51,8 +51,8 @@ struct TextLine
{
QString m_qsText;
int m_iFontSize; // 0 means default
QFont::Weight m_eFontWeight;
QFont::Style m_eStyle;
bool bold;
bool italic;
Qt::Alignment m_eAlign;
TextLine();
@ -67,7 +67,7 @@ class VTextManager
Q_DECLARE_TR_FUNCTIONS(VTextManager)
public:
VTextManager();
virtual ~VTextManager();
virtual ~VTextManager() = default;
VTextManager(const VTextManager &text);
VTextManager &operator=(const VTextManager &text);
@ -80,17 +80,17 @@ public:
void FitFontSize(qreal fW, qreal fH);
QList<TextLine> GetAllSourceLines() const;
void AddSourceLine(const TextLine& tl);
void ClearSourceLines();
int GetSourceLinesCount() const;
const TextLine& GetSourceLine(int i) const;
void Update(const QString& qsName, const VPieceLabelData& data);
void Update(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight);
void Update(VAbstractPattern* pDoc);
private:
QFont m_font;
QList<TextLine> m_liLines;
static QList<TextLine> m_patternLabelLines;
};
#endif // VTEXTMANAGER_H

View File

@ -111,6 +111,57 @@ const QStringList builInPostfixOperators = QStringList() << cm_Oprt
const QString pl_size = QStringLiteral("size");
const QString pl_height = QStringLiteral("height");
const QString pl_date = QStringLiteral("date");
const QString pl_time = QStringLiteral("time");
const QString pl_patternName = QStringLiteral("patternName");
const QString pl_patternNumber = QStringLiteral("patternNumber");
const QString pl_author = QStringLiteral("author");
const QString pl_customer = QStringLiteral("customer");
const QString pl_pExt = QStringLiteral("pExt");
const QString pl_pFileName = QStringLiteral("pFileName");
const QString pl_mFileName = QStringLiteral("mFileName");
const QString pl_mExt = QStringLiteral("mExt");
const QString pl_pLetter = QStringLiteral("pLetter");
const QString pl_pAnnotation = QStringLiteral("pAnnotation");
const QString pl_pOrientation = QStringLiteral("pOrientation");
const QString pl_pRotation = QStringLiteral("pRotation");
const QString pl_pTilt = QStringLiteral("pTilt");
const QString pl_pFoldPosition = QStringLiteral("pFoldPosition");
const QString pl_pName = QStringLiteral("pName");
const QString pl_pQuantity = QStringLiteral("pQuantity");
const QString pl_mFabric = QStringLiteral("mFabric");
const QString pl_mLining = QStringLiteral("mLining");
const QString pl_mInterfacing = QStringLiteral("mInterfacing");
const QString pl_mInterlining = QStringLiteral("mInterlining");
const QString pl_wCut = QStringLiteral("wCut");
const QString pl_wOnFold = QStringLiteral("wOnFold");
const QStringList labelTemplatePlaceholders = QStringList() << pl_size
<< pl_height
<< pl_date
<< pl_time
<< pl_patternName
<< pl_patternNumber
<< pl_author
<< pl_customer
<< pl_pExt
<< pl_pFileName
<< pl_mFileName
<< pl_mExt
<< pl_pLetter
<< pl_pAnnotation
<< pl_pOrientation
<< pl_pRotation
<< pl_pTilt
<< pl_pFoldPosition
<< pl_pName
<< pl_pQuantity
<< pl_mFabric
<< pl_mLining
<< pl_mInterfacing
<< pl_mInterlining
<< pl_wCut
<< pl_wOnFold;
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");

View File

@ -353,6 +353,32 @@ extern const QStringList builInPostfixOperators;
// Placeholders
extern const QString pl_size;
extern const QString pl_height;
extern const QString pl_date;
extern const QString pl_time;
extern const QString pl_patternName;
extern const QString pl_patternNumber;
extern const QString pl_author;
extern const QString pl_customer;
extern const QString pl_pExt;
extern const QString pl_pFileName;
extern const QString pl_mFileName;
extern const QString pl_mExt;
extern const QString pl_pLetter;
extern const QString pl_pAnnotation;
extern const QString pl_pOrientation;
extern const QString pl_pRotation;
extern const QString pl_pTilt;
extern const QString pl_pFoldPosition;
extern const QString pl_pName;
extern const QString pl_pQuantity;
extern const QString pl_mFabric;
extern const QString pl_mLining;
extern const QString pl_mInterfacing;
extern const QString pl_mInterlining;
extern const QString pl_wCut;
extern const QString pl_wOnFold;
extern const QStringList labelTemplatePlaceholders;
extern const QString cursorArrowOpenHand;
extern const QString cursorArrowCloseHand;

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

View File

@ -84,5 +84,20 @@
<file alias="16x16/status/help-about.png">icons/win.icon.theme/16x16/actions/help-about.png</file>
<file alias="24x24/status/help-about.png">icons/win.icon.theme/24x24/actions/help-about.png</file>
<file alias="32x32/status/help-about.png">icons/win.icon.theme/32x32/actions/help-about.png</file>
<file alias="16x16/actions/format-justify-center.png">icons/win.icon.theme/16x16/actions/format-justify-center.png</file>
<file alias="16x16/actions/format-justify-left.png">icons/win.icon.theme/16x16/actions/format-justify-left.png</file>
<file alias="16x16/actions/format-justify-right.png">icons/win.icon.theme/16x16/actions/format-justify-right.png</file>
<file alias="16x16/actions/format-text-bold.png">icons/win.icon.theme/16x16/actions/format-text-bold.png</file>
<file alias="16x16/actions/format-text-italic.png">icons/win.icon.theme/16x16/actions/format-text-italic.png</file>
<file alias="24x24/actions/format-justify-left.png">icons/win.icon.theme/24x24/actions/format-justify-left.png</file>
<file alias="24x24/actions/format-justify-right.png">icons/win.icon.theme/24x24/actions/format-justify-right.png</file>
<file alias="24x24/actions/format-justify-center.png">icons/win.icon.theme/24x24/actions/format-justify-center.png</file>
<file alias="24x24/actions/format-text-bold.png">icons/win.icon.theme/24x24/actions/format-text-bold.png</file>
<file alias="24x24/actions/format-text-italic.png">icons/win.icon.theme/24x24/actions/format-text-italic.png</file>
<file alias="32x32/actions/format-justify-center.png">icons/win.icon.theme/32x32/actions/format-justify-center.png</file>
<file alias="32x32/actions/format-justify-left.png">icons/win.icon.theme/32x32/actions/format-justify-left.png</file>
<file alias="32x32/actions/format-justify-right.png">icons/win.icon.theme/32x32/actions/format-justify-right.png</file>
<file alias="32x32/actions/format-text-bold.png">icons/win.icon.theme/32x32/actions/format-text-bold.png</file>
<file alias="32x32/actions/format-text-italic.png">icons/win.icon.theme/32x32/actions/format-text-italic.png</file>
</qresource>
</RCC>

View File

@ -54,6 +54,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
pmsTranslator(nullptr),
_patternUnit(Unit::Cm),
_patternType(MeasurementsType::Unknown),
patternFilePath(),
currentScene(nullptr),
sceneView(nullptr),
doc(nullptr),

View File

@ -105,6 +105,9 @@ public:
virtual bool IsAppInGUIMode()const =0;
QString GetPPath() const;
void SetPPath(const QString &value);
protected:
QUndoStack *undoStack;
@ -131,7 +134,7 @@ private:
Q_DISABLE_COPY(VAbstractApplication)
Unit _patternUnit;
MeasurementsType _patternType;
QString patternFilePath;
QGraphicsScene **currentScene;
VMainGraphicsView *sceneView;
@ -147,6 +150,18 @@ private:
void ClearTranslation();
};
//---------------------------------------------------------------------------------------------------------------------
inline QString VAbstractApplication::GetPPath() const
{
return patternFilePath;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VAbstractApplication::SetPPath(const QString &value)
{
patternFilePath = value;
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>

View File

@ -45,9 +45,12 @@
#include "../vmisc/vmath.h"
#include "../vpatterndb/pmsystems.h"
namespace
{
const QString settingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
const QString settingPathsMultisizeMeasurements = QStringLiteral("paths/standard_measurements");
const QString settingPathsTemplates = QStringLiteral("paths/templates");
const QString settingPathsLabelTemplate = QStringLiteral("paths/labels");
const QString settingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
const QString settingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
@ -60,13 +63,12 @@ const QString settingConfigurationConfirmItemDeletion = QStringLiteral("confi
const QString settingConfigurationConfirmFormatRewriting = QStringLiteral("configuration/confirm_format_rewriting");
const QString settingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
const QString settingPatternUser = QStringLiteral("pattern/user");
const QString settingPatternUndo = QStringLiteral("pattern/undo");
const QString settingPatternForbidFlipping = QStringLiteral("pattern/forbidFlipping");
const QString settingPatternHideMainPath = QStringLiteral("pattern/hideMainPath");
const QString settingDoublePassmark = QStringLiteral("pattern/doublePassmark");
const QString settingPatternDefaultSeamAllowance = QStringLiteral("pattern/defaultSeamAllowance");
const QString settingLabelFont = QStringLiteral("pattern/labelFont");
const QString settingPatternLabelFont = QStringLiteral("pattern/labelFont");
const QString settingGeneralRecentFileList = QStringLiteral("recentFileList");
const QString settingGeneralRestoreFileList = QStringLiteral("restoreFileList");
@ -79,12 +81,27 @@ const QString settingIncrementsDialogSize = QStringLiteral("toolIncrement
const QString settingFormulaWizardDialogSize = QStringLiteral("formulaWizardDialogSize");
const QString settingLatestSkippedVersion = QStringLiteral("lastestSkippedVersion");
const QString settingDateOfLastRemind = QStringLiteral("dateOfLastRemind");
const QString settingUserDefinedMaterials = QStringLiteral("configuration/userDefinedMaterials");
const QString settingCSVWithHeader = QStringLiteral("csv/withHeader");
const QString settingCSVCodec = QStringLiteral("csv/withCodec");
const QString settingCSVSeparator = QStringLiteral("csv/withSeparator");
const QString settingLabelDateFormat = QStringLiteral("label/dateFormat");
const QString settingLabelUserDateFormats = QStringLiteral("label/userDateFormats");
const QString settingLabelTimeFormat = QStringLiteral("label/timeFormat");
const QString settingLabelUserTimeFormats = QStringLiteral("label/userTimeFormats");
//---------------------------------------------------------------------------------------------------------------------
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
{
for (int i = 0; i < predefinedFormats.size(); ++i)
{
formats.removeAll(predefinedFormats.at(i));
}
return formats;
}
}
static const QString commonIniFilename = QStringLiteral("common");
#if !defined(Q_OS_WIN)
@ -314,6 +331,24 @@ void VCommonSettings::SetPathTemplate(const QString &value)
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetDefPathLabelTemplate()
{
return QDir::homePath() + QLatin1String("/valentina/") + tr("label templates");
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetPathLabelTemplate() const
{
return value(settingPathsLabelTemplate, GetDefPathLabelTemplate()).toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetPathLabelTemplate(const QString &value)
{
setValue(settingPathsLabelTemplate, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetOsSeparator() const
{
@ -443,24 +478,6 @@ void VCommonSettings::SetToolBarStyle(const bool &value)
setValue(settingConfigurationToolBarStyle, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetUser() const
{
QString user;
#ifdef Q_OS_WIN
user = value(settingPatternUser, QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
#else
user = value(settingPatternUser, QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
#endif
return user;
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetUser(const QString &value)
{
setValue(settingPatternUser, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetUndoCount() const
{
@ -630,27 +647,6 @@ void VCommonSettings::SetDateOfLastRemind(const QDate &date)
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::GetUserDefinedMaterials() const
{
return value(settingUserDefinedMaterials).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::AddUserDefinedMaterial(QString qsMaterial)
{
QStringList qsl = GetUserDefinedMaterials();
qsl << qsMaterial;
setValue(settingUserDefinedMaterials, qsl);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::ClearUserDefinedMaterial()
{
QStringList qsl;
setValue(settingUserDefinedMaterials, qsl);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetForbidWorkpieceFlipping() const
{
@ -828,11 +824,115 @@ double VCommonSettings::GetDefaultSeamAllowance()
//---------------------------------------------------------------------------------------------------------------------
QFont VCommonSettings::GetLabelFont() const
{
return qvariant_cast<QFont>(value(settingLabelFont, QApplication::font()));
return qvariant_cast<QFont>(value(settingPatternLabelFont, QApplication::font()));
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetLabelFont(const QFont &f)
{
setValue(settingLabelFont, f);
setValue(settingPatternLabelFont, f);
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetLabelDateFormat() const
{
const QString format = value(settingLabelDateFormat, VCommonSettings::PredefinedDateFormats().first()).toString();
const QStringList allFormats = VCommonSettings::PredefinedDateFormats() + GetUserDefinedDateFormats();
if (allFormats.contains(format))
{
return format;
}
else
{
return VCommonSettings::PredefinedDateFormats().first();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetLabelDateFormat(const QString &format)
{
setValue(settingLabelDateFormat, format);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::PredefinedDateFormats()
{
QStringList formats = QStringList() << "MM-dd-yyyy"
<< "d/M/yy"
<< "ddddMMMM dd, yyyy"
<< "dd/MM/yy"
<< "dd/MM/yyyy"
<< "MMM d, yy"
<< "MMM d, yyyy"
<< "d. MMM. yyyy"
<< "MMMM d, yyyy"
<< "d. MMMM yyyy"
<< "ddd, MMM d, yy"
<< "ddd dd/MMM yy"
<< "ddd, MMMM d, yyyy"
<< "ddddMMMM d, yyyy"
<< "MM-dd"
<< "yy-MM-dd"
<< "yyyy-MM-dd"
<< "MM/yy"
<< "MMM dd"
<< "MMMM";
return formats;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::GetUserDefinedDateFormats() const
{
return value(settingLabelUserDateFormats, QStringList()).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetUserDefinedDateFormats(const QStringList &formats)
{
setValue(settingLabelUserDateFormats, ClearFormats(VCommonSettings::PredefinedDateFormats(), formats));
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetLabelTimeFormat() const
{
const QString format = value(settingLabelTimeFormat, VCommonSettings::PredefinedTimeFormats().first()).toString();
const QStringList allFormats = VCommonSettings::PredefinedTimeFormats() + GetUserDefinedTimeFormats();
if (allFormats.contains(format))
{
return format;
}
else
{
return VCommonSettings::PredefinedTimeFormats().first();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetLabelTimeFormat(const QString &format)
{
setValue(settingLabelTimeFormat, format);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::PredefinedTimeFormats()
{
QStringList formats = QStringList() << "hh:mm:ss"
<< "hh:mm:ss AP"
<< "hh:mm"
<< "hh:mm AP";
return formats;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::GetUserDefinedTimeFormats() const
{
return value(settingLabelUserTimeFormats, QStringList()).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetUserDefinedTimeFormats(const QStringList &formats)
{
setValue(settingLabelUserTimeFormats, ClearFormats(VCommonSettings::PredefinedTimeFormats(), formats));
}

View File

@ -66,6 +66,10 @@ public:
QString GetPathTemplate() const;
void SetPathTemplate(const QString &value);
static QString GetDefPathLabelTemplate();
QString GetPathLabelTemplate() const;
void SetPathLabelTemplate(const QString &value);
bool GetOsSeparator() const;
void SetOsSeparator(const bool &value);
@ -96,9 +100,6 @@ public:
bool GetToolBarStyle() const;
void SetToolBarStyle(const bool &value);
QString GetUser() const;
void SetUser(const QString &value);
int GetUndoCount() const;
void SetUndoCount(const int &value);
@ -135,10 +136,6 @@ public:
QDate GetDateOfLastRemind() const;
void SetDateOfLastRemind(const QDate &date);
QStringList GetUserDefinedMaterials() const;
void AddUserDefinedMaterial(QString qsMaterial);
void ClearUserDefinedMaterial();
bool GetForbidWorkpieceFlipping() const;
void SetForbidWorkpieceFlipping(bool value);
@ -170,6 +167,20 @@ public:
static const QString unixStandardSharePath;
#endif
QString GetLabelDateFormat() const;
void SetLabelDateFormat(const QString &format);
static QStringList PredefinedDateFormats();
QStringList GetUserDefinedDateFormats() const;
void SetUserDefinedDateFormats(const QStringList &formats);
QString GetLabelTimeFormat() const;
void SetLabelTimeFormat(const QString &format);
static QStringList PredefinedTimeFormats();
QStringList GetUserDefinedTimeFormats() const;
void SetUserDefinedTimeFormats(const QStringList &formats);
private:
Q_DISABLE_COPY(VCommonSettings)
};

View File

@ -40,40 +40,5 @@ enum class ArrowType : char
atRear
};
enum class MaterialType : char
{
mtFabric = 0,
mtLining = 1,
mtInterfacing = 2,
mtInterlining = 3,
mtUserDefined = 4
};
enum class PlacementType : char
{
ptNone = 0,
ptCutOnFold = 1
};
/**
* @brief The MaterialCutPlacement struct used to hold a material, cut number and placement 3-tuple
*/
struct MaterialCutPlacement
{
MaterialType m_eMaterial;
QString m_qsMaterialUserDef;
int m_iCutNumber;
PlacementType m_ePlacement;
MaterialCutPlacement()
: m_eMaterial(MaterialType::mtFabric),
m_qsMaterialUserDef(),
m_iCutNumber(0),
m_ePlacement(PlacementType::ptNone)
{}
};
typedef QList<MaterialCutPlacement> MCPContainer;
#endif // FLOATITEMDEF_H

View File

@ -59,65 +59,119 @@ VPieceLabelData &VPieceLabelData::operator=(const VPieceLabelData &data)
VPieceLabelData::~VPieceLabelData()
{}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Append(const MaterialCutPlacement& rMCP)
{
d->m_conMCP.append(rMCP);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Insert(int i, const MaterialCutPlacement& rMCP)
{
Q_ASSERT(i >= 0);
Q_ASSERT(i <= GetMCPCount());
d->m_conMCP.insert(i, rMCP);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Set(int i, const MaterialCutPlacement& rMCP)
{
Q_ASSERT(i >= 0);
Q_ASSERT(i < GetMCPCount());
d->m_conMCP[i] = rMCP;
}
//---------------------------------------------------------------------------------------------------------------------
int VPieceLabelData::GetMCPCount() const
{
return d->m_conMCP.count();
}
//---------------------------------------------------------------------------------------------------------------------
const MaterialCutPlacement& VPieceLabelData::GetMCP(int i) const
{
Q_ASSERT(i >= 0);
Q_ASSERT(i < GetMCPCount());
return d->m_conMCP.at(i);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::RemoveMCP(int i)
{
Q_ASSERT(i >= 0);
Q_ASSERT(i < GetMCPCount());
d->m_conMCP.removeAt(i);
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Clear()
{
d->m_qsLetter.clear();
d->m_conMCP.clear();
}
//---------------------------------------------------------------------------------------------------------------------
const QString& VPieceLabelData::GetLetter() const
QString VPieceLabelData::GetLetter() const
{
return d->m_qsLetter;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetLetter(QString qsLetter)
void VPieceLabelData::SetLetter(const QString &qsLetter)
{
d->m_qsLetter = qsLetter.left(3);
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetAnnotation() const
{
return d->m_annotation;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetAnnotation(const QString &val)
{
d->m_annotation = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetOrientation() const
{
return d->m_orientation;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetOrientation(const QString &val)
{
d->m_orientation = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetRotation() const
{
return d->m_rotation;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetRotation(const QString &val)
{
d->m_rotation = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetTilt() const
{
return d->m_tilt;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetTilt(const QString &val)
{
d->m_tilt = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetFoldPosition() const
{
return d->m_foldPosition;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetFoldPosition(const QString &val)
{
d->m_foldPosition = val;
}
//---------------------------------------------------------------------------------------------------------------------
int VPieceLabelData::GetQuantity() const
{
return d->m_quantity;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetQuantity(int val)
{
if (val >= 1)
{
d->m_quantity = val;
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VPieceLabelData::IsOnFold() const
{
return d->m_onFold;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetOnFold(bool onFold)
{
d->m_onFold = onFold;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VLabelTemplateLine> VPieceLabelData::GetLabelTemplate() const
{
return d->m_lines;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetLabelTemplate(const QVector<VLabelTemplateLine> &lines)
{
d->m_lines = lines;
}

View File

@ -35,6 +35,7 @@
#include "floatitemdef.h"
class VPieceLabelDataPrivate;
class VLabelTemplateLine;
/**
* @brief The VPieceLabelData class holds some information about a single
@ -56,18 +57,35 @@ public:
void Swap(VPieceLabelData &data) Q_DECL_NOTHROW
{ VPatternLabelData::Swap(data); std::swap(d, data.d); }
// methods, which operate on MaterialCutPlacement container
void Append(const MaterialCutPlacement& rMCP);
void Insert(int i, const MaterialCutPlacement& rMCP);
void Set(int i, const MaterialCutPlacement& rMCP);
int GetMCPCount() const;
const MaterialCutPlacement& GetMCP(int i) const;
void RemoveMCP(int i);
void Clear();
// methods, which operate on other members
const QString& GetLetter() const;
void SetLetter(QString qsLetter);
QString GetLetter() const;
void SetLetter(const QString &qsLetter);
QString GetAnnotation() const;
void SetAnnotation(const QString &val);
QString GetOrientation() const;
void SetOrientation(const QString &val);
QString GetRotation() const;
void SetRotation(const QString &val);
QString GetTilt() const;
void SetTilt(const QString &val);
QString GetFoldPosition() const;
void SetFoldPosition(const QString &val);
int GetQuantity() const;
void SetQuantity(int val);
bool IsOnFold() const;
void SetOnFold(bool onFold);
QVector<VLabelTemplateLine> GetLabelTemplate() const;
void SetLabelTemplate(const QVector<VLabelTemplateLine> &lines);
private:
QSharedDataPointer<VPieceLabelDataPrivate> d;

View File

@ -31,9 +31,11 @@
#include <QSharedData>
#include <QString>
#include <QVector>
#include "../vmisc/diagnostic.h"
#include "floatitemdef.h"
#include "../ifc/ifcdef.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
@ -44,21 +46,43 @@ class VPieceLabelDataPrivate : public QSharedData
public:
VPieceLabelDataPrivate()
: m_qsLetter(),
m_conMCP()
m_annotation(),
m_orientation(),
m_rotation(),
m_tilt(),
m_foldPosition(),
m_quantity(1),
m_onFold(false),
m_lines()
{}
VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data)
: QSharedData(data),
m_qsLetter(data.m_qsLetter),
m_conMCP(data.m_conMCP)
m_annotation(data.m_annotation),
m_orientation(data.m_orientation),
m_rotation(data.m_rotation),
m_tilt(data.m_tilt),
m_foldPosition(data.m_foldPosition),
m_quantity(data.m_quantity),
m_onFold(data.m_onFold),
m_lines(data.m_lines)
{}
~VPieceLabelDataPrivate() Q_DECL_EQ_DEFAULT;
/** @brief m_qsLetter Detail letter (should be no more than 3 characters) */
QString m_qsLetter;
/** @brief m_conMCP List of material, cut, placement tuples */
MCPContainer m_conMCP;
QString m_annotation;
QString m_orientation;
QString m_rotation;
QString m_tilt;
QString m_foldPosition;
int m_quantity;
bool m_onFold;
QVector<VLabelTemplateLine> m_lines;
private:
VPieceLabelDataPrivate &operator=(const VPieceLabelDataPrivate &) Q_DECL_EQ_DELETE;

View File

@ -96,7 +96,11 @@ const QString highhipCirc_M = QStringLiteral("highhip_circ"); /
const QString hipCirc_M = QStringLiteral("hip_circ"); // G09
const QString neckArcF_M = QStringLiteral("neck_arc_f"); // G10
const QString highbustArcF_M = QStringLiteral("highbust_arc_f"); // G11
// size and bust_arc_f are synonyms
const QString size_M = QStringLiteral("size"); // G12
const QString bustArcF_M = QStringLiteral("bust_arc_f"); // G12
const QString lowbustArcF_M = QStringLiteral("lowbust_arc_f"); // G13
const QString ribArcF_M = QStringLiteral("rib_arc_f"); // G14
const QString waistArcF_M = QStringLiteral("waist_arc_f"); // G15
@ -400,6 +404,7 @@ QStringList ListGroupG()
<< neckArcF_M // G10
<< highbustArcF_M // G11
<< bustArcF_M // G12
<< size_M // G12
<< lowbustArcF_M // G13
<< ribArcF_M // G14
<< waistArcF_M // G15
@ -794,47 +799,48 @@ QString MapDiagrams(const VTranslateMeasurements *trM, const QString &number)
case 9: // G10
case 10: // G11
case 11: // G12
case 12: // G13
case 13: // G14
case 14: // G15
case 15: // G16
case 16: // G17
case 12: // G12
case 13: // G13
case 14: // G14
case 15: // G15
case 16: // G16
case 17: // G17
return QStringLiteral("Gp2");
case 17: // G18
case 18: // G19
case 19: // G20
case 20: // G21
case 21: // G22
case 22: // G23
case 23: // G24
case 24: // G25
case 18: // G18
case 19: // G19
case 20: // G20
case 21: // G21
case 22: // G22
case 23: // G23
case 24: // G24
case 25: // G25
return QStringLiteral("Gp3");
case 25: // G26
case 26: // G27
case 27: // G28
case 28: // G29
case 29: // G30
case 30: // G31
case 31: // G32
case 32: // G33
case 26: // G26
case 27: // G27
case 28: // G28
case 29: // G29
case 30: // G30
case 31: // G31
case 32: // G32
case 33: // G33
return QStringLiteral("Gp4");
case 33: // G34
case 34: // G35
case 35: // G36
case 36: // G37
case 37: // G38
case 38: // G39
case 39: // G40
case 40: // G41
case 34: // G34
case 35: // G35
case 36: // G36
case 37: // G37
case 38: // G38
case 39: // G39
case 40: // G40
case 41: // G41
return QStringLiteral("Gp5");
case 41: // G42
case 42: // G42
return QStringLiteral("Gp6");
case 42: // G43
case 43: // G44
case 43: // G43
case 44: // G44
return QStringLiteral("Gp7");
case 44: // G45
case 45: // G45
return QStringLiteral("Gp8");
case 45: // G46
case 46: // G46
return QStringLiteral("Gp9");
default:
break;

View File

@ -98,7 +98,11 @@ extern const QString highhipCirc_M; // G08
extern const QString hipCirc_M; // G09
extern const QString neckArcF_M; // G10
extern const QString highbustArcF_M; // G11
// size and bust_arc_f are synonyms
extern const QString size_M; // G12
extern const QString bustArcF_M; // G12
extern const QString lowbustArcF_M; // G13
extern const QString ribArcF_M; // G14
extern const QString waistArcF_M; // G15

View File

@ -610,18 +610,6 @@ const VTranslateVars *VContainer::GetTrVars() const
return d->trVars;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VariableExist check if exist variable this same name.
* @param name name of row
* @return true if contains
*/
// cppcheck-suppress unusedFunction
bool VContainer::VariableExist(const QString &name)
{
return d->variables.contains(name);
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type) const

View File

@ -178,8 +178,6 @@ public:
static qreal height();
static qreal *rheight();
bool VariableExist(const QString& name);
void RemoveIncrement(const QString& name);
const QHash<quint32, QSharedPointer<VGObject> > *DataGObjects() const;

View File

@ -669,6 +669,13 @@ void VTranslateMeasurements::InitGroupG()
"Full measurement description.");
InitMeasurement(bustArcF_M, m, g, d, "G12");
//=================================================================================================================
m = translate("VTranslateMeasurements", "size",
"Name in a formula. Don't use math symbols and space in name!!!!");
g = translate("VTranslateMeasurements", "Size", "Full measurement name.");
d = translate("VTranslateMeasurements", "Same as bust_arc_f.",
"Full measurement description.");
InitMeasurement(size_M, m, g, d, "G12");
//=================================================================================================================
m = translate("VTranslateMeasurements", "lowbust_arc_f",
"Name in a formula. Don't use math symbols and space in name!!!!");
g = translate("VTranslateMeasurements", "Lowbust arc, front", "Full measurement name.");

View File

@ -459,6 +459,30 @@ void VTranslateVars::InitPlaceholder()
{
placeholders.insert(pl_size, translate("VTranslateVars", "size", "placeholder"));
placeholders.insert(pl_height, translate("VTranslateVars", "height", "placeholder"));
placeholders.insert(pl_date, translate("VTranslateVars", "date", "placeholder"));
placeholders.insert(pl_time, translate("VTranslateVars", "time", "placeholder"));
placeholders.insert(pl_patternName, translate("VTranslateVars", "patternName", "placeholder"));
placeholders.insert(pl_patternNumber, translate("VTranslateVars", "patternNumber", "placeholder"));
placeholders.insert(pl_author, translate("VTranslateVars", "author", "placeholder"));
placeholders.insert(pl_customer, translate("VTranslateVars", "customer", "placeholder"));
placeholders.insert(pl_pExt, translate("VTranslateVars", "pExt", "placeholder"));
placeholders.insert(pl_pFileName, translate("VTranslateVars", "pFileName", "placeholder"));
placeholders.insert(pl_mFileName, translate("VTranslateVars", "mFileName", "placeholder"));
placeholders.insert(pl_mExt, translate("VTranslateVars", "mExt", "placeholder"));
placeholders.insert(pl_pLetter, translate("VTranslateVars", "pLetter", "placeholder"));
placeholders.insert(pl_pAnnotation, translate("VTranslateVars", "pAnnotation", "placeholder"));
placeholders.insert(pl_pOrientation, translate("VTranslateVars", "pOrientation", "placeholder"));
placeholders.insert(pl_pRotation, translate("VTranslateVars", "pRotation", "placeholder"));
placeholders.insert(pl_pTilt, translate("VTranslateVars", "pTilt", "placeholder"));
placeholders.insert(pl_pFoldPosition, translate("VTranslateVars", "pFoldPosition", "placeholder"));
placeholders.insert(pl_pName, translate("VTranslateVars", "pName", "placeholder"));
placeholders.insert(pl_pQuantity, translate("VTranslateVars", "pQuantity", "placeholder"));
placeholders.insert(pl_mFabric, translate("VTranslateVars", "mFabric", "placeholder"));
placeholders.insert(pl_mLining, translate("VTranslateVars", "mLining", "placeholder"));
placeholders.insert(pl_mInterfacing, translate("VTranslateVars", "mInterfacing", "placeholder"));
placeholders.insert(pl_mInterlining, translate("VTranslateVars", "mInterlining", "placeholder"));
placeholders.insert(pl_wCut, translate("VTranslateVars", "wCut", "placeholder"));
placeholders.insert(pl_wOnFold, translate("VTranslateVars", "wOnFold", "placeholder"));
}
#undef translate
@ -673,6 +697,44 @@ QString VTranslateVars::PlaceholderToUser(const QString &var) const
return var;
}
//---------------------------------------------------------------------------------------------------------------------
QString VTranslateVars::PlaceholderToUserText(QString text) const
{
QChar per('%');
auto i = placeholders.constBegin();
while (i != placeholders.constEnd())
{
const QString translated = per + i.value().translate() + per;
const QString original = per + i.key() + per;
if (translated != original)
{
text.replace(original, translated);
}
++i;
}
return text;
}
//---------------------------------------------------------------------------------------------------------------------
QString VTranslateVars::PlaceholderFromUserText(QString text) const
{
QChar per('%');
auto i = placeholders.constBegin();
while (i != placeholders.constEnd())
{
const QString translated = per + i.value().translate() + per;
const QString original = per + i.key() + per;
if (translated != original)
{
text.replace(translated, original);
}
++i;
}
return text;
}
//---------------------------------------------------------------------------------------------------------------------
QString VTranslateVars::VarToUser(const QString &var) const
{

View File

@ -48,6 +48,9 @@ public:
QString InternalVarToUser(const QString &var) const;
QString PlaceholderToUser(const QString &var) const;
QString PlaceholderToUserText(QString text) const;
QString PlaceholderFromUserText(QString text) const;
QString VarToUser(const QString &var) const;
QString VarFromUser(const QString &var) const;

View File

@ -45,7 +45,8 @@ HEADERS += \
$$PWD/tools/piece/dialogseamallowance.h \
$$PWD/tools/piece/dialogpiecepath.h \
$$PWD/tools/dialogpin.h \
$$PWD/tools/dialoginsertnode.h
$$PWD/tools/dialoginsertnode.h \
$$PWD/support/dialogeditlabel.h
SOURCES += \
$$PWD/tools/dialogalongline.cpp \
@ -90,7 +91,8 @@ SOURCES += \
$$PWD/tools/piece/dialogseamallowance.cpp \
$$PWD/tools/piece/dialogpiecepath.cpp \
$$PWD/tools/dialogpin.cpp \
$$PWD/tools/dialoginsertnode.cpp
$$PWD/tools/dialoginsertnode.cpp \
$$PWD/support/dialogeditlabel.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \
@ -139,4 +141,5 @@ FORMS += \
$$PWD/tools/piece/tabs/tabgrainline.ui \
$$PWD/tools/piece/tabs/tabpins.ui \
$$PWD/tools/dialoginsertnode.ui \
$$PWD/tools/piece/tabs/tabpassmarks.ui
$$PWD/tools/piece/tabs/tabpassmarks.ui \
$$PWD/support/dialogeditlabel.ui

View File

@ -0,0 +1,639 @@
/************************************************************************
**
** @file dialogeditlabel.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 11 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2017 Valentina project
** <https://bitbucket.org/dismine/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 "dialogeditlabel.h"
#include "ui_dialogeditlabel.h"
#include "../vmisc/vabstractapplication.h"
#include "../vformat/vlabeltemplate.h"
#include "../ifc/xml/vlabeltemplateconverter.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/exception/vexception.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpiece.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include <QDir>
#include <QMessageBox>
#include <QFileDialog>
#include <QMenu>
#include <QDate>
//---------------------------------------------------------------------------------------------------------------------
DialogEditLabel::DialogEditLabel(VAbstractPattern *doc, QWidget *parent)
: QDialog(parent),
ui(new Ui::DialogEditLabel),
m_placeholdersMenu(new QMenu(this)),
m_doc(doc),
m_placeholders()
{
ui->setupUi(this);
ui->lineEditLine->setClearButtonEnabled(true);
connect(ui->toolButtonAdd, &QToolButton::clicked, this, &DialogEditLabel::AddLine);
connect(ui->toolButtonRemove, &QToolButton::clicked, this, &DialogEditLabel::RemoveLine);
connect(ui->lineEditLine, &QLineEdit::textEdited, this, &DialogEditLabel::SaveLineText);
connect(ui->toolButtonBold, &QToolButton::toggled, this, &DialogEditLabel::SaveFontStyle);
connect(ui->toolButtonItalic, &QToolButton::toggled, this, &DialogEditLabel::SaveFontStyle);
connect(ui->toolButtonTextLeft, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating);
connect(ui->toolButtonTextCenter, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating);
connect(ui->toolButtonTextRight, &QToolButton::toggled, this, &DialogEditLabel::SaveTextFormating);
connect(ui->listWidgetEdit, &QListWidget::itemSelectionChanged, this, &DialogEditLabel::ShowLineDetails);
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &DialogEditLabel::TabChanged);
connect(ui->toolButtonNewLabel, &QToolButton::clicked, this, &DialogEditLabel::NewTemplate);
connect(ui->toolButtonExportLabel, &QToolButton::clicked, this, &DialogEditLabel::ExportTemplate);
connect(ui->toolButtonImportLabel, &QToolButton::clicked, this, &DialogEditLabel::ImportTemplate);
connect(ui->spinBoxFontSize, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
&DialogEditLabel::SaveAdditionalFontSize);
InitPlaceholders();
InitPlaceholdersMenu();
ui->pushButtonInsert->setMenu(m_placeholdersMenu);
}
//---------------------------------------------------------------------------------------------------------------------
DialogEditLabel::~DialogEditLabel()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::ShowLineDetails()
{
if (ui->listWidgetEdit->count() > 0)
{
const QListWidgetItem *line = ui->listWidgetEdit->currentItem();
if (line)
{
ui->lineEditLine->blockSignals(true);
ui->lineEditLine->setText(line->text());
ui->lineEditLine->blockSignals(false);
const QFont lineFont = line->font();
ui->toolButtonBold->blockSignals(true);
ui->toolButtonBold->setChecked(lineFont.bold());
ui->toolButtonBold->blockSignals(false);
ui->toolButtonItalic->blockSignals(true);
ui->toolButtonItalic->setChecked(lineFont.italic());
ui->toolButtonItalic->blockSignals(false);
ui->toolButtonTextLeft->blockSignals(true);
ui->toolButtonTextCenter->blockSignals(true);
ui->toolButtonTextRight->blockSignals(true);
const int lineAlignment = line->textAlignment();
if (lineAlignment == 0 || lineAlignment & Qt::AlignLeft)
{
ui->toolButtonTextLeft->setChecked(true);
ui->toolButtonTextCenter->setChecked(false);
ui->toolButtonTextRight->setChecked(false);
}
else if (lineAlignment & Qt::AlignHCenter)
{
ui->toolButtonTextLeft->setChecked(false);
ui->toolButtonTextCenter->setChecked(true);
ui->toolButtonTextRight->setChecked(false);
}
else if (lineAlignment & Qt::AlignRight)
{
ui->toolButtonTextLeft->setChecked(false);
ui->toolButtonTextCenter->setChecked(false);
ui->toolButtonTextRight->setChecked(true);
}
ui->toolButtonTextLeft->blockSignals(false);
ui->toolButtonTextCenter->blockSignals(false);
ui->toolButtonTextRight->blockSignals(false);
ui->spinBoxFontSize->blockSignals(true);
ui->spinBoxFontSize->setValue(line->data(Qt::UserRole).toInt());
ui->spinBoxFontSize->blockSignals(false);
}
}
SetupControls();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::AddLine()
{
int row = ui->listWidgetEdit->currentRow();
ui->listWidgetEdit->insertItem(++row, new QListWidgetItem(tr("<empty>")));
ui->listWidgetEdit->setCurrentRow(row);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::RemoveLine()
{
ui->listWidgetEdit->blockSignals(true);
QListWidgetItem *curLine = ui->listWidgetEdit->takeItem(ui->listWidgetEdit->currentRow());
if (curLine)
{
delete curLine;
}
ui->listWidgetEdit->blockSignals(false);
ShowLineDetails();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::SaveLineText(const QString &text)
{
QListWidgetItem *curLine = ui->listWidgetEdit->currentItem();
if (curLine)
{
curLine->setText(text);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::SaveFontStyle(bool checked)
{
QListWidgetItem *curLine = ui->listWidgetEdit->currentItem();
if (curLine)
{
QFont lineFont = curLine->font();
QToolButton *button = qobject_cast<QToolButton *>(sender());
if (button)
{
if (button == ui->toolButtonBold)
{
lineFont.setBold(checked);
}
else if (button == ui->toolButtonItalic)
{
lineFont.setItalic(checked);
}
}
curLine->setFont(lineFont);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::SaveTextFormating(bool checked)
{
QListWidgetItem *curLine = ui->listWidgetEdit->currentItem();
if (curLine)
{
QToolButton *button = qobject_cast<QToolButton *>(sender());
if (button)
{
ui->toolButtonTextLeft->blockSignals(true);
ui->toolButtonTextCenter->blockSignals(true);
ui->toolButtonTextRight->blockSignals(true);
if (button == ui->toolButtonTextLeft)
{
if (checked)
{
curLine->setTextAlignment(Qt::AlignLeft);
ui->toolButtonTextCenter->setChecked(false);
ui->toolButtonTextRight->setChecked(false);
}
else
{
button->setChecked(true);
}
}
else if (button == ui->toolButtonTextCenter)
{
if (checked)
{
curLine->setTextAlignment(Qt::AlignHCenter);
ui->toolButtonTextLeft->setChecked(false);
ui->toolButtonTextRight->setChecked(false);
}
else
{
button->setChecked(true);
}
}
else if (button == ui->toolButtonTextRight)
{
if (checked)
{
curLine->setTextAlignment(Qt::AlignRight);
ui->toolButtonTextCenter->setChecked(false);
ui->toolButtonTextRight->setChecked(false);
}
else
{
button->setChecked(true);
}
}
ui->toolButtonTextLeft->blockSignals(false);
ui->toolButtonTextCenter->blockSignals(false);
ui->toolButtonTextRight->blockSignals(false);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::NewTemplate()
{
if (ui->listWidgetEdit->count() > 0)
{
const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Create new template"),
tr("Creating new template will overwrite the current, do "
"you want to continue?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No)
{
return;
}
}
ui->listWidgetEdit->blockSignals(true);
ui->listWidgetEdit->clear();
ui->listWidgetEdit->blockSignals(false);
ShowLineDetails();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::ExportTemplate()
{
QString filters(tr("Label template") + QLatin1String("(*.xml)"));
QString dir = qApp->Settings()->GetPathLabelTemplate();
bool usedNotExistedDir = false;
QDir directory(dir);
if (not directory.exists())
{
usedNotExistedDir = directory.mkpath(".");
}
QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"),
dir + QLatin1String("/") + tr("template") + QLatin1String(".xml"),
filters, nullptr, QFileDialog::DontUseNativeDialog);
auto RemoveTempDir = [usedNotExistedDir, dir]()
{
if (usedNotExistedDir)
{
QDir directory(dir);
directory.rmpath(".");
}
};
if (fileName.isEmpty())
{
RemoveTempDir();
return;
}
QFileInfo f( fileName );
if (f.suffix().isEmpty() && f.suffix() != QLatin1String("xml"))
{
fileName += QLatin1String(".xml");
}
VLabelTemplate ltemplate;
ltemplate.CreateEmptyTemplate();
ltemplate.AddLines(GetTemplate());
QString error;
const bool result = ltemplate.SaveDocument(fileName, error);
if (result == false)
{
QMessageBox messageBox(this);
messageBox.setIcon(QMessageBox::Warning);
messageBox.setInformativeText(tr("Could not save file"));
messageBox.setDefaultButton(QMessageBox::Ok);
messageBox.setDetailedText(error);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
}
RemoveTempDir();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::ImportTemplate()
{
if (ui->listWidgetEdit->count() > 0)
{
const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Import template"),
tr("Import template will overwrite the current, do "
"you want to continue?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No)
{
return;
}
}
QString filter(tr("Label template") + QLatin1String("(*.xml)"));
const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"),
qApp->Settings()->GetPathLabelTemplate(), filter, nullptr,
QFileDialog::DontUseNativeDialog);
if (fileName.isEmpty())
{
return;
}
try
{
VLabelTemplate ltemplate;
ltemplate.setXMLContent(VLabelTemplateConverter(fileName).Convert());
SetTemplate(ltemplate.ReadLines());
}
catch (VException &e)
{
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()),
qUtf8Printable(e.DetailedInformation()));
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::InsertPlaceholder()
{
QAction *action = qobject_cast<QAction *>(sender());
if (action)
{
ui->lineEditLine->insert(action->data().toString());
ui->lineEditLine->setFocus();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::TabChanged(int index)
{
if (index == ui->tabWidget->indexOf(ui->tabPreview))
{
ui->toolButtonNewLabel->setDisabled(true);
ui->toolButtonImportLabel->setDisabled(true);
InitPreviewLines(GetTemplate());
}
else
{
ui->toolButtonNewLabel->setEnabled(ui->listWidgetEdit->count() > 0);
ui->toolButtonImportLabel->setEnabled(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::SaveAdditionalFontSize(int i)
{
QListWidgetItem *curLine = ui->listWidgetEdit->currentItem();
if (curLine)
{
QFont lineFont = curLine->font();
lineFont.setPointSize(lineFont.pointSize() - curLine->data(Qt::UserRole).toInt() + i);
curLine->setFont(lineFont);
curLine->setData(Qt::UserRole, i);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::SetupControls()
{
const bool enabled = ui->listWidgetEdit->count() > 0;
if (not enabled)
{
ui->lineEditLine->blockSignals(true);
ui->lineEditLine->clear();
ui->lineEditLine->blockSignals(false);
}
ui->toolButtonAdd->setEnabled(true);
ui->toolButtonImportLabel->setEnabled(true);
ui->toolButtonRemove->setEnabled(enabled);
ui->toolButtonBold->setEnabled(enabled);
ui->toolButtonItalic->setEnabled(enabled);
ui->toolButtonTextLeft->setEnabled(enabled);
ui->toolButtonTextCenter->setEnabled(enabled);
ui->toolButtonTextRight->setEnabled(enabled);
ui->pushButtonInsert->setEnabled(enabled);
ui->toolButtonNewLabel->setEnabled(enabled);
ui->toolButtonExportLabel->setEnabled(enabled);
ui->lineEditLine->setEnabled(enabled);
ui->spinBoxFontSize->setEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::InitPlaceholdersMenu()
{
QChar per('%');
auto i = m_placeholders.constBegin();
while (i != m_placeholders.constEnd())
{
auto value = i.value();
QAction *action = m_placeholdersMenu->addAction(value.first);
action->setData(per + qApp->TrVars()->PlaceholderToUser(i.key()) + per);
connect(action, &QAction::triggered, this, &DialogEditLabel::InsertPlaceholder);
++i;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::InitPlaceholders()
{
// Pattern tags
QLocale locale(qApp->Settings()->GetLocale());
const QString date = locale.toString(QDate::currentDate(), m_doc->GetLabelDateFormat());
m_placeholders.insert(pl_date, qMakePair(tr("Date"), date));
const QString time = locale.toString(QTime::currentTime(), m_doc->GetLabelTimeFormat());
m_placeholders.insert(pl_time, qMakePair(tr("Time"), time));
m_placeholders.insert(pl_patternName, qMakePair(tr("Pattern name"), m_doc->GetPatternName()));
m_placeholders.insert(pl_patternNumber, qMakePair(tr("Pattern number"), m_doc->GetPatternNumber()));
m_placeholders.insert(pl_author, qMakePair(tr("Company name or designer name"),
m_doc->GetCompanyName()));
m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), m_doc->GetCustomerName()));
m_placeholders.insert(pl_pExt, qMakePair(tr("Pattern extension"), QString("val")));
const QString patternFilePath = QFileInfo(qApp->GetPPath()).baseName();
m_placeholders.insert(pl_pFileName, qMakePair(tr("Pattern file name"), patternFilePath));
const QString measurementsFilePath = QFileInfo(m_doc->MPath()).baseName();
m_placeholders.insert(pl_mFileName, qMakePair(tr("Measurments file name"), measurementsFilePath));
QString curSize;
QString curHeight;
QString mExt;
if (qApp->patternType() == MeasurementsType::Multisize)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
mExt = "vst";
}
else if (qApp->patternType() == MeasurementsType::Individual)
{
curSize = QString::number(VContainer::size());
curHeight = QString::number(VContainer::height());
mExt = "vit";
}
m_placeholders.insert(pl_size, qMakePair(tr("Size"), curSize));
m_placeholders.insert(pl_height, qMakePair(tr("Height"), curHeight));
m_placeholders.insert(pl_mExt, qMakePair(tr("Measurments extension"), mExt));
// Piece tags
m_placeholders.insert(pl_pLetter, qMakePair(tr("Piece letter"), QString("")));
m_placeholders.insert(pl_pAnnotation, qMakePair(tr("Piece annotation"), QString("")));
m_placeholders.insert(pl_pOrientation, qMakePair(tr("Piece orientation"), QString("")));
m_placeholders.insert(pl_pRotation, qMakePair(tr("Piece rotation"), QString("")));
m_placeholders.insert(pl_pTilt, qMakePair(tr("Piece tilt"), QString("")));
m_placeholders.insert(pl_pFoldPosition, qMakePair(tr("Piece fold position"), QString("")));
m_placeholders.insert(pl_pName, qMakePair(tr("Piece name"), QString("")));
m_placeholders.insert(pl_pQuantity, qMakePair(tr("Quantity"), QString("")));
m_placeholders.insert(pl_mFabric, qMakePair(tr("Material: Fabric"), tr("Fabric")));
m_placeholders.insert(pl_mLining, qMakePair(tr("Material: Lining"), tr("Lining")));
m_placeholders.insert(pl_mInterfacing, qMakePair(tr("Material: Interfacing"), tr("Interfacing")));
m_placeholders.insert(pl_mInterlining, qMakePair(tr("Material: Interlining"), tr("Interlining")));
m_placeholders.insert(pl_wCut, qMakePair(tr("Word: Cut"), tr("Cut")));
m_placeholders.insert(pl_wOnFold, qMakePair(tr("Word: on fold"), QString("")));// By default should be empty
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogEditLabel::ReplacePlaceholders(QString line) const
{
auto i = m_placeholders.constBegin();
while (i != m_placeholders.constEnd())
{
line.replace(QChar('%')+i.key()+QChar('%'), i.value().second);
++i;
}
return line;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VLabelTemplateLine> DialogEditLabel::GetTemplate() const
{
QVector<VLabelTemplateLine> lines;
for (int i=0; i<ui->listWidgetEdit->count(); ++i)
{
const QListWidgetItem *lineItem = ui->listWidgetEdit->item(i);
if (lineItem)
{
VLabelTemplateLine line;
line.line = qApp->TrVars()->PlaceholderFromUserText(lineItem->text());
line.alignment = lineItem->textAlignment();
line.fontSizeIncrement = lineItem->data(Qt::UserRole).toInt();
const QFont font = lineItem->font();
line.bold = font.bold();
line.italic = font.italic();
lines.append(line);
}
}
return lines;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::SetTemplate(const QVector<VLabelTemplateLine> &lines)
{
ui->listWidgetEdit->blockSignals(true);
ui->listWidgetEdit->clear();
int row = -1;
for (int i=0; i<lines.size(); ++i)
{
QListWidgetItem *item = new QListWidgetItem(qApp->TrVars()->PlaceholderToUserText(lines.at(i).line));
item->setTextAlignment(lines.at(i).alignment);
item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement);
QFont font = item->font();
font.setBold(lines.at(i).bold);
font.setItalic(lines.at(i).italic);
font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement);
item->setFont(font);
ui->listWidgetEdit->insertItem(++row, item);
}
ui->listWidgetEdit->blockSignals(false);
if (ui->listWidgetEdit->count() > 0)
{
ui->listWidgetEdit->setCurrentRow(0);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::SetPiece(const VPiece &piece)
{
const VPieceLabelData& pieceData = piece.GetPatternPieceData();
m_placeholders[pl_pLetter].second = pieceData.GetLetter();
m_placeholders[pl_pAnnotation].second = pieceData.GetAnnotation();
m_placeholders[pl_pOrientation].second = pieceData.GetOrientation();
m_placeholders[pl_pRotation].second = pieceData.GetRotation();
m_placeholders[pl_pTilt].second = pieceData.GetTilt();
m_placeholders[pl_pFoldPosition].second = pieceData.GetFoldPosition();
m_placeholders[pl_pName].second = piece.GetName();
m_placeholders[pl_pQuantity].second = QString::number(pieceData.GetQuantity());
if (pieceData.IsOnFold())
{
m_placeholders[pl_wOnFold].second = tr("on fold");
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::InitPreviewLines(const QVector<VLabelTemplateLine> &lines)
{
ui->listWidgetPreview->clear();
int row = -1;
for (int i=0; i<lines.size(); ++i)
{
QListWidgetItem *item = new QListWidgetItem(ReplacePlaceholders(lines.at(i).line));
item->setTextAlignment(lines.at(i).alignment);
item->setData(Qt::UserRole, lines.at(i).fontSizeIncrement);
QFont font = item->font();
font.setBold(lines.at(i).bold);
font.setItalic(lines.at(i).italic);
font.setPointSize(font.pointSize() + lines.at(i).fontSizeIncrement);
item->setFont(font);
ui->listWidgetPreview->insertItem(++row, item);
}
if (ui->listWidgetPreview->count() > 0)
{
ui->listWidgetPreview->setCurrentRow(0);
}
}

View File

@ -0,0 +1,89 @@
/************************************************************************
**
** @file dialogeditlabel.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 11 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2017 Valentina project
** <https://bitbucket.org/dismine/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 DIALOGEDITLABEL_H
#define DIALOGEDITLABEL_H
#include <QDialog>
#include <QMap>
namespace Ui
{
class DialogEditLabel;
}
class VLabelTemplateLine;
class QMenu;
class VAbstractPattern;
class VPiece;
class DialogEditLabel : public QDialog
{
Q_OBJECT
public:
explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr);
virtual ~DialogEditLabel();
QVector<VLabelTemplateLine> GetTemplate() const;
void SetTemplate(const QVector<VLabelTemplateLine> &lines);
void SetPiece(const VPiece &piece);
private slots:
void ShowLineDetails();
void AddLine();
void RemoveLine();
void SaveLineText(const QString &text);
void SaveFontStyle(bool checked);
void SaveTextFormating(bool checked);
void NewTemplate();
void ExportTemplate();
void ImportTemplate();
void InsertPlaceholder();
void TabChanged(int index);
void SaveAdditionalFontSize(int i);
private:
Q_DISABLE_COPY(DialogEditLabel)
Ui::DialogEditLabel *ui;
QMenu *m_placeholdersMenu;
VAbstractPattern *m_doc;
QMap<QString, QPair<QString, QString>> m_placeholders;
void SetupControls();
void InitPlaceholdersMenu();
void InitPlaceholders();
QString ReplacePlaceholders(QString line) const;
void InitPreviewLines(const QVector<VLabelTemplateLine> &lines);
};
#endif // DIALOGEDITLABEL_H

View File

@ -0,0 +1,408 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogEditLabel</class>
<widget class="QDialog" name="DialogEditLabel">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>464</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit label template</string>
</property>
<property name="windowIcon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QToolButton" name="toolButtonNewLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Clear current and begin new label</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="document-new">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonImportLabel">
<property name="toolTip">
<string>Import from label template</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="document-open">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonExportLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Export label as template</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="document-save-as">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabEdit">
<attribute name="title">
<string>Edit</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidgetEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QToolButton" name="toolButtonBold">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string comment="Font formating">Bold</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="format-text-bold">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonItalic">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string comment="Font formating">Italic</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="format-text-italic">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonTextLeft">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Aligns with the left edge</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="format-justify-left">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonTextCenter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Centers horizontally in the available space</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="format-justify-center">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonTextRight">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Aligns with the right edge</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="format-justify-right">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxFontSize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Additional font size. Use to make a line bigger.</string>
</property>
<property name="maximum">
<number>25</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff>../../../../app/valentina/dialogs</normaloff>../../../../app/valentina/dialogs</iconset>
</property>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonRemove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff>../../../../app/valentina/dialogs</normaloff>../../../../app/valentina/dialogs</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Text:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="VLineEdit" name="lineEditLine">
<property name="enabled">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>Line of text</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonInsert">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Insert placeholders</string>
</property>
<property name="text">
<string>Insert...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabPreview">
<attribute name="title">
<string>Preview</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QListWidget" name="listWidgetPreview"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VLineEdit</class>
<extends>QLineEdit</extends>
<header>vlineedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogEditLabel</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogEditLabel</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -42,6 +42,7 @@
#include "dialogpiecepath.h"
#include "../../../undocommands/savepiecepathoptions.h"
#include "../../support/dialogeditwrongformula.h"
#include "../../support/dialogeditlabel.h"
#include "../../../tools/vtoolseamallowance.h"
#include <QMenu>
@ -103,9 +104,6 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
m_my(0),
m_dialog(),
m_visPins(),
m_qslMaterials(),
m_qslPlacements(),
m_conMCP(),
m_oldData(),
m_oldGeom(),
m_oldGrainline(),
@ -123,7 +121,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
m_timerWidth(nullptr),
m_timerWidthBefore(nullptr),
m_timerWidthAfter(nullptr),
m_saWidth(0)
m_saWidth(0),
m_templateLines()
{
ui->setupUi(this);
@ -245,19 +244,19 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
m_mx = piece.GetMx();
m_my = piece.GetMy();
uiTabLabels->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter());
m_conMCP.clear();
for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i)
{
m_conMCP << piece.GetPatternPieceData().GetMCP(i);
}
UpdateList();
m_oldData = piece.GetPatternPieceData();
uiTabLabels->lineEditLetter->setText(m_oldData.GetLetter());
uiTabLabels->lineEditAnnotation->setText(m_oldData.GetAnnotation());
uiTabLabels->lineEditOrientation->setText(m_oldData.GetOrientation());
uiTabLabels->lineEditRotation->setText(m_oldData.GetRotation());
uiTabLabels->lineEditTilt->setText(m_oldData.GetTilt());
uiTabLabels->lineEditFoldPosition->setText(m_oldData.GetFoldPosition());
uiTabLabels->spinBoxQuantity->setValue(m_oldData.GetQuantity());
uiTabLabels->checkBoxFold->setChecked(m_oldData.IsOnFold());
m_templateLines = m_oldData.GetLabelTemplate();
uiTabGrainline->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType()));
m_oldData = piece.GetPatternPieceData();
uiTabLabels->groupBoxDetailLabel->setChecked(m_oldData.IsVisible());
ChangeCurrentData(uiTabLabels->comboBoxDLCenterPin, m_oldData.CenterPin());
ChangeCurrentData(uiTabLabels->comboBoxDLTopLeftPin, m_oldData.TopLeftPin());
@ -459,105 +458,6 @@ void DialogSeamAllowance::resizeEvent(QResizeEvent *event)
DialogTool::resizeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateList()
{
uiTabLabels->listWidgetMCP->clear();
for (int i = 0; i < m_conMCP.count(); ++i)
{
MaterialCutPlacement mcp = m_conMCP.at(i);
QString qsText = tr("Cut %1 of %2%3").arg(mcp.m_iCutNumber);
if (mcp.m_eMaterial < MaterialType::mtUserDefined)
{
qsText = qsText.arg(m_qslMaterials[int(mcp.m_eMaterial)]);
}
else
{
qsText = qsText.arg(mcp.m_qsMaterialUserDef);
}
if (mcp.m_ePlacement == PlacementType::ptCutOnFold)
{
qsText = qsText.arg(QLatin1String(" ") + tr("on Fold"));
}
else
{
qsText = qsText.arg("");
}
uiTabLabels->listWidgetMCP->addItem(qsText);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::AddUpdate()
{
MaterialCutPlacement mcp;
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
const int i = uiTabLabels->comboBoxMaterial->currentData().toInt();
QString qsMat = uiTabLabels->comboBoxMaterial->currentText();
if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i])
{
mcp.m_eMaterial = MaterialType(i);
mcp.m_qsMaterialUserDef.clear();
}
else
{
mcp.m_eMaterial = MaterialType::mtUserDefined;
mcp.m_qsMaterialUserDef = qsMat;
// check if we have new user defined material
bool bFound = false;
for (int i = 0; i < qslUserMaterials.count() && bFound == false; ++i)
{
if (mcp.m_qsMaterialUserDef == qslUserMaterials[i])
{
bFound = true;
}
}
if (bFound == false)
{
qApp->Settings()->AddUserDefinedMaterial(mcp.m_qsMaterialUserDef);
qApp->Settings()->sync();
uiTabLabels->comboBoxMaterial->addItem(mcp.m_qsMaterialUserDef, int(MaterialType::mtUserDefined));
}
}
mcp.m_iCutNumber = uiTabLabels->spinBoxCutNumber->value();
mcp.m_ePlacement = PlacementType(uiTabLabels->comboBoxPlacement->currentIndex());
if (m_bAddMode == true)
{
m_conMCP << mcp;
}
else
{
int iR = uiTabLabels->listWidgetMCP->currentRow();
SCASSERT(iR >= 0)
m_conMCP[iR] = mcp;
SetAddMode();
}
UpdateList();
ClearFields();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::Cancel()
{
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::Remove()
{
int iR = uiTabLabels->listWidgetMCP->currentRow();
SCASSERT(iR >= 0)
m_conMCP.removeAt(iR);
UpdateList();
ClearFields();
SetAddMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NameDetailChanged()
{
@ -584,12 +484,6 @@ void DialogSeamAllowance::NameDetailChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::MaterialChanged()
{
uiTabLabels->pushButtonAdd->setEnabled(uiTabLabels->comboBoxMaterial->currentText().isEmpty() == false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
{
@ -1529,53 +1423,6 @@ void DialogSeamAllowance::UpdatePatternLabelValues()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetAddMode()
{
uiTabLabels->pushButtonAdd->setText(tr("Add"));
uiTabLabels->pushButtonCancel->hide();
uiTabLabels->pushButtonRemove->hide();
uiTabLabels->listWidgetMCP->setCurrentRow(-1);
m_bAddMode = true;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetEditMode()
{
int iR = uiTabLabels->listWidgetMCP->currentRow();
// this method can be called by clicking on item or by update. In the latter case there is nothing else to do!
if (iR < 0 || iR >= m_conMCP.count())
{
return;
}
uiTabLabels->pushButtonAdd->setText(tr("Update"));
uiTabLabels->pushButtonCancel->show();
uiTabLabels->pushButtonRemove->show();
MaterialCutPlacement mcp = m_conMCP.at(iR);
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
int iRow = qApp->Settings()->GetUserDefinedMaterials().indexOf(mcp.m_qsMaterialUserDef);
if (iRow >= 0)
{
uiTabLabels->comboBoxMaterial->setCurrentIndex(iRow + m_qslMaterials.count());
}
else
{
uiTabLabels->comboBoxMaterial->setCurrentText(mcp.m_qsMaterialUserDef);
}
}
else
{
uiTabLabels->comboBoxMaterial->setCurrentIndex(int(mcp.m_eMaterial));
}
uiTabLabels->spinBoxCutNumber->setValue(mcp.m_iCutNumber);
uiTabLabels->comboBoxPlacement->setCurrentIndex(int(mcp.m_ePlacement));
m_bAddMode = false;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnabledGrainline()
{
@ -2099,6 +1946,19 @@ void DialogSeamAllowance::PatternPinPointChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EditLabel()
{
DialogEditLabel editor(qApp->getCurrentDocument());
editor.SetTemplate(m_templateLines);
editor.SetPiece(GetPiece());
if (QDialog::Accepted == editor.exec())
{
m_templateLines = editor.GetTemplate();
}
}
//---------------------------------------------------------------------------------------------------------------------
VPiece DialogSeamAllowance::CreatePiece() const
{
@ -2116,12 +1976,14 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.SetMy(m_my);
piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth);
piece.GetPatternPieceData().SetLetter(uiTabLabels->lineEditLetter->text());
for (int i = 0; i < m_conMCP.count(); ++i)
{
piece.GetPatternPieceData().Append(m_conMCP[i]);
}
piece.GetPatternPieceData().SetAnnotation(uiTabLabels->lineEditAnnotation->text());
piece.GetPatternPieceData().SetOrientation(uiTabLabels->lineEditOrientation->text());
piece.GetPatternPieceData().SetRotation(uiTabLabels->lineEditRotation->text());
piece.GetPatternPieceData().SetTilt(uiTabLabels->lineEditTilt->text());
piece.GetPatternPieceData().SetFoldPosition(uiTabLabels->lineEditFoldPosition->text());
piece.GetPatternPieceData().SetQuantity(uiTabLabels->spinBoxQuantity->value());
piece.GetPatternPieceData().SetOnFold(uiTabLabels->checkBoxFold->isChecked());
piece.GetPatternPieceData().SetLabelTemplate(m_templateLines);
piece.GetPatternPieceData().SetPos(m_oldData.GetPos());
piece.GetPatternPieceData().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditDLWidthFormula));
piece.GetPatternPieceData().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditDLHeightFormula));
@ -2646,35 +2508,14 @@ void DialogSeamAllowance::InitPatternPieceDataTab()
{
uiTabLabels->lineEditName->setClearButtonEnabled(true);
uiTabLabels->lineEditLetter->setClearButtonEnabled(true);
uiTabLabels->lineEditAnnotation->setClearButtonEnabled(true);
uiTabLabels->lineEditOrientation->setClearButtonEnabled(true);
uiTabLabels->lineEditRotation->setClearButtonEnabled(true);
uiTabLabels->lineEditTilt->setClearButtonEnabled(true);
uiTabLabels->lineEditFoldPosition->setClearButtonEnabled(true);
connect(uiTabLabels->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged);
m_qslMaterials << QApplication::translate("Detail", "Fabric", nullptr)
<< QApplication::translate("Detail", "Lining", nullptr)
<< QApplication::translate("Detail", "Interfacing", nullptr)
<< QApplication::translate("Detail", "Interlining", nullptr);
for (int i = 0; i < m_qslMaterials.count(); ++i)
{
uiTabLabels->comboBoxMaterial->addItem(m_qslMaterials[i], i);
}
const QStringList qsl = qApp->Settings()->GetUserDefinedMaterials();
for (int i = 0; i < qsl.count(); ++i)
{
uiTabLabels->comboBoxMaterial->addItem(qsl.at(i), int(MaterialType::mtUserDefined));
}
m_qslPlacements << tr("None") << tr("Cut on fold");
uiTabLabels->comboBoxPlacement->addItems(m_qslPlacements);
connect(uiTabLabels->pushButtonAdd, &QPushButton::clicked, this, &DialogSeamAllowance::AddUpdate);
connect(uiTabLabels->pushButtonCancel, &QPushButton::clicked, this, &DialogSeamAllowance::Cancel);
connect(uiTabLabels->pushButtonRemove, &QPushButton::clicked, this, &DialogSeamAllowance::Remove);
connect(uiTabLabels->listWidgetMCP, &QListWidget::itemClicked, this, &DialogSeamAllowance::SetEditMode);
connect(uiTabLabels->comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogSeamAllowance::MaterialChanged);
SetAddMode();
connect(uiTabLabels->pushButtonEditPieceLabel, &QPushButton::clicked, this, &DialogSeamAllowance::EditLabel);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2880,14 +2721,6 @@ void DialogSeamAllowance::UpdateCurrentInternalPathRecord()
item->setText(GetPathName(path));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ClearFields()
{
uiTabLabels->comboBoxMaterial->setCurrentIndex(0);
uiTabLabels->spinBoxCutNumber->setValue(0);
uiTabLabels->comboBoxPlacement->setCurrentIndex(0);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula)
{

View File

@ -75,15 +75,8 @@ protected:
virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE;
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
protected slots:
void UpdateList();
void AddUpdate();
void Cancel();
void Remove();
private slots:
void NameDetailChanged();
void MaterialChanged();
void ShowMainPathContextMenu(const QPoint &pos);
void ShowCustomSAContextMenu(const QPoint &pos);
void ShowInternalPathsContextMenu(const QPoint &pos);
@ -111,9 +104,6 @@ private slots:
void UpdateDetailLabelValues();
void UpdatePatternLabelValues();
void SetAddMode();
void SetEditMode();
void EditGrainlineFormula();
void EditDLFormula();
void EditPLFormula();
@ -156,6 +146,8 @@ private slots:
void DetailPinPointChanged();
void PatternPinPointChanged();
void EditLabel();
private:
Q_DISABLE_COPY(DialogSeamAllowance)
@ -190,11 +182,6 @@ private:
QPointer<DialogTool> m_dialog;
QPointer<VisPiecePins> m_visPins;
QStringList m_qslMaterials;
QStringList m_qslPlacements;
// temporary container for Material/Cut/Placement 3-tuples
MCPContainer m_conMCP;
VPieceLabelData m_oldData;
VPatternLabelData m_oldGeom;
VGrainlineData m_oldGrainline;
@ -215,6 +202,8 @@ private:
QTimer *m_timerWidthAfter;
qreal m_saWidth;
QVector<VLabelTemplateLine> m_templateLines;
VPiece CreatePiece() const;
void NewMainPathItem(const VPieceNode &node);
@ -227,7 +216,6 @@ private:
bool MainPathIsClockwise() const;
void UpdateCurrentCustomSARecord();
void UpdateCurrentInternalPathRecord();
void ClearFields();
QListWidgetItem *GetItemById(quint32 id);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>566</width>
<height>596</height>
<width>579</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
@ -28,8 +28,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>546</width>
<height>576</height>
<width>559</width>
<height>480</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -44,14 +44,45 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QSplitter" name="splitter">
<layout class="QHBoxLayout" name="horizontalLayout_30">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Label template:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditPieceLabel">
<property name="toolTip">
<string>Edit pattern label</string>
</property>
<property name="text">
<string>Edit template</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3">
<widget class="QGroupBox" name="groupBoxLabelData">
<property name="title">
<string>Label data</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
@ -92,76 +123,107 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Material/Cut number/Placement</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<item row="2" column="0">
<widget class="QLabel" name="labelQuantity">
<property name="text">
<string>Cut number:</string>
<string>Quantity:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Material type:</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxMaterial">
<property name="toolTip">
<string>You can choose one of the predefined materials or enter a new one</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QSpinBox" name="spinBoxCutNumber">
<item row="2" column="1">
<widget class="QSpinBox" name="spinBoxQuantity">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000</number>
<number>9999</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Placement:</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="comboBoxPlacement"/>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButtonAdd">
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxFold">
<property name="text">
<string>Add</string>
<string>on fold</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QPushButton" name="pushButtonCancel">
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cancel</string>
<string>Annotation:</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pushButtonRemove">
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditAnnotation">
<property name="placeholderText">
<string>A text field to add comments in</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Remove</string>
<string>Orientation:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditOrientation">
<property name="placeholderText">
<string notr="true">&quot;Left&quot;/&quot;Right&quot;/&quot;Undefined&quot;</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Rotation:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEditRotation">
<property name="placeholderText">
<string notr="true">&quot;1-Way&quot;/&quot;2-Way&quot;/&quot;4-Way&quot;/&quot;Any&quot;</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Tilt:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditTilt">
<property name="placeholderText">
<string notr="true">&quot;CW X&quot;/&quot;CCW X&quot;</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Fold position:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditFoldPosition">
<property name="placeholderText">
<string notr="true">&quot;Up/Down&quot;/&quot;Left/Right&quot;</string>
</property>
</widget>
</item>
@ -169,7 +231,7 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -183,21 +245,6 @@
</item>
</layout>
</widget>
<widget class="QListWidget" name="listWidgetMCP">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabLabels">
<attribute name="title">
<string>Labels</string>

View File

@ -302,7 +302,14 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
const VPieceLabelData& data = piece.GetPatternPieceData();
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible() == true? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrAnnotation, data.GetAnnotation());
doc->SetAttribute(domData, VAbstractPattern::AttrOrientation, data.GetOrientation());
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation());
doc->SetAttribute(domData, VAbstractPattern::AttrTilt, data.GetTilt());
doc->SetAttribute(domData, VAbstractPattern::AttrFoldPosition, data.GetFoldPosition());
doc->SetAttribute(domData, VAbstractPattern::AttrQuantity, data.GetQuantity());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible());
doc->SetAttribute(domData, VAbstractPattern::AttrOnFold, data.IsOnFold());
doc->SetAttribute(domData, AttrMx, data.GetPos().x());
doc->SetAttribute(domData, AttrMy, data.GetPos().y());
doc->SetAttribute(domData, VAbstractPattern::AttrWidth, data.GetLabelWidth());
@ -337,19 +344,8 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
domData.removeAttribute(AttrBottomRightPin);
}
for (int i = 0; i < data.GetMCPCount(); ++i)
{
const MaterialCutPlacement mcp = data.GetMCP(i);
QDomElement domMCP = doc->createElement(VAbstractPattern::TagMCP);
doc->SetAttribute(domMCP, VAbstractPattern::AttrMaterial, int(mcp.m_eMaterial));
if (mcp.m_eMaterial == MaterialType::mtUserDefined)
{
doc->SetAttribute(domMCP, VAbstractPattern::AttrUserDefined, mcp.m_qsMaterialUserDef);
}
doc->SetAttribute(domMCP, VAbstractPattern::AttrCutNumber, mcp.m_iCutNumber);
doc->SetAttribute(domMCP, VAbstractPattern::AttrPlacement, int(mcp.m_ePlacement));
domData.appendChild(domMCP);
}
doc->SetLabelTemplate(domData, data.GetLabelTemplate());
domElement.appendChild(domData);
}
@ -358,7 +354,7 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE
{
QDomElement domData = doc->createElement(VAbstractPattern::TagPatternInfo);
const VPatternLabelData& geom = piece.GetPatternInfo();
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible() == true ? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible());
doc->SetAttribute(domData, AttrMx, geom.GetPos().x());
doc->SetAttribute(domData, AttrMy, geom.GetPos().y());
doc->SetAttribute(domData, VAbstractPattern::AttrWidth, geom.GetLabelWidth());
@ -402,7 +398,7 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle
// grainline
QDomElement domData = doc->createElement(VAbstractPattern::TagGrainline);
const VGrainlineData& glGeom = piece.GetGrainlineGeometry();
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible() == true ? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible());
doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x());
doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y());
doc->SetAttribute(domData, AttrLength, glGeom.GetLength());
@ -578,7 +574,7 @@ void VToolSeamAllowance::UpdatePatternInfo()
if (PrepareLabelData(geom, m_patternInfo, pos, labelAngle))
{
m_patternInfo->UpdateData(doc, VContainer::size(), VContainer::height());
m_patternInfo->UpdateData(doc);
UpdateLabelItem(m_patternInfo, pos, labelAngle);
}
}
@ -1151,7 +1147,7 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data,
connect(m_grainLine, &VGrainlineItem::SignalResized, this, &VToolSeamAllowance::SaveResizeGrainline);
connect(m_grainLine, &VGrainlineItem::SignalRotated, this, &VToolSeamAllowance::SaveRotateGrainline);
connect(doc, &VAbstractPattern::patternChanged, this, &VToolSeamAllowance::UpdatePatternInfo);
connect(doc, &VAbstractPattern::UpdatePatternLabel, this, &VToolSeamAllowance::UpdatePatternInfo);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolSeamAllowance::UpdateDetailLabel);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolSeamAllowance::UpdatePatternInfo);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolSeamAllowance::UpdateGrainline);

View File

@ -0,0 +1,76 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/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 "vlineedit.h"
//---------------------------------------------------------------------------------------------------------------------
VLineEdit::VLineEdit(QWidget *parent)
: QLineEdit(parent),
m_selectOnMousePress(false)
{}
//---------------------------------------------------------------------------------------------------------------------
VLineEdit::VLineEdit(const QString &contents, QWidget *parent)
: QLineEdit(contents, parent),
m_selectOnMousePress(false)
{}
//---------------------------------------------------------------------------------------------------------------------
void VLineEdit::focusInEvent(QFocusEvent *e)
{
QLineEdit::focusInEvent(e);
selectAll();
m_selectOnMousePress = true;
}
//---------------------------------------------------------------------------------------------------------------------
void VLineEdit::focusOutEvent(QFocusEvent *e)
{
const int start = selectionStart();
const int selectionLength = selectedText().length();
const bool wasTextSelected = hasSelectedText();
QLineEdit::focusOutEvent(e);
if (wasTextSelected)
{
setSelection(start, selectionLength);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VLineEdit::mousePressEvent(QMouseEvent *e)
{
QLineEdit::mousePressEvent(e);
if(m_selectOnMousePress)
{
selectAll();
m_selectOnMousePress = false;
}
}

View File

@ -0,0 +1,50 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 8, 2017
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/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 VLINEEDIT_H
#define VLINEEDIT_H
#include <QLineEdit>
class VLineEdit : public QLineEdit
{
Q_OBJECT
public:
VLineEdit(QWidget * parent = nullptr);
VLineEdit(const QString &contents, QWidget *parent = nullptr);
protected:
virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VLineEdit)
bool m_selectOnMousePress;
};
#endif // VLINEEDIT_H

View File

@ -164,8 +164,8 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
const TextLine& tl = m_tm.GetSourceLine(i);
fnt.setPixelSize(m_tm.GetFont().pixelSize() + tl.m_iFontSize);
fnt.setWeight(tl.m_eFontWeight);
fnt.setStyle(tl.m_eStyle);
fnt.setBold(tl.bold);
fnt.setItalic(tl.italic);
QString qsText = tl.m_qsText;
QFontMetrics fm(fnt);
@ -235,25 +235,6 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VTextGraphicsItem::AddLine adds a line of text to the label list.
* @param tl line of text to add
*/
void VTextGraphicsItem::AddLine(const TextLine& tl)
{
m_tm.AddSourceLine(tl);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VTextGraphicsItem::Clear deletes all the label texts
*/
void VTextGraphicsItem::Clear()
{
m_tm.ClearSourceLines();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VTextGraphicsItem::SetSize Tries to set the label size to (fW, fH). If any of those is too small, the label
@ -362,9 +343,9 @@ void VTextGraphicsItem::UpdateData(const QString &qsName, const VPieceLabelData
* @brief VTextGraphicsItem::UpdateData Updates the pattern label
* @param pDoc pointer to the pattern object
*/
void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight)
void VTextGraphicsItem::UpdateData(VAbstractPattern* pDoc)
{
m_tm.Update(pDoc, dSize, dHeight);
m_tm.Update(pDoc);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -63,12 +63,10 @@ public:
void SetFont(const QFont& fnt);
int GetFontSize() const;
void AddLine(const TextLine& tl);
void Clear();
void SetSize(qreal fW, qreal fH);
bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const;
void UpdateData(const QString& qsName, const VPieceLabelData& data);
void UpdateData(const VAbstractPattern* pDoc, qreal dSize, qreal dHeight);
void UpdateData(VAbstractPattern* pDoc);
int GetTextLines() const;
protected:

View File

@ -21,7 +21,8 @@ SOURCES += \
$$PWD/vcurvepathitem.cpp \
$$PWD/global.cpp \
$$PWD/vscenepoint.cpp \
$$PWD/scalesceneitems.cpp
$$PWD/scalesceneitems.cpp \
$$PWD/vlineedit.cpp
*msvc*:SOURCES += $$PWD/stable.cpp
@ -46,4 +47,5 @@ HEADERS += \
$$PWD/vcurvepathitem.h \
$$PWD/global.h \
$$PWD/vscenepoint.h \
$$PWD/scalesceneitems.h
$$PWD/scalesceneitems.h \
$$PWD/vlineedit.h

View File

@ -224,6 +224,22 @@ void TST_BuitInRegExp::TestCheckInternalVaribleRegExp()
}
}
//---------------------------------------------------------------------------------------------------------------------
void TST_BuitInRegExp::TestTemplatePlaceholders()
{
QSet<QString> originals;
QSet<QString> translations;
for (int i = 0; i < labelTemplatePlaceholders.size(); ++i)
{
originals.insert(labelTemplatePlaceholders.at(i));
translations.insert(m_trMs->PlaceholderToUser(labelTemplatePlaceholders.at(i)));
}
QCOMPARE(originals.size(), labelTemplatePlaceholders.size()); // All tags are unique
QCOMPARE(translations.size(), labelTemplatePlaceholders.size()); // All translated tags are unique
}
//---------------------------------------------------------------------------------------------------------------------
void TST_BuitInRegExp::cleanupTestCase()
{

View File

@ -61,6 +61,7 @@ private slots:
void TestCheckUnderlineExists();
void TestCheckInternalVaribleRegExp_data();
void TestCheckInternalVaribleRegExp();
void TestTemplatePlaceholders();
void cleanupTestCase();
private:

View File

@ -250,7 +250,11 @@ void TST_NameRegExp::TestCorrectOrderMeasurement_data()
QTest::newRow("G09") << hipCirc_M << "hip_circ";
QTest::newRow("G10") << neckArcF_M << "neck_arc_f";
QTest::newRow("G11") << highbustArcF_M << "highbust_arc_f";
// size and bust_arc_f are synonyms
QTest::newRow("G12") << bustArcF_M << "bust_arc_f";
QTest::newRow("G12") << size_M << "size";
QTest::newRow("G13") << lowbustArcF_M << "lowbust_arc_f";
QTest::newRow("G14") << ribArcF_M << "rib_arc_f";
QTest::newRow("G15") << waistArcF_M << "waist_arc_f";