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

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;
......
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