2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "watchwindow.h"
|
|
|
|
|
|
2009-03-17 17:00:06 +01:00
|
|
|
#include "debuggeractions.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerconstants.h"
|
|
|
|
|
#include "debuggerengine.h"
|
2009-08-19 14:41:51 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "watchhandler.h"
|
2010-09-22 17:30:22 +02:00
|
|
|
#include "watchdelegatewidgets.h"
|
2009-03-17 17:00:06 +01:00
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <utils/savedaction.h>
|
2009-03-19 15:24:18 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDebug>
|
2010-09-22 17:30:22 +02:00
|
|
|
#include <QtCore/QVariant>
|
2010-09-24 10:35:22 +02:00
|
|
|
#include <QtCore/QMetaProperty>
|
|
|
|
|
#include <QtCore/QMetaObject>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtGui/QContextMenuEvent>
|
|
|
|
|
#include <QtGui/QHeaderView>
|
2009-03-19 15:24:18 +01:00
|
|
|
#include <QtGui/QItemDelegate>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QMenu>
|
|
|
|
|
#include <QtGui/QResizeEvent>
|
|
|
|
|
|
2009-09-25 16:01:28 +02:00
|
|
|
using namespace Debugger;
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Debugger::Internal;
|
|
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// WatchDelegate
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class WatchDelegate : public QItemDelegate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-09-24 10:35:22 +02:00
|
|
|
explicit WatchDelegate(QObject *parent) : QItemDelegate(parent) {}
|
2009-03-19 15:24:18 +01:00
|
|
|
|
|
|
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
|
2010-09-22 17:30:22 +02:00
|
|
|
const QModelIndex &index) const
|
2009-03-19 15:24:18 +01:00
|
|
|
{
|
2010-09-22 17:30:22 +02:00
|
|
|
// Value column: Custom editor. Apply integer-specific settings.
|
|
|
|
|
if (index.column() == 1) {
|
2010-11-04 11:27:23 +01:00
|
|
|
const QVariant::Type type =
|
|
|
|
|
static_cast<QVariant::Type>(index.data(LocalsEditTypeRole).toInt());
|
2010-09-22 17:30:22 +02:00
|
|
|
switch (type) {
|
|
|
|
|
case QVariant::Bool:
|
|
|
|
|
return new BooleanComboBox(parent);
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
WatchLineEdit *edit = WatchLineEdit::create(type, parent);
|
|
|
|
|
if (IntegerWatchLineEdit *intEdit = qobject_cast<IntegerWatchLineEdit *>(edit))
|
|
|
|
|
intEdit->setBase(index.data(LocalsIntegerBaseRole).toInt());
|
|
|
|
|
return edit;
|
|
|
|
|
}
|
|
|
|
|
// Standard line edits for the rest
|
2009-03-19 15:24:18 +01:00
|
|
|
return new QLineEdit(parent);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-07 13:38:19 +02:00
|
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
2010-09-24 10:35:22 +02:00
|
|
|
const QModelIndex &index) const
|
2009-03-19 15:24:18 +01:00
|
|
|
{
|
2010-09-24 10:35:22 +02:00
|
|
|
// Standard handling for anything but the watcher name column (change
|
|
|
|
|
// expression), which removes/recreates a row, which cannot be done
|
|
|
|
|
// in model->setData().
|
|
|
|
|
if (index.column() != 0) {
|
|
|
|
|
QItemDelegate::setModelData(editor, model, index);
|
2010-09-22 17:30:22 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2010-09-24 10:35:22 +02:00
|
|
|
const QMetaProperty userProperty = editor->metaObject()->userProperty();
|
|
|
|
|
QTC_ASSERT(userProperty.isValid(), return);
|
|
|
|
|
const QVariant value = editor->property(userProperty.name());
|
|
|
|
|
const QString exp = index.data(LocalsExpressionRole).toString();
|
|
|
|
|
if (exp != value.toString()) {
|
|
|
|
|
model->setData(index, exp, RequestRemoveWatchExpressionRole);
|
|
|
|
|
model->setData(index, value, RequestWatchExpressionRole);
|
2009-03-19 15:24:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
|
|
|
|
|
const QModelIndex &) const
|
|
|
|
|
{
|
|
|
|
|
editor->setGeometry(option.rect);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// WatchWindow
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
WatchWindow::WatchWindow(Type type, QWidget *parent)
|
|
|
|
|
: QTreeView(parent),
|
|
|
|
|
m_alwaysResizeColumnsToContents(true),
|
|
|
|
|
m_type(type)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-01 12:49:41 +02:00
|
|
|
m_grabbing = false;
|
|
|
|
|
|
2009-05-05 10:14:35 +02:00
|
|
|
QAction *act = theDebuggerAction(UseAlternatingRowColors);
|
2010-03-16 16:55:56 +01:00
|
|
|
setFrameStyle(QFrame::NoFrame);
|
2010-04-16 11:39:36 +02:00
|
|
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
2008-12-02 12:01:29 +01:00
|
|
|
setWindowTitle(tr("Locals and Watchers"));
|
2009-05-05 10:14:35 +02:00
|
|
|
setAlternatingRowColors(act->isChecked());
|
2008-12-02 12:01:29 +01:00
|
|
|
setIndentation(indentation() * 9/10);
|
|
|
|
|
setUniformRowHeights(true);
|
2009-03-19 15:24:18 +01:00
|
|
|
setItemDelegate(new WatchDelegate(this));
|
2009-04-29 12:20:10 +02:00
|
|
|
setDragEnabled(true);
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
setDropIndicatorShown(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-05 10:14:35 +02:00
|
|
|
connect(act, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(setAlternatingRowColorsHelper(bool)));
|
2009-10-20 16:02:35 +02:00
|
|
|
connect(this, SIGNAL(expanded(QModelIndex)),
|
|
|
|
|
this, SLOT(expandNode(QModelIndex)));
|
|
|
|
|
connect(this, SIGNAL(collapsed(QModelIndex)),
|
|
|
|
|
this, SLOT(collapseNode(QModelIndex)));
|
2010-01-29 21:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::expandNode(const QModelIndex &idx)
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsExpandedRole, true, idx);
|
2010-01-29 21:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::collapseNode(const QModelIndex &idx)
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsExpandedRole, false, idx);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-17 18:02:08 +01:00
|
|
|
void WatchWindow::keyPressEvent(QKeyEvent *ev)
|
|
|
|
|
{
|
2009-04-03 13:39:14 +02:00
|
|
|
if (ev->key() == Qt::Key_Delete && m_type == WatchersType) {
|
2008-12-17 18:02:08 +01:00
|
|
|
QModelIndex idx = currentIndex();
|
|
|
|
|
QModelIndex idx1 = idx.sibling(idx.row(), 0);
|
2010-06-16 11:08:54 +02:00
|
|
|
QString exp = idx1.data().toString();
|
2010-06-23 15:13:51 +02:00
|
|
|
removeWatchExpression(exp);
|
2009-04-07 13:38:19 +02:00
|
|
|
} else if (ev->key() == Qt::Key_Return
|
|
|
|
|
&& ev->modifiers() == Qt::ControlModifier
|
|
|
|
|
&& m_type == LocalsType) {
|
2009-04-03 13:39:14 +02:00
|
|
|
QModelIndex idx = currentIndex();
|
|
|
|
|
QModelIndex idx1 = idx.sibling(idx.row(), 0);
|
|
|
|
|
QString exp = model()->data(idx1).toString();
|
2010-06-23 15:13:51 +02:00
|
|
|
watchExpression(exp);
|
2008-12-17 18:02:08 +01:00
|
|
|
}
|
|
|
|
|
QTreeView::keyPressEvent(ev);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-29 12:20:10 +02:00
|
|
|
void WatchWindow::dragEnterEvent(QDragEnterEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
//QTreeView::dragEnterEvent(ev);
|
|
|
|
|
if (ev->mimeData()->hasFormat("text/plain")) {
|
|
|
|
|
ev->setDropAction(Qt::CopyAction);
|
|
|
|
|
ev->accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::dragMoveEvent(QDragMoveEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
//QTreeView::dragMoveEvent(ev);
|
|
|
|
|
if (ev->mimeData()->hasFormat("text/plain")) {
|
|
|
|
|
ev->setDropAction(Qt::CopyAction);
|
|
|
|
|
ev->accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::dropEvent(QDropEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
if (ev->mimeData()->hasFormat("text/plain")) {
|
2010-06-23 15:13:51 +02:00
|
|
|
watchExpression(ev->mimeData()->text());
|
2009-04-29 12:20:10 +02:00
|
|
|
//ev->acceptProposedAction();
|
|
|
|
|
ev->setDropAction(Qt::CopyAction);
|
|
|
|
|
ev->accept();
|
|
|
|
|
}
|
|
|
|
|
//QTreeView::dropEvent(ev);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-14 15:38:20 +02:00
|
|
|
void WatchWindow::mouseDoubleClickEvent(QMouseEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
const QModelIndex idx = indexAt(ev->pos());
|
|
|
|
|
if (!idx.isValid()) {
|
2010-07-23 18:20:13 +02:00
|
|
|
// The "<Edit>" case.
|
|
|
|
|
watchExpression(QString());
|
2010-07-14 15:38:20 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QTreeView::mouseDoubleClickEvent(ev);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|
|
|
|
{
|
2010-03-17 12:38:37 +01:00
|
|
|
const QModelIndex idx = indexAt(ev->pos());
|
|
|
|
|
const QModelIndex mi0 = idx.sibling(idx.row(), 0);
|
|
|
|
|
const QModelIndex mi1 = idx.sibling(idx.row(), 1);
|
|
|
|
|
const QModelIndex mi2 = idx.sibling(idx.row(), 2);
|
2010-06-16 11:08:54 +02:00
|
|
|
const quint64 address = mi0.data(LocalsAddressRole).toULongLong();
|
|
|
|
|
const quint64 pointerValue = mi0.data(LocalsPointerValueRole).toULongLong();
|
|
|
|
|
const QString exp = mi0.data(LocalsExpressionRole).toString();
|
|
|
|
|
const QString type = mi2.data().toString();
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2010-03-17 12:38:37 +01:00
|
|
|
const QStringList alternativeFormats =
|
2010-06-16 11:08:54 +02:00
|
|
|
mi0.data(LocalsTypeFormatListRole).toStringList();
|
2009-12-08 16:00:06 +01:00
|
|
|
const int typeFormat =
|
2010-06-16 11:08:54 +02:00
|
|
|
mi0.data(LocalsTypeFormatRole).toInt();
|
2009-12-08 16:00:06 +01:00
|
|
|
const int individualFormat =
|
2010-06-16 11:08:54 +02:00
|
|
|
mi0.data(LocalsIndividualFormatRole).toInt();
|
2009-12-08 16:00:06 +01:00
|
|
|
const int effectiveIndividualFormat =
|
|
|
|
|
individualFormat == -1 ? typeFormat : individualFormat;
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2009-07-08 09:02:36 +02:00
|
|
|
QMenu typeFormatMenu;
|
2009-07-03 11:20:47 +02:00
|
|
|
QList<QAction *> typeFormatActions;
|
2010-05-19 15:15:56 +02:00
|
|
|
QAction *clearTypeFormatAction = 0;
|
2009-07-08 09:02:36 +02:00
|
|
|
if (idx.isValid()) {
|
2010-03-17 12:38:37 +01:00
|
|
|
typeFormatMenu.setTitle(
|
2010-03-29 17:45:55 +02:00
|
|
|
tr("Change Format for Type \"%1\"").arg(type));
|
2009-10-07 14:29:55 +02:00
|
|
|
if (alternativeFormats.isEmpty()) {
|
|
|
|
|
typeFormatMenu.setEnabled(false);
|
2009-11-25 16:32:44 +01:00
|
|
|
} else {
|
2010-06-25 09:07:14 +02:00
|
|
|
clearTypeFormatAction = typeFormatMenu.addAction(tr("Automatic"));
|
2010-05-19 15:15:56 +02:00
|
|
|
clearTypeFormatAction->setEnabled(typeFormat != -1);
|
|
|
|
|
clearTypeFormatAction->setCheckable(true);
|
|
|
|
|
clearTypeFormatAction->setChecked(typeFormat == -1);
|
|
|
|
|
typeFormatMenu.addSeparator();
|
2009-11-25 16:32:44 +01:00
|
|
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
|
|
|
|
const QString format = alternativeFormats.at(i);
|
|
|
|
|
QAction *act = new QAction(format, &typeFormatMenu);
|
|
|
|
|
act->setCheckable(true);
|
|
|
|
|
if (i == typeFormat)
|
|
|
|
|
act->setChecked(true);
|
|
|
|
|
typeFormatMenu.addAction(act);
|
|
|
|
|
typeFormatActions.append(act);
|
2010-03-17 13:03:34 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
typeFormatMenu.setTitle(tr("Change Format for Type"));
|
|
|
|
|
typeFormatMenu.setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMenu individualFormatMenu;
|
|
|
|
|
QList<QAction *> individualFormatActions;
|
|
|
|
|
QAction *clearIndividualFormatAction = 0;
|
2010-06-25 09:07:14 +02:00
|
|
|
if (idx.isValid()) {
|
2010-03-17 13:03:34 +01:00
|
|
|
individualFormatMenu.setTitle(
|
2010-06-25 09:07:14 +02:00
|
|
|
tr("Change Format for Object Named \"%1\"").arg(mi0.data().toString()));
|
2010-03-17 13:03:34 +01:00
|
|
|
if (alternativeFormats.isEmpty()) {
|
|
|
|
|
individualFormatMenu.setEnabled(false);
|
|
|
|
|
} else {
|
2010-06-25 09:07:14 +02:00
|
|
|
clearIndividualFormatAction
|
|
|
|
|
= individualFormatMenu.addAction(tr("Automatic"));
|
2010-03-17 13:03:34 +01:00
|
|
|
clearIndividualFormatAction->setEnabled(individualFormat != -1);
|
2010-05-19 15:15:56 +02:00
|
|
|
clearIndividualFormatAction->setCheckable(true);
|
|
|
|
|
clearIndividualFormatAction->setChecked(individualFormat == -1);
|
2010-03-17 13:03:34 +01:00
|
|
|
individualFormatMenu.addSeparator();
|
|
|
|
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
|
|
|
|
const QString format = alternativeFormats.at(i);
|
|
|
|
|
QAction *act = new QAction(format, &individualFormatMenu);
|
2009-11-25 16:32:44 +01:00
|
|
|
act->setCheckable(true);
|
|
|
|
|
if (i == effectiveIndividualFormat)
|
|
|
|
|
act->setChecked(true);
|
|
|
|
|
individualFormatMenu.addAction(act);
|
|
|
|
|
individualFormatActions.append(act);
|
|
|
|
|
}
|
2009-10-07 14:29:55 +02:00
|
|
|
}
|
2009-07-08 09:02:36 +02:00
|
|
|
} else {
|
2010-03-17 12:38:37 +01:00
|
|
|
individualFormatMenu.setTitle(tr("Change Format for Object"));
|
2009-07-08 09:02:36 +02:00
|
|
|
individualFormatMenu.setEnabled(false);
|
2009-07-03 11:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
const bool actionsEnabled = modelData(EngineActionsEnabledRole).toBool();
|
|
|
|
|
const unsigned engineCapabilities = modelData(EngineCapabilitiesRole).toUInt();
|
2010-07-14 14:52:14 +02:00
|
|
|
const bool canHandleWatches =
|
|
|
|
|
actionsEnabled && (engineCapabilities & AddWatcherCapability);
|
2010-11-04 11:27:23 +01:00
|
|
|
const DebuggerState state =
|
|
|
|
|
static_cast<DebuggerState>(modelData(EngineStateRole).toInt());
|
2010-04-16 16:36:00 +02:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
QMenu menu;
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *actInsertNewWatchItem = menu.addAction(tr("Insert New Watch Item"));
|
2010-04-16 16:36:00 +02:00
|
|
|
actInsertNewWatchItem->setEnabled(canHandleWatches);
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *actSelectWidgetToWatch = menu.addAction(tr("Select Widget to Watch"));
|
2010-04-16 16:36:00 +02:00
|
|
|
actSelectWidgetToWatch->setEnabled(canHandleWatches);
|
2009-08-12 10:51:25 +02:00
|
|
|
|
2010-05-19 17:34:47 +02:00
|
|
|
QAction *actOpenMemoryEditAtVariableAddress = 0;
|
|
|
|
|
QAction *actOpenMemoryEditAtPointerValue = 0;
|
|
|
|
|
QAction *actOpenMemoryEditor =
|
2010-05-07 15:16:31 +02:00
|
|
|
new QAction(tr("Open Memory Editor..."), &menu);
|
2010-02-05 10:23:55 +01:00
|
|
|
const bool canShowMemory = engineCapabilities & ShowMemoryCapability;
|
2010-05-19 17:34:47 +02:00
|
|
|
actOpenMemoryEditor->setEnabled(actionsEnabled && canShowMemory);
|
|
|
|
|
|
|
|
|
|
// Offer to open address pointed to or variable address.
|
2010-06-16 11:08:54 +02:00
|
|
|
const bool createPointerActions = pointerValue && pointerValue != address;
|
2010-05-19 17:34:47 +02:00
|
|
|
|
|
|
|
|
if (canShowMemory && address)
|
|
|
|
|
actOpenMemoryEditAtVariableAddress =
|
2010-06-25 09:07:14 +02:00
|
|
|
new QAction(tr("Open Memory Editor at Object's Address (0x%1)")
|
|
|
|
|
.arg(address, 0, 16), &menu);
|
2010-05-19 17:34:47 +02:00
|
|
|
if (createPointerActions)
|
|
|
|
|
actOpenMemoryEditAtPointerValue =
|
2010-06-25 09:07:14 +02:00
|
|
|
new QAction(tr("Open Memory Editor at Referenced Address (0x%1)")
|
|
|
|
|
.arg(pointerValue, 0, 16), &menu);
|
2009-07-03 11:20:47 +02:00
|
|
|
menu.addSeparator();
|
2009-08-18 16:46:33 +02:00
|
|
|
|
2010-05-19 17:34:47 +02:00
|
|
|
QAction *actSetWatchPointAtVariableAddress = 0;
|
2010-06-16 11:08:54 +02:00
|
|
|
QAction *actSetWatchPointAtPointerValue = 0;
|
2010-05-07 15:16:31 +02:00
|
|
|
const bool canSetWatchpoint = engineCapabilities & WatchpointCapability;
|
2010-05-19 17:34:47 +02:00
|
|
|
if (canSetWatchpoint && address) {
|
|
|
|
|
actSetWatchPointAtVariableAddress =
|
2010-11-04 11:27:23 +01:00
|
|
|
new QAction(tr("Add Watchpoint at Object's Address (0x%1)")
|
2010-06-23 15:13:51 +02:00
|
|
|
.arg(address, 0, 16), &menu);
|
2010-06-16 11:08:54 +02:00
|
|
|
actSetWatchPointAtVariableAddress->
|
|
|
|
|
setChecked(mi0.data(LocalsIsWatchpointAtAddressRole).toBool());
|
2010-05-20 19:35:34 +02:00
|
|
|
if (createPointerActions) {
|
2010-05-19 17:34:47 +02:00
|
|
|
actSetWatchPointAtPointerValue =
|
2010-11-04 11:27:23 +01:00
|
|
|
new QAction(tr("Add Watchpoint at Referenced Address (0x%1)")
|
2010-06-23 15:13:51 +02:00
|
|
|
.arg(pointerValue, 0, 16), &menu);
|
2010-05-20 19:35:34 +02:00
|
|
|
actSetWatchPointAtPointerValue->setCheckable(true);
|
2010-06-16 11:08:54 +02:00
|
|
|
actSetWatchPointAtPointerValue->
|
|
|
|
|
setChecked(mi0.data(LocalsIsWatchpointAtPointerValueRole).toBool());
|
2010-05-20 19:35:34 +02:00
|
|
|
}
|
2010-05-07 15:16:31 +02:00
|
|
|
} else {
|
2010-05-19 17:34:47 +02:00
|
|
|
actSetWatchPointAtVariableAddress =
|
2010-11-04 11:27:23 +01:00
|
|
|
new QAction(tr("At Watchpoint"), &menu);
|
2010-05-19 17:34:47 +02:00
|
|
|
actSetWatchPointAtVariableAddress->setEnabled(false);
|
2010-05-07 15:16:31 +02:00
|
|
|
}
|
2010-11-04 11:27:23 +01:00
|
|
|
actSetWatchPointAtVariableAddress->setToolTip(
|
|
|
|
|
tr("Setting a watchpoint on an address will cause the program "
|
|
|
|
|
"to stop when the data at the address it modified"));
|
2010-05-07 15:16:31 +02:00
|
|
|
|
2010-07-14 14:52:14 +02:00
|
|
|
QString actionName = exp.isEmpty() ? tr("Watch Expression")
|
|
|
|
|
: tr("Watch Expression \"%1\"").arg(exp);
|
|
|
|
|
QAction *actWatchExpression = new QAction(actionName, &menu);
|
|
|
|
|
actWatchExpression->setEnabled(canHandleWatches && !exp.isEmpty());
|
2010-06-23 15:13:51 +02:00
|
|
|
|
2010-10-11 12:59:49 +02:00
|
|
|
// Can remove watch if engine can handle it or session engine.
|
2010-07-14 14:52:14 +02:00
|
|
|
actionName = exp.isEmpty() ? tr("Remove Watch Expression")
|
|
|
|
|
: tr("Remove Watch Expression \"%1\"").arg(exp);
|
|
|
|
|
QAction *actRemoveWatchExpression = new QAction(actionName, &menu);
|
2010-11-04 11:27:23 +01:00
|
|
|
actRemoveWatchExpression->setEnabled(
|
|
|
|
|
(canHandleWatches || state == DebuggerNotReady) && !exp.isEmpty());
|
2010-06-23 15:13:51 +02:00
|
|
|
|
|
|
|
|
if (m_type == LocalsType)
|
|
|
|
|
menu.addAction(actWatchExpression);
|
|
|
|
|
else
|
|
|
|
|
menu.addAction(actRemoveWatchExpression);
|
2009-07-03 11:20:47 +02:00
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
menu.addAction(actInsertNewWatchItem);
|
|
|
|
|
menu.addAction(actSelectWidgetToWatch);
|
2009-07-03 11:20:47 +02:00
|
|
|
menu.addMenu(&typeFormatMenu);
|
|
|
|
|
menu.addMenu(&individualFormatMenu);
|
2010-05-19 17:34:47 +02:00
|
|
|
if (actOpenMemoryEditAtVariableAddress)
|
|
|
|
|
menu.addAction(actOpenMemoryEditAtVariableAddress);
|
|
|
|
|
if (actOpenMemoryEditAtPointerValue)
|
|
|
|
|
menu.addAction(actOpenMemoryEditAtPointerValue);
|
|
|
|
|
menu.addAction(actOpenMemoryEditor);
|
|
|
|
|
menu.addAction(actSetWatchPointAtVariableAddress);
|
|
|
|
|
if (actSetWatchPointAtPointerValue)
|
|
|
|
|
menu.addAction(actSetWatchPointAtPointerValue);
|
2009-02-27 11:41:19 +01:00
|
|
|
menu.addSeparator();
|
2009-10-07 13:36:48 +02:00
|
|
|
|
2009-04-07 16:39:17 +02:00
|
|
|
menu.addAction(theDebuggerAction(UseDebuggingHelpers));
|
2009-10-01 11:22:44 +02:00
|
|
|
menu.addAction(theDebuggerAction(UseToolTipsInLocalsView));
|
2009-10-06 10:54:08 +02:00
|
|
|
menu.addAction(theDebuggerAction(AutoDerefPointers));
|
2009-11-25 08:35:02 +01:00
|
|
|
menu.addAction(theDebuggerAction(ShowStdNamespace));
|
|
|
|
|
menu.addAction(theDebuggerAction(ShowQtNamespace));
|
2010-09-23 11:15:56 +02:00
|
|
|
menu.addAction(theDebuggerAction(SortStructMembers));
|
2009-10-07 13:36:48 +02:00
|
|
|
|
2009-08-18 16:46:33 +02:00
|
|
|
QAction *actAdjustColumnWidths =
|
2010-02-12 10:52:09 +01:00
|
|
|
menu.addAction(tr("Adjust Column Widths to Contents"));
|
2009-08-18 16:46:33 +02:00
|
|
|
QAction *actAlwaysAdjustColumnWidth =
|
2010-02-12 10:52:09 +01:00
|
|
|
menu.addAction(tr("Always Adjust Column Widths to Contents"));
|
2009-08-18 16:46:33 +02:00
|
|
|
actAlwaysAdjustColumnWidth->setCheckable(true);
|
|
|
|
|
actAlwaysAdjustColumnWidth->setChecked(m_alwaysResizeColumnsToContents);
|
|
|
|
|
|
2009-03-18 09:03:47 +01:00
|
|
|
menu.addSeparator();
|
2010-09-28 13:09:19 +02:00
|
|
|
QAction *actClearCodeModelSnapshot
|
|
|
|
|
= new QAction(tr("Refresh Code Model Snapshot"), &menu);
|
|
|
|
|
actClearCodeModelSnapshot->setEnabled(actionsEnabled
|
|
|
|
|
&& theDebuggerAction(UseCodeModel)->isChecked());
|
|
|
|
|
menu.addAction(actClearCodeModelSnapshot);
|
|
|
|
|
QAction *actShowInEditor
|
|
|
|
|
= new QAction(tr("Show View Contents in Editor"), &menu);
|
|
|
|
|
actShowInEditor->setEnabled(actionsEnabled);
|
|
|
|
|
menu.addAction(actShowInEditor);
|
2009-03-19 15:54:52 +01:00
|
|
|
menu.addAction(theDebuggerAction(SettingsDialog));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QAction *act = menu.exec(ev->globalPos());
|
2010-05-19 17:34:47 +02:00
|
|
|
if (act == 0)
|
|
|
|
|
return;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
if (act == actAdjustColumnWidths) {
|
2008-12-02 12:01:29 +01:00
|
|
|
resizeColumnsToContents();
|
2009-08-12 10:51:25 +02:00
|
|
|
} else if (act == actAlwaysAdjustColumnWidth) {
|
2008-12-02 12:01:29 +01:00
|
|
|
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
|
2009-08-12 10:51:25 +02:00
|
|
|
} else if (act == actInsertNewWatchItem) {
|
2010-07-23 18:20:13 +02:00
|
|
|
watchExpression(QString());
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == actOpenMemoryEditAtVariableAddress) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(RequestShowMemoryRole, address);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == actOpenMemoryEditAtPointerValue) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(RequestShowMemoryRole, pointerValue);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == actOpenMemoryEditor) {
|
2009-08-19 14:41:51 +02:00
|
|
|
AddressDialog dialog;
|
2010-06-16 11:08:54 +02:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
|
setModelData(RequestShowMemoryRole, dialog.address());
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == actSetWatchPointAtVariableAddress) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(RequestToggleWatchRole, address);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == actSetWatchPointAtPointerValue) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(RequestToggleWatchRole, pointerValue);
|
2009-08-12 10:51:25 +02:00
|
|
|
} else if (act == actSelectWidgetToWatch) {
|
2009-07-01 12:49:41 +02:00
|
|
|
grabMouse(Qt::CrossCursor);
|
|
|
|
|
m_grabbing = true;
|
2010-06-23 15:13:51 +02:00
|
|
|
} else if (act == actWatchExpression) {
|
|
|
|
|
watchExpression(exp);
|
|
|
|
|
} else if (act == actRemoveWatchExpression) {
|
|
|
|
|
removeWatchExpression(exp);
|
2009-10-16 16:26:28 +02:00
|
|
|
} else if (act == actClearCodeModelSnapshot) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(RequestClearCppCodeModelSnapshotRole);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == clearTypeFormatAction) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsTypeFormatRole, -1, mi1);
|
2010-05-19 17:34:47 +02:00
|
|
|
} else if (act == clearIndividualFormatAction) {
|
2010-06-16 11:08:54 +02:00
|
|
|
setModelData(LocalsIndividualFormatRole, -1, mi1);
|
2010-09-08 09:09:09 +02:00
|
|
|
} else if (act == actShowInEditor) {
|
|
|
|
|
setModelData(RequestShowInEditorRole);
|
2010-01-29 21:33:57 +01:00
|
|
|
} else {
|
2010-03-17 13:03:34 +01:00
|
|
|
for (int i = 0; i != typeFormatActions.size(); ++i) {
|
2009-07-03 11:20:47 +02:00
|
|
|
if (act == typeFormatActions.at(i))
|
2010-06-23 16:30:42 +02:00
|
|
|
setModelData(LocalsTypeFormatRole, i, mi1);
|
2010-03-17 13:03:34 +01:00
|
|
|
}
|
|
|
|
|
for (int i = 0; i != individualFormatActions.size(); ++i) {
|
|
|
|
|
if (act == individualFormatActions.at(i))
|
2010-06-23 16:30:42 +02:00
|
|
|
setModelData(LocalsIndividualFormatRole, i, mi1);
|
2009-07-03 11:20:47 +02:00
|
|
|
}
|
2009-07-01 12:49:41 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::resizeColumnsToContents()
|
|
|
|
|
{
|
|
|
|
|
resizeColumnToContents(0);
|
|
|
|
|
resizeColumnToContents(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::setAlwaysResizeColumnsToContents(bool on)
|
|
|
|
|
{
|
|
|
|
|
if (!header())
|
|
|
|
|
return;
|
|
|
|
|
m_alwaysResizeColumnsToContents = on;
|
2010-01-29 21:33:57 +01:00
|
|
|
QHeaderView::ResizeMode mode = on
|
2008-12-02 12:01:29 +01:00
|
|
|
? QHeaderView::ResizeToContents : QHeaderView::Interactive;
|
|
|
|
|
header()->setResizeMode(0, mode);
|
|
|
|
|
header()->setResizeMode(1, mode);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-01 12:49:41 +02:00
|
|
|
bool WatchWindow::event(QEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
if (m_grabbing && ev->type() == QEvent::MouseButtonPress) {
|
|
|
|
|
QMouseEvent *mev = static_cast<QMouseEvent *>(ev);
|
|
|
|
|
m_grabbing = false;
|
|
|
|
|
releaseMouse();
|
2010-06-23 15:13:51 +02:00
|
|
|
setModelData(RequestWatchPointRole, mapToGlobal(mev->pos()));
|
2009-07-01 12:49:41 +02:00
|
|
|
}
|
|
|
|
|
return QTreeView::event(ev);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void WatchWindow::editItem(const QModelIndex &idx)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(idx) // FIXME
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-13 09:11:07 +02:00
|
|
|
void WatchWindow::setModel(QAbstractItemModel *model)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 09:11:07 +02:00
|
|
|
QTreeView::setModel(model);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
setRootIsDecorated(true);
|
|
|
|
|
header()->setDefaultAlignment(Qt::AlignLeft);
|
|
|
|
|
header()->setResizeMode(QHeaderView::ResizeToContents);
|
|
|
|
|
if (m_type != LocalsType)
|
|
|
|
|
header()->hide();
|
2009-03-25 13:05:12 +01:00
|
|
|
|
2009-08-31 09:14:04 +02:00
|
|
|
connect(model, SIGNAL(layoutChanged()),
|
|
|
|
|
this, SLOT(resetHelper()));
|
|
|
|
|
connect(model, SIGNAL(enableUpdates(bool)),
|
|
|
|
|
this, SLOT(setUpdatesEnabled(bool)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::setUpdatesEnabled(bool enable)
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << "ENABLING UPDATES: " << enable;
|
|
|
|
|
QTreeView::setUpdatesEnabled(enable);
|
2009-03-25 13:05:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::resetHelper()
|
|
|
|
|
{
|
|
|
|
|
resetHelper(model()->index(0, 0));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-08 11:00:46 +01:00
|
|
|
void WatchWindow::resetHelper(const QModelIndex &idx)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
if (idx.data(LocalsExpandedRole).toBool()) {
|
2009-03-25 13:05:12 +01:00
|
|
|
//qDebug() << "EXPANDING " << model()->data(idx, INameRole);
|
2008-12-02 12:01:29 +01:00
|
|
|
expand(idx);
|
|
|
|
|
for (int i = 0, n = model()->rowCount(idx); i != n; ++i) {
|
|
|
|
|
QModelIndex idx1 = model()->index(i, 0, idx);
|
2008-12-08 11:00:46 +01:00
|
|
|
resetHelper(idx1);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-03-25 13:05:12 +01:00
|
|
|
} else {
|
|
|
|
|
//qDebug() << "COLLAPSING " << model()->data(idx, INameRole);
|
|
|
|
|
collapse(idx);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-06-23 15:13:51 +02:00
|
|
|
void WatchWindow::watchExpression(const QString &exp)
|
|
|
|
|
{
|
|
|
|
|
setModelData(RequestWatchExpressionRole, exp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::removeWatchExpression(const QString &exp)
|
|
|
|
|
{
|
|
|
|
|
setModelData(RequestRemoveWatchExpressionRole, exp);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void WatchWindow::setModelData
|
|
|
|
|
(int role, const QVariant &value, const QModelIndex &index)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(model(), return);
|
|
|
|
|
model()->setData(index, value, role);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant WatchWindow::modelData(int role, const QModelIndex &index)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(model(), return QVariant());
|
|
|
|
|
return model()->data(index, role);
|
|
|
|
|
}
|
|
|
|
|
|