25 const CInfoArea *ia = qobject_cast<const CInfoArea *>(this->parent());
32 CInfoArea *ia = qobject_cast<CInfoArea *>(this->parent());
40 if (!ia) {
return false; }
48 if (!this->isVisible()) {
return false; }
51 if (this->isFloating())
53 if (this->isMinimized()) {
return false; }
61 QList<const CInfoArea *> parentInfoAreas = this->findParentInfoAreas();
62 Q_ASSERT(!parentInfoAreas.isEmpty());
63 if (parentInfoAreas.isEmpty())
return;
67 if (!contextMenu->isEmpty()) { contextMenu->addSeparator(); }
70 parentInfoAreas.first()->addToContextMenu(contextMenu);
74 if (parentInfoAreas.size() < 2) {
return; }
75 contextMenu->addSeparator();
76 for (
int i = 1; i < parentInfoAreas.size(); i++)
78 const CInfoArea *infoArea = parentInfoAreas.at(i);
79 QString title(infoArea->windowTitle());
80 if (title.isEmpty()) { title = infoArea->objectName(); }
81 QMenu *m = contextMenu->addMenu(title);
91 QList<CEnableForDockWidgetInfoArea *> infoAreaDockWidgets = this->findEmbeddedDockWidgetInfoAreaComponents();
94 Q_ASSERT_X(dwia, Q_FUNC_INFO,
"Missing info area");
95 dwia->setParentDockWidgetInfoArea(
this);
99 QList<CEnableForDockWidgetInfoArea *> CDockWidgetInfoArea::findEmbeddedDockWidgetInfoAreaComponents()
101 QList<QWidget *> widgets = this->findChildren<QWidget *>();
102 QList<CEnableForDockWidgetInfoArea *> widgetsWithDockWidgetInfoAreaComponent;
103 for (QWidget *w : widgets)
109 if (dwc) { widgetsWithDockWidgetInfoAreaComponent.append(dwc); }
111 QList<CDockWidgetInfoArea *> nestedInfoAreas = this->findNestedInfoAreas();
112 if (nestedInfoAreas.isEmpty())
return widgetsWithDockWidgetInfoAreaComponent;
117 QList<CEnableForDockWidgetInfoArea *> nestedInfoAreaComponents =
118 ia->findEmbeddedDockWidgetInfoAreaComponents();
119 if (nestedInfoAreaComponents.isEmpty()) {
continue; }
120 for (CEnableForDockWidgetInfoArea *iac : nestedInfoAreaComponents)
122 const bool r = widgetsWithDockWidgetInfoAreaComponent.removeOne(iac);
127 return widgetsWithDockWidgetInfoAreaComponent;
130 QList<CDockWidgetInfoArea *> CDockWidgetInfoArea::findNestedInfoAreas()
133 QList<CDockWidgetInfoArea *> nestedInfoAreas = this->findChildren<CDockWidgetInfoArea *>();
134 return nestedInfoAreas;
137 QList<const CInfoArea *> CDockWidgetInfoArea::findParentInfoAreas()
const
139 QList<const CInfoArea *> parents;
140 QWidget *currentWidget = this->parentWidget();
141 while (currentWidget)
143 const CInfoArea *ia = qobject_cast<CInfoArea *>(currentWidget);
144 if (ia) { parents.append(ia); }
145 currentWidget = currentWidget->parentWidget();
Info area, hosting dockable widgets.
void addToContextMenu(QMenu *menu) const
Add items to context menu.
bool isSelectedDockWidgetInfoArea(const CDockWidgetInfoArea *infoArea) const
Is given widget selected. Means it is not floating, and the one selected.
High level reusable GUI components.