Sayonara Player
DateFilter.h
1 /* DateFilter.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DATE_MODE_H_
22 #define DATE_MODE_H_
23 
24 #include "Helper/Pimpl.h"
25 
26 #include <QString>
27 #include <QList>
28 #include <QPair>
29 
30 
31 class QDateTime;
32 namespace Library
33 {
38  class DateFilter
39  {
40  public:
41 
42 
43  enum class TimeSpan : char
44  {
45  Days=1,
46  Weeks,
47  Months,
48  Years
49  };
50 
51  typedef QPair<Library::DateFilter::TimeSpan, quint8> TimeSpanEntry;
53 
54  enum class ChangeMode : char
55  {
56  Modified=1,
57  Created=2,
58  ModifiedOrCreated=3
59  };
60 
61  enum class Type : char
62  {
63  NewerThan=1,
64  OlderThan,
65  Between
66  };
67 
68  private:
69  PIMPL(Library::DateFilter)
70 
71  public:
72 
73  explicit DateFilter(const QString& name=QString());
74  DateFilter(const DateFilter& other);
75  void operator=(const DateFilter& other);
76  bool operator==(const DateFilter& other) const;
77 
78  ~DateFilter();
79 
80  QString name() const;
81  void set_name(const QString& name);
82  bool valid() const;
83  void clear();
84 
85  void set_between(TimeSpan span_from, quint8 value_from, TimeSpan span_to, quint8 value_to, ChangeMode change_mode=ChangeMode::Created);
86  void set_between(const QDateTime& from, const QDateTime& to, ChangeMode change_mode=ChangeMode::Created);
87 
88  void set_older_than(TimeSpan span, quint8 value, ChangeMode change_mode=ChangeMode::Created);
89  void set_older_than(const QDateTime& date, ChangeMode change_mode);
90 
91  void set_newer_than(TimeSpan span, quint8 value, ChangeMode change_mode=ChangeMode::Created);
92  void set_newer_than(const QDateTime& date, ChangeMode change_mode=ChangeMode::Created);
93 
94  TimeSpanMap time_span_map() const;
95  Library::DateFilter::Type type() const;
96 
97  QString get_sql_filter(const QString& track_prefix=QString()) const;
98 
99  QString toString() const;
100  static Library::DateFilter fromString(const QString& str);
101  };
102 }
103 
104 #endif
Definition: DatabaseAlbums.h:29
The DateFilter class.
Definition: DateFilter.h:38
Definition: org_mpris_media_player2_adaptor.h:20