forked from qt-creator/qt-creator
Debugger: Rework Tooltips. Again.
Too much layers of complexity. Instead of keeping an eye on the "live" tree model and switch to a static StandardItemModel whenever live synchronization is not possible (and do all the tree view snake oil magic that's needed to make the switch appear "smooth") keep static copies of relevant parts of the live model, and update them whenever the the live model changes. Change-Id: I88a7de67f7703cd2fed041351346b1c7ada0839e Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com> Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -54,6 +54,7 @@ public:
|
||||
bool isValid() const { return !expression.isEmpty(); }
|
||||
bool matchesFrame(const StackFrame &frame) const;
|
||||
bool isSame(const DebuggerToolTipContext &other) const;
|
||||
QString toolTip() const;
|
||||
|
||||
QString fileName;
|
||||
int position;
|
||||
@@ -89,8 +90,6 @@ public:
|
||||
|
||||
virtual bool eventFilter(QObject *, QEvent *);
|
||||
|
||||
static QString treeModelClipboardContents(const QAbstractItemModel *model);
|
||||
|
||||
void debugModeEntered();
|
||||
void leavingDebugMode();
|
||||
void sessionAboutToChange();
|
||||
@@ -101,8 +100,6 @@ public:
|
||||
|
||||
public slots:
|
||||
static void slotUpdateVisibleToolTips();
|
||||
void slotItemIsExpanded(const QModelIndex &idx);
|
||||
void slotColumnAdjustmentRequested();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -679,7 +679,7 @@ QString WatchItem::expression() const
|
||||
QString WatchItem::displayName() const
|
||||
{
|
||||
QString result;
|
||||
if (!parent())
|
||||
if (!parentItem())
|
||||
return result;
|
||||
if (d.iname.startsWith("return"))
|
||||
result = WatchModel::tr("returned value");
|
||||
@@ -720,6 +720,23 @@ QString WatchItem::displayType() const
|
||||
return result;
|
||||
}
|
||||
|
||||
QColor WatchItem::color() const
|
||||
{
|
||||
static const QColor red(200, 0, 0);
|
||||
static const QColor gray(140, 140, 140);
|
||||
if (watchModel()) {
|
||||
if (!d.valueEnabled)
|
||||
return gray;
|
||||
if (!watchModel()->contentIsValid() && !d.isInspect())
|
||||
return gray;
|
||||
if (d.value.isEmpty()) // This might still show 0x...
|
||||
return gray;
|
||||
if (d.value != watchModel()->m_valueCache.value(d.iname))
|
||||
return red;
|
||||
}
|
||||
return QColor();
|
||||
}
|
||||
|
||||
QVariant WatchItem::data(int column, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
@@ -763,22 +780,9 @@ QVariant WatchItem::data(int column, int role) const
|
||||
return boolSetting(UseToolTipsInLocalsView)
|
||||
? d.toToolTip() : QVariant();
|
||||
|
||||
case Qt::ForegroundRole: {
|
||||
static const QVariant red(QColor(200, 0, 0));
|
||||
static const QVariant gray(QColor(140, 140, 140));
|
||||
if (column == 1) {
|
||||
QTC_ASSERT(model(), break);
|
||||
if (!d.valueEnabled)
|
||||
return gray;
|
||||
if (!watchModel()->contentIsValid() && !d.isInspect())
|
||||
return gray;
|
||||
if (d.value.isEmpty()) // This might still show 0x...
|
||||
return gray;
|
||||
if (d.value != watchModel()->m_valueCache.value(d.iname))
|
||||
return red;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::ForegroundRole:
|
||||
if (column == 1)
|
||||
return color();
|
||||
|
||||
case LocalsExpressionRole:
|
||||
return QVariant(expression());
|
||||
@@ -1109,8 +1113,10 @@ void WatchModel::insertDataItem(const WatchData &data, bool destructive)
|
||||
newItem->d = data;
|
||||
const int row = findInsertPosition(parent->children(), newItem);
|
||||
parent->insertChild(row, newItem);
|
||||
if (m_expandedINames.contains(parent->d.iname))
|
||||
if (m_expandedINames.contains(parent->d.iname)) {
|
||||
emit inameIsExpanded(parent->d.iname);
|
||||
emit itemIsExpanded(indexFromItem(parent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1245,6 +1251,7 @@ void WatchModel::reexpandItems()
|
||||
foreach (const QByteArray &iname, m_expandedINames) {
|
||||
WatchItem *item = findItem(iname);
|
||||
emit itemIsExpanded(indexFromItem(item));
|
||||
emit inameIsExpanded(iname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
|
||||
QVariant editValue() const;
|
||||
int editType() const;
|
||||
QColor color() const;
|
||||
|
||||
void formatRequests(QByteArray *out) const;
|
||||
void showInEditorHelper(QString *contents, int depth) const;
|
||||
@@ -173,6 +174,7 @@ public:
|
||||
signals:
|
||||
void currentIndexRequested(const QModelIndex &idx);
|
||||
void itemIsExpanded(const QModelIndex &idx);
|
||||
void inameIsExpanded(const QByteArray &iname);
|
||||
void columnAdjustmentRequested();
|
||||
};
|
||||
|
||||
|
||||
@@ -46,9 +46,10 @@
|
||||
|
||||
#include <coreplugin/messagebox.h>
|
||||
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/savedaction.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/treemodel.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
@@ -61,6 +62,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QTextStream>
|
||||
|
||||
// For InputDialog, move to Utils?
|
||||
#include <coreplugin/helpmanager.h>
|
||||
@@ -906,7 +908,17 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
||||
} else if (act == &actRemoveAllWatchExpression) {
|
||||
handler->clearWatches();
|
||||
} else if (act == &actCopy) {
|
||||
copyToClipboard(DebuggerToolTipManager::treeModelClipboardContents(model()));
|
||||
QString text;
|
||||
QTextStream str(&text);
|
||||
handler->model()->rootItem()->walkTree([&str](Utils::TreeItem *item) {
|
||||
str << QString(item->level(), QLatin1Char('\t'))
|
||||
<< item->data(0, Qt::DisplayRole).toString() << '\t'
|
||||
<< item->data(1, Qt::DisplayRole).toString() << '\t'
|
||||
<< item->data(2, Qt::DisplayRole).toString() << '\n';
|
||||
});
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(text, QClipboard::Selection);
|
||||
clipboard->setText(text, QClipboard::Clipboard);
|
||||
} else if (act == &actCopyValue) {
|
||||
copyToClipboard(mi1.data().toString());
|
||||
} else if (act == &actShowInEditor) {
|
||||
|
||||
Reference in New Issue
Block a user