forked from qt-creator/qt-creator
Debugger: Show position in separately displayed text in tooltip
Task-number: QTCREATORBUG-17324 Change-Id: Ic9571a91e5f414abd10b18698a0e0ae9bb0f1f46 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
#include <QTableWidget>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
#include <QToolTip>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@@ -352,6 +353,27 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class TextEdit : public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
bool event(QEvent *ev) override
|
||||
{
|
||||
if (ev->type() == QEvent::ToolTip) {
|
||||
auto hev = static_cast<QHelpEvent *>(ev);
|
||||
QTextCursor cursor = cursorForPosition(hev->pos());
|
||||
int nextPos = cursor.position();
|
||||
if (document() && nextPos + 1 < document()->characterCount())
|
||||
++nextPos;
|
||||
cursor.setPosition(nextPos, QTextCursor::KeepAnchor);
|
||||
QString msg = QString("Position: %1 Character: %2")
|
||||
.arg(cursor.anchor()).arg(cursor.selectedText());
|
||||
QToolTip::showText(hev->globalPos(), msg, this);
|
||||
}
|
||||
return QTextEdit::event(ev);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -2211,7 +2233,7 @@ void WatchModel::showEditValue(const WatchItem *item)
|
||||
str = QString::fromUtf16((ushort *)ba.constData(), ba.size() / 2);
|
||||
else if (format == DisplayUtf16String)
|
||||
str = QString::fromUcs4((uint *)ba.constData(), ba.size() / 4);
|
||||
m_separatedView->prepareObject<QTextEdit>(item)->setPlainText(str);
|
||||
m_separatedView->prepareObject<TextEdit>(item)->setPlainText(str);
|
||||
} else if (format == DisplayPlotData) {
|
||||
// Plots
|
||||
std::vector<double> data;
|
||||
@@ -2637,3 +2659,5 @@ static QVariant createItemDelegate()
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Debugger
|
||||
|
||||
#include "watchhandler.moc"
|
||||
|
||||
Reference in New Issue
Block a user