2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-02-17 14:08:49 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-02-17 14:08:49 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-02-17 14:08:49 +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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2009-02-17 14:08:49 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +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
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt 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
|
|
|
****************************************************************************/
|
2009-02-17 14:08:49 +01:00
|
|
|
|
|
|
|
|
#include "sourcefileswindow.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
#include "debuggercore.h"
|
2010-11-05 19:38:40 +01:00
|
|
|
#include "debuggerengine.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2009-02-17 14:08:49 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2009-03-24 14:41:15 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QContextMenuEvent>
|
|
|
|
|
#include <QMenu>
|
2009-02-17 14:08:49 +01:00
|
|
|
|
2010-11-05 19:38:40 +01:00
|
|
|
|
2009-02-17 14:08:49 +01:00
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// SourceFilesWindow
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
SourceFilesTreeView::SourceFilesTreeView(QWidget *parent)
|
|
|
|
|
: BaseTreeView(parent)
|
2009-02-17 14:08:49 +01:00
|
|
|
{
|
2012-03-29 14:20:45 +02:00
|
|
|
setSortingEnabled(true);
|
2009-02-17 14:08:49 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void SourceFilesTreeView::rowActivated(const QModelIndex &index)
|
2009-02-17 14:08:49 +01:00
|
|
|
{
|
2011-09-30 12:28:55 +02:00
|
|
|
DebuggerEngine *engine = debuggerCore()->currentEngine();
|
2010-12-14 12:21:29 +01:00
|
|
|
QTC_ASSERT(engine, return);
|
|
|
|
|
engine->gotoLocation(index.data().toString());
|
2009-02-17 14:08:49 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
void SourceFilesTreeView::contextMenuEvent(QContextMenuEvent *ev)
|
2009-02-17 14:08:49 +01:00
|
|
|
{
|
2011-09-30 12:28:55 +02:00
|
|
|
DebuggerEngine *engine = debuggerCore()->currentEngine();
|
2010-12-14 12:21:29 +01:00
|
|
|
QTC_ASSERT(engine, return);
|
2012-03-29 14:20:45 +02:00
|
|
|
QModelIndex index = indexAt(ev->pos());
|
2009-03-10 19:35:17 +01:00
|
|
|
index = index.sibling(index.row(), 0);
|
2010-06-16 11:08:54 +02:00
|
|
|
QString name = index.data().toString();
|
2010-12-14 12:21:29 +01:00
|
|
|
bool engineActionsEnabled = engine->debuggerActionsEnabled();
|
2009-03-10 19:35:17 +01:00
|
|
|
|
2009-02-17 14:08:49 +01:00
|
|
|
QMenu menu;
|
2010-02-12 10:52:09 +01:00
|
|
|
QAction *act1 = new QAction(tr("Reload Data"), &menu);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
|
|
|
|
act1->setEnabled(engineActionsEnabled);
|
2009-02-17 14:08:49 +01:00
|
|
|
//act1->setCheckable(true);
|
2009-03-10 19:35:17 +01:00
|
|
|
QAction *act2 = 0;
|
|
|
|
|
if (name.isEmpty()) {
|
2010-02-12 10:52:09 +01:00
|
|
|
act2 = new QAction(tr("Open File"), &menu);
|
2009-03-10 19:35:17 +01:00
|
|
|
act2->setEnabled(false);
|
|
|
|
|
} else {
|
2010-02-12 10:52:09 +01:00
|
|
|
act2 = new QAction(tr("Open File \"%1\"'").arg(name), &menu);
|
2009-03-10 19:35:17 +01:00
|
|
|
act2->setEnabled(true);
|
|
|
|
|
}
|
2010-01-29 21:33:57 +01:00
|
|
|
|
2009-02-17 14:08:49 +01:00
|
|
|
menu.addAction(act1);
|
2009-03-10 19:35:17 +01:00
|
|
|
menu.addAction(act2);
|
2011-09-30 12:28:55 +02:00
|
|
|
addBaseContextActions(&menu);
|
2009-02-17 14:08:49 +01:00
|
|
|
|
|
|
|
|
QAction *act = menu.exec(ev->globalPos());
|
|
|
|
|
|
2009-03-10 19:35:17 +01:00
|
|
|
if (act == act1)
|
2010-12-14 12:21:29 +01:00
|
|
|
engine->reloadSourceFiles();
|
2009-03-10 19:35:17 +01:00
|
|
|
else if (act == act2)
|
2010-12-14 12:21:29 +01:00
|
|
|
engine->gotoLocation(name);
|
2011-09-30 12:28:55 +02:00
|
|
|
else
|
|
|
|
|
handleBaseContextAction(act);
|
2009-02-17 14:08:49 +01:00
|
|
|
}
|
2009-03-10 17:30:11 +01:00
|
|
|
|
2012-03-29 14:20:45 +02:00
|
|
|
SourceFilesWindow::SourceFilesWindow()
|
|
|
|
|
: BaseWindow(new SourceFilesTreeView)
|
|
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("Source Files"));
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
2010-01-29 21:33:57 +01:00
|
|
|
|