Skip to content

Commit c45327a

Browse files
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
1 parent e978a32 commit c45327a

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/DockManager.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ void DockManagerPrivate::emitTopLevelEvents()
336336

337337

338338
//============================================================================
339-
bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
339+
bool DockManagerPrivate::restoreState(const QByteArray& State, int version)
340340
{
341+
QByteArray state = State.startsWith("<?xml") ? State : qUncompress(State);
341342
if (!checkFormat(state, version))
342343
{
343344
qDebug() << "checkFormat: Error checking format!!!!!!!";
@@ -489,11 +490,11 @@ unsigned int CDockManager::zOrderIndex() const
489490

490491

491492
//============================================================================
492-
QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
493+
QByteArray CDockManager::saveState(int version) const
493494
{
494495
QByteArray xmldata;
495496
QXmlStreamWriter s(&xmldata);
496-
s.setAutoFormatting(XmlAutoFormattingEnabled == XmlMode);
497+
s.setAutoFormatting(d->ConfigFlags.testFlag(XmlAutoFormattingEnabled));
497498
s.writeStartDocument();
498499
s.writeStartElement("QtAdvancedDockingSystem");
499500
s.writeAttribute("Version", QString::number(version));
@@ -506,7 +507,7 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
506507
s.writeEndElement();
507508
s.writeEndDocument();
508509

509-
return xmldata;
510+
return d->ConfigFlags.testFlag(XmlCompressionEnabled) ? qCompress(xmldata, 9) : xmldata;
510511
}
511512

512513

src/DockManager.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ struct DockWidgetTabPrivate;
5151
struct DockAreaWidgetPrivate;
5252

5353
/**
54-
* The central dock manager that maintains the complete docking system
54+
* The central dock manager that maintains the complete docking system.
55+
* With the configuration flags you can globally control the functionality
56+
* of the docking system.
5557
**/
5658
class ADS_EXPORT CDockManager : public CDockContainerWidget
5759
{
@@ -108,12 +110,6 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
108110
MenuAlphabeticallySorted
109111
};
110112

111-
enum eXmlMode
112-
{
113-
XmlAutoFormattingDisabled,
114-
XmlAutoFormattingEnabled
115-
};
116-
117113
/**
118114
* These global configuration flags configure some global dock manager
119115
* settings.
@@ -124,7 +120,9 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
124120
DockAreaHasCloseButton = 0x02, //!< If the flag is set each dock area has a close button
125121
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
126122
OpaqueSplitterResize = 0x08, //!< See QSplitter::setOpaqueResize() documentation
127-
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize, ///< the default configuration
123+
XmlAutoFormattingEnabled = 0x10,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace).
124+
XmlCompressionEnabled = 0x20,//!< If enabled, the XML output will be compressed and is not human readable anymore
125+
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize | XmlCompressionEnabled, ///< the default configuration
128126
};
129127
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
130128

@@ -228,7 +226,7 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
228226
* The XmlMode XmlAutoFormattingDisabled is better if you would like to have
229227
* a more compact XML output - i.e. for storage in ini files.
230228
*/
231-
QByteArray saveState(eXmlMode XmlMode = XmlAutoFormattingDisabled, int version = 0) const;
229+
QByteArray saveState(int version = 0) const;
232230

233231
/**
234232
* Restores the state of this dockmanagers dockwidgets.

0 commit comments

Comments
 (0)