Serialize current index of SectionWidget

This commit is contained in:
mfreiholz 2016-02-11 14:51:38 +01:00
parent cb3324284a
commit 861d5187e3
3 changed files with 11 additions and 4 deletions

View File

@ -42,6 +42,7 @@ public:
int indexOfContent(SectionContent::RefPtr c) const; int indexOfContent(SectionContent::RefPtr c) const;
int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = NULL) const; int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = NULL) const;
int currentIndex() const;
void moveContent(int from, int to); void moveContent(int from, int to);
public slots: public slots:

View File

@ -379,7 +379,7 @@ void ContainerWidget::saveGeometryWalk(QDataStream& out, QWidget* widget) const
else if ((sw = dynamic_cast<SectionWidget*>(widget)) != NULL) else if ((sw = dynamic_cast<SectionWidget*>(widget)) != NULL)
{ {
out << 2; // Type = SectionWidget out << 2; // Type = SectionWidget
out << sw->geometry(); out << sw->currentIndex();
out << sw->contents().count(); out << sw->contents().count();
const QList<SectionContent::RefPtr>& contents = sw->contents(); const QList<SectionContent::RefPtr>& contents = sw->contents();
for (int i = 0; i < contents.count(); ++i) 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"; qWarning() << "Missing splitter object for section";
return false; return false;
} }
QRect geom;
int count; int currentIndex, count;
in >> geom >> count; in >> currentIndex >> count;
SectionWidget* sw = new SectionWidget(this); SectionWidget* sw = new SectionWidget(this);
// sw->setGeometry(geom); // sw->setGeometry(geom);
@ -436,6 +436,7 @@ bool ContainerWidget::restoreGeometryWalk(QDataStream& in, QSplitter* currentSpl
if (sc) if (sc)
sw->addContent(sc); sw->addContent(sc);
} }
sw->setCurrentIndex(currentIndex);
currentSplitter->addWidget(sw); currentSplitter->addWidget(sw);
} }
// Unknown // Unknown

View File

@ -206,6 +206,11 @@ int SectionWidget::indexOfContentByTitlePos(const QPoint& p, QWidget* exclude) c
return index; return index;
} }
int SectionWidget::currentIndex() const
{
return _contentsLayout->currentIndex();
}
void SectionWidget::moveContent(int from, int to) void SectionWidget::moveContent(int from, int to)
{ {
if (from >= _contents.size() || from < 0 || to >= _contents.size() || to < 0 || from == to) if (from >= _contents.size() || from < 0 || to >= _contents.size() || to < 0 || from == to)