debugger: simplify StartGdbServerDialog

Change-Id: Icd2b009b9d69faf4361868d9561df9e2c5ced928
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-07-25 04:11:50 +02:00
parent 6cbcdf243f
commit 04c97da81e
2 changed files with 27 additions and 46 deletions

View File

@@ -37,8 +37,7 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <projectexplorer/profilechooser.h> #include <projectexplorer/profilechooser.h>
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/profileinformation.h>
#include <projectexplorer/devicesupport/devicemanagermodel.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/portlist.h> #include <utils/portlist.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -87,17 +86,16 @@ public:
LinuxDeviceConfiguration::ConstPtr currentDevice() const LinuxDeviceConfiguration::ConstPtr currentDevice() const
{ {
return deviceManagerModel->device(deviceComboBox->currentIndex()) Profile *profile = profileChooser->currentProfile();
.dynamicCast<const LinuxDeviceConfiguration>(); IDevice::ConstPtr device = DeviceProfileInformation::device(profile);
return device.dynamicCast<const LinuxDeviceConfiguration>();
} }
StartGdbServerDialog *q; StartGdbServerDialog *q;
bool startServerOnly; bool startServerOnly;
AbstractRemoteLinuxProcessList *processList; AbstractRemoteLinuxProcessList *processList;
QSortFilterProxyModel proxyModel; QSortFilterProxyModel proxyModel;
DeviceManagerModel *deviceManagerModel;
QComboBox *deviceComboBox;
QLineEdit *processFilterLineEdit; QLineEdit *processFilterLineEdit;
QTableView *tableView; QTableView *tableView;
QPushButton *attachProcessButton; QPushButton *attachProcessButton;
@@ -117,13 +115,7 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q
{ {
settings = ICore::settings(); settings = ICore::settings();
deviceComboBox = new QComboBox(q);
profileChooser = new ProfileChooser(q, ProfileChooser::RemoteDebugging); profileChooser = new ProfileChooser(q, ProfileChooser::RemoteDebugging);
// sysrootPathChooser = new PathChooser(q);
// sysrootPathChooser->setExpectedKind(PathChooser::Directory);
// sysrootPathChooser->setPromptDialogTitle(StartGdbServerDialog::tr("Select Sysroot"));
// sysrootPathChooser->setPath(settings->value(LastSysroot).toString());
//executablePathChooser = new PathChooser(q); //executablePathChooser = new PathChooser(q);
//executablePathChooser->setExpectedKind(PathChooser::File); //executablePathChooser->setExpectedKind(PathChooser::File);
@@ -152,7 +144,6 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q
textBrowser->setEnabled(false); textBrowser->setEnabled(false);
QFormLayout *formLayout = new QFormLayout(); QFormLayout *formLayout = new QFormLayout();
formLayout->addRow(StartGdbServerDialog::tr("Device:"), deviceComboBox);
formLayout->addRow(StartGdbServerDialog::tr("Target:"), profileChooser); formLayout->addRow(StartGdbServerDialog::tr("Target:"), profileChooser);
formLayout->addRow(StartGdbServerDialog::tr("&Filter entries:"), processFilterLineEdit); formLayout->addRow(StartGdbServerDialog::tr("&Filter entries:"), processFilterLineEdit);
@@ -176,39 +167,32 @@ StartGdbServerDialog::StartGdbServerDialog(QWidget *parent) :
{ {
setWindowTitle(tr("List of Remote Processes")); setWindowTitle(tr("List of Remote Processes"));
d->deviceManagerModel = new DeviceManagerModel(DeviceManager::instance(), this);
QObject::connect(d->closeButton, SIGNAL(clicked()), this, SLOT(reject())); QObject::connect(d->closeButton, SIGNAL(clicked()), this, SLOT(reject()));
d->deviceComboBox->setModel(d->deviceManagerModel);
d->deviceComboBox->setCurrentIndex(d->settings->value(LastDevice).toInt());
connect(&d->gatherer, SIGNAL(error(QString)), SLOT(portGathererError(QString))); connect(&d->gatherer, SIGNAL(error(QString)), SLOT(portGathererError(QString)));
connect(&d->gatherer, SIGNAL(portListReady()), SLOT(portListReady())); connect(&d->gatherer, SIGNAL(portListReady()), SLOT(portListReady()));
if (d->deviceManagerModel->rowCount() == 0) {
d->tableView->setEnabled(false);
} else {
d->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
d->proxyModel.setDynamicSortFilter(true);
d->proxyModel.setFilterKeyColumn(-1);
d->tableView->setModel(&d->proxyModel);
connect(d->processFilterLineEdit, SIGNAL(textChanged(QString)),
&d->proxyModel, SLOT(setFilterRegExp(QString)));
connect(d->tableView->selectionModel(), d->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), d->proxyModel.setDynamicSortFilter(true);
d->proxyModel.setFilterKeyColumn(-1);
d->tableView->setModel(&d->proxyModel);
connect(d->processFilterLineEdit, SIGNAL(textChanged(QString)),
&d->proxyModel, SLOT(setFilterRegExp(QString)));
connect(d->tableView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(updateButtons()));
connect(d->profileChooser, SIGNAL(activated(int)),
SLOT(updateButtons())); SLOT(updateButtons()));
connect(d->profileChooser, SIGNAL(activated(int)), //connect(d->updateListButton, SIGNAL(clicked()),
SLOT(updateButtons())); // SLOT(updateProcessList()));
//connect(d->updateListButton, SIGNAL(clicked()), connect(d->attachProcessButton, SIGNAL(clicked()), SLOT(attachToProcess()));
// SLOT(updateProcessList())); connect(&d->proxyModel, SIGNAL(layoutChanged()),
connect(d->attachProcessButton, SIGNAL(clicked()), SLOT(attachToProcess())); SLOT(handleProcessListUpdated()));
connect(&d->proxyModel, SIGNAL(layoutChanged()), connect(d->profileChooser, SIGNAL(currentIndexChanged(int)),
SLOT(handleProcessListUpdated())); SLOT(attachToDevice()));
connect(d->deviceComboBox, SIGNAL(currentIndexChanged(int)), updateButtons();
SLOT(attachToDevice(int))); attachToDevice();
updateButtons();
attachToDevice(d->deviceComboBox->currentIndex());
}
} }
StartGdbServerDialog::~StartGdbServerDialog() StartGdbServerDialog::~StartGdbServerDialog()
@@ -217,11 +201,9 @@ StartGdbServerDialog::~StartGdbServerDialog()
delete d; delete d;
} }
void StartGdbServerDialog::attachToDevice(int modelIndex) void StartGdbServerDialog::attachToDevice()
{ {
LinuxDeviceConfiguration::ConstPtr device LinuxDeviceConfiguration::ConstPtr device = d->currentDevice();
= d->deviceManagerModel->device(modelIndex)
.dynamicCast<const LinuxDeviceConfiguration>();
// TODO: display error on non-matching device. // TODO: display error on non-matching device.
if (!device) if (!device)
return; return;
@@ -282,7 +264,6 @@ void StartGdbServerDialog::attachToProcess()
} }
d->settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString()); d->settings->setValue(LastProfile, d->profileChooser->currentProfileId().toString());
d->settings->setValue(LastDevice, d->deviceComboBox->currentIndex());
d->settings->setValue(LastProcessName, d->processFilterLineEdit->text()); d->settings->setValue(LastProcessName, d->processFilterLineEdit->text());
startGdbServerOnPort(port, process.pid); startGdbServerOnPort(port, process.pid);

View File

@@ -54,7 +54,7 @@ signals:
void processAborted(); void processAborted();
private slots: private slots:
void attachToDevice(int modelIndex); void attachToDevice();
void handleRemoteError(const QString &errorMessage); void handleRemoteError(const QString &errorMessage);
void handleProcessListUpdated(); void handleProcessListUpdated();
void updateProcessList(); void updateProcessList();