forked from qt-creator/qt-creator
TextEditor: Use signal/signal connection from *EditorWidget to *Editor
This reduces the need for most of the remaining uses of the editor() back link. Change-Id: I557cf4d3b5e1986f811fb17e87bf1825ac6912c6 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -2962,10 +2962,8 @@ void BaseTextEditorWidgetPrivate::processTooltipRequest(const QTextCursor &c)
|
|||||||
{
|
{
|
||||||
const QPoint toolTipPoint = q->toolTipPosition(c);
|
const QPoint toolTipPoint = q->toolTipPosition(c);
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
BaseTextEditor *ed = q->editor();
|
|
||||||
emit ed->tooltipOverrideRequested(ed, toolTipPoint, c.position(), &handled);
|
|
||||||
if (!handled)
|
if (!handled)
|
||||||
emit ed->tooltipRequested(ed, toolTipPoint, c.position());
|
emit q->tooltipRequested(toolTipPoint, c.position());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextEditorWidget::viewportEvent(QEvent *event)
|
bool BaseTextEditorWidget::viewportEvent(QEvent *event)
|
||||||
@@ -4900,10 +4898,10 @@ void BaseTextEditorWidget::extraAreaLeaveEvent(QEvent *)
|
|||||||
|
|
||||||
void BaseTextEditorWidget::extraAreaContextMenuEvent(QContextMenuEvent *e)
|
void BaseTextEditorWidget::extraAreaContextMenuEvent(QContextMenuEvent *e)
|
||||||
{
|
{
|
||||||
QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
|
|
||||||
if (d->m_marksVisible) {
|
if (d->m_marksVisible) {
|
||||||
|
QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
|
||||||
QMenu * contextMenu = new QMenu(this);
|
QMenu * contextMenu = new QMenu(this);
|
||||||
emit editor()->markContextMenuRequested(editor(), cursor.blockNumber() + 1, contextMenu);
|
emit markContextMenuRequested(cursor.blockNumber() + 1, contextMenu);
|
||||||
if (!contextMenu->isEmpty())
|
if (!contextMenu->isEmpty())
|
||||||
contextMenu->exec(e->globalPos());
|
contextMenu->exec(e->globalPos());
|
||||||
delete contextMenu;
|
delete contextMenu;
|
||||||
@@ -4951,7 +4949,7 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
if (inMarkArea) {
|
if (inMarkArea) {
|
||||||
//Find line by cursor position
|
//Find line by cursor position
|
||||||
int line = cursor.blockNumber() + 1;
|
int line = cursor.blockNumber() + 1;
|
||||||
emit editor()->markTooltipRequested(editor(), mapToGlobal(e->pos()), line);
|
emit markTooltipRequested(mapToGlobal(e->pos()), line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->buttons() & Qt::LeftButton && !d->m_markDragStart.isNull()) {
|
if (e->buttons() & Qt::LeftButton && !d->m_markDragStart.isNull()) {
|
||||||
@@ -5069,7 +5067,7 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
|
|||||||
else
|
else
|
||||||
kind = BaseTextEditor::BreakpointRequest;
|
kind = BaseTextEditor::BreakpointRequest;
|
||||||
|
|
||||||
emit editor()->markRequested(editor(), line, kind);
|
emit markRequested(line, kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7318,6 +7316,31 @@ BaseTextEditor *BaseTextEditorFactory::createEditorHelper(const BaseTextDocument
|
|||||||
if (m_autoCompleterCreator)
|
if (m_autoCompleterCreator)
|
||||||
widget->setAutoCompleter(m_autoCompleterCreator());
|
widget->setAutoCompleter(m_autoCompleterCreator());
|
||||||
|
|
||||||
|
connect(widget, &BaseTextEditorWidget::markRequested, editor,
|
||||||
|
[editor](int line, BaseTextEditor::MarkRequestKind kind) {
|
||||||
|
editor->markRequested(editor, line, kind);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(widget, &BaseTextEditorWidget::markContextMenuRequested, editor,
|
||||||
|
[editor](int line, QMenu *menu) {
|
||||||
|
editor->markContextMenuRequested(editor, line, menu);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(widget, &BaseTextEditorWidget::tooltipOverrideRequested, editor,
|
||||||
|
[editor](const QPoint &globalPos, int position, bool *handled) {
|
||||||
|
editor->tooltipOverrideRequested(editor, globalPos, position, handled);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(widget, &BaseTextEditorWidget::tooltipRequested, editor,
|
||||||
|
[editor](const QPoint &globalPos, int position) {
|
||||||
|
editor->tooltipRequested(editor, globalPos, position);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(widget, &BaseTextEditorWidget::markTooltipRequested, editor,
|
||||||
|
[editor](const QPoint &globalPos, int line) {
|
||||||
|
editor->markTooltipRequested(editor, globalPos, line);
|
||||||
|
});
|
||||||
|
|
||||||
widget->finalizeInitialization();
|
widget->finalizeInitialization();
|
||||||
editor->finalizeInitialization();
|
editor->finalizeInitialization();
|
||||||
|
|
||||||
|
|||||||
@@ -607,6 +607,13 @@ protected:
|
|||||||
int visibleFoldedBlockNumber() const;
|
int visibleFoldedBlockNumber() const;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void markRequested(int line, TextEditor::BaseTextEditor::MarkRequestKind kind);
|
||||||
|
void markContextMenuRequested(int line, QMenu *menu);
|
||||||
|
void tooltipOverrideRequested(const QPoint &globalPos, int position, bool *handled);
|
||||||
|
void tooltipRequested(const QPoint &globalPos, int position);
|
||||||
|
void markTooltipRequested(const QPoint &globalPos, int line);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void slotCursorPositionChanged(); // Used in VcsBase
|
virtual void slotCursorPositionChanged(); // Used in VcsBase
|
||||||
virtual void slotCodeStyleSettingsChanged(const QVariant &); // Used in CppEditor
|
virtual void slotCodeStyleSettingsChanged(const QVariant &); // Used in CppEditor
|
||||||
|
|||||||
Reference in New Issue
Block a user