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