Commit 67ab31c2 authored by Leandro Melo's avatar Leandro Melo Committed by Eike Ziller
Browse files

Editor: Bookmark when Shift-clicking the gutter



Task-number: QTCREATORBUG-2852

Change-Id: If539f812bce76c1c1e7b63e7133e2a7c962990ea
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent d4a881e6
......@@ -760,6 +760,14 @@ void BookmarkManager::loadBookmarks()
updateActionStatus();
}
void BookmarkManager::handleBookmarkRequest(TextEditor::ITextEditor *textEditor,
int line,
TextEditor::ITextEditor::MarkRequestKind kind)
{
if (kind == TextEditor::ITextEditor::BookmarkRequest && textEditor->file())
toggleBookmark(textEditor->file()->fileName(), line);
}
// BookmarkViewFactory
BookmarkViewFactory::BookmarkViewFactory(BookmarkManager *bm)
......
......@@ -36,6 +36,8 @@
#include <coreplugin/icontext.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <texteditor/itexteditor.h>
#include <QtCore/QAbstractItemModel>
#include <QtCore/QMultiMap>
#include <QtCore/QList>
......@@ -51,10 +53,6 @@ namespace Core {
class IEditor;
}
namespace TextEditor {
class ITextEditor;
}
namespace Bookmarks {
namespace Internal {
......@@ -115,6 +113,9 @@ signals:
private slots:
void updateActionStatus();
void loadBookmarks();
void handleBookmarkRequest(TextEditor::ITextEditor * textEditor,
int line,
TextEditor::ITextEditor::MarkRequestKind kind);
private:
TextEditor::ITextEditor *currentTextEditor() const;
......
......@@ -179,6 +179,13 @@ void BookmarksPlugin::editorOpened(Core::IEditor *editor)
if (qobject_cast<ITextEditor *>(editor)) {
connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
connect(editor,
SIGNAL(markRequested(TextEditor::ITextEditor*,int,
TextEditor::ITextEditor::MarkRequestKind)),
m_bookmarkManager,
SLOT(handleBookmarkRequest(TextEditor::ITextEditor*,int,
TextEditor::ITextEditor::MarkRequestKind)));
}
}
......
......@@ -707,7 +707,9 @@ public slots:
void editorOpened(Core::IEditor *editor);
void updateBreakMenuItem(Core::IEditor *editor);
void setBusyCursor(bool busy);
void requestMark(TextEditor::ITextEditor *editor, int lineNumber);
void requestMark(TextEditor::ITextEditor *editor,
int lineNumber,
TextEditor::ITextEditor::MarkRequestKind kind);
void requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu);
......@@ -1773,8 +1775,8 @@ void DebuggerPluginPrivate::editorOpened(IEditor *editor)
if (!textEditor)
return;
connect(textEditor,
SIGNAL(markRequested(TextEditor::ITextEditor*,int)),
SLOT(requestMark(TextEditor::ITextEditor*,int)));
SIGNAL(markRequested(TextEditor::ITextEditor*,int, TextEditor::ITextEditor::MarkRequestKind)),
SLOT(requestMark(TextEditor::ITextEditor*,int, TextEditor::ITextEditor::MarkRequestKind)));
connect(textEditor,
SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
......@@ -1943,8 +1945,13 @@ void DebuggerPluginPrivate::toggleBreakpointByAddress(quint64 address,
}
}
void DebuggerPluginPrivate::requestMark(ITextEditor *editor, int lineNumber)
void DebuggerPluginPrivate::requestMark(ITextEditor *editor,
int lineNumber,
ITextEditor::MarkRequestKind kind)
{
if (kind != ITextEditor::BreakpointRequest)
return;
if (editor->property("DisassemblerView").toBool()) {
QString line = editor->contents()
.section('\n', lineNumber - 1, lineNumber - 1);
......
......@@ -4370,7 +4370,12 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
d->extraAreaToggleMarkBlockNumber = -1;
if (cursor.blockNumber() == n) {
int line = n + 1;
emit editor()->markRequested(editor(), line);
ITextEditor::MarkRequestKind kind;
if (QApplication::keyboardModifiers() & Qt::ShiftModifier)
kind = ITextEditor::BookmarkRequest;
else
kind = ITextEditor::BreakpointRequest;
emit editor()->markRequested(editor(), line, kind);
}
}
}
......
......@@ -153,10 +153,15 @@ public:
static QMap<QString, QString> openedTextEditorsContents();
static QMap<QString, QTextCodec *> openedTextEditorsEncodings();
enum MarkRequestKind {
BreakpointRequest,
BookmarkRequest
};
signals:
void contentsChanged();
void contentsChangedBecauseOfUndo();
void markRequested(TextEditor::ITextEditor *editor, int line);
void markRequested(TextEditor::ITextEditor *editor, int line, TextEditor::ITextEditor::MarkRequestKind kind);
void markContextMenuRequested(TextEditor::ITextEditor *editor, int line, QMenu *menu);
void tooltipOverrideRequested(TextEditor::ITextEditor *editor, const QPoint &globalPos, int position, bool *handled);
void tooltipRequested(TextEditor::ITextEditor *editor, const QPoint &globalPos, int position);
......
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