Added more placeholders.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-14 15:11:14 +03:00
parent 67cee35426
commit 89ed92e93f
14 changed files with 151 additions and 65 deletions

View File

@ -46,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),
@ -66,8 +65,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
deleteAction(nullptr),
changeImageAction(nullptr),
saveImageAction(nullptr),
showImageAction(nullptr),
m_filePath(filePath)
showImageAction(nullptr)
{
ui->setupUi(this);
@ -77,7 +75,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
qApp->ValentinaSettings()->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."));
@ -85,15 +83,15 @@ 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"));
@ -874,6 +872,6 @@ void DialogPatternProperties::EditLabel()
}
}
DialogEditLabel editor;
DialogEditLabel editor(doc);
editor.exec();
}

View File

@ -46,8 +46,7 @@ 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();
@ -83,7 +82,6 @@ private:
QAction *changeImageAction;
QAction *saveImageAction;
QAction *showImageAction;
const QString &m_filePath;
void SetHeightsChecked(bool enabled);
void SetSizesChecked(bool enabled);

View File

@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">

View File

@ -1519,10 +1519,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->SetPath(RelativeMPath(qApp->GetPPath(), mPath));
watcher->addPath(mPath);
PatternChangesWereSaved(false);
ui->actionEditCurrent->setEnabled(true);
@ -1568,10 +1568,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->SetPath(RelativeMPath(qApp->GetPPath(), mPath));
watcher->addPath(mPath);
PatternChangesWereSaved(false);
ui->actionEditCurrent->setEnabled(true);
@ -1607,7 +1607,7 @@ void MainWindow::UnloadMeasurements()
if (doc->ListMeasurements().isEmpty())
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
watcher->removePath(AbsoluteMPath(qApp->GetPPath(), doc->MPath()));
doc->SetPath(QString());
PatternChangesWereSaved(false);
ui->actionEditCurrent->setEnabled(false);
@ -1628,7 +1628,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 +1700,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 +2530,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 +2639,7 @@ bool MainWindow::SaveAs()
*/
bool MainWindow::Save()
{
if (curFile.isEmpty() || patternReadOnly)
if (qApp->GetPPath().isEmpty() || patternReadOnly)
{
return SaveAs();
}
@ -2646,7 +2653,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 +2672,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 +2682,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 +2697,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 +2761,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 +2814,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 +3168,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 +3198,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,8 +3383,8 @@ 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));
}
@ -3407,9 +3416,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 +3433,10 @@ void MainWindow::AutoSavePattern()
void MainWindow::setCurrentFile(const QString &fileName)
{
qCDebug(vMainWindow, "Set current name to \"%s\"", qUtf8Printable(fileName));
curFile = fileName;
qApp->SetPPath(fileName);
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 +3521,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 +3858,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 +3981,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()));
@ -4813,7 +4822,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 +4865,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 +4978,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 +4996,7 @@ QString MainWindow::GetMeasurementFileName()
else
{
QString shownName(" [");
shownName += StrippedName(AbsoluteMPath(curFile, doc->MPath()));
shownName += StrippedName(AbsoluteMPath(qApp->GetPPath(), doc->MPath()));
if(mChanges)
{
@ -5003,12 +5012,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 +5032,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

@ -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

@ -111,6 +111,16 @@ 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 cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");

View File

@ -353,6 +353,16 @@ 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 cursorArrowOpenHand;
extern const QString cursorArrowCloseHand;

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

@ -459,6 +459,16 @@ 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"));
}
#undef translate

View File

@ -34,6 +34,8 @@
#include "vtranslatemeasurements.h"
#define trPL(pl) QLatin1String("%") + qApp->TrVars()->PlaceholderToUser((pl)) + QLatin1String("%")
class VTranslateVars : public VTranslateMeasurements
{
public:

View File

@ -31,7 +31,9 @@
#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 <QDir>
#include <QMessageBox>
@ -40,10 +42,11 @@
#include <QDate>
//---------------------------------------------------------------------------------------------------------------------
DialogEditLabel::DialogEditLabel(QWidget *parent)
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);
@ -429,7 +432,7 @@ void DialogEditLabel::InitPlaceholdersMenu()
{
auto value = i.value();
QAction *action = m_placeholdersMenu->addAction(value.first);
action->setData(i.key());
action->setData(trPL(i.key()));
connect(action, &QAction::triggered, this, &DialogEditLabel::InsertPlaceholder);
++i;
}
@ -439,7 +442,39 @@ void DialogEditLabel::InitPlaceholdersMenu()
void DialogEditLabel::InitPlaceholders()
{
QLocale locale(qApp->Settings()->GetLocale());
m_placeholders.insert("%date%", qMakePair(tr("Date"), locale.toString(QDate::currentDate(), "dd MMMM yyyy")));
m_placeholders.insert(pl_date, qMakePair(tr("Date"), locale.toString(QDate::currentDate())));
m_placeholders.insert(pl_time, qMakePair(tr("Time"), locale.toString(QTime::currentTime())));
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()).fileName();
m_placeholders.insert(pl_pFileName, qMakePair(tr("Pattern file name"), patternFilePath));
const QString measurementsFilePath = QFileInfo(m_doc->MPath()).fileName();
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)
{
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));
}
//---------------------------------------------------------------------------------------------------------------------
@ -448,7 +483,7 @@ QString DialogEditLabel::ReplacePlaceholders(QString line) const
auto i = m_placeholders.constBegin();
while (i != m_placeholders.constEnd())
{
line.replace(i.key(), i.value().second);
line.replace(QChar('%')+i.key()+QChar('%'), i.value().second);
++i;
}
return line;

View File

@ -39,13 +39,14 @@ namespace Ui
class VLabelTemplateLine;
class QMenu;
class VAbstractPattern;
class DialogEditLabel : public QDialog
{
Q_OBJECT
public:
explicit DialogEditLabel(QWidget *parent = nullptr);
explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr);
virtual ~DialogEditLabel();
private slots:
@ -65,6 +66,7 @@ private:
Q_DISABLE_COPY(DialogEditLabel)
Ui::DialogEditLabel *ui;
QMenu *m_placeholdersMenu;
VAbstractPattern *m_doc;
QMap<QString, QPair<QString, QString>> m_placeholders;