mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Serialize SectionIndexData on storeSate().
This commit is contained in:
parent
ac80242545
commit
195b34c0ca
@ -14,6 +14,7 @@ class QGridLayout;
|
||||
#include "ads/Internal.h"
|
||||
#include "ads/SectionContent.h"
|
||||
#include "ads/FloatingWidget.h"
|
||||
#include "ads/Serialization.h"
|
||||
|
||||
ADS_NAMESPACE_BEGIN
|
||||
class SectionWidget;
|
||||
@ -129,6 +130,9 @@ private:
|
||||
QByteArray saveHierarchy() const;
|
||||
void saveFloatingWidgets(QDataStream& out) const;
|
||||
void saveSectionWidgets(QDataStream& out, QWidget* widget) const;
|
||||
|
||||
bool saveSectionIndex(ADS_NS_SER::SectionIndexData &sid) const;
|
||||
|
||||
bool restoreHierarchy(const QByteArray& data);
|
||||
bool restoreFloatingWidgets(QDataStream& in, int version, QList<FloatingWidget*>& floatings);
|
||||
bool restoreSectionWidgets(QDataStream& in, int version, QSplitter* currentSplitter, QList<SectionWidget*>& sections, QList<SectionContent::RefPtr>& contentsToHide);
|
||||
|
@ -65,6 +65,8 @@ class ADS_EXPORT_API SectionEntity
|
||||
{
|
||||
public:
|
||||
SectionEntity();
|
||||
qint32 x;
|
||||
qint32 y;
|
||||
qint32 width;
|
||||
qint32 height;
|
||||
qint32 currentIndex;
|
||||
|
@ -369,10 +369,10 @@ QByteArray ContainerWidget::saveState() const
|
||||
}
|
||||
|
||||
// SectionIndex data.
|
||||
const QByteArray sectionIndexData;
|
||||
if (!sectionIndexData.isEmpty())
|
||||
ADS_NS_SER::SectionIndexData sid;
|
||||
if (saveSectionIndex(sid))
|
||||
{
|
||||
writer.write(ADS_NS_SER::ET_SectionIndex, sectionIndexData);
|
||||
writer.write(sid);
|
||||
}
|
||||
|
||||
if (writer.offsetsCount() == 0)
|
||||
@ -844,6 +844,34 @@ void ContainerWidget::saveSectionWidgets(QDataStream& out, QWidget* widget) cons
|
||||
}
|
||||
}
|
||||
|
||||
bool ContainerWidget::saveSectionIndex(ADS_NS_SER::SectionIndexData& sid) const
|
||||
{
|
||||
if (_sections.count() <= 0)
|
||||
return false;
|
||||
|
||||
sid.sectionsCount = _sections.count();
|
||||
for (int i = 0; i < _sections.count(); ++i)
|
||||
{
|
||||
ADS_NS_SER::SectionEntity se;
|
||||
se.x = _sections[i]->geometry().x();
|
||||
se.y = _sections[i]->geometry().y();
|
||||
se.width = _sections[i]->geometry().width();
|
||||
se.height = _sections[i]->geometry().height();
|
||||
se.currentIndex = _sections[i]->currentIndex();
|
||||
se.sectionContentsCount = _sections[i]->contents().count();
|
||||
foreach (const SectionContent::RefPtr& sc, _sections[i]->contents())
|
||||
{
|
||||
ADS_NS_SER::SectionContentEntity sce;
|
||||
sce.uniqueName = sc->uniqueName();
|
||||
sce.visible = true;
|
||||
sce.preferredIndex = _sections[i]->indexOfContent(sc);
|
||||
se.sectionContents.append(sce); // std::move()?
|
||||
}
|
||||
sid.sections.append(se); // std::move()?
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContainerWidget::restoreHierarchy(const QByteArray& data)
|
||||
{
|
||||
QDataStream in(data);
|
||||
|
@ -147,6 +147,8 @@ SectionEntity::SectionEntity() :
|
||||
|
||||
QDataStream& operator<<(QDataStream& out, const SectionEntity& data)
|
||||
{
|
||||
out << data.x;
|
||||
out << data.y;
|
||||
out << data.width;
|
||||
out << data.height;
|
||||
out << data.currentIndex;
|
||||
@ -160,6 +162,8 @@ QDataStream& operator<<(QDataStream& out, const SectionEntity& data)
|
||||
|
||||
QDataStream& operator>>(QDataStream& in, SectionEntity& data)
|
||||
{
|
||||
in >> data.x;
|
||||
in >> data.y;
|
||||
in >> data.width;
|
||||
in >> data.height;
|
||||
in >> data.currentIndex;
|
||||
|
Loading…
Reference in New Issue
Block a user