From c45327aafdfa19f065bc83f6f6e750233ecb2e60 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Wed, 26 Jun 2019 14:57:14 +0200 Subject: [PATCH] Removed enum eXmlMode and added XmlAutoFormatting flag anc XmlCompressionEnabled flag to eConfigFlags. Added support for XML compression for the XML generated by the store function. If enabled then XML the generated XML is not human readable anymore but it needs less space when storing into settings file --- src/DockManager.cpp | 9 +++++---- src/DockManager.h | 16 +++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/DockManager.cpp b/src/DockManager.cpp index c3b3ace..9de76eb 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -336,8 +336,9 @@ void DockManagerPrivate::emitTopLevelEvents() //============================================================================ -bool DockManagerPrivate::restoreState(const QByteArray &state, int version) +bool DockManagerPrivate::restoreState(const QByteArray& State, int version) { + QByteArray state = State.startsWith("ConfigFlags.testFlag(XmlAutoFormattingEnabled)); s.writeStartDocument(); s.writeStartElement("QtAdvancedDockingSystem"); s.writeAttribute("Version", QString::number(version)); @@ -506,7 +507,7 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const s.writeEndElement(); s.writeEndDocument(); - return xmldata; + return d->ConfigFlags.testFlag(XmlCompressionEnabled) ? qCompress(xmldata, 9) : xmldata; } diff --git a/src/DockManager.h b/src/DockManager.h index 72ab026..4a6dfdc 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -51,7 +51,9 @@ struct DockWidgetTabPrivate; struct DockAreaWidgetPrivate; /** - * The central dock manager that maintains the complete docking system + * The central dock manager that maintains the complete docking system. + * With the configuration flags you can globally control the functionality + * of the docking system. **/ class ADS_EXPORT CDockManager : public CDockContainerWidget { @@ -108,12 +110,6 @@ public: MenuAlphabeticallySorted }; - enum eXmlMode - { - XmlAutoFormattingDisabled, - XmlAutoFormattingEnabled - }; - /** * These global configuration flags configure some global dock manager * settings. @@ -124,7 +120,9 @@ public: DockAreaHasCloseButton = 0x02, //!< If the flag is set each dock area has a close button DockAreaCloseButtonClosesTab = 0x04,//!< If the flag is set, the dock area close button closes the active tab, if not set, it closes the complete cock area OpaqueSplitterResize = 0x08, //!< See QSplitter::setOpaqueResize() documentation - DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize, ///< the default configuration + XmlAutoFormattingEnabled = 0x10,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace). + XmlCompressionEnabled = 0x20,//!< If enabled, the XML output will be compressed and is not human readable anymore + DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize | XmlCompressionEnabled, ///< the default configuration }; Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag) @@ -228,7 +226,7 @@ public: * The XmlMode XmlAutoFormattingDisabled is better if you would like to have * a more compact XML output - i.e. for storage in ini files. */ - QByteArray saveState(eXmlMode XmlMode = XmlAutoFormattingDisabled, int version = 0) const; + QByteArray saveState(int version = 0) const; /** * Restores the state of this dockmanagers dockwidgets.