Commit 1924fdb9 authored by hjk's avatar hjk

TextEditor: Merge PlainTextEditor into Base

Same patter. Plain is fully merged now, so remove the files, too.

Change-Id: Id8c0ba5689ad9980a0db3580cb9833344fd911f3
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 068462e5
......@@ -48,7 +48,7 @@
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/plaintexteditor.h>
#include <texteditor/basetexteditor.h>
#include <utils/algorithm.h>
#include <QLineEdit>
......
......@@ -31,7 +31,6 @@
#define ANDROIDMANIFESTEDITORWIDGET_H
#include <texteditor/basetexteditor.h>
#include <texteditor/plaintexteditor.h>
#include <QAbstractListModel>
#include <QStackedWidget>
......
......@@ -37,7 +37,7 @@
#include <cpptools/cppcompletionassist.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/plaintexteditor.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/codeassist/iassistproposal.h>
#include <texteditor/codeassist/iassistproposalmodel.h>
#include <texteditor/codeassist/basicproposalitemlistmodel.h>
......
......@@ -34,7 +34,7 @@
#include <texteditor/codeassist/iassistproposal.h>
#include <texteditor/convenience.h>
#include <texteditor/plaintexteditor.h>
#include <texteditor/basetexteditor.h>
#include <utils/changeset.h>
#include <utils/fileutils.h>
......
......@@ -32,7 +32,7 @@
#include "formwindowfile.h"
#include <texteditor/plaintexteditor.h>
#include <texteditor/basetexteditor.h>
#include <QSharedPointer>
......
......@@ -51,10 +51,11 @@ struct FormWindowEditorPrivate
};
FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditorWidget *editor) :
TextEditor::PlainTextEditor(editor),
TextEditor::BaseTextEditor(editor),
d(new FormWindowEditorPrivate)
{
d->m_widget = editor;
setDuplicateSupported(true);
setContext(Core::Context(Designer::Constants::K_DESIGNER_XML_EDITOR_ID,
Designer::Constants::C_DESIGNER_XML_EDITOR));
......
......@@ -32,27 +32,25 @@
#include "designer_export.h"
#include <coreplugin/editormanager/ieditor.h>
#include <texteditor/plaintexteditor.h>
#include <texteditor/basetexteditor.h>
QT_BEGIN_NAMESPACE
class QDesignerFormWindowInterface;
QT_END_NAMESPACE
namespace TextEditor { class PlainTextEditor; }
namespace Designer {
namespace Internal { class DesignerXmlEditorWidget; }
struct FormWindowEditorPrivate;
// IEditor that is used for the QDesignerFormWindowInterface
// It is a read-only PlainTextEditor that shows the XML of the form.
// DesignerXmlEditorWidget is the corresponding PlainTextEditorWidget,
// It is a read-only text editor that shows the XML of the form.
// DesignerXmlEditorWidget is the corresponding BaseTextEditorWidget,
// FormWindowFile the corresponding BaseTextDocument.
// The content from the QDesignerFormWindowInterface is synced to the
// content of the XML editor.
class DESIGNER_EXPORT FormWindowEditor : public TextEditor::PlainTextEditor
class DESIGNER_EXPORT FormWindowEditor : public TextEditor::BaseTextEditor
{
Q_PROPERTY(QString contents READ contents)
Q_OBJECT
......
......@@ -48,7 +48,7 @@
#include "circularclipboard.h"
#include "circularclipboardassist.h"
#include "highlighterutils.h"
#include "plaintexteditor.h"
#include "basetexteditor.h"
#include <texteditor/codeassist/codeassistant.h>
#include <texteditor/codeassist/defaultassistinterface.h>
#include <texteditor/generichighlighter/context.h>
......@@ -115,10 +115,15 @@
/*!
\class TextEditor::BaseTextEditor
\brief The BaseTextEditor class is a base class for QPlainTextEdit-based text editors.
\brief The BaseTextEditor class is base implementation for QPlainTextEdit-based
text editors. It can use the Kate text highlighting definitions, and some basic
auto indentation.
The corresponding document base class is BaseTextDocument, the corresponding
widget base class is BaseTextEditorWidget.
The corresponding document base class is BaseTextDocument, the corresponding widget base class
is BaseTextEditorWidget.
It is the default editor for text files used by \QC, if no other editor
implementation matches the MIME type.
*/
......@@ -6367,7 +6372,11 @@ QColor BaseTextEditorWidget::replacementPenColor(int blockNumber) const
BaseTextEditor *BaseTextEditorWidget::createEditor()
{
return new PlainTextEditor(this);
auto editor = new BaseTextEditor(this);
editor->setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
editor->setDuplicateSupported(true);
return editor;
}
void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
......@@ -7021,6 +7030,17 @@ void BaseTextEditorWidget::setupAsPlainEditor()
connect(Manager::instance(), SIGNAL(mimeTypesRegistered()), this, SLOT(configureMimeType()));
}
IEditor *BaseTextEditor::duplicate()
{
auto newWidget = new BaseTextEditorWidget(editorWidget());
newWidget->setupAsPlainEditor();
TextEditorSettings::initializeEditor(newWidget);
auto editor = newWidget->editor();
editor->setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
editor->setDuplicateSupported(true);
return editor;
}
} // namespace TextEditor
......
......@@ -140,6 +140,8 @@ public:
Core::IDocument *document();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
IEditor *duplicate();
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
QWidget *toolBar();
......
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "plaintexteditor.h"
#include "tabsettings.h"
#include "texteditorplugin.h"
#include "texteditorsettings.h"
#include "basetextdocument.h"
#include "normalindenter.h"
#include "highlighterutils.h"
#include <texteditor/generichighlighter/context.h>
#include <texteditor/generichighlighter/highlightdefinition.h>
#include <texteditor/generichighlighter/highlighter.h>
#include <texteditor/generichighlighter/highlightersettings.h>
#include <texteditor/generichighlighter/manager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
using namespace Core;
using namespace TextEditor::Internal;
/*!
\class TextEditor::PlainTextEditor
\brief The PlainTextEditor class is a text editor implementation that adds highlighting
by using the Kate text highlighting definitions, and some basic auto indentation.
It is the default editor for text files used by \QC, if no other editor implementation
matches the MIME type. The corresponding document is implemented in PlainTextDocument,
the corresponding widget is implemented in PlainTextEditorWidget.
*/
namespace TextEditor {
PlainTextEditor::PlainTextEditor(BaseTextEditorWidget *editor)
: BaseTextEditor(editor)
{
setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
setDuplicateSupported(true);
}
IEditor *PlainTextEditor::duplicate()
{
auto newWidget = new BaseTextEditorWidget(editorWidget());
newWidget->setupAsPlainEditor();
TextEditorSettings::initializeEditor(newWidget);
return newWidget->editor();
}
} // namespace TextEditor
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef PLAINTEXTEDITOR_H
#define PLAINTEXTEDITOR_H
#include "basetexteditor.h"
namespace TextEditor {
class TEXTEDITOR_EXPORT PlainTextEditor : public BaseTextEditor
{
Q_OBJECT
public:
PlainTextEditor(BaseTextEditorWidget *);
Core::IEditor *duplicate();
};
} // namespace TextEditor
#endif // PLAINTEXTEDITOR_H
......@@ -28,7 +28,7 @@
****************************************************************************/
#include "plaintexteditorfactory.h"
#include "plaintexteditor.h"
#include "basetexteditor.h"
#include "basetextdocument.h"
#include "normalindenter.h"
#include "texteditoractionhandler.h"
......@@ -80,15 +80,15 @@ Core::IEditor *PlainTextEditorFactory::createEditor()
*/
void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
{
PlainTextEditor *editorEditable = qobject_cast<PlainTextEditor *>(editor);
if (editorEditable) {
BaseTextDocument *file = qobject_cast<BaseTextDocument *>(editor->document());
BaseTextEditor *textEditor = qobject_cast<BaseTextEditor *>(editor);
if (textEditor) {
Core::IDocument *file = editor->document();
if (!file)
return;
BaseTextEditorWidget *textEditor = editorEditable->editorWidget();
BaseTextEditorWidget *widget = textEditor->editorWidget();
Core::Id infoSyntaxDefinition(Constants::INFO_SYNTAX_DEFINITION);
Core::InfoBar *infoBar = file->infoBar();
if (!textEditor->isMissingSyntaxDefinition()) {
if (!widget->isMissingSyntaxDefinition()) {
infoBar->removeInfo(infoSyntaxDefinition);
} else if (infoBar->canInfoBeAdded(infoSyntaxDefinition)) {
Core::InfoBarEntry info(infoSyntaxDefinition,
......@@ -96,7 +96,7 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
"Would you like to try to find one?"),
Core::InfoBarEntry::GlobalSuppressionEnabled);
info.setCustomButtonInfo(tr("Show Highlighter Options..."),
textEditor, SLOT(acceptMissingSyntaxDefinitionInfo()));
widget, SLOT(acceptMissingSyntaxDefinitionInfo()));
infoBar->addInfo(info);
}
}
......
......@@ -6,7 +6,6 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
include(../../qtcreatorplugin.pri)
SOURCES += texteditorplugin.cpp \
textfilewizard.cpp \
plaintexteditor.cpp \
plaintexteditorfactory.cpp \
basetextdocument.cpp \
basetexteditor.cpp \
......@@ -110,7 +109,6 @@ SOURCES += texteditorplugin.cpp \
HEADERS += texteditorplugin.h \
textfilewizard.h \
plaintexteditor.h \
plaintexteditorfactory.h \
basetexteditor_p.h \
basetextdocument.h \
......
......@@ -96,8 +96,6 @@ QtcPlugin {
"normalindenter.h",
"outlinefactory.cpp",
"outlinefactory.h",
"plaintexteditor.cpp",
"plaintexteditor.h",
"plaintexteditorfactory.cpp",
"plaintexteditorfactory.h",
"quickfix.cpp",
......
......@@ -37,7 +37,7 @@
#include "texteditorsettings.h"
#include "textfilewizard.h"
#include "plaintexteditorfactory.h"
#include "plaintexteditor.h"
#include "basetexteditor.h"
#include "outlinefactory.h"
#include "snippets/plaintextsnippetprovider.h"
#include "textmarkregistry.h"
......
......@@ -37,7 +37,6 @@ namespace Core { class SearchResultWindow; }
namespace TextEditor {
class FontSettings;
class PlainTextEditorWidget;
class TextEditorSettings;
namespace Internal {
......
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