GUI: Use SearchListView in attach dialog
This commit is contained in:
parent
a8c6aabfb4
commit
255a139bcf
|
@ -1,5 +1,6 @@
|
|||
#include "AttachDialog.h"
|
||||
#include "ui_AttachDialog.h"
|
||||
#include "SearchListView.h"
|
||||
#include <QMenu>
|
||||
|
||||
AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AttachDialog)
|
||||
|
@ -9,26 +10,43 @@ AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Attach
|
|||
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
|
||||
#endif
|
||||
|
||||
//setup actions
|
||||
// Setup actions/shortcuts
|
||||
//
|
||||
// Enter key as shortcut for "Attach"
|
||||
mAttachAction = new QAction("Attach", this);
|
||||
mAttachAction->setShortcut(QKeySequence("enter"));
|
||||
connect(mAttachAction, SIGNAL(triggered()), this, SLOT(on_btnAttach_clicked()));
|
||||
|
||||
// F5 as shortcut to refresh view
|
||||
mRefreshAction = new QAction("Refresh", this);
|
||||
mRefreshAction->setShortcut(QKeySequence("F5"));
|
||||
connect(mRefreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
|
||||
this->addAction(mRefreshAction);
|
||||
|
||||
// Create search view (regex disabled)
|
||||
mSearchListView = new SearchListView(false);
|
||||
mSearchListView->mSearchStartCol = 1;
|
||||
ui->verticalLayout->insertWidget(0, mSearchListView);
|
||||
|
||||
//setup process list
|
||||
int charwidth = ui->listProcesses->getCharWidth();
|
||||
ui->listProcesses->addColumnAt(charwidth * sizeof(int) * 2 + 8, "PID", true);
|
||||
ui->listProcesses->addColumnAt(800, "Path", true);
|
||||
ui->listProcesses->setDrawDebugOnly(false);
|
||||
connect(ui->listProcesses, SIGNAL(enterPressedSignal()), this, SLOT(on_btnAttach_clicked()));
|
||||
connect(ui->listProcesses, SIGNAL(doubleClickedSignal()), this, SLOT(on_btnAttach_clicked()));
|
||||
connect(ui->listProcesses, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(processListContextMenu(QPoint)));
|
||||
int charwidth = mSearchListView->mList->getCharWidth();
|
||||
mSearchListView->mList->addColumnAt(charwidth * sizeof(int) * 2 + 8, "PID", true);
|
||||
mSearchListView->mList->addColumnAt(800, "Path", true);
|
||||
mSearchListView->mList->setDrawDebugOnly(false);
|
||||
|
||||
charwidth = mSearchListView->mSearchList->getCharWidth();
|
||||
mSearchListView->mSearchList->addColumnAt(charwidth * sizeof(int) * 2 + 8, "PID", true);
|
||||
mSearchListView->mSearchList->addColumnAt(800, "Path", true);
|
||||
mSearchListView->mSearchList->setDrawDebugOnly(false);
|
||||
|
||||
connect(mSearchListView, SIGNAL(enterPressedSignal()), this, SLOT(on_btnAttach_clicked()));
|
||||
connect(mSearchListView, SIGNAL(doubleClickedSignal()), this, SLOT(on_btnAttach_clicked()));
|
||||
connect(mSearchListView, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(processListContextMenu(QMenu*)));
|
||||
|
||||
// Highlight the search box
|
||||
mSearchListView->mCurList->setFocus();
|
||||
|
||||
// Populate the process list atleast once
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
@ -39,40 +57,35 @@ AttachDialog::~AttachDialog()
|
|||
|
||||
void AttachDialog::refresh()
|
||||
{
|
||||
ui->listProcesses->setRowCount(0);
|
||||
ui->listProcesses->setTableOffset(0);
|
||||
mSearchListView->mCurList->setRowCount(0);
|
||||
mSearchListView->mCurList->setTableOffset(0);
|
||||
DBGPROCESSINFO* entries;
|
||||
int count;
|
||||
if(!DbgFunctions()->GetProcessList(&entries, &count))
|
||||
return;
|
||||
ui->listProcesses->setRowCount(count);
|
||||
mSearchListView->mCurList->setRowCount(count);
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
ui->listProcesses->setCellContent(i, 0, QString().sprintf("%.8X", entries[i].dwProcessId));
|
||||
ui->listProcesses->setCellContent(i, 1, QString(entries[i].szExeFile));
|
||||
mSearchListView->mCurList->setCellContent(i, 0, QString().sprintf("%.8X", entries[i].dwProcessId));
|
||||
mSearchListView->mCurList->setCellContent(i, 1, QString(entries[i].szExeFile));
|
||||
}
|
||||
ui->listProcesses->setSingleSelection(0);
|
||||
ui->listProcesses->reloadData();
|
||||
mSearchListView->mCurList->setSingleSelection(0);
|
||||
mSearchListView->mCurList->reloadData();
|
||||
}
|
||||
|
||||
void AttachDialog::on_btnAttach_clicked()
|
||||
{
|
||||
QString pid = ui->listProcesses->getCellContent(ui->listProcesses->getInitialSelection(), 0);
|
||||
QString pid = mSearchListView->mCurList->getCellContent(mSearchListView->mList->getInitialSelection(), 0);
|
||||
DbgCmdExec(QString("attach " + pid).toUtf8().constData());
|
||||
accept();
|
||||
}
|
||||
|
||||
void AttachDialog::processListContextMenu(const QPoint & pos)
|
||||
void AttachDialog::processListContextMenu(QMenu* wMenu)
|
||||
{
|
||||
QMenu* wMenu = new QMenu(this); //create context menu
|
||||
// Don't show menu options if nothing is listed
|
||||
if(!mSearchListView->mCurList->getRowCount())
|
||||
return;
|
||||
|
||||
wMenu->addAction(mAttachAction);
|
||||
wMenu->addAction(mRefreshAction);
|
||||
QMenu wCopyMenu("&Copy", this);
|
||||
ui->listProcesses->setupCopyMenu(&wCopyMenu);
|
||||
if(wCopyMenu.actions().length())
|
||||
{
|
||||
wMenu->addSeparator();
|
||||
wMenu->addMenu(&wCopyMenu);
|
||||
}
|
||||
wMenu->exec(mapToGlobal(pos)); //execute context menu
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define ATTACHDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "SearchListView.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -19,10 +20,13 @@ public:
|
|||
private slots:
|
||||
void on_btnAttach_clicked();
|
||||
void refresh();
|
||||
void processListContextMenu(const QPoint & pos);
|
||||
void processListContextMenu(QMenu* wMenu);
|
||||
|
||||
private:
|
||||
Ui::AttachDialog* ui;
|
||||
|
||||
SearchListView* mSearchListView;
|
||||
|
||||
QAction* mAttachAction;
|
||||
QAction* mRefreshAction;
|
||||
};
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>611</width>
|
||||
<height>293</height>
|
||||
<width>800</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -38,22 +38,6 @@
|
|||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="StdTable" name="listProcesses">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
|
@ -119,14 +103,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>StdTable</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>StdTable.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../resource.qrc"/>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue