forked from qt-creator/qt-creator
Move Help item from text editor to core
The functionality is not text editor specific. Change-Id: Iee531572f14673e75129f4bfbb64a1437899d31e Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -277,26 +277,26 @@ void BackendReceiver::references(const ReferencesMessage &message)
|
||||
futureInterface.reportFinished();
|
||||
}
|
||||
|
||||
static TextEditor::HelpItem::Category toHelpItemCategory(ToolTipInfo::QdocCategory category)
|
||||
static Core::HelpItem::Category toHelpItemCategory(ToolTipInfo::QdocCategory category)
|
||||
{
|
||||
switch (category) {
|
||||
case ToolTipInfo::Unknown:
|
||||
return TextEditor::HelpItem::Unknown;
|
||||
return Core::HelpItem::Unknown;
|
||||
case ToolTipInfo::ClassOrNamespace:
|
||||
return TextEditor::HelpItem::ClassOrNamespace;
|
||||
return Core::HelpItem::ClassOrNamespace;
|
||||
case ToolTipInfo::Enum:
|
||||
return TextEditor::HelpItem::Enum;
|
||||
return Core::HelpItem::Enum;
|
||||
case ToolTipInfo::Typedef:
|
||||
return TextEditor::HelpItem::Typedef;
|
||||
return Core::HelpItem::Typedef;
|
||||
case ToolTipInfo::Macro:
|
||||
return TextEditor::HelpItem::Macro;
|
||||
return Core::HelpItem::Macro;
|
||||
case ToolTipInfo::Brief:
|
||||
return TextEditor::HelpItem::Brief;
|
||||
return Core::HelpItem::Brief;
|
||||
case ToolTipInfo::Function:
|
||||
return TextEditor::HelpItem::Function;
|
||||
return Core::HelpItem::Function;
|
||||
}
|
||||
|
||||
return TextEditor::HelpItem::Unknown;
|
||||
return Core::HelpItem::Unknown;
|
||||
}
|
||||
|
||||
static QStringList toStringList(const Utf8StringVector &utf8StringVector)
|
||||
|
@@ -230,8 +230,8 @@ void ClangHoverHandler::abort()
|
||||
}
|
||||
}
|
||||
|
||||
#define RETURN_TEXT_FOR_CASE(enumValue) case TextEditor::HelpItem::enumValue: return #enumValue
|
||||
static const char *helpItemCategoryAsString(TextEditor::HelpItem::Category category)
|
||||
#define RETURN_TEXT_FOR_CASE(enumValue) case Core::HelpItem::enumValue: return #enumValue
|
||||
static const char *helpItemCategoryAsString(Core::HelpItem::Category category)
|
||||
{
|
||||
switch (category) {
|
||||
RETURN_TEXT_FOR_CASE(Unknown);
|
||||
@@ -267,7 +267,7 @@ void ClangHoverHandler::processToolTipInfo(const CppTools::ToolTipInfo &info)
|
||||
if (!helpLinks.isEmpty()) {
|
||||
qCDebug(hoverLog) << " Match!";
|
||||
setLastHelpItemIdentified(
|
||||
HelpItem(qdocIdCandidate, info.qDocMark, info.qDocCategory, helpLinks));
|
||||
Core::HelpItem(qdocIdCandidate, info.qDocMark, info.qDocCategory, helpLinks));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ void ClangHoverHandler::operateTooltip(TextEditor::TextEditorWidget *editorWidge
|
||||
const QPoint &point)
|
||||
{
|
||||
if (priority() == Priority_Diagnostic) {
|
||||
const HelpItem helpItem = lastHelpItemIdentified();
|
||||
const Core::HelpItem helpItem = lastHelpItemIdentified();
|
||||
const QString helpId = helpItem.isValid() ? helpItem.helpId() : QString();
|
||||
processWithEditorDocumentProcessor(editorWidget, point, m_cursorPosition, helpId);
|
||||
return;
|
||||
|
@@ -80,6 +80,7 @@ SOURCES += corejsextensions.cpp \
|
||||
editormanager/systemeditor.cpp \
|
||||
designmode.cpp \
|
||||
editortoolbar.cpp \
|
||||
helpitem.cpp \
|
||||
helpmanager.cpp \
|
||||
outputpanemanager.cpp \
|
||||
navigationsubwidget.cpp \
|
||||
@@ -192,6 +193,7 @@ HEADERS += corejsextensions.h \
|
||||
editormanager/systemeditor.h \
|
||||
designmode.h \
|
||||
editortoolbar.h \
|
||||
helpitem.h \
|
||||
helpmanager.h \
|
||||
helpmanager_implementation.h \
|
||||
outputpanemanager.h \
|
||||
|
@@ -84,6 +84,8 @@ Project {
|
||||
"generalsettings.ui",
|
||||
"generatedfile.cpp",
|
||||
"generatedfile.h",
|
||||
"helpitem.cpp",
|
||||
"helpitem.h",
|
||||
"helpmanager.cpp",
|
||||
"helpmanager.h",
|
||||
"helpmanager_implementation.h",
|
||||
|
@@ -24,11 +24,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "helpitem.h"
|
||||
#include "helpmanager.h"
|
||||
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <utils/htmldocextractor.h>
|
||||
|
||||
using namespace TextEditor;
|
||||
using namespace Core;
|
||||
|
||||
HelpItem::HelpItem() = default;
|
||||
|
@@ -25,15 +25,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "texteditor_global.h"
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Core {
|
||||
|
||||
class TEXTEDITOR_EXPORT HelpItem
|
||||
class CORE_EXPORT HelpItem
|
||||
{
|
||||
public:
|
||||
enum Category {
|
||||
@@ -79,4 +79,4 @@ private:
|
||||
mutable QMap<QString, QUrl> m_helpLinks; // cached help links
|
||||
};
|
||||
|
||||
} // namespace TextEditor
|
||||
} // namespace Core
|
@@ -31,8 +31,8 @@
|
||||
#include "cppsemanticinfo.h"
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <coreplugin/helpitem.h>
|
||||
#include <texteditor/codeassist/assistinterface.h>
|
||||
#include <texteditor/helpitem.h>
|
||||
#include <texteditor/quickfix.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
@@ -56,7 +56,7 @@ struct CPPTOOLS_EXPORT ToolTipInfo {
|
||||
|
||||
QStringList qDocIdCandidates;
|
||||
QString qDocMark;
|
||||
TextEditor::HelpItem::Category qDocCategory;
|
||||
Core::HelpItem::Category qDocCategory;
|
||||
|
||||
QString sizeInBytes;
|
||||
};
|
||||
|
@@ -85,7 +85,7 @@ public:
|
||||
: path(QDir::toNativeSeparators(includeFile.resolvedFileName()))
|
||||
, fileName(Utils::FileName::fromString(includeFile.resolvedFileName()).fileName())
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::Brief;
|
||||
helpCategory = Core::HelpItem::Brief;
|
||||
helpIdCandidates = QStringList(fileName);
|
||||
helpMark = fileName;
|
||||
link = Utils::Link(path);
|
||||
@@ -102,7 +102,7 @@ class CppMacro : public CppElement
|
||||
public:
|
||||
explicit CppMacro(const Macro ¯o)
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::Macro;
|
||||
helpCategory = Core::HelpItem::Macro;
|
||||
const QString macroName = QString::fromUtf8(macro.name(), macro.name().size());
|
||||
helpIdCandidates = QStringList(macroName);
|
||||
helpMark = macroName;
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
explicit CppNamespace(Symbol *declaration)
|
||||
: CppDeclarableElement(declaration)
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::ClassOrNamespace;
|
||||
helpCategory = Core::HelpItem::ClassOrNamespace;
|
||||
tooltip = qualifiedName;
|
||||
}
|
||||
};
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
|
||||
CppClass::CppClass(Symbol *declaration) : CppDeclarableElement(declaration)
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::ClassOrNamespace;
|
||||
helpCategory = Core::HelpItem::ClassOrNamespace;
|
||||
tooltip = qualifiedName;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public:
|
||||
explicit CppFunction(Symbol *declaration)
|
||||
: CppDeclarableElement(declaration)
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::Function;
|
||||
helpCategory = Core::HelpItem::Function;
|
||||
|
||||
const FullySpecifiedType &type = declaration->type();
|
||||
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
explicit CppEnum(Enum *declaration)
|
||||
: CppDeclarableElement(declaration)
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::Enum;
|
||||
helpCategory = Core::HelpItem::Enum;
|
||||
tooltip = qualifiedName;
|
||||
}
|
||||
};
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
explicit CppTypedef(Symbol *declaration)
|
||||
: CppDeclarableElement(declaration)
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::Typedef;
|
||||
helpCategory = Core::HelpItem::Typedef;
|
||||
tooltip = Overview().prettyType(declaration->type(), qualifiedName);
|
||||
}
|
||||
};
|
||||
@@ -288,7 +288,7 @@ public:
|
||||
LookupContext::fullyQualifiedName(symbol));
|
||||
if (!name.isEmpty()) {
|
||||
tooltip = name;
|
||||
helpCategory = TextEditor::HelpItem::ClassOrNamespace;
|
||||
helpCategory = Core::HelpItem::ClassOrNamespace;
|
||||
const QStringList &allNames = stripName(name);
|
||||
if (!allNames.isEmpty()) {
|
||||
helpMark = allNames.last();
|
||||
@@ -307,7 +307,7 @@ public:
|
||||
explicit CppEnumerator(EnumeratorDeclaration *declaration)
|
||||
: CppDeclarableElement(declaration)
|
||||
{
|
||||
helpCategory = TextEditor::HelpItem::Enum;
|
||||
helpCategory = Core::HelpItem::Enum;
|
||||
|
||||
Overview overview;
|
||||
|
||||
|
@@ -27,8 +27,8 @@
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <coreplugin/helpitem.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/helpitem.h>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
virtual CppClass *toCppClass();
|
||||
|
||||
TextEditor::HelpItem::Category helpCategory = TextEditor::HelpItem::Unknown;
|
||||
Core::HelpItem::Category helpCategory = Core::HelpItem::Unknown;
|
||||
QStringList helpIdCandidates;
|
||||
QString helpMark;
|
||||
Utils::Link link;
|
||||
|
@@ -34,7 +34,7 @@ namespace CppTools {
|
||||
class CPPTOOLS_EXPORT CppHoverHandler : public TextEditor::BaseHoverHandler
|
||||
{
|
||||
public:
|
||||
static QString tooltipTextForHelpItem(const TextEditor::HelpItem &help);
|
||||
static QString tooltipTextForHelpItem(const Core::HelpItem &help);
|
||||
|
||||
private:
|
||||
void identifyMatch(TextEditor::TextEditorWidget *editorWidget,
|
||||
|
@@ -63,12 +63,13 @@ void ProFileHoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidg
|
||||
if (m_manualKind != UnknownManual) {
|
||||
QUrl url(QString::fromLatin1("qthelp://org.qt-project.qmake/qmake/qmake-%1-reference.html#%2")
|
||||
.arg(manualName()).arg(m_docFragment));
|
||||
setLastHelpItemIdentified(TextEditor::HelpItem(url.toString(),
|
||||
m_docFragment, TextEditor::HelpItem::QMakeVariableOfFunction));
|
||||
setLastHelpItemIdentified(Core::HelpItem(url.toString(),
|
||||
m_docFragment,
|
||||
Core::HelpItem::QMakeVariableOfFunction));
|
||||
} else {
|
||||
// General qmake manual will be shown outside any function or variable
|
||||
setLastHelpItemIdentified(TextEditor::HelpItem(QLatin1String("qmake"),
|
||||
TextEditor::HelpItem::Unknown));
|
||||
setLastHelpItemIdentified(
|
||||
Core::HelpItem(QLatin1String("qmake"), Core::HelpItem::Unknown));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/helpitem.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
@@ -44,7 +45,6 @@
|
||||
#include <qmljs/qmljsutils.h>
|
||||
#include <qmljs/qmljsqrcparser.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/helpitem.h>
|
||||
#include <utils/executeondestruction.h>
|
||||
#include <utils/tooltip/tooltip.h>
|
||||
|
||||
|
@@ -99,12 +99,12 @@ const QString &BaseHoverHandler::toolTip() const
|
||||
return m_toolTip;
|
||||
}
|
||||
|
||||
void BaseHoverHandler::setLastHelpItemIdentified(const HelpItem &help)
|
||||
void BaseHoverHandler::setLastHelpItemIdentified(const Core::HelpItem &help)
|
||||
{
|
||||
m_lastHelpItemIdentified = help;
|
||||
}
|
||||
|
||||
const HelpItem &BaseHoverHandler::lastHelpItemIdentified() const
|
||||
const Core::HelpItem &BaseHoverHandler::lastHelpItemIdentified() const
|
||||
{
|
||||
return m_lastHelpItemIdentified;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ void BaseHoverHandler::process(TextEditorWidget *widget, int pos, ReportPriority
|
||||
{
|
||||
m_toolTip.clear();
|
||||
m_priority = -1;
|
||||
m_lastHelpItemIdentified = HelpItem();
|
||||
m_lastHelpItemIdentified = Core::HelpItem();
|
||||
|
||||
identifyMatch(widget, pos, report);
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "texteditor_global.h"
|
||||
#include "helpitem.h"
|
||||
|
||||
#include <coreplugin/helpitem.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
#include <functional>
|
||||
@@ -68,8 +68,8 @@ protected:
|
||||
void setToolTip(const QString &tooltip);
|
||||
const QString &toolTip() const;
|
||||
|
||||
void setLastHelpItemIdentified(const HelpItem &help);
|
||||
const HelpItem &lastHelpItemIdentified() const;
|
||||
void setLastHelpItemIdentified(const Core::HelpItem &help);
|
||||
const Core::HelpItem &lastHelpItemIdentified() const;
|
||||
|
||||
bool isContextHelpRequest() const;
|
||||
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
void process(TextEditorWidget *widget, int pos, ReportPriority report);
|
||||
|
||||
QString m_toolTip;
|
||||
HelpItem m_lastHelpItemIdentified;
|
||||
Core::HelpItem m_lastHelpItemIdentified;
|
||||
int m_priority = -1;
|
||||
bool m_isContextHelpRequest = false;
|
||||
};
|
||||
|
@@ -56,7 +56,6 @@ SOURCES += texteditorplugin.cpp \
|
||||
outlinefactory.cpp \
|
||||
basehoverhandler.cpp \
|
||||
colorpreviewhoverhandler.cpp \
|
||||
helpitem.cpp \
|
||||
autocompleter.cpp \
|
||||
snippets/snippetssettingspage.cpp \
|
||||
snippets/snippet.cpp \
|
||||
@@ -165,7 +164,6 @@ HEADERS += texteditorplugin.h \
|
||||
ioutlinewidget.h \
|
||||
basehoverhandler.h \
|
||||
colorpreviewhoverhandler.h \
|
||||
helpitem.h \
|
||||
autocompleter.h \
|
||||
snippets/snippetssettingspage.h \
|
||||
snippets/snippet.h \
|
||||
|
@@ -80,8 +80,6 @@ Project {
|
||||
"fontsettingspage.ui",
|
||||
"formattexteditor.cpp",
|
||||
"formattexteditor.h",
|
||||
"helpitem.cpp",
|
||||
"helpitem.h",
|
||||
"highlighterutils.cpp",
|
||||
"highlighterutils.h",
|
||||
"icodestylepreferences.cpp",
|
||||
|
Reference in New Issue
Block a user