forked from qt-creator/qt-creator
TextEditor: Merge the two sets of *EditorWidget constructors
Change-Id: I45d87d0be722ac36d64af222f03f8cb76242c9df Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -1423,9 +1423,10 @@ int PermissionsModel::rowCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
|
|
||||||
AndroidManifestTextEditorWidget::AndroidManifestTextEditorWidget(AndroidManifestEditorWidget *parent)
|
AndroidManifestTextEditorWidget::AndroidManifestTextEditorWidget(AndroidManifestEditorWidget *parent)
|
||||||
: TextEditor::BaseTextEditorWidget(new AndroidManifestDocument(parent), parent),
|
: TextEditor::BaseTextEditorWidget(parent),
|
||||||
m_parent(parent)
|
m_parent(parent)
|
||||||
{
|
{
|
||||||
|
setTextDocument(TextEditor::BaseTextDocumentPtr(new AndroidManifestDocument(parent)));
|
||||||
setupAsPlainEditor();
|
setupAsPlainEditor();
|
||||||
textDocument()->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
textDocument()->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
|
||||||
}
|
}
|
||||||
|
@@ -62,8 +62,8 @@ JavaEditor::JavaEditor(JavaEditorWidget *editor)
|
|||||||
|
|
||||||
Core::IEditor *JavaEditor::duplicate()
|
Core::IEditor *JavaEditor::duplicate()
|
||||||
{
|
{
|
||||||
JavaEditorWidget *ret = new JavaEditorWidget(
|
JavaEditorWidget *ret = new JavaEditorWidget;
|
||||||
qobject_cast<JavaEditorWidget*>(editorWidget()));
|
ret->setTextDocument(editorWidget()->textDocumentPtr());
|
||||||
TextEditor::TextEditorSettings::initializeEditor(ret);
|
TextEditor::TextEditorSettings::initializeEditor(ret);
|
||||||
return ret->editor();
|
return ret->editor();
|
||||||
}
|
}
|
||||||
@@ -72,13 +72,7 @@ Core::IEditor *JavaEditor::duplicate()
|
|||||||
// JavaEditorWidget
|
// JavaEditorWidget
|
||||||
//
|
//
|
||||||
|
|
||||||
JavaEditorWidget::JavaEditorWidget(QWidget *parent)
|
JavaEditorWidget::JavaEditorWidget()
|
||||||
: BaseTextEditorWidget(new JavaDocument(), parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
JavaEditorWidget::JavaEditorWidget(JavaEditorWidget *other)
|
|
||||||
: BaseTextEditorWidget(other)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,14 +56,10 @@ class JavaEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JavaEditorWidget(QWidget *parent = 0);
|
JavaEditorWidget();
|
||||||
JavaEditorWidget(JavaEditorWidget *other);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
|
|
||||||
private:
|
|
||||||
JavaEditorWidget(BaseTextEditorWidget *); // avoid stupidity
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class JavaDocument : public TextEditor::BaseTextDocument
|
class JavaDocument : public TextEditor::BaseTextDocument
|
||||||
|
@@ -49,6 +49,7 @@ JavaEditorFactory::JavaEditorFactory()
|
|||||||
Core::IEditor *JavaEditorFactory::createEditor()
|
Core::IEditor *JavaEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
JavaEditorWidget *editor = new JavaEditorWidget;
|
JavaEditorWidget *editor = new JavaEditorWidget;
|
||||||
|
editor->setTextDocument(TextEditor::BaseTextDocumentPtr(new JavaDocument));
|
||||||
TextEditor::TextEditorSettings::initializeEditor(editor);
|
TextEditor::TextEditorSettings::initializeEditor(editor);
|
||||||
return editor->editor();
|
return editor->editor();
|
||||||
}
|
}
|
||||||
|
@@ -70,8 +70,8 @@ CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
|
|||||||
|
|
||||||
Core::IEditor *CMakeEditor::duplicate()
|
Core::IEditor *CMakeEditor::duplicate()
|
||||||
{
|
{
|
||||||
CMakeEditorWidget *ret = new CMakeEditorWidget(
|
CMakeEditorWidget *ret = new CMakeEditorWidget;
|
||||||
qobject_cast<CMakeEditorWidget *>(editorWidget()));
|
ret->setTextDocument(editorWidget()->textDocumentPtr());
|
||||||
TextEditor::TextEditorSettings::initializeEditor(ret);
|
TextEditor::TextEditorSettings::initializeEditor(ret);
|
||||||
return ret->editor();
|
return ret->editor();
|
||||||
}
|
}
|
||||||
@@ -150,19 +150,7 @@ QString CMakeEditor::contextHelpId() const
|
|||||||
// CMakeEditor
|
// CMakeEditor
|
||||||
//
|
//
|
||||||
|
|
||||||
CMakeEditorWidget::CMakeEditorWidget(QWidget *parent)
|
CMakeEditorWidget::CMakeEditorWidget()
|
||||||
: BaseTextEditorWidget(new CMakeDocument(), parent)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
CMakeEditorWidget::CMakeEditorWidget(CMakeEditorWidget *other)
|
|
||||||
: BaseTextEditorWidget(other)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMakeEditorWidget::ctor()
|
|
||||||
{
|
{
|
||||||
setCodeFoldingSupported(true);
|
setCodeFoldingSupported(true);
|
||||||
}
|
}
|
||||||
|
@@ -66,8 +66,7 @@ class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMakeEditorWidget(QWidget *parent = 0);
|
CMakeEditorWidget();
|
||||||
CMakeEditorWidget(CMakeEditorWidget *other);
|
|
||||||
|
|
||||||
bool save(const QString &fileName = QString());
|
bool save(const QString &fileName = QString());
|
||||||
|
|
||||||
@@ -76,10 +75,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
void contextMenuEvent(QContextMenuEvent *e);
|
void contextMenuEvent(QContextMenuEvent *e);
|
||||||
|
|
||||||
private:
|
|
||||||
CMakeEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
|
||||||
void ctor();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMakeDocument : public TextEditor::BaseTextDocument
|
class CMakeDocument : public TextEditor::BaseTextDocument
|
||||||
|
@@ -72,7 +72,8 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
|
|||||||
|
|
||||||
Core::IEditor *CMakeEditorFactory::createEditor()
|
Core::IEditor *CMakeEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
CMakeEditorWidget *rc = new CMakeEditorWidget();
|
CMakeEditorWidget *widget = new CMakeEditorWidget;
|
||||||
TextEditor::TextEditorSettings::initializeEditor(rc);
|
widget->setTextDocument(TextEditor::BaseTextDocumentPtr(new CMakeDocument));
|
||||||
return rc->editor();
|
TextEditor::TextEditorSettings::initializeEditor(widget);
|
||||||
|
return widget->editor();
|
||||||
}
|
}
|
||||||
|
@@ -175,20 +175,10 @@ CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CppEditorWidget::CppEditorWidget(QWidget *parent)
|
CppEditorWidget::CppEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
||||||
: TextEditor::BaseTextEditorWidget(new CPPEditorDocument(), parent)
|
: TextEditor::BaseTextEditorWidget(0)
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
CppEditorWidget::CppEditorWidget(CppEditorWidget *other)
|
|
||||||
: TextEditor::BaseTextEditorWidget(other)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppEditorWidget::ctor()
|
|
||||||
{
|
{
|
||||||
|
setTextDocument(doc);
|
||||||
d.reset(new CppEditorWidgetPrivate(this));
|
d.reset(new CppEditorWidgetPrivate(this));
|
||||||
|
|
||||||
qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
|
qRegisterMetaType<SemanticInfo>("CppTools::SemanticInfo");
|
||||||
@@ -781,8 +771,7 @@ void CppEditorWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
|
|
||||||
Core::IEditor *CPPEditor::duplicate()
|
Core::IEditor *CPPEditor::duplicate()
|
||||||
{
|
{
|
||||||
CppEditorWidget *newEditor = new CppEditorWidget(
|
CppEditorWidget *newEditor = new CppEditorWidget(editorWidget()->textDocumentPtr());
|
||||||
qobject_cast<CppEditorWidget *>(editorWidget()));
|
|
||||||
CppEditorPlugin::instance()->initializeEditor(newEditor);
|
CppEditorPlugin::instance()->initializeEditor(newEditor);
|
||||||
return newEditor->editor();
|
return newEditor->editor();
|
||||||
}
|
}
|
||||||
|
@@ -77,8 +77,7 @@ public:
|
|||||||
static QString identifierUnderCursor(QTextCursor *macroCursor);
|
static QString identifierUnderCursor(QTextCursor *macroCursor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppEditorWidget(QWidget *parent = 0);
|
CppEditorWidget(TextEditor::BaseTextDocumentPtr doc);
|
||||||
CppEditorWidget(CppEditorWidget *other);
|
|
||||||
~CppEditorWidget();
|
~CppEditorWidget();
|
||||||
|
|
||||||
CPPEditorDocument *cppEditorDocument() const;
|
CPPEditorDocument *cppEditorDocument() const;
|
||||||
@@ -154,9 +153,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
static bool openCppEditorAt(const Link &, bool inNextSplit = false);
|
static bool openCppEditorAt(const Link &, bool inNextSplit = false);
|
||||||
|
|
||||||
CppEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
|
||||||
void ctor();
|
|
||||||
|
|
||||||
unsigned editorRevision() const;
|
unsigned editorRevision() const;
|
||||||
bool isOutdated() const;
|
bool isOutdated() const;
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@ CppEditorFactory::CppEditorFactory(CppEditorPlugin *owner) :
|
|||||||
|
|
||||||
IEditor *CppEditorFactory::createEditor()
|
IEditor *CppEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
CppEditorWidget *editor = new CppEditorWidget();
|
CppEditorWidget *editor = new CppEditorWidget(BaseTextDocumentPtr(new CPPEditorDocument));
|
||||||
m_owner->initializeEditor(editor);
|
m_owner->initializeEditor(editor);
|
||||||
return editor->editor();
|
return editor->editor();
|
||||||
}
|
}
|
||||||
|
@@ -102,9 +102,10 @@ public:
|
|||||||
QVERIFY(ast);
|
QVERIFY(ast);
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
auto textDocument = new TextEditor::BaseTextDocument;
|
TextEditor::BaseTextDocumentPtr textDocument(new TextEditor::BaseTextDocument);
|
||||||
textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||||
TextEditor::BaseTextEditorWidget editorWidget(textDocument, 0);
|
TextEditor::BaseTextEditorWidget editorWidget(0);
|
||||||
|
editorWidget.setTextDocument(textDocument);
|
||||||
editorWidget.setupAsPlainEditor();
|
editorWidget.setupAsPlainEditor();
|
||||||
QString error;
|
QString error;
|
||||||
editorWidget.open(&error, document->fileName(), document->fileName());
|
editorWidget.open(&error, document->fileName(), document->fileName());
|
||||||
|
@@ -37,14 +37,14 @@
|
|||||||
namespace Designer {
|
namespace Designer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
DesignerXmlEditorWidget::DesignerXmlEditorWidget(QDesignerFormWindowInterface *form,
|
DesignerXmlEditorWidget::DesignerXmlEditorWidget(QDesignerFormWindowInterface *form)
|
||||||
QWidget *parent) :
|
|
||||||
TextEditor::BaseTextEditorWidget(new FormWindowFile(form), parent),
|
|
||||||
m_designerEditor(new FormWindowEditor(this))
|
|
||||||
{
|
{
|
||||||
|
TextEditor::BaseTextDocumentPtr doc(new FormWindowFile(form));
|
||||||
|
setTextDocument(doc);
|
||||||
|
m_designerEditor = new FormWindowEditor(this);
|
||||||
setupAsPlainEditor();
|
setupAsPlainEditor();
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
configureMimeType(textDocument()->mimeType());
|
configureMimeType(doc->mimeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditor::BaseTextEditor *DesignerXmlEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *DesignerXmlEditorWidget::createEditor()
|
||||||
|
@@ -57,8 +57,7 @@ class DesignerXmlEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DesignerXmlEditorWidget(QDesignerFormWindowInterface *form,
|
explicit DesignerXmlEditorWidget(QDesignerFormWindowInterface *form);
|
||||||
QWidget *parent = 0);
|
|
||||||
|
|
||||||
FormWindowEditor *designerEditor() const;
|
FormWindowEditor *designerEditor() const;
|
||||||
Internal::FormWindowFile *formWindowFile() const;
|
Internal::FormWindowFile *formWindowFile() const;
|
||||||
|
@@ -663,7 +663,7 @@ Command *FormEditorW::addToolAction(QAction *a, const Context &context, Id id,
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorData FormEditorW::createEditor(QWidget *parent)
|
EditorData FormEditorW::createEditor()
|
||||||
{
|
{
|
||||||
if (Designer::Constants::Internal::debug)
|
if (Designer::Constants::Internal::debug)
|
||||||
qDebug() << "FormEditorW::createEditor";
|
qDebug() << "FormEditorW::createEditor";
|
||||||
@@ -683,7 +683,7 @@ EditorData FormEditorW::createEditor(QWidget *parent)
|
|||||||
qdesigner_internal::FormWindowBase::setupDefaultAction(form);
|
qdesigner_internal::FormWindowBase::setupDefaultAction(form);
|
||||||
#endif
|
#endif
|
||||||
data.widgetHost = new SharedTools::WidgetHost( /* parent */ 0, form);
|
data.widgetHost = new SharedTools::WidgetHost( /* parent */ 0, form);
|
||||||
DesignerXmlEditorWidget *xmlEditor = new DesignerXmlEditorWidget(form, parent);
|
DesignerXmlEditorWidget *xmlEditor = new DesignerXmlEditorWidget(form);
|
||||||
TextEditor::TextEditorSettings::initializeEditor(xmlEditor);
|
TextEditor::TextEditorSettings::initializeEditor(xmlEditor);
|
||||||
data.formWindowEditor = xmlEditor->designerEditor();
|
data.formWindowEditor = xmlEditor->designerEditor();
|
||||||
connect(data.formWindowEditor->document(), SIGNAL(filePathChanged(QString,QString)),
|
connect(data.formWindowEditor->document(), SIGNAL(filePathChanged(QString,QString)),
|
||||||
|
@@ -111,7 +111,7 @@ public:
|
|||||||
// Deletes an existing instance if there is one.
|
// Deletes an existing instance if there is one.
|
||||||
static void deleteInstance();
|
static void deleteInstance();
|
||||||
|
|
||||||
EditorData createEditor(QWidget *parent = 0);
|
EditorData createEditor();
|
||||||
|
|
||||||
inline QDesignerFormEditorInterface *designerEditor() const { return m_formeditor; }
|
inline QDesignerFormEditorInterface *designerEditor() const { return m_formeditor; }
|
||||||
inline QWidget * const*designerSubWindows() const { return m_designerSubWindows; }
|
inline QWidget * const*designerSubWindows() const { return m_designerSubWindows; }
|
||||||
|
@@ -101,8 +101,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
|
DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
|
||||||
: BaseTextEditorWidget(new BaseTextDocument, parent)
|
: BaseTextEditorWidget(parent)
|
||||||
{
|
{
|
||||||
|
setTextDocument(BaseTextDocumentPtr(new BaseTextDocument));
|
||||||
DisplaySettings settings = displaySettings();
|
DisplaySettings settings = displaySettings();
|
||||||
settings.m_textWrapping = false;
|
settings.m_textWrapping = false;
|
||||||
settings.m_displayLineNumbers = false;
|
settings.m_displayLineNumbers = false;
|
||||||
|
@@ -36,8 +36,9 @@
|
|||||||
namespace DiffEditor {
|
namespace DiffEditor {
|
||||||
|
|
||||||
SelectableTextEditorWidget::SelectableTextEditorWidget(QWidget *parent)
|
SelectableTextEditorWidget::SelectableTextEditorWidget(QWidget *parent)
|
||||||
: BaseTextEditorWidget(new TextEditor::BaseTextDocument, parent)
|
: BaseTextEditorWidget(parent)
|
||||||
{
|
{
|
||||||
|
setTextDocument(TextEditor::BaseTextDocumentPtr(new TextEditor::BaseTextDocument));
|
||||||
setFrameStyle(QFrame::NoFrame);
|
setFrameStyle(QFrame::NoFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,7 +64,8 @@ ProjectFilesFactory::ProjectFilesFactory(Manager *manager)
|
|||||||
|
|
||||||
Core::IEditor *ProjectFilesFactory::createEditor()
|
Core::IEditor *ProjectFilesFactory::createEditor()
|
||||||
{
|
{
|
||||||
auto widget = new ProjectFilesEditorWidget(new BaseTextDocument, 0);
|
auto widget = new ProjectFilesEditorWidget;
|
||||||
|
widget->setTextDocument(BaseTextDocumentPtr(new BaseTextDocument));
|
||||||
TextEditorSettings::initializeEditor(widget);
|
TextEditorSettings::initializeEditor(widget);
|
||||||
return widget->editor();
|
return widget->editor();
|
||||||
}
|
}
|
||||||
@@ -85,7 +86,8 @@ ProjectFilesEditor::ProjectFilesEditor(ProjectFilesEditorWidget *editor)
|
|||||||
|
|
||||||
Core::IEditor *ProjectFilesEditor::duplicate()
|
Core::IEditor *ProjectFilesEditor::duplicate()
|
||||||
{
|
{
|
||||||
auto widget = new ProjectFilesEditorWidget(editorWidget());
|
auto widget = new ProjectFilesEditorWidget;
|
||||||
|
widget->setTextDocument(editorWidget()->textDocumentPtr());
|
||||||
TextEditorSettings::initializeEditor(widget);
|
TextEditorSettings::initializeEditor(widget);
|
||||||
return widget->editor();
|
return widget->editor();
|
||||||
}
|
}
|
||||||
@@ -96,13 +98,7 @@ Core::IEditor *ProjectFilesEditor::duplicate()
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ProjectFilesEditorWidget::ProjectFilesEditorWidget(BaseTextDocument *doc, QWidget *parent)
|
ProjectFilesEditorWidget::ProjectFilesEditorWidget()
|
||||||
: BaseTextEditorWidget(doc, parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectFilesEditorWidget::ProjectFilesEditorWidget(BaseTextEditorWidget *other)
|
|
||||||
: BaseTextEditorWidget(other)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,8 +39,6 @@ namespace GenericProjectManager {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class Manager;
|
class Manager;
|
||||||
class ProjectFilesEditor;
|
|
||||||
class ProjectFilesEditorWidget;
|
|
||||||
|
|
||||||
class ProjectFilesFactory: public Core::IEditorFactory
|
class ProjectFilesFactory: public Core::IEditorFactory
|
||||||
{
|
{
|
||||||
@@ -52,6 +50,16 @@ public:
|
|||||||
Core::IEditor *createEditor();
|
Core::IEditor *createEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ProjectFilesEditorWidget : public TextEditor::BaseTextEditorWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ProjectFilesEditorWidget();
|
||||||
|
|
||||||
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
|
};
|
||||||
|
|
||||||
class ProjectFilesEditor : public TextEditor::BaseTextEditor
|
class ProjectFilesEditor : public TextEditor::BaseTextEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -62,17 +70,6 @@ public:
|
|||||||
Core::IEditor *duplicate();
|
Core::IEditor *duplicate();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProjectFilesEditorWidget : public TextEditor::BaseTextEditorWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ProjectFilesEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
|
|
||||||
ProjectFilesEditorWidget(BaseTextEditorWidget *other);
|
|
||||||
|
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace GenericProjectManager
|
} // namespace GenericProjectManager
|
||||||
|
|
||||||
|
@@ -140,20 +140,10 @@ void Document::addRange(const QTextCursor &cursor, GLSL::Scope *scope)
|
|||||||
_cursors.append(c);
|
_cursors.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlslEditorWidget::GlslEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent)
|
GlslEditorWidget::GlslEditorWidget(const TextEditor::BaseTextDocumentPtr &doc)
|
||||||
: TextEditor::BaseTextEditorWidget(doc, parent)
|
|
||||||
{
|
{
|
||||||
ctor();
|
setTextDocument(doc);
|
||||||
}
|
|
||||||
|
|
||||||
GlslEditorWidget::GlslEditorWidget(GlslEditorWidget *other)
|
|
||||||
: TextEditor::BaseTextEditorWidget(other)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GlslEditorWidget::ctor()
|
|
||||||
{
|
|
||||||
m_outlineCombo = 0;
|
m_outlineCombo = 0;
|
||||||
setParenthesesMatchingEnabled(true);
|
setParenthesesMatchingEnabled(true);
|
||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
@@ -215,8 +205,7 @@ bool GlslEditorWidget::isOutdated() const
|
|||||||
|
|
||||||
Core::IEditor *GlslEditor::duplicate()
|
Core::IEditor *GlslEditor::duplicate()
|
||||||
{
|
{
|
||||||
GlslEditorWidget *newEditor = new GlslEditorWidget(
|
GlslEditorWidget *newEditor = new GlslEditorWidget(editorWidget()->textDocumentPtr());
|
||||||
qobject_cast<GlslEditorWidget *>(editorWidget()));
|
|
||||||
TextEditor::TextEditorSettings::initializeEditor(newEditor);
|
TextEditor::TextEditorSettings::initializeEditor(newEditor);
|
||||||
return newEditor->editor();
|
return newEditor->editor();
|
||||||
}
|
}
|
||||||
|
@@ -86,8 +86,7 @@ class GlslEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlslEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
|
GlslEditorWidget(const TextEditor::BaseTextDocumentPtr &doc);
|
||||||
GlslEditorWidget(GlslEditorWidget *other);
|
|
||||||
|
|
||||||
int editorRevision() const;
|
int editorRevision() const;
|
||||||
bool isOutdated() const;
|
bool isOutdated() const;
|
||||||
@@ -107,8 +106,6 @@ protected:
|
|||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlslEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
|
||||||
void ctor();
|
|
||||||
void setSelectedElements();
|
void setSelectedElements();
|
||||||
QString wordUnderCursor() const;
|
QString wordUnderCursor() const;
|
||||||
|
|
||||||
|
@@ -66,10 +66,10 @@ GLSLEditorFactory::GLSLEditorFactory(QObject *parent)
|
|||||||
|
|
||||||
Core::IEditor *GLSLEditorFactory::createEditor()
|
Core::IEditor *GLSLEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
auto doc = new TextEditor::BaseTextDocument;
|
TextEditor::BaseTextDocumentPtr doc(new TextEditor::BaseTextDocument);
|
||||||
doc->setId(C_GLSLEDITOR_ID);
|
doc->setId(C_GLSLEDITOR_ID);
|
||||||
doc->setIndenter(new GLSLIndenter);
|
doc->setIndenter(new GLSLIndenter);
|
||||||
GlslEditorWidget *rc = new GlslEditorWidget(doc, 0);
|
GlslEditorWidget *rc = new GlslEditorWidget(doc);
|
||||||
TextEditor::TextEditorSettings::initializeEditor(rc);
|
TextEditor::TextEditorSettings::initializeEditor(rc);
|
||||||
return rc->editor();
|
return rc->editor();
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ PythonEditor::PythonEditor(PythonEditorWidget *editorWidget)
|
|||||||
|
|
||||||
Core::IEditor *PythonEditor::duplicate()
|
Core::IEditor *PythonEditor::duplicate()
|
||||||
{
|
{
|
||||||
PythonEditorWidget *widget = new PythonEditorWidget(qobject_cast<PythonEditorWidget *>(editorWidget()));
|
PythonEditorWidget *widget = new PythonEditorWidget(editorWidget()->textDocumentPtr());
|
||||||
TextEditor::TextEditorSettings::initializeEditor(widget);
|
TextEditor::TextEditorSettings::initializeEditor(widget);
|
||||||
return widget->editor();
|
return widget->editor();
|
||||||
}
|
}
|
||||||
|
@@ -60,10 +60,10 @@ EditorFactory::EditorFactory(QObject *parent)
|
|||||||
|
|
||||||
Core::IEditor *EditorFactory::createEditor()
|
Core::IEditor *EditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
auto doc = new BaseTextDocument;
|
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||||
doc->setId(Constants::C_PYTHONEDITOR_ID);
|
doc->setId(Constants::C_PYTHONEDITOR_ID);
|
||||||
doc->setIndenter(new PythonIndenter);
|
doc->setIndenter(new PythonIndenter);
|
||||||
PythonEditorWidget *widget = new PythonEditorWidget(doc, 0);
|
PythonEditorWidget *widget = new PythonEditorWidget(doc);
|
||||||
TextEditor::TextEditorSettings::initializeEditor(widget);
|
TextEditor::TextEditorSettings::initializeEditor(widget);
|
||||||
|
|
||||||
return widget->editor();
|
return widget->editor();
|
||||||
|
@@ -47,25 +47,14 @@
|
|||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent)
|
PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
||||||
: TextEditor::BaseTextEditorWidget(doc, parent)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
PythonEditorWidget::PythonEditorWidget(PythonEditorWidget *other)
|
|
||||||
: TextEditor::BaseTextEditorWidget(other)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PythonEditorWidget::ctor()
|
|
||||||
{
|
{
|
||||||
|
setTextDocument(doc);
|
||||||
setParenthesesMatchingEnabled(true);
|
setParenthesesMatchingEnabled(true);
|
||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
setCodeFoldingSupported(true);
|
setCodeFoldingSupported(true);
|
||||||
|
|
||||||
new PythonHighlighter(textDocument());
|
new PythonHighlighter(doc.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditor::BaseTextEditor *PythonEditorWidget::createEditor()
|
TextEditor::BaseTextEditor *PythonEditorWidget::createEditor()
|
||||||
|
@@ -40,15 +40,10 @@ class PythonEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PythonEditorWidget(TextEditor::BaseTextDocument *doc, QWidget *parent);
|
PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc);
|
||||||
PythonEditorWidget(PythonEditorWidget *other);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
|
|
||||||
private:
|
|
||||||
PythonEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
|
||||||
void ctor();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -64,8 +64,8 @@ ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
|
|||||||
|
|
||||||
Core::IEditor *ProFileEditor::duplicate()
|
Core::IEditor *ProFileEditor::duplicate()
|
||||||
{
|
{
|
||||||
ProFileEditorWidget *ret = new ProFileEditorWidget(
|
ProFileEditorWidget *ret = new ProFileEditorWidget;
|
||||||
qobject_cast<ProFileEditorWidget*>(editorWidget()));
|
ret->setTextDocument(editorWidget()->textDocumentPtr());
|
||||||
TextEditor::TextEditorSettings::initializeEditor(ret);
|
TextEditor::TextEditorSettings::initializeEditor(ret);
|
||||||
return ret->editor();
|
return ret->editor();
|
||||||
}
|
}
|
||||||
@@ -74,12 +74,7 @@ Core::IEditor *ProFileEditor::duplicate()
|
|||||||
// ProFileEditorWidget
|
// ProFileEditorWidget
|
||||||
//
|
//
|
||||||
|
|
||||||
ProFileEditorWidget::ProFileEditorWidget(QWidget *parent)
|
ProFileEditorWidget::ProFileEditorWidget()
|
||||||
: BaseTextEditorWidget(new ProFileDocument(), parent)
|
|
||||||
{}
|
|
||||||
|
|
||||||
ProFileEditorWidget::ProFileEditorWidget(ProFileEditorWidget *other)
|
|
||||||
: BaseTextEditorWidget(other)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
static bool isValidFileNameChar(const QChar &c)
|
static bool isValidFileNameChar(const QChar &c)
|
||||||
|
@@ -55,17 +55,13 @@ class ProFileEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProFileEditorWidget(QWidget *parent = 0);
|
ProFileEditorWidget();
|
||||||
ProFileEditorWidget(ProFileEditorWidget *other);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual Link findLinkAt(const QTextCursor &, bool resolveTarget = true,
|
virtual Link findLinkAt(const QTextCursor &, bool resolveTarget = true,
|
||||||
bool inNextSplit = false);
|
bool inNextSplit = false);
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
void contextMenuEvent(QContextMenuEvent *);
|
void contextMenuEvent(QContextMenuEvent *);
|
||||||
|
|
||||||
private:
|
|
||||||
ProFileEditorWidget(BaseTextEditorWidget *); // avoid stupidity
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProFileDocument : public TextEditor::BaseTextDocument
|
class ProFileDocument : public TextEditor::BaseTextDocument
|
||||||
|
@@ -66,6 +66,7 @@ ProFileEditorFactory::ProFileEditorFactory(QmakeManager *manager) :
|
|||||||
Core::IEditor *ProFileEditorFactory::createEditor()
|
Core::IEditor *ProFileEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
ProFileEditorWidget *editor = new ProFileEditorWidget;
|
ProFileEditorWidget *editor = new ProFileEditorWidget;
|
||||||
|
editor->setTextDocument(TextEditor::BaseTextDocumentPtr(new ProFileDocument));
|
||||||
TextEditor::TextEditorSettings::initializeEditor(editor);
|
TextEditor::TextEditorSettings::initializeEditor(editor);
|
||||||
return editor->editor();
|
return editor->editor();
|
||||||
}
|
}
|
||||||
|
@@ -97,21 +97,12 @@ using namespace QmlJSTools;
|
|||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlJSTextEditorWidget::QmlJSTextEditorWidget(QWidget *parent) :
|
QmlJSTextEditorWidget::QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
||||||
TextEditor::BaseTextEditorWidget(new QmlJSEditorDocument, parent)
|
: TextEditor::BaseTextEditorWidget(0)
|
||||||
{
|
{
|
||||||
ctor();
|
setTextDocument(doc);
|
||||||
}
|
|
||||||
|
|
||||||
QmlJSTextEditorWidget::QmlJSTextEditorWidget(QmlJSTextEditorWidget *other)
|
m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(doc.data());
|
||||||
: TextEditor::BaseTextEditorWidget(other)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlJSTextEditorWidget::ctor()
|
|
||||||
{
|
|
||||||
m_qmlJsEditorDocument = static_cast<QmlJSEditorDocument *>(textDocument());
|
|
||||||
m_outlineCombo = 0;
|
m_outlineCombo = 0;
|
||||||
m_contextPane = 0;
|
m_contextPane = 0;
|
||||||
m_findReferences = new FindReferences(this);
|
m_findReferences = new FindReferences(this);
|
||||||
@@ -177,8 +168,7 @@ QModelIndex QmlJSTextEditorWidget::outlineModelIndex()
|
|||||||
|
|
||||||
IEditor *QmlJSEditor::duplicate()
|
IEditor *QmlJSEditor::duplicate()
|
||||||
{
|
{
|
||||||
QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget(
|
QmlJSTextEditorWidget *newEditor = new QmlJSTextEditorWidget(editorWidget()->textDocumentPtr());
|
||||||
qobject_cast<QmlJSTextEditorWidget *>(editorWidget()));
|
|
||||||
TextEditor::TextEditorSettings::initializeEditor(newEditor);
|
TextEditor::TextEditorSettings::initializeEditor(newEditor);
|
||||||
return newEditor->editor();
|
return newEditor->editor();
|
||||||
}
|
}
|
||||||
|
@@ -74,8 +74,7 @@ class QmlJSTextEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlJSTextEditorWidget(QWidget *parent = 0);
|
QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr doc);
|
||||||
QmlJSTextEditorWidget(QmlJSTextEditorWidget *other);
|
|
||||||
~QmlJSTextEditorWidget();
|
~QmlJSTextEditorWidget();
|
||||||
|
|
||||||
QmlJSEditorDocument *qmlJsEditorDocument() const;
|
QmlJSEditorDocument *qmlJsEditorDocument() const;
|
||||||
@@ -124,8 +123,6 @@ protected:
|
|||||||
QString foldReplacementText(const QTextBlock &block) const;
|
QString foldReplacementText(const QTextBlock &block) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlJSTextEditorWidget(TextEditor::BaseTextEditorWidget *); // avoid stupidity
|
|
||||||
void ctor();
|
|
||||||
bool isClosingBrace(const QList<QmlJS::Token> &tokens) const;
|
bool isClosingBrace(const QList<QmlJS::Token> &tokens) const;
|
||||||
|
|
||||||
void setSelectedElements();
|
void setSelectedElements();
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qmljseditorfactory.h"
|
#include "qmljseditorfactory.h"
|
||||||
|
#include "qmljseditordocument.h"
|
||||||
#include "qmljseditoreditable.h"
|
#include "qmljseditoreditable.h"
|
||||||
#include "qmljseditor.h"
|
#include "qmljseditor.h"
|
||||||
#include "qmljseditorconstants.h"
|
#include "qmljseditorconstants.h"
|
||||||
@@ -64,7 +65,7 @@ QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
|
|||||||
|
|
||||||
Core::IEditor *QmlJSEditorFactory::createEditor()
|
Core::IEditor *QmlJSEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget();
|
QmlJSTextEditorWidget *rc = new QmlJSTextEditorWidget(TextEditor::BaseTextDocumentPtr(new QmlJSEditorDocument));
|
||||||
TextEditor::TextEditorSettings::initializeEditor(rc);
|
TextEditor::TextEditorSettings::initializeEditor(rc);
|
||||||
return rc->editor();
|
return rc->editor();
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
#include <texteditor/normalindenter.h>
|
#include <texteditor/normalindenter.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace TextEditor;
|
||||||
using namespace Qnx;
|
using namespace Qnx;
|
||||||
using namespace Qnx::Internal;
|
using namespace Qnx::Internal;
|
||||||
|
|
||||||
@@ -168,11 +169,12 @@ void BarDescriptorEditorWidget::initAssetsPage()
|
|||||||
|
|
||||||
void BarDescriptorEditorWidget::initSourcePage()
|
void BarDescriptorEditorWidget::initSourcePage()
|
||||||
{
|
{
|
||||||
auto doc = new TextEditor::BaseTextDocument;
|
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||||
doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); // FIXME: This looks odd.
|
doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); // FIXME: This looks odd.
|
||||||
doc->setIndenter(new TextEditor::NormalIndenter);
|
doc->setIndenter(new TextEditor::NormalIndenter);
|
||||||
|
|
||||||
m_xmlSourceWidget = new TextEditor::BaseTextEditorWidget(doc, this);
|
m_xmlSourceWidget = new TextEditor::BaseTextEditorWidget(this);
|
||||||
|
m_xmlSourceWidget->setTextDocument(doc);
|
||||||
m_xmlSourceWidget->setupAsPlainEditor();
|
m_xmlSourceWidget->setupAsPlainEditor();
|
||||||
addWidget(m_xmlSourceWidget);
|
addWidget(m_xmlSourceWidget);
|
||||||
|
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QTextCursor;
|
class QTextCursor;
|
||||||
@@ -147,6 +148,8 @@ private:
|
|||||||
BaseTextDocumentPrivate *d;
|
BaseTextDocumentPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef QSharedPointer<BaseTextDocument> BaseTextDocumentPtr;
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
#endif // BASETEXTDOCUMENT_H
|
#endif // BASETEXTDOCUMENT_H
|
||||||
|
@@ -566,17 +566,15 @@ QString BaseTextEditorWidget::convertToPlainText(const QString &txt)
|
|||||||
|
|
||||||
static const char kTextBlockMimeType[] = "application/vnd.qtcreator.blocktext";
|
static const char kTextBlockMimeType[] = "application/vnd.qtcreator.blocktext";
|
||||||
|
|
||||||
BaseTextEditorWidget::BaseTextEditorWidget(BaseTextDocument *doc, QWidget *parent)
|
BaseTextEditorWidget::BaseTextEditorWidget(QWidget *parent)
|
||||||
: QPlainTextEdit(parent)
|
: QPlainTextEdit(parent)
|
||||||
{
|
{
|
||||||
d = new BaseTextEditorWidgetPrivate(this);
|
d = new BaseTextEditorWidgetPrivate(this);
|
||||||
d->ctor(QSharedPointer<BaseTextDocument>(doc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseTextEditorWidget::BaseTextEditorWidget(BaseTextEditorWidget *other)
|
void BaseTextEditorWidget::setTextDocument(const QSharedPointer<BaseTextDocument> &doc)
|
||||||
{
|
{
|
||||||
d = new BaseTextEditorWidgetPrivate(this);
|
d->ctor(doc);
|
||||||
d->ctor(other->d->m_document);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidgetPrivate::ctor(const QSharedPointer<BaseTextDocument> &doc)
|
void BaseTextEditorWidgetPrivate::ctor(const QSharedPointer<BaseTextDocument> &doc)
|
||||||
@@ -1000,6 +998,11 @@ BaseTextDocument *BaseTextEditorWidget::textDocument() const
|
|||||||
return d->m_document.data();
|
return d->m_document.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseTextDocumentPtr BaseTextEditorWidget::textDocumentPtr() const
|
||||||
|
{
|
||||||
|
return d->m_document;
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidgetPrivate::editorContentsChange(int position, int charsRemoved, int charsAdded)
|
void BaseTextEditorWidgetPrivate::editorContentsChange(int position, int charsRemoved, int charsAdded)
|
||||||
{
|
{
|
||||||
if (m_animator)
|
if (m_animator)
|
||||||
@@ -2806,7 +2809,7 @@ AutoCompleter *BaseTextEditor::autoCompleter() const
|
|||||||
void BaseTextEditorWidgetPrivate::setupDocumentSignals()
|
void BaseTextEditorWidgetPrivate::setupDocumentSignals()
|
||||||
{
|
{
|
||||||
QTextDocument *doc = m_document->document();
|
QTextDocument *doc = m_document->document();
|
||||||
q->setDocument(doc);
|
q->QPlainTextEdit::setDocument(doc);
|
||||||
q->setCursorWidth(2); // Applies to the document layout
|
q->setCursorWidth(2); // Applies to the document layout
|
||||||
|
|
||||||
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(doc->documentLayout());
|
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(doc->documentLayout());
|
||||||
@@ -7096,7 +7099,8 @@ void BaseTextEditorWidget::setupAsPlainEditor()
|
|||||||
|
|
||||||
IEditor *BaseTextEditor::duplicate()
|
IEditor *BaseTextEditor::duplicate()
|
||||||
{
|
{
|
||||||
auto newWidget = new BaseTextEditorWidget(editorWidget());
|
auto newWidget = new BaseTextEditorWidget(0);
|
||||||
|
newWidget->setTextDocument(editorWidget()->textDocumentPtr());
|
||||||
newWidget->setupAsPlainEditor();
|
newWidget->setupAsPlainEditor();
|
||||||
TextEditorSettings::initializeEditor(newWidget);
|
TextEditorSettings::initializeEditor(newWidget);
|
||||||
auto editor = newWidget->editor();
|
auto editor = newWidget->editor();
|
||||||
|
@@ -212,11 +212,13 @@ class TEXTEDITOR_EXPORT BaseTextEditorWidget : public QPlainTextEdit
|
|||||||
Q_PROPERTY(int verticalBlockSelectionLastColumn READ verticalBlockSelectionLastColumn)
|
Q_PROPERTY(int verticalBlockSelectionLastColumn READ verticalBlockSelectionLastColumn)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseTextEditorWidget(BaseTextDocument *doc, QWidget *parent);
|
BaseTextEditorWidget(QWidget *parent = 0);
|
||||||
BaseTextEditorWidget(BaseTextEditorWidget *other);
|
|
||||||
~BaseTextEditorWidget();
|
~BaseTextEditorWidget();
|
||||||
|
|
||||||
|
void setTextDocument(const BaseTextDocumentPtr &doc);
|
||||||
|
|
||||||
BaseTextDocument *textDocument() const;
|
BaseTextDocument *textDocument() const;
|
||||||
|
BaseTextDocumentPtr textDocumentPtr() const;
|
||||||
|
|
||||||
// IEditor
|
// IEditor
|
||||||
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
|
@@ -61,10 +61,11 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
|
|||||||
|
|
||||||
Core::IEditor *PlainTextEditorFactory::createEditor()
|
Core::IEditor *PlainTextEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
auto doc = new BaseTextDocument;
|
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||||
doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||||
doc->setIndenter(new NormalIndenter);
|
doc->setIndenter(new NormalIndenter);
|
||||||
auto widget = new BaseTextEditorWidget(doc, 0);
|
auto widget = new BaseTextEditorWidget(0);
|
||||||
|
widget->setTextDocument(doc);
|
||||||
widget->setupAsPlainEditor();
|
widget->setupAsPlainEditor();
|
||||||
TextEditorSettings::initializeEditor(widget);
|
TextEditorSettings::initializeEditor(widget);
|
||||||
connect(widget, SIGNAL(configured(Core::IEditor*)),
|
connect(widget, SIGNAL(configured(Core::IEditor*)),
|
||||||
|
@@ -50,9 +50,11 @@ SnippetEditor::SnippetEditor(SnippetEditorWidget *editor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SnippetEditorWidget::SnippetEditorWidget(QWidget *parent)
|
SnippetEditorWidget::SnippetEditorWidget(QWidget *parent)
|
||||||
: BaseTextEditorWidget(new BaseTextDocument, parent)
|
: BaseTextEditorWidget(parent)
|
||||||
{
|
{
|
||||||
textDocument()->setId(Constants::SNIPPET_EDITOR_ID);
|
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||||
|
doc->setId(Constants::SNIPPET_EDITOR_ID);
|
||||||
|
setTextDocument(doc);
|
||||||
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
||||||
setHighlightCurrentLine(false);
|
setHighlightCurrentLine(false);
|
||||||
setLineNumbersVisible(false);
|
setLineNumbersVisible(false);
|
||||||
|
@@ -90,6 +90,8 @@
|
|||||||
\sa VcsBase::VcsBaseEditorWidget
|
\sa VcsBase::VcsBaseEditorWidget
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using namespace TextEditor;
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -649,12 +651,14 @@ QComboBox *VcsBaseEditorWidgetPrivate::entriesComboBox()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
VcsBaseEditorWidget::VcsBaseEditorWidget(const VcsBaseEditorParameters *type, QWidget *parent)
|
VcsBaseEditorWidget::VcsBaseEditorWidget(const VcsBaseEditorParameters *type, QWidget *parent)
|
||||||
: BaseTextEditorWidget(new TextEditor::BaseTextDocument, parent),
|
: BaseTextEditorWidget(parent),
|
||||||
d(new Internal::VcsBaseEditorWidgetPrivate(this, type))
|
d(new Internal::VcsBaseEditorWidgetPrivate(this, type))
|
||||||
{
|
{
|
||||||
|
BaseTextDocumentPtr doc(new BaseTextDocument);
|
||||||
|
doc->setId(type->id);
|
||||||
|
doc->setMimeType(QLatin1String(d->m_parameters->mimeType));
|
||||||
|
setTextDocument(doc);
|
||||||
viewport()->setMouseTracking(true);
|
viewport()->setMouseTracking(true);
|
||||||
textDocument()->setId(type->id);
|
|
||||||
textDocument()->setMimeType(QLatin1String(d->m_parameters->mimeType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsBaseEditorWidget::setDiffFilePattern(const QRegExp &pattern)
|
void VcsBaseEditorWidget::setDiffFilePattern(const QRegExp &pattern)
|
||||||
|
Reference in New Issue
Block a user