Cute Chess  0.1
pgndatabase.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 PGN_DATABASE_H
19 #define PGN_DATABASE_H
20 
21 #include <QObject>
22 #include <QList>
23 #include <QDateTime>
24 #include <QFile>
25 #include <pgngame.h>
26 #include <pgngameentry.h>
27 class PgnStream;
28 
36 class PgnDatabase : public QObject
37 {
38  Q_OBJECT
39 
40  public:
42  enum Status
43  {
44  Ok,
49  };
50 
55  PgnDatabase(const QString& fileName, QObject* parent = nullptr);
57  virtual ~PgnDatabase();
58 
75 
77  QString fileName() const;
78 
80  Status status() const;
81 
90  QDateTime lastModified() const;
91 
98 
104  QString displayName() const;
114  void setDisplayName(const QString& displayName);
115 
121  Status game(const PgnGameEntry* entry, PgnGame* game);
122 
123  private:
124  QList<const PgnGameEntry*> m_entries;
125  QDateTime m_lastModified;
126  QString m_fileName;
127  QString m_displayName;
128 };
129 
130 #endif // PGN_DATABASE_H
The database can be used normally.
Definition: pgndatabase.h:44
A class for reading games in PGN format from a text stream.
Definition: pgnstream.h:41
QString fileName() const
Definition: pgndatabase.cpp:45
An entry in a PGN collection.
Definition: pgngameentry.h:39
Status status() const
Definition: pgndatabase.cpp:50
QList< const PgnGameEntry * > entries() const
Definition: pgndatabase.cpp:40
void setLastModified(const QDateTime &lastModified)
Definition: pgndatabase.cpp:69
A game of chess in PGN format.
Definition: pgngame.h:51
Database contains corrupted or invalid data.
Definition: pgndatabase.h:48
Database file was modified externally.
Definition: pgndatabase.h:45
QString displayName() const
Definition: pgndatabase.cpp:74
PgnDatabase(const QString &fileName, QObject *parent=nullptr)
Definition: pgndatabase.cpp:22
void setDisplayName(const QString &displayName)
Definition: pgndatabase.cpp:79
PGN database.
Definition: pgndatabase.h:36
virtual ~PgnDatabase()
Definition: pgndatabase.cpp:29
void setEntries(const QList< const PgnGameEntry *> &entries)
Definition: pgndatabase.cpp:34
QDateTime lastModified() const
Definition: pgndatabase.cpp:64
Database file does not exist.
Definition: pgndatabase.h:46
Status
Definition: pgndatabase.h:42
Status game(const PgnGameEntry *entry, PgnGame *game)
Definition: pgndatabase.cpp:84
Database file cannot be read.
Definition: pgndatabase.h:47