-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWonderTable.hpp
75 lines (57 loc) · 1.99 KB
/
WonderTable.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef WONDERTABLE_HPP
#define WONDERTABLE_HPP
#include <QTableWidget>
#include "BoardModel.hpp"
#include "WonderDescription.hpp"
#include "IntegerTableItem.hpp"
class SelectionTableItem : public QTableWidgetItem
{
int selected;
int total;
public:
SelectionTableItem(int selected, int total)
: QTableWidgetItem(QString("%1/%2").arg(selected).arg(total))
{}
void setSelectedCount(int selected)
{
this->selected = selected;
this->setText(QString("%1/%2").arg(selected).arg(total));
}
bool operator<(const SelectionTableItem &other) const
{
return this->selected < other.selected;
}
};
class WonderTable : public QTableWidget
{
Q_OBJECT
signals:
void closeTable();
void wonderSelectionChanged(WonderModel::Wonder wonder, int wonderSelection);
private:
BoardModel *boardModel;
QMap<WonderModel::Wonder, int> wonders;
QMap<WonderModel::Wonder, int> wonderSelection;
WonderDescription::WonderDescriptionType wonderDescriptionType;
QMap<WonderModel::Wonder, QTableWidgetItem *> wonderTableNameItems;
QMap<WonderModel::Wonder, QTableWidgetItem *> wonderTableCountItems;
QMap<WonderModel::Wonder, WonderDescription *> wonderDescriptions;
int selectionTotal;
public:
WonderTable(BoardModel *boardModel,
QMap<WonderModel::Wonder, int> wonders,
WonderDescription::WonderDescriptionType wonderDescriptionType = WonderDescription::OVERVIEW,
QWidget *parent = 0);
void setCompactColumns();
void setFullColumns();
QMap<WonderModel::Wonder, int> getWonders() const;
QMap<WonderModel::Wonder, int> getSelectedWonders() const;
int getSelectionTotal() const;
void setSelectionTotal(int selectionTotal);
virtual void update();
private slots:
void wonderSelectionCountChanged(WonderModel::Wonder wonder, int wonderSelection);
void selectWonder();
void triggerWonderBuilt(WonderModel::Wonder wonder);
};
#endif // WONDERTABLE_HPP