summaryrefslogtreecommitdiff
path: root/Applications/SystemMonitor/DevicesModel.h
blob: 0e4e29dac6917eb0b334fd92b5e5cdb52ab7296e (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
#pragma once

#include <AK/String.h>
#include <AK/Vector.h>
#include <LibGUI/GModel.h>

class DevicesModel final : public GModel {
public:
    enum Column {
        Device = 0,
        Major,
        Minor,
        ClassName,
        Type,
        __Count
    };

    virtual ~DevicesModel() override;
    static NonnullRefPtr<DevicesModel> create();

    virtual int row_count(const GModelIndex&) const override;
    virtual int column_count(const GModelIndex&) const override;
    virtual String column_name(int column) const override;
    virtual ColumnMetadata column_metadata(int column) const override;
    virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
    virtual void update() override;

private:
    DevicesModel();

    struct DeviceInfo {
        String path;
        unsigned major;
        unsigned minor;
        String class_name;
        enum Type {
            Block,
            Character
        };
        Type type;
    };

    Vector<DeviceInfo> m_devices;
};