diff --git a/kdevplatform/language/codegen/basicrefactoring.cpp b/kdevplatform/language/codegen/basicrefactoring.cpp index 0def6fed5f594682fe433db5bfb9beecde00e015..b6d66ad540b756abc1fc36804a04fb6dda7f2e5c 100644 --- a/kdevplatform/language/codegen/basicrefactoring.cpp +++ b/kdevplatform/language/codegen/basicrefactoring.cpp @@ -292,10 +292,9 @@ BasicRefactoring::NameAndCollector BasicRefactoring::newNameForDeclaration( UsesWidget uses(declaration.data(), collector); //So the context-links work - QWidget* navigationWidget = declaration->context()->createNavigationWidget(declaration.data()); - auto* abstractNavigationWidget = dynamic_cast(navigationWidget); - if (abstractNavigationWidget) - connect(&uses, &UsesWidget::navigateDeclaration, abstractNavigationWidget, + auto* navigationWidget = declaration->context()->createNavigationWidget(declaration.data()); + if (navigationWidget) + connect(&uses, &UsesWidget::navigateDeclaration, navigationWidget, &AbstractNavigationWidget::navigateDeclaration); QString declarationName = declaration->toString(); diff --git a/kdevplatform/language/duchain/ducontext.cpp b/kdevplatform/language/duchain/ducontext.cpp index db0f742cb41d7751f804f817ecaad620e1b6b76e..1636006cf5039e1b38a095d1faa1c5e02edf9af1 100644 --- a/kdevplatform/language/duchain/ducontext.cpp +++ b/kdevplatform/language/duchain/ducontext.cpp @@ -1495,8 +1495,8 @@ TopDUContext* DUContext::topContext() const return m_dynamicData->m_topContext; } -QWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, - AbstractNavigationWidget::DisplayHints hints) const +AbstractNavigationWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, + AbstractNavigationWidget::DisplayHints hints) const { if (decl) { auto* widget = new AbstractNavigationWidget; diff --git a/kdevplatform/language/duchain/ducontext.h b/kdevplatform/language/duchain/ducontext.h index 64ae9653473959b3d37bccfb650cc9d85a5dc682..dee3185ea711ed1962d5e9251c37984b5fadd4fe 100644 --- a/kdevplatform/language/duchain/ducontext.h +++ b/kdevplatform/language/duchain/ducontext.h @@ -666,9 +666,6 @@ private: /** * Can be specialized by languages to create a navigation/information-widget. * - * Ideally, the widget would be based on @c KDevelop::QuickOpenEmbeddedWidgetInterface - * for user-interaction within the quickopen list. - * * The returned widget will be owned by the caller. * * @param decl A member-declaration of this context the navigation-widget should be created for. @@ -682,9 +679,9 @@ private: * then the widget will not close when the cursor moves in the document, which * enables you to change the document contents from the widget without immediately closing the widget. */ - virtual QWidget* createNavigationWidget(Declaration* decl = nullptr, TopDUContext* topContext = nullptr, - AbstractNavigationWidget::DisplayHints hints = - AbstractNavigationWidget::NoHints) const; + virtual AbstractNavigationWidget* + createNavigationWidget(Declaration* decl = nullptr, TopDUContext* topContext = nullptr, + AbstractNavigationWidget::DisplayHints hints = AbstractNavigationWidget::NoHints) const; enum { Identity = 2 diff --git a/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp b/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp index 33b998081d4d2d662d5ddfd3b0405af12fe8f1f7..1291ea515e6b298461157768e7db5814e9392753 100644 --- a/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp @@ -257,10 +257,10 @@ NavigationContextPointer AbstractNavigationContext::registerChild(AbstractNaviga NavigationContextPointer AbstractNavigationContext::registerChild(const DeclarationPointer& declaration) { //We create a navigation-widget here, and steal its context.. evil ;) - QScopedPointer navigationWidget(declaration->context()->createNavigationWidget(declaration.data())); - if (auto* abstractNavigationWidget = - dynamic_cast(navigationWidget.data())) { - NavigationContextPointer ret = abstractNavigationWidget->context(); + QScopedPointer navigationWidget( + declaration->context()->createNavigationWidget(declaration.data())); + if (navigationWidget) { + NavigationContextPointer ret = navigationWidget->context(); ret->setPreviousContext(this); d->m_children << ret; return ret; diff --git a/kdevplatform/shell/mainwindow_p.cpp b/kdevplatform/shell/mainwindow_p.cpp index b5861824838f65056f3797684a6f6ca174e588b2..078ac22f5a1be2853672bd8f6c577a753070eba1 100644 --- a/kdevplatform/shell/mainwindow_p.cpp +++ b/kdevplatform/shell/mainwindow_p.cpp @@ -404,7 +404,7 @@ void MainWindowPrivate::tabToolTipRequested(Sublime::View* view, Sublime::Contai TopDUContext* top = DUChainUtils::standardContextForUrl(urlDoc->url()); if (top) { - if ( QWidget* navigationWidget = top->createNavigationWidget() ) { + if (auto* navigationWidget = top->createNavigationWidget()) { NavigationToolTip* tooltip = new KDevelop::NavigationToolTip(m_mainWindow, QCursor::pos() + QPoint(20, 20), navigationWidget); tooltip->resize(navigationWidget->sizeHint() + QSize(10, 10)); tooltip->setHandleRect(container->tabRect(tab)); diff --git a/plugins/clang/duchain/clangducontext.cpp b/plugins/clang/duchain/clangducontext.cpp index 99048e57080e87dc2dd50883b85164dbfd2b0267..971eadee1d327ece9a5bc3861edba5884b61eedc 100644 --- a/plugins/clang/duchain/clangducontext.cpp +++ b/plugins/clang/duchain/clangducontext.cpp @@ -28,9 +28,10 @@ using namespace KDevelop; -template<> -QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, - KDevelop::AbstractNavigationWidget::DisplayHints hints) const +template <> +KDevelop::AbstractNavigationWidget* +ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, + KDevelop::AbstractNavigationWidget::DisplayHints hints) const { if (!decl) { const QUrl u = url().toUrl(); @@ -45,9 +46,10 @@ QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte return new ClangNavigationWidget(DeclarationPointer(decl), hints); } -template<> -QWidget* ClangNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* /*topContext*/, - KDevelop::AbstractNavigationWidget::DisplayHints hints) const +template <> +KDevelop::AbstractNavigationWidget* +ClangNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* /*topContext*/, + KDevelop::AbstractNavigationWidget::DisplayHints hints) const { if (!decl) { clangDebug() << "no declaration, not returning navigationwidget"; diff --git a/plugins/clang/duchain/clangducontext.h b/plugins/clang/duchain/clangducontext.h index b4a1e9b00b04500abdb8c694de83cab82106fba8..7eb270a7913d3bf9065aadaf572b71270ce4abb5 100644 --- a/plugins/clang/duchain/clangducontext.h +++ b/plugins/clang/duchain/clangducontext.h @@ -39,9 +39,10 @@ public: static_cast(this)->d_func_dynamic()->setClassId(this); } - QWidget* createNavigationWidget(KDevelop::Declaration* decl = nullptr, - KDevelop::TopDUContext* topContext = nullptr, - KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints) const override; + KDevelop::AbstractNavigationWidget* + createNavigationWidget(KDevelop::Declaration* decl = nullptr, KDevelop::TopDUContext* topContext = nullptr, + KDevelop::AbstractNavigationWidget::DisplayHints hints + = KDevelop::AbstractNavigationWidget::NoHints) const override; enum { Identity = IdentityT diff --git a/plugins/classbrowser/classtree.cpp b/plugins/classbrowser/classtree.cpp index 5df629d38bd19fdaecdbfecebb7017d8589333b1..a0f84da2459799f1f9e562f7d8c8f1bab5b18ca5 100644 --- a/plugins/classbrowser/classtree.cpp +++ b/plugins/classbrowser/classtree.cpp @@ -111,8 +111,7 @@ bool ClassTree::event(QEvent* event) if (m_tooltip) { m_tooltip->close(); } - QWidget* navigationWidget = decl->topContext()->createNavigationWidget(decl); - if (navigationWidget) { + if (auto* navigationWidget = decl->topContext()->createNavigationWidget(decl)) { m_tooltip = new KDevelop::NavigationToolTip(this, helpEvent->globalPos() + QPoint(40, 0), navigationWidget); m_tooltip->resize(navigationWidget->sizeHint() + QSize(10, 10)); diff --git a/plugins/contextbrowser/contextbrowserview.cpp b/plugins/contextbrowser/contextbrowserview.cpp index daf3000400afe6dddbe3bd3c4de333235d75d963..bae2f7ed9f9e3a5f09133da877d68fc9447cc671 100644 --- a/plugins/contextbrowser/contextbrowserview.cpp +++ b/plugins/contextbrowser/contextbrowserview.cpp @@ -131,7 +131,7 @@ void selectUse(ContextBrowserView* view, Direction direction) } } -QWidget* ContextBrowserView::createWidget(KDevelop::DUContext* context) +AbstractNavigationWidget* ContextBrowserView::createWidget(KDevelop::DUContext* context) { m_context = IndexedDUContext(context); if (m_context.data()) { @@ -145,7 +145,7 @@ KDevelop::IndexedDeclaration ContextBrowserView::declaration() const return m_declaration; } -QWidget* ContextBrowserView::createWidget(Declaration* decl, TopDUContext* topContext) +AbstractNavigationWidget* ContextBrowserView::createWidget(Declaration* decl, TopDUContext* topContext) { m_declaration = IndexedDeclaration(decl); return decl->context()->createNavigationWidget(decl, topContext, AbstractNavigationWidget::EmbeddableWidget); @@ -354,8 +354,7 @@ void ContextBrowserView::setDeclaration(KDevelop::Declaration* decl, KDevelop::T m_navigationWidgetDeclaration = decl->id(); if (!isLocked() && (isVisible() || force)) { // NO-OP if tool view is hidden, for performance reasons - QWidget* w = createWidget(decl, topContext); - updateMainWidget(w); + updateMainWidget(createWidget(decl, topContext)); } } @@ -393,8 +392,7 @@ void ContextBrowserView::setContext(KDevelop::DUContext* context) } if (!isLocked() && isVisible()) { // NO-OP if tool view is hidden, for performance reasons - QWidget* w = createWidget(context); - updateMainWidget(w); + updateMainWidget(createWidget(context)); } } diff --git a/plugins/contextbrowser/contextbrowserview.h b/plugins/contextbrowser/contextbrowserview.h index 425af86277b985260f98d4fdc55ef84fbb7227c6..10a1f28e32ca1071b12ef0b4dbf1770a5f25b507 100644 --- a/plugins/contextbrowser/contextbrowserview.h +++ b/plugins/contextbrowser/contextbrowserview.h @@ -70,10 +70,10 @@ public: } //duchain must be locked - QWidget* createWidget(KDevelop::DUContext* context); + KDevelop::AbstractNavigationWidget* createWidget(KDevelop::DUContext* context); //duchain must be locked - QWidget* createWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext); + KDevelop::AbstractNavigationWidget* createWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext); KDevelop::IndexedDeclaration declaration() const; diff --git a/plugins/projectmanagerview/projectmodelitemdelegate.cpp b/plugins/projectmanagerview/projectmodelitemdelegate.cpp index 92299ede819751308d3b756a59a91dfcafb67bf2..89c0cc8e0acf70e434de9d973012f1274d7a8973 100644 --- a/plugins/projectmanagerview/projectmodelitemdelegate.cpp +++ b/plugins/projectmanagerview/projectmodelitemdelegate.cpp @@ -199,8 +199,7 @@ bool ProjectModelItemDelegate::helpEvent(QHelpEvent* event, const TopDUContext* top = DUChainUtils::standardContextForUrl(it->file()->path().toUrl()); if (top) { - QWidget* navigationWidget = top->createNavigationWidget(); - if (navigationWidget) { + if (auto* navigationWidget = top->createNavigationWidget()) { // force possible existing normal tooltip for other list item to hide // Seems that is still only done with a small delay though, // but the API seems not to allow more control. diff --git a/plugins/qmljs/duchain/qmljsducontext.cpp b/plugins/qmljs/duchain/qmljsducontext.cpp index 23c1db3dbf584f0fdb4ce676cc0ce42c6664f647..8b9c25afb2577311fb85b94ac536484dc066d7f5 100644 --- a/plugins/qmljs/duchain/qmljsducontext.cpp +++ b/plugins/qmljs/duchain/qmljsducontext.cpp @@ -35,9 +35,9 @@ using namespace KDevelop; namespace QmlJS { -template<> -QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, - AbstractNavigationWidget::DisplayHints hints) const +template <> +AbstractNavigationWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, + AbstractNavigationWidget::DisplayHints hints) const { if (!decl) { const QUrl u = url().toUrl(); @@ -52,15 +52,17 @@ QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte return new NavigationWidget(decl, topContext, hints); } -template<> -QWidget* QmlJSNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, AbstractNavigationWidget::DisplayHints hints) const { +template <> +AbstractNavigationWidget* +QmlJSNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, + AbstractNavigationWidget::DisplayHints hints) const +{ if (!decl) { qCDebug(KDEV_QMLJS_DUCHAIN) << "no declaration, not returning navigationwidget"; return nullptr; } return new NavigationWidget(decl, topContext, hints); } - } DUCHAIN_DEFINE_TYPE_WITH_DATA(QmlJS::QmlJSNormalDUContext, DUContextData) diff --git a/plugins/qmljs/duchain/qmljsducontext.h b/plugins/qmljs/duchain/qmljsducontext.h index f7ce87a36a369c7e3352f3a2831e4d58c53f3b9b..a31c81c49097b9e0f550c0dba339f2e930e656ed 100644 --- a/plugins/qmljs/duchain/qmljsducontext.h +++ b/plugins/qmljs/duchain/qmljsducontext.h @@ -26,8 +26,6 @@ #include #include -class QWidget; - namespace KDevelop { class Declaration; @@ -61,9 +59,9 @@ public: static_cast(this)->d_func_dynamic()->setClassId(this); } - QWidget* createNavigationWidget(KDevelop::Declaration* decl, - KDevelop::TopDUContext* topContext, - KDevelop::AbstractNavigationWidget::DisplayHints hints) const override; + KDevelop::AbstractNavigationWidget* + createNavigationWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext, + KDevelop::AbstractNavigationWidget::DisplayHints hints) const override; enum { Identity = IdentityT