mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
LibGUI: Add Model::Role::TextAlignment and remove from ColumnMetadata
This commit is contained in:
parent
3c819b8ff4
commit
2e03bded43
19 changed files with 211 additions and 100 deletions
|
@ -35,7 +35,7 @@ class ItemListModel final : public GUI::Model {
|
|||
public:
|
||||
static NonnullRefPtr<ItemListModel> create(Vector<T>& data) { return adopt(*new ItemListModel<T>(data)); }
|
||||
|
||||
virtual ~ItemListModel() override {}
|
||||
virtual ~ItemListModel() override { }
|
||||
|
||||
virtual int row_count(const GUI::ModelIndex&) const override
|
||||
{
|
||||
|
@ -54,11 +54,13 @@ public:
|
|||
|
||||
virtual ColumnMetadata column_metadata(int) const override
|
||||
{
|
||||
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||
return { 70 };
|
||||
}
|
||||
|
||||
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
|
||||
{
|
||||
if (role == Role::TextAlignment)
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
if (role == Role::Display)
|
||||
return m_data.at(index.row());
|
||||
|
||||
|
|
|
@ -61,13 +61,15 @@ GUI::Model::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column
|
|||
{
|
||||
switch (column) {
|
||||
case Column::Name:
|
||||
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||
return { 70 };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GUI::Variant IRCChannelMemberListModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
if (role == Role::TextAlignment)
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
case Column::Name:
|
||||
|
|
|
@ -63,13 +63,15 @@ GUI::Model::ColumnMetadata IRCWindowListModel::column_metadata(int column) const
|
|||
{
|
||||
switch (column) {
|
||||
case Column::Name:
|
||||
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||
return { 70 };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GUI::Variant IRCWindowListModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
if (role == Role::TextAlignment)
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
case Column::Name: {
|
||||
|
|
|
@ -77,46 +77,66 @@ GUI::Model::ColumnMetadata DevicesModel::column_metadata(int column) const
|
|||
{
|
||||
switch (column) {
|
||||
case Column::Device:
|
||||
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||
return { 70 };
|
||||
case Column::Major:
|
||||
return { 32, Gfx::TextAlignment::CenterRight };
|
||||
return { 32 };
|
||||
case Column::Minor:
|
||||
return { 32, Gfx::TextAlignment::CenterRight };
|
||||
return { 32 };
|
||||
case Column::ClassName:
|
||||
return { 120, Gfx::TextAlignment::CenterLeft };
|
||||
return { 120 };
|
||||
case Column::Type:
|
||||
return { 120, Gfx::TextAlignment::CenterLeft };
|
||||
return { 120 };
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
GUI::Variant DevicesModel::data(const GUI::ModelIndex& index, Role) const
|
||||
GUI::Variant DevicesModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
ASSERT(is_valid(index));
|
||||
|
||||
const DeviceInfo& device = m_devices[index.row()];
|
||||
switch (index.column()) {
|
||||
case Column::Device:
|
||||
return device.path;
|
||||
case Column::Major:
|
||||
return device.major;
|
||||
case Column::Minor:
|
||||
return device.minor;
|
||||
case Column::ClassName:
|
||||
return device.class_name;
|
||||
case Column::Type:
|
||||
switch (device.type) {
|
||||
case DeviceInfo::Type::Block:
|
||||
return "Block";
|
||||
case DeviceInfo::Type::Character:
|
||||
return "Character";
|
||||
if (role == Role::TextAlignment) {
|
||||
switch (index.column()) {
|
||||
case Column::Device:
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
case Column::Major:
|
||||
return Gfx::TextAlignment::CenterRight;
|
||||
case Column::Minor:
|
||||
return Gfx::TextAlignment::CenterRight;
|
||||
case Column::ClassName:
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
case Column::Type:
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
if (role == Role::Display) {
|
||||
const DeviceInfo& device = m_devices[index.row()];
|
||||
switch (index.column()) {
|
||||
case Column::Device:
|
||||
return device.path;
|
||||
case Column::Major:
|
||||
return device.major;
|
||||
case Column::Minor:
|
||||
return device.minor;
|
||||
case Column::ClassName:
|
||||
return device.class_name;
|
||||
case Column::Type:
|
||||
switch (device.type) {
|
||||
case DeviceInfo::Type::Block:
|
||||
return "Block";
|
||||
case DeviceInfo::Type::Character:
|
||||
return "Character";
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void DevicesModel::update()
|
||||
|
|
|
@ -132,59 +132,59 @@ GUI::Model::ColumnMetadata ProcessModel::column_metadata(int column) const
|
|||
{
|
||||
switch (column) {
|
||||
case Column::Icon:
|
||||
return { 16, Gfx::TextAlignment::CenterLeft };
|
||||
return { 16 };
|
||||
case Column::PID:
|
||||
return { 32, Gfx::TextAlignment::CenterRight };
|
||||
return { 32 };
|
||||
case Column::TID:
|
||||
return { 32, Gfx::TextAlignment::CenterRight };
|
||||
return { 32 };
|
||||
case Column::State:
|
||||
return { 75, Gfx::TextAlignment::CenterLeft };
|
||||
return { 75 };
|
||||
case Column::Priority:
|
||||
return { 16, Gfx::TextAlignment::CenterRight };
|
||||
return { 16 };
|
||||
case Column::EffectivePriority:
|
||||
return { 16, Gfx::TextAlignment::CenterRight };
|
||||
return { 16 };
|
||||
case Column::User:
|
||||
return { 50, Gfx::TextAlignment::CenterLeft };
|
||||
return { 50 };
|
||||
case Column::Virtual:
|
||||
return { 65, Gfx::TextAlignment::CenterRight };
|
||||
return { 65 };
|
||||
case Column::Physical:
|
||||
return { 65, Gfx::TextAlignment::CenterRight };
|
||||
return { 65 };
|
||||
case Column::DirtyPrivate:
|
||||
return { 65, Gfx::TextAlignment::CenterRight };
|
||||
return { 65 };
|
||||
case Column::CleanInode:
|
||||
return { 65, Gfx::TextAlignment::CenterRight };
|
||||
return { 65 };
|
||||
case Column::PurgeableVolatile:
|
||||
return { 65, Gfx::TextAlignment::CenterRight };
|
||||
return { 65 };
|
||||
case Column::PurgeableNonvolatile:
|
||||
return { 65, Gfx::TextAlignment::CenterRight };
|
||||
return { 65 };
|
||||
case Column::CPU:
|
||||
return { 32, Gfx::TextAlignment::CenterRight };
|
||||
return { 32 };
|
||||
case Column::Name:
|
||||
return { 140, Gfx::TextAlignment::CenterLeft };
|
||||
return { 140 };
|
||||
case Column::Syscalls:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::InodeFaults:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::ZeroFaults:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::CowFaults:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::FileReadBytes:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::FileWriteBytes:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::UnixSocketReadBytes:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::UnixSocketWriteBytes:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::IPv4SocketReadBytes:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::IPv4SocketWriteBytes:
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
return { 60 };
|
||||
case Column::Pledge:
|
||||
return { 60, Gfx::TextAlignment::CenterLeft };
|
||||
return { 60 };
|
||||
case Column::Veil:
|
||||
return { 60, Gfx::TextAlignment::CenterLeft };
|
||||
return { 60 };
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -199,6 +199,42 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const
|
|||
{
|
||||
ASSERT(is_valid(index));
|
||||
|
||||
if (role == Role::TextAlignment) {
|
||||
switch (index.column()) {
|
||||
case Column::Icon:
|
||||
case Column::Name:
|
||||
case Column::State:
|
||||
case Column::User:
|
||||
case Column::Pledge:
|
||||
case Column::Veil:
|
||||
return Gfx::TextAlignment::CenterLeft;
|
||||
case Column::PID:
|
||||
case Column::TID:
|
||||
case Column::Priority:
|
||||
case Column::EffectivePriority:
|
||||
case Column::Virtual:
|
||||
case Column::Physical:
|
||||
case Column::DirtyPrivate:
|
||||
case Column::CleanInode:
|
||||
case Column::PurgeableVolatile:
|
||||
case Column::PurgeableNonvolatile:
|
||||
case Column::CPU:
|
||||
case Column::Syscalls:
|
||||
case Column::InodeFaults:
|
||||
case Column::ZeroFaults:
|
||||
case Column::CowFaults:
|
||||
case Column::FileReadBytes:
|
||||
case Column::FileWriteBytes:
|
||||
case Column::UnixSocketReadBytes:
|
||||
case Column::UnixSocketWriteBytes:
|
||||
case Column::IPv4SocketReadBytes:
|
||||
case Column::IPv4SocketWriteBytes:
|
||||
return Gfx::TextAlignment::CenterRight;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
auto it = m_threads.find(m_pids[index.row()]);
|
||||
auto& thread = *(*it).value;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue