Unity Scopes API
DateTimePickerFilter.h
1 /*
2  * Copyright (C) 2015 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/FilterBase.h>
22 #include <chrono>
23 #include <bitset>
24 
25 namespace unity
26 {
27 
28 namespace scopes
29 {
30 class FilterState;
31 
32 namespace internal
33 {
34 class DateTimePickerFilterImpl;
35 }
36 
37 namespace experimental
38 {
39 
47 class DateTimePickerFilter : public FilterBase
48 {
49 public:
51  UNITY_DEFINES_PTRS(DateTimePickerFilter);
53 
61  enum ModeFlags {
62  Years,
63  Months,
64  Days,
65  Hours,
66  Minutes,
67  Seconds
68  };
69 
73  typedef std::bitset<6> Mode;
74 
83  static DateTimePickerFilter::UPtr create(std::string const& id, Mode mode);
84 
91  void set_time_label(std::string const& label);
92 
99  void set_date_label(std::string const& label);
100 
107  void set_minimum(std::chrono::system_clock::time_point const& date);
108 
115  void set_maximum(std::chrono::system_clock::time_point const& date);
116 
122  std::string time_label() const;
123 
129  std::string date_label() const;
130 
136  Mode mode() const;
137 
143  bool has_minimum() const;
144 
150  bool has_maximum() const;
151 
158  std::chrono::system_clock::time_point minimum() const;
159 
166  std::chrono::system_clock::time_point maximum() const;
167 
173  bool has_selected_date(FilterState const& filter_state) const;
174 
182  std::chrono::system_clock::time_point selected_date(FilterState const& filter_state) const;
183 
189  void update_state(FilterState& filter_state, std::chrono::system_clock::time_point const& date) const;
190 
199  static void update_state(FilterState& filter_state, std::string const& filter_id, std::chrono::system_clock::time_point const& date);
200 
201 private:
202  DateTimePickerFilter(internal::DateTimePickerFilterImpl*);
203  internal::DateTimePickerFilterImpl* fwd() const;
204  friend class internal::DateTimePickerFilterImpl;
205 };
206 
207 } // namespace experimental
208 
209 } // namespace scopes
210 
211 } // namespace unity
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31