diff --git a/src/plugins/debugger/gdb/startgdbserverdialog.cpp b/src/plugins/debugger/gdb/startgdbserverdialog.cpp index aaf20651617..d1658ed6ffa 100644 --- a/src/plugins/debugger/gdb/startgdbserverdialog.cpp +++ b/src/plugins/debugger/gdb/startgdbserverdialog.cpp @@ -66,8 +66,8 @@ #include #include #include -#include #include +#include #include using namespace Core; @@ -100,7 +100,7 @@ public: QSortFilterProxyModel proxyModel; QLineEdit *processFilterLineEdit; - QTableView *tableView; + QTreeView *processView; QPushButton *attachProcessButton; QTextBrowser *textBrowser; QPushButton *closeButton; @@ -128,13 +128,13 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q processFilterLineEdit->setText(settings->value(LastProcessName).toString()); processFilterLineEdit->selectAll(); - tableView = new QTableView(q); - tableView->setShowGrid(false); - tableView->setSortingEnabled(true); - tableView->horizontalHeader()->setDefaultSectionSize(100); - tableView->horizontalHeader()->setStretchLastSection(true); - tableView->verticalHeader()->setVisible(false); - tableView->setSelectionMode(QAbstractItemView::SingleSelection); + processView = new QTreeView(q); + processView->setSortingEnabled(true); + processView->header()->setDefaultSectionSize(100); + processView->header()->setStretchLastSection(true); + processView->setAlternatingRowColors(true); + processView->setSelectionMode(QAbstractItemView::SingleSelection); + processView->setRootIsDecorated(false); attachProcessButton = new QPushButton(q); attachProcessButton->setText(StartGdbServerDialog::tr("&Attach to Selected Process")); @@ -154,7 +154,7 @@ StartGdbServerDialogPrivate::StartGdbServerDialogPrivate(StartGdbServerDialog *q horizontalLayout2->addWidget(attachProcessButton); horizontalLayout2->addWidget(closeButton); - formLayout->addRow(tableView); + formLayout->addRow(processView); formLayout->addRow(textBrowser); formLayout->addRow(horizontalLayout2); q->setLayout(formLayout); @@ -174,14 +174,14 @@ StartGdbServerDialog::StartGdbServerDialog(QWidget *parent) : connect(&d->gatherer, SIGNAL(error(QString)), SLOT(portGathererError(QString))); connect(&d->gatherer, SIGNAL(portListReady()), SLOT(portListReady())); - d->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); + d->processView->setSelectionBehavior(QAbstractItemView::SelectRows); d->proxyModel.setDynamicSortFilter(true); d->proxyModel.setFilterKeyColumn(-1); - d->tableView->setModel(&d->proxyModel); + d->processView->setModel(&d->proxyModel); connect(d->processFilterLineEdit, SIGNAL(textChanged(QString)), &d->proxyModel, SLOT(setFilterRegExp(QString))); - connect(d->tableView->selectionModel(), + connect(d->processView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateButtons())); connect(d->profileChooser, SIGNAL(activated(int)), @@ -229,7 +229,6 @@ void StartGdbServerDialog::handleRemoteError(const QString &errorMsg) void StartGdbServerDialog::handleProcessListUpdated() { - d->tableView->resizeRowsToContents(); updateButtons(); } @@ -244,8 +243,8 @@ void StartGdbServerDialog::updateProcessList() void StartGdbServerDialog::attachToProcess() { - const QModelIndexList &indexes = - d->tableView->selectionModel()->selectedIndexes(); + const QModelIndexList indexes = + d->processView->selectionModel()->selectedIndexes(); if (indexes.empty()) return; d->attachProcessButton->setEnabled(false); @@ -290,7 +289,7 @@ void StartGdbServerDialog::handleProcessKilled() void StartGdbServerDialog::updateButtons() { - d->attachProcessButton->setEnabled(d->tableView->selectionModel()->hasSelection() + d->attachProcessButton->setEnabled(d->processView->selectionModel()->hasSelection() || d->proxyModel.rowCount() == 1); } diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp index df3f49dcc37..ad3f689163c 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp @@ -54,7 +54,7 @@ public: using namespace Internal; DeviceProcessList::DeviceProcessList(const IDevice::ConstPtr &device, QObject *parent) - : QAbstractTableModel(parent), d(new DeviceProcessListPrivate(device)) + : QAbstractItemModel(parent), d(new DeviceProcessListPrivate(device)) { } @@ -63,6 +63,24 @@ DeviceProcessList::~DeviceProcessList() delete d; } +QModelIndex DeviceProcessList::parent(const QModelIndex &) const +{ + return QModelIndex(); +} + +bool DeviceProcessList::hasChildren(const QModelIndex &parent) const +{ + if (!parent.isValid()) + return rowCount(parent) > 0 && columnCount(parent) > 0; + return false; +} + +QModelIndex DeviceProcessList::index(int row, int column, const QModelIndex &parent) const +{ + return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex(); +} + + void DeviceProcessList::update() { QTC_ASSERT(d->state == Inactive, return); diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h index a763544ce4b..46da8d1c51b 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h +++ b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h @@ -32,7 +32,7 @@ #include "idevice.h" -#include +#include #include #include @@ -51,7 +51,7 @@ public: QString exe; }; -class PROJECTEXPLORER_EXPORT DeviceProcessList : public QAbstractTableModel +class PROJECTEXPLORER_EXPORT DeviceProcessList : public QAbstractItemModel { Q_OBJECT @@ -76,11 +76,14 @@ protected: IDevice::ConstPtr device() const; private: + QModelIndex index(int row, int column, const QModelIndex &parent) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + QModelIndex parent(const QModelIndex &) const; + bool hasChildren(const QModelIndex &parent) const; virtual void doUpdate() = 0; virtual void doKillProcess(const DeviceProcess &process) = 0;