Make items_opt private

This commit is contained in:
Jeremy Soller 2024-02-29 13:42:13 -07:00
parent bcd5da57ab
commit b9f959a298
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
4 changed files with 61 additions and 47 deletions

View file

@ -552,7 +552,6 @@ pub enum HeadingOptions {
pub struct Tab {
pub location: Location,
pub context_menu: Option<Point>,
pub items_opt: Option<Vec<Item>>,
pub view: View,
pub dialog: Option<DialogKind>,
pub scroll_opt: Option<Viewport>,
@ -562,6 +561,7 @@ pub struct Tab {
pub history_i: usize,
pub history: Vec<Location>,
pub config: TabConfig,
items_opt: Option<Vec<Item>>,
sort_name: HeadingOptions,
sort_direction: bool,
}
@ -574,7 +574,6 @@ impl Tab {
Self {
location,
context_menu: None,
items_opt: None,
view: View::Grid,
dialog: None,
scroll_opt: None,
@ -584,6 +583,7 @@ impl Tab {
history_i: 0,
history,
config,
items_opt: None,
sort_name,
sort_direction,
}
@ -601,6 +601,44 @@ impl Tab {
}
}
pub fn items_opt(&self) -> Option<&Vec<Item>> {
self.items_opt.as_ref()
}
pub fn items_opt_mut(&mut self) -> Option<&mut Vec<Item>> {
self.items_opt.as_mut()
}
pub fn set_items(&mut self, items: Vec<Item>) {
self.items_opt = Some(items);
}
pub fn select_all(&mut self) {
if let Some(ref mut items) = self.items_opt {
for item in items.iter_mut() {
if !self.config.show_hidden && item.hidden {
item.selected = false;
continue;
}
item.selected = true;
item.click_time = None;
}
}
}
pub fn select_none(&mut self) -> bool {
let mut had_selection = false;
if let Some(ref mut items) = self.items_opt {
for item in items.iter_mut() {
if item.selected {
item.selected = false;
had_selection = true;
}
}
}
had_selection
}
fn select_by_drag(&mut self, rect: Rectangle) {
let items = match &mut self.items_opt {
Some(some) => some,