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 @@ ...@@ -42,7 +42,7 @@
#include <qmljs/qmljslookupcontext.h> #include <qmljs/qmljslookupcontext.h>
namespace TextEditor { namespace TextEditor {
class BaseTextEditorEditable; class BaseTextEditor;
} //TextEditor } //TextEditor
namespace QmlJS { namespace QmlJS {
...@@ -54,9 +54,9 @@ class QMLJS_EXPORT IContextPane : public QObject ...@@ -54,9 +54,9 @@ class QMLJS_EXPORT IContextPane : public QObject
public: public:
IContextPane(QObject *parent = 0) : QObject(parent) {} IContextPane(QObject *parent = 0) : QObject(parent) {}
virtual ~IContextPane() {} 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 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; virtual QWidget* widget() = 0;
signals: signals:
void closed(); void closed();
......
...@@ -34,10 +34,9 @@ ...@@ -34,10 +34,9 @@
#ifndef SETTINGSUTILS_H #ifndef SETTINGSUTILS_H
#define SETTINGSUTILS_H #define SETTINGSUTILS_H
#include <QtCore/QSettings>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtCore/QLatin1String>
#include <QtCore/QSettings>
#include <QtCore/QVariant> #include <QtCore/QVariant>
namespace Utils { namespace Utils {
......
...@@ -497,7 +497,7 @@ Bookmark *BookmarkManager::bookmarkForIndex(QModelIndex index) ...@@ -497,7 +497,7 @@ Bookmark *BookmarkManager::bookmarkForIndex(QModelIndex index)
bool BookmarkManager::gotoBookmark(Bookmark* bookmark) bool BookmarkManager::gotoBookmark(Bookmark* bookmark)
{ {
using namespace TextEditor; 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 (editor->currentLine() == bookmark->lineNumber());
return false; return false;
} }
......
...@@ -299,7 +299,7 @@ void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc) ...@@ -299,7 +299,7 @@ void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
void Manager::gotoLocation(const QString &fileName, int line, int column) void Manager::gotoLocation(const QString &fileName, int line, int column)
{ {
bool newEditor = false; bool newEditor = false;
TextEditor::BaseTextEditor::openEditorAt(fileName, line, column, QString(), TextEditor::BaseTextEditorWidget::openEditorAt(fileName, line, column, QString(),
Core::EditorManager::IgnoreNavigationHistory, Core::EditorManager::IgnoreNavigationHistory,
&newEditor); &newEditor);
} }
......
...@@ -51,27 +51,27 @@ using namespace CMakeProjectManager::Internal; ...@@ -51,27 +51,27 @@ using namespace CMakeProjectManager::Internal;
// ProFileEditorEditable // ProFileEditorEditable
// //
CMakeEditorEditable::CMakeEditorEditable(CMakeEditor *editor) CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
: BaseTextEditorEditable(editor), : BaseTextEditor(editor),
m_context(CMakeProjectManager::Constants::C_CMAKEEDITOR, m_context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
TextEditor::Constants::C_TEXTEDITOR) TextEditor::Constants::C_TEXTEDITOR)
{ } { }
Core::Context CMakeEditorEditable::context() const Core::Context CMakeEditor::context() const
{ {
return m_context; 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(), CMakeEditorWidget *w = qobject_cast<CMakeEditorWidget*>(editorWidget());
qobject_cast<CMakeEditor*>(editor())->actionHandler()); CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory(), w->actionHandler());
ret->duplicateFrom(editor()); ret->duplicateFrom(w);
TextEditor::TextEditorSettings::instance()->initializeEditor(ret); 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); return QLatin1String(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
} }
...@@ -80,8 +80,8 @@ QString CMakeEditorEditable::id() const ...@@ -80,8 +80,8 @@ QString CMakeEditorEditable::id() const
// CMakeEditor // CMakeEditor
// //
CMakeEditor::CMakeEditor(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah) CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah)
: BaseTextEditor(parent), m_factory(factory), m_ah(ah) : BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah)
{ {
CMakeDocument *doc = new CMakeDocument(); CMakeDocument *doc = new CMakeDocument();
doc->setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE)); doc->setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE));
...@@ -92,18 +92,18 @@ CMakeEditor::CMakeEditor(QWidget *parent, CMakeEditorFactory *factory, TextEdito ...@@ -92,18 +92,18 @@ CMakeEditor::CMakeEditor(QWidget *parent, CMakeEditorFactory *factory, TextEdito
baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter); 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()); CMakeHighlighter *highlighter = qobject_cast<CMakeHighlighter*>(baseTextDocument()->syntaxHighlighter());
if (!highlighter) if (!highlighter)
return; return;
......
...@@ -45,18 +45,16 @@ class FontSettings; ...@@ -45,18 +45,16 @@ class FontSettings;
} }
namespace CMakeProjectManager { namespace CMakeProjectManager {
namespace Internal { namespace Internal {
class CMakeManager; class CMakeEditorWidget;
class CMakeHighlighter; class CMakeHighlighter;
class CMakeManager;
class CMakeEditor; class CMakeEditor : public TextEditor::BaseTextEditor
class CMakeEditorEditable : public TextEditor::BaseTextEditorEditable
{ {
public: public:
CMakeEditorEditable(CMakeEditor *); CMakeEditor(CMakeEditorWidget *);
Core::Context context() const; Core::Context context() const;
bool duplicateSupported() const { return true; } bool duplicateSupported() const { return true; }
...@@ -67,20 +65,21 @@ private: ...@@ -67,20 +65,21 @@ private:
const Core::Context m_context; const Core::Context m_context;
}; };
class CMakeEditor : public TextEditor::BaseTextEditor class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CMakeEditor(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah); CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah);
~CMakeEditor(); ~CMakeEditorWidget();
bool save(const QString &fileName = QString()); bool save(const QString &fileName = QString());
CMakeEditorFactory *factory() { return m_factory; } CMakeEditorFactory *factory() { return m_factory; }
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; } TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
protected: protected:
TextEditor::BaseTextEditorEditable *createEditableInterface(); TextEditor::BaseTextEditor *createEditor();
public slots: public slots:
virtual void setFontSettings(const TextEditor::FontSettings &); virtual void setFontSettings(const TextEditor::FontSettings &);
......
...@@ -71,9 +71,9 @@ Core::IFile *CMakeEditorFactory::open(const QString &fileName) ...@@ -71,9 +71,9 @@ Core::IFile *CMakeEditorFactory::open(const QString &fileName)
Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent) 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); TextEditor::TextEditorSettings::instance()->initializeEditor(rc);
return rc->editableInterface(); return rc->editor();
} }
QStringList CMakeEditorFactory::mimeTypes() const QStringList CMakeEditorFactory::mimeTypes() const
......
...@@ -166,14 +166,14 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown() ...@@ -166,14 +166,14 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown()
void CodepasterPlugin::updateActions() void CodepasterPlugin::updateActions()
{ {
const IEditor* editor = EditorManager::instance()->currentEditor(); 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); m_postEditorAction->setEnabled(textEditor != 0);
} }
void CodepasterPlugin::postEditor() void CodepasterPlugin::postEditor()
{ {
const IEditor* editor = EditorManager::instance()->currentEditor(); const IEditor* editor = EditorManager::instance()->currentEditor();
const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor); const BaseTextEditor *textEditor = qobject_cast<const BaseTextEditor *>(editor);
if (!textEditor) if (!textEditor)
return; return;
...@@ -181,7 +181,7 @@ void CodepasterPlugin::postEditor() ...@@ -181,7 +181,7 @@ void CodepasterPlugin::postEditor()
if (data.isEmpty()) if (data.isEmpty())
data = textEditor->contents(); data = textEditor->contents();
if (!data.isEmpty()) if (!data.isEmpty())
post(data, textEditor->editor()->mimeType()); post(data, textEditor->editorWidget()->mimeType());
} }
void CodepasterPlugin::postClipboard() void CodepasterPlugin::postClipboard()
......
This diff is collapsed.
...@@ -71,7 +71,7 @@ class FontSettings; ...@@ -71,7 +71,7 @@ class FontSettings;
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditor; class CPPEditorWidget;
class SemanticHighlighter: public QThread, CPlusPlus::TopLevelDeclarationProcessor class SemanticHighlighter: public QThread, CPlusPlus::TopLevelDeclarationProcessor
{ {
...@@ -142,11 +142,11 @@ private: ...@@ -142,11 +142,11 @@ private:
SemanticInfo m_lastSemanticInfo; SemanticInfo m_lastSemanticInfo;
}; };
class CPPEditorEditable : public TextEditor::BaseTextEditorEditable class CPPEditor : public TextEditor::BaseTextEditor
{ {
Q_OBJECT Q_OBJECT
public: public:
CPPEditorEditable(CPPEditor *); CPPEditor(CPPEditorWidget *);
Core::Context context() const; Core::Context context() const;
bool duplicateSupported() const { return true; } bool duplicateSupported() const { return true; }
...@@ -160,15 +160,15 @@ private: ...@@ -160,15 +160,15 @@ private:
Core::Context m_context; Core::Context m_context;
}; };
class CPPEditor : public TextEditor::BaseTextEditor class CPPEditorWidget : public TextEditor::BaseTextEditorWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
typedef TextEditor::TabSettings TabSettings; typedef TextEditor::TabSettings TabSettings;
CPPEditor(QWidget *parent); CPPEditorWidget(QWidget *parent);
~CPPEditor(); ~CPPEditorWidget();
void unCommentSelection(); void unCommentSelection();
unsigned editorRevision() const; unsigned editorRevision() const;
...@@ -178,8 +178,8 @@ public: ...@@ -178,8 +178,8 @@ public:
CPlusPlus::OverviewModel *outlineModel() const; CPlusPlus::OverviewModel *outlineModel() const;
QModelIndex outlineModelIndex(); QModelIndex outlineModelIndex();
virtual void paste(); // reimplemented from BaseTextEditor virtual void paste(); // reimplemented from BaseTextEditorWidget
virtual void cut(); // reimplemented from BaseTextEditor virtual void cut(); // reimplemented from BaseTextEditorWidget
CPlusPlus::CppModelManagerInterface *modelManager() const; CPlusPlus::CppModelManagerInterface *modelManager() const;
...@@ -215,7 +215,7 @@ protected: ...@@ -215,7 +215,7 @@ protected:
void contextMenuEvent(QContextMenuEvent *); void contextMenuEvent(QContextMenuEvent *);
void keyPressEvent(QKeyEvent *); void keyPressEvent(QKeyEvent *);
TextEditor::BaseTextEditorEditable *createEditableInterface(); TextEditor::BaseTextEditor *createEditor();
const CPlusPlus::Macro *findCanonicalMacro(const QTextCursor &cursor, const CPlusPlus::Macro *findCanonicalMacro(const QTextCursor &cursor,
CPlusPlus::Document::Ptr doc) const; CPlusPlus::Document::Ptr doc) const;
...@@ -258,7 +258,7 @@ private: ...@@ -258,7 +258,7 @@ private:
const SemanticInfo &semanticInfo, const SemanticInfo &semanticInfo,
QList<QTextEdit::ExtraSelection> *selections); QList<QTextEdit::ExtraSelection> *selections);
void createToolBar(CPPEditorEditable *editable); void createToolBar(CPPEditor *editable);
void startRename(); void startRename();
void finishRename(); void finishRename();
......
...@@ -84,7 +84,7 @@ namespace { ...@@ -84,7 +84,7 @@ namespace {
} }
} }
CppElementEvaluator::CppElementEvaluator(CPPEditor *editor) : CppElementEvaluator::CppElementEvaluator(CPPEditorWidget *editor) :
m_editor(editor), m_editor(editor),
m_modelManager(CppModelManagerInterface::instance()), m_modelManager(CppModelManagerInterface::instance()),
m_tc(editor->textCursor()), m_tc(editor->textCursor()),
...@@ -264,10 +264,10 @@ void CppElement::setHelpMark(const QString &mark) ...@@ -264,10 +264,10 @@ void CppElement::setHelpMark(const QString &mark)
const QString &CppElement::helpMark() const const QString &CppElement::helpMark() const
{ return m_helpMark; } { return m_helpMark; }
void CppElement::setLink(const CPPEditor::Link &link) void CppElement::setLink(const CPPEditorWidget::Link &link)
{ m_link = link; } { m_link = link; }
const CPPEditor::Link &CppElement::link() const const CPPEditorWidget::Link &CppElement::link() const
{ return m_link; } { return m_link; }
void CppElement::setTooltip(const QString &tooltip) void CppElement::setTooltip(const QString &tooltip)
...@@ -301,7 +301,7 @@ CppInclude::CppInclude(const Document::Include &includeFile) : ...@@ -301,7 +301,7 @@ CppInclude::CppInclude(const Document::Include &includeFile) :
setHelpCategory(TextEditor::HelpItem::Brief); setHelpCategory(TextEditor::HelpItem::Brief);
setHelpIdCandidates(QStringList(m_fileName)); setHelpIdCandidates(QStringList(m_fileName));
setHelpMark(m_fileName); setHelpMark(m_fileName);
setLink(CPPEditor::Link(m_path)); setLink(CPPEditorWidget::Link(m_path));
setTooltip(m_path); setTooltip(m_path);
} }
...@@ -317,7 +317,7 @@ CppMacro::CppMacro(const Macro &macro) : CppElement() ...@@ -317,7 +317,7 @@ CppMacro::CppMacro(const Macro &macro) : CppElement()
setHelpCategory(TextEditor::HelpItem::Macro); setHelpCategory(TextEditor::HelpItem::Macro);
setHelpIdCandidates(QStringList(macro.name())); setHelpIdCandidates(QStringList(macro.name()));
setHelpMark(macro.name()); setHelpMark(macro.name());
setLink(CPPEditor::Link(macro.fileName(), macro.line())); setLink(CPPEditorWidget::Link(macro.fileName(), macro.line()));
setTooltip(macro.toString()); setTooltip(macro.toString());
} }
...@@ -344,7 +344,7 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration) : CppElement() ...@@ -344,7 +344,7 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration) : CppElement()
} }
setTooltip(overview.prettyType(declaration->type(), m_qualifiedName)); setTooltip(overview.prettyType(declaration->type(), m_qualifiedName));
setLink(CPPEditor::linkToSymbol(declaration)); setLink(CPPEditorWidget::linkToSymbol(declaration));
setHelpMark(m_name); setHelpMark(m_name);
} }
......
...@@ -59,13 +59,13 @@ class CppModelManagerInterface; ...@@ -59,13 +59,13 @@ class CppModelManagerInterface;
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditor; class CPPEditorWidget;
class CppElement; class CppElement;
class CppElementEvaluator class CppElementEvaluator
{ {
public: public:
CppElementEvaluator(CPPEditor *editor); CppElementEvaluator(CPPEditorWidget *editor);
void setTextCursor(const QTextCursor &tc); void setTextCursor(const QTextCursor &tc);
void setLookupBaseClasses(const bool lookup); void setLookupBaseClasses(const bool lookup);
...@@ -85,7 +85,7 @@ private: ...@@ -85,7 +85,7 @@ private:
const CPlusPlus::LookupItem &lookupItem, const CPlusPlus::LookupItem &lookupItem,
const CPlusPlus::LookupContext &lookupContext); const CPlusPlus::LookupContext &lookupContext);
CPPEditor *m_editor; CPPEditorWidget *m_editor;
CPlusPlus::CppModelManagerInterface *m_modelManager; CPlusPlus::CppModelManagerInterface *m_modelManager;
QTextCursor m_tc; QTextCursor m_tc;
bool m_lookupBaseClasses; bool m_lookupBaseClasses;
...@@ -101,14 +101,14 @@ public: ...@@ -101,14 +101,14 @@ public:
const TextEditor::HelpItem::Category &helpCategory() const; const TextEditor::HelpItem::Category &helpCategory() const;
const QStringList &helpIdCandidates() const; const QStringList &helpIdCandidates() const;
const QString &helpMark() const; const QString &helpMark() const;
const CPPEditor::Link &link() const; const CPPEditorWidget::Link &link() const;
const QString &tooltip() const; const QString &tooltip() const;
protected: protected:
CppElement(); CppElement();
void setHelpCategory(const TextEditor::HelpItem::Category &category); 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 setTooltip(const QString &tooltip);
void setHelpIdCandidates(const QStringList &candidates); void setHelpIdCandidates(const QStringList &candidates);
void addHelpIdCandidate(const QString &candidate); void addHelpIdCandidate(const QString &candidate);
...@@ -118,7 +118,7 @@ private: ...@@ -118,7 +118,7 @@ private:
TextEditor::HelpItem::Category m_helpCategory; TextEditor::HelpItem::Category m_helpCategory;
QStringList m_helpIdCandidates; QStringList m_helpIdCandidates;
QString m_helpMark; QString m_helpMark;
CPPEditor::Link m_link; CPPEditorWidget::Link m_link;
QString m_tooltip; QString m_tooltip;
}; };
......
...@@ -43,7 +43,7 @@ namespace CppEditor { ...@@ -43,7 +43,7 @@ namespace CppEditor {
namespace Internal { namespace Internal {
class CPPEditor; class CPPEditorWidget;
class CppHighlighter : public TextEditor::SyntaxHighlighter class CppHighlighter : public TextEditor::SyntaxHighlighter
{ {
......
...@@ -58,7 +58,7 @@ CppHoverHandler::~CppHoverHandler() ...@@ -58,7 +58,7 @@ CppHoverHandler::~CppHoverHandler()
bool CppHoverHandler::acceptEditor(IEditor *editor) bool CppHoverHandler::acceptEditor(IEditor *editor)
{ {
CPPEditorEditable *cppEditor = qobject_cast<CPPEditorEditable *>(editor); CPPEditor *cppEditor = qobject_cast<CPPEditor *>(editor);
if (cppEditor) if (cppEditor)
return true;