refs #335, findParentInfoAreas method to allow nested context menus

This commit is contained in:
Klaus Basan
2014-10-08 02:58:13 +02:00
committed by Roland Winklmeier
parent 9452ff10c9
commit cd7e2f6f72
2 changed files with 21 additions and 5 deletions

View File

@@ -62,16 +62,16 @@ namespace BlackGui
void CDockWidgetInfoArea::addToContextMenu(QMenu *contextMenu) const
{
Components::CMainInfoAreaComponent *mainWidget = qobject_cast<CMainInfoAreaComponent *>(parentWidget());
Q_ASSERT(mainWidget);
if (!mainWidget) return;
QList<const CInfoArea *> parentInfoAreas = this->findParentInfoAreas();
Q_ASSERT(!parentInfoAreas.isEmpty());
if (parentInfoAreas.isEmpty()) return;
// Dockable widget's context menu
CDockWidget::addToContextMenu(contextMenu);
// from main component (info area)
contextMenu->addSeparator();
mainWidget->addToContextMenu(contextMenu);
parentInfoAreas.last()->addToContextMenu(contextMenu);
}
void CDockWidgetInfoArea::initalFloating()
@@ -122,4 +122,17 @@ namespace BlackGui
QList<CDockWidgetInfoArea *> nestedInfoAreas = this->findChildren<CDockWidgetInfoArea *>();
return nestedInfoAreas;
}
}
const QList<const CInfoArea *> CDockWidgetInfoArea::findParentInfoAreas() const
{
QList<const CInfoArea *> parents;
QWidget *currentWidget = this->parentWidget();
while (currentWidget)
{
const CInfoArea *ia = qobject_cast<CInfoArea *>(currentWidget);
if (ia) { parents.append(ia); }
currentWidget = currentWidget->parentWidget();
}
return parents;
}
} // namespace

View File

@@ -58,6 +58,9 @@ namespace BlackGui
//! Nested info areas
QList<CDockWidgetInfoArea *> findNestedInfoAreas();
//! The parent info areas
const QList<const CInfoArea *> findParentInfoAreas() const;
};
} // namespace