BCESolve
bcepriortablemodel.hpp
1// This file is part of the BCESolve library for games of incomplete
2// information
3// Copyright (C) 2022 Benjamin A. Brooks
4//
5// BCESolve free software: you can redistribute it and/or modify it
6// 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// BCESolve is distributed in the hope that it will be useful, but
11// WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see
17// <http://www.gnu.org/licenses/>.
18//
19// Benjamin A. Brooks
20// ben@benjaminbrooks.net
21// Chicago, IL
22
23#ifndef BCEPRIORTABLEMODEL_HPP
24#define BCEPRIORTABLEMODEL_HPP
25
26#include <QtWidgets>
27#include <QAbstractTableModel>
28#include <QTableView>
29#include "bcegame.hpp"
30
32
39class BCEPriorTableModel : public QAbstractTableModel
40{
41 Q_OBJECT
42
43public:
46 game(_game)
47 { }
48
50
52 Qt::ItemFlags flags(const QModelIndex & index) const
53 { return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; }
54
56 int rowCount(const QModelIndex & parent = QModelIndex()) const Q_DECL_OVERRIDE
57 { return game->getNumStates(); }
59 int columnCount(const QModelIndex & parent = QModelIndex()) const Q_DECL_OVERRIDE
60 { return 1; }
61
64 { emit layoutChanged(); }
65
67
69 QVariant data(const QModelIndex & index,
70 int role) const Q_DECL_OVERRIDE;
71
73
74 bool setData(const QModelIndex & index, const QVariant & value, int role);
75
77
79 QVariant headerData(int section,
80 Qt::Orientation orientation,
81 int role) const Q_DECL_OVERRIDE;
82
83protected:
86
87};
88
89
90
91
92
93#endif
int getNumStates() const
Returns the number of states.
Definition: bceabstractgame.hpp:247
The base class for games of incomplete information.
Definition: bcegame.hpp:40
Table models for BCEViewer.
Definition: bcepriortablemodel.hpp:40
void emitLayoutChanged()
Emits layoutChanged signal.
Definition: bcepriortablemodel.hpp:63
Qt::ItemFlags flags(const QModelIndex &index) const
Returns flags.
Definition: bcepriortablemodel.hpp:52
BCEGame * game
Pointer to the associated game.
Definition: bcepriortablemodel.hpp:85
bool setData(const QModelIndex &index, const QVariant &value, int role)
Reimplements the setData method.
Definition: bcepriortablemodel.cpp:42
QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE
Returns formatted header data.
Definition: bcepriortablemodel.cpp:58
int columnCount(const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
Returns the number of column player actions.
Definition: bcepriortablemodel.hpp:59
int rowCount(const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
Returns the number of row player actions.
Definition: bcepriortablemodel.hpp:56
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE
Reimplements the data method.
Definition: bcepriortablemodel.cpp:25
BCEPriorTableModel(BCEGame *_game)
Constructor.
Definition: bcepriortablemodel.hpp:45