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