2019-03-01 13:54:28 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-05-23 14:15:57 -07:00
|
|
|
#include <AK/Vector.h>
|
2019-03-01 13:54:28 +01:00
|
|
|
#include <LibGUI/GTableView.h>
|
2019-03-23 03:53:51 +01:00
|
|
|
#include <LibGUI/GItemView.h>
|
|
|
|
#include <LibGUI/GStackWidget.h>
|
2019-05-09 01:24:37 +02:00
|
|
|
#include <LibGUI/GDirectoryModel.h>
|
2019-03-01 13:54:28 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2019-03-23 03:53:51 +01:00
|
|
|
class DirectoryView final : public GStackWidget {
|
2019-03-01 13:54:28 +01:00
|
|
|
public:
|
2019-03-23 03:53:51 +01:00
|
|
|
explicit DirectoryView(GWidget* parent);
|
|
|
|
virtual ~DirectoryView() override;
|
2019-03-01 13:54:28 +01:00
|
|
|
|
|
|
|
void open(const String& path);
|
|
|
|
String path() const { return model().path(); }
|
2019-03-02 09:16:57 +01:00
|
|
|
void open_parent_directory();
|
2019-05-23 14:15:57 -07:00
|
|
|
void open_previous_directory();
|
|
|
|
void open_next_directory();
|
|
|
|
int path_history_size() const { return m_path_history.size(); }
|
|
|
|
int path_history_position() const { return m_path_history_position; }
|
2019-03-01 13:54:28 +01:00
|
|
|
|
2019-03-20 22:31:21 +01:00
|
|
|
void refresh();
|
|
|
|
|
2019-03-01 13:54:28 +01:00
|
|
|
Function<void(const String&)> on_path_change;
|
|
|
|
Function<void(String)> on_status_message;
|
2019-03-25 04:25:25 +01:00
|
|
|
Function<void(int done, int total)> on_thumbnail_progress;
|
2019-03-01 13:54:28 +01:00
|
|
|
|
2019-03-23 03:53:51 +01:00
|
|
|
enum ViewMode { Invalid, List, Icon };
|
|
|
|
void set_view_mode(ViewMode);
|
|
|
|
ViewMode view_mode() const { return m_view_mode; }
|
2019-03-01 13:54:28 +01:00
|
|
|
|
2019-03-23 03:53:51 +01:00
|
|
|
private:
|
2019-05-09 01:24:37 +02:00
|
|
|
GDirectoryModel& model() { return *m_model; }
|
|
|
|
const GDirectoryModel& model() const { return *m_model; }
|
2019-03-01 13:54:28 +01:00
|
|
|
|
2019-05-09 04:56:52 +02:00
|
|
|
void handle_activation(const GModelIndex&);
|
|
|
|
|
2019-03-01 13:54:28 +01:00
|
|
|
void set_status_message(const String&);
|
2019-03-09 14:52:25 +01:00
|
|
|
|
2019-03-23 03:53:51 +01:00
|
|
|
ViewMode m_view_mode { Invalid };
|
|
|
|
|
2019-05-09 01:24:37 +02:00
|
|
|
Retained<GDirectoryModel> m_model;
|
2019-05-23 14:15:57 -07:00
|
|
|
int m_path_history_position{ 0 };
|
|
|
|
Vector<String> m_path_history;
|
|
|
|
void add_path_to_history(const String& path);
|
2019-03-23 03:53:51 +01:00
|
|
|
|
|
|
|
GTableView* m_table_view { nullptr };
|
|
|
|
GItemView* m_item_view { nullptr };
|
2019-03-01 13:54:28 +01:00
|
|
|
};
|