Ref T184, formatting

This commit is contained in:
Klaus Basan
2017-11-12 02:41:35 +01:00
parent 9a2c4573dc
commit 878498cc9d
3 changed files with 30 additions and 25 deletions

View File

@@ -28,49 +28,49 @@ namespace BlackGui
{
// it the parent is already an info area at this time, we keep it
// otherwise we expect the info area to set it later
this->m_parentDockableInfoArea = parentInfoArea;
m_parentDockableInfoArea = parentInfoArea;
}
bool CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
{
// sanity check
if (this->m_parentDockableInfoArea)
if (m_parentDockableInfoArea)
{
// we already have a value
// changes should not happen
Q_ASSERT_X(this->m_parentDockableInfoArea == parentDockableWidget, Q_FUNC_INFO, "Reassigned parent dock widget area");
return this->m_parentDockableInfoArea == parentDockableWidget;
Q_ASSERT_X(m_parentDockableInfoArea == parentDockableWidget, Q_FUNC_INFO, "Reassigned parent dock widget area");
return m_parentDockableInfoArea == parentDockableWidget;
}
m_parentDockableInfoArea = parentDockableWidget;
QMetaObject::Connection con = QDockWidget::connect(parentDockableWidget, &QDockWidget::destroyed, [this]
{
// break dependency to dockable widget
this->m_parentDockableInfoArea = nullptr;
m_parentDockableInfoArea = nullptr;
});
Q_ASSERT_X(con, Q_FUNC_INFO, "Connection failed");
this->m_connections.append(con);
m_connections.append(con);
return true;
}
CInfoArea *CEnableForDockWidgetInfoArea::getParentInfoArea() const
{
Q_ASSERT(this->m_parentDockableInfoArea);
if (!this->m_parentDockableInfoArea) return nullptr;
return this->m_parentDockableInfoArea->getParentInfoArea();
Q_ASSERT(m_parentDockableInfoArea);
if (!m_parentDockableInfoArea) return nullptr;
return m_parentDockableInfoArea->getParentInfoArea();
}
bool CEnableForDockWidgetInfoArea::isParentDockWidgetFloating() const
{
Q_ASSERT(this->m_parentDockableInfoArea);
if (!this->m_parentDockableInfoArea) { return false; }
return this->m_parentDockableInfoArea->isFloating();
Q_ASSERT(m_parentDockableInfoArea);
if (!m_parentDockableInfoArea) { return false; }
return m_parentDockableInfoArea->isFloating();
}
bool CEnableForDockWidgetInfoArea::isVisibleWidget() const
{
if (!this->m_parentDockableInfoArea) { return false; } // can happen function is used while dock widget not yet fully initialized
return this->m_parentDockableInfoArea->isVisibleWidget();
if (!m_parentDockableInfoArea) { return false; } // can happen function is used while dock widget not yet fully initialized
return m_parentDockableInfoArea->isVisibleWidget();
}
CEnableForFramelessWindow *CEnableForDockWidgetInfoArea::mainApplicationWindow() const

View File

@@ -97,8 +97,10 @@ namespace BlackGui
void CDockWidgetInfoArea::initialFloating()
{
CDockWidget::initialFloating(); // initial floating to init position & size
// set the top level dock widget area to all children
QList<CEnableForDockWidgetInfoArea *> infoAreaDockWidgets = this->findEmbeddedDockWidgetInfoAreaComponents();
for(CEnableForDockWidgetInfoArea *dwia : infoAreaDockWidgets)
for (CEnableForDockWidgetInfoArea *dwia : infoAreaDockWidgets)
{
Q_ASSERT_X(dwia, Q_FUNC_INFO, "Missing info area");
dwia->setParentDockWidgetInfoArea(this);
@@ -107,12 +109,14 @@ namespace BlackGui
QList<CEnableForDockWidgetInfoArea *> CDockWidgetInfoArea::findEmbeddedDockWidgetInfoAreaComponents()
{
QList<QWidget *> widgets = this->findChildren<QWidget *>();
QList<QWidget *> widgets = this->findChildren<QWidget *>(); // must not use Qt::FindDirectChildrenOnly here
QList<CEnableForDockWidgetInfoArea *> widgetsWithDockWidgetInfoAreaComponent;
for(QWidget *w : widgets)
for (QWidget *w : widgets)
{
Q_ASSERT(w);
CEnableForDockWidgetInfoArea *dwc = dynamic_cast<Components::CEnableForDockWidgetInfoArea *>(w);
// CEnableForDockWidgetInfoArea is no QObject, so we use dynamic_cast
CEnableForDockWidgetInfoArea *dwc = dynamic_cast<CEnableForDockWidgetInfoArea *>(w);
if (dwc)
{
widgetsWithDockWidgetInfoAreaComponent.append(dwc);
@@ -122,13 +126,13 @@ namespace BlackGui
if (nestedInfoAreas.isEmpty()) return widgetsWithDockWidgetInfoAreaComponent;
// we have to exclude the nested embedded areas
for(CDockWidgetInfoArea *ia : nestedInfoAreas)
for (CDockWidgetInfoArea *ia : nestedInfoAreas)
{
QList<CEnableForDockWidgetInfoArea *> nestedInfoAreaComponents = ia->findEmbeddedDockWidgetInfoAreaComponents();
if (nestedInfoAreaComponents.isEmpty()) { continue; }
for(CEnableForDockWidgetInfoArea *iac : nestedInfoAreaComponents)
for (CEnableForDockWidgetInfoArea *iac : nestedInfoAreaComponents)
{
bool r = widgetsWithDockWidgetInfoAreaComponent.removeOne(iac);
const bool r = widgetsWithDockWidgetInfoAreaComponent.removeOne(iac);
Q_ASSERT(r); // why is the nested component not in the child list?
Q_UNUSED(r);
}
@@ -138,6 +142,7 @@ namespace BlackGui
QList<CDockWidgetInfoArea *> CDockWidgetInfoArea::findNestedInfoAreas()
{
// must not use Qt::FindDirectChildrenOnly here
QList<CDockWidgetInfoArea *> nestedInfoAreas = this->findChildren<CDockWidgetInfoArea *>();
return nestedInfoAreas;
}

View File

@@ -582,7 +582,7 @@ namespace BlackGui
// if we have > 1 docked widgets, we have a tab bar
if (m_tabBar)
{
QString qss = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameDockWidgetTab());
const QString qss = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameDockWidgetTab());
m_tabBar->setStyleSheet(qss);
m_tabBar->setObjectName("comp_MainInfoAreaDockWidgetTab");
m_tabBar->setMovable(false);
@@ -649,9 +649,9 @@ namespace BlackGui
void CInfoArea::emitInfoAreaStatus()
{
int sia = this->getSelectedDockInfoAreaIndex();
QList<int> floating = this->getAreaIndexesDockedOrFloating(true);
QList<int> docked = this->getAreaIndexesDockedOrFloating(false);
const int sia = this->getSelectedDockInfoAreaIndex();
const QList<int> floating = this->getAreaIndexesDockedOrFloating(true);
const QList<int> docked = this->getAreaIndexesDockedOrFloating(false);
emit changedInfoAreaStatus(sia, docked, floating);
}