Cute Chess  0.1
pgngamefilter.h
1 /*
2  This file is part of Cute Chess.
3 
4  Cute Chess is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Cute Chess is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef PGNGAMEFILTER_H
19 #define PGNGAMEFILTER_H
20 
21 #include <QByteArray>
22 #include <QDate>
23 #include "board/side.h"
24 class QString;
25 class PgnGameEntry;
26 
36 class LIB_EXPORT PgnGameFilter
37 {
38  public:
40  enum Type
41  {
45  Advanced
46  };
47 
49  enum Result
50  {
57  Draw,
58  Unfinished
59  };
60 
67  PgnGameFilter();
74  PgnGameFilter(const QString& pattern);
75 
77  Type type() const;
78 
80  const char* pattern() const;
81 
83  const char* event() const;
85  const char* site() const;
92  const char* player() const;
94  const char* opponent() const;
96  Chess::Side playerSide() const;
102  const QDate& minDate() const;
108  const QDate& maxDate() const;
110  int minRound() const;
112  int maxRound() const;
114  Result result() const;
119  bool isResultInverted() const;
120 
126  void setPattern(const QString& pattern);
127 
129  void setEvent(const QString& event);
131  void setSite(const QString& site);
133  void setMinDate(const QDate& date);
135  void setMaxDate(const QDate& date);
137  void setMinRound(int round);
139  void setMaxRound(int round);
141  void setPlayer(const QString& name, Chess::Side side);
143  void setOpponent(const QString& name);
145  void setResult(Result result);
147  void setResultInverted(bool invert);
148 
149  private:
150  Type m_type;
151  QByteArray m_pattern;
152  QByteArray m_event;
153  QByteArray m_site;
154  QByteArray m_player;
155  QByteArray m_opponent;
156  Chess::Side m_playerSide;
157  QDate m_minDate;
158  QDate m_maxDate;
159  int m_minRound;
160  int m_maxRound;
161  Result m_result;
162  bool m_resultInverted;
163 };
164 
166 {
167  return m_type;
168 }
169 
170 inline const char* PgnGameFilter::pattern() const
171 {
172  return m_pattern.constData();
173 }
174 
175 inline const char* PgnGameFilter::event() const
176 {
177  return m_event.constData();
178 }
179 
180 inline const char* PgnGameFilter::site() const
181 {
182  return m_site.constData();
183 }
184 
185 inline const QDate& PgnGameFilter::minDate() const
186 {
187  return m_minDate;
188 }
189 
190 inline const QDate& PgnGameFilter::maxDate() const
191 {
192  return m_maxDate;
193 }
194 
195 inline int PgnGameFilter::minRound() const
196 {
197  return m_minRound;
198 }
199 
200 inline int PgnGameFilter::maxRound() const
201 {
202  return m_maxRound;
203 }
204 
206 {
207  return m_result;
208 }
209 
211 {
212  return m_resultInverted;
213 }
214 
215 inline const char* PgnGameFilter::player() const
216 {
217  return m_player.constData();
218 }
219 
220 inline const char* PgnGameFilter::opponent() const
221 {
222  return m_opponent.constData();
223 }
224 
226 {
227  return m_playerSide;
228 }
229 
230 #endif // PGNGAMEFILTER_H
Result
Definition: pgngamefilter.h:49
Definition: pgngamefilter.h:43
const QDate & maxDate() const
Definition: pgngamefilter.h:190
Result result() const
Definition: pgngamefilter.h:205
An entry in a PGN collection.
Definition: pgngameentry.h:39
A filter for chess games in a PGN database.
Definition: pgngamefilter.h:36
The black player wins.
Definition: pgngamefilter.h:54
Chess::Side playerSide() const
Definition: pgngamefilter.h:225
Type type() const
Definition: pgngamefilter.h:165
int minRound() const
Definition: pgngamefilter.h:195
The game is a draw.
Definition: pgngamefilter.h:57
Either player wins.
Definition: pgngamefilter.h:52
The first player loses.
Definition: pgngamefilter.h:56
const char * pattern() const
Definition: pgngamefilter.h:170
int maxRound() const
Definition: pgngamefilter.h:200
The white player wins.
Definition: pgngamefilter.h:53
The side or color of a chess player.
Definition: side.h:34
bool isResultInverted() const
Definition: pgngamefilter.h:210
Any result (no filtering)
Definition: pgngamefilter.h:51
const char * opponent() const
Definition: pgngamefilter.h:220
const QDate & minDate() const
Definition: pgngamefilter.h:185
The first player wins.
Definition: pgngamefilter.h:55
const char * player() const
Definition: pgngamefilter.h:215
const char * event() const
Definition: pgngamefilter.h:175
Type
Definition: pgngamefilter.h:40
const char * site() const
Definition: pgngamefilter.h:180