diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-16 16:05:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-16 16:44:09 +0200 |
commit | 96f98b1fc92fec77d222c5b7b356b278c660429b (patch) | |
tree | 549b4a11669e33fef769c7b3421658e94303ca2b | |
parent | f882424869e2abaa1deb24a59881ef4847055569 (diff) | |
download | serenity-96f98b1fc92fec77d222c5b7b356b278c660429b.zip |
LibGUI: Simplify TableCellPaintingDelegate API slightly
No need to pass the Model *and* a ModelIndex, the index knows which
model it belongs to anyway.
-rw-r--r-- | Applications/SystemMonitor/ProcessMemoryMapWidget.cpp | 4 | ||||
-rw-r--r-- | Applications/SystemMonitor/main.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibGUI/AbstractTableView.h | 2 | ||||
-rw-r--r-- | Libraries/LibGUI/TableView.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibGUI/TreeView.cpp | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index ece75cd1dd..9252bb7c62 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -37,10 +37,10 @@ class PagemapPaintingDelegate final : public GUI::TableCellPaintingDelegate { public: virtual ~PagemapPaintingDelegate() override {} - virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Gfx::Palette&, const GUI::Model& model, const GUI::ModelIndex& index) override + virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Gfx::Palette&, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); - auto pagemap = model.data(index, GUI::ModelRole::Custom).to_string(); + auto pagemap = index.data(GUI::ModelRole::Custom).to_string(); float scale_factor = (float)pagemap.length() / (float)rect.width(); diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 26face0aa1..4dd0e5630b 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -337,12 +337,12 @@ class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate public: virtual ~ProgressBarPaintingDelegate() override { } - virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override + virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Palette& palette, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); - auto percentage = model.data(index, GUI::ModelRole::Custom).to_i32(); + auto percentage = index.data(GUI::ModelRole::Custom).to_i32(); - auto data = model.data(index, GUI::ModelRole::Display); + auto data = index.data(GUI::ModelRole::Display); String text; if (data.is_string()) text = data.as_string(); diff --git a/Libraries/LibGUI/AbstractTableView.h b/Libraries/LibGUI/AbstractTableView.h index 2b4cd0c8d0..cbc80f6528 100644 --- a/Libraries/LibGUI/AbstractTableView.h +++ b/Libraries/LibGUI/AbstractTableView.h @@ -34,7 +34,7 @@ class TableCellPaintingDelegate { public: virtual ~TableCellPaintingDelegate() {} - virtual void paint(Painter&, const Gfx::IntRect&, const Gfx::Palette&, const Model&, const ModelIndex&) = 0; + virtual void paint(Painter&, const Gfx::IntRect&, const Gfx::Palette&, const ModelIndex&) = 0; }; class AbstractTableView : public AbstractView { diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp index e0da2140f9..92951d19ae 100644 --- a/Libraries/LibGUI/TableView.cpp +++ b/Libraries/LibGUI/TableView.cpp @@ -111,7 +111,7 @@ void TableView::paint_event(PaintEvent& event) auto cell_index = model()->index(row_index, column_index); if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) { - delegate->paint(painter, cell_rect, palette(), *model(), cell_index); + delegate->paint(painter, cell_rect, palette(), cell_index); } else { auto data = model()->data(cell_index); if (data.is_bitmap()) { diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp index 01c1407bea..270eec79db 100644 --- a/Libraries/LibGUI/TreeView.cpp +++ b/Libraries/LibGUI/TreeView.cpp @@ -291,7 +291,7 @@ void TreeView::paint_event(PaintEvent& event) auto cell_index = model.index(index.row(), column_index, index.parent()); if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) { - delegate->paint(painter, cell_rect, palette(), model, cell_index); + delegate->paint(painter, cell_rect, palette(), cell_index); } else { auto data = model.data(cell_index); |