-
Notifications
You must be signed in to change notification settings - Fork 1
/
grouptimetablewidget.cpp
79 lines (68 loc) · 3.22 KB
/
grouptimetablewidget.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
#include "grouptimetablewidget.h"
#include "definitions.h"
#include <QDebug>
const int GroupTimeTableWidget::DAY_COUNT = 7;
GroupTimeTableWidget::GroupTimeTableWidget(TimeTable* timetable,QWidget *parent) :
timetable_( timetable),
QWidget(parent)
{
titleGroupBox_ = new QGroupBox(this);
groupNameLineEdit_ = new QLineEdit( titleGroupBox_);
saveButton_ = new QPushButton( QString::fromUtf8("Сохранить расписание группы"), titleGroupBox_);
clearButton_ = new QPushButton( QString::fromUtf8("Очистить"), titleGroupBox_);
manageLayout_ = new QHBoxLayout(titleGroupBox_);
manageLayout_->addWidget( groupNameLineEdit_);
manageLayout_->addWidget( saveButton_);
manageLayout_->addWidget( clearButton_);
mainLayout_ = new QGridLayout(this);
mainLayout_->addWidget( titleGroupBox_, 0,0);
for( int i = 1; i <= DAY_COUNT; i++)
{
DayTimeTableWidget* dayWidget = new DayTimeTableWidget( i-1, this);
timetableList_.push_back( dayWidget);
mainLayout_->addWidget( dayWidget, i, 0);
}
setLayout( mainLayout_);
setAutoFillBackground(true);
connect( saveButton_, SIGNAL(clicked()), this, SLOT(saveTask()));
connect( clearButton_, SIGNAL(clicked()), this, SLOT(clearAll()));
}
void GroupTimeTableWidget::saveTask()
{
for( TimetableList::iterator it = timetableList_.begin(); it != timetableList_.end(); ++it)
{
DayTimeTableWidget::ValueList* list = (*it)->saveTask();
for( DayTimeTableWidget::ValueList::iterator iter = list->begin(); iter != list->end(); ++iter)
{
int weekCount = (*(*iter))[WEEK_KEY].toInt();
int eventTimeNumber = (*(*iter))[EVENT_TIME_KEY].toInt();
QString eventName = (*(*iter))[EVENT_NAME_KEY];
int eventType = (*(*iter))[EVENT_TYPE_KEY].toInt();
QString location = (*(*iter))[EVENT_LOCATION_KEY];
QString name = (*(*iter))[NAME_KEY];
QString lastName = (*(*iter))[LAST_NAME_KEY];
QString sureName = (*(*iter))[SURE_NAME_KEY];
qDebug() << "NAME: " << name << lastName << sureName;
// if( !groupNameLineEdit->text().isEmpty() && !eventNameLineEdit->text().isEmpty() &&
// !eventLocationLineEdit->text().isEmpty() && !teacherNameLineEdit->text().isEmpty() && !teacherLastNameLineEdit->text().isEmpty() &&
// !teacherSureNameLineEdit->text().isEmpty())
// {
// если обе недели выбраны
timetable_->addEvent( groupNameLineEdit_->text(), weekCount, eventTimeNumber, eventName, eventType, location, (*it)->getDayNumber(), name, lastName, sureName);
// }
// else
// {
// QMessageBox::warning( this, QString::fromUtf8("Ошибка записи"), QString::fromUtf8("Заполни все поля, Трекин)"));
// }
}
}
clearAll();
}
void GroupTimeTableWidget::clearAll()
{
groupNameLineEdit_->clear();
for( TimetableList::iterator it = timetableList_.begin(); it != timetableList_.end(); ++it)
{
(*it)->clear();
}
}