TextEditor: reduce complexity of bookmark requests

Since the book mark support is nowadays part of the text editor plugin
we can directly access the bookmark manager from within the editor
without the indirection over the TextEditorPluginPrivate.

Change-Id: I5c04679d6583c06d615d489d3891431adcb64834
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2024-01-18 08:45:37 +01:00
parent 45bb4a5f76
commit 15a1fd6afc
2 changed files with 10 additions and 53 deletions

View File

@@ -6,6 +6,7 @@
#include "autocompleter.h"
#include "basehoverhandler.h"
#include "behaviorsettings.h"
#include "bookmarkmanager.h"
#include "circularclipboard.h"
#include "circularclipboardassist.h"
#include "codeassist/assistinterface.h"
@@ -6429,6 +6430,9 @@ void TextEditorWidget::extraAreaContextMenuEvent(QContextMenuEvent *e)
if (d->m_marksVisible) {
QTextCursor cursor = cursorForPosition(QPoint(0, e->pos().y()));
auto contextMenu = new QMenu(this);
bookmarkManager().requestContextMenu(textDocument()->filePath(),
cursor.blockNumber() + 1,
contextMenu);
emit markContextMenuRequested(this, cursor.blockNumber() + 1, contextMenu);
if (!contextMenu->isEmpty())
contextMenu->exec(e->globalPos());
@@ -6621,13 +6625,12 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
}
}
int line = n + 1;
TextMarkRequestKind kind;
if (QApplication::keyboardModifiers() & Qt::ShiftModifier)
kind = BookmarkRequest;
else
kind = BreakpointRequest;
emit markRequested(this, line, kind);
if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
if (!textDocument()->isTemporary())
bookmarkManager().toggleBookmark(textDocument()->filePath(), line);
} else {
emit markRequested(this, line, BreakpointRequest);
}
}
}
}