1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 04:14:58 +00:00
serenity/Userland/Applications/SystemMonitor/DevicesModel.h
sin-ack ca2c81251a Everywhere: Replace Model::update() with Model::invalidate()
Most of the models were just calling did_update anyway, which is
pointless since it can be unified to the base Model class. Instead, code
calling update() will now call invalidate(), which functions identically
and is more obvious in what it does.

Additionally, a default implementation is provided, which removes the
need to add empty implementations of update() for each model subclass.

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-08-06 19:14:31 +02:00

51 lines
1.1 KiB
C++

/*
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibGUI/Model.h>
class DevicesModel final : public GUI::Model {
public:
enum Column {
Device = 0,
Major,
Minor,
ClassName,
Type,
__Count
};
virtual ~DevicesModel() override;
static NonnullRefPtr<DevicesModel> create();
virtual int row_count(const GUI::ModelIndex&) const override;
virtual int column_count(const GUI::ModelIndex&) const override;
virtual String column_name(int column) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
// FIXME: This should be moved to granularly updating itself.
virtual void invalidate() override;
private:
DevicesModel();
struct DeviceInfo {
String path;
unsigned major;
unsigned minor;
String class_name;
enum Type {
Block,
Character
};
Type type;
};
Vector<DeviceInfo> m_devices;
};