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

View File

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

View File

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