Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to display file sizes and modification dates, and optionally sort by them #165

Open
crumblingstatue opened this issue Oct 16, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@crumblingstatue
Copy link
Contributor

These are commonly expected features from a file picker
image

@hacknus
Copy link
Contributor

hacknus commented Nov 29, 2024

Can we use the table demo for that?

The metadata will be available with #184.

@fluxxcode
Copy link
Owner

We can try. But it won't be that easy and we have to rewrite a lot of code for the central panel.

Is there a show_rows option in the default egui tables to update only visible elements?

@hacknus
Copy link
Contributor

hacknus commented Nov 29, 2024

I think it also works with a ScrollArea around it, but I've never tried

@hacknus
Copy link
Contributor

hacknus commented Nov 29, 2024

I'm playing around with it, and I think the TableBuilder could definitely be the way to go, but as you said, there is quite some work involved.

@hacknus
Copy link
Contributor

hacknus commented Nov 29, 2024

But I think this bug in egui needs to be fixed first, before we can continue here: emilk/egui#5045

@fluxxcode
Copy link
Owner

Ough yes, that doesn't look good. Maybe we can implement a workaround for this. Unfortunately, the issue has been around for 3 months now...

@hacknus
Copy link
Contributor

hacknus commented Nov 30, 2024

found a workaround for the egui bug. getting there...
Bildschirmfoto 2024-11-30 um 13 40 24

@hacknus
Copy link
Contributor

hacknus commented Nov 30, 2024

The main change is that this function

    /// Returns an iterator in the given range of the directory contents.
    /// No filters are applied using this iterator.
    pub fn iter_range_mut(
        &mut self,
        range: std::ops::Range<usize>,
    ) -> impl Iterator<Item = &mut DirectoryEntry> {
        self.content[range].iter_mut()
    }

will no longer be used and instead everything is handled by indices:

    /// Returns one directory entry by index
    pub fn get(&mut self, i: usize) -> Option<&mut DirectoryEntry> {
        self.content.get_mut(i)
    }

    pub fn filtered_get<'s>(
        &'s mut self,
        index: usize,
        search_value: &'s str,
    ) -> Option<&'s mut DirectoryEntry> {
        self.content
            .iter_mut()
            .filter(|p| apply_search_value(p, search_value))
            .nth(index)
    }

    pub fn filtered_count(&self, search_value: &str) -> usize {
        self.content
            .iter()
            .filter(|p| apply_search_value(p, search_value))
            .count()
    }

This is due to the implementation of rows() where it does not get you a range object but just an index. It still has a ScrollArea in the back and should only display the items that are visible. And I think this way also for the filtered ones (?)

@hacknus hacknus mentioned this issue Nov 30, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants