Commit f576ad9f authored by hjk's avatar hjk

texteditor: merge ITextEditable into ITextEditor

rename BastTextEditor->BaseTextEditorWidget, BaseTextEditorEditable->BaseTextEditor
rename BaseTextEditor{,Widget} subclasses
rename editableInterface->editorInterface
rename createEditableInterface->createEditor
minor cleanups after renamings
parent e32cf192
......@@ -42,7 +42,7 @@
#include <qmljs/qmljslookupcontext.h>
namespace TextEditor {
class BaseTextEditorEditable;
class BaseTextEditor;
} //TextEditor
namespace QmlJS {
......@@ -54,9 +54,9 @@ class QMLJS_EXPORT IContextPane : public QObject
public:
IContextPane(QObject *parent = 0) : QObject(parent) {}
virtual ~IContextPane() {}
virtual void apply(TextEditor::BaseTextEditorEditable *editor, Document::Ptr document, LookupContext::Ptr lookupContext, AST::Node *node, bool update, bool force = false) = 0;
virtual void apply(TextEditor::BaseTextEditor *editor, Document::Ptr document, LookupContext::Ptr lookupContext, AST::Node *node, bool update, bool force = false) = 0;
virtual void setEnabled(bool) = 0;
virtual bool isAvailable(TextEditor::BaseTextEditorEditable *editor, Document::Ptr document, AST::Node *node) = 0;
virtual bool isAvailable(TextEditor::BaseTextEditor *editor, Document::Ptr document, AST::Node *node) = 0;
virtual QWidget* widget() = 0;
signals:
void closed();
......
......@@ -34,10 +34,9 @@
#ifndef SETTINGSUTILS_H
#define SETTINGSUTILS_H
#include <QtCore/QSettings>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QLatin1String>
#include <QtCore/QSettings>
#include <QtCore/QVariant>
namespace Utils {
......
......@@ -497,7 +497,7 @@ Bookmark *BookmarkManager::bookmarkForIndex(QModelIndex index)
bool BookmarkManager::gotoBookmark(Bookmark* bookmark)
{
using namespace TextEditor;
if (ITextEditor *editor = BaseTextEditor::openEditorAt(bookmark->filePath(), bookmark->lineNumber()))
if (ITextEditor *editor = BaseTextEditorWidget::openEditorAt(bookmark->filePath(), bookmark->lineNumber()))
return (editor->currentLine() == bookmark->lineNumber());
return false;
}
......
......@@ -299,7 +299,7 @@ void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
void Manager::gotoLocation(const QString &fileName, int line, int column)
{
bool newEditor = false;
TextEditor::BaseTextEditor::openEditorAt(fileName, line, column, QString(),
TextEditor::BaseTextEditorWidget::openEditorAt(fileName, line, column, QString(),
Core::EditorManager::IgnoreNavigationHistory,
&newEditor);
}
......
......@@ -51,27 +51,27 @@ using namespace CMakeProjectManager::Internal;
// ProFileEditorEditable
//
CMakeEditorEditable::CMakeEditorEditable(CMakeEditor *editor)
: BaseTextEditorEditable(editor),
CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
: BaseTextEditor(editor),
m_context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
TextEditor::Constants::C_TEXTEDITOR)
{ }
Core::Context CMakeEditorEditable::context() const
Core::Context CMakeEditor::context() const
{
return m_context;
}
Core::IEditor *CMakeEditorEditable::duplicate(QWidget *parent)
Core::IEditor *CMakeEditor::duplicate(QWidget *parent)
{
CMakeEditor *ret = new CMakeEditor(parent, qobject_cast<CMakeEditor*>(editor())->factory(),
qobject_cast<CMakeEditor*>(editor())->actionHandler());
ret->duplicateFrom(editor());
CMakeEditorWidget *w = qobject_cast<CMakeEditorWidget*>(editorWidget());
CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory(), w->actionHandler());
ret->duplicateFrom(w);
TextEditor::TextEditorSettings::instance()->initializeEditor(ret);
return ret->editableInterface();
return ret->editor();
}
QString CMakeEditorEditable::id() const
QString CMakeEditor::id() const
{
return QLatin1String(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
}
......@@ -80,8 +80,8 @@ QString CMakeEditorEditable::id() const
// CMakeEditor
//
CMakeEditor::CMakeEditor(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah)
: BaseTextEditor(parent), m_factory(factory), m_ah(ah)
CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah)
: BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah)
{
CMakeDocument *doc = new CMakeDocument();
doc->setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE));
......@@ -92,18 +92,18 @@ CMakeEditor::CMakeEditor(QWidget *parent, CMakeEditorFactory *factory, TextEdito
baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter);
}
CMakeEditor::~CMakeEditor()
CMakeEditorWidget::~CMakeEditorWidget()
{
}
TextEditor::BaseTextEditorEditable *CMakeEditor::createEditableInterface()
TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor()
{
return new CMakeEditorEditable(this);
return new CMakeEditor(this);
}
void CMakeEditor::setFontSettings(const TextEditor::FontSettings &fs)
void CMakeEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
TextEditor::BaseTextEditor::setFontSettings(fs);
TextEditor::BaseTextEditorWidget::setFontSettings(fs);
CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter());
if (!highlighter)
return;
......
......@@ -45,18 +45,16 @@ class FontSettings;
}
namespace CMakeProjectManager {
namespace Internal {
class CMakeManager;
class CMakeEditorWidget;
class CMakeHighlighter;
class CMakeManager;
class CMakeEditor;
class CMakeEditorEditable : public TextEditor::BaseTextEditorEditable
class CMakeEditor : public TextEditor::BaseTextEditor
{
public:
CMakeEditorEditable(CMakeEditor *);
CMakeEditor(CMakeEditorWidget *);
Core::Context context() const;
bool duplicateSupported() const { return true; }
......@@ -67,20 +65,21 @@ private:
const Core::Context m_context;
};
class CMakeEditor : public TextEditor::BaseTextEditor
class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget
{
Q_OBJECT
public:
CMakeEditor(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah);
~CMakeEditor();
CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah);
~CMakeEditorWidget();
bool save(const QString &fileName = QString());
CMakeEditorFactory *factory() { return m_factory; }
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
protected:
TextEditor::BaseTextEditorEditable *createEditableInterface();
TextEditor::BaseTextEditor *createEditor();
public slots:
virtual void setFontSettings(const TextEditor::FontSettings &);
......
......@@ -71,9 +71,9 @@ Core::IFile *CMakeEditorFactory::open(const QString &fileName)
Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent)
{
CMakeEditor *rc = new CMakeEditor(parent, this, m_actionHandler);
CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler);
TextEditor::TextEditorSettings::instance()->initializeEditor(rc);
return rc->editableInterface();
return rc->editor();
}
QStringList CMakeEditorFactory::mimeTypes() const
......
......@@ -166,14 +166,14 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown()
void CodepasterPlugin::updateActions()
{
const IEditor* editor = EditorManager::instance()->currentEditor();
const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor);
m_postEditorAction->setEnabled(textEditor != 0);
}
void CodepasterPlugin::postEditor()
{
const IEditor* editor = EditorManager::instance()->currentEditor();
const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor);
if (!textEditor)
return;
......@@ -181,7 +181,7 @@ void CodepasterPlugin::postEditor()
if (data.isEmpty())
data = textEditor->contents();
if (!data.isEmpty())
post(data, textEditor->editor()->mimeType());
post(data, textEditor->editorWidget()->mimeType());
}
void CodepasterPlugin::postClipboard()
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ class FontSettings;
namespace CppEditor {
namespace Internal {
class CPPEditor;
class CPPEditorWidget;
class SemanticHighlighter: public QThread, CPlusPlus::TopLevelDeclarationProcessor
{
......@@ -142,11 +142,11 @@ private:
SemanticInfo m_lastSemanticInfo;
};
class CPPEditorEditable : public TextEditor::BaseTextEditorEditable
class CPPEditor : public TextEditor::BaseTextEditor
{
Q_OBJECT
public:
CPPEditorEditable(CPPEditor *);
CPPEditor(CPPEditorWidget *);
Core::Context context() const;
bool duplicateSupported() const { return true; }
......@@ -160,15 +160,15 @@ private:
Core::Context m_context;
};
class CPPEditor : public TextEditor::BaseTextEditor
class CPPEditorWidget : public TextEditor::BaseTextEditorWidget
{
Q_OBJECT
public:
typedef TextEditor::TabSettings TabSettings;
CPPEditor(QWidget *parent);
~CPPEditor();
CPPEditorWidget(QWidget *parent);
~CPPEditorWidget();
void unCommentSelection();
unsigned editorRevision() const;
......@@ -178,8 +178,8 @@ public:
CPlusPlus::OverviewModel *outlineModel() const;
QModelIndex outlineModelIndex();
virtual void paste(); // reimplemented from BaseTextEditor
virtual void cut(); // reimplemented from BaseTextEditor
virtual void paste(); // reimplemented from BaseTextEditorWidget
virtual void cut(); // reimplemented from BaseTextEditorWidget
CPlusPlus::CppModelManagerInterface *modelManager() const;
......@@ -215,7 +215,7 @@ protected:
void contextMenuEvent(QContextMenuEvent *);
void keyPressEvent(QKeyEvent *);
TextEditor::BaseTextEditorEditable *createEditableInterface();
TextEditor::BaseTextEditor *createEditor();
const CPlusPlus::Macro *findCanonicalMacro(const QTextCursor &cursor,
CPlusPlus::Document::Ptr doc) const;
......@@ -258,7 +258,7 @@ private:
const SemanticInfo &semanticInfo,
QList<QTextEdit::ExtraSelection> *selections);
void createToolBar(CPPEditorEditable *editable);
void createToolBar(CPPEditor *editable);
void startRename();
void finishRename();
......
......@@ -84,7 +84,7 @@ namespace {
}
}
CppElementEvaluator::CppElementEvaluator(CPPEditor *editor) :
CppElementEvaluator::CppElementEvaluator(CPPEditorWidget *editor) :
m_editor(editor),
m_modelManager(CppModelManagerInterface::instance()),
m_tc(editor->textCursor()),
......@@ -264,10 +264,10 @@ void CppElement::setHelpMark(const QString &mark)
const QString &CppElement::helpMark() const
{ return m_helpMark; }
void CppElement::setLink(const CPPEditor::Link &link)
void CppElement::setLink(const CPPEditorWidget::Link &link)
{ m_link = link; }
const CPPEditor::Link &CppElement::link() const
const CPPEditorWidget::Link &CppElement::link() const
{ return m_link; }
void CppElement::setTooltip(const QString &tooltip)
......@@ -301,7 +301,7 @@ CppInclude::CppInclude(const Document::Include &includeFile) :
setHelpCategory(TextEditor::HelpItem::Brief);
setHelpIdCandidates(QStringList(m_fileName));
setHelpMark(m_fileName);
setLink(CPPEditor::Link(m_path));
setLink(CPPEditorWidget::Link(m_path));
setTooltip(m_path);
}
......@@ -317,7 +317,7 @@ CppMacro::CppMacro(const Macro &macro) : CppElement()
setHelpCategory(TextEditor::HelpItem::Macro);
setHelpIdCandidates(QStringList(macro.name()));
setHelpMark(macro.name());
setLink(CPPEditor::Link(macro.fileName(), macro.line()));
setLink(CPPEditorWidget::Link(macro.fileName(), macro.line()));
setTooltip(macro.toString());
}
......@@ -344,7 +344,7 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration) : CppElement()
}
setTooltip(overview.prettyType(declaration->type(), m_qualifiedName));
setLink(CPPEditor::linkToSymbol(declaration));
setLink(CPPEditorWidget::linkToSymbol(declaration));
setHelpMark(m_name);
}
......
......@@ -59,13 +59,13 @@ class CppModelManagerInterface;
namespace CppEditor {
namespace Internal {
class CPPEditor;
class CPPEditorWidget;
class CppElement;
class CppElementEvaluator
{
public:
CppElementEvaluator(CPPEditor *editor);
CppElementEvaluator(CPPEditorWidget *editor);
void setTextCursor(const QTextCursor &tc);
void setLookupBaseClasses(const bool lookup);
......@@ -85,7 +85,7 @@ private:
const CPlusPlus::LookupItem &lookupItem,
const CPlusPlus::LookupContext &lookupContext);
CPPEditor *m_editor;
CPPEditorWidget *m_editor;
CPlusPlus::CppModelManagerInterface *m_modelManager;
QTextCursor m_tc;
bool m_lookupBaseClasses;
......@@ -101,14 +101,14 @@ public:
const TextEditor::HelpItem::Category &helpCategory() const;
const QStringList &helpIdCandidates() const;
const QString &helpMark() const;
const CPPEditor::Link &link() const;
const CPPEditorWidget::Link &link() const;
const QString &tooltip() const;
protected:
CppElement();
void setHelpCategory(const TextEditor::HelpItem::Category &category);
void setLink(const CPPEditor::Link &link);
void setLink(const CPPEditorWidget::Link &link);
void setTooltip(const QString &tooltip);
void setHelpIdCandidates(const QStringList &candidates);
void addHelpIdCandidate(const QString &candidate);
......@@ -118,7 +118,7 @@ private:
TextEditor::HelpItem::Category m_helpCategory;
QStringList m_helpIdCandidates;
QString m_helpMark;
CPPEditor::Link m_link;
CPPEditorWidget::Link m_link;
QString m_tooltip;
};
......
......@@ -43,7 +43,7 @@ namespace CppEditor {
namespace Internal {
class CPPEditor;
class CPPEditorWidget;
class CppHighlighter : public TextEditor::SyntaxHighlighter
{
......
......@@ -58,7 +58,7 @@ CppHoverHandler::~CppHoverHandler()
bool CppHoverHandler::acceptEditor(IEditor *editor)
{
CPPEditorEditable *cppEditor = qobject_cast<CPPEditorEditable *>(editor);
CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor);
if (cppEditor)
return true;
return false;
......@@ -66,7 +66,7 @@ bool CppHoverHandler::acceptEditor(IEditor *editor)
void CppHoverHandler::identifyMatch(TextEditor::ITextEditor *editor, int pos)
{
CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor->widget());
CPPEditorWidget *cppEditor = qobject_cast<CPPEditorWidget *>(editor->widget());
if (!cppEditor)
return;
......
......@@ -98,7 +98,7 @@ bool CppOutlineFilterModel::filterAcceptsRow(int sourceRow,
}
CppOutlineWidget::CppOutlineWidget(CPPEditor *editor) :
CppOutlineWidget::CppOutlineWidget(CPPEditorWidget *editor) :
TextEditor::IOutlineWidget(),
m_editor(editor),
m_treeView(new CppOutlineTreeView(this)),
......@@ -197,18 +197,18 @@ bool CppOutlineWidget::syncCursor()
bool CppOutlineWidgetFactory::supportsEditor(Core::IEditor *editor) const
{
if (qobject_cast<CPPEditorEditable*>(editor))
if (qobject_cast<CPPEditor*>(editor))
return true;
return false;
}
TextEditor::IOutlineWidget *CppOutlineWidgetFactory::createWidget(Core::IEditor *editor)
{
CPPEditorEditable *cppEditable = qobject_cast<CPPEditorEditable*>(editor);
CPPEditor *cppEditor = qobject_cast<CPPEditor*>(cppEditable->widget());
Q_ASSERT(cppEditor);
CPPEditor *cppEditor = qobject_cast<CPPEditor*>(editor);
CPPEditorWidget *cppEditorWidget = qobject_cast<CPPEditorWidget*>(cppEditor->widget());
Q_ASSERT(cppEditorWidget);
CppOutlineWidget *widget = new CppOutlineWidget(cppEditor);
CppOutlineWidget *widget = new CppOutlineWidget(cppEditorWidget);
return widget;
}
......@@ -70,7 +70,7 @@ class CppOutlineWidget : public TextEditor::IOutlineWidget
{
Q_OBJECT
public:
CppOutlineWidget(CPPEditor *editor);
CppOutlineWidget(CPPEditorWidget *editor);
// IOutlineWidget
virtual QList<QAction*> filterMenuActions() const;
......@@ -86,7 +86,7 @@ private:
bool syncCursor();
private:
CPPEditor *m_editor;
CPPEditorWidget *m_editor;
CppOutlineTreeView *m_treeView;
CPlusPlus::OverviewModel *m_model;
CppOutlineFilterModel *m_proxyModel;
......
......@@ -118,10 +118,10 @@ Core::IFile *CppEditorFactory::open(const QString &fileName)
Core::IEditor *CppEditorFactory::createEditor(QWidget *parent)
{
CPPEditor *editor = new CPPEditor(parent);
CPPEditorWidget *editor = new CPPEditorWidget(parent);
editor->setRevisionsVisible(true);
m_owner->initializeEditor(editor);
return editor->editableInterface();
return editor->editor();
}
QStringList CppEditorFactory::mimeTypes() const
......@@ -172,7 +172,7 @@ CppPlugin *CppPlugin::instance()
return m_instance;
}
void CppPlugin::initializeEditor(CPPEditor *editor)
void CppPlugin::initializeEditor(CPPEditorWidget *editor)
{
m_actionHandler->setupActions(editor);
......@@ -352,7 +352,7 @@ ExtensionSystem::IPlugin::ShutdownFlag CppPlugin::aboutToShutdown()
void CppPlugin::switchDeclarationDefinition()
{
Core::EditorManager *em = Core::EditorManager::instance();
CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget());
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget());
if (editor)
editor->switchDeclarationDefinition();
}
......@@ -360,7 +360,7 @@ void CppPlugin::switchDeclarationDefinition()
void CppPlugin::jumpToDefinition()
{
Core::EditorManager *em = Core::EditorManager::instance();
CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget());
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget());
if (editor)
editor->jumpToDefinition();
}
......@@ -368,7 +368,7 @@ void CppPlugin::jumpToDefinition()
void CppPlugin::renameSymbolUnderCursor()
{
Core::EditorManager *em = Core::EditorManager::instance();
CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget());
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget());
if (editor)
editor->renameSymbolUnderCursor();
}
......@@ -376,32 +376,32 @@ void CppPlugin::renameSymbolUnderCursor()
void CppPlugin::findUsages()
{
Core::EditorManager *em = Core::EditorManager::instance();
CPPEditor *editor = qobject_cast<CPPEditor*>(em->currentEditor()->widget());
CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget());
if (editor)
editor->findUsages();
}
void CppPlugin::quickFix(TextEditor::ITextEditable *editable)
void CppPlugin::quickFix(TextEditor::ITextEditor *editor)
{
m_currentTextEditable = editable;
m_currentEditor = editor;
quickFixNow();
}
void CppPlugin::quickFixNow()
{
if (! m_currentTextEditable)
if (! m_currentEditor)
return;
Core::EditorManager *em = Core::EditorManager::instance();
CPPEditor *currentEditor = qobject_cast<CPPEditor*>(em->currentEditor()->widget());
CPPEditorWidget *currentEditor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget());
if (CPPEditor *editor = qobject_cast<CPPEditor*>(m_currentTextEditable->widget())) {
if (CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(m_currentEditor->widget())) {
if (currentEditor == editor) {
if (editor->isOutdated())
m_quickFixTimer->start(QUICKFIX_INTERVAL);
else
TextEditor::CompletionSupport::instance()->
complete(m_currentTextEditable, TextEditor::QuickFixCompletion, true);
complete(m_currentEditor, TextEditor::QuickFixCompletion, true);
}
}
}
......@@ -431,7 +431,7 @@ void CppPlugin::currentEditorChanged(Core::IEditor *editor)
if (! editor)