mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-29 09:39:12 -04:00
Fileman memory opt (#2076)
* paginator * fixes * string instead of path, so saves ram. * fix FileLoadView * pagination list number * pagination "size" test * added detection of special folder name to display page numbers instead of (0 or a number of byte) * order of things: only one directory '..', only on first page Co-authored-by: gullradriel <gullradriel@no-mail.com>
This commit is contained in:
parent
56303eb385
commit
a30875b582
2 changed files with 147 additions and 48 deletions
|
@ -31,7 +31,7 @@
|
|||
namespace ui {
|
||||
|
||||
struct fileman_entry {
|
||||
std::filesystem::path path{};
|
||||
std::string path{};
|
||||
uint32_t size{};
|
||||
bool is_directory{};
|
||||
};
|
||||
|
@ -61,8 +61,12 @@ class FileManBaseView : public View {
|
|||
void push_dir(const std::filesystem::path& path);
|
||||
|
||||
protected:
|
||||
static constexpr size_t max_filename_length = 64;
|
||||
static constexpr size_t max_items_shown = 100;
|
||||
uint32_t prev_highlight = 0;
|
||||
uint8_t pagination = 0;
|
||||
uint8_t nb_pages = 1;
|
||||
static constexpr size_t max_filename_length = 20;
|
||||
static constexpr size_t max_items_loaded = 75; // too memory hungry, so won't load more
|
||||
static constexpr size_t items_per_page = 20;
|
||||
|
||||
struct file_assoc_t {
|
||||
std::filesystem::path extension;
|
||||
|
@ -87,7 +91,7 @@ class FileManBaseView : public View {
|
|||
|
||||
void pop_dir();
|
||||
void refresh_list();
|
||||
void reload_current();
|
||||
void reload_current(bool reset_pagination = false);
|
||||
void load_directory_contents(const std::filesystem::path& dir_path);
|
||||
const file_assoc_t& get_assoc(const std::filesystem::path& ext) const;
|
||||
|
||||
|
@ -97,11 +101,14 @@ class FileManBaseView : public View {
|
|||
std::function<void(KeyEvent)> on_select_entry{nullptr};
|
||||
std::function<void(bool)> on_refresh_widgets{nullptr};
|
||||
|
||||
const std::string str_back{"<--"};
|
||||
const std::string str_next{"-->"};
|
||||
const std::string str_full{"Can't load more.."};
|
||||
const std::filesystem::path parent_dir_path{u".."};
|
||||
std::filesystem::path current_path{u""};
|
||||
std::filesystem::path extension_filter{u""};
|
||||
|
||||
std::vector<fileman_entry> entry_list{};
|
||||
std::list<fileman_entry> entry_list{};
|
||||
std::vector<uint32_t> saved_index_stack{};
|
||||
|
||||
bool show_hidden_files{false};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue