MCPcopy Create free account
hub / github.com/KDE/kdevelop / existentWidgetForDockWidget

Function existentWidgetForDockWidget

kdevplatform/sublime/idealcontroller.cpp:119–137  ·  view source on GitHub ↗

* Return a widget that used to be and can again become a dock widget's widget * (@p viewWidget itself or its QMainWindow parent). * * @param mainWindow the main window ancestor of @p viewWidget * @param viewWidget non-null disowned tool view widget */

Source from the content-addressed store, hash-verified

117 * @param viewWidget non-null disowned tool view widget
118 */
119[[nodiscard]] QWidget* existentWidgetForDockWidget(const Sublime::MainWindow& mainWindow, QWidget* viewWidget)
120{
121 Q_ASSERT(viewWidget);
122
123 // The previous dock widget (grand)parent of the disowned view widget must have been destroyed by now, and
124 // the view widget itself must have been saved from destruction by setting its (grand)parent to the main window.
125 // If not, the caller of this function would be stealing the view widget from its current (grand)parent dock widget.
126
127 auto* const viewParent = viewWidget->parentWidget();
128 Q_ASSERT(viewParent);
129 if (viewParent == &mainWindow) {
130 return viewWidget;
131 }
132
133 // a tool view widget with a toolbar lives in a QMainWindow that lives in a dock widget
134 Q_ASSERT(qobject_cast<QMainWindow*>(viewParent));
135 Q_ASSERT(viewParent->parentWidget() == &mainWindow);
136 return viewParent;
137}
138
139struct DockWidgetInfo
140{

Callers 2

addViewMethod · 0.85
toolViewRemovedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected