2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-02-02 17:25:14 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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"
|
2011-04-21 15:52:51 +02:00
|
|
|
#include "debuggerinternalconstants.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
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2010-02-02 17:25:14 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QKeyEvent>
|
2010-02-02 17:25:14 +01:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// SnapshotWindow
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
SnapshotTreeView::SnapshotTreeView(SnapshotHandler *handler)
|
2010-02-02 17:25:14 +01:00
|
|
|
{
|
2010-11-05 19:38:40 +01:00
|
|
|
m_snapshotHandler = handler;
|
2010-02-02 17:25:14 +01:00
|
|
|
setWindowTitle(tr("Snapshots"));
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void SnapshotTreeView::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
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void SnapshotTreeView::keyPressEvent(QKeyEvent *ev)
|
2010-02-02 17:25:14 +01:00
|
|
|
{
|
|
|
|
|
if (ev->key() == Qt::Key_Delete) {
|
2012-03-29 14:20:45 +02:00
|
|
|
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
|
|
|
}
|
2014-04-09 17:39:41 +02:00
|
|
|
BaseTreeView::keyPressEvent(ev);
|
2010-02-02 17:25:14 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void SnapshotTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
2010-02-02 17:25:14 +01:00
|
|
|
{
|
2012-03-29 14:20:45 +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());
|
2012-11-28 20:28:42 +02:00
|
|
|
|
2014-06-04 13:21:02 +02:00
|
|
|
menu.addSeparator();
|
2014-07-28 14:23:52 +02:00
|
|
|
menu.addAction(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-02-02 17:25:14 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void SnapshotTreeView::removeSnapshot(int i)
|
2010-11-08 17:43:31 +01:00
|
|
|
{
|
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
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|