forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -1147,16 +1147,31 @@ QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
|
|||||||
{
|
{
|
||||||
int selStart = selectionStart();
|
int selStart = selectionStart();
|
||||||
int selEnd = selectionEnd();
|
int selEnd = selectionEnd();
|
||||||
int byteCount = selEnd - selStart + 1;
|
int byteCount = std::min(8, selEnd - selStart + 1);
|
||||||
if (m_hexCursor == 0 || byteCount > 8)
|
|
||||||
return QString();
|
|
||||||
|
|
||||||
const QPoint &startPoint = offsetToPos(selStart);
|
// check even position against selection line by line
|
||||||
const QPoint &endPoint = offsetToPos(selEnd + 1);
|
bool insideSelection = false;
|
||||||
QRect selRect(startPoint, endPoint);
|
int startInLine = selStart;
|
||||||
selRect.setHeight(m_lineHeight);
|
do {
|
||||||
if (!selRect.contains(helpEvent->pos()))
|
const int lineIndex = startInLine / m_bytesPerLine;
|
||||||
return QString();
|
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 bigEndianValue, littleEndianValue;
|
||||||
quint64 bigEndianValueOld, littleEndianValueOld;
|
quint64 bigEndianValueOld, littleEndianValueOld;
|
||||||
|
Reference in New Issue
Block a user