diff options
author | Akshay <[email protected]> | 2021-02-06 13:30:40 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-02-21 05:13:14 +0000 |
commit | 53f7a679a0cf7a510de13d67cf370988f71c0d08 (patch) | |
tree | b43b30df476d76d0a18feb7c6e7e00fd3ac4dae4 /src/habit/count.rs | |
parent | 9cdef4e296c77fb94d99553de05ba1aaa6c81ed8 (diff) |
deprecate view_month_offset in favor of cursor
Diffstat (limited to 'src/habit/count.rs')
-rw-r--r-- | src/habit/count.rs | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/habit/count.rs b/src/habit/count.rs index b14354c..09fd399 100644 --- a/src/habit/count.rs +++ b/src/habit/count.rs | |||
@@ -1,13 +1,12 @@ | |||
1 | use std::collections::HashMap; | 1 | use std::collections::HashMap; |
2 | use std::default::Default; | ||
2 | 3 | ||
3 | use chrono::NaiveDate; | 4 | use chrono::NaiveDate; |
4 | use cursive::direction::Absolute; | ||
5 | use serde::{Deserialize, Serialize}; | 5 | use serde::{Deserialize, Serialize}; |
6 | 6 | ||
7 | use crate::app::Cursor; | ||
8 | use crate::habit::prelude::default_auto; | 7 | use crate::habit::prelude::default_auto; |
9 | use crate::habit::traits::Habit; | 8 | use crate::habit::traits::Habit; |
10 | use crate::habit::{TrackEvent, ViewMode}; | 9 | use crate::habit::{InnerData, TrackEvent}; |
11 | 10 | ||
12 | #[derive(Debug, Serialize, Deserialize)] | 11 | #[derive(Debug, Serialize, Deserialize)] |
13 | pub struct Count { | 12 | pub struct Count { |
@@ -19,13 +18,7 @@ pub struct Count { | |||
19 | auto: bool, | 18 | auto: bool, |
20 | 19 | ||
21 | #[serde(skip)] | 20 | #[serde(skip)] |
22 | view_month_offset: u32, | 21 | inner_data: InnerData, |
23 | |||
24 | #[serde(skip)] | ||
25 | cursor: Cursor, | ||
26 | |||
27 | #[serde(skip)] | ||
28 | view_mode: ViewMode, | ||
29 | } | 22 | } |
30 | 23 | ||
31 | impl Count { | 24 | impl Count { |
@@ -35,9 +28,7 @@ impl Count { | |||
35 | stats: HashMap::new(), | 28 | stats: HashMap::new(), |
36 | goal, | 29 | goal, |
37 | auto, | 30 | auto, |
38 | view_month_offset: 0, | 31 | inner_data: Default::default(), |
39 | cursor: Cursor::new(), | ||
40 | view_mode: ViewMode::Day, | ||
41 | }; | 32 | }; |
42 | } | 33 | } |
43 | } | 34 | } |
@@ -101,23 +92,11 @@ impl Habit for Count { | |||
101 | }; | 92 | }; |
102 | } | 93 | } |
103 | } | 94 | } |
104 | fn set_view_month_offset(&mut self, offset: u32) { | 95 | fn inner_data_ref(&self) -> &InnerData { |
105 | self.view_month_offset = offset; | 96 | &self.inner_data |
106 | } | ||
107 | fn view_month_offset(&self) -> u32 { | ||
108 | self.view_month_offset | ||
109 | } | ||
110 | fn move_cursor(&mut self, d: Absolute) { | ||
111 | self.cursor.do_move(d); | ||
112 | } | ||
113 | fn cursor(&self) -> Cursor { | ||
114 | self.cursor | ||
115 | } | ||
116 | fn set_view_mode(&mut self, mode: ViewMode) { | ||
117 | self.view_mode = mode; | ||
118 | } | 97 | } |
119 | fn view_mode(&self) -> ViewMode { | 98 | fn inner_data_mut_ref(&mut self) -> &mut InnerData { |
120 | self.view_mode | 99 | &mut self.inner_data |
121 | } | 100 | } |
122 | fn is_auto(&self) -> bool { | 101 | fn is_auto(&self) -> bool { |
123 | self.auto | 102 | self.auto |