QmakeProjectManager: Some editor creation related cleanup

Use a BaseEditorFactory derived class, move some code around.

Change-Id: I051ae55d106610ca818abdd3a5f6fd9f17131af2
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-08-22 17:40:24 +02:00
parent 3430514eff
commit b84a47ffc5
6 changed files with 84 additions and 104 deletions

View File

@@ -28,20 +28,23 @@
****************************************************************************/
#include "profilehoverhandler.h"
#include "profileeditor.h"
#include "profilecompletionassist.h"
#include "qmakeprojectmanagerconstants.h"
#include <coreplugin/helpmanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/basetexteditor.h>
#include <utils/htmldocextractor.h>
#include <QTextBlock>
#include <QUrl>
using namespace QmakeProjectManager;
using namespace QmakeProjectManager::Internal;
using namespace Core;
namespace QmakeProjectManager {
namespace Internal {
ProFileHoverHandler::ProFileHoverHandler(QObject *parent)
: BaseHoverHandler(parent),
m_manualKind(UnknownManual)
@@ -56,20 +59,18 @@ ProFileHoverHandler::~ProFileHoverHandler()
bool ProFileHoverHandler::acceptEditor(IEditor *editor)
{
if (qobject_cast<ProFileEditor *>(editor) != 0)
return true;
return false;
return editor->context().contains(Constants::C_PROFILEEDITOR);
}
void ProFileHoverHandler::identifyMatch(TextEditor::BaseTextEditor *editor, int pos)
{
m_docFragment.clear();
m_manualKind = UnknownManual;
if (ProFileEditorWidget *proFileEditor = qobject_cast<ProFileEditorWidget *>(editor->widget())) {
if (!proFileEditor->extraSelectionTooltip(pos).isEmpty()) {
setToolTip(proFileEditor->extraSelectionTooltip(pos));
if (TextEditor::BaseTextEditorWidget *widget = editor->editorWidget()) {
if (!widget->extraSelectionTooltip(pos).isEmpty()) {
setToolTip(widget->extraSelectionTooltip(pos));
} else {
QTextDocument *document = proFileEditor->document();
QTextDocument *document = widget->document();
QTextBlock block = document->findBlock(pos);
identifyQMakeKeyword(block.text(), pos - block.position());
@@ -161,3 +162,5 @@ void ProFileHoverHandler::identifyDocFragment(ProFileHoverHandler::ManualKind ma
}
}
} // namespace Internal
} // namespace QmakeProjectManager