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-06-18 10:34:53 +02:00
|
|
|
#include "watchhandler.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-17 17:00:06 +01:00
|
|
|
#include "debuggeractions.h"
|
2009-08-12 10:51:25 +02:00
|
|
|
#include "debuggeragents.h"
|
2009-08-19 14:41:51 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2009-09-25 16:01:28 +02:00
|
|
|
#include "debuggermanager.h"
|
2009-10-06 10:54:08 +02:00
|
|
|
#include "idebuggerengine.h"
|
2009-03-17 17:00:06 +01:00
|
|
|
|
2009-03-19 15:24:18 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QContextMenuEvent>
|
2009-08-12 10:51:25 +02:00
|
|
|
#include <QtGui/QDialog>
|
|
|
|
|
#include <QtGui/QHBoxLayout>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QHeaderView>
|
2009-03-19 15:24:18 +01:00
|
|
|
#include <QtGui/QItemDelegate>
|
2009-08-12 10:51:25 +02:00
|
|
|
#include <QtGui/QLabel>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QLineEdit>
|
|
|
|
|
#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:
|
|
|
|
|
WatchDelegate(QObject *parent) : QItemDelegate(parent) {}
|
|
|
|
|
|
|
|
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
|
|
|
|
|
const QModelIndex &) const
|
|
|
|
|
{
|
|
|
|
|
return new QLineEdit(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setEditorData(QWidget *editor, const QModelIndex &index) const
|
|
|
|
|
{
|
|
|
|
|
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor);
|
|
|
|
|
QTC_ASSERT(lineEdit, return);
|
2010-01-29 21:33:57 +01:00
|
|
|
if (index.column() == 1)
|
2009-03-19 15:33:11 +01:00
|
|
|
lineEdit->setText(index.model()->data(index, Qt::DisplayRole).toString());
|
|
|
|
|
else
|
|
|
|
|
lineEdit->setText(index.model()->data(index, ExpressionRole).toString());
|
2009-03-19 15:24:18 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-07 13:38:19 +02:00
|
|
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
2009-03-19 15:24:18 +01:00
|
|
|
const QModelIndex &index) const
|
|
|
|
|
{
|
2009-04-07 13:38:19 +02:00
|
|
|
//qDebug() << "SET MODEL DATA";
|
2009-03-19 15:24:18 +01:00
|
|
|
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
|
|
|
|
|
QTC_ASSERT(lineEdit, return);
|
|
|
|
|
QString value = lineEdit->text();
|
2009-04-07 13:38:19 +02:00
|
|
|
QString exp = model->data(index, ExpressionRole).toString();
|
|
|
|
|
model->setData(index, value, Qt::EditRole);
|
2009-03-19 15:24:18 +01:00
|
|
|
if (index.column() == 1) {
|
2009-09-29 16:38:29 +02:00
|
|
|
// The value column.
|
2009-05-29 10:35:04 +02:00
|
|
|
theDebuggerAction(AssignValue)->trigger(QString(exp + '=' + value));
|
2009-04-03 13:39:14 +02:00
|
|
|
} else if (index.column() == 2) {
|
2009-09-29 16:38:29 +02:00
|
|
|
// The type column.
|
2009-05-29 10:35:04 +02:00
|
|
|
theDebuggerAction(AssignType)->trigger(QString(exp + '=' + value));
|
2009-03-19 15:24:18 +01:00
|
|
|
} else if (index.column() == 0) {
|
2009-09-29 16:38:29 +02:00
|
|
|
// The watcher name column.
|
2009-03-19 15:44:26 +01:00
|
|
|
theDebuggerAction(RemoveWatchExpression)->trigger(exp);
|
2009-04-16 14:42:19 +02:00
|
|
|
theDebuggerAction(WatchExpression)->trigger(value);
|
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
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
WatchWindow::WatchWindow(Type type, DebuggerManager *manager, QWidget *parent)
|
|
|
|
|
: QTreeView(parent), m_alwaysResizeColumnsToContents(true), m_type(type),
|
|
|
|
|
m_manager(manager)
|
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);
|
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)
|
|
|
|
|
{
|
2009-06-17 16:00:03 +02:00
|
|
|
model()->setData(idx, true, ExpandedRole);
|
2010-01-29 21:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatchWindow::collapseNode(const QModelIndex &idx)
|
|
|
|
|
{
|
2009-06-17 16:00:03 +02:00
|
|
|
model()->setData(idx, false, ExpandedRole);
|
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);
|
|
|
|
|
QString exp = model()->data(idx1).toString();
|
2009-04-03 13:39:14 +02:00
|
|
|
theDebuggerAction(RemoveWatchExpression)->trigger(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();
|
|
|
|
|
theDebuggerAction(WatchExpression)->trigger(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")) {
|
|
|
|
|
theDebuggerAction(WatchExpression)->trigger(ev->mimeData()->text());
|
|
|
|
|
//ev->acceptProposedAction();
|
|
|
|
|
ev->setDropAction(Qt::CopyAction);
|
|
|
|
|
ev->accept();
|
|
|
|
|
}
|
|
|
|
|
//QTreeView::dropEvent(ev);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|
|
|
|
{
|
2009-07-03 11:20:47 +02:00
|
|
|
QModelIndex idx = indexAt(ev->pos());
|
|
|
|
|
QModelIndex mi0 = idx.sibling(idx.row(), 0);
|
|
|
|
|
QModelIndex mi1 = idx.sibling(idx.row(), 1);
|
|
|
|
|
QModelIndex mi2 = idx.sibling(idx.row(), 2);
|
2009-09-29 16:38:29 +02:00
|
|
|
QString exp = model()->data(mi0, ExpressionRole).toString();
|
2009-07-03 11:20:47 +02:00
|
|
|
QString type = model()->data(mi2).toString();
|
|
|
|
|
|
2010-01-29 21:33:57 +01:00
|
|
|
QStringList alternativeFormats =
|
2009-07-03 11:20:47 +02:00
|
|
|
model()->data(mi0, TypeFormatListRole).toStringList();
|
2009-12-08 16:00:06 +01:00
|
|
|
const int typeFormat =
|
|
|
|
|
qMax(int(DecimalFormat), model()->data(mi0, TypeFormatRole).toInt());
|
|
|
|
|
const int individualFormat =
|
|
|
|
|
model()->data(mi0, IndividualFormatRole).toInt();
|
|
|
|
|
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;
|
|
|
|
|
QMenu individualFormatMenu;
|
2009-07-03 11:20:47 +02:00
|
|
|
QList<QAction *> typeFormatActions;
|
|
|
|
|
QList<QAction *> individualFormatActions;
|
2009-11-25 16:32:44 +01:00
|
|
|
QAction *clearIndividualFormatAction = 0;
|
2009-07-08 09:02:36 +02:00
|
|
|
if (idx.isValid()) {
|
2010-02-12 10:52:09 +01:00
|
|
|
typeFormatMenu.setTitle(tr("Change Format for Type '%1'").arg(type));
|
|
|
|
|
individualFormatMenu.setTitle(tr("Change Format for Expression '%1'").arg(exp));
|
2009-10-07 14:29:55 +02:00
|
|
|
if (alternativeFormats.isEmpty()) {
|
|
|
|
|
typeFormatMenu.setEnabled(false);
|
|
|
|
|
individualFormatMenu.setEnabled(false);
|
2009-11-25 16:32:44 +01:00
|
|
|
} else {
|
|
|
|
|
clearIndividualFormatAction = individualFormatMenu.addAction(tr("Clear"));
|
|
|
|
|
clearIndividualFormatAction->setEnabled(individualFormat != -1);
|
|
|
|
|
individualFormatMenu.addSeparator();
|
|
|
|
|
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);
|
|
|
|
|
act = new QAction(format, &individualFormatMenu);
|
|
|
|
|
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 {
|
|
|
|
|
typeFormatMenu.setTitle(tr("Change format for type"));
|
|
|
|
|
typeFormatMenu.setEnabled(false);
|
|
|
|
|
individualFormatMenu.setTitle(tr("Change format for expression"));
|
|
|
|
|
individualFormatMenu.setEnabled(false);
|
2009-07-03 11:20:47 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QMenu menu;
|
2009-08-12 10:51:25 +02:00
|
|
|
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *actInsertNewWatchItem = menu.addAction(tr("Insert New Watch Item"));
|
|
|
|
|
QAction *actSelectWidgetToWatch = menu.addAction(tr("Select Widget to Watch"));
|
2009-08-12 10:51:25 +02:00
|
|
|
|
2009-10-16 16:26:28 +02:00
|
|
|
const bool actionsEnabled = m_manager->debuggerActionsEnabled();
|
2010-02-05 10:23:55 +01:00
|
|
|
const unsigned engineCapabilities = m_manager->debuggerCapabilities();
|
2009-08-19 14:41:51 +02:00
|
|
|
const QString address = model()->data(mi0, AddressRole).toString();
|
2009-08-12 10:51:25 +02:00
|
|
|
QAction *actWatchKnownMemory = 0;
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *actWatchUnknownMemory = new QAction(tr("Open Memory Editor..."), &menu);
|
2010-02-05 10:23:55 +01:00
|
|
|
const bool canShowMemory = engineCapabilities & ShowMemoryCapability;
|
|
|
|
|
actWatchUnknownMemory->setEnabled(actionsEnabled && canShowMemory);
|
2009-10-07 13:36:48 +02:00
|
|
|
|
2010-02-05 10:23:55 +01:00
|
|
|
if (canShowMemory && !address.isEmpty())
|
2010-03-11 18:55:52 +01:00
|
|
|
actWatchKnownMemory =
|
|
|
|
|
new QAction(tr("Open Memory Editor at %1").arg(address), &menu);
|
2009-07-03 11:20:47 +02:00
|
|
|
menu.addSeparator();
|
2009-08-18 16:46:33 +02:00
|
|
|
|
2009-12-04 13:36:14 +01:00
|
|
|
QAction *actWatchOrRemove;
|
2010-01-29 22:49:55 +01:00
|
|
|
if (m_type == LocalsType) {
|
2009-12-04 13:36:14 +01:00
|
|
|
actWatchOrRemove = theDebuggerAction(WatchExpression)->updatedAction(exp);
|
|
|
|
|
} else {
|
|
|
|
|
actWatchOrRemove = theDebuggerAction(RemoveWatchExpression)->updatedAction(exp);
|
|
|
|
|
// Also for the case where the user cleared the expression.
|
|
|
|
|
actWatchOrRemove->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
menu.addAction(actWatchOrRemove);
|
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);
|
2009-08-19 14:41:51 +02:00
|
|
|
if (actWatchKnownMemory)
|
|
|
|
|
menu.addAction(actWatchKnownMemory);
|
|
|
|
|
menu.addAction(actWatchUnknownMemory);
|
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(RecheckDebuggingHelpers));
|
|
|
|
|
menu.addAction(theDebuggerAction(UseDebuggingHelpers));
|
2010-03-11 18:55:52 +01:00
|
|
|
QAction *actClearCodeModelSnapshot
|
|
|
|
|
= new QAction(tr("Refresh Code Model Snapshot"), &menu);
|
|
|
|
|
actClearCodeModelSnapshot->setEnabled(actionsEnabled
|
|
|
|
|
&& theDebuggerAction(UseCodeModel)->isChecked());
|
2009-10-16 16:26:28 +02:00
|
|
|
menu.addAction(actClearCodeModelSnapshot);
|
2009-08-18 16:46:33 +02:00
|
|
|
menu.addSeparator();
|
2009-10-01 11:22:44 +02:00
|
|
|
menu.addAction(theDebuggerAction(UseToolTipsInLocalsView));
|
2010-01-29 21:33:57 +01:00
|
|
|
|
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));
|
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();
|
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());
|
|
|
|
|
|
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) {
|
2009-07-01 12:49:41 +02:00
|
|
|
theDebuggerAction(WatchExpression)
|
|
|
|
|
->trigger(WatchHandler::watcherEditPlaceHolder());
|
2009-08-19 14:41:51 +02:00
|
|
|
} else if (actWatchKnownMemory != 0 && act == actWatchKnownMemory) {
|
2009-08-14 13:04:05 +02:00
|
|
|
(void) new MemoryViewAgent(m_manager, address);
|
2009-08-19 14:41:51 +02:00
|
|
|
} else if (actWatchUnknownMemory != 0 && act == actWatchUnknownMemory) {
|
|
|
|
|
AddressDialog dialog;
|
|
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
|
(void) new MemoryViewAgent(m_manager, dialog.address());
|
|
|
|
|
}
|
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;
|
2009-10-16 16:26:28 +02:00
|
|
|
} else if (act == actClearCodeModelSnapshot) {
|
|
|
|
|
m_manager->clearCppCodeModelSnapshot();
|
2009-11-25 16:32:44 +01:00
|
|
|
} else if (clearIndividualFormatAction && act == clearIndividualFormatAction) {
|
|
|
|
|
model()->setData(mi1, -1, IndividualFormatRole);
|
2010-01-29 21:33:57 +01:00
|
|
|
} else {
|
2009-07-03 11:20:47 +02:00
|
|
|
for (int i = 0; i != alternativeFormats.size(); ++i) {
|
|
|
|
|
if (act == typeFormatActions.at(i))
|
|
|
|
|
model()->setData(mi1, i, TypeFormatRole);
|
|
|
|
|
else if (act == individualFormatActions.at(i))
|
|
|
|
|
model()->setData(mi1, i, IndividualFormatRole);
|
|
|
|
|
}
|
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();
|
|
|
|
|
theDebuggerAction(WatchPoint)->trigger(mapToGlobal(mev->pos()));
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2008-12-08 11:00:46 +01:00
|
|
|
if (model()->data(idx, ExpandedRole).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
|
|
|
}
|
|
|
|
|
}
|