- adds sectionContentVisibilityChanged(...) signal
This commit is contained in:
mfreiholz 2016-04-11 07:08:40 +02:00
parent f2a352c305
commit 932ec71ad8
4 changed files with 22 additions and 0 deletions

View File

@ -153,6 +153,13 @@ signals:
*/
void activeTabChanged(const SectionContent::RefPtr& sc, bool active);
/*!
* Emits whenever the visibility of a SectionContent changes.
* \see showSectionContent(), hideSectionContent()
* \since 0.2
*/
void sectionContentVisibilityChanged(const SectionContent::RefPtr& sc, bool visible);
private:
// Elements inside container.
QList<SectionWidget*> _sections;

View File

@ -163,6 +163,7 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
fw->setVisible(true);
fw->_titleWidget->setVisible(true);
fw->_contentWidget->setVisible(true);
emit sectionContentVisibilityChanged(sc, true);
return true;
}
@ -178,11 +179,13 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
if (hsi.preferredSectionId > 0 && (sw = SWLookupMapById(this).value(hsi.preferredSectionId)) != NULL)
{
sw->addContent(hsi.data, true);
emit sectionContentVisibilityChanged(sc, true);
return true;
}
else if (_sections.size() > 0 && (sw = _sections.first()) != NULL)
{
sw->addContent(hsi.data, true);
emit sectionContentVisibilityChanged(sc, true);
return true;
}
else
@ -190,6 +193,7 @@ bool ContainerWidget::showSectionContent(const SectionContent::RefPtr& sc)
sw = newSectionWidget();
addSection(sw);
sw->addContent(hsi.data, true);
emit sectionContentVisibilityChanged(sc, true);
return true;
}
}
@ -210,6 +214,7 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
if (!found)
continue;
_floatings.at(i)->setVisible(false);
emit sectionContentVisibilityChanged(sc, false);
return true;
}
@ -240,6 +245,7 @@ bool ContainerWidget::hideSectionContent(const SectionContent::RefPtr& sc)
sw = NULL;
deleteEmptySplitter(this);
}
emit sectionContentVisibilityChanged(sc, false);
return true;
}

View File

@ -96,8 +96,10 @@ MainWindow::MainWindow(QWidget *parent) :
_container->setOrientation(Qt::Vertical);
#if QT_VERSION >= 0x050000
QObject::connect(_container, &ADS_NS::ContainerWidget::activeTabChanged, this, &MainWindow::onActiveTabChanged);
QObject::connect(_container, &ADS_NS::ContainerWidget::sectionContentVisibilityChanged, this, &MainWindow::onSectionContentVisibilityChanged);
#else
QObject::connect(_container, SIGNAL(activeTabChanged(const SectionContent::RefPtr&, bool)), this, SLOT(onActiveTabChanged(const SectionContent::RefPtr&, bool)));
QObject::connect(_container, SIGNAL(sectionContentVisibilityChanged(SectionContent::RefPtr,bool)), this, SLOT(onSectionContentVisibilityChanged(SectionContent::RefPtr,bool)));
#endif
setCentralWidget(_container);
@ -151,6 +153,11 @@ void MainWindow::onActiveTabChanged(const ADS_NS::SectionContent::RefPtr& sc, bo
}
}
void MainWindow::onSectionContentVisibilityChanged(const ADS_NS::SectionContent::RefPtr& sc, bool visible)
{
qDebug() << Q_FUNC_INFO << sc->uniqueName() << visible;
}
void MainWindow::onActionAddSectionContentTriggered()
{
return;

View File

@ -24,8 +24,10 @@ public slots:
private slots:
#if QT_VERSION >= 0x050000
void onActiveTabChanged(const ADS_NS::SectionContent::RefPtr& sc, bool active);
void onSectionContentVisibilityChanged(const ADS_NS::SectionContent::RefPtr& sc, bool visible);
#else
void onActiveTabChanged(const SectionContent::RefPtr& sc, bool active);
void onSectionContentVisibilityChanged(const SectionContent::RefPtr& sc, bool visible);
#endif
void onActionAddSectionContentTriggered();