forked from qt-creator/qt-creator
TextEditors: Remove useless duplicated (set)textCodec methods
They are duplicated from TextDocument::(set)codec. The default implementation of the duplicated methods was just delegating to the text document. The override of setTextCodec in QmlJsEditor was useless, since it was only called from EditorConfiguration::configureEditor with the ITextEditor::TextCodecFromProjectSetting flag anyhow, which made the overridden method in QmlJsEditor be the same as the fallback. Aside from that, the duplicated methods wouldn't have belonged to the *editor* anyhow, but to the document. Change-Id: Ib43c28210b6bf88726159d751a4905a1d062f80e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -237,7 +237,7 @@ void EditorConfiguration::configureEditor(ITextEditor *textEditor) const
|
|||||||
if (baseTextEditor)
|
if (baseTextEditor)
|
||||||
baseTextEditor->setCodeStyle(codeStyle(baseTextEditor->languageSettingsId()));
|
baseTextEditor->setCodeStyle(codeStyle(baseTextEditor->languageSettingsId()));
|
||||||
if (!d->m_useGlobal) {
|
if (!d->m_useGlobal) {
|
||||||
textEditor->setTextCodec(d->m_textCodec, ITextEditor::TextCodecFromProjectSetting);
|
textEditor->textDocument()->setCodec(d->m_textCodec);
|
||||||
if (baseTextEditor)
|
if (baseTextEditor)
|
||||||
switchSettings(baseTextEditor);
|
switchSettings(baseTextEditor);
|
||||||
}
|
}
|
||||||
|
@@ -60,13 +60,6 @@ bool QmlJSEditor::isDesignModePreferred() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditor::setTextCodec(QTextCodec *codec, TextCodecReason reason)
|
|
||||||
{
|
|
||||||
if (reason != TextCodecOtherReason) // qml is defined to be utf8
|
|
||||||
return;
|
|
||||||
editorWidget()->setTextCodec(codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Utils::CommentDefinition *QmlJSEditor::commentDefinition() const
|
const Utils::CommentDefinition *QmlJSEditor::commentDefinition() const
|
||||||
{
|
{
|
||||||
return &m_commentDefinition;
|
return &m_commentDefinition;
|
||||||
|
@@ -49,7 +49,6 @@ public:
|
|||||||
Core::Id id() const;
|
Core::Id id() const;
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
bool isDesignModePreferred() const;
|
bool isDesignModePreferred() const;
|
||||||
void setTextCodec(QTextCodec *codec, TextCodecReason = TextCodecOtherReason);
|
|
||||||
|
|
||||||
const Utils::CommentDefinition *commentDefinition() const;
|
const Utils::CommentDefinition *commentDefinition() const;
|
||||||
private:
|
private:
|
||||||
|
@@ -5837,17 +5837,6 @@ void BaseTextEditorWidget::unfoldAll()
|
|||||||
centerCursor();
|
centerCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditorWidget::setTextCodec(QTextCodec *codec)
|
|
||||||
{
|
|
||||||
baseTextDocument()->setCodec(codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextCodec *BaseTextEditorWidget::textCodec() const
|
|
||||||
{
|
|
||||||
// TODO: Fix all QTextCodec usages to be const *.
|
|
||||||
return const_cast<QTextCodec *>(baseTextDocument()->codec());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BaseTextEditorWidget::setReadOnly(bool b)
|
void BaseTextEditorWidget::setReadOnly(bool b)
|
||||||
{
|
{
|
||||||
QPlainTextEdit::setReadOnly(b);
|
QPlainTextEdit::setReadOnly(b);
|
||||||
|
@@ -211,9 +211,6 @@ public:
|
|||||||
void setActionHack(QObject *hack);
|
void setActionHack(QObject *hack);
|
||||||
QObject *actionHack() const;
|
QObject *actionHack() const;
|
||||||
|
|
||||||
void setTextCodec(QTextCodec *codec);
|
|
||||||
QTextCodec *textCodec() const;
|
|
||||||
|
|
||||||
void setReadOnly(bool b);
|
void setReadOnly(bool b);
|
||||||
|
|
||||||
void setTextCursor(const QTextCursor &cursor);
|
void setTextCursor(const QTextCursor &cursor);
|
||||||
@@ -640,9 +637,6 @@ public:
|
|||||||
|
|
||||||
QString contextHelpId() const; // from IContext
|
QString contextHelpId() const; // from IContext
|
||||||
|
|
||||||
void setTextCodec(QTextCodec *codec, TextCodecReason = TextCodecOtherReason) { m_editorWidget->setTextCodec(codec); }
|
|
||||||
QTextCodec *textCodec() const { return m_editorWidget->textCodec(); }
|
|
||||||
|
|
||||||
// ITextEditor
|
// ITextEditor
|
||||||
void remove(int length);
|
void remove(int length);
|
||||||
void insert(const QString &string);
|
void insert(const QString &string);
|
||||||
|
@@ -59,7 +59,7 @@ QMap<QString, QTextCodec *> TextEditor::ITextEditor::openedTextEditorsEncodings(
|
|||||||
if (!textEditor)
|
if (!textEditor)
|
||||||
continue;
|
continue;
|
||||||
QString fileName = textEditor->document()->filePath();
|
QString fileName = textEditor->document()->filePath();
|
||||||
workingCopy[fileName] = textEditor->textCodec();
|
workingCopy[fileName] = const_cast<QTextCodec *>(textEditor->textDocument()->codec());
|
||||||
}
|
}
|
||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
@@ -109,15 +109,6 @@ public:
|
|||||||
|
|
||||||
virtual ITextMarkable *markableInterface() = 0;
|
virtual ITextMarkable *markableInterface() = 0;
|
||||||
|
|
||||||
enum TextCodecReason {
|
|
||||||
TextCodecOtherReason,
|
|
||||||
TextCodecFromSystemSetting,
|
|
||||||
TextCodecFromProjectSetting
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void setTextCodec(QTextCodec *, TextCodecReason reason = TextCodecOtherReason) = 0;
|
|
||||||
virtual QTextCodec *textCodec() const = 0;
|
|
||||||
|
|
||||||
virtual const Utils::CommentDefinition* commentDefinition() const = 0;
|
virtual const Utils::CommentDefinition* commentDefinition() const = 0;
|
||||||
|
|
||||||
static QMap<QString, QString> openedTextEditorsContents();
|
static QMap<QString, QString> openedTextEditorsContents();
|
||||||
|
@@ -1164,7 +1164,7 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const
|
|||||||
unicode += QLatin1Char('\n');
|
unicode += QLatin1Char('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const QTextCodec *cd = textCodec();
|
const QTextCodec *cd = baseTextDocument()->codec();
|
||||||
rc.chunk = cd ? cd->fromUnicode(unicode) : unicode.toLocal8Bit();
|
rc.chunk = cd ? cd->fromUnicode(unicode) : unicode.toLocal8Bit();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1232,8 +1232,8 @@ static QTextCodec *findFileCodec(const QString &source)
|
|||||||
if (!editors.empty()) {
|
if (!editors.empty()) {
|
||||||
const EditorList::const_iterator ecend = editors.constEnd();
|
const EditorList::const_iterator ecend = editors.constEnd();
|
||||||
for (EditorList::const_iterator it = editors.constBegin(); it != ecend; ++it)
|
for (EditorList::const_iterator it = editors.constBegin(); it != ecend; ++it)
|
||||||
if (const TextEditor::BaseTextEditor *be = qobject_cast<const TextEditor::BaseTextEditor *>(*it)) {
|
if (TextEditor::BaseTextEditor *be = qobject_cast<TextEditor::BaseTextEditor *>(*it)) {
|
||||||
QTextCodec *codec = be->editorWidget()->textCodec();
|
QTextCodec *codec = const_cast<QTextCodec *>(be->textDocument()->codec());
|
||||||
return codec;
|
return codec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user