Remove caching label placeholders.
This commit is contained in:
parent
57f8a56830
commit
0225ade6fc
|
@ -926,7 +926,7 @@ void VAbstractPattern::SetMPath(const QString &path)
|
||||||
RemoveDimensions();
|
RemoveDimensions();
|
||||||
}
|
}
|
||||||
m_MPath = path;
|
m_MPath = path;
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1039,7 +1039,7 @@ void VAbstractPattern::SetPatternName(const QString &qsName)
|
||||||
m_patternName = qsName;
|
m_patternName = qsName;
|
||||||
CheckTagExists(TagPatternName);
|
CheckTagExists(TagPatternName);
|
||||||
setTagText(TagPatternName, m_patternName);
|
setTagText(TagPatternName, m_patternName);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1056,7 +1056,7 @@ void VAbstractPattern::SetCompanyName(const QString &qsName)
|
||||||
m_companyName = qsName;
|
m_companyName = qsName;
|
||||||
CheckTagExists(TagCompanyName);
|
CheckTagExists(TagCompanyName);
|
||||||
setTagText(TagCompanyName, m_companyName);
|
setTagText(TagCompanyName, m_companyName);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1073,7 +1073,7 @@ void VAbstractPattern::SetPatternNumber(const QString &qsNum)
|
||||||
m_patternNumber = qsNum;
|
m_patternNumber = qsNum;
|
||||||
CheckTagExists(TagPatternNum);
|
CheckTagExists(TagPatternNum);
|
||||||
setTagText(TagPatternNum, m_patternNumber);
|
setTagText(TagPatternNum, m_patternNumber);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1089,7 +1089,7 @@ void VAbstractPattern::SetCustomerName(const QString &qsName)
|
||||||
{
|
{
|
||||||
CheckTagExists(TagCustomerName);
|
CheckTagExists(TagCustomerName);
|
||||||
setTagText(TagCustomerName, qsName);
|
setTagText(TagCustomerName, qsName);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1105,7 +1105,7 @@ void VAbstractPattern::SetCustomerBirthDate(const QDate &date)
|
||||||
{
|
{
|
||||||
CheckTagExists(TagCustomerBirthDate);
|
CheckTagExists(TagCustomerBirthDate);
|
||||||
setTagText(TagCustomerBirthDate, date.toString("yyyy-MM-dd"));
|
setTagText(TagCustomerBirthDate, date.toString("yyyy-MM-dd"));
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1121,7 @@ void VAbstractPattern::SetCustomerEmail(const QString &email)
|
||||||
{
|
{
|
||||||
CheckTagExists(TagCustomerEmail);
|
CheckTagExists(TagCustomerEmail);
|
||||||
setTagText(TagCustomerEmail, email);
|
setTagText(TagCustomerEmail, email);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1138,7 @@ void VAbstractPattern::SetLabelDateFormat(const QString &format)
|
||||||
m_labelDateFormat = format;
|
m_labelDateFormat = format;
|
||||||
QDomElement tag = CheckTagExists(TagPatternLabel);
|
QDomElement tag = CheckTagExists(TagPatternLabel);
|
||||||
SetAttribute(tag, AttrDateFormat, m_labelDateFormat);
|
SetAttribute(tag, AttrDateFormat, m_labelDateFormat);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1163,7 @@ void VAbstractPattern::SetLabelTimeFormat(const QString &format)
|
||||||
{
|
{
|
||||||
QDomElement tag = CheckTagExists(TagPatternLabel);
|
QDomElement tag = CheckTagExists(TagPatternLabel);
|
||||||
SetAttribute(tag, AttrTimeFormat, format);
|
SetAttribute(tag, AttrTimeFormat, format);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1175,7 +1175,7 @@ void VAbstractPattern::SetPatternLabelTemplate(const QVector<VLabelTemplateLine>
|
||||||
RemoveAllChildren(tag);
|
RemoveAllChildren(tag);
|
||||||
SetLabelTemplate(tag, lines);
|
SetLabelTemplate(tag, lines);
|
||||||
patternLabelLines = lines;
|
patternLabelLines = lines;
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -1208,7 +1208,7 @@ auto VAbstractPattern::SetWatermarkPath(const QString &path) -> bool
|
||||||
parent.removeChild(tag);
|
parent.removeChild(tag);
|
||||||
|
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
m_watermarkPath = path;
|
m_watermarkPath = path;
|
||||||
modified = true;
|
modified = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1217,7 +1217,7 @@ auto VAbstractPattern::SetWatermarkPath(const QString &path) -> bool
|
||||||
if (setTagText(tag, path))
|
if (setTagText(tag, path))
|
||||||
{
|
{
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
m_watermarkPath = path;
|
m_watermarkPath = path;
|
||||||
modified = true;
|
modified = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1242,7 +1242,7 @@ void VAbstractPattern::SetPatternMaterials(const QMap<int, QString> &materials)
|
||||||
RemoveAllChildren(tag);
|
RemoveAllChildren(tag);
|
||||||
SetMaterials(tag, materials);
|
SetMaterials(tag, materials);
|
||||||
patternMaterials = materials;
|
patternMaterials = materials;
|
||||||
patternLabelWasChanged = true;
|
SetPatternWasChanged(true);
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,18 +273,6 @@ auto operator>>(QDataStream &dataStream, VTextManager &data) -> QDataStream &
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
QT_WARNING_PUSH
|
|
||||||
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(QDateTime, placeholdersExpirationTime) // NOLINT
|
|
||||||
|
|
||||||
using VPlaceholdersCache = QMap<QString, QString>;
|
|
||||||
Q_GLOBAL_STATIC(VPlaceholdersCache, placeholdersCache) // NOLINT
|
|
||||||
|
|
||||||
QT_WARNING_POP
|
|
||||||
|
|
||||||
const qint64 placeholdersExpirationTimeout = 15; // seconds
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void PrepareMeasurementsPlaceholders(const VContainer *data, QMap<QString, QString> &placeholders)
|
void PrepareMeasurementsPlaceholders(const VContainer *data, QMap<QString, QString> &placeholders)
|
||||||
{
|
{
|
||||||
|
@ -455,12 +443,6 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data, bo
|
||||||
SCASSERT(doc != nullptr)
|
SCASSERT(doc != nullptr)
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
|
|
||||||
if (placeholdersExpirationTime->isValid() && QDateTime::currentDateTime() <= *placeholdersExpirationTime)
|
|
||||||
{
|
|
||||||
*placeholdersExpirationTime = QDateTime::currentDateTime().addSecs(placeholdersExpirationTimeout);
|
|
||||||
return *placeholdersCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, QString> placeholders;
|
QMap<QString, QString> placeholders;
|
||||||
|
|
||||||
// Pattern tags
|
// Pattern tags
|
||||||
|
@ -517,9 +499,6 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data, bo
|
||||||
placeholders.insert(pl_mInterlining, phTr->translate("Placeholder", "Interlining"));
|
placeholders.insert(pl_mInterlining, phTr->translate("Placeholder", "Interlining"));
|
||||||
placeholders.insert(pl_wCut, phTr->translate("Placeholder", "Cut"));
|
placeholders.insert(pl_wCut, phTr->translate("Placeholder", "Cut"));
|
||||||
|
|
||||||
*placeholdersCache = placeholders;
|
|
||||||
*placeholdersExpirationTime = QDateTime::currentDateTime().addSecs(placeholdersExpirationTimeout);
|
|
||||||
|
|
||||||
return placeholders;
|
return placeholders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,7 +881,7 @@ void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VTextManager::BreakTextIntoLines(const QString &text, const QFont &font, int maxWidth) const -> QStringList
|
auto VTextManager::BreakTextIntoLines(const QString &text, const QFont &font, int maxWidth) -> QStringList
|
||||||
{
|
{
|
||||||
QFontMetrics fontMetrics(font);
|
QFontMetrics fontMetrics(font);
|
||||||
QStringList words = text.split(' ');
|
QStringList words = text.split(' ');
|
||||||
|
|
|
@ -124,7 +124,7 @@ private:
|
||||||
static const quint32 streamHeader;
|
static const quint32 streamHeader;
|
||||||
static const quint16 classVersion;
|
static const quint16 classVersion;
|
||||||
|
|
||||||
auto BreakTextIntoLines(const QString &text, const QFont &font, int maxWidth) const -> QStringList;
|
static auto BreakTextIntoLines(const QString &text, const QFont &font, int maxWidth) -> QStringList;
|
||||||
auto BreakTextIntoLines(const QString &text, const VSvgFont &font, int maxWidth, qreal penWidth) const
|
auto BreakTextIntoLines(const QString &text, const VSvgFont &font, int maxWidth, qreal penWidth) const
|
||||||
-> QStringList;
|
-> QStringList;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user