-
Notifications
You must be signed in to change notification settings - Fork 0
/
yellowcot.cpp
executable file
·127 lines (109 loc) · 5.17 KB
/
yellowcot.cpp
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
/*
Yellowcot 1.2.6, released 2013-03-23
Copyleft 2013 Anthony Karam Karam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "yellowcot.h"
YCQuiz::YCQuiz(QWidget *parent) : QWidget(parent) {
//create widgets
fileIsLoaded = new QCheckBox();
tabBar = new QTabBar;
tabBar->addTab(tr("Quiz"));
tabBar->addTab(tr("Edit"));
questionsAndAnswersList = new QComboBox();
currQorA = new QPushButton();
currQorA->setLayout(new QHBoxLayout());
currQorA->setMinimumWidth(MINWIDTH);
currQorA->setMinimumHeight(MINHEIGHT);
currQorA->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
rangeLbl = new QLabel(tr("Range:"));
startBox = new QSpinBox();
toLbl = new QLabel(tr("to"));
toLbl->setAlignment(Qt::AlignCenter);
endBox = new QSpinBox();
reversedLbl = new QLabel(tr("Reversed Mode:"));
reversedCheckBox = new QCheckBox(tr("Swap Questions and Answers"));
editTable = new QTableWidget(this);
editTable->setRowCount(0);
editTable->setColumnCount(6);
editTable->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
editTable->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
QTableWidgetItem *header0 = new QTableWidgetItem(tr("Question"));
editTable->setHorizontalHeaderItem(0, header0);
QTableWidgetItem *header1 = new QTableWidgetItem(tr("Question Source"));
editTable->setHorizontalHeaderItem(1, header1);
QTableWidgetItem *header2 = new QTableWidgetItem(tr("Question Licence"));
editTable->setHorizontalHeaderItem(2, header2);
QTableWidgetItem *header3 = new QTableWidgetItem(tr("Answer"));
editTable->setHorizontalHeaderItem(3, header3);
QTableWidgetItem *header4 = new QTableWidgetItem(tr("Answer Source"));
editTable->setHorizontalHeaderItem(4, header4);
QTableWidgetItem *header5 = new QTableWidgetItem(tr("Answer Licence"));
editTable->setHorizontalHeaderItem(5, header5);
editTable->resizeColumnsToContents();
editTable->resizeRowsToContents();
insertRow = new QPushButton(tr("Insert Row"));
removeRow = new QPushButton(tr("Remove Row"));
moveRowUp = new QPushButton(tr("Move Row Up"));
moveRowDown = new QPushButton(tr("Move Row Down"));
insertImage = new QPushButton(tr("Insert Image"));
insertText = new QPushButton(tr("Insert Text"));
questionMediaSources = new QComboBox();
answerMediaSources = new QComboBox();
showLicencingData = new QCheckBox(tr("Show Licencing Data"));
//hide licencing columns
editTable->setColumnHidden(1, true);
editTable->setColumnHidden(2, true);
editTable->setColumnHidden(4, true);
editTable->setColumnHidden(5, true);
//respond appropriately if the showLicencingData checkbox is checked/unchecked
connect(showLicencingData, SIGNAL(stateChanged(int)), this, SLOT(toggleLicencing()));
//give the tab bar control over which widgets are visible at any given time
connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(updateVisibleWidgets()));
updateVisibleWidgets();
//respond appropriately if either the start field or end field is changed
connect(startBox, SIGNAL(valueChanged(int)), this, SLOT(respondToStartChange()));
connect(endBox, SIGNAL(valueChanged(int)), this, SLOT(respondToEndChange()));
//advance the current question/answer when it is clicked
connect(currQorA, SIGNAL(clicked()), this, SLOT(advanceQorA()));
//insert, remove, or move a row depending on which button is clicked
connect(insertRow, SIGNAL(clicked()), this, SLOT(insertARow()));
connect(removeRow, SIGNAL(clicked()), this, SLOT(removeARow()));
connect(moveRowUp, SIGNAL(clicked()), this, SLOT(moveTheRowUp()));
connect(moveRowDown, SIGNAL(clicked()), this, SLOT(moveTheRowDown()));
//insert an image if the button is clicked
connect(insertImage, SIGNAL(clicked()), this, SLOT(insertAnImage()));
//insert a text if the button is clicked
connect(insertText, SIGNAL(clicked()), this, SLOT(insertAText()));
//organise widgets on a layout
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(tabBar, 0, 0, 1, 4);
mainLayout->addWidget(currQorA, 1, 0, 1, 4);
mainLayout->addWidget(rangeLbl, 2, 0);
mainLayout->addWidget(startBox, 2, 1);
mainLayout->addWidget(toLbl, 2, 2);
mainLayout->addWidget(endBox, 2, 3);
mainLayout->addWidget(reversedLbl, 3, 0);
mainLayout->addWidget(reversedCheckBox, 3, 1, 1, 3);
mainLayout->addWidget(showLicencingData, 4, 0, 1, 4);
mainLayout->addWidget(editTable, 5, 0, 1, 4);
mainLayout->addWidget(insertRow, 6, 0, 1, 2);
mainLayout->addWidget(removeRow, 6, 2, 1, 2);
mainLayout->addWidget(moveRowUp, 7, 0, 1, 2);
mainLayout->addWidget(moveRowDown, 7, 2, 1, 2);
mainLayout->addWidget(insertImage, 8, 0, 1, 2);
mainLayout->addWidget(insertText, 8, 2, 1, 2);
//use the layout
setLayout(mainLayout);
//clear everything
clearEverything();
}