mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
LibGUI: The UI calls it 'Icon view', fix the name in the code
This commit is contained in:
parent
8e01356b2f
commit
ef433cb367
9 changed files with 74 additions and 74 deletions
|
@ -78,8 +78,8 @@ DirectoryView::DirectoryView()
|
||||||
{
|
{
|
||||||
set_active_widget(nullptr);
|
set_active_widget(nullptr);
|
||||||
set_content_margins({ 2, 2, 2, 2 });
|
set_content_margins({ 2, 2, 2, 2 });
|
||||||
m_item_view = add<GUI::ItemView>();
|
m_icon_view = add<GUI::IconView>();
|
||||||
m_item_view->set_model(model());
|
m_icon_view->set_model(model());
|
||||||
|
|
||||||
m_columns_view = add<GUI::ColumnsView>();
|
m_columns_view = add<GUI::ColumnsView>();
|
||||||
m_columns_view->set_model(model());
|
m_columns_view->set_model(model());
|
||||||
|
@ -89,7 +89,7 @@ DirectoryView::DirectoryView()
|
||||||
|
|
||||||
m_table_view->model()->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending);
|
m_table_view->model()->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending);
|
||||||
|
|
||||||
m_item_view->set_model_column(GUI::FileSystemModel::Column::Name);
|
m_icon_view->set_model_column(GUI::FileSystemModel::Column::Name);
|
||||||
m_columns_view->set_model_column(GUI::FileSystemModel::Column::Name);
|
m_columns_view->set_model_column(GUI::FileSystemModel::Column::Name);
|
||||||
|
|
||||||
m_model->on_error = [this](int error, const char* error_string) {
|
m_model->on_error = [this](int error, const char* error_string) {
|
||||||
|
@ -105,7 +105,7 @@ DirectoryView::DirectoryView()
|
||||||
|
|
||||||
m_model->on_complete = [this] {
|
m_model->on_complete = [this] {
|
||||||
m_table_view->selection().clear();
|
m_table_view->selection().clear();
|
||||||
m_item_view->selection().clear();
|
m_icon_view->selection().clear();
|
||||||
|
|
||||||
add_path_to_history(model().root_path());
|
add_path_to_history(model().root_path());
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ DirectoryView::DirectoryView()
|
||||||
on_thumbnail_progress(done, total);
|
on_thumbnail_progress(done, total);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_item_view->on_activation = [&](const GUI::ModelIndex& index) {
|
m_icon_view->on_activation = [&](const GUI::ModelIndex& index) {
|
||||||
handle_activation(index);
|
handle_activation(index);
|
||||||
};
|
};
|
||||||
m_columns_view->on_activation = [&](const GUI::ModelIndex& index) {
|
m_columns_view->on_activation = [&](const GUI::ModelIndex& index) {
|
||||||
|
@ -145,10 +145,10 @@ DirectoryView::DirectoryView()
|
||||||
if (on_selection_change)
|
if (on_selection_change)
|
||||||
on_selection_change(*m_table_view);
|
on_selection_change(*m_table_view);
|
||||||
};
|
};
|
||||||
m_item_view->on_selection_change = [this] {
|
m_icon_view->on_selection_change = [this] {
|
||||||
update_statusbar();
|
update_statusbar();
|
||||||
if (on_selection_change)
|
if (on_selection_change)
|
||||||
on_selection_change(*m_item_view);
|
on_selection_change(*m_icon_view);
|
||||||
};
|
};
|
||||||
m_columns_view->on_selection_change = [this] {
|
m_columns_view->on_selection_change = [this] {
|
||||||
update_statusbar();
|
update_statusbar();
|
||||||
|
@ -160,9 +160,9 @@ DirectoryView::DirectoryView()
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
on_context_menu_request(*m_table_view, index, event);
|
on_context_menu_request(*m_table_view, index, event);
|
||||||
};
|
};
|
||||||
m_item_view->on_context_menu_request = [this](auto& index, auto& event) {
|
m_icon_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
on_context_menu_request(*m_item_view, index, event);
|
on_context_menu_request(*m_icon_view, index, event);
|
||||||
};
|
};
|
||||||
m_columns_view->on_context_menu_request = [this](auto& index, auto& event) {
|
m_columns_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
|
@ -173,9 +173,9 @@ DirectoryView::DirectoryView()
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
on_drop(*m_table_view, index, event);
|
on_drop(*m_table_view, index, event);
|
||||||
};
|
};
|
||||||
m_item_view->on_drop = [this](auto& index, auto& event) {
|
m_icon_view->on_drop = [this](auto& index, auto& event) {
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
on_drop(*m_item_view, index, event);
|
on_drop(*m_icon_view, index, event);
|
||||||
};
|
};
|
||||||
m_columns_view->on_drop = [this](auto& index, auto& event) {
|
m_columns_view->on_drop = [this](auto& index, auto& event) {
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
|
@ -195,7 +195,7 @@ void DirectoryView::set_view_mode(ViewMode mode)
|
||||||
return;
|
return;
|
||||||
m_view_mode = mode;
|
m_view_mode = mode;
|
||||||
update();
|
update();
|
||||||
if (mode == ViewMode::List) {
|
if (mode == ViewMode::Table) {
|
||||||
set_active_widget(m_table_view);
|
set_active_widget(m_table_view);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ void DirectoryView::set_view_mode(ViewMode mode)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mode == ViewMode::Icon) {
|
if (mode == ViewMode::Icon) {
|
||||||
set_active_widget(m_item_view);
|
set_active_widget(m_icon_view);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
@ -297,7 +297,7 @@ void DirectoryView::update_statusbar()
|
||||||
auto index = current_view().selection().first();
|
auto index = current_view().selection().first();
|
||||||
|
|
||||||
// FIXME: This is disgusting. This code should not even be aware that there is a GUI::SortingProxyModel in the table view.
|
// FIXME: This is disgusting. This code should not even be aware that there is a GUI::SortingProxyModel in the table view.
|
||||||
if (m_view_mode == ViewMode::List) {
|
if (m_view_mode == ViewMode::Table) {
|
||||||
auto& filter_model = (GUI::SortingProxyModel&)*m_table_view->model();
|
auto& filter_model = (GUI::SortingProxyModel&)*m_table_view->model();
|
||||||
index = filter_model.map_to_target(index);
|
index = filter_model.map_to_target(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGUI/ColumnsView.h>
|
#include <LibGUI/ColumnsView.h>
|
||||||
#include <LibGUI/FileSystemModel.h>
|
#include <LibGUI/FileSystemModel.h>
|
||||||
#include <LibGUI/ItemView.h>
|
#include <LibGUI/IconView.h>
|
||||||
#include <LibGUI/StackWidget.h>
|
#include <LibGUI/StackWidget.h>
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -59,7 +59,7 @@ public:
|
||||||
|
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
Invalid,
|
Invalid,
|
||||||
List,
|
Table,
|
||||||
Columns,
|
Columns,
|
||||||
Icon
|
Icon
|
||||||
};
|
};
|
||||||
|
@ -69,12 +69,12 @@ public:
|
||||||
GUI::AbstractView& current_view()
|
GUI::AbstractView& current_view()
|
||||||
{
|
{
|
||||||
switch (m_view_mode) {
|
switch (m_view_mode) {
|
||||||
case ViewMode::List:
|
case ViewMode::Table:
|
||||||
return *m_table_view;
|
return *m_table_view;
|
||||||
case ViewMode::Columns:
|
case ViewMode::Columns:
|
||||||
return *m_columns_view;
|
return *m_columns_view;
|
||||||
case ViewMode::Icon:
|
case ViewMode::Icon:
|
||||||
return *m_item_view;
|
return *m_icon_view;
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
void for_each_view_implementation(Callback callback)
|
void for_each_view_implementation(Callback callback)
|
||||||
{
|
{
|
||||||
callback(*m_table_view);
|
callback(*m_table_view);
|
||||||
callback(*m_item_view);
|
callback(*m_icon_view);
|
||||||
callback(*m_columns_view);
|
callback(*m_columns_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +107,6 @@ private:
|
||||||
void add_path_to_history(const StringView& path);
|
void add_path_to_history(const StringView& path);
|
||||||
|
|
||||||
RefPtr<GUI::TableView> m_table_view;
|
RefPtr<GUI::TableView> m_table_view;
|
||||||
RefPtr<GUI::ItemView> m_item_view;
|
RefPtr<GUI::IconView> m_icon_view;
|
||||||
RefPtr<GUI::ColumnsView> m_columns_view;
|
RefPtr<GUI::ColumnsView> m_columns_view;
|
||||||
};
|
};
|
||||||
|
|
|
@ -144,16 +144,16 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config, String initial_location
|
||||||
auto& desktop_widget = window->set_main_widget<DesktopWidget>();
|
auto& desktop_widget = window->set_main_widget<DesktopWidget>();
|
||||||
desktop_widget.set_layout<GUI::VerticalBoxLayout>();
|
desktop_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||||
|
|
||||||
auto& item_view = desktop_widget.add<GUI::ItemView>();
|
auto& icon_view = desktop_widget.add<GUI::IconView>();
|
||||||
item_view.set_frame_thickness(0);
|
icon_view.set_frame_thickness(0);
|
||||||
item_view.set_scrollbars_enabled(false);
|
icon_view.set_scrollbars_enabled(false);
|
||||||
item_view.set_fill_with_background_color(false);
|
icon_view.set_fill_with_background_color(false);
|
||||||
|
|
||||||
auto model = GUI::FileSystemModel::create(initial_location);
|
auto model = GUI::FileSystemModel::create(initial_location);
|
||||||
item_view.set_model(model);
|
icon_view.set_model(model);
|
||||||
item_view.set_model_column(GUI::FileSystemModel::Column::Name);
|
icon_view.set_model_column(GUI::FileSystemModel::Column::Name);
|
||||||
|
|
||||||
item_view.on_activation = [&](auto& index) {
|
icon_view.on_activation = [&](auto& index) {
|
||||||
if (!index.is_valid())
|
if (!index.is_valid())
|
||||||
return;
|
return;
|
||||||
auto& node = model->node(index);
|
auto& node = model->node(index);
|
||||||
|
@ -219,7 +219,7 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config, String initial_location
|
||||||
desktop_view_context_menu->add_separator();
|
desktop_view_context_menu->add_separator();
|
||||||
desktop_view_context_menu->add_action(display_properties_action);
|
desktop_view_context_menu->add_action(display_properties_action);
|
||||||
|
|
||||||
item_view.on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
icon_view.on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||||
if (!index.is_valid())
|
if (!index.is_valid())
|
||||||
desktop_view_context_menu->popup(event.screen_position());
|
desktop_view_context_menu->popup(event.screen_position());
|
||||||
};
|
};
|
||||||
|
@ -354,8 +354,8 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
|
|
||||||
view_as_table_action = GUI::Action::create_checkable(
|
view_as_table_action = GUI::Action::create_checkable(
|
||||||
"Table view", { Mod_Ctrl, KeyCode::Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
|
"Table view", { Mod_Ctrl, KeyCode::Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
|
||||||
directory_view.set_view_mode(DirectoryView::ViewMode::List);
|
directory_view.set_view_mode(DirectoryView::ViewMode::Table);
|
||||||
config->write_entry("DirectoryView", "ViewMode", "List");
|
config->write_entry("DirectoryView", "ViewMode", "Table");
|
||||||
config->sync();
|
config->sync();
|
||||||
},
|
},
|
||||||
window);
|
window);
|
||||||
|
@ -832,8 +832,8 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
// Read direcory read mode from config.
|
// Read direcory read mode from config.
|
||||||
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
||||||
|
|
||||||
if (dir_view_mode.contains("List")) {
|
if (dir_view_mode.contains("Table")) {
|
||||||
directory_view.set_view_mode(DirectoryView::ViewMode::List);
|
directory_view.set_view_mode(DirectoryView::ViewMode::Table);
|
||||||
view_as_table_action->set_checked(true);
|
view_as_table_action->set_checked(true);
|
||||||
} else if (dir_view_mode.contains("Columns")) {
|
} else if (dir_view_mode.contains("Columns")) {
|
||||||
directory_view.set_view_mode(DirectoryView::ViewMode::Columns);
|
directory_view.set_view_mode(DirectoryView::ViewMode::Columns);
|
||||||
|
|
|
@ -40,7 +40,7 @@ class FileSystemModel;
|
||||||
class Frame;
|
class Frame;
|
||||||
class GroupBox;
|
class GroupBox;
|
||||||
class HorizontalBoxLayout;
|
class HorizontalBoxLayout;
|
||||||
class ItemView;
|
class IconView;
|
||||||
class JsonArrayModel;
|
class JsonArrayModel;
|
||||||
class KeyEvent;
|
class KeyEvent;
|
||||||
class Label;
|
class Label;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <Kernel/KeyCode.h>
|
#include <Kernel/KeyCode.h>
|
||||||
#include <LibGUI/DragOperation.h>
|
#include <LibGUI/DragOperation.h>
|
||||||
#include <LibGUI/ItemView.h>
|
#include <LibGUI/IconView.h>
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
#include <LibGUI/Painter.h>
|
#include <LibGUI/Painter.h>
|
||||||
#include <LibGUI/ScrollBar.h>
|
#include <LibGUI/ScrollBar.h>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
ItemView::ItemView()
|
IconView::IconView()
|
||||||
{
|
{
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
set_background_role(ColorRole::Base);
|
set_background_role(ColorRole::Base);
|
||||||
|
@ -45,11 +45,11 @@ ItemView::ItemView()
|
||||||
horizontal_scrollbar().set_visible(false);
|
horizontal_scrollbar().set_visible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemView::~ItemView()
|
IconView::~IconView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::select_all()
|
void IconView::select_all()
|
||||||
{
|
{
|
||||||
selection().clear();
|
selection().clear();
|
||||||
for (int item_index = 0; item_index < item_count(); ++item_index) {
|
for (int item_index = 0; item_index < item_count(); ++item_index) {
|
||||||
|
@ -58,25 +58,25 @@ void ItemView::select_all()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::scroll_into_view(const ModelIndex& index, Orientation orientation)
|
void IconView::scroll_into_view(const ModelIndex& index, Orientation orientation)
|
||||||
{
|
{
|
||||||
ScrollableWidget::scroll_into_view(item_rect(index.row()), orientation);
|
ScrollableWidget::scroll_into_view(item_rect(index.row()), orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::resize_event(ResizeEvent& event)
|
void IconView::resize_event(ResizeEvent& event)
|
||||||
{
|
{
|
||||||
AbstractView::resize_event(event);
|
AbstractView::resize_event(event);
|
||||||
update_content_size();
|
update_content_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::did_update_model(unsigned flags)
|
void IconView::did_update_model(unsigned flags)
|
||||||
{
|
{
|
||||||
AbstractView::did_update_model(flags);
|
AbstractView::did_update_model(flags);
|
||||||
update_content_size();
|
update_content_size();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::update_content_size()
|
void IconView::update_content_size()
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
return set_content_size({});
|
return set_content_size({});
|
||||||
|
@ -93,7 +93,7 @@ void ItemView::update_content_size()
|
||||||
set_content_size({ content_width, content_height });
|
set_content_size({ content_width, content_height });
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::Rect ItemView::item_rect(int item_index) const
|
Gfx::Rect IconView::item_rect(int item_index) const
|
||||||
{
|
{
|
||||||
if (!m_visual_row_count || !m_visual_column_count)
|
if (!m_visual_row_count || !m_visual_column_count)
|
||||||
return {};
|
return {};
|
||||||
|
@ -107,7 +107,7 @@ Gfx::Rect ItemView::item_rect(int item_index) const
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<int> ItemView::items_intersecting_rect(const Gfx::Rect& rect) const
|
Vector<int> IconView::items_intersecting_rect(const Gfx::Rect& rect) const
|
||||||
{
|
{
|
||||||
ASSERT(model());
|
ASSERT(model());
|
||||||
const auto& column_metadata = model()->column_metadata(model_column());
|
const auto& column_metadata = model()->column_metadata(model_column());
|
||||||
|
@ -125,7 +125,7 @@ Vector<int> ItemView::items_intersecting_rect(const Gfx::Rect& rect) const
|
||||||
return item_indexes;
|
return item_indexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelIndex ItemView::index_at_event_position(const Gfx::Point& position) const
|
ModelIndex IconView::index_at_event_position(const Gfx::Point& position) const
|
||||||
{
|
{
|
||||||
ASSERT(model());
|
ASSERT(model());
|
||||||
// FIXME: Since all items are the same size, just compute the clicked item index
|
// FIXME: Since all items are the same size, just compute the clicked item index
|
||||||
|
@ -146,12 +146,12 @@ ModelIndex ItemView::index_at_event_position(const Gfx::Point& position) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::Point ItemView::adjusted_position(const Gfx::Point& position) const
|
Gfx::Point IconView::adjusted_position(const Gfx::Point& position) const
|
||||||
{
|
{
|
||||||
return position.translated(0, vertical_scrollbar().value());
|
return position.translated(0, vertical_scrollbar().value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::mousedown_event(MouseEvent& event)
|
void IconView::mousedown_event(MouseEvent& event)
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
return AbstractView::mousedown_event(event);
|
return AbstractView::mousedown_event(event);
|
||||||
|
@ -183,7 +183,7 @@ void ItemView::mousedown_event(MouseEvent& event)
|
||||||
m_rubber_band_current = adjusted_position;
|
m_rubber_band_current = adjusted_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::mouseup_event(MouseEvent& event)
|
void IconView::mouseup_event(MouseEvent& event)
|
||||||
{
|
{
|
||||||
if (m_rubber_banding && event.button() == MouseButton::Left) {
|
if (m_rubber_banding && event.button() == MouseButton::Left) {
|
||||||
m_rubber_banding = false;
|
m_rubber_banding = false;
|
||||||
|
@ -193,7 +193,7 @@ void ItemView::mouseup_event(MouseEvent& event)
|
||||||
AbstractView::mouseup_event(event);
|
AbstractView::mouseup_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::drag_move_event(DragEvent& event)
|
void IconView::drag_move_event(DragEvent& event)
|
||||||
{
|
{
|
||||||
auto index = index_at_event_position(event.position());
|
auto index = index_at_event_position(event.position());
|
||||||
ModelIndex new_drop_candidate_index;
|
ModelIndex new_drop_candidate_index;
|
||||||
|
@ -212,7 +212,7 @@ void ItemView::drag_move_event(DragEvent& event)
|
||||||
event.accept();
|
event.accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::mousemove_event(MouseEvent& event)
|
void IconView::mousemove_event(MouseEvent& event)
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
return AbstractView::mousemove_event(event);
|
return AbstractView::mousemove_event(event);
|
||||||
|
@ -239,7 +239,7 @@ void ItemView::mousemove_event(MouseEvent& event)
|
||||||
AbstractView::mousemove_event(event);
|
AbstractView::mousemove_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::get_item_rects(int item_index, const Gfx::Font& font, const Variant& item_text, Gfx::Rect& item_rect, Gfx::Rect& icon_rect, Gfx::Rect& text_rect) const
|
void IconView::get_item_rects(int item_index, const Gfx::Font& font, const Variant& item_text, Gfx::Rect& item_rect, Gfx::Rect& icon_rect, Gfx::Rect& text_rect) const
|
||||||
{
|
{
|
||||||
item_rect = this->item_rect(item_index);
|
item_rect = this->item_rect(item_index);
|
||||||
icon_rect = { 0, 0, 32, 32 };
|
icon_rect = { 0, 0, 32, 32 };
|
||||||
|
@ -251,7 +251,7 @@ void ItemView::get_item_rects(int item_index, const Gfx::Font& font, const Varia
|
||||||
text_rect.intersect(item_rect);
|
text_rect.intersect(item_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::second_paint_event(PaintEvent& event)
|
void IconView::second_paint_event(PaintEvent& event)
|
||||||
{
|
{
|
||||||
if (!m_rubber_banding)
|
if (!m_rubber_banding)
|
||||||
return;
|
return;
|
||||||
|
@ -266,7 +266,7 @@ void ItemView::second_paint_event(PaintEvent& event)
|
||||||
painter.draw_rect(rubber_band_rect, palette().rubber_band_border());
|
painter.draw_rect(rubber_band_rect, palette().rubber_band_border());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::paint_event(PaintEvent& event)
|
void IconView::paint_event(PaintEvent& event)
|
||||||
{
|
{
|
||||||
Color widget_background_color = palette().color(background_role());
|
Color widget_background_color = palette().color(background_role());
|
||||||
Frame::paint_event(event);
|
Frame::paint_event(event);
|
||||||
|
@ -328,14 +328,14 @@ void ItemView::paint_event(PaintEvent& event)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
int ItemView::item_count() const
|
int IconView::item_count() const
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
return 0;
|
return 0;
|
||||||
return model()->row_count();
|
return model()->row_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemView::keydown_event(KeyEvent& event)
|
void IconView::keydown_event(KeyEvent& event)
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
return;
|
return;
|
|
@ -31,10 +31,10 @@
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class ItemView : public AbstractView {
|
class IconView : public AbstractView {
|
||||||
C_OBJECT(ItemView)
|
C_OBJECT(IconView)
|
||||||
public:
|
public:
|
||||||
virtual ~ItemView() override;
|
virtual ~IconView() override;
|
||||||
|
|
||||||
int content_width() const;
|
int content_width() const;
|
||||||
int horizontal_padding() const { return m_horizontal_padding; }
|
int horizontal_padding() const { return m_horizontal_padding; }
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
virtual void select_all() override;
|
virtual void select_all() override;
|
||||||
private:
|
private:
|
||||||
ItemView();
|
IconView();
|
||||||
|
|
||||||
virtual void did_update_model(unsigned flags) override;
|
virtual void did_update_model(unsigned flags) override;
|
||||||
virtual void paint_event(PaintEvent&) override;
|
virtual void paint_event(PaintEvent&) override;
|
|
@ -28,8 +28,8 @@ OBJS = \
|
||||||
Frame.o \
|
Frame.o \
|
||||||
GroupBox.o \
|
GroupBox.o \
|
||||||
Icon.o \
|
Icon.o \
|
||||||
|
IconView.o \
|
||||||
InputBox.o \
|
InputBox.o \
|
||||||
ItemView.o \
|
|
||||||
INILexer.o \
|
INILexer.o \
|
||||||
INISyntaxHighlighter.o \
|
INISyntaxHighlighter.o \
|
||||||
JsonArrayModel.o \
|
JsonArrayModel.o \
|
||||||
|
|
|
@ -40,14 +40,14 @@ MultiView::MultiView()
|
||||||
{
|
{
|
||||||
set_active_widget(nullptr);
|
set_active_widget(nullptr);
|
||||||
set_content_margins({ 2, 2, 2, 2 });
|
set_content_margins({ 2, 2, 2, 2 });
|
||||||
m_item_view = add<ItemView>();
|
m_icon_view = add<IconView>();
|
||||||
m_table_view = add<TableView>();
|
m_table_view = add<TableView>();
|
||||||
|
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
||||||
m_columns_view = add<ColumnsView>();
|
m_columns_view = add<ColumnsView>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_item_view->on_activation = [&](auto& index) {
|
m_icon_view->on_activation = [&](auto& index) {
|
||||||
if (on_activation)
|
if (on_activation)
|
||||||
on_activation(index);
|
on_activation(index);
|
||||||
};
|
};
|
||||||
|
@ -66,7 +66,7 @@ MultiView::MultiView()
|
||||||
if (on_selection_change)
|
if (on_selection_change)
|
||||||
on_selection_change();
|
on_selection_change();
|
||||||
};
|
};
|
||||||
m_item_view->on_selection_change = [this] {
|
m_icon_view->on_selection_change = [this] {
|
||||||
if (on_selection_change)
|
if (on_selection_change)
|
||||||
on_selection_change();
|
on_selection_change();
|
||||||
};
|
};
|
||||||
|
@ -81,7 +81,7 @@ MultiView::MultiView()
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
on_context_menu_request(index, event);
|
on_context_menu_request(index, event);
|
||||||
};
|
};
|
||||||
m_item_view->on_context_menu_request = [this](auto& index, auto& event) {
|
m_icon_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
on_context_menu_request(index, event);
|
on_context_menu_request(index, event);
|
||||||
};
|
};
|
||||||
|
@ -96,7 +96,7 @@ MultiView::MultiView()
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
on_drop(index, event);
|
on_drop(index, event);
|
||||||
};
|
};
|
||||||
m_item_view->on_drop = [this](auto& index, auto& event) {
|
m_icon_view->on_drop = [this](auto& index, auto& event) {
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
on_drop(index, event);
|
on_drop(index, event);
|
||||||
};
|
};
|
||||||
|
@ -121,7 +121,7 @@ void MultiView::set_view_mode(ViewMode mode)
|
||||||
return;
|
return;
|
||||||
m_view_mode = mode;
|
m_view_mode = mode;
|
||||||
update();
|
update();
|
||||||
if (mode == ViewMode::List) {
|
if (mode == ViewMode::Table) {
|
||||||
set_active_widget(m_table_view);
|
set_active_widget(m_table_view);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void MultiView::set_view_mode(ViewMode mode)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (mode == ViewMode::Icon) {
|
if (mode == ViewMode::Icon) {
|
||||||
set_active_widget(m_item_view);
|
set_active_widget(m_icon_view);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
|
@ -153,7 +153,7 @@ void MultiView::set_model_column(int column)
|
||||||
if (m_model_column == column)
|
if (m_model_column == column)
|
||||||
return;
|
return;
|
||||||
m_model_column = column;
|
m_model_column = column;
|
||||||
m_item_view->set_model_column(column);
|
m_icon_view->set_model_column(column);
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
||||||
m_columns_view->set_model_column(column);
|
m_columns_view->set_model_column(column);
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,7 +168,7 @@ void MultiView::build_actions()
|
||||||
{
|
{
|
||||||
m_view_as_table_action = Action::create_checkable(
|
m_view_as_table_action = Action::create_checkable(
|
||||||
"Table view", Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [this](auto&) {
|
"Table view", Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [this](auto&) {
|
||||||
set_view_mode(ViewMode::List);
|
set_view_mode(ViewMode::Table);
|
||||||
});
|
});
|
||||||
|
|
||||||
m_view_as_icons_action = Action::create_checkable(
|
m_view_as_icons_action = Action::create_checkable(
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/ColumnsView.h>
|
#include <LibGUI/ColumnsView.h>
|
||||||
#include <LibGUI/ItemView.h>
|
#include <LibGUI/IconView.h>
|
||||||
#include <LibGUI/StackWidget.h>
|
#include <LibGUI/StackWidget.h>
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
Function<void(const ModelIndex&, const DropEvent&)> on_drop;
|
Function<void(const ModelIndex&, const DropEvent&)> on_drop;
|
||||||
|
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
List,
|
Table,
|
||||||
Columns,
|
Columns,
|
||||||
Icon
|
Icon
|
||||||
};
|
};
|
||||||
|
@ -65,14 +65,14 @@ public:
|
||||||
GUI::AbstractView& current_view()
|
GUI::AbstractView& current_view()
|
||||||
{
|
{
|
||||||
switch (m_view_mode) {
|
switch (m_view_mode) {
|
||||||
case ViewMode::List:
|
case ViewMode::Table:
|
||||||
return *m_table_view;
|
return *m_table_view;
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
||||||
case ViewMode::Columns:
|
case ViewMode::Columns:
|
||||||
return *m_columns_view;
|
return *m_columns_view;
|
||||||
#endif
|
#endif
|
||||||
case ViewMode::Icon:
|
case ViewMode::Icon:
|
||||||
return *m_item_view;
|
return *m_icon_view;
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
void for_each_view_implementation(Callback callback)
|
void for_each_view_implementation(Callback callback)
|
||||||
{
|
{
|
||||||
callback(*m_table_view);
|
callback(*m_table_view);
|
||||||
callback(*m_item_view);
|
callback(*m_icon_view);
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
||||||
callback(*m_columns_view);
|
callback(*m_columns_view);
|
||||||
#endif
|
#endif
|
||||||
|
@ -113,7 +113,7 @@ private:
|
||||||
RefPtr<Model> m_model;
|
RefPtr<Model> m_model;
|
||||||
|
|
||||||
RefPtr<TableView> m_table_view;
|
RefPtr<TableView> m_table_view;
|
||||||
RefPtr<ItemView> m_item_view;
|
RefPtr<IconView> m_icon_view;
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
||||||
RefPtr<ColumnsView> m_columns_view;
|
RefPtr<ColumnsView> m_columns_view;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue