diff options
author | hjk <hjk@theqtcompany.com> | 2016-07-19 11:58:15 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2016-07-19 10:45:23 +0000 |
commit | 6edfb669081231cc0fd7ddaad83fe83b48aa77a7 (patch) | |
tree | 5c4301e8e6ab19a914e24a25461388209232402f /src/plugins/bookmarks | |
parent | 36e12b75e0c8d907665c975a9b283ed0cf61b59d (diff) |
TextEditor: Enable tooltips for textmarks
Adjust bookmark code, add tooltips for clang diagnostics.
Change-Id: I489d499f5431fcb29f27611d4350298acb30baac
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/bookmarks')
-rw-r--r-- | src/plugins/bookmarks/bookmark.cpp | 4 | ||||
-rw-r--r-- | src/plugins/bookmarks/bookmark.h | 12 | ||||
-rw-r--r-- | src/plugins/bookmarks/bookmarkmanager.cpp | 18 | ||||
-rw-r--r-- | src/plugins/bookmarks/bookmarkmanager.h | 6 | ||||
-rw-r--r-- | src/plugins/bookmarks/bookmarksplugin.cpp | 7 |
5 files changed, 10 insertions, 37 deletions
diff --git a/src/plugins/bookmarks/bookmark.cpp b/src/plugins/bookmarks/bookmark.cpp index c4c29741d74..f7575ef39f8 100644 --- a/src/plugins/bookmarks/bookmark.cpp +++ b/src/plugins/bookmarks/bookmark.cpp @@ -78,7 +78,7 @@ void Bookmark::updateFileName(const QString &fileName) void Bookmark::setNote(const QString ¬e) { - m_note = note; + setToolTip(note); } void Bookmark::updateNote(const QString ¬e) @@ -94,5 +94,5 @@ QString Bookmark::lineText() const QString Bookmark::note() const { - return m_note; + return toolTip(); } diff --git a/src/plugins/bookmarks/bookmark.h b/src/plugins/bookmarks/bookmark.h index af9c219b9c3..6d818946ff3 100644 --- a/src/plugins/bookmarks/bookmark.h +++ b/src/plugins/bookmarks/bookmark.h @@ -37,13 +37,14 @@ class Bookmark : public TextEditor::TextMark public: Bookmark(int lineNumber, BookmarkManager *manager); - void updateLineNumber(int lineNumber); - void move(int line); - void updateBlock(const QTextBlock &block); - void updateFileName(const QString &fileName); + void updateLineNumber(int lineNumber) override; + void move(int line) override; + void updateBlock(const QTextBlock &block) override; + void updateFileName(const QString &fileName) override; + void removedFromEditor() override; + void setNote(const QString ¬e); void updateNote(const QString ¬e); - void removedFromEditor(); QString lineText() const; QString note() const; @@ -51,7 +52,6 @@ public: private: BookmarkManager *m_manager; QString m_lineText; - QString m_note; }; } // namespace Internal diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 0083466fef1..3fc051c5399 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -38,7 +38,6 @@ #include <projectexplorer/session.h> #include <texteditor/texteditor.h> #include <utils/icon.h> -#include <utils/tooltip/tooltip.h> #include <utils/qtcassert.h> #include <utils/checkablemessagebox.h> #include <utils/theme/theme.h> @@ -845,17 +844,6 @@ void BookmarkManager::saveBookmarks() SessionManager::setValue(QLatin1String("Bookmarks"), list); } -void BookmarkManager::operateTooltip(QWidget *widget, const QPoint &pos, Bookmark *mark) -{ - if (!mark) - return; - - if (mark->note().isEmpty()) - ToolTip::hide(); - else - ToolTip::show(pos, mark->note(), widget); -} - /* Loads the bookmarks from the session settings. */ void BookmarkManager::loadBookmarks() { @@ -867,12 +855,6 @@ void BookmarkManager::loadBookmarks() updateActionStatus(); } -void BookmarkManager::handleBookmarkTooltipRequest(IEditor *editor, const QPoint &pos, int line) -{ - Bookmark *mark = findBookmark(editor->document()->filePath().toString(), line); - operateTooltip(editor->widget(), pos, mark); -} - // BookmarkViewFactory BookmarkViewFactory::BookmarkViewFactory(BookmarkManager *bm) diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h index 0bc81ad135b..1a35f28400a 100644 --- a/src/plugins/bookmarks/bookmarkmanager.h +++ b/src/plugins/bookmarks/bookmarkmanager.h @@ -26,7 +26,6 @@ #pragma once #include <utils/itemviews.h> -#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/inavigationwidgetfactory.h> #include <QAbstractItemModel> @@ -36,6 +35,8 @@ #include <QPixmap> #include <QStyledItemDelegate> +namespace Core { class IContext; } + namespace Bookmarks { namespace Internal { @@ -87,8 +88,6 @@ public: Note = Qt::UserRole + 4 }; - void handleBookmarkTooltipRequest(Core::IEditor *editor, const QPoint &pos, int line); - void toggleBookmark(const QString &fileName, int lineNumber); void nextInDocument(); void prevInDocument(); @@ -117,7 +116,6 @@ private: bool removeBookmarkFromMap(Bookmark *bookmark, const QString &fileName = QString()); static QString bookmarkToString(const Bookmark *b); void saveBookmarks(); - void operateTooltip(QWidget *widget, const QPoint &pos, Bookmark *mark); typedef QMultiMap<QString, Bookmark *> FileNameBookmarksMap; typedef QMap<QString, FileNameBookmarksMap *> DirectoryFileBookmarksMap; diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index 89119bb830b..e1a59296af2 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -170,13 +170,6 @@ void BookmarksPlugin::editorOpened(IEditor *editor) m_bookmarkManager->toggleBookmark(editor->document()->filePath().toString(), line); }); - - connect(widget, &TextEditorWidget::markTooltipRequested, m_bookmarkManager, - [this, editor](TextEditorWidget *, const QPoint &pos, int line) { - if (editor->document()) - m_bookmarkManager->handleBookmarkTooltipRequest(editor, pos, line); - }); - connect(widget, &TextEditorWidget::markContextMenuRequested, this, &BookmarksPlugin::requestContextMenu); } |