mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:58:11 +00:00
LibGUI: Enable using a ColumnsView inside MultiView :^)
Now that SortingProxyModel has greatly improved support for hierarchies we can enable this without crashing.
This commit is contained in:
parent
b9ae937279
commit
4c23e75d2f
2 changed files with 1 additions and 34 deletions
|
@ -41,21 +41,16 @@ MultiView::MultiView()
|
||||||
set_content_margins({ 2, 2, 2, 2 });
|
set_content_margins({ 2, 2, 2, 2 });
|
||||||
m_icon_view = add<IconView>();
|
m_icon_view = add<IconView>();
|
||||||
m_table_view = add<TableView>();
|
m_table_view = add<TableView>();
|
||||||
|
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
m_columns_view = add<ColumnsView>();
|
m_columns_view = add<ColumnsView>();
|
||||||
#endif
|
|
||||||
|
|
||||||
m_icon_view->on_activation = [&](auto& index) {
|
m_icon_view->on_activation = [&](auto& index) {
|
||||||
if (on_activation)
|
if (on_activation)
|
||||||
on_activation(index);
|
on_activation(index);
|
||||||
};
|
};
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
m_columns_view->on_activation = [&](auto& index) {
|
m_columns_view->on_activation = [&](auto& index) {
|
||||||
if (on_activation)
|
if (on_activation)
|
||||||
on_activation(index);
|
on_activation(index);
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
m_table_view->on_activation = [&](auto& index) {
|
m_table_view->on_activation = [&](auto& index) {
|
||||||
if (on_activation)
|
if (on_activation)
|
||||||
on_activation(index);
|
on_activation(index);
|
||||||
|
@ -69,12 +64,10 @@ MultiView::MultiView()
|
||||||
if (on_selection_change)
|
if (on_selection_change)
|
||||||
on_selection_change();
|
on_selection_change();
|
||||||
};
|
};
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
m_columns_view->on_selection_change = [this] {
|
m_columns_view->on_selection_change = [this] {
|
||||||
if (on_selection_change)
|
if (on_selection_change)
|
||||||
on_selection_change();
|
on_selection_change();
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
m_table_view->on_context_menu_request = [this](auto& index, auto& event) {
|
m_table_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
|
@ -84,12 +77,10 @@ MultiView::MultiView()
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
on_context_menu_request(index, event);
|
on_context_menu_request(index, event);
|
||||||
};
|
};
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
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)
|
||||||
on_context_menu_request(index, event);
|
on_context_menu_request(index, event);
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
m_table_view->on_drop = [this](auto& index, auto& event) {
|
m_table_view->on_drop = [this](auto& index, auto& event) {
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
|
@ -99,12 +90,10 @@ MultiView::MultiView()
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
on_drop(index, event);
|
on_drop(index, event);
|
||||||
};
|
};
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
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)
|
||||||
on_drop(index, event);
|
on_drop(index, event);
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
build_actions();
|
build_actions();
|
||||||
set_view_mode(ViewMode::Icon);
|
set_view_mode(ViewMode::Icon);
|
||||||
|
@ -126,13 +115,11 @@ void MultiView::set_view_mode(ViewMode mode)
|
||||||
m_view_as_table_action->set_checked(true);
|
m_view_as_table_action->set_checked(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
if (mode == ViewMode::Columns) {
|
if (mode == ViewMode::Columns) {
|
||||||
set_active_widget(m_columns_view);
|
set_active_widget(m_columns_view);
|
||||||
m_view_as_columns_action->set_checked(true);
|
m_view_as_columns_action->set_checked(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (mode == ViewMode::Icon) {
|
if (mode == ViewMode::Icon) {
|
||||||
set_active_widget(m_icon_view);
|
set_active_widget(m_icon_view);
|
||||||
m_view_as_icons_action->set_checked(true);
|
m_view_as_icons_action->set_checked(true);
|
||||||
|
@ -157,9 +144,7 @@ void MultiView::set_model_column(int column)
|
||||||
return;
|
return;
|
||||||
m_model_column = column;
|
m_model_column = column;
|
||||||
m_icon_view->set_model_column(column);
|
m_icon_view->set_model_column(column);
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
m_columns_view->set_model_column(column);
|
m_columns_view->set_model_column(column);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiView::set_column_hidden(int column_index, bool hidden)
|
void MultiView::set_column_hidden(int column_index, bool hidden)
|
||||||
|
@ -179,29 +164,23 @@ void MultiView::build_actions()
|
||||||
set_view_mode(ViewMode::Icon);
|
set_view_mode(ViewMode::Icon);
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
m_view_as_columns_action = Action::create_checkable(
|
m_view_as_columns_action = Action::create_checkable(
|
||||||
"Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [this](auto&) {
|
"Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [this](auto&) {
|
||||||
set_view_mode(ViewMode::Columns);
|
set_view_mode(ViewMode::Columns);
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
|
|
||||||
m_view_type_action_group = make<ActionGroup>();
|
m_view_type_action_group = make<ActionGroup>();
|
||||||
m_view_type_action_group->set_exclusive(true);
|
m_view_type_action_group->set_exclusive(true);
|
||||||
m_view_type_action_group->add_action(*m_view_as_table_action);
|
m_view_type_action_group->add_action(*m_view_as_table_action);
|
||||||
m_view_type_action_group->add_action(*m_view_as_icons_action);
|
m_view_type_action_group->add_action(*m_view_as_icons_action);
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
m_view_type_action_group->add_action(*m_view_as_columns_action);
|
m_view_type_action_group->add_action(*m_view_as_columns_action);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiView::apply_multi_select()
|
void MultiView::apply_multi_select()
|
||||||
{
|
{
|
||||||
m_table_view->set_multi_select(m_multi_select);
|
m_table_view->set_multi_select(m_multi_select);
|
||||||
m_icon_view->set_multi_select(m_multi_select);
|
m_icon_view->set_multi_select(m_multi_select);
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
m_columns_view->set_multi_select(m_multi_select);
|
||||||
//m_columns_view->set_multi_select(m_multi_select);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiView::set_multi_select(bool multi_select)
|
void MultiView::set_multi_select(bool multi_select)
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
#include <LibGUI/StackWidget.h>
|
#include <LibGUI/StackWidget.h>
|
||||||
#include <LibGUI/TableView.h>
|
#include <LibGUI/TableView.h>
|
||||||
|
|
||||||
//#define MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
class MultiView final : public GUI::StackWidget {
|
class MultiView final : public GUI::StackWidget {
|
||||||
|
@ -70,10 +68,8 @@ public:
|
||||||
switch (m_view_mode) {
|
switch (m_view_mode) {
|
||||||
case ViewMode::Table:
|
case ViewMode::Table:
|
||||||
return *m_table_view;
|
return *m_table_view;
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
case ViewMode::Columns:
|
case ViewMode::Columns:
|
||||||
return *m_columns_view;
|
return *m_columns_view;
|
||||||
#endif
|
|
||||||
case ViewMode::Icon:
|
case ViewMode::Icon:
|
||||||
return *m_icon_view;
|
return *m_icon_view;
|
||||||
default:
|
default:
|
||||||
|
@ -89,9 +85,7 @@ public:
|
||||||
{
|
{
|
||||||
callback(*m_table_view);
|
callback(*m_table_view);
|
||||||
callback(*m_icon_view);
|
callback(*m_icon_view);
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
callback(*m_columns_view);
|
callback(*m_columns_view);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Model* model() { return m_model; }
|
Model* model() { return m_model; }
|
||||||
|
@ -101,9 +95,7 @@ public:
|
||||||
|
|
||||||
Action& view_as_table_action() { return *m_view_as_table_action; }
|
Action& view_as_table_action() { return *m_view_as_table_action; }
|
||||||
Action& view_as_icons_action() { return *m_view_as_icons_action; }
|
Action& view_as_icons_action() { return *m_view_as_icons_action; }
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
Action& view_as_columns_action() { return *m_view_as_columns_action; }
|
Action& view_as_columns_action() { return *m_view_as_columns_action; }
|
||||||
#endif
|
|
||||||
|
|
||||||
bool is_multi_select() const { return m_multi_select; }
|
bool is_multi_select() const { return m_multi_select; }
|
||||||
void set_multi_select(bool);
|
void set_multi_select(bool);
|
||||||
|
@ -121,15 +113,11 @@ private:
|
||||||
|
|
||||||
RefPtr<TableView> m_table_view;
|
RefPtr<TableView> m_table_view;
|
||||||
RefPtr<IconView> m_icon_view;
|
RefPtr<IconView> m_icon_view;
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
RefPtr<ColumnsView> m_columns_view;
|
RefPtr<ColumnsView> m_columns_view;
|
||||||
#endif
|
|
||||||
|
|
||||||
RefPtr<Action> m_view_as_table_action;
|
RefPtr<Action> m_view_as_table_action;
|
||||||
RefPtr<Action> m_view_as_icons_action;
|
RefPtr<Action> m_view_as_icons_action;
|
||||||
#ifdef MULTIVIEW_WITH_COLUMNSVIEW
|
|
||||||
RefPtr<Action> m_view_as_columns_action;
|
RefPtr<Action> m_view_as_columns_action;
|
||||||
#endif
|
|
||||||
|
|
||||||
OwnPtr<ActionGroup> m_view_type_action_group;
|
OwnPtr<ActionGroup> m_view_type_action_group;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue