Reverse change.

Cache object must not be available public, must be static.
This commit is contained in:
Roman Telezhynskyi 2024-02-23 14:42:57 +02:00
parent cf5fd8124f
commit 2ae203897a
2 changed files with 19 additions and 28 deletions

View File

@ -76,6 +76,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsRawLayoutData, ("paths/rawL
QT_WARNING_POP QT_WARNING_POP
int cachedLineWidth = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace } // namespace
#ifndef QPRINTENGINE_H #ifndef QPRINTENGINE_H
@ -83,15 +85,18 @@ Q_DECLARE_METATYPE(QMarginsF) // NOLINT
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application, QObject *parent) VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application,
: VCommonSettings(format, scope, organization, application, parent), cachedLineWidth(-1) { QObject *parent)
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF) : VCommonSettings(format, scope, organization, application, parent)
{
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent) VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent), cachedLineWidth(-1) { : VCommonSettings(fileName, format, parent)
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF) {
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -353,12 +358,8 @@ void VPSettings::SetLayoutExportFormat(qint8 format)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPSettings::SetCachedLineWidth(int lineWidth) { auto VPSettings::GetLayoutLineWidth() const -> int
cachedLineWidth = lineWidth; {
}
//---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetCachedLineWidth() -> int {
if (cachedLineWidth == -1) if (cachedLineWidth == -1)
{ {
cachedLineWidth = qvariant_cast<int>(value(*settingLayoutLineWidth, 3)); cachedLineWidth = qvariant_cast<int>(value(*settingLayoutLineWidth, 3));
@ -367,17 +368,11 @@ auto VPSettings::GetCachedLineWidth() -> int {
return cachedLineWidth; return cachedLineWidth;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetLayoutLineWidth() -> int
{
return GetCachedLineWidth();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPSettings::SetLayoutLineWidth(int width) void VPSettings::SetLayoutLineWidth(int width)
{ {
SetCachedLineWidth(qBound(1, width, 10)); cachedLineWidth = qBound(1, width, 10);
setValue(*settingLayoutLineWidth, GetCachedLineWidth()); setValue(*settingLayoutLineWidth, cachedLineWidth);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -36,12 +36,9 @@ class VPSettings : public VCommonSettings
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
private:
Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT
int cachedLineWidth;
public: public:
VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr); VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr);
VPSettings(const QString &fileName, Format format, QObject *parent = nullptr); VPSettings(const QString &fileName, Format format, QObject *parent = nullptr);
~VPSettings() override = default; ~VPSettings() override = default;
@ -108,15 +105,14 @@ public:
auto GetLayoutExportFormat() const -> qint8; auto GetLayoutExportFormat() const -> qint8;
void SetLayoutExportFormat(qint8 format); void SetLayoutExportFormat(qint8 format);
void SetCachedLineWidth(int lineWidth); auto GetLayoutLineWidth() const -> int;
auto GetCachedLineWidth() -> int;
auto GetLayoutLineWidth() -> int;
void SetLayoutLineWidth(int width); void SetLayoutLineWidth(int width);
auto GetShowGrainline() const -> bool; auto GetShowGrainline() const -> bool;
void SetShowGrainline(bool value); void SetShowGrainline(bool value);
private:
Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT
}; };
#endif // VPSETTINGS_H #endif // VPSETTINGS_H