Beispiel #1
0
YearsForm::YearsForm(QWidget* parent): QDialog(parent)
{
	setupUi(this);
	
	detailsTextEdit->setReadOnly(true);
	
	modifyYearPushButton->setDefault(true);

	yearsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

	connect(addYearPushButton, SIGNAL(clicked()), this, SLOT(addYear()));
	connect(closePushButton, SIGNAL(clicked()), this, SLOT(close()));
	connect(removeYearPushButton, SIGNAL(clicked()), this, SLOT(removeYear()));
	connect(yearsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(yearChanged()));
	connect(modifyYearPushButton, SIGNAL(clicked()), this, SLOT(modifyYear()));
	connect(sortYearsPushButton, SIGNAL(clicked()), this, SLOT(sortYears()));
	connect(activateStudentsPushButton, SIGNAL(clicked()), this, SLOT(activateStudents()));
	connect(deactivateStudentsPushButton, SIGNAL(clicked()), this, SLOT(deactivateStudents()));
	connect(divisionsPushButton, SIGNAL(clicked()), this, SLOT(divideYear()));
	connect(yearsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(modifyYear()));

	centerWidgetOnScreen(this);
	restoreFETDialogGeometry(this);
	//restore splitter state
	QSettings settings(COMPANY, PROGRAM);
	if(settings.contains(this->metaObject()->className()+QString("/splitter-state")))
		splitter->restoreState(settings.value(this->metaObject()->className()+QString("/splitter-state")).toByteArray());
	
	yearsListWidget->clear();
	for(int i=0; i<gt.rules.yearsList.size(); i++){
		StudentsYear* year=gt.rules.yearsList[i];
		yearsListWidget->addItem(year->name);
	}
	
	if(yearsListWidget->count()>0)
		yearsListWidget->setCurrentRow(0);
}
Beispiel #2
0
regionEditDialog::regionEditDialog(Link *lk, mainWindow *win)
{
	QLabel *label;

	window = win;
	link = lk;
	upload = 0;

	QHBoxLayout *mainLayout = new QHBoxLayout;
	QVBoxLayout *regionLayout = new QVBoxLayout;
	QVBoxLayout *yearLayout = new QVBoxLayout;
	QVBoxLayout *statsLayout = new QVBoxLayout;
	QVBoxLayout *calendarLayout = new QVBoxLayout;

	label = new QLabel(tr("Select Region"));
	regionLayout->addWidget(label);
	regionLayout->addWidget(&regionSelector);
	regionSelector.setSizeAdjustPolicy(QComboBox::AdjustToContents);

	label = new QLabel(tr("New Region"));
	regionLayout->addWidget(label);
	regionLayout->addWidget(&regionEntry);

	addRegionButton.setText(tr("Add"));
	regionLayout->addWidget(&addRegionButton);
	connect(&addRegionButton, SIGNAL(clicked()), this, SLOT(addRegion()));

	regionLayout->addStretch();

	QPushButton *exitButton = new QPushButton;
	exitButton->setText(tr("Done"));
	regionLayout->addWidget(exitButton, Qt::AlignRight);
	connect(exitButton, SIGNAL(clicked()), this, SLOT(cancel()));

	label = new QLabel(tr("Select Year"));
	yearLayout->addWidget(label);
	yearLayout->addWidget(&yearSelector);

	label = new QLabel(tr("New Year"));
	yearLayout->addWidget(label);
	yearLayout->addWidget(&yearEntry);

	addYearButton.setText(tr("Add"));
	yearLayout->addWidget(&addYearButton);
	connect(&addYearButton, SIGNAL(clicked()), this, SLOT(addYear()));

	yearLayout->addStretch();

	label = new QLabel(tr("Statutory days"));
	statsLayout->addWidget(label);
	regionSelector.setSizeAdjustPolicy(QComboBox::AdjustToContents);
	statsLayout->addWidget(&stats);

	QPushButton *removeButton = new QPushButton;
	removeButton->setText(tr("Remove"));
	statsLayout->addWidget(removeButton);
	connect(removeButton, SIGNAL(clicked()), this, SLOT(remove()));

	calendarLayout->addWidget(&calendar);

	QPushButton *addButton = new QPushButton;
	addButton->setText(tr("Add"));
	calendarLayout->addWidget(addButton);
	connect(addButton, SIGNAL(clicked()), this, SLOT(add()));

	QFrame* line = new QFrame();
	line->setFrameShape(QFrame::VLine);
	line->setFrameShadow(QFrame::Sunken);

	mainLayout->addLayout(regionLayout);
	mainLayout->addWidget(line);
	mainLayout->addLayout(yearLayout);
	mainLayout->addLayout(statsLayout);
	mainLayout->addLayout(calendarLayout);
	setLayout(mainLayout);

	// Error Message Box setup
	msgbox.setIcon(QMessageBox::Critical);
	msgbox.setStandardButtons(QMessageBox::Ok);
}
TEST(dateTest, Date){
	//validation based on http://www.timeanddate.com/date/weekday.html	
	Date birthday;
	birthday.day = 7;
	birthday.month = 11;
	birthday.year = 1984;
	
	Date dday;
	dday.day = 6;
	dday.month = 6;
	dday.year = 1944;
	
	Date apolloEleven;
	apolloEleven.day = 20;
	apolloEleven.month = 7;
	apolloEleven.year = 1969;
	
	// begin addDay check	
	addDay(birthday);
	CHECK(birthday.day == 8 && birthday.month == 11 && birthday.year == 1984);
	CHECK(getDayOfWeek(dow(birthday)) == "Thursday");
	
	addDay(dday);
	CHECK(dday.day == 7 && dday.month == 6 && dday.year == 1944);
	CHECK(getDayOfWeek(dow(dday)) == "Wednesday");
	
	addDay(apolloEleven);
	CHECK(apolloEleven.day == 21 && apolloEleven.month == 7 && apolloEleven.year == 1969);
	CHECK(getDayOfWeek(dow(apolloEleven)) == "Monday");	
	// end addDay check
	
	// begin addMonth check
	addMonth(birthday);
	CHECK(birthday.day == 8 && birthday.month == 12 && birthday.year == 1984);
	CHECK(getDayOfWeek(dow(birthday)) == "Saturday");
	
	addMonth(dday);
	CHECK(dday.day == 7 && dday.month == 7 && dday.year == 1944);
	CHECK(getDayOfWeek(dow(dday)) == "Friday");
	
	addMonth(apolloEleven);
	CHECK(apolloEleven.day == 20 && apolloEleven.month == 8 && apolloEleven.year == 1969);
	CHECK(getDayOfWeek(dow(apolloEleven)) == "Wednesday");
	// end addMonth check
	
	// begin addYear check
	addYear(birthday);
	CHECK(birthday.day == 8 && birthday.month == 12 && birthday.year == 1985);
	CHECK(getDayOfWeek(dow(birthday)) == "Sunday");
	
	addYear(dday);
	CHECK(dday.day == 7 && dday.month == 7 && dday.year == 1945);
	CHECK(getDayOfWeek(dow(dday)) == "Saturday");
	
	addYear(apolloEleven);
	CHECK(apolloEleven.day == 20 && apolloEleven.month == 8 && apolloEleven.year == 1970);
	CHECK(getDayOfWeek(dow(apolloEleven)) == "Thursday");
	// end addYear check

	// begin getNextMonday check
	Date nmBirthday = getNextMonday(birthday);
	CHECK(nmBirthday.day == 9 && nmBirthday.month == 12 && nmBirthday.year == 1985);
	CHECK(getDayOfWeek(dow(nmBirthday)) == "Monday");
	
	Date nmDDay = getNextMonday(dday);
	CHECK(nmDDay.day == 9 && nmDDay.month == 7 && nmDDay.year == 1945);
	CHECK(getDayOfWeek(dow(nmDDay)) == "Monday");
	
	Date nmApolloEleven = getNextMonday(apolloEleven);
	CHECK(nmApolloEleven.day == 24 && nmApolloEleven.month == 8 && nmApolloEleven.year == 1970);
	CHECK(getDayOfWeek(dow(nmApolloEleven)) == "Monday");
	// end getNextMonday check
}