mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 11:39:44 +03:00
LibGUI: GTableModel::data() should take a GModelIndex instead of int,int.
This commit is contained in:
parent
dc4e6dd7bc
commit
7df1121e1c
Notes:
sideshowbarker
2024-07-19 15:09:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7df1121e1c2
@ -135,10 +135,10 @@ String DirectoryTableModel::name_for_gid(uid_t gid) const
|
||||
return (*it).value;
|
||||
}
|
||||
|
||||
GVariant DirectoryTableModel::data(int row, int column) const
|
||||
GVariant DirectoryTableModel::data(const GModelIndex& index) const
|
||||
{
|
||||
auto& entry = this->entry(row);
|
||||
switch (column) {
|
||||
auto& entry = this->entry(index.row());
|
||||
switch (index.column()) {
|
||||
case Column::Icon: return icon_for(entry);
|
||||
case Column::Name: return entry.name;
|
||||
case Column::Size: return (int)entry.size;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
virtual int column_count() const override;
|
||||
virtual String column_name(int column) const override;
|
||||
virtual ColumnMetadata column_metadata(int column) const override;
|
||||
virtual GVariant data(int row, int column) const override;
|
||||
virtual GVariant data(const GModelIndex&) const override;
|
||||
virtual void update() override;
|
||||
virtual void activate(const GModelIndex&) override;
|
||||
|
||||
|
@ -80,12 +80,12 @@ static String pretty_byte_size(size_t size)
|
||||
return String::format("%uK", size / 1024);
|
||||
}
|
||||
|
||||
GVariant ProcessTableModel::data(int row, int column) const
|
||||
GVariant ProcessTableModel::data(const GModelIndex& index) const
|
||||
{
|
||||
ASSERT(is_valid({ row, column }));
|
||||
auto it = m_processes.find(m_pids[row]);
|
||||
ASSERT(is_valid(index));
|
||||
auto it = m_processes.find(m_pids[index.row()]);
|
||||
auto& process = *(*it).value;
|
||||
switch (column) {
|
||||
switch (index.column()) {
|
||||
case Column::Icon: return *m_generic_process_icon;
|
||||
case Column::PID: return process.current_state.pid;
|
||||
case Column::State: return process.current_state.state;
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
virtual int column_count() const override;
|
||||
virtual String column_name(int column) const override;
|
||||
virtual ColumnMetadata column_metadata(int column) const override;
|
||||
virtual GVariant data(int row, int column) const override;
|
||||
virtual GVariant data(const GModelIndex&) const override;
|
||||
virtual void update() override;
|
||||
|
||||
pid_t selected_pid() const;
|
||||
|
@ -45,11 +45,11 @@ public:
|
||||
virtual String row_name(int) const { return { }; }
|
||||
virtual String column_name(int) const { return { }; }
|
||||
virtual ColumnMetadata column_metadata(int) const { return { }; }
|
||||
virtual GVariant data(int row, int column) const = 0;
|
||||
virtual GVariant data(const GModelIndex&) const = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void activate(const GModelIndex&) { }
|
||||
|
||||
bool is_valid(GModelIndex index) const
|
||||
bool is_valid(const GModelIndex& index) const
|
||||
{
|
||||
return index.row() >= 0 && index.row() < row_count() && index.column() >= 0 && index.column() < column_count();
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ void GTableView::paint_event(GPaintEvent& event)
|
||||
auto column_metadata = m_model->column_metadata(column_index);
|
||||
int column_width = column_metadata.preferred_width;
|
||||
Rect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height());
|
||||
auto data = m_model->data(row_index, column_index);
|
||||
auto data = m_model->data({ row_index, column_index });
|
||||
if (data.is_bitmap())
|
||||
painter.blit(cell_rect.location(), data.as_bitmap(), data.as_bitmap().rect());
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user