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

Method prepareViewWidget

kdevplatform/sublime/idealcontroller.cpp:273–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271};
272
273std::pair<QWidget*, bool> ToolViewWidgetCache::prepareViewWidget(View& view, QWidget* parent)
274{
275 const auto* const document = view.document();
276 Q_ASSERT(document);
277
278 if (auto* const widget = view.widget()) {
279 Q_ASSERT(m_widgets.value(document).widget() == widget);
280 qCDebug(SUBLIME) << "the view already has a tool view widget" << document->documentSpecifier();
281 return {widget, false};
282 }
283
284 auto& cachedWidget = m_widgets[document];
285
286 if (auto* const widget = cachedWidget.widget()) {
287 cachedWidget.addUse();
288 view.setSharedWidget(widget);
289 qCDebug(SUBLIME).nospace() << "reusing an existing tool view widget " << document->documentSpecifier()
290 << ", use count: " << cachedWidget.useCount();
291 return {widget, false};
292 }
293
294 auto* const widget = view.initializeWidget(parent);
295 Q_ASSERT(widget);
296 cachedWidget.initializeWidget(widget);
297 qCDebug(SUBLIME) << "created a new tool view widget" << document->documentSpecifier();
298 return {widget, true};
299}
300
301bool ToolViewWidgetCache::disuse(const View& view)
302{

Callers 1

addViewMethod · 0.80

Calls 8

setSharedWidgetMethod · 0.80
useCountMethod · 0.80
documentMethod · 0.45
widgetMethod · 0.45
valueMethod · 0.45
documentSpecifierMethod · 0.45
addUseMethod · 0.45
initializeWidgetMethod · 0.45

Tested by

no test coverage detected