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"
25class QString;
26class PgnGameEntry;
27
37class LIB_EXPORT PgnGameFilter
38{
39 public:
48
61
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
171inline const char* PgnGameFilter::pattern() const
172{
173 return m_pattern.constData();
174}
175
176inline const char* PgnGameFilter::event() const
177{
178 return m_event.constData();
179}
180
181inline const char* PgnGameFilter::site() const
182{
183 return m_site.constData();
184}
185
186inline const QDate& PgnGameFilter::minDate() const
187{
188 return m_minDate;
189}
190
191inline const QDate& PgnGameFilter::maxDate() const
192{
193 return m_maxDate;
194}
195
196inline int PgnGameFilter::minRound() const
197{
198 return m_minRound;
199}
200
201inline 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
216inline const char* PgnGameFilter::player() const
217{
218 return m_player.constData();
219}
220
221inline const char* PgnGameFilter::opponent() const
222{
223 return m_opponent.constData();
224}
225
227{
228 return m_playerSide;
229}
230
231#endif // PGNGAMEFILTER_H
The side or color of a chess player.
Definition side.h:36
An entry in a PGN collection.
Definition pgngameentry.h:41
A filter for chess games in a PGN database.
Definition pgngamefilter.h:38
const char * event() const
Definition pgngamefilter.h:176
const QDate & maxDate() const
Definition pgngamefilter.h:191
Type
Definition pgngamefilter.h:42
@ FixedString
Definition pgngamefilter.h:44
@ Advanced
Definition pgngamefilter.h:46
Chess::Side playerSide() const
Definition pgngamefilter.h:226
int maxRound() const
Definition pgngamefilter.h:201
PgnGameFilter()
Definition pgngamefilter.cpp:23
const char * opponent() const
Definition pgngamefilter.h:221
const QDate & minDate() const
Definition pgngamefilter.h:186
bool isResultInverted() const
Definition pgngamefilter.h:211
int minRound() const
Definition pgngamefilter.h:196
const char * site() const
Definition pgngamefilter.h:181
Result result() const
Definition pgngamefilter.h:206
const char * player() const
Definition pgngamefilter.h:216
Result
Definition pgngamefilter.h:51
@ FirstPlayerLoses
The first player loses.
Definition pgngamefilter.h:57
@ Unfinished
The game wasn't completed.
Definition pgngamefilter.h:59
@ Draw
The game is a draw.
Definition pgngamefilter.h:58
@ EitherPlayerWins
Either player wins.
Definition pgngamefilter.h:53
@ WhiteWins
The white player wins.
Definition pgngamefilter.h:54
@ BlackWins
The black player wins.
Definition pgngamefilter.h:55
@ FirstPlayerWins
The first player wins.
Definition pgngamefilter.h:56
@ AnyResult
Any result (no filtering).
Definition pgngamefilter.h:52
Type type() const
Definition pgngamefilter.h:166
const char * pattern() const
Definition pgngamefilter.h:171