forked from qt-creator/qt-creator
ProjectExplorer: Merge DeviceProcessList into ProcessList
The abstraction was not used anymore. Change-Id: I756ae65b9164d0032c3e6a26c3a123fc50f72a75 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -828,7 +828,7 @@ ProcessInterface *DockerDevice::createProcessInterface() const
|
|||||||
return new DockerProcessImpl(this->sharedFromThis(), d);
|
return new DockerProcessImpl(this->sharedFromThis(), d);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProcessList *DockerDevice::createProcessListModel(QObject *parent) const
|
ProcessList *DockerDevice::createProcessListModel(QObject *parent) const
|
||||||
{
|
{
|
||||||
return new ProcessList(sharedFromThis(), parent);
|
return new ProcessList(sharedFromThis(), parent);
|
||||||
}
|
}
|
||||||
|
@@ -74,7 +74,7 @@ public:
|
|||||||
Utils::ProcessInterface *createProcessInterface() const override;
|
Utils::ProcessInterface *createProcessInterface() const override;
|
||||||
|
|
||||||
bool canCreateProcessModel() const override { return true; }
|
bool canCreateProcessModel() const override { return true; }
|
||||||
ProjectExplorer::DeviceProcessList *createProcessListModel(QObject *parent) const override;
|
ProjectExplorer::ProcessList *createProcessListModel(QObject *parent) const override;
|
||||||
bool hasDeviceTester() const override { return false; }
|
bool hasDeviceTester() const override { return false; }
|
||||||
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
||||||
bool usableAsBuildDevice() const override;
|
bool usableAsBuildDevice() const override;
|
||||||
|
@@ -55,7 +55,6 @@ add_qtc_plugin(ProjectExplorer
|
|||||||
devicesupport/devicemanager.cpp devicesupport/devicemanager.h
|
devicesupport/devicemanager.cpp devicesupport/devicemanager.h
|
||||||
devicesupport/devicemanagermodel.cpp devicesupport/devicemanagermodel.h
|
devicesupport/devicemanagermodel.cpp devicesupport/devicemanagermodel.h
|
||||||
devicesupport/deviceprocessesdialog.cpp devicesupport/deviceprocessesdialog.h
|
devicesupport/deviceprocessesdialog.cpp devicesupport/deviceprocessesdialog.h
|
||||||
devicesupport/deviceprocesslist.cpp devicesupport/deviceprocesslist.h
|
|
||||||
devicesupport/devicesettingspage.cpp devicesupport/devicesettingspage.h
|
devicesupport/devicesettingspage.cpp devicesupport/devicesettingspage.h
|
||||||
devicesupport/devicesettingswidget.cpp devicesupport/devicesettingswidget.h
|
devicesupport/devicesettingswidget.cpp devicesupport/devicesettingswidget.h
|
||||||
devicesupport/devicetestdialog.cpp devicesupport/devicetestdialog.h
|
devicesupport/devicetestdialog.cpp devicesupport/devicetestdialog.h
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
#include "../projectexplorerconstants.h"
|
#include "../projectexplorerconstants.h"
|
||||||
#include "../projectexplorertr.h"
|
#include "../projectexplorertr.h"
|
||||||
#include "desktopprocesssignaloperation.h"
|
#include "desktopprocesssignaloperation.h"
|
||||||
#include "deviceprocesslist.h"
|
|
||||||
#include "processlist.h"
|
#include "processlist.h"
|
||||||
|
|
||||||
#include <coreplugin/fileutils.h>
|
#include <coreplugin/fileutils.h>
|
||||||
@@ -90,7 +89,7 @@ bool DesktopDevice::canCreateProcessModel() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProcessList *DesktopDevice::createProcessListModel(QObject *parent) const
|
ProcessList *DesktopDevice::createProcessListModel(QObject *parent) const
|
||||||
{
|
{
|
||||||
return new ProcessList(sharedFromThis(), parent);
|
return new ProcessList(sharedFromThis(), parent);
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ public:
|
|||||||
|
|
||||||
IDeviceWidget *createWidget() override;
|
IDeviceWidget *createWidget() override;
|
||||||
bool canCreateProcessModel() const override;
|
bool canCreateProcessModel() const override;
|
||||||
DeviceProcessList *createProcessListModel(QObject *parent) const override;
|
ProcessList *createProcessListModel(QObject *parent) const override;
|
||||||
DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||||
QUrl toolControlChannel(const ControlChannelHint &) const override;
|
QUrl toolControlChannel(const ControlChannelHint &) const override;
|
||||||
bool usableAsBuildDevice() const override;
|
bool usableAsBuildDevice() const override;
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "deviceprocessesdialog.h"
|
#include "deviceprocessesdialog.h"
|
||||||
|
|
||||||
#include "deviceprocesslist.h"
|
|
||||||
#include "idevice.h"
|
#include "idevice.h"
|
||||||
|
#include "processlist.h"
|
||||||
#include "../kitchooser.h"
|
#include "../kitchooser.h"
|
||||||
#include "../kitinformation.h"
|
#include "../kitinformation.h"
|
||||||
#include "../projectexplorertr.h"
|
#include "../projectexplorertr.h"
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
ProcessInfo selectedProcess() const;
|
ProcessInfo selectedProcess() const;
|
||||||
|
|
||||||
QDialog *q;
|
QDialog *q;
|
||||||
std::unique_ptr<DeviceProcessList> processList;
|
std::unique_ptr<ProcessList> processList;
|
||||||
ProcessListFilterModel proxyModel;
|
ProcessListFilterModel proxyModel;
|
||||||
QLabel *kitLabel;
|
QLabel *kitLabel;
|
||||||
KitChooser *kitChooser;
|
KitChooser *kitChooser;
|
||||||
@@ -191,11 +191,11 @@ void DeviceProcessesDialogPrivate::setDevice(const IDevice::ConstPtr &device)
|
|||||||
QTC_ASSERT(processList, return);
|
QTC_ASSERT(processList, return);
|
||||||
proxyModel.setSourceModel(processList->model());
|
proxyModel.setSourceModel(processList->model());
|
||||||
|
|
||||||
connect(processList.get(), &DeviceProcessList::error,
|
connect(processList.get(), &ProcessList::error,
|
||||||
this, &DeviceProcessesDialogPrivate::handleRemoteError);
|
this, &DeviceProcessesDialogPrivate::handleRemoteError);
|
||||||
connect(processList.get(), &DeviceProcessList::processListUpdated,
|
connect(processList.get(), &ProcessList::processListUpdated,
|
||||||
this, &DeviceProcessesDialogPrivate::handleProcessListUpdated);
|
this, &DeviceProcessesDialogPrivate::handleProcessListUpdated);
|
||||||
connect(processList.get(), &DeviceProcessList::processKilled,
|
connect(processList.get(), &ProcessList::processKilled,
|
||||||
this, &DeviceProcessesDialogPrivate::handleProcessKilled, Qt::QueuedConnection);
|
this, &DeviceProcessesDialogPrivate::handleProcessKilled, Qt::QueuedConnection);
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
@@ -1,146 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "deviceprocesslist.h"
|
|
||||||
|
|
||||||
#include "idevice.h"
|
|
||||||
#include "../projectexplorertr.h"
|
|
||||||
|
|
||||||
#include <utils/processinfo.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
#include <utils/treemodel.h>
|
|
||||||
|
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
enum State { Inactive, Listing, Killing };
|
|
||||||
|
|
||||||
class DeviceProcessTreeItem : public TreeItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DeviceProcessTreeItem(const ProcessInfo &p, Qt::ItemFlags f) : process(p), fl(f) {}
|
|
||||||
|
|
||||||
QVariant data(int column, int role) const final;
|
|
||||||
Qt::ItemFlags flags(int) const final { return fl; }
|
|
||||||
|
|
||||||
ProcessInfo process;
|
|
||||||
Qt::ItemFlags fl;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DeviceProcessListPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DeviceProcessListPrivate(const IDevice::ConstPtr &device)
|
|
||||||
: device(device)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
qint64 ownPid = -1;
|
|
||||||
const IDevice::ConstPtr device;
|
|
||||||
State state = Inactive;
|
|
||||||
TreeModel<TypedTreeItem<DeviceProcessTreeItem>, DeviceProcessTreeItem> model;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
using namespace Internal;
|
|
||||||
|
|
||||||
DeviceProcessList::DeviceProcessList(const IDevice::ConstPtr &device, QObject *parent)
|
|
||||||
: QObject(parent), d(std::make_unique<DeviceProcessListPrivate>(device))
|
|
||||||
{
|
|
||||||
d->model.setHeader({Tr::tr("Process ID"), Tr::tr("Command Line")});
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceProcessList::~DeviceProcessList() = default;
|
|
||||||
|
|
||||||
void DeviceProcessList::update()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(d->state == Inactive, return);
|
|
||||||
QTC_ASSERT(device(), return);
|
|
||||||
|
|
||||||
d->model.clear();
|
|
||||||
d->model.rootItem()->appendChild(
|
|
||||||
new DeviceProcessTreeItem(
|
|
||||||
{0, Tr::tr("Fetching process list. This might take a while."), ""},
|
|
||||||
Qt::NoItemFlags));
|
|
||||||
d->state = Listing;
|
|
||||||
doUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceProcessList::reportProcessListUpdated(const QList<ProcessInfo> &processes)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(d->state == Listing, return);
|
|
||||||
setFinished();
|
|
||||||
d->model.clear();
|
|
||||||
for (const ProcessInfo &process : processes) {
|
|
||||||
Qt::ItemFlags fl;
|
|
||||||
if (process.processId != d->ownPid)
|
|
||||||
fl = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
||||||
d->model.rootItem()->appendChild(new DeviceProcessTreeItem(process, fl));
|
|
||||||
}
|
|
||||||
|
|
||||||
emit processListUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceProcessList::killProcess(int row)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(row >= 0 && row < d->model.rootItem()->childCount(), return);
|
|
||||||
QTC_ASSERT(d->state == Inactive, return);
|
|
||||||
QTC_ASSERT(device(), return);
|
|
||||||
|
|
||||||
d->state = Killing;
|
|
||||||
doKillProcess(at(row));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceProcessList::setOwnPid(qint64 pid)
|
|
||||||
{
|
|
||||||
d->ownPid = pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceProcessList::reportProcessKilled()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(d->state == Killing, return);
|
|
||||||
setFinished();
|
|
||||||
emit processKilled();
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcessInfo DeviceProcessList::at(int row) const
|
|
||||||
{
|
|
||||||
return d->model.rootItem()->childAt(row)->process;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemModel *DeviceProcessList::model() const
|
|
||||||
{
|
|
||||||
return &d->model;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant DeviceProcessTreeItem::data(int column, int role) const
|
|
||||||
{
|
|
||||||
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
|
|
||||||
if (column == 0)
|
|
||||||
return process.processId ? process.processId : QVariant();
|
|
||||||
else
|
|
||||||
return process.commandLine;
|
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceProcessList::setFinished()
|
|
||||||
{
|
|
||||||
d->state = Inactive;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDevice::ConstPtr DeviceProcessList::device() const
|
|
||||||
{
|
|
||||||
return d->device;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceProcessList::reportError(const QString &message)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(d->state != Inactive, return);
|
|
||||||
setFinished();
|
|
||||||
emit error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
|
@@ -1,56 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../projectexplorer_export.h"
|
|
||||||
#include "idevicefwd.h"
|
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Utils { class ProcessInfo; }
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
|
||||||
|
|
||||||
namespace Internal { class DeviceProcessListPrivate; }
|
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT DeviceProcessList : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
DeviceProcessList(const IDeviceConstPtr &device, QObject *parent = nullptr);
|
|
||||||
~DeviceProcessList() override;
|
|
||||||
|
|
||||||
void update();
|
|
||||||
void killProcess(int row);
|
|
||||||
void setOwnPid(qint64 pid);
|
|
||||||
|
|
||||||
Utils::ProcessInfo at(int row) const;
|
|
||||||
QAbstractItemModel *model() const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void processListUpdated();
|
|
||||||
void error(const QString &errorMsg);
|
|
||||||
void processKilled();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void reportError(const QString &message);
|
|
||||||
void reportProcessKilled();
|
|
||||||
void reportProcessListUpdated(const QList<Utils::ProcessInfo> &processes);
|
|
||||||
|
|
||||||
IDeviceConstPtr device() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual void doUpdate() = 0;
|
|
||||||
virtual void doKillProcess(const Utils::ProcessInfo &process) = 0;
|
|
||||||
|
|
||||||
void setFinished();
|
|
||||||
|
|
||||||
const std::unique_ptr<Internal::DeviceProcessListPrivate> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
|
@@ -4,8 +4,8 @@
|
|||||||
#include "idevice.h"
|
#include "idevice.h"
|
||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "deviceprocesslist.h"
|
|
||||||
#include "idevicefactory.h"
|
#include "idevicefactory.h"
|
||||||
|
#include "processlist.h"
|
||||||
#include "sshparameters.h"
|
#include "sshparameters.h"
|
||||||
|
|
||||||
#include "../kit.h"
|
#include "../kit.h"
|
||||||
@@ -393,7 +393,7 @@ PortsGatheringMethod IDevice::portsGatheringMethod() const
|
|||||||
&Port::parseFromCommandOutput};
|
&Port::parseFromCommandOutput};
|
||||||
};
|
};
|
||||||
|
|
||||||
DeviceProcessList *IDevice::createProcessListModel(QObject *parent) const
|
ProcessList *IDevice::createProcessListModel(QObject *parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent)
|
Q_UNUSED(parent)
|
||||||
QTC_ASSERT(false, qDebug("This should not have been called..."); return nullptr);
|
QTC_ASSERT(false, qDebug("This should not have been called..."); return nullptr);
|
||||||
|
@@ -41,7 +41,7 @@ class Process;
|
|||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class DeviceProcessList;
|
class ProcessList;
|
||||||
class FileTransferInterface;
|
class FileTransferInterface;
|
||||||
class FileTransferSetupData;
|
class FileTransferSetupData;
|
||||||
class Kit;
|
class Kit;
|
||||||
@@ -142,7 +142,7 @@ public:
|
|||||||
|
|
||||||
virtual PortsGatheringMethod portsGatheringMethod() const;
|
virtual PortsGatheringMethod portsGatheringMethod() const;
|
||||||
virtual bool canCreateProcessModel() const { return false; }
|
virtual bool canCreateProcessModel() const { return false; }
|
||||||
virtual DeviceProcessList *createProcessListModel(QObject *parent = nullptr) const;
|
virtual ProcessList *createProcessListModel(QObject *parent = nullptr) const;
|
||||||
virtual bool hasDeviceTester() const { return false; }
|
virtual bool hasDeviceTester() const { return false; }
|
||||||
virtual DeviceTester *createDeviceTester() const;
|
virtual DeviceTester *createDeviceTester() const;
|
||||||
|
|
||||||
|
@@ -3,8 +3,12 @@
|
|||||||
|
|
||||||
#include "processlist.h"
|
#include "processlist.h"
|
||||||
|
|
||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include "idevice.h"
|
||||||
|
#include "../projectexplorertr.h"
|
||||||
|
|
||||||
#include <utils/processinfo.h>
|
#include <utils/processinfo.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -17,45 +21,140 @@
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
enum State { Inactive, Listing, Killing };
|
||||||
|
|
||||||
|
class DeviceProcessTreeItem : public TreeItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceProcessTreeItem(const ProcessInfo &p, Qt::ItemFlags f) : process(p), fl(f) {}
|
||||||
|
|
||||||
|
QVariant data(int column, int role) const final;
|
||||||
|
Qt::ItemFlags flags(int) const final { return fl; }
|
||||||
|
|
||||||
|
ProcessInfo process;
|
||||||
|
Qt::ItemFlags fl;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DeviceProcessListPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeviceProcessListPrivate(const IDevice::ConstPtr &device)
|
||||||
|
: device(device)
|
||||||
|
{
|
||||||
|
// FIXME: This should not be used for non-desktop cases.
|
||||||
|
#if defined(Q_OS_UNIX)
|
||||||
|
ownPid = getpid();
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
ownPid = GetCurrentProcessId();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 ownPid = -1;
|
||||||
|
const IDevice::ConstPtr device;
|
||||||
|
State state = Inactive;
|
||||||
|
TreeModel<TypedTreeItem<DeviceProcessTreeItem>, DeviceProcessTreeItem> model;
|
||||||
|
DeviceProcessSignalOperation::Ptr signalOperation;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
using namespace Internal;
|
||||||
|
|
||||||
ProcessList::ProcessList(const IDevice::ConstPtr &device, QObject *parent)
|
ProcessList::ProcessList(const IDevice::ConstPtr &device, QObject *parent)
|
||||||
: DeviceProcessList(device, parent)
|
: QObject(parent), d(std::make_unique<DeviceProcessListPrivate>(device))
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_UNIX)
|
d->model.setHeader({Tr::tr("Process ID"), Tr::tr("Command Line")});
|
||||||
setOwnPid(getpid());
|
|
||||||
#elif defined(Q_OS_WIN)
|
|
||||||
setOwnPid(GetCurrentProcessId());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessList::doKillProcess(const ProcessInfo &processInfo)
|
ProcessList::~ProcessList() = default;
|
||||||
|
|
||||||
|
void ProcessList::update()
|
||||||
{
|
{
|
||||||
m_signalOperation = device()->signalOperation();
|
QTC_ASSERT(d->state == Inactive, return);
|
||||||
connect(m_signalOperation.data(),
|
QTC_ASSERT(d->device, return);
|
||||||
&DeviceProcessSignalOperation::finished,
|
|
||||||
this,
|
d->model.clear();
|
||||||
&ProcessList::reportDelayedKillStatus);
|
d->model.rootItem()->appendChild(
|
||||||
m_signalOperation->killProcess(processInfo.processId);
|
new DeviceProcessTreeItem(
|
||||||
|
{0, Tr::tr("Fetching process list. This might take a while."), ""},
|
||||||
|
Qt::NoItemFlags));
|
||||||
|
d->state = Listing;
|
||||||
|
|
||||||
|
QTimer::singleShot(0, this, &ProcessList::handleUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessList::killProcess(int row)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(row >= 0 && row < d->model.rootItem()->childCount(), return);
|
||||||
|
QTC_ASSERT(d->state == Inactive, return);
|
||||||
|
QTC_ASSERT(d->device, return);
|
||||||
|
|
||||||
|
d->state = Killing;
|
||||||
|
|
||||||
|
const ProcessInfo processInfo = at(row);
|
||||||
|
d->signalOperation = d->device->signalOperation();
|
||||||
|
connect(d->signalOperation.data(), &DeviceProcessSignalOperation::finished,
|
||||||
|
this, &ProcessList::reportDelayedKillStatus);
|
||||||
|
d->signalOperation->killProcess(processInfo.processId);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessInfo ProcessList::at(int row) const
|
||||||
|
{
|
||||||
|
return d->model.rootItem()->childAt(row)->process;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAbstractItemModel *ProcessList::model() const
|
||||||
|
{
|
||||||
|
return &d->model;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant DeviceProcessTreeItem::data(int column, int role) const
|
||||||
|
{
|
||||||
|
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
|
||||||
|
if (column == 0)
|
||||||
|
return process.processId ? process.processId : QVariant();
|
||||||
|
else
|
||||||
|
return process.commandLine;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessList::setFinished()
|
||||||
|
{
|
||||||
|
d->state = Inactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessList::handleUpdate()
|
void ProcessList::handleUpdate()
|
||||||
{
|
{
|
||||||
reportProcessListUpdated(ProcessInfo::processInfoList(DeviceProcessList::device()->rootPath()));
|
const QList<ProcessInfo> processes = ProcessInfo::processInfoList(d->device->rootPath());
|
||||||
}
|
QTC_ASSERT(d->state == Listing, return);
|
||||||
|
setFinished();
|
||||||
|
d->model.clear();
|
||||||
|
for (const ProcessInfo &process : processes) {
|
||||||
|
Qt::ItemFlags fl;
|
||||||
|
if (process.processId != d->ownPid)
|
||||||
|
fl = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
d->model.rootItem()->appendChild(new DeviceProcessTreeItem(process, fl));
|
||||||
|
}
|
||||||
|
|
||||||
void ProcessList::doUpdate()
|
emit processListUpdated();
|
||||||
{
|
|
||||||
QTimer::singleShot(0, this, &ProcessList::handleUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessList::reportDelayedKillStatus(const QString &errorMessage)
|
void ProcessList::reportDelayedKillStatus(const QString &errorMessage)
|
||||||
{
|
{
|
||||||
if (errorMessage.isEmpty())
|
if (errorMessage.isEmpty()) {
|
||||||
reportProcessKilled();
|
QTC_CHECK(d->state == Killing);
|
||||||
else
|
setFinished();
|
||||||
reportError(errorMessage);
|
emit processKilled();
|
||||||
|
} else {
|
||||||
|
QTC_CHECK(d->state != Inactive);
|
||||||
|
setFinished();
|
||||||
|
emit error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
m_signalOperation.reset();
|
d->signalOperation.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // ProjectExplorer
|
||||||
|
@@ -3,28 +3,46 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "deviceprocesslist.h"
|
#include "../projectexplorer_export.h"
|
||||||
#include "idevice.h"
|
#include "idevicefwd.h"
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace Utils { class ProcessInfo; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT ProcessList : public DeviceProcessList
|
namespace Internal { class DeviceProcessListPrivate; }
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT ProcessList : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProcessList(const IDeviceConstPtr &device, QObject *parent = nullptr);
|
ProcessList(const IDeviceConstPtr &device, QObject *parent = nullptr);
|
||||||
|
~ProcessList() override;
|
||||||
|
|
||||||
private:
|
void update();
|
||||||
void doUpdate() override;
|
void killProcess(int row);
|
||||||
void doKillProcess(const Utils::ProcessInfo &process) override;
|
|
||||||
|
Utils::ProcessInfo at(int row) const;
|
||||||
|
QAbstractItemModel *model() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void processListUpdated();
|
||||||
|
void error(const QString &errorMsg);
|
||||||
|
void processKilled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleUpdate();
|
void handleUpdate();
|
||||||
void reportDelayedKillStatus(const QString &errorMessage);
|
void reportDelayedKillStatus(const QString &errorMessage);
|
||||||
|
|
||||||
private:
|
void setFinished();
|
||||||
DeviceProcessSignalOperation::Ptr m_signalOperation;
|
|
||||||
|
const std::unique_ptr<Internal::DeviceProcessListPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -210,7 +210,6 @@ Project {
|
|||||||
"devicemanager.cpp", "devicemanager.h",
|
"devicemanager.cpp", "devicemanager.h",
|
||||||
"devicemanagermodel.cpp", "devicemanagermodel.h",
|
"devicemanagermodel.cpp", "devicemanagermodel.h",
|
||||||
"deviceprocessesdialog.cpp", "deviceprocessesdialog.h",
|
"deviceprocessesdialog.cpp", "deviceprocessesdialog.h",
|
||||||
"deviceprocesslist.cpp", "deviceprocesslist.h",
|
|
||||||
"devicesettingspage.cpp", "devicesettingspage.h",
|
"devicesettingspage.cpp", "devicesettingspage.h",
|
||||||
"devicesettingswidget.cpp", "devicesettingswidget.h",
|
"devicesettingswidget.cpp", "devicesettingswidget.h",
|
||||||
"devicetestdialog.cpp", "devicetestdialog.h",
|
"devicetestdialog.cpp", "devicetestdialog.h",
|
||||||
|
@@ -995,7 +995,7 @@ IDeviceWidget *LinuxDevice::createWidget()
|
|||||||
return new Internal::GenericLinuxDeviceConfigurationWidget(sharedFromThis());
|
return new Internal::GenericLinuxDeviceConfigurationWidget(sharedFromThis());
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceProcessList *LinuxDevice::createProcessListModel(QObject *parent) const
|
ProcessList *LinuxDevice::createProcessListModel(QObject *parent) const
|
||||||
{
|
{
|
||||||
return new ProcessList(sharedFromThis(), parent);
|
return new ProcessList(sharedFromThis(), parent);
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ public:
|
|||||||
ProjectExplorer::IDeviceWidget *createWidget() override;
|
ProjectExplorer::IDeviceWidget *createWidget() override;
|
||||||
|
|
||||||
bool canCreateProcessModel() const override { return true; }
|
bool canCreateProcessModel() const override { return true; }
|
||||||
ProjectExplorer::DeviceProcessList *createProcessListModel(QObject *parent) const override;
|
ProjectExplorer::ProcessList *createProcessListModel(QObject *parent) const override;
|
||||||
bool hasDeviceTester() const override { return true; }
|
bool hasDeviceTester() const override { return true; }
|
||||||
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
||||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||||
|
Reference in New Issue
Block a user