Commit 6c6f47f8 authored by hjk's avatar hjk Committed by Eike Ziller

Core: Make IEditor::id a value member and adjust users

Change-Id: I47e457c4a1821c515cd8a740d27bfe005a0c09e6
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 9035a9b7
......@@ -44,6 +44,8 @@ using namespace Internal;
Android::Internal::AndroidManifestEditor::AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget)
: Core::IEditor(editorWidget), m_toolBar(0)
{
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
m_toolBar = new QToolBar(editorWidget);
m_actionGroup = new QActionGroup(this);
connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*)));
......@@ -64,11 +66,6 @@ Android::Internal::AndroidManifestEditor::AndroidManifestEditor(AndroidManifestE
setWidget(editorWidget);
}
Core::Id AndroidManifestEditor::id() const
{
return Constants::ANDROID_MANIFEST_EDITOR_ID;
}
bool AndroidManifestEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
return widget()->open(errorString, fileName, realFileName);
......
......@@ -50,7 +50,6 @@ class AndroidManifestEditor : public Core::IEditor
public:
explicit AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget);
Core::Id id() const;
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
QWidget *toolBar();
AndroidManifestEditorWidget *widget() const;
......
......@@ -52,6 +52,7 @@ using namespace Android::Internal;
JavaEditor::JavaEditor(JavaEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Constants::JAVA_EDITOR_ID);
setContext(Core::Context(Constants::C_JAVA_EDITOR,
TextEditor::Constants::C_TEXTEDITOR));
}
......@@ -64,11 +65,6 @@ Core::IEditor *JavaEditor::duplicate()
return ret->editor();
}
Core::Id JavaEditor::id() const
{
return Core::Id(Constants::JAVA_EDITOR_ID);
}
TextEditor::CompletionAssistProvider *JavaEditor::completionAssistProvider()
{
return ExtensionSystem::PluginManager::getObject<JavaCompletionAssistProvider>();
......
......@@ -49,7 +49,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
TextEditor::CompletionAssistProvider *completionAssistProvider();
};
......
......@@ -340,6 +340,7 @@ class BinEditor : public Core::IEditor
public:
BinEditor(BinEditorWidget *widget)
{
setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
setWidget(widget);
m_widget = widget;
m_file = new BinEditorDocument(m_widget);
......@@ -380,7 +381,6 @@ public:
return m_file->open(errorString, fileName);
}
Core::IDocument *document() { return m_file; }
Core::Id id() const { return Core::Id(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); }
QWidget *toolBar() { return m_toolBar; }
......
......@@ -59,6 +59,7 @@ using namespace CMakeProjectManager::Internal;
CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged()));
......@@ -72,11 +73,6 @@ Core::IEditor *CMakeEditor::duplicate()
return ret->editor();
}
Core::Id CMakeEditor::id() const
{
return Core::Id(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
}
TextEditor::CompletionAssistProvider *CMakeEditor::completionAssistProvider()
{
return ExtensionSystem::PluginManager::getObject<CMakeFileCompletionAssistProvider>();
......
......@@ -54,7 +54,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
TextEditor::CompletionAssistProvider *completionAssistProvider();
private slots:
......
......@@ -56,3 +56,14 @@
\sa Core::EditorFactoryInterface Core::IContext
*/
void Core::IEditor::setId(Core::Id id)
{
m_id = id;
}
Core::Id Core::IEditor::id() const
{
return m_id;
}
......@@ -47,9 +47,11 @@ public:
IEditor(QObject *parent = 0) : IContext(parent) {}
virtual ~IEditor() {}
void setId(Core::Id id);
Core::Id id() const;
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName) = 0;
virtual IDocument *document() = 0;
virtual Core::Id id() const = 0;
virtual bool duplicateSupported() const { return false; }
virtual IEditor *duplicate() { return 0; }
......@@ -64,6 +66,9 @@ public:
virtual QWidget *toolBar() = 0;
virtual bool isDesignModePreferred() const { return false; }
private:
Core::Id m_id;
};
} // namespace Core
......
......@@ -504,6 +504,7 @@ bool handleDoxygenContinuation(QTextCursor &cursor,
CPPEditor::CPPEditor(CPPEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(CppEditor::Constants::CPPEDITOR_ID);
m_context.add(CppEditor::Constants::C_CPPEDITOR);
m_context.add(ProjectExplorer::Constants::LANG_CXX);
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
......@@ -1499,11 +1500,6 @@ Core::IEditor *CPPEditor::duplicate()
return newEditor->editor();
}
Core::Id CPPEditor::id() const
{
return CppEditor::Constants::CPPEDITOR_ID;
}
bool CPPEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))
......
......@@ -98,7 +98,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
......
......@@ -60,9 +60,11 @@ class DescriptionEditor : public BaseTextEditor
{
Q_OBJECT
public:
DescriptionEditor(BaseTextEditorWidget *editorWidget) : BaseTextEditor(editorWidget) {}
Core::Id id() const { return "DescriptionEditor"; }
DescriptionEditor(BaseTextEditorWidget *editorWidget)
: BaseTextEditor(editorWidget)
{
setId("DescriptionEditor");
}
};
class DescriptionEditorWidget : public BaseTextEditorWidget
......@@ -147,6 +149,7 @@ DiffEditor::DiffEditor(DiffEditor *other)
void DiffEditor::ctor()
{
setId(Constants::DIFF_EDITOR_ID);
QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
m_descriptionWidget = new Internal::DescriptionEditorWidget(splitter);
......@@ -212,11 +215,6 @@ Core::IDocument *DiffEditor::document()
return m_document.data();
}
Core::Id DiffEditor::id() const
{
return Constants::DIFF_EDITOR_ID;
}
static QToolBar *createToolBar(const QWidget *someWidget)
{
// Create
......
......@@ -67,7 +67,6 @@ public:
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
Core::Id id() const;
QWidget *toolBar();
......
......@@ -360,12 +360,11 @@ public:
SideDiffEditor(BaseTextEditorWidget *editorWidget)
: BaseTextEditor(editorWidget)
{
setId("SideDiffEditor");
connect(this, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
this, SLOT(slotTooltipRequested(TextEditor::ITextEditor*,QPoint,int)));
}
Core::Id id() const { return "SideDiffEditor"; }
private slots:
void slotTooltipRequested(TextEditor::ITextEditor *editor, const QPoint &globalPoint, int position);
......
......@@ -78,14 +78,10 @@ Core::IEditor *ProjectFilesFactory::createEditor()
ProjectFilesEditor::ProjectFilesEditor(ProjectFilesEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Constants::FILES_EDITOR_ID);
setContext(Core::Context(Constants::C_FILESEDITOR));
}
Core::Id ProjectFilesEditor::id() const
{
return Core::Id(Constants::FILES_EDITOR_ID);
}
bool ProjectFilesEditor::duplicateSupported() const
{
return true;
......
......@@ -59,7 +59,6 @@ class ProjectFilesEditor : public TextEditor::BaseTextEditor
public:
ProjectFilesEditor(ProjectFilesEditorWidget *editorWidget);
Core::Id id() const;
bool duplicateSupported() const;
Core::IEditor *duplicate();
};
......
......@@ -206,11 +206,6 @@ Core::IEditor *GLSLEditorEditable::duplicate()
return newEditor->editor();
}
Core::Id GLSLEditorEditable::id() const
{
return GLSLEditor::Constants::C_GLSLEDITOR_ID;
}
bool GLSLEditorEditable::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
baseTextDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
......
......@@ -46,6 +46,7 @@ namespace Internal {
GLSLEditorEditable::GLSLEditorEditable(GLSLTextEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(GLSLEditor::Constants::C_GLSLEDITOR_ID);
setContext(Core::Context(GLSLEditor::Constants::C_GLSLEDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
}
......
......@@ -46,7 +46,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
TextEditor::CompletionAssistProvider *completionAssistProvider();
};
......
......@@ -62,6 +62,8 @@ ImageViewer::ImageViewer(QWidget *parent)
: IEditor(parent),
d(new ImageViewerPrivate)
{
setId(Constants::IMAGEVIEWER_ID);
d->file = new ImageViewerFile(this);
d->imageView = new ImageView();
......@@ -137,11 +139,6 @@ Core::IDocument *ImageViewer::document()
return d->file;
}
Core::Id ImageViewer::id() const
{
return Core::Id(Constants::IMAGEVIEWER_ID);
}
QWidget *ImageViewer::toolBar()
{
return d->toolbar;
......
......@@ -56,7 +56,6 @@ public:
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
Core::Id id() const;
QWidget *toolBar();
public slots:
......
......@@ -50,6 +50,7 @@ namespace Internal {
PythonEditor::PythonEditor(EditorWidget *editorWidget)
:BaseTextEditor(editorWidget)
{
setId(Constants::C_PYTHONEDITOR_ID);
setContext(Core::Context(Constants::C_PYTHONEDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
}
......@@ -65,14 +66,6 @@ Core::IEditor *PythonEditor::duplicate()
return widget->editor();
}
/**
* @returns Unique editor class identifier, that is Constants::C_PYTHONEDITOR_ID
*/
Core::Id PythonEditor::id() const
{
return Core::Id(Constants::C_PYTHONEDITOR_ID);
}
bool PythonEditor::open(QString *errorString,
const QString &fileName,
const QString &realFileName)
......
......@@ -48,8 +48,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
/**
Opens file for editing, actual work performed by base class
*/
......
......@@ -55,6 +55,7 @@ namespace Internal {
ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Constants::PROFILE_EDITOR_ID);
setContext(Core::Context(Constants::C_PROFILEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
}
......@@ -67,11 +68,6 @@ Core::IEditor *ProFileEditor::duplicate()
return ret->editor();
}
Core::Id ProFileEditor::id() const
{
return Core::Id(Constants::PROFILE_EDITOR_ID);
}
TextEditor::CompletionAssistProvider *ProFileEditor::completionAssistProvider()
{
return ExtensionSystem::PluginManager::getObject<ProFileCompletionAssistProvider>();
......
......@@ -49,7 +49,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
TextEditor::CompletionAssistProvider *completionAssistProvider();
};
......
......@@ -183,11 +183,6 @@ IEditor *QmlJSEditor::duplicate()
return newEditor->editor();
}
Id QmlJSEditor::id() const
{
return Constants::C_QMLJSEDITOR_ID;
}
bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
......
......@@ -50,6 +50,7 @@ namespace Internal {
QmlJSEditor::QmlJSEditor(QmlJSTextEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Constants::C_QMLJSEDITOR_ID);
m_context.add(Constants::C_QMLJSEDITOR_ID);
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
m_context.add(ProjectExplorer::Constants::LANG_QMLJS);
......
......@@ -48,7 +48,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
bool isDesignModePreferred() const;
......
......@@ -56,6 +56,7 @@ namespace Internal {
BarDescriptorEditor::BarDescriptorEditor()
{
setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID);
m_file = new BarDescriptorDocument(this);
BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(this);
......@@ -122,11 +123,6 @@ Core::IDocument *BarDescriptorEditor::document()
return m_file;
}
Core::Id BarDescriptorEditor::id() const
{
return Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID;
}
QWidget *BarDescriptorEditor::toolBar()
{
return m_toolBar;
......
......@@ -62,7 +62,6 @@ public:
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
Core::Id id() const;
QWidget *toolBar();
EditorPage activePage() const;
......
......@@ -87,6 +87,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
m_contextMenu(new QMenu),
m_toolBar(new QToolBar)
{
setId(ResourceEditor::Constants::RESOURCEEDITOR_ID);
setContext(context);
setWidget(m_resourceEditor);
......@@ -217,11 +218,6 @@ void ResourceEditorDocument::setBlockDirtyChanged(bool value)
m_blockDirtyChanged = value;
}
Core::Id ResourceEditorW::id() const
{
return Core::Id(ResourceEditor::Constants::RESOURCEEDITOR_ID);
}
QWidget *ResourceEditorW::toolBar()
{
return m_toolBar;
......
......@@ -88,7 +88,6 @@ public:
// IEditor
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document() { return m_resourceDocument; }
Core::Id id() const;
QWidget *toolBar();
void setSuggestedFileName(const QString &fileName);
......
......@@ -63,6 +63,7 @@ namespace TextEditor {
PlainTextEditor::PlainTextEditor(PlainTextEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
}
......@@ -111,11 +112,6 @@ IEditor *PlainTextEditor::duplicate()
return newWidget->editor();
}
Id PlainTextEditor::id() const
{
return Core::Constants::K_DEFAULT_TEXT_EDITOR_ID;
}
void PlainTextEditorWidget::unCommentSelection()
{
Utils::unCommentSelection(this, m_commentDefinition);
......
......@@ -49,7 +49,6 @@ public:
bool duplicateSupported() const { return true; }
Core::IEditor *duplicate();
Core::Id id() const;
};
class TEXTEDITOR_EXPORT PlainTextDocument : public BaseTextDocument
......
......@@ -47,11 +47,7 @@ SnippetEditor::SnippetEditor(SnippetEditorWidget *editor)
: BaseTextEditor(editor)
{
setContext(Core::Context(Constants::SNIPPET_EDITOR_ID, Constants::C_TEXTEDITOR));
}
Core::Id SnippetEditor::id() const
{
return Core::Id(Constants::SNIPPET_EDITOR_ID);
setId(Constants::SNIPPET_EDITOR_ID);
}
SnippetEditorWidget::SnippetEditorWidget(QWidget *parent) : BaseTextEditorWidget(parent)
......
......@@ -50,7 +50,6 @@ public:
bool duplicateSupported() const { return false; }
Core::IEditor *duplicate() { return 0; }
Core::Id id() const;
};
class TEXTEDITOR_EXPORT SnippetEditorWidget : public BaseTextEditorWidget
......
......@@ -154,22 +154,17 @@ class VcsBaseEditor : public TextEditor::BaseTextEditor
public:
VcsBaseEditor(VcsBaseEditorWidget *, const VcsBaseEditorParameters *type);
Core::Id id() const { return m_id; }
signals:
void describeRequested(const QString &source, const QString &change);
void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int line);
private:
Core::Id m_id;
};
VcsBaseEditor::VcsBaseEditor(VcsBaseEditorWidget *widget,
const VcsBaseEditorParameters *type) :
BaseTextEditor(widget),
m_id(type->id)
BaseTextEditor(widget)
{
setId(type->id);
setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));
}
......
......@@ -181,6 +181,7 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa
SubmitEditorWidget *editorWidget) :
d(new VcsBaseSubmitEditorPrivate(parameters, editorWidget, this))
{
setId(parameters->id);
setContext(Core::Context(parameters->context));
setWidget(d->m_widget);
document()->setDisplayName(QCoreApplication::translate("VCS", d->m_parameters->displayName));
......@@ -392,11 +393,6 @@ void VcsBaseSubmitEditor::setCheckScriptWorkingDirectory(const QString &s)
d->m_checkScriptWorkingDirectory = s;
}
Core::Id VcsBaseSubmitEditor::id() const
{
return d->m_parameters->id;
}
static QToolBar *createToolBar(const QWidget *someWidget, QAction *submitAction, QAction *diffAction)
{
// Create
......
......@@ -114,7 +114,6 @@ public:
// Core::IEditor
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
Core::Id id() const;
QWidget *toolBar();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment