Commit 12e3583f authored by Milian Wolff's avatar Milian Wolff

cleanup: remove html prefix/suffix feature from navigation widget

This was *only* being used by the project file quickopen feature,
and you only saw it when clicking into the quickopen list, or when
pressing alt. I doubt anyone ever did that. And it was madness
anyways: we decreased the font size in a hacky non-html compliant
way which actually made it quite hard to read for me. So the only
thing we lose is the project name... which is an acceptable
tradeoff. This feature messed up the whole API considerably, removing
it makes me very happy.

We can bring back the project name in the future by introducing a
generic wrapper-widget that supports the
QuickOpenEmbeddedWidgetInterface.
parent 518e7871
...@@ -1496,7 +1496,6 @@ TopDUContext* DUContext::topContext() const ...@@ -1496,7 +1496,6 @@ TopDUContext* DUContext::topContext() const
} }
QWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, QWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
AbstractNavigationWidget::DisplayHints hints) const AbstractNavigationWidget::DisplayHints hints) const
{ {
if (decl) { if (decl) {
...@@ -1506,7 +1505,6 @@ QWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topC ...@@ -1506,7 +1505,6 @@ QWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topC
decl), decl),
TopDUContextPointer( TopDUContextPointer(
topContext)); topContext));
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
widget->setContext(NavigationContextPointer(context)); widget->setContext(NavigationContextPointer(context));
return widget; return widget;
} else { } else {
......
...@@ -675,8 +675,6 @@ private: ...@@ -675,8 +675,6 @@ private:
* Zero to create a widget for this context. * Zero to create a widget for this context.
* @param topContext Top-context from where the navigation-widget is triggered. * @param topContext Top-context from where the navigation-widget is triggered.
* In C++, this is needed to resolve forward-declarations. * In C++, this is needed to resolve forward-declarations.
* @param htmlPrefix Html-formatted text that should be prepended before any information shown by this widget
* @param htmlSuffix Html-formatted text that should be appended to any information shown by this widget
* *
* Can return zero which disables the navigation widget. * Can return zero which disables the navigation widget.
* *
...@@ -685,8 +683,6 @@ private: ...@@ -685,8 +683,6 @@ private:
* enables you to change the document contents from the widget without immediately closing the widget. * enables you to change the document contents from the widget without immediately closing the widget.
*/ */
virtual QWidget* createNavigationWidget(Declaration* decl = nullptr, TopDUContext* topContext = nullptr, virtual QWidget* createNavigationWidget(Declaration* decl = nullptr, TopDUContext* topContext = nullptr,
const QString& htmlPrefix = QString(),
const QString& htmlSuffix = QString(),
AbstractNavigationWidget::DisplayHints hints = AbstractNavigationWidget::DisplayHints hints =
AbstractNavigationWidget::NoHints) const; AbstractNavigationWidget::NoHints) const;
......
...@@ -90,8 +90,6 @@ QString AbstractDeclarationNavigationContext::html(bool shorten) ...@@ -90,8 +90,6 @@ QString AbstractDeclarationNavigationContext::html(bool shorten)
modifyHtml() += QLatin1String("<html><body><p>"); modifyHtml() += QLatin1String("<html><body><p>");
addExternalHtml(prefix());
if (!d->m_declaration.data()) { if (!d->m_declaration.data()) {
modifyHtml() += i18n("<br /> lost declaration <br />"); modifyHtml() += i18n("<br /> lost declaration <br />");
return currentHtml(); return currentHtml();
...@@ -365,8 +363,6 @@ QString AbstractDeclarationNavigationContext::html(bool shorten) ...@@ -365,8 +363,6 @@ QString AbstractDeclarationNavigationContext::html(bool shorten)
//modifyHtml() += "<br />"; //modifyHtml() += "<br />";
addExternalHtml(suffix());
modifyHtml() += QLatin1String("</p></body></html>"); modifyHtml() += QLatin1String("</p></body></html>");
return currentHtml(); return currentHtml();
......
...@@ -78,7 +78,6 @@ QString AbstractIncludeNavigationContext::html(bool shorten) ...@@ -78,7 +78,6 @@ QString AbstractIncludeNavigationContext::html(bool shorten)
{ {
clear(); clear();
modifyHtml() += QLatin1String("<html><body><p>"); modifyHtml() += QLatin1String("<html><body><p>");
addExternalHtml(prefix());
QUrl u = m_item.url(); QUrl u = m_item.url();
NavigationAction action(u, KTextEditor::Cursor(0, 0)); NavigationAction action(u, KTextEditor::Cursor(0, 0));
...@@ -102,8 +101,6 @@ QString AbstractIncludeNavigationContext::html(bool shorten) ...@@ -102,8 +101,6 @@ QString AbstractIncludeNavigationContext::html(bool shorten)
modifyHtml() += i18n("not parsed yet"); modifyHtml() += i18n("not parsed yet");
} }
addExternalHtml(suffix());
modifyHtml() += QLatin1String("</p></body></html>"); modifyHtml() += QLatin1String("</p></body></html>");
return currentHtml(); return currentHtml();
} }
......
...@@ -56,7 +56,6 @@ public: ...@@ -56,7 +56,6 @@ public:
QMap<int, int> m_linkLines; //Holds the line for each link QMap<int, int> m_linkLines; //Holds the line for each link
QMap<int, NavigationAction> m_intLinks; QMap<int, NavigationAction> m_intLinks;
AbstractNavigationContext* m_previousContext; AbstractNavigationContext* m_previousContext;
QString m_prefix, m_suffix;
TopDUContextPointer m_topContext; TopDUContextPointer m_topContext;
QString m_currentText; //Here the text is built QString m_currentText; //Here the text is built
...@@ -87,32 +86,6 @@ AbstractNavigationContext::~AbstractNavigationContext() ...@@ -87,32 +86,6 @@ AbstractNavigationContext::~AbstractNavigationContext()
{ {
} }
void AbstractNavigationContext::addExternalHtml(const QString& text)
{
int lastPos = 0;
int pos = 0;
QString fileMark = QStringLiteral("KDEV_FILE_LINK{");
while (pos < text.length() && (pos = text.indexOf(fileMark, pos)) != -1) {
modifyHtml() += text.mid(lastPos, pos - lastPos);
pos += fileMark.length();
if (pos != text.length()) {
int fileEnd = text.indexOf(QLatin1Char('}'), pos);
if (fileEnd != -1) {
QString file = text.mid(pos, fileEnd - pos);
pos = fileEnd + 1;
const QUrl url = QUrl::fromUserInput(file);
makeLink(url.fileName(), file, NavigationAction(url, KTextEditor::Cursor()));
}
}
lastPos = pos;
}
modifyHtml() += text.mid(lastPos, text.length() - lastPos);
}
void AbstractNavigationContext::makeLink(const QString& name, const DeclarationPointer& declaration, void AbstractNavigationContext::makeLink(const QString& name, const DeclarationPointer& declaration,
NavigationAction::Type actionType) NavigationAction::Type actionType)
{ {
...@@ -398,22 +371,6 @@ int AbstractNavigationContext::linkCount() const ...@@ -398,22 +371,6 @@ int AbstractNavigationContext::linkCount() const
return d->m_linkCount; return d->m_linkCount;
} }
QString AbstractNavigationContext::prefix() const
{
return d->m_prefix;
}
QString AbstractNavigationContext::suffix() const
{
return d->m_suffix;
}
void AbstractNavigationContext::setPrefixSuffix(const QString& prefix, const QString& suffix)
{
d->m_prefix = prefix;
d->m_suffix = suffix;
}
NavigationContextPointer AbstractNavigationContext::back() NavigationContextPointer AbstractNavigationContext::back()
{ {
if (d->m_previousContext) if (d->m_previousContext)
......
...@@ -74,10 +74,6 @@ public: ...@@ -74,10 +74,6 @@ public:
void up(); void up();
void down(); void down();
QString prefix() const;
QString suffix() const;
void setPrefixSuffix(const QString& prefix, const QString& suffix);
NavigationContextPointer accept(); NavigationContextPointer accept();
NavigationContextPointer back(); NavigationContextPointer back();
NavigationContextPointer accept(IndexedDeclaration decl); NavigationContextPointer accept(IndexedDeclaration decl);
...@@ -143,8 +139,6 @@ protected: ...@@ -143,8 +139,6 @@ protected:
//Clears the computed html and links //Clears the computed html and links
void clear(); void clear();
void addExternalHtml(const QString& text);
///Creates and registers a link to the given declaration, labeled by the given name ///Creates and registers a link to the given declaration, labeled by the given name
virtual void makeLink(const QString& name, const DeclarationPointer& declaration, virtual void makeLink(const QString& name, const DeclarationPointer& declaration,
NavigationAction::Type actionType); NavigationAction::Type actionType);
......
...@@ -30,7 +30,6 @@ using namespace KDevelop; ...@@ -30,7 +30,6 @@ using namespace KDevelop;
template<> template<>
QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const KDevelop::AbstractNavigationWidget::DisplayHints hints) const
{ {
if (!decl) { if (!decl) {
...@@ -41,14 +40,13 @@ QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte ...@@ -41,14 +40,13 @@ QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte
item.isDirectory = false; item.isDirectory = false;
item.basePath = u.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); item.basePath = u.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
return new ClangNavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), htmlPrefix, htmlSuffix, hints); return new ClangNavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), hints);
} }
return new ClangNavigationWidget(DeclarationPointer(decl), hints); return new ClangNavigationWidget(DeclarationPointer(decl), hints);
} }
template<> template<>
QWidget* ClangNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* /*topContext*/, QWidget* ClangNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* /*topContext*/,
const QString& /*htmlPrefix*/, const QString& /*htmlSuffix*/,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const KDevelop::AbstractNavigationWidget::DisplayHints hints) const
{ {
if (!decl) { if (!decl) {
......
...@@ -41,7 +41,6 @@ public: ...@@ -41,7 +41,6 @@ public:
QWidget* createNavigationWidget(KDevelop::Declaration* decl = nullptr, QWidget* createNavigationWidget(KDevelop::Declaration* decl = nullptr,
KDevelop::TopDUContext* topContext = nullptr, KDevelop::TopDUContext* topContext = nullptr,
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString(),
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints) const override; KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints) const override;
enum { enum {
......
...@@ -47,7 +47,6 @@ QString MacroNavigationContext::html(bool shorten) ...@@ -47,7 +47,6 @@ QString MacroNavigationContext::html(bool shorten)
clear(); clear();
modifyHtml() += QLatin1String("<html><body><p>"); modifyHtml() += QLatin1String("<html><body><p>");
addExternalHtml(prefix());
QStringList parameterList; QStringList parameterList;
parameterList.reserve(m_macro->parametersSize()); parameterList.reserve(m_macro->parametersSize());
......
...@@ -110,7 +110,6 @@ ClangNavigationWidget::ClangNavigationWidget(const MacroDefinition::Ptr& macro, ...@@ -110,7 +110,6 @@ ClangNavigationWidget::ClangNavigationWidget(const MacroDefinition::Ptr& macro,
} }
ClangNavigationWidget::ClangNavigationWidget(const IncludeItem& includeItem, const KDevelop::TopDUContextPointer& topContext, ClangNavigationWidget::ClangNavigationWidget(const IncludeItem& includeItem, const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget() : AbstractNavigationWidget()
{ {
...@@ -119,7 +118,6 @@ ClangNavigationWidget::ClangNavigationWidget(const IncludeItem& includeItem, con ...@@ -119,7 +118,6 @@ ClangNavigationWidget::ClangNavigationWidget(const IncludeItem& includeItem, con
//The first context is registered so it is kept alive by the shared-pointer mechanism //The first context is registered so it is kept alive by the shared-pointer mechanism
auto context = new IncludeNavigationContext(includeItem, topContext); auto context = new IncludeNavigationContext(includeItem, topContext);
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
setContext(NavigationContextPointer(context)); setContext(NavigationContextPointer(context));
} }
......
...@@ -44,7 +44,6 @@ public: ...@@ -44,7 +44,6 @@ public:
ClangNavigationWidget(const MacroDefinition::Ptr& macro, const KDevelop::DocumentCursor& expansionLocation, ClangNavigationWidget(const MacroDefinition::Ptr& macro, const KDevelop::DocumentCursor& expansionLocation,
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints); KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints);
ClangNavigationWidget(const KDevelop::IncludeItem& includeItem, const KDevelop::TopDUContextPointer& topContext, ClangNavigationWidget(const KDevelop::IncludeItem& includeItem, const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString(),
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints); KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints);
~ClangNavigationWidget() override = default; ~ClangNavigationWidget() override = default;
......
...@@ -135,8 +135,7 @@ QWidget* ContextBrowserView::createWidget(KDevelop::DUContext* context) ...@@ -135,8 +135,7 @@ QWidget* ContextBrowserView::createWidget(KDevelop::DUContext* context)
{ {
m_context = IndexedDUContext(context); m_context = IndexedDUContext(context);
if (m_context.data()) { if (m_context.data()) {
return m_context.data()->createNavigationWidget(nullptr, nullptr, {}, {}, return m_context.data()->createNavigationWidget(nullptr, nullptr, AbstractNavigationWidget::EmbeddableWidget);
AbstractNavigationWidget::EmbeddableWidget);
} }
return nullptr; return nullptr;
} }
...@@ -149,8 +148,7 @@ KDevelop::IndexedDeclaration ContextBrowserView::declaration() const ...@@ -149,8 +148,7 @@ KDevelop::IndexedDeclaration ContextBrowserView::declaration() const
QWidget* ContextBrowserView::createWidget(Declaration* decl, TopDUContext* topContext) QWidget* ContextBrowserView::createWidget(Declaration* decl, TopDUContext* topContext)
{ {
m_declaration = IndexedDeclaration(decl); m_declaration = IndexedDeclaration(decl);
return decl->context()->createNavigationWidget(decl, topContext, {}, {}, return decl->context()->createNavigationWidget(decl, topContext, AbstractNavigationWidget::EmbeddableWidget);
AbstractNavigationWidget::EmbeddableWidget);
} }
void ContextBrowserView::resetWidget() void ContextBrowserView::resetWidget()
......
...@@ -31,23 +31,18 @@ namespace QmlJS { ...@@ -31,23 +31,18 @@ namespace QmlJS {
NavigationWidget::NavigationWidget(KDevelop::Declaration* decl, NavigationWidget::NavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext, KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) KDevelop::AbstractNavigationWidget::DisplayHints hints)
{ {
auto context = new DeclarationNavigationContext( auto context = new DeclarationNavigationContext(
DeclarationPointer(decl), DeclarationPointer(decl),
TopDUContextPointer(topContext) TopDUContextPointer(topContext)
); );
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
setContext(NavigationContextPointer(context)); setContext(NavigationContextPointer(context));
setDisplayHints(hints); setDisplayHints(hints);
} }
NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem, NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem,
const KDevelop::TopDUContextPointer& topContext, const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget() : AbstractNavigationWidget()
{ {
...@@ -57,7 +52,6 @@ NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem, ...@@ -57,7 +52,6 @@ NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem,
auto context = new AbstractIncludeNavigationContext( auto context = new AbstractIncludeNavigationContext(
includeItem, topContext, includeItem, topContext,
StandardParsingEnvironment); StandardParsingEnvironment);
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
setContext(NavigationContextPointer(context)); setContext(NavigationContextPointer(context));
} }
} }
...@@ -38,13 +38,9 @@ class KDEVQMLJSDUCHAIN_EXPORT NavigationWidget : public KDevelop::AbstractNaviga ...@@ -38,13 +38,9 @@ class KDEVQMLJSDUCHAIN_EXPORT NavigationWidget : public KDevelop::AbstractNaviga
public: public:
NavigationWidget(KDevelop::Declaration* decl, NavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext, KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints); KDevelop::AbstractNavigationWidget::DisplayHints hints);
NavigationWidget(const KDevelop::IncludeItem& includeItem, NavigationWidget(const KDevelop::IncludeItem& includeItem,
const KDevelop::TopDUContextPointer& topContext, const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints); KDevelop::AbstractNavigationWidget::DisplayHints hints);
}; };
......
...@@ -37,7 +37,6 @@ namespace QmlJS { ...@@ -37,7 +37,6 @@ namespace QmlJS {
template<> template<>
QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
AbstractNavigationWidget::DisplayHints hints) const AbstractNavigationWidget::DisplayHints hints) const
{ {
if (!decl) { if (!decl) {
...@@ -48,19 +47,18 @@ QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte ...@@ -48,19 +47,18 @@ QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte
item.isDirectory = false; item.isDirectory = false;
item.basePath = u.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); item.basePath = u.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
return new NavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), htmlPrefix, htmlSuffix, hints); return new NavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), hints);
} }
return new NavigationWidget(decl, topContext, htmlPrefix, htmlSuffix, hints); return new NavigationWidget(decl, topContext, hints);
} }
template<> template<>
QWidget* QmlJSNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, const QString& htmlPrefix, QWidget* QmlJSNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, AbstractNavigationWidget::DisplayHints hints) const {
const QString& htmlSuffix, AbstractNavigationWidget::DisplayHints hints) const {
if (!decl) { if (!decl) {
qCDebug(KDEV_QMLJS_DUCHAIN) << "no declaration, not returning navigationwidget"; qCDebug(KDEV_QMLJS_DUCHAIN) << "no declaration, not returning navigationwidget";
return nullptr; return nullptr;
} }
return new NavigationWidget(decl, topContext, htmlPrefix, htmlSuffix, hints); return new NavigationWidget(decl, topContext, hints);
} }
} }
......
...@@ -63,8 +63,6 @@ public: ...@@ -63,8 +63,6 @@ public:
QWidget* createNavigationWidget(KDevelop::Declaration* decl, QWidget* createNavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext, KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const override; KDevelop::AbstractNavigationWidget::DisplayHints hints) const override;
enum { enum {
......
...@@ -196,7 +196,7 @@ QWidget* DUChainItemData::expandingWidget() const ...@@ -196,7 +196,7 @@ QWidget* DUChainItemData::expandingWidget() const
} }
return decl->context()->createNavigationWidget(decl, decl->topContext(), return decl->context()->createNavigationWidget(decl, decl->topContext(),
QString(), QString(), AbstractNavigationWidget::EmbeddableWidget); AbstractNavigationWidget::EmbeddableWidget);
} }
QIcon DUChainItemData::icon() const QIcon DUChainItemData::icon() const
......
...@@ -146,10 +146,8 @@ QWidget* ProjectFileData::expandingWidget() const ...@@ -146,10 +146,8 @@ QWidget* ProjectFileData::expandingWidget() const
} }
if (chosen) { if (chosen) {
return chosen->createNavigationWidget(nullptr, nullptr, // TODO: show project name, by introducing a generic wrapper widget that supports QuickOpenEmbeddedWidgetInterface
QLatin1String("<small><small>") return chosen->createNavigationWidget();
+ i18nc("%1: project name", "Project %1", project())
+ QLatin1String("</small></small><br/>"));
} else { } else {
auto* ret = new QTextBrowser(); auto* ret = new QTextBrowser();
ret->resize(400, 100); ret->resize(400, 100);
......
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