Commit f1acf395 authored by hjk's avatar hjk Committed by Christian Kandeler

remotelinux: use treeview to list processes.

Change-Id: Iafba9d5c61b5fd36242b25a262638f475e5e1858
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 010db470
......@@ -63,15 +63,16 @@ RemoteLinuxProcessesDialog::RemoteLinuxProcessesDialog(AbstractRemoteLinuxProces
processList->setParent(this);
d->ui.setupUi(this);
d->ui.tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
d->proxyModel.setSourceModel(d->processList);
d->proxyModel.setDynamicSortFilter(true);
d->proxyModel.setFilterKeyColumn(1);
d->ui.tableView->setModel(&d->proxyModel);
d->ui.treeView->setModel(&d->proxyModel);
d->ui.treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
d->ui.treeView->setUniformRowHeights(true);
connect(d->ui.processFilterLineEdit, SIGNAL(textChanged(QString)),
&d->proxyModel, SLOT(setFilterRegExp(QString)));
connect(d->ui.tableView->selectionModel(),
connect(d->ui.treeView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
SLOT(handleSelectionChanged()));
connect(d->ui.updateListButton, SIGNAL(clicked()),
......@@ -79,7 +80,7 @@ RemoteLinuxProcessesDialog::RemoteLinuxProcessesDialog(AbstractRemoteLinuxProces
connect(d->ui.killProcessButton, SIGNAL(clicked()), SLOT(killProcess()));
connect(d->processList, SIGNAL(error(QString)),
SLOT(handleRemoteError(QString)));
connect(d->processList, SIGNAL(modelReset()),
connect(d->processList, SIGNAL(processListUpdated()),
SLOT(handleProcessListUpdated()));
connect(d->processList, SIGNAL(processKilled()),
SLOT(handleProcessKilled()), Qt::QueuedConnection);
......@@ -104,7 +105,6 @@ void RemoteLinuxProcessesDialog::handleRemoteError(const QString &errorMsg)
void RemoteLinuxProcessesDialog::handleProcessListUpdated()
{
d->ui.updateListButton->setEnabled(true);
d->ui.tableView->resizeRowsToContents();
handleSelectionChanged();
}
......@@ -118,7 +118,7 @@ void RemoteLinuxProcessesDialog::updateProcessList()
void RemoteLinuxProcessesDialog::killProcess()
{
const QModelIndexList &indexes
= d->ui.tableView->selectionModel()->selectedIndexes();
= d->ui.treeView->selectionModel()->selectedIndexes();
if (indexes.empty())
return;
d->ui.updateListButton->setEnabled(false);
......@@ -133,7 +133,7 @@ void RemoteLinuxProcessesDialog::handleProcessKilled()
void RemoteLinuxProcessesDialog::handleSelectionChanged()
{
d->ui.killProcessButton->setEnabled(d->ui.tableView->selectionModel()->hasSelection());
d->ui.killProcessButton->setEnabled(d->ui.treeView->selectionModel()->hasSelection());
}
} // namespace RemoteLinux
......@@ -47,23 +47,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTableView" name="tableView">
<property name="showGrid">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>100</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
<widget class="QTreeView" name="treeView"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
......
......@@ -90,8 +90,11 @@ void AbstractRemoteLinuxProcessList::update()
{
QTC_ASSERT(d->state == Inactive, return);
beginResetModel();
d->remoteProcesses.clear();
if (!d->remoteProcesses.isEmpty()) {
beginRemoveRows(QModelIndex(), 0, d->remoteProcesses.count() - 1);
d->remoteProcesses.clear();
endRemoveRows();
}
d->state = Listing;
startProcess(listProcessesCommandLine());
}
......@@ -134,13 +137,17 @@ QVariant AbstractRemoteLinuxProcessList::headerData(int section, Qt::Orientation
QVariant AbstractRemoteLinuxProcessList::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() >= rowCount(index.parent())
|| index.column() >= columnCount() || role != Qt::DisplayRole)
|| index.column() >= columnCount())
return QVariant();
const RemoteProcess &proc = d->remoteProcesses.at(index.row());
if (index.column() == 0)
return proc.pid;
else
return proc.cmdLine;
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
const RemoteProcess &proc = d->remoteProcesses.at(index.row());
if (index.column() == 0)
return proc.pid;
else
return proc.cmdLine;
}
return QVariant();
}
void AbstractRemoteLinuxProcessList::handleRemoteStdOut(const QByteArray &output)
......@@ -182,8 +189,14 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus)
case SshRemoteProcess::ExitedNormally:
if (d->process.processExitCode() == 0) {
if (d->state == Listing) {
d->remoteProcesses = buildProcessList(QString::fromUtf8(d->remoteStdout.data(),
beginResetModel();
QList<RemoteProcess> processes = buildProcessList(QString::fromUtf8(d->remoteStdout.data(),
d->remoteStdout.count()));
if (!processes.isEmpty()) {
beginInsertRows(QModelIndex(), 0, processes.count()-1);
d->remoteProcesses = processes;
endInsertRows();
}
}
} else {
d->errorMsg = tr("Remote process failed.");
......@@ -193,6 +206,9 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus)
Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid exit status");
}
if (d->state == Listing)
emit processListUpdated();
if (!d->errorMsg.isEmpty()) {
if (!d->remoteStderr.isEmpty())
d->errorMsg += tr("\nRemote stderr was: %1").arg(QString::fromUtf8(d->remoteStderr));
......@@ -201,9 +217,6 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus)
emit processKilled();
}
if (d->state == Listing)
endResetModel();
setFinished();
}
......
......@@ -57,6 +57,7 @@ public:
QString commandLineAt(int row) const;
signals:
void processListUpdated();
void error(const QString &errorMsg);
void processKilled();
......
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