2010-02-02 17:25:14 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "snapshotwindow.h"
|
2010-11-05 19:38:40 +01:00
|
|
|
#include "snapshothandler.h"
|
2010-02-02 17:25:14 +01:00
|
|
|
|
|
|
|
|
#include "debuggeractions.h"
|
2010-11-10 16:33:11 +01:00
|
|
|
#include "debuggercore.h"
|
2010-12-10 10:01:29 +01:00
|
|
|
#include "debuggerengine.h"
|
2010-02-02 17:25:14 +01:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <utils/savedaction.h>
|
2010-02-02 17:25:14 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QHeaderView>
|
|
|
|
|
#include <QtGui/QMenu>
|
2010-11-02 16:14:00 +01:00
|
|
|
#include <QtGui/QKeyEvent>
|
2010-02-02 17:25:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// SnapshotWindow
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
SnapshotWindow::SnapshotWindow(SnapshotHandler *handler)
|
2010-02-02 17:25:14 +01:00
|
|
|
{
|
2010-11-05 19:38:40 +01:00
|
|
|
m_snapshotHandler = handler;
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
QAction *act = debuggerCore()->action(UseAlternatingRowColors);
|
2010-02-02 17:25:14 +01:00
|
|
|
setWindowTitle(tr("Snapshots"));
|
2010-04-16 11:39:36 +02:00
|
|
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
2010-03-16 16:55:56 +01:00
|
|
|
setFrameStyle(QFrame::NoFrame);
|
2010-02-02 17:25:14 +01:00
|
|
|
setAlternatingRowColors(act->isChecked());
|
|
|
|
|
setRootIsDecorated(false);
|
|
|
|
|
setIconSize(QSize(10, 10));
|
|
|
|
|
|
|
|
|
|
header()->setDefaultAlignment(Qt::AlignLeft);
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(activated(QModelIndex)),
|
2010-11-05 19:38:40 +01:00
|
|
|
SLOT(rowActivated(QModelIndex)));
|
2010-02-02 17:25:14 +01:00
|
|
|
connect(act, SIGNAL(toggled(bool)),
|
2010-11-05 19:38:40 +01:00
|
|
|
SLOT(setAlternatingRowColorsHelper(bool)));
|
2011-03-16 18:48:14 +01:00
|
|
|
connect(debuggerCore()->action(AlwaysAdjustSnapshotsColumnWidths),
|
|
|
|
|
SIGNAL(toggled(bool)),
|
|
|
|
|
SLOT(setAlwaysResizeColumnsToContents(bool)));
|
2010-02-02 17:25:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SnapshotWindow::rowActivated(const QModelIndex &index)
|
2010-11-08 15:19:13 +01:00
|
|
|
{
|
2010-11-05 19:38:40 +01:00
|
|
|
m_snapshotHandler->activateSnapshot(index.row());
|
2010-02-02 17:25:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SnapshotWindow::keyPressEvent(QKeyEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
if (ev->key() == Qt::Key_Delete) {
|
|
|
|
|
QItemSelectionModel *sm = selectionModel();
|
|
|
|
|
QTC_ASSERT(sm, return);
|
|
|
|
|
QModelIndexList si = sm->selectedIndexes();
|
|
|
|
|
if (si.isEmpty())
|
|
|
|
|
si.append(currentIndex().sibling(currentIndex().row(), 0));
|
2010-11-10 16:33:11 +01:00
|
|
|
|
|
|
|
|
foreach (const QModelIndex &idx, si)
|
|
|
|
|
if (idx.column() == 0)
|
|
|
|
|
removeSnapshot(idx.row());
|
2010-02-02 17:25:14 +01:00
|
|
|
}
|
|
|
|
|
QTreeView::keyPressEvent(ev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SnapshotWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|
|
|
|
{
|
2010-07-13 15:57:34 +02:00
|
|
|
QModelIndex idx = indexAt(ev->pos());
|
2010-02-02 17:25:14 +01:00
|
|
|
|
|
|
|
|
QMenu menu;
|
|
|
|
|
|
2010-07-13 15:57:34 +02:00
|
|
|
QAction *actCreate = menu.addAction(tr("Create Snapshot"));
|
|
|
|
|
actCreate->setEnabled(idx.data(SnapshotCapabilityRole).toBool());
|
|
|
|
|
menu.addSeparator();
|
|
|
|
|
|
2010-07-20 18:06:34 +02:00
|
|
|
QAction *actRemove = menu.addAction(tr("Remove Snapshot"));
|
|
|
|
|
actRemove->setEnabled(idx.isValid());
|
|
|
|
|
menu.addSeparator();
|
|
|
|
|
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *actAdjust = menu.addAction(tr("Adjust Column Widths to Contents"));
|
2011-03-16 18:48:14 +01:00
|
|
|
menu.addAction(debuggerCore()->action(AlwaysAdjustSnapshotsColumnWidths));
|
2010-02-02 17:25:14 +01:00
|
|
|
menu.addSeparator();
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
menu.addAction(debuggerCore()->action(SettingsDialog));
|
2010-02-02 17:25:14 +01:00
|
|
|
|
|
|
|
|
QAction *act = menu.exec(ev->globalPos());
|
|
|
|
|
|
2010-07-13 15:57:34 +02:00
|
|
|
if (act == actCreate)
|
2010-11-05 19:38:40 +01:00
|
|
|
m_snapshotHandler->createSnapshot(idx.row());
|
2010-07-20 18:06:34 +02:00
|
|
|
else if (act == actRemove)
|
2010-11-08 17:43:31 +01:00
|
|
|
removeSnapshot(idx.row());
|
2010-07-13 15:57:34 +02:00
|
|
|
else if (act == actAdjust)
|
2010-02-02 17:25:14 +01:00
|
|
|
resizeColumnsToContents();
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-08 17:43:31 +01:00
|
|
|
void SnapshotWindow::removeSnapshot(int i)
|
|
|
|
|
{
|
2010-12-10 10:01:29 +01:00
|
|
|
m_snapshotHandler->at(i)->quitDebugger();
|
2010-11-08 17:43:31 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-02 17:25:14 +01:00
|
|
|
void SnapshotWindow::resizeColumnsToContents()
|
|
|
|
|
{
|
|
|
|
|
for (int i = model()->columnCount(); --i >= 0; )
|
|
|
|
|
resizeColumnToContents(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SnapshotWindow::setAlwaysResizeColumnsToContents(bool on)
|
|
|
|
|
{
|
|
|
|
|
QHeaderView::ResizeMode mode =
|
|
|
|
|
on ? QHeaderView::ResizeToContents : QHeaderView::Interactive;
|
|
|
|
|
for (int i = model()->columnCount(); --i >= 0; )
|
|
|
|
|
header()->setResizeMode(i, mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|