summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorIgnas S <anon>2019-08-12 11:46:01 +0300
committerAndreas Kling <awesomekling@gmail.com>2019-08-12 11:01:47 +0200
commit6228e18a091db6fd9c34cc2f3f2b11a766eb668f (patch)
tree2c4efcc2b9f3fc90fc1da76f0718b99fe623d277 /Libraries
parent405d7ddec85217f09e768a9b8b3eec5509d9e989 (diff)
downloadserenity-6228e18a091db6fd9c34cc2f3f2b11a766eb668f.zip
GTableView and friends: API improvements for 'Sortable' flag.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/GDirectoryModel.cpp2
-rw-r--r--Libraries/LibGUI/GModel.h3
-rw-r--r--Libraries/LibGUI/GTableView.cpp2
3 files changed, 4 insertions, 3 deletions
diff --git a/Libraries/LibGUI/GDirectoryModel.cpp b/Libraries/LibGUI/GDirectoryModel.cpp
index 6c428fc3ff..f71d9242c6 100644
--- a/Libraries/LibGUI/GDirectoryModel.cpp
+++ b/Libraries/LibGUI/GDirectoryModel.cpp
@@ -119,7 +119,7 @@ GModel::ColumnMetadata GDirectoryModel::column_metadata(int column) const
{
switch (column) {
case Column::Icon:
- return { 16, TextAlignment::Center, false };
+ return { 16, TextAlignment::Center, nullptr, GModel::ColumnMetadata::Sortable::False };
case Column::Name:
return { 120, TextAlignment::CenterLeft };
case Column::Size:
diff --git a/Libraries/LibGUI/GModel.h b/Libraries/LibGUI/GModel.h
index 59f0028021..0aee640eac 100644
--- a/Libraries/LibGUI/GModel.h
+++ b/Libraries/LibGUI/GModel.h
@@ -44,8 +44,9 @@ public:
struct ColumnMetadata {
int preferred_width { 0 };
TextAlignment text_alignment { TextAlignment::CenterLeft };
- bool sortable { true };
const Font* font { nullptr };
+ enum class Sortable { False, True };
+ Sortable sortable { Sortable::True };
};
enum class Role {
diff --git a/Libraries/LibGUI/GTableView.cpp b/Libraries/LibGUI/GTableView.cpp
index 1800733143..b7472afd07 100644
--- a/Libraries/LibGUI/GTableView.cpp
+++ b/Libraries/LibGUI/GTableView.cpp
@@ -159,7 +159,7 @@ void GTableView::mousedown_event(GMouseEvent& event)
}
auto header_rect = this->header_rect(i);
auto column_metadata = model()->column_metadata(i);
- if (header_rect.contains(event.position()) && column_metadata.sortable) {
+ if (header_rect.contains(event.position()) && column_metadata.sortable == GModel::ColumnMetadata::Sortable::True) {
auto new_sort_order = GSortOrder::Ascending;
if (model()->key_column() == i)
new_sort_order = model()->sort_order() == GSortOrder::Ascending