summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cppeditor/cppeditor.pro2
-rw-r--r--src/plugins/cppeditor/cppeditor.qrc1
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.cpp (renamed from src/plugins/cpptools/cpphoverhandler.cpp)48
-rw-r--r--src/plugins/cppeditor/cpphoverhandler.h (renamed from src/plugins/cpptools/cpphoverhandler.h)25
-rw-r--r--src/plugins/cppeditor/cppplugin.cpp7
-rw-r--r--src/plugins/cppeditor/images/f1.svg (renamed from src/plugins/cpptools/images/f1.svg)0
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp11
-rw-r--r--src/plugins/cpptools/cppmodelmanager.h2
-rw-r--r--src/plugins/cpptools/cpptools.pro5
-rw-r--r--src/plugins/cpptools/cpptools.qrc5
-rw-r--r--src/plugins/cpptools/cpptoolseditorsupport.h1
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.cpp1
12 files changed, 64 insertions, 44 deletions
diff --git a/src/plugins/cppeditor/cppeditor.pro b/src/plugins/cppeditor/cppeditor.pro
index cb71e9a838..8ac3b334df 100644
--- a/src/plugins/cppeditor/cppeditor.pro
+++ b/src/plugins/cppeditor/cppeditor.pro
@@ -8,6 +8,7 @@ HEADERS += cppplugin.h \
cppeditor.h \
cppeditoractionhandler.h \
cpphighlighter.h \
+ cpphoverhandler.h \
cppfilewizard.h \
cppeditorconstants.h \
cppeditorenums.h \
@@ -17,6 +18,7 @@ SOURCES += cppplugin.cpp \
cppeditoractionhandler.cpp \
cppeditor.cpp \
cpphighlighter.cpp \
+ cpphoverhandler.cpp \
cppfilewizard.cpp \
cppclasswizard.cpp
RESOURCES += cppeditor.qrc
diff --git a/src/plugins/cppeditor/cppeditor.qrc b/src/plugins/cppeditor/cppeditor.qrc
index 6ddcbac8bb..9a69ae6ab9 100644
--- a/src/plugins/cppeditor/cppeditor.qrc
+++ b/src/plugins/cppeditor/cppeditor.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/cppeditor" >
+ <file>images/f1.svg</file>
<file>images/qt_cpp.png</file>
<file>images/qt_h.png</file>
<file>CppEditor.mimetypes.xml</file>
diff --git a/src/plugins/cpptools/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp
index 497ac78d74..439fc2ad96 100644
--- a/src/plugins/cpptools/cpphoverhandler.cpp
+++ b/src/plugins/cppeditor/cpphoverhandler.cpp
@@ -32,10 +32,13 @@
***************************************************************************/
#include "cpphoverhandler.h"
-#include "cppmodelmanager.h"
+#include "cppeditor.h"
+#include "cppplugin.h"
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <cpptools/cppmodelmanagerinterface.h>
#include <texteditor/itexteditor.h>
#include <texteditor/basetexteditor.h>
#include <debugger/debuggerconstants.h>
@@ -57,12 +60,16 @@
#include <QtHelp/QHelpEngineCore>
#include <QtCore/QtCore>
-using namespace CppTools::Internal;
+using namespace CppEditor::Internal;
using namespace CPlusPlus;
-CppHoverHandler::CppHoverHandler(CppModelManager *manager, QObject *parent)
- : QObject(parent), m_manager(manager), m_helpEngineNeedsSetup(false)
+CppHoverHandler::CppHoverHandler(QObject *parent)
+ : QObject(parent)
+ , m_core(CppPlugin::core())
+ , m_helpEngineNeedsSetup(false)
{
+ m_modelManager = m_core->pluginManager()->getObject<CppTools::CppModelManagerInterface>();
+
QFileInfo fi(ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>()->settings()->fileName());
m_helpEngine = new QHelpEngineCore(fi.absolutePath()
+ QLatin1String("/helpcollection.qhc"), this);
@@ -70,6 +77,10 @@ CppHoverHandler::CppHoverHandler(CppModelManager *manager, QObject *parent)
m_helpEngine->setupData();
m_helpEngine->setCurrentFilter(tr("Unfiltered"));
m_helpEngineNeedsSetup = m_helpEngine->registeredDocumentations().count() == 0;
+
+ // Listen for editor opened events in order to connect to tooltip/helpid requests
+ connect(m_core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
+ this, SLOT(editorOpened(Core::IEditor *)));
}
void CppHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int pos)
@@ -77,15 +88,27 @@ void CppHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int p
updateHelpIdAndTooltip(editor, pos);
}
-void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint &point, int pos)
+void CppHoverHandler::editorOpened(Core::IEditor *editor)
{
- const int dbgcontext = m_manager->core()->
- uniqueIDManager()->uniqueIdentifier(Debugger::Constants::C_GDBDEBUGGER);
+ CPPEditorEditable *cppEditor = qobject_cast<CPPEditorEditable *>(editor);
+ if (!cppEditor)
+ return;
+
+ connect(cppEditor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*, QPoint, int)),
+ this, SLOT(showToolTip(TextEditor::ITextEditor*, QPoint, int)));
+
+ connect(cppEditor, SIGNAL(contextHelpIdRequested(TextEditor::ITextEditor*, int)),
+ this, SLOT(updateContextHelpId(TextEditor::ITextEditor*, int)));
+}
- if (m_manager->core()->hasContext(dbgcontext))
+void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint &point, int pos)
+{
+ if (!editor)
return;
- if (! editor)
+ const int dbgcontext = m_core->uniqueIDManager()->uniqueIdentifier(Debugger::Constants::C_GDBDEBUGGER);
+
+ if (m_core->hasContext(dbgcontext))
return;
updateHelpIdAndTooltip(editor, pos);
@@ -158,6 +181,9 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
m_helpId.clear();
m_toolTip.clear();
+ if (!m_modelManager)
+ return;
+
TextEditor::BaseTextEditor *edit = qobject_cast<TextEditor::BaseTextEditor *>(editor->widget());
if (!edit)
return;
@@ -165,7 +191,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
QTextCursor tc(edit->document());
tc.setPosition(pos);
- const Snapshot documents = m_manager->snapshot();
+ const Snapshot documents = m_modelManager->snapshot();
const int lineNumber = tc.block().blockNumber() + 1;
const QString fileName = editor->file()->fileName();
@@ -261,7 +287,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
if (!m_helpId.isEmpty() && !m_helpEngine->linksForIdentifier(m_helpId).isEmpty()) {
m_toolTip = QString(QLatin1String("<table><tr><td valign=middle><nobr>%1</td>"
- "<td><img src=\":/cpptools/images/f1.svg\"></td></tr></table>"))
+ "<td><img src=\":/cppeditor/images/f1.svg\"></td></tr></table>"))
.arg(Qt::escape(m_toolTip));
editor->setContextHelpId(m_helpId);
} else if (!m_toolTip.isEmpty()) {
diff --git a/src/plugins/cpptools/cpphoverhandler.h b/src/plugins/cppeditor/cpphoverhandler.h
index d1de5277b1..d8bd48031c 100644
--- a/src/plugins/cpptools/cpphoverhandler.h
+++ b/src/plugins/cppeditor/cpphoverhandler.h
@@ -35,36 +35,47 @@
#define CPPHOVERHANDLER_H
#include <QtCore/QObject>
-#include <QtCore/QPoint>
QT_BEGIN_NAMESPACE
class QHelpEngineCore;
+class QPoint;
QT_END_NAMESPACE
+namespace Core {
+class ICore;
+class IEditor;
+}
+
+namespace CppTools {
+class CppModelManagerInterface;
+}
+
namespace TextEditor {
class ITextEditor;
}
-namespace CppTools {
+namespace CppEditor {
namespace Internal {
-class CppModelManager;
-
class CppHoverHandler : public QObject
{
Q_OBJECT
public:
- CppHoverHandler(CppModelManager *manager, QObject *parent);
+ CppHoverHandler(QObject *parent = 0);
public slots:
void showToolTip(TextEditor::ITextEditor *editor, const QPoint &point, int pos);
void updateContextHelpId(TextEditor::ITextEditor *editor, int pos);
+private slots:
+ void editorOpened(Core::IEditor *editor);
+
private:
void updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, int pos);
- CppModelManager *m_manager;
+ Core::ICore *m_core;
+ CppTools::CppModelManagerInterface *m_modelManager;
QHelpEngineCore *m_helpEngine;
QString m_helpId;
QString m_toolTip;
@@ -72,6 +83,6 @@ private:
};
} // namespace Internal
-} // namespace CppTools
+} // namespace CppEditor
#endif // CPPHOVERHANDLER_H
diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp
index ac4a74b051..4031f80439 100644
--- a/src/plugins/cppeditor/cppplugin.cpp
+++ b/src/plugins/cppeditor/cppplugin.cpp
@@ -32,12 +32,13 @@
***************************************************************************/
#include "cppplugin.h"
+#include "cppclasswizard.h"
#include "cppeditor.h"
+#include "cppeditoractionhandler.h"
#include "cppeditorconstants.h"
#include "cppeditorenums.h"
#include "cppfilewizard.h"
-#include "cppclasswizard.h"
-#include "cppeditoractionhandler.h"
+#include "cpphoverhandler.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/mimedatabase.h>
@@ -171,6 +172,8 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
m_factory = new CppPluginEditorFactory(this);
addObject(m_factory);
+ addAutoReleasedObject(new CppHoverHandler);
+
CppFileWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard);
wizardParameters.setCategory(QLatin1String("C++"));
diff --git a/src/plugins/cpptools/images/f1.svg b/src/plugins/cppeditor/images/f1.svg
index 468594cb77..468594cb77 100644
--- a/src/plugins/cpptools/images/f1.svg
+++ b/src/plugins/cppeditor/images/f1.svg
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index a02656ee8c..bc5d72c097 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -34,7 +34,6 @@
#include <cplusplus/pp.h>
#include "cppmodelmanager.h"
-#include "cpphoverhandler.h"
#include "cpptoolsconstants.h"
#include "cpptoolseditorsupport.h"
@@ -464,8 +463,6 @@ CppModelManager::CppModelManager(QObject *parent) :
connect(this, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)),
this, SLOT(onDocumentUpdated(CPlusPlus::Document::Ptr)));
- m_hoverHandler = new CppHoverHandler(this, this);
-
// Listen for editor closed and opened events so that we can keep track of changing files
connect(m_core->editorManager(), SIGNAL(editorOpened(Core::IEditor *)),
this, SLOT(editorOpened(Core::IEditor *)));
@@ -633,14 +630,6 @@ void CppModelManager::editorOpened(Core::IEditor *editor)
CppEditorSupport *editorSupport = new CppEditorSupport(this);
editorSupport->setTextEditor(textEditor);
m_editorSupport[textEditor] = editorSupport;
-
- // ### move in CppEditorSupport
- connect(editor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*, QPoint, int)),
- m_hoverHandler, SLOT(showToolTip(TextEditor::ITextEditor*, QPoint, int)));
-
- // ### move in CppEditorSupport
- connect(editor, SIGNAL(contextHelpIdRequested(TextEditor::ITextEditor*, int)),
- m_hoverHandler, SLOT(updateContextHelpId(TextEditor::ITextEditor*, int)));
}
}
diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h
index 2594705620..990d019ad7 100644
--- a/src/plugins/cpptools/cppmodelmanager.h
+++ b/src/plugins/cpptools/cppmodelmanager.h
@@ -60,7 +60,6 @@ namespace Internal {
class CppEditorSupport;
class CppPreprocessor;
-class CppHoverHandler;
class CppModelManager : public CppModelManagerInterface
{
@@ -144,7 +143,6 @@ private:
private:
Core::ICore *m_core;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
- CppHoverHandler *m_hoverHandler;
CPlusPlus::Snapshot m_snapshot;
// cache
diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro
index f86ca6bdd5..ce71c2de71 100644
--- a/src/plugins/cpptools/cpptools.pro
+++ b/src/plugins/cpptools/cpptools.pro
@@ -25,14 +25,11 @@ SOURCES += cppquickopenfilter.cpp \
# Input
SOURCES += cpptoolsplugin.cpp \
cppmodelmanager.cpp \
- cppcodecompletion.cpp \
- cpphoverhandler.cpp
+ cppcodecompletion.cpp
HEADERS += cpptoolsplugin.h \
cppmodelmanager.h \
cppcodecompletion.h \
- cpphoverhandler.h \
cppmodelmanagerinterface.h \
cpptoolseditorsupport.h \
cpptoolsconstants.h
-RESOURCES += cpptools.qrc
FORMS += completionsettingspage.ui
diff --git a/src/plugins/cpptools/cpptools.qrc b/src/plugins/cpptools/cpptools.qrc
deleted file mode 100644
index a750578a4b..0000000000
--- a/src/plugins/cpptools/cpptools.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/cpptools" >
- <file>images/f1.svg</file>
- </qresource>
-</RCC>
diff --git a/src/plugins/cpptools/cpptoolseditorsupport.h b/src/plugins/cpptools/cpptoolseditorsupport.h
index 6cfb7dc201..4fb6c14071 100644
--- a/src/plugins/cpptools/cpptoolseditorsupport.h
+++ b/src/plugins/cpptools/cpptoolseditorsupport.h
@@ -40,7 +40,6 @@
QT_BEGIN_NAMESPACE
class QTimer;
-class QByteArray;
QT_END_NAMESPACE
namespace TextEditor {
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp
index 0454a0b6fe..9d190162c8 100644
--- a/src/plugins/cpptools/cpptoolsplugin.cpp
+++ b/src/plugins/cpptools/cpptoolsplugin.cpp
@@ -37,7 +37,6 @@
#include "cppclassesfilter.h"
#include "cppcodecompletion.h"
#include "cppfunctionsfilter.h"
-#include "cpphoverhandler.h"
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
#include "cppquickopenfilter.h"