Memleak fixes

* Set parent of title- and content-widget to associated container-widget
* inside FloatingWidget::takeContent(...)

Restore state
* Restore all contents as visible and then call hideSectionContent(...) at
* the end. This is more consistent and uses same code (public API).
* Pass version to sub-methods to handle different formats
* Fix serialization, if nothing is visible (no sections, only hidden
* contents)
This commit is contained in:
mfreiholz
2016-02-19 12:00:39 +01:00
parent 6a1b6307c9
commit 032a5d6cdf
7 changed files with 216 additions and 42 deletions

View File

@@ -159,6 +159,9 @@ void SectionWidget::addContent(const InternalContentData& data, bool autoActivat
// Switch to newest.
else if (autoActivate)
setCurrentIndex(_contents.count() - 1);
// Mark is as inactive tab.
else
data.titleWidget->setActiveTab(false); // or: setCurrentIndex(currentIndex())
}
bool SectionWidget::takeContent(int uid, InternalContentData& data)
@@ -265,8 +268,14 @@ void SectionWidget::moveContent(int from, int to)
void SectionWidget::setCurrentIndex(int index)
{
// Set active TAB.
qDebug() << Q_FUNC_INFO << index;
if (index < 0 || index > _contents.count() - 1)
{
qWarning() << Q_FUNC_INFO << "Invalid index" << index;
return;
}
qDebug() << Q_FUNC_INFO << index << QString("section=%1; content=%2").arg(_uid).arg(_contents.at(index)->uniqueName());
// Set active TAB
for (int i = 0; i < _tabsLayout->count(); ++i)
{
QLayoutItem* item = _tabsLayout->itemAt(i);
@@ -283,7 +292,7 @@ void SectionWidget::setCurrentIndex(int index)
}
}
// Set active CONTENT.
// Set active CONTENT
_contentsLayout->setCurrentIndex(index);
}