mirror of
https://github.com/YGGverse/nexy.git
synced 2026-03-31 17:25:27 +00:00
group sort members
This commit is contained in:
parent
936b459f12
commit
917b1007ad
2 changed files with 36 additions and 24 deletions
|
|
@ -147,13 +147,13 @@ impl Storage {
|
|||
// format dirs list
|
||||
let dc = &self.list_config.dir; // just short alias
|
||||
dirs.sort_by(|a, b| {
|
||||
if dc.is_sort_accessed {
|
||||
if dc.sort.time.is_accessed {
|
||||
a.meta.atime().cmp(&b.meta.atime())
|
||||
} else if dc.is_sort_created {
|
||||
} else if dc.sort.time.is_created {
|
||||
a.meta.ctime().cmp(&b.meta.ctime())
|
||||
} else if dc.is_sort_modified {
|
||||
} else if dc.sort.time.is_modified {
|
||||
a.meta.mtime().cmp(&b.meta.mtime())
|
||||
} else if dc.is_sort_count {
|
||||
} else if dc.sort.is_count {
|
||||
a.meta.size().cmp(&b.meta.size())
|
||||
} else {
|
||||
a.name.cmp(&b.name)
|
||||
|
|
@ -188,13 +188,13 @@ impl Storage {
|
|||
// format files list
|
||||
let fc = &self.list_config.file; // just short alias
|
||||
files.sort_by(|a, b| {
|
||||
if fc.is_sort_accessed {
|
||||
if fc.sort.time.is_accessed {
|
||||
a.meta.atime().cmp(&b.meta.atime())
|
||||
} else if fc.is_sort_created {
|
||||
} else if fc.sort.time.is_created {
|
||||
a.meta.ctime().cmp(&b.meta.ctime())
|
||||
} else if fc.is_sort_modified {
|
||||
} else if fc.sort.time.is_modified {
|
||||
a.meta.mtime().cmp(&b.meta.mtime())
|
||||
} else if fc.is_sort_size {
|
||||
} else if fc.sort.is_size {
|
||||
a.meta.size().cmp(&b.meta.size())
|
||||
} else {
|
||||
a.name.cmp(&b.name)
|
||||
|
|
|
|||
|
|
@ -4,22 +4,26 @@ pub struct Time {
|
|||
pub is_modified: bool,
|
||||
}
|
||||
|
||||
pub struct DirSort {
|
||||
pub time: Time,
|
||||
pub is_count: bool,
|
||||
}
|
||||
|
||||
pub struct FileSort {
|
||||
pub time: Time,
|
||||
pub is_size: bool,
|
||||
}
|
||||
|
||||
pub struct Dir {
|
||||
pub is_count: bool,
|
||||
pub is_reverse: bool,
|
||||
pub is_sort_accessed: bool,
|
||||
pub is_sort_count: bool,
|
||||
pub is_sort_created: bool,
|
||||
pub is_sort_modified: bool,
|
||||
pub sort: DirSort,
|
||||
pub time: Time,
|
||||
}
|
||||
pub struct File {
|
||||
pub is_reverse: bool,
|
||||
pub is_size: bool,
|
||||
pub is_sort_accessed: bool,
|
||||
pub is_sort_created: bool,
|
||||
pub is_sort_modified: bool,
|
||||
pub is_sort_size: bool,
|
||||
pub sort: FileSort,
|
||||
pub time: Time,
|
||||
}
|
||||
|
||||
|
|
@ -40,10 +44,14 @@ impl ListConfig {
|
|||
},
|
||||
is_count: config.list_dir_count,
|
||||
is_reverse: config.list_dir_reverse,
|
||||
is_sort_accessed: config.list_dir_sort_accessed,
|
||||
is_sort_created: config.list_dir_sort_created,
|
||||
is_sort_modified: config.list_dir_sort_modified,
|
||||
is_sort_count: config.list_dir_sort_count,
|
||||
sort: DirSort {
|
||||
time: Time {
|
||||
is_accessed: config.list_dir_sort_accessed,
|
||||
is_created: config.list_dir_sort_created,
|
||||
is_modified: config.list_dir_sort_modified,
|
||||
},
|
||||
is_count: config.list_dir_sort_count,
|
||||
},
|
||||
},
|
||||
file: File {
|
||||
time: Time {
|
||||
|
|
@ -53,10 +61,14 @@ impl ListConfig {
|
|||
},
|
||||
is_reverse: config.list_file_reverse,
|
||||
is_size: config.list_file_size,
|
||||
is_sort_accessed: config.list_file_sort_accessed,
|
||||
is_sort_created: config.list_file_sort_created,
|
||||
is_sort_modified: config.list_file_sort_modified,
|
||||
is_sort_size: config.list_file_sort_size,
|
||||
sort: FileSort {
|
||||
time: Time {
|
||||
is_accessed: config.list_file_sort_accessed,
|
||||
is_created: config.list_file_sort_created,
|
||||
is_modified: config.list_file_sort_modified,
|
||||
},
|
||||
is_size: config.list_file_sort_size,
|
||||
},
|
||||
},
|
||||
time_format: config.list_time_format.clone(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue