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
}
QWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
AbstractNavigationWidget::DisplayHints hints) const
{
if (decl) {
......@@ -1506,7 +1505,6 @@ QWidget* DUContext::createNavigationWidget(Declaration* decl, TopDUContext* topC
decl),
TopDUContextPointer(
topContext));
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
widget->setContext(NavigationContextPointer(context));
return widget;
} else {
......
......@@ -675,8 +675,6 @@ private:
* Zero to create a widget for this context.
* @param topContext Top-context from where the navigation-widget is triggered.
* 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.
*
......@@ -685,8 +683,6 @@ private:
* enables you to change the document contents from the widget without immediately closing the widget.
*/
virtual QWidget* createNavigationWidget(Declaration* decl = nullptr, TopDUContext* topContext = nullptr,
const QString& htmlPrefix = QString(),
const QString& htmlSuffix = QString(),
AbstractNavigationWidget::DisplayHints hints =
AbstractNavigationWidget::NoHints) const;
......
......@@ -90,8 +90,6 @@ QString AbstractDeclarationNavigationContext::html(bool shorten)
modifyHtml() += QLatin1String("<html><body><p>");
addExternalHtml(prefix());
if (!d->m_declaration.data()) {
modifyHtml() += i18n("<br /> lost declaration <br />");
return currentHtml();
......@@ -365,8 +363,6 @@ QString AbstractDeclarationNavigationContext::html(bool shorten)
//modifyHtml() += "<br />";
addExternalHtml(suffix());
modifyHtml() += QLatin1String("</p></body></html>");
return currentHtml();
......
......@@ -78,7 +78,6 @@ QString AbstractIncludeNavigationContext::html(bool shorten)
{
clear();
modifyHtml() += QLatin1String("<html><body><p>");
addExternalHtml(prefix());
QUrl u = m_item.url();
NavigationAction action(u, KTextEditor::Cursor(0, 0));
......@@ -102,8 +101,6 @@ QString AbstractIncludeNavigationContext::html(bool shorten)
modifyHtml() += i18n("not parsed yet");
}
addExternalHtml(suffix());
modifyHtml() += QLatin1String("</p></body></html>");
return currentHtml();
}
......
......@@ -56,7 +56,6 @@ public:
QMap<int, int> m_linkLines; //Holds the line for each link
QMap<int, NavigationAction> m_intLinks;
AbstractNavigationContext* m_previousContext;
QString m_prefix, m_suffix;
TopDUContextPointer m_topContext;
QString m_currentText; //Here the text is built
......@@ -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,
NavigationAction::Type actionType)
{
......@@ -398,22 +371,6 @@ int AbstractNavigationContext::linkCount() const
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()
{
if (d->m_previousContext)
......
......@@ -74,10 +74,6 @@ public:
void up();
void down();
QString prefix() const;
QString suffix() const;
void setPrefixSuffix(const QString& prefix, const QString& suffix);
NavigationContextPointer accept();
NavigationContextPointer back();
NavigationContextPointer accept(IndexedDeclaration decl);
......@@ -143,8 +139,6 @@ protected:
//Clears the computed html and links
void clear();
void addExternalHtml(const QString& text);
///Creates and registers a link to the given declaration, labeled by the given name
virtual void makeLink(const QString& name, const DeclarationPointer& declaration,
NavigationAction::Type actionType);
......
......@@ -30,7 +30,6 @@ using namespace KDevelop;
template<>
QWidget* ClangTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const
{
if (!decl) {
......@@ -41,14 +40,13 @@ 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, hints);
return new ClangNavigationWidget(item, TopDUContextPointer(topContext ? topContext : this->topContext()), hints);
}
return new ClangNavigationWidget(DeclarationPointer(decl), hints);
}
template<>
QWidget* ClangNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* /*topContext*/,
const QString& /*htmlPrefix*/, const QString& /*htmlSuffix*/,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const
{
if (!decl) {
......
......@@ -41,7 +41,6 @@ public:
QWidget* createNavigationWidget(KDevelop::Declaration* decl = nullptr,
KDevelop::TopDUContext* topContext = nullptr,
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString(),
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints) const override;
enum {
......
......@@ -47,7 +47,6 @@ QString MacroNavigationContext::html(bool shorten)
clear();
modifyHtml() += QLatin1String("<html><body><p>");
addExternalHtml(prefix());
QStringList parameterList;
parameterList.reserve(m_macro->parametersSize());
......
......@@ -110,7 +110,6 @@ ClangNavigationWidget::ClangNavigationWidget(const MacroDefinition::Ptr& macro,
}
ClangNavigationWidget::ClangNavigationWidget(const IncludeItem& includeItem, const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget()
{
......@@ -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
auto context = new IncludeNavigationContext(includeItem, topContext);
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
setContext(NavigationContextPointer(context));
}
......
......@@ -44,7 +44,6 @@ public:
ClangNavigationWidget(const MacroDefinition::Ptr& macro, const KDevelop::DocumentCursor& expansionLocation,
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints);
ClangNavigationWidget(const KDevelop::IncludeItem& includeItem, const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix = QString(), const QString& htmlSuffix = QString(),
KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints);
~ClangNavigationWidget() override = default;
......
......@@ -135,8 +135,7 @@ QWidget* ContextBrowserView::createWidget(KDevelop::DUContext* context)
{
m_context = IndexedDUContext(context);
if (m_context.data()) {
return m_context.data()->createNavigationWidget(nullptr, nullptr, {}, {},
AbstractNavigationWidget::EmbeddableWidget);
return m_context.data()->createNavigationWidget(nullptr, nullptr, AbstractNavigationWidget::EmbeddableWidget);
}
return nullptr;
}
......@@ -149,8 +148,7 @@ KDevelop::IndexedDeclaration ContextBrowserView::declaration() const
QWidget* ContextBrowserView::createWidget(Declaration* decl, TopDUContext* topContext)
{
m_declaration = IndexedDeclaration(decl);
return decl->context()->createNavigationWidget(decl, topContext, {}, {},
AbstractNavigationWidget::EmbeddableWidget);
return decl->context()->createNavigationWidget(decl, topContext, AbstractNavigationWidget::EmbeddableWidget);
}
void ContextBrowserView::resetWidget()
......
......@@ -31,23 +31,18 @@ namespace QmlJS {
NavigationWidget::NavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints)
{
auto context = new DeclarationNavigationContext(
DeclarationPointer(decl),
TopDUContextPointer(topContext)
);
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
setContext(NavigationContextPointer(context));
setDisplayHints(hints);
}
NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem,
const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints)
: AbstractNavigationWidget()
{
......@@ -57,7 +52,6 @@ NavigationWidget::NavigationWidget(const KDevelop::IncludeItem& includeItem,
auto context = new AbstractIncludeNavigationContext(
includeItem, topContext,
StandardParsingEnvironment);
context->setPrefixSuffix(htmlPrefix, htmlSuffix);
setContext(NavigationContextPointer(context));
}
}
......@@ -38,13 +38,9 @@ class KDEVQMLJSDUCHAIN_EXPORT NavigationWidget : public KDevelop::AbstractNaviga
public:
NavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints);
NavigationWidget(const KDevelop::IncludeItem& includeItem,
const KDevelop::TopDUContextPointer& topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints);
};
......
......@@ -37,7 +37,6 @@ namespace QmlJS {
template<>
QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
const QString& htmlPrefix, const QString& htmlSuffix,
AbstractNavigationWidget::DisplayHints hints) const
{
if (!decl) {
......@@ -48,19 +47,18 @@ QWidget* QmlJSTopDUContext::createNavigationWidget(Declaration* decl, TopDUConte
item.isDirectory = false;
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<>
QWidget* QmlJSNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext, const QString& htmlPrefix,
const QString& htmlSuffix, AbstractNavigationWidget::DisplayHints hints) const {
QWidget* 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, htmlPrefix, htmlSuffix, hints);
return new NavigationWidget(decl, topContext, hints);
}
}
......
......@@ -63,8 +63,6 @@ public:
QWidget* createNavigationWidget(KDevelop::Declaration* decl,
KDevelop::TopDUContext* topContext,
const QString& htmlPrefix,
const QString& htmlSuffix,
KDevelop::AbstractNavigationWidget::DisplayHints hints) const override;
enum {
......
......@@ -196,7 +196,7 @@ QWidget* DUChainItemData::expandingWidget() const
}
return decl->context()->createNavigationWidget(decl, decl->topContext(),
QString(), QString(), AbstractNavigationWidget::EmbeddableWidget);
AbstractNavigationWidget::EmbeddableWidget);
}
QIcon DUChainItemData::icon() const
......
......@@ -146,10 +146,8 @@ QWidget* ProjectFileData::expandingWidget() const
}
if (chosen) {
return chosen->createNavigationWidget(nullptr, nullptr,
QLatin1String("<small><small>")
+ i18nc("%1: project name", "Project %1", project())
+ QLatin1String("</small></small><br/>"));
// TODO: show project name, by introducing a generic wrapper widget that supports QuickOpenEmbeddedWidgetInterface
return chosen->createNavigationWidget();
} else {
auto* ret = new QTextBrowser();
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