* 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 */
| 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 | |
| 139 | struct DockWidgetInfo |
| 140 | { |
no outgoing calls
no test coverage detected