CppEditor: Use full tooltip in ClangTextMark

Change-Id: I39cc64acbdbcd5e5156e1514acaf9674a91e81a4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
hjk
2016-07-22 08:57:32 +02:00
committed by hjk
parent fe3f288f27
commit 728b914727
15 changed files with 82 additions and 60 deletions

View File

@@ -111,6 +111,7 @@
#include <QTimeLine>
#include <QTimer>
#include <QToolBar>
#include <QVBoxLayout>
//#define DO_FOO
@@ -5048,6 +5049,7 @@ void TextEditorWidget::showDefaultContextMenu(QContextMenuEvent *e, Id menuConte
void TextEditorWidget::extraAreaLeaveEvent(QEvent *)
{
d->extraAreaPreviousMarkTooltipRequestedLine = -1;
ToolTip::hide();
// fake missing mouse move event from Qt
QMouseEvent me(QEvent::MouseMove, QPoint(-1, -1), Qt::NoButton, 0, 0);
@@ -5108,13 +5110,16 @@ void TextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
int line = cursor.blockNumber() + 1;
if (d->extraAreaPreviousMarkTooltipRequestedLine != line) {
if (auto data = static_cast<TextBlockUserData *>(cursor.block().userData())) {
QStringList toolTips;
foreach (TextMark *mark, data->marks()) {
QString toolTip = mark->toolTip();
if (!toolTip.isEmpty())
toolTips.append(toolTip);
if (data->marks().isEmpty()) {
ToolTip::hide();
} else {
auto layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(2);
foreach (TextMark *mark, data->marks())
mark->addToToolTipLayout(layout);
ToolTip::show(mapToGlobal(e->pos()), layout, this);
}
ToolTip::show(mapToGlobal(e->pos()), toolTips.join('\n'), this);
}
}
d->extraAreaPreviousMarkTooltipRequestedLine = line;