-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor_comp_structs.cpp
More file actions
288 lines (219 loc) · 11.1 KB
/
editor_comp_structs.cpp
File metadata and controls
288 lines (219 loc) · 11.1 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#include "editor_comp_structs.h"
/* =========================== */
/* Class Constructor */
/* =========================== */
// Default constructor
EditorCompStructs::EditorCompStructs(QWidget &parent) : parent_(&parent)
{
// Dual column layout
layoutMain_ = new QHBoxLayout;
layoutRight_ = new QVBoxLayout;
// List Widget
listComps_ = new QListWidget;
listComps_->setMinimumWidth(MIN_LIST_WIDGET_WIDTH);
listComps_->setMaximumWidth(MIN_LIST_WIDGET_WIDTH);
// Right column heading
QFont font;
font.setBold(true);
font.setPointSize(16);
// League heading / short name
lblShortName_ = new QLabel("");
lblShortName_->setFont(font);
lblShortName_->setMaximumHeight(25);
layoutRight_->addWidget(lblShortName_);
// League/structure details
frmDetails_ = new QFormLayout;
QLabel *lblLongName = new QLabel("Long Name:");
lblLongName_ = new QLabel();
frmDetails_->addRow(lblLongName, lblLongName_);
QLabel *lblOffsetA = new QLabel("Offset A:");
lblOffsetA_ = new QLabel();
frmDetails_->addRow(lblOffsetA, lblOffsetA_);
QLabel *lblOffsetB = new QLabel("Offset B:");
lblOffsetB_ = new QLabel();
frmDetails_->addRow(lblOffsetB, lblOffsetB_);
grpDetails_ = new QGroupBox("Details");
grpDetails_->setLayout(frmDetails_);
layoutRight_->addWidget(grpDetails_);
// League size
frmLeagueSize_ = new QFormLayout;
QLabel *lblLeagueSizePos = new QLabel("Offset:");
lblLeagueSizePos_ = new QLabel();
frmLeagueSize_->addRow(lblLeagueSizePos, lblLeagueSizePos_);
QLabel *lblLeagueSizeRelativePos = new QLabel("Relative position:");
lblLeagueSizeRelativePos_ = new QLabel();
frmLeagueSize_->addRow(lblLeagueSizeRelativePos, lblLeagueSizeRelativePos_);
QLabel *lblLeagueSizeHex = new QLabel("Current setting:");
lblLeagueSizeHex_ = new QLabel();
frmLeagueSize_->addRow(lblLeagueSizeHex, lblLeagueSizeHex_);
QLabel *lblLeagueSizeComboBox = new QLabel("Edit setting:");
comboLeagueSize_ = new QComboBox();
frmLeagueSize_->addRow(lblLeagueSizeComboBox, comboLeagueSize_);
grpLeagueSize_ = new QGroupBox("League Size");
grpLeagueSize_->setLayout(frmLeagueSize_);
layoutRight_->addWidget(grpLeagueSize_);
// Playoffs
frmPlayoffs_ = new QFormLayout;
QLabel *lblPlayoffsPos = new QLabel("Offset:");
lblPlayoffsPos_ = new QLabel();
frmPlayoffs_->addRow(lblPlayoffsPos, lblPlayoffsPos_);
QLabel *lblPlayoffsRelativePos = new QLabel("Relative position:");
lblPlayoffsRelativePos_ = new QLabel();
frmPlayoffs_->addRow(lblPlayoffsRelativePos, lblPlayoffsRelativePos_);
QLabel *lblPlayoffsHex = new QLabel("Current setting:");
lblPlayoffsHex_ = new QLabel();
frmPlayoffs_->addRow(lblPlayoffsHex, lblPlayoffsHex_);
QLabel *lblPlayoffsComboBox = new QLabel("Edit setting:");
comboPlayoffs_ = new QComboBox();
frmPlayoffs_->addRow(lblPlayoffsComboBox, comboPlayoffs_);
grpPlayoffs_ = new QGroupBox("Playoffs");
grpPlayoffs_->setLayout(frmPlayoffs_);
layoutRight_->addWidget(grpPlayoffs_);
// Schedule
frmSchedule_ = new QFormLayout;
QLabel *lblSchedulePos = new QLabel("Offset:");
lblSchedulePos_ = new QLabel();
frmSchedule_->addRow(lblSchedulePos, lblSchedulePos_);
QLabel *lblScheduleRelativePos = new QLabel("Relative position:");
lblScheduleRelativePos_ = new QLabel();
frmSchedule_->addRow(lblScheduleRelativePos, lblScheduleRelativePos_);
QLabel *lblScheduleHex = new QLabel("Current setting:");
lblScheduleHex_ = new QLabel();
frmSchedule_->addRow(lblScheduleHex, lblScheduleHex_);
QLabel *lblScheduleComboBox = new QLabel("Edit setting:");
comboSchedule_ = new QComboBox();
frmSchedule_->addRow(lblScheduleComboBox, comboSchedule_);
grpSchedule_ = new QGroupBox("Schedule / Playoff Structure");
grpSchedule_->setLayout(frmSchedule_);
layoutRight_->addWidget(grpSchedule_);
// Structure
frmStructure_ = new QFormLayout;
QLabel *lblStructurePos = new QLabel("Offset:");
lblStructurePos_ = new QLabel();
frmStructure_->addRow(lblStructurePos, lblStructurePos_);
QLabel *lblStructureRelativePos = new QLabel("Relative position:");
lblStructureRelativePos_ = new QLabel();
frmStructure_->addRow(lblStructureRelativePos, lblStructureRelativePos_);
QLabel *lblStructureHex = new QLabel("Current setting:");
lblStructureHex_ = new QLabel();
frmStructure_->addRow(lblStructureHex, lblStructureHex_);
QLabel *lblStructureComboBox = new QLabel("Edit setting:");
comboStructure_ = new QComboBox();
frmStructure_->addRow(lblStructureComboBox, comboStructure_);
grpStructure_ = new QGroupBox("League Structure / Playoff Structure / OT Rule");
grpStructure_->setLayout(frmStructure_);
layoutRight_->addWidget(grpStructure_);
QSpacerItem *spacer = new QSpacerItem(40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
layoutRight_->addItem(spacer);
// Set layout
layoutMain_->addWidget(listComps_); // List widget -> main layout
layoutMain_->addLayout(layoutRight_); // Right column -> main layout
parent_->setLayout(layoutMain_); // Main layout -> tab widget
QObject::connect(listComps_, SIGNAL(currentRowChanged(int)), this, SLOT(on_listComps_currentRowChanged(int))); // List widget
}
/* ============================= */
/* Data Initialisation */
/* ============================= */
// Initialise data
void EditorCompStructs::init()
{
listComps_->clear();
// List widget containing competitions
for(auto itr = CompStructs::vect_.begin(); itr < CompStructs::vect_.end(); ++itr)
listComps_->addItem(new QListWidgetItem(itr->getShortName()));
// Combo box of league sizes
for(auto itr = CompStructs::preLeagueSize_.begin(); itr < CompStructs::preLeagueSize_.end(); ++itr)
comboLeagueSize_->addItem(itr->getDescAndData());
// Combo box of playoffs
for(auto itr = CompStructs::prePlayoffs_.begin(); itr < CompStructs::prePlayoffs_.end(); ++itr)
comboPlayoffs_->addItem(itr->getDescAndData());
// Combo box of schedules
for(auto itr = CompStructs::preSchedule_.begin(); itr < CompStructs::preSchedule_.end(); ++itr)
comboSchedule_->addItem(itr->getDescAndData());
// Combo box of structures
for(auto itr = CompStructs::preStructure_.begin(); itr < CompStructs::preStructure_.end(); ++itr)
comboStructure_->addItem(itr->getDescAndData());
// Initialise the list widget with the first item/row (must be initialised before connecting the slots/signals)
listComps_->setCurrentRow(0);
// Combo boxes (must be connected after initialising the list widget - otherwise the first entry will be overwritten at start-up)
QObject::connect(comboLeagueSize_, SIGNAL(currentIndexChanged(int)), this, SLOT(on_comboLeagueSize_currentIndexChanged(int))); // League size
QObject::connect(comboPlayoffs_, SIGNAL(currentIndexChanged(int)), this, SLOT(on_comboPlayoffs_currentIndexChanged(int))); // Playoffs
QObject::connect(comboSchedule_, SIGNAL(currentIndexChanged(int)), this, SLOT(on_comboSchedule_currentIndexChanged(int))); // Schedule
QObject::connect(comboStructure_, SIGNAL(currentIndexChanged(int)), this, SLOT(on_comboStructure_currentIndexChanged(int))); // Structure
}
// Clear list widget
void EditorCompStructs::clear()
{
listComps_->clear();
}
/* ============================ */
/* List Box Functions */
/* ============================ */
// Populate form with details of selected competition
void EditorCompStructs::on_listComps_currentRowChanged(int currentRow)
{
currentRow_ = currentRow;
// Short name
lblShortName_->setText(CompStructs::vect_[currentRow_].getShortName());
//lblShortName_->setText(QString::number(CompStructs::vect_[currentRow_].getPlayoffsIndex()));
// Details
lblLongName_->setText(CompStructs::vect_[currentRow_].getLongName());
lblOffsetA_->setText(CompStructs::vect_[currentRow_].getOffsetA());
lblOffsetB_->setText(CompStructs::vect_[currentRow_].getOffsetB());
// League Size
lblLeagueSizePos_->setText(CompStructs::vect_[currentRow_].getLeagueSizePos());
lblLeagueSizeRelativePos_->setText(CompStructs::vect_[currentRow_].getLeagueSizeRelativePos());
lblLeagueSizeHex_->setText(CompStructs::vect_[currentRow_].getLeagueSizeString());
comboLeagueSize_->setCurrentIndex(CompStructs::vect_[currentRow_].getLeagueSizeIndex());
// Playoffs
lblPlayoffsPos_->setText(CompStructs::vect_[currentRow_].getPlayoffsPos());
lblPlayoffsRelativePos_->setText(CompStructs::vect_[currentRow_].getPlayoffsRelativePos());
lblPlayoffsHex_->setText(CompStructs::vect_[currentRow_].getPlayoffsString());
comboPlayoffs_->setCurrentIndex(CompStructs::vect_[currentRow_].getPlayoffsIndex());
// Schedule
lblSchedulePos_->setText(CompStructs::vect_[currentRow_].getSchedulePos());
lblScheduleRelativePos_->setText(CompStructs::vect_[currentRow_].getScheduleRelativePos());
lblScheduleHex_->setText(CompStructs::vect_[currentRow_].getScheduleString());
comboSchedule_->setCurrentIndex(CompStructs::vect_[currentRow_].getScheduleIndex());
// Structure
lblStructurePos_->setText(CompStructs::vect_[currentRow_].getStructurePos());
lblStructureRelativePos_->setText(CompStructs::vect_[currentRow_].getStructureRelativePos());
lblStructureHex_->setText(CompStructs::vect_[currentRow_].getStructureString());
comboStructure_->setCurrentIndex(CompStructs::vect_[currentRow_].getStructureIndex());
}
/* =============================== */
/* League Size Functions */
/* =============================== */
// Update the line up rule following a change of selection on the combo box
void EditorCompStructs::on_comboLeagueSize_currentIndexChanged(int currentIndex)
{
CompStructs::vect_[currentRow_].setLeagueSize(currentIndex);
lblLeagueSizeHex_->setText(CompStructs::vect_[currentRow_].getLeagueSizeString());
}
/* ============================ */
/* Playoffs Functions */
/* ============================ */
// Update the line up rule following a change of selection on the combo box
void EditorCompStructs::on_comboPlayoffs_currentIndexChanged(int currentIndex)
{
CompStructs::vect_[currentRow_].setPlayoffs(currentIndex);
lblPlayoffsHex_->setText(CompStructs::vect_[currentRow_].getPlayoffsString());
}
/* ============================ */
/* Schedule Functions */
/* ============================ */
// Update the line up rule following a change of selection on the combo box
void EditorCompStructs::on_comboSchedule_currentIndexChanged(int currentIndex)
{
CompStructs::vect_[currentRow_].setSchedule(currentIndex);
lblScheduleHex_->setText(CompStructs::vect_[currentRow_].getScheduleString());
}
/* ============================= */
/* Structure Functions */
/* ============================= */
// Update the line up rule following a change of selection on the combo box
void EditorCompStructs::on_comboStructure_currentIndexChanged(int currentIndex)
{
CompStructs::vect_[currentRow_].setStructure(currentIndex);
lblStructureHex_->setText(CompStructs::vect_[currentRow_].getStructureString());
}