From 861d5187e34b3202538a5c84e4e1a2c69cd45eaa Mon Sep 17 00:00:00 2001 From: mfreiholz Date: Thu, 11 Feb 2016 14:51:38 +0100 Subject: [PATCH] Serialize current index of SectionWidget --- AdvancedDockingSystem/include/ads/SectionWidget.h | 1 + AdvancedDockingSystem/src/ContainerWidget.cpp | 9 +++++---- AdvancedDockingSystem/src/SectionWidget.cpp | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/AdvancedDockingSystem/include/ads/SectionWidget.h b/AdvancedDockingSystem/include/ads/SectionWidget.h index 3b66c7d..6fe5735 100644 --- a/AdvancedDockingSystem/include/ads/SectionWidget.h +++ b/AdvancedDockingSystem/include/ads/SectionWidget.h @@ -42,6 +42,7 @@ public: int indexOfContent(SectionContent::RefPtr c) const; int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = NULL) const; + int currentIndex() const; void moveContent(int from, int to); public slots: diff --git a/AdvancedDockingSystem/src/ContainerWidget.cpp b/AdvancedDockingSystem/src/ContainerWidget.cpp index f5af656..7abc252 100644 --- a/AdvancedDockingSystem/src/ContainerWidget.cpp +++ b/AdvancedDockingSystem/src/ContainerWidget.cpp @@ -379,7 +379,7 @@ void ContainerWidget::saveGeometryWalk(QDataStream& out, QWidget* widget) const else if ((sw = dynamic_cast(widget)) != NULL) { out << 2; // Type = SectionWidget - out << sw->geometry(); + out << sw->currentIndex(); out << sw->contents().count(); const QList& contents = sw->contents(); for (int i = 0; i < contents.count(); ++i) @@ -422,9 +422,9 @@ bool ContainerWidget::restoreGeometryWalk(QDataStream& in, QSplitter* currentSpl qWarning() << "Missing splitter object for section"; return false; } - QRect geom; - int count; - in >> geom >> count; + + int currentIndex, count; + in >> currentIndex >> count; SectionWidget* sw = new SectionWidget(this); // sw->setGeometry(geom); @@ -436,6 +436,7 @@ bool ContainerWidget::restoreGeometryWalk(QDataStream& in, QSplitter* currentSpl if (sc) sw->addContent(sc); } + sw->setCurrentIndex(currentIndex); currentSplitter->addWidget(sw); } // Unknown diff --git a/AdvancedDockingSystem/src/SectionWidget.cpp b/AdvancedDockingSystem/src/SectionWidget.cpp index a9e077c..7925507 100644 --- a/AdvancedDockingSystem/src/SectionWidget.cpp +++ b/AdvancedDockingSystem/src/SectionWidget.cpp @@ -206,6 +206,11 @@ int SectionWidget::indexOfContentByTitlePos(const QPoint& p, QWidget* exclude) c return index; } +int SectionWidget::currentIndex() const +{ + return _contentsLayout->currentIndex(); +} + void SectionWidget::moveContent(int from, int to) { if (from >= _contents.size() || from < 0 || to >= _contents.size() || to < 0 || from == to)