aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/bineditor
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-03-07 16:30:27 +0100
committerEike Ziller <eike.ziller@qt.io>2018-03-13 08:53:57 +0000
commit7ac1b852b75837c391ae06490b17037bf9ac7591 (patch)
tree482b2ba7220fcb6f2d6c044aca3ae35f8ee7b9d2 /src/plugins/bineditor
parent84e0573cad70d8517e4445d2eb5e700ae77b874c (diff)
Fix binary editor tool tip
It should show up also over the last column, it should also show up if the selection spans multiple lines, and if the mouse is not over the selection it show up with information about the single byte under cursor. If the mouse is over a selection that is longer than 8 bytes, the tool tip is restricted to the first 8 bytes of the selection. Task-number: QTCREATORBUG-17573 Change-Id: Ie7aaf1e52ceadd6be815d4ce3386a60df1418297 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/bineditor')
-rw-r--r--src/plugins/bineditor/bineditorwidget.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/plugins/bineditor/bineditorwidget.cpp b/src/plugins/bineditor/bineditorwidget.cpp
index e647432723..bb61571fb1 100644
--- a/src/plugins/bineditor/bineditorwidget.cpp
+++ b/src/plugins/bineditor/bineditorwidget.cpp
@@ -1147,16 +1147,31 @@ QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
{
int selStart = selectionStart();
int selEnd = selectionEnd();
- int byteCount = selEnd - selStart + 1;
- if (m_hexCursor == 0 || byteCount > 8)
- return QString();
-
- const QPoint &startPoint = offsetToPos(selStart);
- const QPoint &endPoint = offsetToPos(selEnd + 1);
- QRect selRect(startPoint, endPoint);
- selRect.setHeight(m_lineHeight);
- if (!selRect.contains(helpEvent->pos()))
- return QString();
+ int byteCount = std::min(8, selEnd - selStart + 1);
+
+ // check even position against selection line by line
+ bool insideSelection = false;
+ int startInLine = selStart;
+ do {
+ const int lineIndex = startInLine / m_bytesPerLine;
+ const int endOfLine = (lineIndex + 1) * m_bytesPerLine - 1;
+ const int endInLine = std::min(selEnd, endOfLine);
+ const QPoint &startPoint = offsetToPos(startInLine);
+ const QPoint &endPoint = offsetToPos(endInLine) + QPoint(m_columnWidth, 0);
+ QRect selectionLineRect(startPoint, endPoint);
+ selectionLineRect.setHeight(m_lineHeight);
+ if (selectionLineRect.contains(helpEvent->pos())) {
+ insideSelection = true;
+ break;
+ }
+ startInLine = endInLine + 1;
+ } while (startInLine <= selEnd);
+ if (!insideSelection) {
+ // show popup for byte under cursor
+ selStart = posAt(helpEvent->pos());
+ selEnd = selStart;
+ byteCount = 1;
+ }
quint64 bigEndianValue, littleEndianValue;
quint64 bigEndianValueOld, littleEndianValueOld;