Commit 6594529f authored by hjk's avatar hjk
Browse files

Fixes: debugger: easy access to source files and modules from the

context menu
parent c37e4426
......@@ -260,6 +260,8 @@ void DebuggerManager::init()
this, SLOT(loadSymbols(QString)));
connect(modulesView, SIGNAL(loadAllSymbolsRequested()),
this, SLOT(loadAllSymbols()));
connect(modulesView, SIGNAL(fileOpenRequested(QString)),
this, SLOT(fileOpen(QString)));
// Source Files
//m_sourceFilesHandler = new SourceFilesHandler;
......@@ -268,6 +270,8 @@ void DebuggerManager::init()
//sourceFileView->setModel(m_stackHandler->stackModel());
connect(sourceFilesView, SIGNAL(reloadSourceFilesRequested()),
this, SLOT(reloadSourceFiles()));
connect(sourceFilesView, SIGNAL(fileOpenRequested(QString)),
this, SLOT(fileOpen(QString)));
// Registers
QAbstractItemView *registerView =
......@@ -1390,6 +1394,13 @@ void DebuggerManager::gotoLocation(const QString &fileName, int line,
emit gotoLocationRequested(fileName, line, setMarker);
}
void DebuggerManager::fileOpen(const QString &fileName)
{
// connected to the plugin
emit gotoLocationRequested(fileName, 1, false);
}
//////////////////////////////////////////////////////////////////////
//
......
......@@ -245,6 +245,7 @@ public slots:
QVariant sessionValue(const QString &name);
void gotoLocation(const QString &file, int line, bool setLocationMarker);
void fileOpen(const QString &file);
void resetLocation();
void interruptDebuggingRequest();
......
......@@ -48,6 +48,16 @@ ModulesWindow::ModulesWindow(QWidget *parent)
setAlternatingRowColors(true);
setRootIsDecorated(false);
setIconSize(QSize(10, 10));
connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(moduleActivated(QModelIndex)));
}
void ModulesWindow::moduleActivated(const QModelIndex &index)
{
qDebug() << "ACTIVATED: " << index.row() << index.column()
<< model()->data(index);
emit fileOpenRequested(model()->data(index).toString());
}
void ModulesWindow::resizeEvent(QResizeEvent *event)
......@@ -73,19 +83,30 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
QString name = model()->data(index).toString();
QMenu menu;
QAction *act0 = new QAction("Update module list", &menu);
QAction *act1 = new QAction("Adjust column widths to contents", &menu);
QAction *act2 = new QAction("Always adjust column widths to contents", &menu);
QAction *act0 = new QAction(tr("Update module list"), &menu);
QAction *act1 = new QAction(tr("Adjust column widths to contents"), &menu);
QAction *act2 = new QAction(tr("Always adjust column widths to contents"), &menu);
act2->setCheckable(true);
act2->setChecked(m_alwaysResizeColumnsToContents);
QAction *act3 = new QAction("Show source files for module " + name, &menu);
QAction *act4 = new QAction("Load symbols for all modules", &menu);
QAction *act5 = new QAction("Load symbols for module " + name, &menu);
QAction *act3 = new QAction(tr("Show source files for module \"%1\"").arg(name),
&menu);
QAction *act4 = new QAction(tr("Load symbols for all modules"), &menu);
QAction *act5 = 0;
QAction *act6 = 0;
if (name.isEmpty()) {
act5 = new QAction(tr("Load symbols for module"), &menu);
act6 = new QAction(tr("Edit file"), &menu);
} else {
act5 = new QAction(tr("Load symbols for module \"%1\"").arg(name), &menu);
act6 = new QAction(tr("Edit file \"%1\"").arg(name), &menu);
}
act5->setDisabled(name.isEmpty());
act6->setDisabled(name.isEmpty());
menu.addAction(act0);
menu.addAction(act4);
menu.addAction(act5);
menu.addAction(act6);
menu.addSeparator();
menu.addAction(act1);
menu.addAction(act2);
......@@ -104,6 +125,8 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
emit loadAllSymbolsRequested();
else if (act == act5)
emit loadSymbolsRequested(name);
else if (act == act6)
emit fileOpenRequested(name);
}
void ModulesWindow::resizeColumnsToContents()
......
......@@ -47,17 +47,18 @@ signals:
void displaySourceRequested(const QString &modulesName);
void loadSymbolsRequested(const QString &modulesName);
void loadAllSymbolsRequested();
void fileOpenRequested(QString);
public slots:
void resizeColumnsToContents();
void setAlwaysResizeColumnsToContents(bool on);
void moduleActivated(const QModelIndex &);
protected:
private:
void resizeEvent(QResizeEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev);
void setModel(QAbstractItemModel *model);
private:
bool m_alwaysResizeColumnsToContents;
};
......
......@@ -178,28 +178,40 @@ SourceFilesWindow::SourceFilesWindow(QWidget *parent)
this, SLOT(sourceFileActivated(QModelIndex)));
}
SourceFilesWindow::~SourceFilesWindow()
{
}
void SourceFilesWindow::sourceFileActivated(const QModelIndex &index)
{
qDebug() << "ACTIVATED: " << index.row() << index.column();
qDebug() << "ACTIVATED: " << index.row() << index.column()
<< model()->data(index);
emit fileOpenRequested(model()->data(index).toString());
}
void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
{
QModelIndex index = indexAt(ev->pos());
index = index.sibling(index.row(), 0);
QString name = model()->data(index).toString();
QMenu menu;
QAction *act1 = new QAction(tr("Reload data"), &menu);
//act1->setCheckable(true);
QAction *act2 = 0;
if (name.isEmpty()) {
act2 = new QAction(tr("Open file"), &menu);
act2->setEnabled(false);
} else {
act2 = new QAction(tr("Open file \"%1\"'").arg(name), &menu);
act2->setEnabled(true);
}
menu.addAction(act1);
menu.addAction(act2);
QAction *act = menu.exec(ev->globalPos());
if (act == act1) {
if (act == act1)
emit reloadSourceFilesRequested();
}
else if (act == act2)
emit fileOpenRequested(name);
}
void SourceFilesWindow::setSourceFiles(const QMap<QString, QString> &sourceFiles)
......
......@@ -50,13 +50,13 @@ class SourceFilesWindow : public QTreeView
public:
SourceFilesWindow(QWidget *parent = 0);
~SourceFilesWindow();
void setSourceFiles(const QMap<QString, QString> &sourceFiles);
void removeAll();
signals:
void reloadSourceFilesRequested();
void fileOpenRequested(QString file);
private slots:
void sourceFileActivated(const QModelIndex &index);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment