forked from qt-creator/qt-creator
Editor: use forked plaintextedit
Change-Id: I43f3b356d24d4e45e80ed9d25768f9eb805b436e Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -474,7 +474,7 @@ void CppEditorWidget::finalizeInitialization()
|
||||
});
|
||||
connect(&d->m_localRenaming, &CppLocalRenaming::processKeyPressNormally,
|
||||
this, &CppEditorWidget::processKeyNormally);
|
||||
connect(this, &QPlainTextEdit::cursorPositionChanged, this, [this] {
|
||||
connect(this, &PlainTextEdit::cursorPositionChanged, this, [this] {
|
||||
if (d->m_cppEditorOutline)
|
||||
d->m_cppEditorOutline->updateIndex();
|
||||
});
|
||||
@@ -489,8 +489,8 @@ void CppEditorWidget::finalizeInitialization()
|
||||
d->m_updateFunctionDeclDefLinkTimer.setInterval(UPDATE_FUNCTION_DECL_DEF_LINK_INTERVAL);
|
||||
connect(&d->m_updateFunctionDeclDefLinkTimer, &QTimer::timeout,
|
||||
this, &CppEditorWidget::updateFunctionDeclDefLinkNow);
|
||||
connect(this, &QPlainTextEdit::cursorPositionChanged, this, &CppEditorWidget::updateFunctionDeclDefLink);
|
||||
connect(this, &QPlainTextEdit::textChanged, this, &CppEditorWidget::updateFunctionDeclDefLink);
|
||||
connect(this, &PlainTextEdit::cursorPositionChanged, this, &CppEditorWidget::updateFunctionDeclDefLink);
|
||||
connect(this, &PlainTextEdit::textChanged, this, &CppEditorWidget::updateFunctionDeclDefLink);
|
||||
|
||||
// set up the use highlighitng
|
||||
connect(this, &CppEditorWidget::cursorPositionChanged, this, [this] {
|
||||
|
@@ -147,7 +147,7 @@ CppOutlineWidget::CppOutlineWidget(CppEditorWidget *editor) :
|
||||
|
||||
connect(m_treeView, &QAbstractItemView::activated,
|
||||
this, &CppOutlineWidget::onItemActivated);
|
||||
connect(editor, &QPlainTextEdit::cursorPositionChanged, this, [this] {
|
||||
connect(editor, &Utils::PlainTextEdit::cursorPositionChanged, this, [this] {
|
||||
if (m_model->rootItem()->hasChildren())
|
||||
updateIndex();
|
||||
});
|
||||
|
@@ -97,7 +97,7 @@ void SourceAgent::setContent(const QString &filePath, const QString &content)
|
||||
EditorManager::activateEditor(d->editor);
|
||||
}
|
||||
|
||||
QPlainTextEdit *plainTextEdit = d->editor->editorWidget();
|
||||
Utils::PlainTextEdit *plainTextEdit = d->editor->editorWidget();
|
||||
QTC_ASSERT(plainTextEdit, return);
|
||||
plainTextEdit->setReadOnly(true);
|
||||
|
||||
|
@@ -710,7 +710,7 @@ SideBySideDiffEditorWidget::SideBySideDiffEditorWidget(QWidget *parent)
|
||||
connect(m_editor[side]->horizontalScrollBar(), &QAbstractSlider::actionTriggered,
|
||||
this, std::bind(&SideBySideDiffEditorWidget::horizontalSliderChanged, this, side));
|
||||
|
||||
connect(m_editor[side], &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(m_editor[side], &PlainTextEdit::cursorPositionChanged,
|
||||
this, std::bind(&SideBySideDiffEditorWidget::cursorPositionChanged, this, side));
|
||||
|
||||
connect(m_editor[side]->horizontalScrollBar(), &QAbstractSlider::rangeChanged,
|
||||
|
@@ -40,7 +40,7 @@ UnifiedDiffEditorWidget::UnifiedDiffEditorWidget(QWidget *parent)
|
||||
|
||||
clear(Tr::tr("No document"));
|
||||
|
||||
connect(this, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(this, &PlainTextEdit::cursorPositionChanged,
|
||||
this, &UnifiedDiffEditorWidget::slotCursorPositionChangedInEditor);
|
||||
|
||||
IContext::attach(this, Context(Constants::UNIFIED_VIEW_ID));
|
||||
|
@@ -226,7 +226,7 @@ public:
|
||||
this, &RelativeNumbersColumn::followEditorLayout);
|
||||
|
||||
auto start = QOverload<>::of(&QTimer::start);
|
||||
connect(m_editor, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(m_editor, &PlainTextEdit::cursorPositionChanged,
|
||||
&m_timerUpdate, start);
|
||||
connect(m_editor->verticalScrollBar(), &QAbstractSlider::valueChanged,
|
||||
&m_timerUpdate, start);
|
||||
|
@@ -252,7 +252,7 @@ void InstantBlame::setup()
|
||||
}
|
||||
|
||||
qCInfo(log) << "Adding blame cursor connection";
|
||||
m_blameCursorPosConn = connect(widget, &QPlainTextEdit::cursorPositionChanged, this,
|
||||
m_blameCursorPosConn = connect(widget, &PlainTextEdit::cursorPositionChanged, this,
|
||||
[this] {
|
||||
if (!settings().instantBlame()) {
|
||||
disconnect(m_blameCursorPosConn);
|
||||
@@ -354,7 +354,7 @@ void InstantBlame::once()
|
||||
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
||||
this, [this] { m_blameMark.reset(); }, Qt::SingleShotConnection);
|
||||
|
||||
connect(widget, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(widget, &PlainTextEdit::cursorPositionChanged,
|
||||
this, [this] { m_blameMark.reset(); }, Qt::SingleShotConnection);
|
||||
|
||||
const FilePath workingDirectory = currentState().topLevel();
|
||||
|
@@ -252,7 +252,7 @@ GlslEditorWidget::GlslEditorWidget()
|
||||
connect(&m_updateDocumentTimer, &QTimer::timeout,
|
||||
this, &GlslEditorWidget::updateDocumentNow);
|
||||
|
||||
connect(this, &QPlainTextEdit::textChanged, [this] { m_updateDocumentTimer.start(); });
|
||||
connect(this, &PlainTextEdit::textChanged, [this] { m_updateDocumentTimer.start(); });
|
||||
|
||||
m_outlineCombo = new QComboBox;
|
||||
m_outlineCombo->setMinimumContentsLength(22);
|
||||
|
@@ -34,7 +34,7 @@ AbstractEditorDialog::AbstractEditorDialog(QWidget *parent, const QString &title
|
||||
this, &AbstractEditorDialog::rejected);
|
||||
QObject::connect(m_editorWidget, &BindingEditorWidget::returnKeyClicked,
|
||||
this, &AbstractEditorDialog::accepted);
|
||||
QObject::connect(m_editorWidget, &QPlainTextEdit::textChanged,
|
||||
QObject::connect(m_editorWidget, &Utils::PlainTextEdit::textChanged,
|
||||
this, &AbstractEditorDialog::textChanged);
|
||||
}
|
||||
|
||||
|
@@ -69,7 +69,7 @@ void TextEditorWidget::setTextEditor(
|
||||
|
||||
setFocusProxy(m_textEditor->editorWidget());
|
||||
|
||||
connect(m_textEditor->editorWidget(), &QPlainTextEdit::cursorPositionChanged, this, [this] {
|
||||
connect(m_textEditor->editorWidget(), &Utils::PlainTextEdit::cursorPositionChanged, this, [this] {
|
||||
// Cursor position is changed by rewriter
|
||||
if (!m_blockCursorSelectionSynchronisation)
|
||||
m_updateSelectionTimer.start();
|
||||
|
@@ -133,7 +133,7 @@ void QmlJSEditorWidget::finalizeInitialization()
|
||||
m_updateUsesTimer.setInterval(UPDATE_USES_DEFAULT_INTERVAL);
|
||||
m_updateUsesTimer.setSingleShot(true);
|
||||
connect(&m_updateUsesTimer, &QTimer::timeout, this, &QmlJSEditorWidget::updateUses);
|
||||
connect(this, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(this, &PlainTextEdit::cursorPositionChanged,
|
||||
&m_updateUsesTimer, QOverload<>::of(&QTimer::start));
|
||||
|
||||
m_updateOutlineIndexTimer.setInterval(UPDATE_OUTLINE_INTERVAL);
|
||||
|
@@ -136,7 +136,7 @@ static FormatOutput format(const FormatInput &input)
|
||||
* actually changed parts are updated while preserving the cursor position, the folded
|
||||
* blocks, and the scroll bar position.
|
||||
*/
|
||||
void updateEditorText(QPlainTextEdit *editor, const QString &text)
|
||||
void updateEditorText(PlainTextEdit *editor, const QString &text)
|
||||
{
|
||||
const QString editorText = editor->toPlainText();
|
||||
if (editorText == text)
|
||||
@@ -260,7 +260,7 @@ static void showError(const QString &error)
|
||||
* Checks the state of @a task and if the formatting was successful calls updateEditorText() with
|
||||
* the respective members of @a task.
|
||||
*/
|
||||
static void checkAndApplyTask(const QPointer<QPlainTextEdit> &textEditor, const FormatInput &input,
|
||||
static void checkAndApplyTask(const QPointer<PlainTextEdit> &textEditor, const FormatInput &input,
|
||||
const FormatOutput &output)
|
||||
{
|
||||
if (!output.has_value()) {
|
||||
@@ -318,7 +318,7 @@ void formatEditorAsync(TextEditorWidget *editor, const Command &command, int sta
|
||||
QObject::connect(doc, &TextDocument::contentsChanged, watcher,
|
||||
&QFutureWatcher<FormatOutput>::cancel);
|
||||
QObject::connect(watcher, &QFutureWatcherBase::finished, watcher,
|
||||
[watcher, editor = QPointer<QPlainTextEdit>(editor), input] {
|
||||
[watcher, editor = QPointer<PlainTextEdit>(editor), input] {
|
||||
if (watcher->isCanceled())
|
||||
showError(Tr::tr("File was modified."));
|
||||
else
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
namespace Utils { class PlainTextEdit; }
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
@@ -20,6 +20,6 @@ TEXTEDITOR_EXPORT void formatEditor(TextEditorWidget *editor, const TextEditor::
|
||||
int startPos = -1, int endPos = 0);
|
||||
TEXTEDITOR_EXPORT void formatEditorAsync(TextEditorWidget *editor, const TextEditor::Command &command,
|
||||
int startPos = -1, int endPos = 0);
|
||||
TEXTEDITOR_EXPORT void updateEditorText(QPlainTextEdit *editor, const QString &text);
|
||||
TEXTEDITOR_EXPORT void updateEditorText(Utils::PlainTextEdit *editor, const QString &text);
|
||||
|
||||
} // namespace TextEditor
|
||||
|
@@ -41,7 +41,7 @@ void SnippetEditorWidget::focusOutEvent(QFocusEvent *event)
|
||||
|
||||
void SnippetEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
QPlainTextEdit::contextMenuEvent(e);
|
||||
PlainTextEdit::contextMenuEvent(e);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@@ -1080,7 +1080,7 @@ void TextDocument::removeMarkFromMarksCache(TextMark *mark)
|
||||
auto scheduleLayoutUpdate = [documentLayout](){
|
||||
// make sure all destructors that may directly or indirectly call this function are
|
||||
// completed before updating.
|
||||
QMetaObject::invokeMethod(documentLayout, &QPlainTextDocumentLayout::requestUpdate,
|
||||
QMetaObject::invokeMethod(documentLayout, &PlainTextDocumentLayout::requestUpdate,
|
||||
Qt::QueuedConnection);
|
||||
};
|
||||
|
||||
|
@@ -348,7 +348,7 @@ void TextBlockUserData::addMark(TextMark *mark)
|
||||
}
|
||||
|
||||
TextDocumentLayout::TextDocumentLayout(QTextDocument *doc)
|
||||
: QPlainTextDocumentLayout(doc)
|
||||
: PlainTextDocumentLayout(doc)
|
||||
{}
|
||||
|
||||
TextDocumentLayout::~TextDocumentLayout()
|
||||
@@ -721,7 +721,7 @@ void TextDocumentLayout::setRequiredWidth(int width)
|
||||
{
|
||||
int oldw = m_requiredWidth;
|
||||
m_requiredWidth = width;
|
||||
int dw = int(QPlainTextDocumentLayout::documentSize().width());
|
||||
int dw = int(PlainTextDocumentLayout::documentSize().width());
|
||||
if (oldw > dw || width > dw)
|
||||
emitDocumentSizeChanged();
|
||||
}
|
||||
@@ -729,7 +729,7 @@ void TextDocumentLayout::setRequiredWidth(int width)
|
||||
|
||||
QSizeF TextDocumentLayout::documentSize() const
|
||||
{
|
||||
QSizeF size = QPlainTextDocumentLayout::documentSize();
|
||||
QSizeF size = PlainTextDocumentLayout::documentSize();
|
||||
size.setWidth(qMax(qreal(m_requiredWidth), size.width()));
|
||||
return size;
|
||||
}
|
||||
@@ -818,7 +818,7 @@ void TextDocumentLayout::requestUpdateNow()
|
||||
int TextDocumentLayout::embeddedWidgetOffset(const QTextBlock &block, QWidget *widget)
|
||||
{
|
||||
if (auto userData = TextBlockUserData::textUserData(block)) {
|
||||
int offset = QPlainTextDocumentLayout::blockBoundingRect(block).height();
|
||||
int offset = PlainTextDocumentLayout::blockBoundingRect(block).height();
|
||||
for (auto embeddedWidget : userData->embeddedWidgets(block)) {
|
||||
if (embeddedWidget == widget)
|
||||
return offset;
|
||||
@@ -838,7 +838,7 @@ void TextDocumentLayout::resetReloadMarks()
|
||||
static QRectF replacementBoundingRect(const QTextDocument *replacement)
|
||||
{
|
||||
QTC_ASSERT(replacement, return {});
|
||||
auto *layout = static_cast<QPlainTextDocumentLayout *>(replacement->documentLayout());
|
||||
auto *layout = static_cast<Utils::PlainTextDocumentLayout *>(replacement->documentLayout());
|
||||
QRectF boundingRect;
|
||||
QTextBlock block = replacement->firstBlock();
|
||||
while (block.isValid()) {
|
||||
@@ -859,7 +859,7 @@ QRectF TextDocumentLayout::blockBoundingRect(const QTextBlock &block) const
|
||||
return replacementBoundingRect(suggestion->replacementDocument());
|
||||
}
|
||||
|
||||
QRectF boundingRect = QPlainTextDocumentLayout::blockBoundingRect(block);
|
||||
QRectF boundingRect = PlainTextDocumentLayout::blockBoundingRect(block);
|
||||
|
||||
if (TextEditorSettings::fontSettings().relativeLineSpacing() != 100) {
|
||||
if (boundingRect.isNull())
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "textsuggestion.h"
|
||||
|
||||
#include <utils/id.h>
|
||||
#include <utils/plaintextedit/plaintextedit.h>
|
||||
|
||||
#include <KSyntaxHighlighting/State>
|
||||
|
||||
@@ -158,7 +159,7 @@ private:
|
||||
quint8 m_attrState = 0;
|
||||
};
|
||||
|
||||
class TEXTEDITOR_EXPORT TextDocumentLayout : public QPlainTextDocumentLayout
|
||||
class TEXTEDITOR_EXPORT TextDocumentLayout : public Utils::PlainTextDocumentLayout
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -126,7 +126,7 @@
|
||||
|
||||
/*!
|
||||
\class TextEditor::BaseTextEditor
|
||||
\brief The BaseTextEditor class is base implementation for QPlainTextEdit-based
|
||||
\brief The BaseTextEditor class is base implementation for PlainTextEdit-based
|
||||
text editors. It can use the Kate text highlighting definitions, and some basic
|
||||
auto indentation.
|
||||
|
||||
@@ -169,7 +169,7 @@ LineColumnButton::LineColumnButton(TextEditorWidget *parent)
|
||||
, m_d(new LineColumnButtonPrivate)
|
||||
{
|
||||
m_d->m_editor = parent;
|
||||
connect(m_d->m_editor, &QPlainTextEdit::cursorPositionChanged, this, &LineColumnButton::update);
|
||||
connect(m_d->m_editor, &PlainTextEdit::cursorPositionChanged, this, &LineColumnButton::update);
|
||||
connect(this, &QToolButton::clicked, ActionManager::instance(), [this] {
|
||||
m_d->m_editor->setFocus();
|
||||
QMetaObject::invokeMethod(
|
||||
@@ -1253,30 +1253,30 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent)
|
||||
connect(&m_codeAssistant, &CodeAssistant::finished,
|
||||
q, &TextEditorWidget::assistFinished);
|
||||
|
||||
connect(q, &QPlainTextEdit::blockCountChanged, this, [this] { slotUpdateExtraAreaWidth(); });
|
||||
connect(q, &PlainTextEdit::blockCountChanged, this, [this] { slotUpdateExtraAreaWidth(); });
|
||||
|
||||
connect(q, &QPlainTextEdit::modificationChanged,
|
||||
connect(q, &PlainTextEdit::modificationChanged,
|
||||
m_extraArea, QOverload<>::of(&QWidget::update));
|
||||
|
||||
connect(q, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(q, &PlainTextEdit::cursorPositionChanged,
|
||||
q, &TextEditorWidget::slotCursorPositionChanged);
|
||||
|
||||
connect(q, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(q, &PlainTextEdit::cursorPositionChanged,
|
||||
this, &TextEditorWidgetPrivate::updateCursorPosition);
|
||||
|
||||
connect(q, &QPlainTextEdit::updateRequest,
|
||||
connect(q, &PlainTextEdit::updateRequest,
|
||||
this, &TextEditorWidgetPrivate::slotUpdateRequest);
|
||||
|
||||
connect(q, &QPlainTextEdit::selectionChanged,
|
||||
connect(q, &PlainTextEdit::selectionChanged,
|
||||
this, &TextEditorWidgetPrivate::slotSelectionChanged);
|
||||
|
||||
connect(q, &QPlainTextEdit::undoAvailable,
|
||||
connect(q, &PlainTextEdit::undoAvailable,
|
||||
this, &TextEditorWidgetPrivate::updateUndoAction);
|
||||
|
||||
connect(q, &QPlainTextEdit::redoAvailable,
|
||||
connect(q, &PlainTextEdit::redoAvailable,
|
||||
this, &TextEditorWidgetPrivate::updateRedoAction);
|
||||
|
||||
connect(q, &QPlainTextEdit::copyAvailable,
|
||||
connect(q, &PlainTextEdit::copyAvailable,
|
||||
this, &TextEditorWidgetPrivate::updateCopyAction);
|
||||
|
||||
m_parenthesesMatchingTimer.setSingleShot(true);
|
||||
@@ -1450,7 +1450,7 @@ Id TextEditorWidget::DebuggerExceptionSelection("TextEdit.DebuggerExceptionSelec
|
||||
Id TextEditorWidget::FakeVimSelection("TextEdit.FakeVimSelection");
|
||||
|
||||
TextEditorWidget::TextEditorWidget(QWidget *parent)
|
||||
: QPlainTextEdit(parent)
|
||||
: PlainTextEdit(parent)
|
||||
{
|
||||
// "Needed", as the creation below triggers ChildEvents that are
|
||||
// passed to this object's event() which uses 'd'.
|
||||
@@ -1491,7 +1491,7 @@ void TextEditorWidgetPrivate::setDocument(const QSharedPointer<TextDocument> &do
|
||||
m_documentConnections.clear();
|
||||
|
||||
m_document = doc;
|
||||
q->QPlainTextEdit::setDocument(doc->document());
|
||||
q->PlainTextEdit::setDocument(doc->document());
|
||||
m_tabSettingsButton->setDocument(q->textDocument());
|
||||
previousDocument.clear();
|
||||
q->setCursorWidth(2); // Applies to the document layout
|
||||
@@ -1501,7 +1501,7 @@ void TextEditorWidgetPrivate::setDocument(const QSharedPointer<TextDocument> &do
|
||||
QTC_CHECK(documentLayout);
|
||||
|
||||
m_documentConnections << connect(documentLayout,
|
||||
&QPlainTextDocumentLayout::updateBlock,
|
||||
&TextDocumentLayout::updateBlock,
|
||||
this,
|
||||
&TextEditorWidgetPrivate::slotUpdateBlockNotify);
|
||||
|
||||
@@ -1513,7 +1513,7 @@ void TextEditorWidgetPrivate::setDocument(const QSharedPointer<TextDocument> &do
|
||||
m_documentConnections << connect(q,
|
||||
&TextEditorWidget::requestBlockUpdate,
|
||||
documentLayout,
|
||||
&QPlainTextDocumentLayout::updateBlock);
|
||||
&TextDocumentLayout::updateBlock);
|
||||
|
||||
m_documentConnections << connect(documentLayout,
|
||||
&TextDocumentLayout::updateExtraArea,
|
||||
@@ -2734,13 +2734,13 @@ void TextEditorWidget::unindent()
|
||||
void TextEditorWidget::undo()
|
||||
{
|
||||
doSetTextCursor(multiTextCursor().mainCursor());
|
||||
QPlainTextEdit::undo();
|
||||
PlainTextEdit::undo();
|
||||
}
|
||||
|
||||
void TextEditorWidget::redo()
|
||||
{
|
||||
doSetTextCursor(multiTextCursor().mainCursor());
|
||||
QPlainTextEdit::redo();
|
||||
PlainTextEdit::redo();
|
||||
}
|
||||
|
||||
bool TextEditorWidget::isUndoAvailable() const
|
||||
@@ -3271,7 +3271,7 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
|
||||
if (cursorWithinSnippet)
|
||||
cursor.beginEditBlock();
|
||||
|
||||
QPlainTextEdit::keyPressEvent(e);
|
||||
PlainTextEdit::keyPressEvent(e);
|
||||
|
||||
if (cursorWithinSnippet) {
|
||||
cursor.endEditBlock();
|
||||
@@ -3473,7 +3473,7 @@ void TextEditorWidget::doSetTextCursor(const QTextCursor &cursor, bool keepMulti
|
||||
const_cast<MultiTextCursor &>(d->m_cursors).replaceMainCursor(c);
|
||||
d->updateCursorSelections();
|
||||
d->resetCursorFlashTimer();
|
||||
QPlainTextEdit::doSetTextCursor(c);
|
||||
PlainTextEdit::doSetTextCursor(c);
|
||||
if (oldCursor != d->m_cursors) {
|
||||
QRect updateRect = d->cursorUpdateRect(oldCursor);
|
||||
if (d->m_highlightCurrentLine)
|
||||
@@ -3624,7 +3624,7 @@ void TextEditorWidget::convertPosition(int pos, int *line, int *column) const
|
||||
bool TextEditorWidget::event(QEvent *e)
|
||||
{
|
||||
if (!d)
|
||||
return QPlainTextEdit::event(e);
|
||||
return PlainTextEdit::event(e);
|
||||
|
||||
// FIXME: That's far too heavy, and triggers e.g for ChildEvent
|
||||
if (e->type() != QEvent::InputMethodQuery)
|
||||
@@ -3668,7 +3668,7 @@ bool TextEditorWidget::event(QEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
return QPlainTextEdit::event(e);
|
||||
return PlainTextEdit::event(e);
|
||||
}
|
||||
|
||||
void TextEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
||||
@@ -3685,7 +3685,7 @@ void TextEditorWidgetPrivate::documentAboutToBeReloaded()
|
||||
|
||||
m_extraSelections.clear();
|
||||
m_extraSelections.reserve(NExtraSelectionKinds);
|
||||
q->QPlainTextEdit::setExtraSelections(QList<QTextEdit::ExtraSelection>());
|
||||
q->PlainTextEdit::setExtraSelections(QList<QTextEdit::ExtraSelection>());
|
||||
|
||||
// clear all overlays
|
||||
m_overlay->clear();
|
||||
@@ -4125,7 +4125,7 @@ void EmbeddedWidgetInterface::close()
|
||||
void TextEditorWidgetPrivate::forceUpdateScrollbarSize()
|
||||
{
|
||||
// We use resizeEvent here as a workaround as we can't get access to the
|
||||
// scrollarea which is a private part of the QPlainTextEdit.
|
||||
// scrollarea which is a private part of the PlainTextEdit.
|
||||
// During the resizeEvent the plain text edit will resize its scrollbars.
|
||||
// The TextEditorWidget will also update its scrollbar overlays.
|
||||
QResizeEvent event(q->size(), q->size());
|
||||
@@ -4985,13 +4985,13 @@ bool TextEditorWidget::viewportEvent(QEvent *event)
|
||||
ToolTip::hide();
|
||||
}
|
||||
}
|
||||
return QPlainTextEdit::viewportEvent(event);
|
||||
return PlainTextEdit::viewportEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void TextEditorWidget::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QPlainTextEdit::resizeEvent(e);
|
||||
PlainTextEdit::resizeEvent(e);
|
||||
QRect cr = rect();
|
||||
d->m_extraArea->setGeometry(
|
||||
QStyle::visualRect(layoutDirection(), cr,
|
||||
@@ -5952,7 +5952,7 @@ void TextEditorWidgetPrivate::paintIndentDepth(PaintEventData &data,
|
||||
while (paintColumn < depth) {
|
||||
if (x >= 0) {
|
||||
int paintPosition = data.tabSettings.positionAtColumn(text, paintColumn);
|
||||
if (q->lineWrapMode() == QPlainTextEdit::WidgetWidth
|
||||
if (q->lineWrapMode() == PlainTextEdit::WidgetWidth
|
||||
&& blockData.layout->lineForTextPosition(paintPosition).lineNumber() != 0) {
|
||||
break;
|
||||
}
|
||||
@@ -7060,7 +7060,7 @@ void TextEditorWidget::timerEvent(QTimerEvent *e)
|
||||
d->m_cursorVisible = !d->m_cursorVisible;
|
||||
viewport()->update(d->cursorUpdateRect(d->m_cursors));
|
||||
}
|
||||
QPlainTextEdit::timerEvent(e);
|
||||
PlainTextEdit::timerEvent(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -7152,7 +7152,7 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
}
|
||||
} else if (!onLink || e->buttons() != Qt::LeftButton
|
||||
|| e->modifiers() != Qt::ControlModifier) {
|
||||
QPlainTextEdit::mouseMoveEvent(e);
|
||||
PlainTextEdit::mouseMoveEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7236,7 +7236,7 @@ void TextEditorWidget::mousePressEvent(QMouseEvent *e)
|
||||
if (HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(e))
|
||||
return;
|
||||
|
||||
QPlainTextEdit::mousePressEvent(e);
|
||||
PlainTextEdit::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void TextEditorWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
@@ -7273,7 +7273,7 @@ void TextEditorWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
QPlainTextEdit::mouseReleaseEvent(e);
|
||||
PlainTextEdit::mouseReleaseEvent(e);
|
||||
|
||||
d->setClipboardSelection();
|
||||
const QTextCursor plainTextEditCursor = textCursor();
|
||||
@@ -7298,9 +7298,9 @@ void TextEditorWidget::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
QTextCursor eventCursor = cursorForPosition(QPoint(e->pos().x(), e->pos().y()));
|
||||
const int eventDocumentPosition = eventCursor.position();
|
||||
|
||||
QPlainTextEdit::mouseDoubleClickEvent(e);
|
||||
PlainTextEdit::mouseDoubleClickEvent(e);
|
||||
|
||||
// QPlainTextEdit::mouseDoubleClickEvent just selects the word under the text cursor. If the
|
||||
// PlainTextEdit::mouseDoubleClickEvent just selects the word under the text cursor. If the
|
||||
// event is triggered on a position that is inbetween two whitespaces this event selects the
|
||||
// previous word or nothing if the whitespaces are at the block start. Replace this behavior
|
||||
// with selecting the whitespaces starting from the previous word end to the next word.
|
||||
@@ -7332,7 +7332,7 @@ void TextEditorWidget::leaveEvent(QEvent *e)
|
||||
{
|
||||
// Clear link emulation when the mouse leaves the editor
|
||||
d->clearLink();
|
||||
QPlainTextEdit::leaveEvent(e);
|
||||
PlainTextEdit::leaveEvent(e);
|
||||
}
|
||||
|
||||
void TextEditorWidget::keyReleaseEvent(QKeyEvent *e)
|
||||
@@ -7347,7 +7347,7 @@ void TextEditorWidget::keyReleaseEvent(QKeyEvent *e)
|
||||
d->processTooltipRequest(textCursor());
|
||||
}
|
||||
|
||||
QPlainTextEdit::keyReleaseEvent(e);
|
||||
PlainTextEdit::keyReleaseEvent(e);
|
||||
}
|
||||
|
||||
void TextEditorWidget::dragEnterEvent(QDragEnterEvent *e)
|
||||
@@ -7358,7 +7358,7 @@ void TextEditorWidget::dragEnterEvent(QDragEnterEvent *e)
|
||||
return;
|
||||
}
|
||||
|
||||
QPlainTextEdit::dragEnterEvent(e);
|
||||
PlainTextEdit::dragEnterEvent(e);
|
||||
}
|
||||
|
||||
static void appendMenuActionsFromContext(QMenu *menu, Id menuContextId)
|
||||
@@ -7704,7 +7704,7 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
||||
void TextEditorWidget::ensureCursorVisible()
|
||||
{
|
||||
ensureBlockIsUnfolded(textCursor().block());
|
||||
QPlainTextEdit::ensureCursorVisible();
|
||||
PlainTextEdit::ensureCursorVisible();
|
||||
}
|
||||
|
||||
void TextEditorWidget::ensureBlockIsUnfolded(QTextBlock block)
|
||||
@@ -7932,7 +7932,7 @@ void TextEditorWidget::wheelEvent(QWheelEvent *e)
|
||||
if (e->modifiers() & Qt::ControlModifier) {
|
||||
if (!scrollWheelZoomingEnabled()) {
|
||||
// When the setting is disabled globally,
|
||||
// we have to skip calling QPlainTextEdit::wheelEvent()
|
||||
// we have to skip calling PlainTextEdit::wheelEvent()
|
||||
// that changes zoom in it.
|
||||
return;
|
||||
}
|
||||
@@ -7942,7 +7942,7 @@ void TextEditorWidget::wheelEvent(QWheelEvent *e)
|
||||
zoomF(deltaY / 120.f);
|
||||
return;
|
||||
}
|
||||
QPlainTextEdit::wheelEvent(e);
|
||||
PlainTextEdit::wheelEvent(e);
|
||||
}
|
||||
|
||||
static void showZoomIndicator(QWidget *editor, const int newZoom)
|
||||
@@ -8221,7 +8221,7 @@ void TextEditorWidgetPrivate::addSearchResultsToScrollBar(
|
||||
for (const SearchResult &result : results) {
|
||||
const QTextBlock &block = q->document()->findBlock(result.start);
|
||||
if (block.isValid() && block.isVisible()) {
|
||||
if (q->lineWrapMode() == QPlainTextEdit::WidgetWidth) {
|
||||
if (q->lineWrapMode() == PlainTextEdit::WidgetWidth) {
|
||||
const int firstLine = block.layout()->lineForTextPosition(result.start - block.position()).lineNumber();
|
||||
const int lastLine = block.layout()->lineForTextPosition(result.start - block.position() + result.length).lineNumber();
|
||||
for (int line = firstLine; line <= lastLine; ++line) {
|
||||
@@ -8245,8 +8245,7 @@ void TextEditorWidgetPrivate::addSearchResultsToScrollBar(const QList<SearchResu
|
||||
Highlight::HighPriority);
|
||||
}
|
||||
|
||||
void TextEditorWidgetPrivate::addSelectionHighlightToScrollBar(
|
||||
const QList<SearchResult> &selections)
|
||||
void TextEditorWidgetPrivate::addSelectionHighlightToScrollBar(const QList<SearchResult> &selections)
|
||||
{
|
||||
addSearchResultsToScrollBar(
|
||||
Constants::SCROLL_BAR_SELECTION,
|
||||
@@ -8616,7 +8615,7 @@ void TextEditorWidgetPrivate::cancelCurrentAnimations()
|
||||
|
||||
void TextEditorWidget::changeEvent(QEvent *e)
|
||||
{
|
||||
QPlainTextEdit::changeEvent(e);
|
||||
PlainTextEdit::changeEvent(e);
|
||||
if (e->type() == QEvent::ApplicationFontChange
|
||||
|| e->type() == QEvent::FontChange) {
|
||||
if (d->m_extraArea) {
|
||||
@@ -8633,14 +8632,14 @@ void TextEditorWidget::changeEvent(QEvent *e)
|
||||
|
||||
void TextEditorWidget::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
QPlainTextEdit::focusInEvent(e);
|
||||
PlainTextEdit::focusInEvent(e);
|
||||
d->startCursorFlashTimer();
|
||||
d->updateHighlights();
|
||||
}
|
||||
|
||||
void TextEditorWidget::focusOutEvent(QFocusEvent *e)
|
||||
{
|
||||
QPlainTextEdit::focusOutEvent(e);
|
||||
PlainTextEdit::focusOutEvent(e);
|
||||
d->m_hoverHandlerRunner.abortHandlers();
|
||||
if (viewport()->cursor().shape() == Qt::BlankCursor)
|
||||
viewport()->setCursor(Qt::IBeamCursor);
|
||||
@@ -8908,7 +8907,7 @@ void TextEditorWidgetPrivate::setExtraSelections(Id kind, const QList<QTextEdit:
|
||||
continue;
|
||||
all += i.value();
|
||||
}
|
||||
q->QPlainTextEdit::setExtraSelections(all);
|
||||
q->PlainTextEdit::setExtraSelections(all);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9099,14 +9098,14 @@ void TextEditorWidget::encourageApply()
|
||||
void TextEditorWidget::showEvent(QShowEvent* e)
|
||||
{
|
||||
triggerPendingUpdates();
|
||||
// QPlainTextEdit::showEvent scrolls to make the cursor visible on first show
|
||||
// PlainTextEdit::showEvent scrolls to make the cursor visible on first show
|
||||
// which we don't want, since we restore previous states when
|
||||
// opening editors, and when splitting/duplicating.
|
||||
// So restore the previous state after that.
|
||||
QByteArray state;
|
||||
if (d->m_wasNotYetShown)
|
||||
state = saveState();
|
||||
QPlainTextEdit::showEvent(e);
|
||||
PlainTextEdit::showEvent(e);
|
||||
if (d->m_wasNotYetShown) {
|
||||
restoreState(state);
|
||||
d->m_wasNotYetShown = false;
|
||||
@@ -9181,12 +9180,12 @@ void TextEditorWidget::setDisplaySettings(const DisplaySettings &ds)
|
||||
{
|
||||
const TextEditor::FontSettings &fs = TextEditorSettings::fontSettings();
|
||||
if (fs.relativeLineSpacing() == 100)
|
||||
setLineWrapMode(ds.m_textWrapping ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
|
||||
setLineWrapMode(ds.m_textWrapping ? PlainTextEdit::WidgetWidth : PlainTextEdit::NoWrap);
|
||||
else
|
||||
setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
setLineWrapMode(PlainTextEdit::NoWrap);
|
||||
|
||||
QTC_ASSERT((fs.relativeLineSpacing() == 100) || (fs.relativeLineSpacing() != 100
|
||||
&& lineWrapMode() == QPlainTextEdit::NoWrap), setLineWrapMode(QPlainTextEdit::NoWrap));
|
||||
&& lineWrapMode() == PlainTextEdit::NoWrap), setLineWrapMode(PlainTextEdit::NoWrap));
|
||||
|
||||
setLineNumbersVisible(ds.m_displayLineNumbers);
|
||||
setHighlightCurrentLine(ds.m_highlightCurrentLine);
|
||||
@@ -9372,21 +9371,21 @@ void TextEditorWidget::selectAll()
|
||||
{
|
||||
// Directly update the internal multi text cursor here to prevent calling setTextCursor.
|
||||
// This would indirectly make sure the cursor is visible which is not desired for select all.
|
||||
QTextCursor c = QPlainTextEdit::textCursor();
|
||||
QTextCursor c = PlainTextEdit::textCursor();
|
||||
c.select(QTextCursor::Document);
|
||||
const_cast<MultiTextCursor &>(d->m_cursors).setCursors({c});
|
||||
QPlainTextEdit::selectAll();
|
||||
PlainTextEdit::selectAll();
|
||||
}
|
||||
|
||||
void TextEditorWidget::copy()
|
||||
{
|
||||
QPlainTextEdit::copy();
|
||||
PlainTextEdit::copy();
|
||||
d->collectToCircularClipboard();
|
||||
}
|
||||
|
||||
void TextEditorWidget::paste()
|
||||
{
|
||||
QPlainTextEdit::paste();
|
||||
PlainTextEdit::paste();
|
||||
encourageApply();
|
||||
}
|
||||
|
||||
@@ -9539,7 +9538,7 @@ QMimeData *TextEditorWidget::createMimeDataFromSelection(bool withHtml) const
|
||||
|
||||
bool TextEditorWidget::canInsertFromMimeData(const QMimeData *source) const
|
||||
{
|
||||
return QPlainTextEdit::canInsertFromMimeData(source);
|
||||
return PlainTextEdit::canInsertFromMimeData(source);
|
||||
}
|
||||
|
||||
struct MappedText
|
||||
@@ -10190,7 +10189,7 @@ void TextEditorWidget::updateVisualWrapColumn()
|
||||
|
||||
void TextEditorWidgetPrivate::updateTabStops()
|
||||
{
|
||||
// Although the tab stop is stored as qreal the API from QPlainTextEdit only allows it
|
||||
// Although the tab stop is stored as qreal the API from PlainTextEdit only allows it
|
||||
// to be set as an int. A work around is to access directly the QTextOption.
|
||||
QTextOption option = q->document()->defaultTextOption();
|
||||
option.setTabStopDistance(charWidth() * m_document->tabSettings().m_tabSize);
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <utils/elidinglabel.h>
|
||||
#include <utils/link.h>
|
||||
#include <utils/multitextcursor.h>
|
||||
#include <utils/plaintextedit/plaintextedit.h>
|
||||
#include <utils/textutils.h>
|
||||
#include <utils/uncommentselection.h>
|
||||
|
||||
@@ -191,7 +192,7 @@ private:
|
||||
Internal::BaseTextEditorPrivate *d;
|
||||
};
|
||||
|
||||
class TEXTEDITOR_EXPORT TextEditorWidget : public QPlainTextEdit
|
||||
class TEXTEDITOR_EXPORT TextEditorWidget : public Utils::PlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -213,7 +214,7 @@ public:
|
||||
QTextCursor textCursorAt(int position) const;
|
||||
Utils::Text::Position lineColumn() const;
|
||||
void convertPosition(int pos, int *line, int *column) const;
|
||||
using QPlainTextEdit::cursorRect;
|
||||
using PlainTextEdit::cursorRect;
|
||||
QRect cursorRect(int pos) const;
|
||||
void setCursorPosition(int pos);
|
||||
QWidget *toolBarWidget() const;
|
||||
|
@@ -736,22 +736,22 @@ void VcsBaseEditorWidget::init()
|
||||
case LogOutput:
|
||||
connect(d->entriesComboBox(), &QComboBox::activated,
|
||||
this, &VcsBaseEditorWidget::slotJumpToEntry);
|
||||
connect(this, &QPlainTextEdit::textChanged,
|
||||
connect(this, &PlainTextEdit::textChanged,
|
||||
this, &VcsBaseEditorWidget::slotPopulateLogBrowser);
|
||||
connect(this, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(this, &PlainTextEdit::cursorPositionChanged,
|
||||
this, &VcsBaseEditorWidget::slotCursorPositionChanged);
|
||||
break;
|
||||
case AnnotateOutput:
|
||||
// Annotation highlighting depends on contents, which is set later on
|
||||
connect(this, &QPlainTextEdit::textChanged, this, &VcsBaseEditorWidget::slotActivateAnnotation);
|
||||
connect(this, &PlainTextEdit::textChanged, this, &VcsBaseEditorWidget::slotActivateAnnotation);
|
||||
break;
|
||||
case DiffOutput:
|
||||
// Diff: set up diff file browsing
|
||||
connect(d->entriesComboBox(), &QComboBox::activated,
|
||||
this, &VcsBaseEditorWidget::slotJumpToEntry);
|
||||
connect(this, &QPlainTextEdit::textChanged,
|
||||
connect(this, &PlainTextEdit::textChanged,
|
||||
this, &VcsBaseEditorWidget::slotPopulateDiffBrowser);
|
||||
connect(this, &QPlainTextEdit::cursorPositionChanged,
|
||||
connect(this, &PlainTextEdit::cursorPositionChanged,
|
||||
this, &VcsBaseEditorWidget::slotCursorPositionChanged);
|
||||
break;
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ void VcsBaseEditorWidget::slotActivateAnnotation()
|
||||
if (changes.isEmpty())
|
||||
return;
|
||||
|
||||
disconnect(this, &QPlainTextEdit::textChanged, this, &VcsBaseEditorWidget::slotActivateAnnotation);
|
||||
disconnect(this, &PlainTextEdit::textChanged, this, &VcsBaseEditorWidget::slotActivateAnnotation);
|
||||
|
||||
if (SyntaxHighlighter *ah = textDocument()->syntaxHighlighter()) {
|
||||
ah->rehighlight();
|
||||
|
Reference in New Issue
Block a user