Commit ddeb2f2d authored by Sven Brauch's avatar Sven Brauch
Browse files

clang, qmljs: adapt to changed navigation widget API

parent 1f93bfb4
......@@ -237,7 +237,7 @@ public:
QWidget* createExpandingWidget(const CodeCompletionModel* /*model*/) const override
{
return new ClangNavigationWidget(m_declaration);
return new ClangNavigationWidget(m_declaration, KDevelop::AbstractNavigationWidget::EmbeddableWidget);
}
int matchQuality() const
......
......@@ -30,7 +30,8 @@ using namespace KDevelop;
template<>
QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix) const
const QString& htmlPrefix, const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const
{
if (!decl) {
const QUrl u = url().toUrl();
......@@ -40,20 +41,21 @@ QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte
item.isDirectory = false;
item.basePath = u.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
return new ClangNavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), htmlPrefix, htmlSuffix);
return new ClangNavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), htmlPrefix, htmlSuffix, hints);
}
return new ClangNavigationWidget(DeclarationPointer(decl));
return new ClangNavigationWidget(DeclarationPointer(decl), hints);
}
template<>
QWidget* ClangNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* /*topContext*/,
const QString& /*htmlPrefix*/, const QString& /*htmlSuffix*/) const
const QString& /*htmlPrefix*/, const QString& /*htmlSuffix*/,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const
{
if (!decl) {
clangDebug() << "no declaration, not returning navigationwidget";
return 0;
}
return new ClangNavigationWidget(DeclarationPointer(decl));
return new ClangNavigationWidget(DeclarationPointer(decl), hints);
}
DUCHAIN_DEFINE_TYPE_WITH_DATA(ClangNormalDUContext, DUContextData)
......
......@@ -40,7 +40,8 @@ public:
}
virtual QWidget* createNavigationWidget(KDevelop::Declaration* decl = 0, KDevelop::TopDUContext* topContext = 0,
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString()) const override;
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString(),
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints) const override;
enum {
Identity = IdentityT
......
......@@ -84,9 +84,10 @@ bool IncludeNavigationContext::filterDeclaration(Declaration* decl)
&& !(declId.startsWith(QLatin1String("__")) || (declId.startsWith(QLatin1Char('_')) && declId.length() > 1 && declId[1].isUpper()) );
}
ClangNavigationWidget::ClangNavigationWidget(const DeclarationPointer& declaration)
ClangNavigationWidget::ClangNavigationWidget(const DeclarationPointer& declaration, KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget()
{
setDisplayHints(hints);
if (auto macro = declaration.dynamicCast<MacroDefinition>()) {
initBrowser(200);
......@@ -102,8 +103,11 @@ ClangNavigationWidget::ClangNavigationWidget(const DeclarationPointer& declarati
}
}
ClangNavigationWidget::ClangNavigationWidget(const MacroDefinition::Ptr& macro, const KDevelop::DocumentCursor& expansionLocation)
ClangNavigationWidget::ClangNavigationWidget(const MacroDefinition::Ptr& macro, const KDevelop::DocumentCursor& expansionLocation,
KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget()
{
setDisplayHints(hints);
initBrowser(400);
//The first context is registered so it is kept alive by the shared-pointer mechanism
......@@ -112,8 +116,11 @@ ClangNavigationWidget::ClangNavigationWidget(const MacroDefinition::Ptr& macro,
}
ClangNavigationWidget::ClangNavigationWidget(const IncludeItem& includeItem, KDevelop::TopDUContextPointer topContext,
const QString& htmlPrefix, const QString& htmlSuffix)
const QString& htmlPrefix, const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget()
{
setDisplayHints(hints);
m_topContext = topContext;
initBrowser(200);
......
......@@ -38,10 +38,13 @@ class IncludeItem;
class KDEVCLANGPRIVATE_EXPORT ClangNavigationWidget : public KDevelop::AbstractNavigationWidget
{
public:
ClangNavigationWidget(const KDevelop::DeclarationPointer& declaration);
ClangNavigationWidget(const MacroDefinition::Ptr& macro, const KDevelop::DocumentCursor& expansionLocation);
ClangNavigationWidget(const KDevelop::DeclarationPointer& declaration,
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints);
ClangNavigationWidget(const MacroDefinition::Ptr& macro, const KDevelop::DocumentCursor& expansionLocation,
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints);
ClangNavigationWidget(const KDevelop::IncludeItem& includeItem, KDevelop::TopDUContextPointer topContext,
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString());
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString(),
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints);
virtual ~ClangNavigationWidget() = default;
/// Used by @see AbstractIncludeFileCompletionItem
......
......@@ -31,7 +31,8 @@ namespace QmlJS {
NavigationWidget::NavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix)
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints)
{
m_topContext = TopDUContextPointer(topContext);
m_startContext = NavigationContextPointer(new DeclarationNavigationContext(
......@@ -41,6 +42,7 @@ NavigationWidget::NavigationWidget(KDevelop::Declaration* decl,
));
m_startContext->setPrefixSuffix(htmlPrefix, htmlSuffix);
m_hints = hints;
setContext(m_startContext);
}
......
......@@ -34,9 +34,10 @@ public:
NavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix);
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints);
};
}
#endif
\ No newline at end of file
#endif
......@@ -35,21 +35,25 @@ using namespace KDevelop;
namespace QmlJS {
template<>
QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, const QString& htmlPrefix, const QString& htmlSuffix) const {
QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
AbstractNavigationWidget::DisplayHints hints) const
{
if (!decl) {
qCDebug(KDEV_QMLJS_DUCHAIN) << "no declaration, not returning navigationwidget";
return nullptr;
}
return new NavigationWidget(decl, topContext, htmlPrefix, htmlSuffix);
return new NavigationWidget(decl, topContext, htmlPrefix, htmlSuffix, hints);
}
template<>
QWidget* QmlJSNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, const QString& htmlPrefix, const QString& htmlSuffix) const {
QWidget* QmlJSNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, const QString& htmlPrefix,
const QString& htmlSuffix, AbstractNavigationWidget::DisplayHints hints) const {
if (!decl) {
qCDebug(KDEV_QMLJS_DUCHAIN) << "no declaration, not returning navigationwidget";
return nullptr;
}
return new NavigationWidget(decl, topContext, htmlPrefix, htmlSuffix);
return new NavigationWidget(decl, topContext, htmlPrefix, htmlSuffix, hints);
}
}
......
......@@ -64,7 +64,8 @@ public:
virtual QWidget* createNavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix) const override;
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const override;
enum {
Identity = IdentityT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment