mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibGUI+FileManager: Merge GDirectoryModel into GFileSystemModel
We used to have two different models for displaying file system contents: the FileManager-grade table-like directory model, which exposed rich data (such as file icons with integrated image previews) about contents of a single directory, and the tree-like GFileSystemModel, which only exposed a tree of file names with very basic info about them. This commit unifies the two. The new GFileSystemModel can be used both as a tree-like and as a table-like model, or in fact in both ways simultaneously. It exposes rich data about a file system subtree rooted at the given root. The users of the two previous models are all ported to use this new model.
This commit is contained in:
parent
0f18a16e2c
commit
fdeb91e000
12 changed files with 597 additions and 700 deletions
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGUI/GDirectoryModel.h>
|
||||
#include <LibGUI/GFileSystemModel.h>
|
||||
#include <LibGUI/GItemView.h>
|
||||
#include <LibGUI/GStackWidget.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
|
@ -13,7 +13,7 @@ public:
|
|||
virtual ~DirectoryView() override;
|
||||
|
||||
void open(const StringView& path);
|
||||
String path() const { return model().path(); }
|
||||
String path() const { return model().root_path(); }
|
||||
void open_parent_directory();
|
||||
void open_previous_directory();
|
||||
void open_next_directory();
|
||||
|
@ -55,11 +55,11 @@ public:
|
|||
callback(*m_item_view);
|
||||
}
|
||||
|
||||
GDirectoryModel& model() { return *m_model; }
|
||||
GFileSystemModel& model() { return *m_model; }
|
||||
|
||||
private:
|
||||
explicit DirectoryView(GWidget* parent);
|
||||
const GDirectoryModel& model() const { return *m_model; }
|
||||
const GFileSystemModel& model() const { return *m_model; }
|
||||
|
||||
void handle_activation(const GModelIndex&);
|
||||
|
||||
|
@ -68,7 +68,7 @@ private:
|
|||
|
||||
ViewMode m_view_mode { Invalid };
|
||||
|
||||
NonnullRefPtr<GDirectoryModel> m_model;
|
||||
NonnullRefPtr<GFileSystemModel> m_model;
|
||||
int m_path_history_position { 0 };
|
||||
Vector<String> m_path_history;
|
||||
void add_path_to_history(const StringView& path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue