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()
......
......@@ -285,11 +285,11 @@ protected:
struct CanonicalSymbol
{
CPPEditor *editor;
CPPEditorWidget *editor;
TypeOfExpression typeOfExpression;
SemanticInfo info;
CanonicalSymbol(CPPEditor *editor, const SemanticInfo &info)
CanonicalSymbol(CPPEditorWidget *editor, const SemanticInfo &info)
: editor(editor), info(info)
{
typeOfExpression.init(info.doc, info.snapshot);
......@@ -310,7 +310,7 @@ struct CanonicalSymbol
return getScopeAndExpression(editor, info, cursor, code);
}
static Scope *getScopeAndExpression(CPPEditor *editor, const SemanticInfo &info,
static Scope *getScopeAndExpression(CPPEditorWidget *editor, const SemanticInfo &info,
const QTextCursor &cursor,
QString *code)
{
......@@ -396,16 +396,16 @@ int numberOfClosedEditors = 0;
} // end of anonymous namespace
CPPEditorEditable::CPPEditorEditable(CPPEditor *editor)
: BaseTextEditorEditable(editor)
CPPEditor::CPPEditor(CPPEditorWidget *editor)
: BaseTextEditor(editor)
{
m_context.add(CppEditor::Constants::C_CPPEDITOR);
m_context.add(ProjectExplorer::Constants::LANG_CXX);
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
}
CPPEditor::CPPEditor(QWidget *parent)
: TextEditor::BaseTextEditor(parent)
CPPEditorWidget::CPPEditorWidget(QWidget *parent)
: TextEditor::BaseTextEditorWidget(parent)
, m_currentRenameSelection(NoCurrentRenameSelection)
, m_inRename(false)
, m_inRenameChanged(false)
......@@ -443,7 +443,7 @@ CPPEditor::CPPEditor(QWidget *parent)
connect(&m_referencesWatcher, SIGNAL(finished()), SLOT(markSymbolsNow()));
}
CPPEditor::~CPPEditor()
CPPEditorWidget::~CPPEditorWidget()
{
if (Core::EditorManager *em = Core::EditorManager::instance())
em->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
......@@ -458,14 +458,14 @@ CPPEditor::~CPPEditor()
}
}
TextEditor::BaseTextEditorEditable *CPPEditor::createEditableInterface()
TextEditor::BaseTextEditor *CPPEditorWidget::createEditor()
{
CPPEditorEditable *editable = new CPPEditorEditable(this);
CPPEditor *editable = new CPPEditor(this);
createToolBar(editable);
return editable;
}
void CPPEditor::createToolBar(CPPEditorEditable *editable)
void CPPEditorWidget::createToolBar(CPPEditor *editable)
{
m_outlineCombo = new QComboBox;
m_outlineCombo->setMinimumContentsLength(22);
......@@ -534,55 +534,55 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
static_cast<QHBoxLayout*>(w->layout())->insertWidget(0, m_outlineCombo, 1);
}
void CPPEditor::paste()
void CPPEditorWidget::paste()
{
if (m_currentRenameSelection == NoCurrentRenameSelection) {
BaseTextEditor::paste();
BaseTextEditorWidget::paste();
return;
}
startRename();
BaseTextEditor::paste();
BaseTextEditorWidget::paste();
finishRename();
}
void CPPEditor::cut()
void CPPEditorWidget::cut()
{
if (m_currentRenameSelection == NoCurrentRenameSelection) {
BaseTextEditor::cut();
BaseTextEditorWidget::cut();
return;
}
startRename();
BaseTextEditor::cut();
BaseTextEditorWidget::cut();
finishRename();
}
CppModelManagerInterface *CPPEditor::modelManager() const
CppModelManagerInterface *CPPEditorWidget::modelManager() const
{
return m_modelManager;
}
void CPPEditor::setMimeType(const QString &mt)
void CPPEditorWidget::setMimeType(const QString &mt)
{
BaseTextEditor::setMimeType(mt);
BaseTextEditorWidget::setMimeType(mt);
setObjCEnabled(mt == CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE);
}
void CPPEditor::setObjCEnabled(bool onoff)
void CPPEditorWidget::setObjCEnabled(bool onoff)
{
m_objcEnabled = onoff;
}
bool CPPEditor::isObjCEnabled() const
bool CPPEditorWidget::isObjCEnabled() const
{ return m_objcEnabled; }
void CPPEditor::startRename()
void CPPEditorWidget::startRename()
{
m_inRenameChanged = false;
}
void CPPEditor::finishRename()
void CPPEditorWidget::finishRename()
{
if (!m_inRenameChanged)
return;
......@@ -613,7 +613,7 @@ void CPPEditor::finishRename()
m_inRename = false;
}
void CPPEditor::abortRename()
void CPPEditorWidget::abortRename()
{
if (m_currentRenameSelection <= NoCurrentRenameSelection)
return;
......@@ -624,13 +624,13 @@ void CPPEditor::abortRename()
setExtraSelections(CodeSemanticsSelection, m_renameSelections);
}
void CPPEditor::rehighlight(bool force)
void CPPEditorWidget::rehighlight(bool force)
{
const SemanticHighlighter::Source source = currentSource(force);
m_semanticHighlighter->rehighlight(source);
}
void CPPEditor::onDocumentUpdated(Document::Ptr doc)
void CPPEditorWidget::onDocumentUpdated(Document::Ptr doc)
{
if (doc->fileName() != file()->fileName())
return;
......@@ -646,7 +646,7 @@ void CPPEditor::onDocumentUpdated(Document::Ptr doc)
m_updateOutlineTimer->start();
}
const Macro *CPPEditor::findCanonicalMacro(const QTextCursor &cursor, Document::Ptr doc) const
const Macro *CPPEditorWidget::findCanonicalMacro(const QTextCursor &cursor, Document::Ptr doc) const
{
if (! doc)
return 0;
......@@ -663,7 +663,7 @@ const Macro *CPPEditor::findCanonicalMacro(const QTextCursor &cursor, Document::
return 0;
}
void CPPEditor::findUsages()
void CPPEditorWidget::findUsages()
{
SemanticInfo info = m_lastSemanticInfo;
info.snapshot = CppModelManagerInterface::instance()->snapshot();
......@@ -679,7 +679,7 @@ void CPPEditor::findUsages()
}
void CPPEditor::renameUsagesNow(const QString &replacement)
void CPPEditorWidget::renameUsagesNow(const QString &replacement)
{
SemanticInfo info = m_lastSemanticInfo;
info.snapshot = CppModelManagerInterface::instance()->snapshot();
......@@ -700,12 +700,12 @@ void CPPEditor::renameUsagesNow(const QString &replacement)
}
}
void CPPEditor::renameUsages()
void CPPEditorWidget::renameUsages()
{
renameUsagesNow();
}
bool CPPEditor::showWarningMessage() const
bool CPPEditorWidget::showWarningMessage() const
{
// Restore settings
QSettings *settings = Core::ICore::instance()->settings();
......@@ -717,7 +717,7 @@ bool CPPEditor::showWarningMessage() const
return showWarningMessage;
}
void CPPEditor::setShowWarningMessage(bool showWarningMessage)
void CPPEditorWidget::setShowWarningMessage(bool showWarningMessage)
{
// Restore settings
QSettings *settings = Core::ICore::instance()->settings();
......@@ -728,13 +728,13 @@ void CPPEditor::setShowWarningMessage(bool showWarningMessage)
settings->endGroup();
}
void CPPEditor::hideRenameNotification()
void CPPEditorWidget::hideRenameNotification()
{
setShowWarningMessage(false);
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
}
void CPPEditor::markSymbolsNow()
void CPPEditorWidget::markSymbolsNow()
{
if (m_references.isCanceled())
return;
......@@ -783,7 +783,7 @@ static QList<int> lazyFindReferences(Scope *scope, QString code, Document::Ptr d
return QList<int>();
}
void CPPEditor::markSymbols(const QTextCursor &tc, const SemanticInfo &info)
void CPPEditorWidget::markSymbols(const QTextCursor &tc, const SemanticInfo &info)
{
abortRename();
......@@ -806,7 +806,7 @@ void CPPEditor::markSymbols(const QTextCursor &tc, const SemanticInfo &info)
}
}
void CPPEditor::renameSymbolUnderCursor()
void CPPEditorWidget::renameSymbolUnderCursor()
{
updateSemanticInfo(m_semanticHighlighter->semanticInfo(currentSource()));
abortRename();
......@@ -833,7 +833,7 @@ void CPPEditor::renameSymbolUnderCursor()
renameUsages();
}
void CPPEditor::onContentsChanged(int position, int charsRemoved, int charsAdded)
void CPPEditorWidget::onContentsChanged(int position, int charsRemoved, int charsAdded)
{
Q_UNUSED(position)
......@@ -857,10 +857,10 @@ void CPPEditor::onContentsChanged(int position, int charsRemoved, int charsAdded
updateUses();
}
void CPPEditor::updateFileName()
void CPPEditorWidget::updateFileName()
{ }
void CPPEditor::jumpToOutlineElement(int)
void CPPEditorWidget::jumpToOutlineElement(int)
{
QModelIndex index = m_proxyModel->mapToSource(m_outlineCombo->view()->currentIndex());
Symbol *symbol = m_outlineModel->symbolFromIndex(index);
......@@ -870,7 +870,7 @@ void CPPEditor::jumpToOutlineElement(int)
openCppEditorAt(linkToSymbol(symbol));
}
void CPPEditor::setSortedOutline(bool sort)
void CPPEditorWidget::setSortedOutline(bool sort)
{
if (sort != sortedOutline()) {
if (sort)
......@@ -884,12 +884,12 @@ void CPPEditor::setSortedOutline(bool sort)
}
}
bool CPPEditor::sortedOutline() const
bool CPPEditorWidget::sortedOutline() const
{
return (m_proxyModel->sortColumn() == 0);
}
void CPPEditor::updateOutlineNow()
void CPPEditorWidget::updateOutlineNow()
{
const Snapshot snapshot = m_modelManager->snapshot();
Document::Ptr document = snapshot.document(file()->fileName());
......@@ -909,12 +909,12 @@ void CPPEditor::updateOutlineNow()
updateOutlineIndexNow();
}
void CPPEditor::updateOutlineIndex()
void CPPEditorWidget::updateOutlineIndex()
{
m_updateOutlineIndexTimer->start();
}
void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses,
void CPPEditorWidget::highlightUses(const QList<SemanticInfo::Use> &uses,
const SemanticInfo &semanticInfo,
QList<QTextEdit::ExtraSelection> *selections)
{
......@@ -950,7 +950,7 @@ void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses,
}
}
void CPPEditor::updateOutlineIndexNow()
void CPPEditorWidget::updateOutlineIndexNow()
{
if (!m_outlineModel->document())
return;
......@@ -980,19 +980,19 @@ void CPPEditor::updateOutlineIndexNow()
}
}
void CPPEditor::updateOutlineToolTip()
void CPPEditorWidget::updateOutlineToolTip()
{
m_outlineCombo->setToolTip(m_outlineCombo->currentText());
}
void CPPEditor::updateUses()
void CPPEditorWidget::updateUses()
{
if (editorRevision() != m_highlightRevision)
m_highlighter.cancel();
m_updateUsesTimer->start();
}
void CPPEditor::updateUsesNow()
void CPPEditorWidget::updateUsesNow()
{
if (m_currentRenameSelection != NoCurrentRenameSelection)
return;
......@@ -1000,7 +1000,7 @@ void CPPEditor::updateUsesNow()
semanticRehighlight();
}
void CPPEditor::highlightSymbolUsages(int from, int to)
void CPPEditorWidget::highlightSymbolUsages(int from, int to)
{
if (editorRevision() != m_highlightRevision)
return; // outdated
......@@ -1072,7 +1072,7 @@ void CPPEditor::highlightSymbolUsages(int from, int to)
}
}
void CPPEditor::finishHighlightSymbolUsages()