aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h
blob: d4be8f0ce768e7b5f48794761d496793bc71a7eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 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