Cute Chess  0.1
pgndatabasemodel.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_MODEL_H
19 #define PGN_DATABASE_MODEL_H
20 
21 #include <QAbstractItemModel>
22 #include <QList>
23 
24 #include "pgndatabase.h"
25 #include "gamedatabasemanager.h"
26 
28 
33 {
34  Q_OBJECT
35 
36  public:
41  PgnDatabaseModel(GameDatabaseManager* gameDatabaseManager,
42  QObject* parent = nullptr);
43 
44  // Inherited from QAbstractItemModel
45  virtual QModelIndex index(int row, int column,
46  const QModelIndex& parent = QModelIndex()) const;
47  virtual QModelIndex parent(const QModelIndex& index) const;
48  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
49  virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
50  virtual QVariant data(const QModelIndex& index, int role) const;
51  virtual QVariant headerData(int section, Qt::Orientation orientation,
52  int role = Qt::DisplayRole) const;
53  virtual Qt::ItemFlags flags(const QModelIndex& index) const;
54  virtual bool setData(const QModelIndex& index, const QVariant& value,
55  int role = Qt::EditRole);
56 
57  private slots:
58  void onDatabaseAdded(int index);
59  void onDatabaseAboutToBeRemoved(int index);
60  void onDatabasesReset();
61 
62  private:
63  GameDatabaseManager* m_gameDatabaseManager;
64 };
65 
66 #endif // PGN_DATABASE_MODEL_H
67 
Manages chess game databases.
Definition: gamedatabasemanager.h:33
Supplies PGN database information to views.
Definition: pgndatabasemodel.h:32
PgnDatabaseModel(GameDatabaseManager *gameDatabaseManager, QObject *parent=nullptr)
Definition: pgndatabasemodel.cpp:21