mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-04 12:58:23 +00:00
change type
This commit is contained in:
@@ -43,28 +43,32 @@ impl StatisticsCache {
|
|||||||
if let Some(state) = state {
|
if let Some(state) = state {
|
||||||
match selection {
|
match selection {
|
||||||
Selection::Empty => (),
|
Selection::Empty => (),
|
||||||
Selection::File(s) => {
|
Selection::File { file_ids } => {
|
||||||
for id in s.files.iter() {
|
for id in file_ids.iter() {
|
||||||
if let Some(file) = state.get(id) {
|
if let Some(file) = state.get(id) {
|
||||||
self.add_file_stats(file, &mut stats);
|
self.add_file_stats(file, &mut stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Selection::Track(s) => {
|
Selection::Track { file_id, trk_ids } => {
|
||||||
if let Some(file) = state.get(&s.file) {
|
if let Some(file) = state.get(file_id) {
|
||||||
for trk in file.trk.iter() {
|
for trk in file.trk.iter() {
|
||||||
if s.trk.contains(&trk.id) {
|
if trk_ids.contains(&trk.id) {
|
||||||
self.add_track_stats(trk, &mut stats);
|
self.add_track_stats(trk, &mut stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Selection::TrackSegment(s) => {
|
Selection::TrackSegment {
|
||||||
if let Some(file) = state.get(&s.file) {
|
file_id,
|
||||||
|
trk_id,
|
||||||
|
trkseg_ids,
|
||||||
|
} => {
|
||||||
|
if let Some(file) = state.get(file_id) {
|
||||||
for trk in file.trk.iter() {
|
for trk in file.trk.iter() {
|
||||||
if s.trk == trk.id {
|
if *trk_id == trk.id {
|
||||||
for trkseg in trk.trkseg.iter() {
|
for trkseg in trk.trkseg.iter() {
|
||||||
if s.trkseg.contains(&trkseg.id) {
|
if trkseg_ids.contains(&trkseg.id) {
|
||||||
self.add_segment_stats(trkseg, &mut stats);
|
self.add_segment_stats(trkseg, &mut stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,13 +77,16 @@ impl StatisticsCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Selection::Waypoints(s) => {
|
Selection::Waypoints { file_id } => {
|
||||||
if let Some(file) = state.get(&s.file) {
|
if let Some(file) = state.get(file_id) {
|
||||||
self.add_file_stats(file, &mut stats);
|
self.add_file_stats(file, &mut stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Selection::Waypoint(s) => {
|
Selection::Waypoint {
|
||||||
if let Some(file) = state.get(&s.file) {
|
file_id,
|
||||||
|
wpt_ids: _,
|
||||||
|
} => {
|
||||||
|
if let Some(file) = state.get(file_id) {
|
||||||
self.add_file_stats(file, &mut stats);
|
self.add_file_stats(file, &mut stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,50 +2,35 @@ use std::collections::HashSet;
|
|||||||
|
|
||||||
use crate::{FileId, TrackId, TrackSegmentId, WaypointId};
|
use crate::{FileId, TrackId, TrackSegmentId, WaypointId};
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct FileSelection {
|
|
||||||
pub files: HashSet<FileId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct TrackSelection {
|
|
||||||
pub file: FileId,
|
|
||||||
pub trk: HashSet<TrackId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct TrackSegmentSelection {
|
|
||||||
pub file: FileId,
|
|
||||||
pub trk: TrackId,
|
|
||||||
pub trkseg: HashSet<TrackSegmentId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct WaypointsSelection {
|
|
||||||
pub file: FileId,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct WaypointSelection {
|
|
||||||
pub file: FileId,
|
|
||||||
pub wpt: HashSet<WaypointId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub enum Selection {
|
pub enum Selection {
|
||||||
#[default]
|
#[default]
|
||||||
Empty,
|
Empty,
|
||||||
File(FileSelection),
|
File {
|
||||||
Track(TrackSelection),
|
file_ids: HashSet<FileId>,
|
||||||
TrackSegment(TrackSegmentSelection),
|
},
|
||||||
Waypoints(WaypointsSelection),
|
Track {
|
||||||
Waypoint(WaypointSelection),
|
file_id: FileId,
|
||||||
|
trk_ids: HashSet<TrackId>,
|
||||||
|
},
|
||||||
|
TrackSegment {
|
||||||
|
file_id: FileId,
|
||||||
|
trk_id: TrackId,
|
||||||
|
trkseg_ids: HashSet<TrackSegmentId>,
|
||||||
|
},
|
||||||
|
Waypoints {
|
||||||
|
file_id: FileId,
|
||||||
|
},
|
||||||
|
Waypoint {
|
||||||
|
file_id: FileId,
|
||||||
|
wpt_ids: HashSet<WaypointId>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Selection {
|
impl Selection {
|
||||||
pub fn select(&mut self, id: FileId) {
|
pub fn select(&mut self, id: FileId) {
|
||||||
let mut files = HashSet::default();
|
let mut file_ids = HashSet::default();
|
||||||
files.insert(id);
|
file_ids.insert(id);
|
||||||
*self = Selection::File(FileSelection { files });
|
*self = Selection::File { file_ids };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user