Extend placeholders list with list of measurements.
This commit is contained in:
parent
92c3f75e02
commit
d10f20f399
|
@ -495,7 +495,7 @@ void DialogPatternProperties::EditLabel()
|
|||
}
|
||||
}
|
||||
|
||||
DialogEditLabel editor(doc);
|
||||
DialogEditLabel editor(doc, pattern);
|
||||
|
||||
templateDataChanged ? editor.SetTemplate(templateLines) : editor.SetTemplate(doc->GetPatternLabelTemplate());
|
||||
|
||||
|
|
|
@ -4947,7 +4947,7 @@ void MainWindow::CreateActions()
|
|||
|
||||
connect(ui->actionLabelTemplateEditor, &QAction::triggered, this, [this]()
|
||||
{
|
||||
DialogEditLabel editor(doc);
|
||||
DialogEditLabel editor(doc, pattern);
|
||||
editor.exec();
|
||||
});
|
||||
|
||||
|
|
|
@ -697,7 +697,7 @@ void VLayoutPiece::SetPieceText(const QString& qsName, const VPieceLabelData& da
|
|||
// generate text
|
||||
d->m_tmDetail.SetFont(font);
|
||||
d->m_tmDetail.SetFontSize(data.GetFontSize());
|
||||
d->m_tmDetail.Update(qsName, data);
|
||||
d->m_tmDetail.Update(qsName, data, pattern);
|
||||
// this will generate the lines of text
|
||||
d->m_tmDetail.SetFontSize(data.GetFontSize());
|
||||
d->m_tmDetail.FitFontSize(labelWidth, labelHeight);
|
||||
|
@ -754,7 +754,7 @@ void VLayoutPiece::SetPatternInfo(VAbstractPattern* pDoc, const VPatternLabelDat
|
|||
d->m_tmPattern.SetFont(font);
|
||||
d->m_tmPattern.SetFontSize(geom.GetFontSize());
|
||||
|
||||
d->m_tmPattern.Update(pDoc);
|
||||
d->m_tmPattern.Update(pDoc, pattern);
|
||||
|
||||
// generate lines of text
|
||||
d->m_tmPattern.SetFontSize(geom.GetFontSize());
|
||||
|
|
|
@ -166,9 +166,10 @@ namespace
|
|||
{
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
|
||||
QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data)
|
||||
{
|
||||
SCASSERT(doc != nullptr)
|
||||
SCASSERT(data != nullptr)
|
||||
|
||||
QMap<QString, QString> placeholders;
|
||||
|
||||
|
@ -233,6 +234,15 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
|
|||
placeholders.insert(pl_userMaterial + number, value);
|
||||
}
|
||||
|
||||
const QMap<QString, QSharedPointer<VMeasurement> > measurements = data->DataMeasurements();
|
||||
auto i = measurements.constBegin();
|
||||
while (i != measurements.constEnd())
|
||||
{
|
||||
QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText();
|
||||
placeholders.insert(pl_measurement + i.key(), QString::number(*i.value()->GetValue()));
|
||||
++i;
|
||||
}
|
||||
|
||||
// Piece tags
|
||||
placeholders.insert(pl_pLetter, QString());
|
||||
placeholders.insert(pl_pAnnotation, QString());
|
||||
|
@ -474,11 +484,11 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
|
|||
* @param qsName detail name
|
||||
* @param data reference to the detail data
|
||||
*/
|
||||
void VTextManager::Update(const QString& qsName, const VPieceLabelData& data)
|
||||
void VTextManager::Update(const QString& qsName, const VPieceLabelData& data, const VContainer *pattern)
|
||||
{
|
||||
m_liLines.clear();
|
||||
|
||||
QMap<QString, QString> placeholders = PreparePlaceholders(qApp->getCurrentDocument());
|
||||
QMap<QString, QString> placeholders = PreparePlaceholders(qApp->getCurrentDocument(), pattern);
|
||||
InitPiecePlaceholders(placeholders, qsName, data);
|
||||
|
||||
QVector<VLabelTemplateLine> lines = data.GetLabelTemplate();
|
||||
|
@ -496,7 +506,7 @@ 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(VAbstractPattern *pDoc)
|
||||
void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern)
|
||||
{
|
||||
m_liLines.clear();
|
||||
|
||||
|
@ -508,7 +518,7 @@ void VTextManager::Update(VAbstractPattern *pDoc)
|
|||
return; // Nothing to parse
|
||||
}
|
||||
|
||||
const QMap<QString, QString> placeholders = PreparePlaceholders(pDoc);
|
||||
const QMap<QString, QString> placeholders = PreparePlaceholders(pDoc, pattern);
|
||||
|
||||
for (int i=0; i<lines.size(); ++i)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
class VPieceLabelData;
|
||||
class VAbstractPattern;
|
||||
class VContainer;
|
||||
|
||||
#define MIN_FONT_SIZE 5
|
||||
#define MAX_FONT_SIZE 128
|
||||
|
@ -88,8 +89,8 @@ public:
|
|||
int GetSourceLinesCount() const;
|
||||
const TextLine& GetSourceLine(int i) const;
|
||||
|
||||
void Update(const QString& qsName, const VPieceLabelData& data);
|
||||
void Update(VAbstractPattern* pDoc);
|
||||
void Update(const QString& qsName, const VPieceLabelData& data, const VContainer *pattern);
|
||||
void Update(VAbstractPattern* pDoc, const VContainer *pattern);
|
||||
|
||||
friend QDataStream& operator<<(QDataStream& dataStream, const VTextManager& data);
|
||||
friend QDataStream& operator>>(QDataStream& dataStream, VTextManager& data);
|
||||
|
|
|
@ -181,34 +181,45 @@ 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 QString pl_measurement = QStringLiteral("measurement_");
|
||||
|
||||
const QStringList labelTemplatePlaceholders = QStringList() << pl_size
|
||||
<< pl_height
|
||||
<< pl_date
|
||||
<< pl_time
|
||||
<< pl_patternName
|
||||
<< pl_patternNumber
|
||||
<< pl_author
|
||||
<< pl_customer
|
||||
<< pl_userMaterial
|
||||
<< 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 QStringList labelTemplatePlaceholders = {
|
||||
pl_size,
|
||||
pl_height,
|
||||
pl_hip,
|
||||
pl_waist,
|
||||
pl_date,
|
||||
pl_time,
|
||||
pl_birthDate,
|
||||
pl_patternName,
|
||||
pl_patternNumber,
|
||||
pl_author,
|
||||
pl_customer,
|
||||
pl_email,
|
||||
pl_userMaterial,
|
||||
pl_pExt,
|
||||
pl_pUnits,
|
||||
pl_pFileName,
|
||||
pl_mFileName,
|
||||
pl_mExt,
|
||||
pl_mUnits,
|
||||
pl_mSizeUnits,
|
||||
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,
|
||||
pl_measurement
|
||||
};
|
||||
|
||||
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
|
||||
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
|
||||
|
|
|
@ -435,6 +435,7 @@ extern const QString pl_mInterfacing;
|
|||
extern const QString pl_mInterlining;
|
||||
extern const QString pl_wCut;
|
||||
extern const QString pl_wOnFold;
|
||||
extern const QString pl_measurement;
|
||||
|
||||
// Don't forget to syncronize with XSD schema.
|
||||
const int userMaterialPlaceholdersQuantity = 20;
|
||||
|
|
|
@ -541,17 +541,24 @@ void VTranslateVars::InitPlaceholder()
|
|||
{
|
||||
placeholders.insert(pl_size, translate("VTranslateVars", "size", "placeholder"));
|
||||
placeholders.insert(pl_height, translate("VTranslateVars", "height", "placeholder"));
|
||||
placeholders.insert(pl_hip, translate("VTranslateVars", "hip", "placeholder"));
|
||||
placeholders.insert(pl_waist, translate("VTranslateVars", "waist", "placeholder"));
|
||||
placeholders.insert(pl_date, translate("VTranslateVars", "date", "placeholder"));
|
||||
placeholders.insert(pl_time, translate("VTranslateVars", "time", "placeholder"));
|
||||
placeholders.insert(pl_birthDate, translate("VTranslateVars", "birthDate", "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_email, translate("VTranslateVars", "email", "placeholder"));
|
||||
placeholders.insert(pl_userMaterial, translate("VTranslateVars", "userMaterial", "placeholder"));
|
||||
placeholders.insert(pl_pExt, translate("VTranslateVars", "pExt", "placeholder"));
|
||||
placeholders.insert(pl_pUnits, translate("VTranslateVars", "pUnits", "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_mUnits, translate("VTranslateVars", "mUnits", "placeholder"));
|
||||
placeholders.insert(pl_mSizeUnits, translate("VTranslateVars", "mSizeUnits", "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"));
|
||||
|
@ -566,6 +573,7 @@ void VTranslateVars::InitPlaceholder()
|
|||
placeholders.insert(pl_mInterlining, translate("VTranslateVars", "mInterlining", "placeholder"));
|
||||
placeholders.insert(pl_wCut, translate("VTranslateVars", "wCut", "placeholder"));
|
||||
placeholders.insert(pl_wOnFold, translate("VTranslateVars", "wOnFold", "placeholder"));
|
||||
placeholders.insert(pl_measurement, translate("VTranslateVars", "measurement", "placeholder"));
|
||||
}
|
||||
|
||||
#undef translate
|
||||
|
|
|
@ -45,11 +45,12 @@
|
|||
#include <QDate>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogEditLabel::DialogEditLabel(VAbstractPattern *doc, QWidget *parent)
|
||||
DialogEditLabel::DialogEditLabel(VAbstractPattern *doc, const VContainer *data, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui::DialogEditLabel),
|
||||
m_placeholdersMenu(new QMenu(this)),
|
||||
m_doc(doc),
|
||||
m_data(data),
|
||||
m_placeholders()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -555,6 +556,16 @@ void DialogEditLabel::InitPlaceholders()
|
|||
m_placeholders.insert(pl_userMaterial + number, qMakePair(materialDescription + number, value));
|
||||
}
|
||||
|
||||
const QMap<QString, QSharedPointer<VMeasurement> > measurements = m_data->DataMeasurements();
|
||||
auto i = measurements.constBegin();
|
||||
while (i != measurements.constEnd())
|
||||
{
|
||||
QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText();
|
||||
m_placeholders.insert(pl_measurement + i.key(), qMakePair(tr("Measurement: %1").arg(description),
|
||||
QString::number(*i.value()->GetValue())));
|
||||
++i;
|
||||
}
|
||||
|
||||
// Piece tags
|
||||
m_placeholders.insert(pl_pLetter, qMakePair(tr("Piece letter"), QString()));
|
||||
m_placeholders.insert(pl_pAnnotation, qMakePair(tr("Piece annotation"), QString()));
|
||||
|
|
|
@ -42,13 +42,14 @@ struct VLabelTemplateLine;
|
|||
class QMenu;
|
||||
class VAbstractPattern;
|
||||
class VPiece;
|
||||
class VContainer;
|
||||
|
||||
class DialogEditLabel : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr);
|
||||
explicit DialogEditLabel(VAbstractPattern *doc, const VContainer *data, QWidget *parent = nullptr);
|
||||
virtual ~DialogEditLabel();
|
||||
|
||||
QVector<VLabelTemplateLine> GetTemplate() const;
|
||||
|
@ -75,6 +76,7 @@ private:
|
|||
Ui::DialogEditLabel *ui;
|
||||
QMenu *m_placeholdersMenu;
|
||||
VAbstractPattern *m_doc;
|
||||
const VContainer *m_data;
|
||||
|
||||
QMap<QString, QPair<QString, QString>> m_placeholders;
|
||||
|
||||
|
|
|
@ -2428,7 +2428,7 @@ void DialogSeamAllowance::PatternPinPointChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::EditLabel()
|
||||
{
|
||||
DialogEditLabel editor(qApp->getCurrentDocument());
|
||||
DialogEditLabel editor(qApp->getCurrentDocument(), data);
|
||||
editor.SetTemplate(m_templateLines);
|
||||
editor.SetPiece(GetPiece());
|
||||
|
||||
|
|
|
@ -614,7 +614,7 @@ void VToolSeamAllowance::UpdateDetailLabel()
|
|||
|
||||
if (PrepareLabelData(labelData, pins, m_dataLabel, pos, labelAngle))
|
||||
{
|
||||
m_dataLabel->UpdateData(detail.GetName(), labelData);
|
||||
m_dataLabel->UpdateData(detail.GetName(), labelData, getData());
|
||||
UpdateLabelItem(m_dataLabel, pos, labelAngle);
|
||||
}
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ void VToolSeamAllowance::UpdatePatternInfo()
|
|||
|
||||
if (PrepareLabelData(geom, pins, m_patternInfo, pos, labelAngle))
|
||||
{
|
||||
m_patternInfo->UpdateData(doc);
|
||||
m_patternInfo->UpdateData(doc, getData());
|
||||
UpdateLabelItem(m_patternInfo, pos, labelAngle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,9 +317,9 @@ bool VTextGraphicsItem::IsContained(QRectF rectBB, qreal dRot, qreal &dX, qreal
|
|||
* @param qsName name of detail
|
||||
* @param data reference to VPatternPieceData
|
||||
*/
|
||||
void VTextGraphicsItem::UpdateData(const QString &qsName, const VPieceLabelData &data)
|
||||
void VTextGraphicsItem::UpdateData(const QString &qsName, const VPieceLabelData &data, const VContainer *pattern)
|
||||
{
|
||||
m_tm.Update(qsName, data);
|
||||
m_tm.Update(qsName, data, pattern);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -327,9 +327,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(VAbstractPattern* pDoc)
|
||||
void VTextGraphicsItem::UpdateData(VAbstractPattern* pDoc, const VContainer *pattern)
|
||||
{
|
||||
m_tm.Update(pDoc);
|
||||
m_tm.Update(pDoc, pattern);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -65,8 +65,8 @@ public:
|
|||
int GetFontSize() const;
|
||||
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(VAbstractPattern* pDoc);
|
||||
void UpdateData(const QString& qsName, const VPieceLabelData& data, const VContainer *pattern);
|
||||
void UpdateData(VAbstractPattern* pDoc, const VContainer *pattern);
|
||||
int GetTextLines() const;
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue
Block a user