forked from qt-creator/qt-creator
Fixes: add a view to see current source file mapping
This commit is contained in:
@@ -37,6 +37,7 @@ HEADERS += attachexternaldialog.h \
|
|||||||
scriptengine.h \
|
scriptengine.h \
|
||||||
stackhandler.h \
|
stackhandler.h \
|
||||||
stackwindow.h \
|
stackwindow.h \
|
||||||
|
sourcefileswindow.h \
|
||||||
startexternaldialog.h \
|
startexternaldialog.h \
|
||||||
threadswindow.h \
|
threadswindow.h \
|
||||||
watchhandler.h \
|
watchhandler.h \
|
||||||
@@ -64,6 +65,7 @@ SOURCES += attachexternaldialog.cpp \
|
|||||||
scriptengine.cpp \
|
scriptengine.cpp \
|
||||||
stackhandler.cpp \
|
stackhandler.cpp \
|
||||||
stackwindow.cpp \
|
stackwindow.cpp \
|
||||||
|
sourcefileswindow.cpp \
|
||||||
startexternaldialog.cpp \
|
startexternaldialog.cpp \
|
||||||
threadswindow.cpp \
|
threadswindow.cpp \
|
||||||
watchhandler.cpp \
|
watchhandler.cpp \
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include "moduleswindow.h"
|
#include "moduleswindow.h"
|
||||||
#include "registerwindow.h"
|
#include "registerwindow.h"
|
||||||
#include "stackwindow.h"
|
#include "stackwindow.h"
|
||||||
|
#include "sourcefileswindow.h"
|
||||||
#include "threadswindow.h"
|
#include "threadswindow.h"
|
||||||
#include "watchwindow.h"
|
#include "watchwindow.h"
|
||||||
|
|
||||||
@@ -165,6 +166,7 @@ void DebuggerManager::init()
|
|||||||
m_outputWindow = new DebuggerOutputWindow;
|
m_outputWindow = new DebuggerOutputWindow;
|
||||||
m_registerWindow = new RegisterWindow;
|
m_registerWindow = new RegisterWindow;
|
||||||
m_stackWindow = new StackWindow;
|
m_stackWindow = new StackWindow;
|
||||||
|
m_sourceFilesWindow = new SourceFilesWindow;
|
||||||
m_threadsWindow = new ThreadsWindow;
|
m_threadsWindow = new ThreadsWindow;
|
||||||
m_localsWindow = new WatchWindow(WatchWindow::LocalsType);
|
m_localsWindow = new WatchWindow(WatchWindow::LocalsType);
|
||||||
m_watchersWindow = new WatchWindow(WatchWindow::WatchersType);
|
m_watchersWindow = new WatchWindow(WatchWindow::WatchersType);
|
||||||
@@ -227,6 +229,13 @@ void DebuggerManager::init()
|
|||||||
connect(modulesView, SIGNAL(loadAllSymbolsRequested()),
|
connect(modulesView, SIGNAL(loadAllSymbolsRequested()),
|
||||||
this, SLOT(loadAllSymbols()));
|
this, SLOT(loadAllSymbols()));
|
||||||
|
|
||||||
|
// Source Files
|
||||||
|
//m_sourceFilesHandler = new SourceFilesHandler;
|
||||||
|
QAbstractItemView *sourceFilesView =
|
||||||
|
qobject_cast<QAbstractItemView *>(m_sourceFilesWindow);
|
||||||
|
//sourceFileView->setModel(m_stackHandler->stackModel());
|
||||||
|
connect(sourceFilesView, SIGNAL(reloadSourceFilesRequested()),
|
||||||
|
this, SLOT(reloadSourceFiles()));
|
||||||
|
|
||||||
// Registers
|
// Registers
|
||||||
QAbstractItemView *registerView =
|
QAbstractItemView *registerView =
|
||||||
@@ -403,6 +412,10 @@ void DebuggerManager::init()
|
|||||||
|
|
||||||
m_stackDock = createDockForWidget(m_stackWindow);
|
m_stackDock = createDockForWidget(m_stackWindow);
|
||||||
|
|
||||||
|
m_sourceFilesDock = createDockForWidget(m_sourceFilesWindow);
|
||||||
|
connect(m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(reloadSourceFiles()), Qt::QueuedConnection);
|
||||||
|
|
||||||
m_threadsDock = createDockForWidget(m_threadsWindow);
|
m_threadsDock = createDockForWidget(m_threadsWindow);
|
||||||
|
|
||||||
setStatus(DebuggerProcessNotReady);
|
setStatus(DebuggerProcessNotReady);
|
||||||
@@ -1240,6 +1253,26 @@ void DebuggerManager::disassemblerDockToggled(bool on)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Sourec files specific stuff
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void DebuggerManager::reloadSourceFiles()
|
||||||
|
{
|
||||||
|
if (!m_sourceFilesDock || !m_sourceFilesDock->isVisible())
|
||||||
|
return;
|
||||||
|
m_engine->reloadSourceFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerManager::sourceFilesDockToggled(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
reloadSourceFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Modules specific stuff
|
// Modules specific stuff
|
||||||
|
@@ -66,6 +66,7 @@ class RegisterHandler;
|
|||||||
class StackHandler;
|
class StackHandler;
|
||||||
class ThreadsHandler;
|
class ThreadsHandler;
|
||||||
class WatchHandler;
|
class WatchHandler;
|
||||||
|
class SourceFilesWindow;
|
||||||
class WatchData;
|
class WatchData;
|
||||||
class BreakpointData;
|
class BreakpointData;
|
||||||
|
|
||||||
@@ -166,6 +167,7 @@ private:
|
|||||||
virtual StackHandler *stackHandler() = 0;
|
virtual StackHandler *stackHandler() = 0;
|
||||||
virtual ThreadsHandler *threadsHandler() = 0;
|
virtual ThreadsHandler *threadsHandler() = 0;
|
||||||
virtual WatchHandler *watchHandler() = 0;
|
virtual WatchHandler *watchHandler() = 0;
|
||||||
|
virtual SourceFilesWindow *sourceFileWindow() = 0;
|
||||||
|
|
||||||
virtual void showApplicationOutput(const QString &data) = 0;
|
virtual void showApplicationOutput(const QString &data) = 0;
|
||||||
virtual bool skipKnownFrames() const = 0;
|
virtual bool skipKnownFrames() const = 0;
|
||||||
@@ -179,6 +181,7 @@ private:
|
|||||||
|
|
||||||
virtual void reloadDisassembler() = 0;
|
virtual void reloadDisassembler() = 0;
|
||||||
virtual void reloadModules() = 0;
|
virtual void reloadModules() = 0;
|
||||||
|
virtual void reloadSourceFiles() = 0;
|
||||||
virtual void reloadRegisters() = 0;
|
virtual void reloadRegisters() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -302,6 +305,9 @@ private slots:
|
|||||||
void reloadDisassembler();
|
void reloadDisassembler();
|
||||||
void disassemblerDockToggled(bool on);
|
void disassemblerDockToggled(bool on);
|
||||||
|
|
||||||
|
void reloadSourceFiles();
|
||||||
|
void sourceFilesDockToggled(bool on);
|
||||||
|
|
||||||
void reloadModules();
|
void reloadModules();
|
||||||
void modulesDockToggled(bool on);
|
void modulesDockToggled(bool on);
|
||||||
void loadSymbols(const QString &moduleName);
|
void loadSymbols(const QString &moduleName);
|
||||||
@@ -323,6 +329,7 @@ private:
|
|||||||
StackHandler *stackHandler() { return m_stackHandler; }
|
StackHandler *stackHandler() { return m_stackHandler; }
|
||||||
ThreadsHandler *threadsHandler() { return m_threadsHandler; }
|
ThreadsHandler *threadsHandler() { return m_threadsHandler; }
|
||||||
WatchHandler *watchHandler() { return m_watchHandler; }
|
WatchHandler *watchHandler() { return m_watchHandler; }
|
||||||
|
SourceFilesWindow *sourceFileWindow() { return m_sourceFilesWindow; }
|
||||||
|
|
||||||
bool skipKnownFrames() const;
|
bool skipKnownFrames() const;
|
||||||
bool debugDumpers() const;
|
bool debugDumpers() const;
|
||||||
@@ -416,6 +423,7 @@ private:
|
|||||||
QDockWidget *m_outputDock;
|
QDockWidget *m_outputDock;
|
||||||
QDockWidget *m_registerDock;
|
QDockWidget *m_registerDock;
|
||||||
QDockWidget *m_stackDock;
|
QDockWidget *m_stackDock;
|
||||||
|
QDockWidget *m_sourceFilesDock;
|
||||||
QDockWidget *m_threadsDock;
|
QDockWidget *m_threadsDock;
|
||||||
QDockWidget *m_watchDock;
|
QDockWidget *m_watchDock;
|
||||||
QList<QDockWidget*> m_dockWidgets;
|
QList<QDockWidget*> m_dockWidgets;
|
||||||
@@ -427,6 +435,7 @@ private:
|
|||||||
StackHandler *m_stackHandler;
|
StackHandler *m_stackHandler;
|
||||||
ThreadsHandler *m_threadsHandler;
|
ThreadsHandler *m_threadsHandler;
|
||||||
WatchHandler *m_watchHandler;
|
WatchHandler *m_watchHandler;
|
||||||
|
SourceFilesWindow *m_sourceFilesWindow;
|
||||||
|
|
||||||
/// Actions
|
/// Actions
|
||||||
friend class DebuggerPlugin;
|
friend class DebuggerPlugin;
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
#include "registerhandler.h"
|
#include "registerhandler.h"
|
||||||
#include "stackhandler.h"
|
#include "stackhandler.h"
|
||||||
#include "watchhandler.h"
|
#include "watchhandler.h"
|
||||||
|
#include "sourcefileswindow.h"
|
||||||
|
|
||||||
#include "startexternaldialog.h"
|
#include "startexternaldialog.h"
|
||||||
#include "attachexternaldialog.h"
|
#include "attachexternaldialog.h"
|
||||||
@@ -986,6 +987,7 @@ void GdbEngine::handleQueryPwd(const GdbResultRecord &record)
|
|||||||
void GdbEngine::handleQuerySources(const GdbResultRecord &record)
|
void GdbEngine::handleQuerySources(const GdbResultRecord &record)
|
||||||
{
|
{
|
||||||
if (record.resultClass == GdbResultDone) {
|
if (record.resultClass == GdbResultDone) {
|
||||||
|
QMap<QString, QString> oldShortToFull = m_shortToFullName;
|
||||||
m_shortToFullName.clear();
|
m_shortToFullName.clear();
|
||||||
m_fullToShortName.clear();
|
m_fullToShortName.clear();
|
||||||
// "^done,files=[{file="../../../../bin/gdbmacros/gdbmacros.cpp",
|
// "^done,files=[{file="../../../../bin/gdbmacros/gdbmacros.cpp",
|
||||||
@@ -1004,6 +1006,8 @@ void GdbEngine::handleQuerySources(const GdbResultRecord &record)
|
|||||||
m_fullToShortName[full] = fileName;
|
m_fullToShortName[full] = fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m_shortToFullName != oldShortToFull)
|
||||||
|
qq->sourceFileWindow()->setSourceFiles(m_shortToFullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1128,7 +1132,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
|
|||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
sendCommand("info pid", GdbInfoProc, QVariant(), true);
|
sendCommand("info pid", GdbInfoProc, QVariant(), true);
|
||||||
#endif
|
#endif
|
||||||
sendCommand("-file-list-exec-source-files", GdbQuerySources);
|
reloadSourceFiles();
|
||||||
tryLoadCustomDumpers();
|
tryLoadCustomDumpers();
|
||||||
|
|
||||||
// intentionally after tryLoadCustomDumpers(),
|
// intentionally after tryLoadCustomDumpers(),
|
||||||
@@ -1262,7 +1266,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
|
|||||||
frame.findChild("func").data() + '%';
|
frame.findChild("func").data() + '%';
|
||||||
|
|
||||||
QApplication::alert(q->mainWindow(), 3000);
|
QApplication::alert(q->mainWindow(), 3000);
|
||||||
sendCommand("-file-list-exec-source-files", GdbQuerySources);
|
reloadSourceFiles();
|
||||||
sendCommand("-break-list", BreakList);
|
sendCommand("-break-list", BreakList);
|
||||||
QVariant var = QVariant::fromValue<GdbMi>(data);
|
QVariant var = QVariant::fromValue<GdbMi>(data);
|
||||||
sendCommand("p 0", GdbAsyncOutput2, var); // dummy
|
sendCommand("p 0", GdbAsyncOutput2, var); // dummy
|
||||||
@@ -2317,6 +2321,18 @@ void GdbEngine::handleModulesList(const GdbResultRecord &record)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Source files specific stuff
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void GdbEngine::reloadSourceFiles()
|
||||||
|
{
|
||||||
|
sendCommand("-file-list-exec-source-files", GdbQuerySources);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Stack specific stuff
|
// Stack specific stuff
|
||||||
@@ -2546,7 +2562,7 @@ bool GdbEngine::supportsThreads() const
|
|||||||
static WatchData m_toolTip;
|
static WatchData m_toolTip;
|
||||||
static QString m_toolTipExpression;
|
static QString m_toolTipExpression;
|
||||||
static QPoint m_toolTipPos;
|
static QPoint m_toolTipPos;
|
||||||
static QHash<QString, WatchData> m_toolTipCache;
|
static QMap<QString, WatchData> m_toolTipCache;
|
||||||
|
|
||||||
static bool hasLetterOrNumber(const QString &exp)
|
static bool hasLetterOrNumber(const QString &exp)
|
||||||
{
|
{
|
||||||
@@ -3672,7 +3688,7 @@ void GdbEngine::handleStackListLocals(const GdbResultRecord &record)
|
|||||||
void GdbEngine::setLocals(const QList<GdbMi> &locals)
|
void GdbEngine::setLocals(const QList<GdbMi> &locals)
|
||||||
{
|
{
|
||||||
//qDebug() << m_varToType;
|
//qDebug() << m_varToType;
|
||||||
QHash<QString, int> seen;
|
QMap<QString, int> seen;
|
||||||
|
|
||||||
foreach (const GdbMi &item, locals) {
|
foreach (const GdbMi &item, locals) {
|
||||||
// Local variables of inlined code are reported as
|
// Local variables of inlined code are reported as
|
||||||
|
@@ -222,8 +222,8 @@ private:
|
|||||||
int m_gdbVersion; // 6.8.0 is 680
|
int m_gdbVersion; // 6.8.0 is 680
|
||||||
|
|
||||||
// awful hack to keep track of used files
|
// awful hack to keep track of used files
|
||||||
QHash<QString, QString> m_shortToFullName;
|
QMap<QString, QString> m_shortToFullName;
|
||||||
QHash<QString, QString> m_fullToShortName;
|
QMap<QString, QString> m_fullToShortName;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Breakpoint specific stuff
|
// Breakpoint specific stuff
|
||||||
@@ -263,6 +263,10 @@ private:
|
|||||||
void handleRegisterListNames(const GdbResultRecord &record);
|
void handleRegisterListNames(const GdbResultRecord &record);
|
||||||
void handleRegisterListValues(const GdbResultRecord &record);
|
void handleRegisterListValues(const GdbResultRecord &record);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Source file specific stuff
|
||||||
|
//
|
||||||
|
void reloadSourceFiles();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Stack specific stuff
|
// Stack specific stuff
|
||||||
|
@@ -87,6 +87,8 @@ public:
|
|||||||
virtual void reloadRegisters() = 0;
|
virtual void reloadRegisters() = 0;
|
||||||
virtual void setDebugDumpers(bool on) = 0;
|
virtual void setDebugDumpers(bool on) = 0;
|
||||||
virtual void setUseCustomDumpers(bool on) = 0;
|
virtual void setUseCustomDumpers(bool on) = 0;
|
||||||
|
|
||||||
|
virtual void reloadSourceFiles() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -112,6 +112,7 @@ private:
|
|||||||
void reloadDisassembler();
|
void reloadDisassembler();
|
||||||
void reloadModules();
|
void reloadModules();
|
||||||
void reloadRegisters() {}
|
void reloadRegisters() {}
|
||||||
|
void reloadSourceFiles() {}
|
||||||
|
|
||||||
bool supportsThreads() const { return true; }
|
bool supportsThreads() const { return true; }
|
||||||
void maybeBreakNow(bool byFunction);
|
void maybeBreakNow(bool byFunction);
|
||||||
|
213
src/plugins/debugger/sourcefileswindow.cpp
Normal file
213
src/plugins/debugger/sourcefileswindow.cpp
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** Non-Open Source Usage
|
||||||
|
**
|
||||||
|
** Licensees may use this file in accordance with the Qt Beta Version
|
||||||
|
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||||
|
** alternatively, in accordance with the terms contained in a written
|
||||||
|
** agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU General
|
||||||
|
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||||
|
** of this file. Please review the following information to ensure GNU
|
||||||
|
** General Public Licensing requirements will be met:
|
||||||
|
**
|
||||||
|
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||||
|
** http://www.gnu.org/copyleft/gpl.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||||
|
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "sourcefileswindow.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using Debugger::Internal::SourceFilesWindow;
|
||||||
|
using Debugger::Internal::SourceFilesModel;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SourceFilesModel
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Debugger::Internal::SourceFilesModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SourceFilesModel(QObject *parent = 0) : QAbstractItemModel(parent) {}
|
||||||
|
|
||||||
|
// QAbstractItemModel
|
||||||
|
int columnCount(const QModelIndex &parent) const
|
||||||
|
{ return parent.isValid() ? 0 : 2; }
|
||||||
|
int rowCount(const QModelIndex &parent) const
|
||||||
|
{ return parent.isValid() ? 0 : m_shortNames.size(); }
|
||||||
|
QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
|
||||||
|
QModelIndex index(int row, int column, const QModelIndex &) const
|
||||||
|
{ return createIndex(row, column); }
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
void clearModel();
|
||||||
|
void update() { reset(); }
|
||||||
|
void setSourceFiles(const QMap<QString, QString> &sourceFiles);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QStringList m_shortNames;
|
||||||
|
QStringList m_fullNames;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SourceFilesModel::clearModel()
|
||||||
|
{
|
||||||
|
if (m_shortNames.isEmpty())
|
||||||
|
return;
|
||||||
|
m_shortNames.clear();
|
||||||
|
m_fullNames.clear();
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant SourceFilesModel::headerData(int section,
|
||||||
|
Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||||
|
static QString headers[] = {
|
||||||
|
tr("Internal name") + " ",
|
||||||
|
tr("Full name") + " ",
|
||||||
|
};
|
||||||
|
return headers[section];
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags SourceFilesModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.row() >= m_fullNames.size())
|
||||||
|
return 0;
|
||||||
|
QFileInfo fi(m_fullNames.at(index.row()));
|
||||||
|
return fi.isReadable() ? QAbstractItemModel::flags(index) : Qt::ItemFlags(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant SourceFilesModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
//static const QIcon icon(":/gdbdebugger/images/breakpoint.svg");
|
||||||
|
//static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg");
|
||||||
|
|
||||||
|
int row = index.row();
|
||||||
|
if (row < 0 || row >= m_shortNames.size())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
switch (index.column()) {
|
||||||
|
case 0:
|
||||||
|
if (role == Qt::DisplayRole)
|
||||||
|
return m_shortNames.at(row);
|
||||||
|
// FIXME: add icons
|
||||||
|
//if (role == Qt::DecorationRole)
|
||||||
|
// return module.symbolsRead ? icon2 : icon;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (role == Qt::DisplayRole)
|
||||||
|
return m_fullNames.at(row);
|
||||||
|
//if (role == Qt::DecorationRole)
|
||||||
|
// return module.symbolsRead ? icon2 : icon;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SourceFilesModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::setData(index, value, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesModel::setSourceFiles(const QMap<QString, QString> &sourceFiles)
|
||||||
|
{
|
||||||
|
m_shortNames.clear();
|
||||||
|
m_fullNames.clear();
|
||||||
|
QMap<QString, QString>::ConstIterator it = sourceFiles.begin();
|
||||||
|
QMap<QString, QString>::ConstIterator et = sourceFiles.end();
|
||||||
|
for (; it != et; ++it) {
|
||||||
|
m_shortNames.append(it.key());
|
||||||
|
m_fullNames.append(it.value());
|
||||||
|
}
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SourceFilesWindow
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SourceFilesWindow::SourceFilesWindow(QWidget *parent)
|
||||||
|
: QTreeView(parent)
|
||||||
|
{
|
||||||
|
m_model = new SourceFilesModel(this);
|
||||||
|
|
||||||
|
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
|
||||||
|
proxyModel->setSourceModel(m_model);
|
||||||
|
setModel(proxyModel);
|
||||||
|
|
||||||
|
setWindowTitle(tr("Source Files"));
|
||||||
|
setSortingEnabled(true);
|
||||||
|
setAlternatingRowColors(true);
|
||||||
|
setRootIsDecorated(false);
|
||||||
|
setIconSize(QSize(10, 10));
|
||||||
|
//header()->setDefaultAlignment(Qt::AlignLeft);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(activated(QModelIndex)),
|
||||||
|
this, SLOT(sourceFileActivated(QModelIndex)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceFilesWindow::~SourceFilesWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesWindow::sourceFileActivated(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
qDebug() << "ACTIVATED: " << index.row() << index.column();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||||
|
{
|
||||||
|
QMenu menu;
|
||||||
|
QAction *act1 = new QAction(tr("Reload data"), &menu);
|
||||||
|
//act1->setCheckable(true);
|
||||||
|
|
||||||
|
menu.addAction(act1);
|
||||||
|
|
||||||
|
QAction *act = menu.exec(ev->globalPos());
|
||||||
|
|
||||||
|
if (act == act1) {
|
||||||
|
emit reloadSourceFilesRequested();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesWindow::setSourceFiles(const QMap<QString, QString> &sourceFiles)
|
||||||
|
{
|
||||||
|
m_model->setSourceFiles(sourceFiles);
|
||||||
|
header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
||||||
|
}
|
76
src/plugins/debugger/sourcefileswindow.h
Normal file
76
src/plugins/debugger/sourcefileswindow.h
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** Non-Open Source Usage
|
||||||
|
**
|
||||||
|
** Licensees may use this file in accordance with the Qt Beta Version
|
||||||
|
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||||
|
** alternatively, in accordance with the terms contained in a written
|
||||||
|
** agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU General
|
||||||
|
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||||
|
** of this file. Please review the following information to ensure GNU
|
||||||
|
** General Public Licensing requirements will be met:
|
||||||
|
**
|
||||||
|
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||||
|
** http://www.gnu.org/copyleft/gpl.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||||
|
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DEBUGGER_SOURCEFILEWINDOW_H
|
||||||
|
#define DEBUGGER_SOURCEFILEWINDOW_H
|
||||||
|
|
||||||
|
#include <QtGui/QTreeWidget>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QComboBox;
|
||||||
|
class QModelIndex;
|
||||||
|
class QStandardItemModel;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Debugger {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class SourceFilesModel;
|
||||||
|
|
||||||
|
class SourceFilesWindow : public QTreeView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SourceFilesWindow(QWidget *parent = 0);
|
||||||
|
~SourceFilesWindow();
|
||||||
|
|
||||||
|
void setSourceFiles(const QMap<QString, QString> &sourceFiles);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void reloadSourceFilesRequested();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void sourceFileActivated(const QModelIndex &index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void contextMenuEvent(QContextMenuEvent *ev);
|
||||||
|
SourceFilesModel *m_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Debugger
|
||||||
|
|
||||||
|
#endif // DEBUGGER_SOURCEFILEWINDOW_H
|
||||||
|
|
213
src/plugins/debugger/statuswindow.cpp
Normal file
213
src/plugins/debugger/statuswindow.cpp
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** Non-Open Source Usage
|
||||||
|
**
|
||||||
|
** Licensees may use this file in accordance with the Qt Beta Version
|
||||||
|
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||||
|
** alternatively, in accordance with the terms contained in a written
|
||||||
|
** agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU General
|
||||||
|
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||||
|
** of this file. Please review the following information to ensure GNU
|
||||||
|
** General Public Licensing requirements will be met:
|
||||||
|
**
|
||||||
|
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||||
|
** http://www.gnu.org/copyleft/gpl.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||||
|
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "sourcefileswindow.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using Debugger::Internal::SourceFilesWindow;
|
||||||
|
using Debugger::Internal::SourceFilesModel;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SourceFilesModel
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Debugger::Internal::SourceFilesModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SourceFilesModel(QObject *parent = 0) : QAbstractItemModel(parent) {}
|
||||||
|
|
||||||
|
// QAbstractItemModel
|
||||||
|
int columnCount(const QModelIndex &parent) const
|
||||||
|
{ return parent.isValid() ? 0 : 2; }
|
||||||
|
int rowCount(const QModelIndex &parent) const
|
||||||
|
{ return parent.isValid() ? 0 : m_shortNames.size(); }
|
||||||
|
QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
|
||||||
|
QModelIndex index(int row, int column, const QModelIndex &) const
|
||||||
|
{ return createIndex(row, column); }
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
void clearModel();
|
||||||
|
void update() { reset(); }
|
||||||
|
void setSourceFiles(const QMap<QString, QString> &sourceFiles);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QStringList m_shortNames;
|
||||||
|
QStringList m_fullNames;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SourceFilesModel::clearModel()
|
||||||
|
{
|
||||||
|
if (m_shortNames.isEmpty())
|
||||||
|
return;
|
||||||
|
m_shortNames.clear();
|
||||||
|
m_fullNames.clear();
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant SourceFilesModel::headerData(int section,
|
||||||
|
Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||||
|
static QString headers[] = {
|
||||||
|
tr("Internal name") + " ",
|
||||||
|
tr("Full name") + " ",
|
||||||
|
};
|
||||||
|
return headers[section];
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags SourceFilesModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.row() >= m_fullNames.size())
|
||||||
|
return 0;
|
||||||
|
QFileInfo fi(m_fullNames.at(index.row()));
|
||||||
|
return fi.isReadable() ? QAbstractItemModel::flags(index) : Qt::ItemFlags(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant SourceFilesModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
//static const QIcon icon(":/gdbdebugger/images/breakpoint.svg");
|
||||||
|
//static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg");
|
||||||
|
|
||||||
|
int row = index.row();
|
||||||
|
if (row < 0 || row >= m_shortNames.size())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
switch (index.column()) {
|
||||||
|
case 0:
|
||||||
|
if (role == Qt::DisplayRole)
|
||||||
|
return m_shortNames.at(row);
|
||||||
|
// FIXME: add icons
|
||||||
|
//if (role == Qt::DecorationRole)
|
||||||
|
// return module.symbolsRead ? icon2 : icon;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (role == Qt::DisplayRole)
|
||||||
|
return m_fullNames.at(row);
|
||||||
|
//if (role == Qt::DecorationRole)
|
||||||
|
// return module.symbolsRead ? icon2 : icon;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SourceFilesModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
return QAbstractItemModel::setData(index, value, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesModel::setSourceFiles(const QMap<QString, QString> &sourceFiles)
|
||||||
|
{
|
||||||
|
m_shortNames.clear();
|
||||||
|
m_fullNames.clear();
|
||||||
|
QMap<QString, QString>::ConstIterator it = sourceFiles.begin();
|
||||||
|
QMap<QString, QString>::ConstIterator et = sourceFiles.end();
|
||||||
|
for (; it != et; ++it) {
|
||||||
|
m_shortNames.append(it.key());
|
||||||
|
m_fullNames.append(it.value());
|
||||||
|
}
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SourceFilesWindow
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SourceFilesWindow::SourceFilesWindow(QWidget *parent)
|
||||||
|
: QTreeView(parent)
|
||||||
|
{
|
||||||
|
m_model = new SourceFilesModel(this);
|
||||||
|
|
||||||
|
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
|
||||||
|
proxyModel->setSourceModel(m_model);
|
||||||
|
setModel(proxyModel);
|
||||||
|
|
||||||
|
setWindowTitle(tr("Source Files"));
|
||||||
|
setSortingEnabled(true);
|
||||||
|
setAlternatingRowColors(true);
|
||||||
|
setRootIsDecorated(false);
|
||||||
|
setIconSize(QSize(10, 10));
|
||||||
|
//header()->setDefaultAlignment(Qt::AlignLeft);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(activated(QModelIndex)),
|
||||||
|
this, SLOT(sourceFileActivated(QModelIndex)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SourceFilesWindow::~SourceFilesWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesWindow::sourceFileActivated(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
qDebug() << "ACTIVATED: " << index.row() << index.column();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||||
|
{
|
||||||
|
QMenu menu;
|
||||||
|
QAction *act1 = new QAction(tr("Reload data"), &menu);
|
||||||
|
//act1->setCheckable(true);
|
||||||
|
|
||||||
|
menu.addAction(act1);
|
||||||
|
|
||||||
|
QAction *act = menu.exec(ev->globalPos());
|
||||||
|
|
||||||
|
if (act == act1) {
|
||||||
|
emit reloadSourceFilesRequested();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SourceFilesWindow::setSourceFiles(const QMap<QString, QString> &sourceFiles)
|
||||||
|
{
|
||||||
|
m_model->setSourceFiles(sourceFiles);
|
||||||
|
header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
||||||
|
}
|
Reference in New Issue
Block a user