-
Notifications
You must be signed in to change notification settings - Fork 0
/
timetable.cpp
88 lines (71 loc) · 2.79 KB
/
timetable.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
#include "timetable.h"
#include "row.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QDebug>
#include <QVariant>
#include <QString>
#include <QMenuBar>
TimeTable::TimeTable(QWidget *parent,QString weekIsUpper) :
QScrollArea(parent)
{
inScroll = new QWidget(this);
inScroll->setLayout(new QVBoxLayout);
for (int i = 0; i < 7; i++)
dayLabel[i].setObjectName("day");
createTable(weekIsUpper);
setWidgetResizable(true);
//setBackgroundRole(QPalette::Dark);
setWidget(inScroll);
setContentsMargins(0,0,0,0);
connect(this,SIGNAL(closed()),parent,SLOT(close()));
}
void TimeTable::createTable(QString week)
{
QSqlQuery query;
QString queryStr1("select W.start_h, W.start_m, W.end_h, W.end_m, "
"S.subject, S.professor, S.type, W.location, W.id "
"from weeks W, subjects S where (weekday = ");
QString queryStr2(") AND (W.subject_id = S.id)"
"order by W.start_h, W.start_m");
dayLabel[0].setText("Monday");
inScroll->layout()->addWidget(&dayLabel[0]);
query.exec(queryStr1 + "0"+") AND (W.is_week_upper = "+week + queryStr2);
while (query.next())
inScroll->layout()->addWidget(new Row(query,0,this));
dayLabel[1].setText("Thuesday");
inScroll->layout()->addWidget(&dayLabel[1]);
query.exec(queryStr1 + "1"+") AND (W.is_week_upper = "+week + queryStr2);
while (query.next())
inScroll->layout()->addWidget(new Row(query,1,this));
dayLabel[2].setText("Wednesday");
inScroll->layout()->addWidget(&dayLabel[2]);
query.exec(queryStr1 + "2"+") AND (W.is_week_upper = "+week + queryStr2);
while (query.next())
inScroll->layout()->addWidget(new Row(query,2,this));
dayLabel[3].setText("Thursday");
inScroll->layout()->addWidget(&dayLabel[3]);
query.exec(queryStr1 + "3"+") AND (W.is_week_upper = "+week + queryStr2);
while (query.next())
inScroll->layout()->addWidget(new Row(query,3,this));
dayLabel[4].setText("Friday");
inScroll->layout()->addWidget(&dayLabel[4]);
query.exec(queryStr1 + "4" +") AND (W.is_week_upper = "+week+ queryStr2);
while (query.next())
inScroll->layout()->addWidget(new Row(query,4,this));
dayLabel[5].setText("Saturday");
inScroll->layout()->addWidget(&dayLabel[5]);
query.exec(queryStr1 + "5" +") AND (W.is_week_upper = "+week+ queryStr2);
while (query.next())
inScroll->layout()->addWidget(new Row(query,5,this));
dayLabel[6].setText("Sunday");
inScroll->layout()->addWidget(&dayLabel[6]);
query.exec(queryStr1 + "6" +") AND (W.is_week_upper = "+week+ queryStr2);
while (query.next())
inScroll->layout()->addWidget(new Row(query,6,this));
}
void TimeTable::closeEvent(QCloseEvent *e)
{
emit closed();
}