mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
FileManager: Port to using GModelSelection
This commit is contained in:
parent
fb18613e8a
commit
9d97781e37
2 changed files with 24 additions and 2 deletions
|
@ -34,6 +34,25 @@ public:
|
||||||
void set_view_mode(ViewMode);
|
void set_view_mode(ViewMode);
|
||||||
ViewMode view_mode() const { return m_view_mode; }
|
ViewMode view_mode() const { return m_view_mode; }
|
||||||
|
|
||||||
|
const GAbstractView& current_view() const
|
||||||
|
{
|
||||||
|
switch (m_view_mode) {
|
||||||
|
case ViewMode::List:
|
||||||
|
return *m_table_view;
|
||||||
|
case ViewMode::Icon:
|
||||||
|
return *m_item_view;
|
||||||
|
default:
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Callback>
|
||||||
|
void for_each_view_implementation(Callback callback)
|
||||||
|
{
|
||||||
|
callback(*m_table_view);
|
||||||
|
callback(*m_item_view);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GDirectoryModel& model() { return *m_model; }
|
GDirectoryModel& model() { return *m_model; }
|
||||||
const GDirectoryModel& model() const { return *m_model; }
|
const GDirectoryModel& model() const { return *m_model; }
|
||||||
|
|
|
@ -197,8 +197,11 @@ int main(int argc, char** argv)
|
||||||
directory_view->on_path_change = [window, location_textbox, &file_system_model, tree_view, &go_forward_action, &go_back_action, directory_view](const String& new_path) {
|
directory_view->on_path_change = [window, location_textbox, &file_system_model, tree_view, &go_forward_action, &go_back_action, directory_view](const String& new_path) {
|
||||||
window->set_title(String::format("File Manager: %s", new_path.characters()));
|
window->set_title(String::format("File Manager: %s", new_path.characters()));
|
||||||
location_textbox->set_text(new_path);
|
location_textbox->set_text(new_path);
|
||||||
file_system_model->set_selected_index(file_system_model->index(new_path));
|
auto new_index = file_system_model->index(new_path);
|
||||||
tree_view->scroll_into_view(file_system_model->selected_index(), Orientation::Vertical);
|
directory_view->for_each_view_implementation([&](auto& view) {
|
||||||
|
view.selection().set(new_index);
|
||||||
|
});
|
||||||
|
tree_view->scroll_into_view(directory_view->current_view().selection().first(), Orientation::Vertical);
|
||||||
tree_view->update();
|
tree_view->update();
|
||||||
|
|
||||||
go_forward_action->set_enabled(directory_view->path_history_position()
|
go_forward_action->set_enabled(directory_view->path_history_position()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue