Remove caching label placeholders.
This commit is contained in:
parent
57f8a56830
commit
0225ade6fc
|
@ -926,7 +926,7 @@ void VAbstractPattern::SetMPath(const QString &path)
|
|||
RemoveDimensions();
|
||||
}
|
||||
m_MPath = path;
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1039,7 +1039,7 @@ void VAbstractPattern::SetPatternName(const QString &qsName)
|
|||
m_patternName = qsName;
|
||||
CheckTagExists(TagPatternName);
|
||||
setTagText(TagPatternName, m_patternName);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1056,7 +1056,7 @@ void VAbstractPattern::SetCompanyName(const QString &qsName)
|
|||
m_companyName = qsName;
|
||||
CheckTagExists(TagCompanyName);
|
||||
setTagText(TagCompanyName, m_companyName);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1073,7 +1073,7 @@ void VAbstractPattern::SetPatternNumber(const QString &qsNum)
|
|||
m_patternNumber = qsNum;
|
||||
CheckTagExists(TagPatternNum);
|
||||
setTagText(TagPatternNum, m_patternNumber);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1089,7 +1089,7 @@ void VAbstractPattern::SetCustomerName(const QString &qsName)
|
|||
{
|
||||
CheckTagExists(TagCustomerName);
|
||||
setTagText(TagCustomerName, qsName);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1105,7 +1105,7 @@ void VAbstractPattern::SetCustomerBirthDate(const QDate &date)
|
|||
{
|
||||
CheckTagExists(TagCustomerBirthDate);
|
||||
setTagText(TagCustomerBirthDate, date.toString("yyyy-MM-dd"));
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1121,7 +1121,7 @@ void VAbstractPattern::SetCustomerEmail(const QString &email)
|
|||
{
|
||||
CheckTagExists(TagCustomerEmail);
|
||||
setTagText(TagCustomerEmail, email);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1138,7 +1138,7 @@ void VAbstractPattern::SetLabelDateFormat(const QString &format)
|
|||
m_labelDateFormat = format;
|
||||
QDomElement tag = CheckTagExists(TagPatternLabel);
|
||||
SetAttribute(tag, AttrDateFormat, m_labelDateFormat);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1163,7 +1163,7 @@ void VAbstractPattern::SetLabelTimeFormat(const QString &format)
|
|||
{
|
||||
QDomElement tag = CheckTagExists(TagPatternLabel);
|
||||
SetAttribute(tag, AttrTimeFormat, format);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1175,7 +1175,7 @@ void VAbstractPattern::SetPatternLabelTemplate(const QVector<VLabelTemplateLine>
|
|||
RemoveAllChildren(tag);
|
||||
SetLabelTemplate(tag, lines);
|
||||
patternLabelLines = lines;
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
@ -1208,7 +1208,7 @@ auto VAbstractPattern::SetWatermarkPath(const QString &path) -> bool
|
|||
parent.removeChild(tag);
|
||||
|
||||
emit patternChanged(false);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
m_watermarkPath = path;
|
||||
modified = true;
|
||||
return true;
|
||||
|
@ -1217,7 +1217,7 @@ auto VAbstractPattern::SetWatermarkPath(const QString &path) -> bool
|
|||
if (setTagText(tag, path))
|
||||
{
|
||||
emit patternChanged(false);
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
m_watermarkPath = path;
|
||||
modified = true;
|
||||
return true;
|
||||
|
@ -1242,7 +1242,7 @@ void VAbstractPattern::SetPatternMaterials(const QMap<int, QString> &materials)
|
|||
RemoveAllChildren(tag);
|
||||
SetMaterials(tag, materials);
|
||||
patternMaterials = materials;
|
||||
patternLabelWasChanged = true;
|
||||
SetPatternWasChanged(true);
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
|
|
@ -273,18 +273,6 @@ auto operator>>(QDataStream &dataStream, VTextManager &data) -> QDataStream &
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -455,12 +443,6 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data, bo
|
|||
SCASSERT(doc != nullptr)
|
||||
SCASSERT(data != nullptr)
|
||||
|
||||
if (placeholdersExpirationTime->isValid() && QDateTime::currentDateTime() <= *placeholdersExpirationTime)
|
||||
{
|
||||
*placeholdersExpirationTime = QDateTime::currentDateTime().addSecs(placeholdersExpirationTimeout);
|
||||
return *placeholdersCache;
|
||||
}
|
||||
|
||||
QMap<QString, QString> placeholders;
|
||||
|
||||
// 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_wCut, phTr->translate("Placeholder", "Cut"));
|
||||
|
||||
*placeholdersCache = placeholders;
|
||||
*placeholdersExpirationTime = QDateTime::currentDateTime().addSecs(placeholdersExpirationTimeout);
|
||||
|
||||
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);
|
||||
QStringList words = text.split(' ');
|
||||
|
|
|
@ -124,7 +124,7 @@ private:
|
|||
static const quint32 streamHeader;
|
||||
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
|
||||
-> QStringList;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user