Remove whitespace
[agianapa.git] / qt / leleja / leleja.cpp
blob96065f649cd5b814a0f9a203e991f06a4d8e0008
1 // akis.vasilias@vasilias-lights.gr
2 #include <QtGui>
3 #include <iostream>
4 #include "leleja.h"
5 #include "myreportdialog.h"
7 Leleja::Leleja(QWidget *parent)
8 : QDialog(parent)
10 std::cout << "Leleja::Leleja()\n";
12 setupUi(this);
14 // Create the report dialog, although
15 // we keep it hidden for the time being.
16 myreportdialog = new MyReportDialog(this);
17 myreportdialog->setGeometry(200, 200, 200, 200);
18 myreportdialog->setWindowTitle(tr("Report"));
20 // Set current date
21 dayinDateEdit->setDate(QDate::currentDate());
22 leleDateEdit->setDate(QDate::currentDate());
24 // Connect signals to slots
25 connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));
28 Leleja::~Leleja()
30 std::cout << "Leleja::~Leleja()\n";
32 delete myreportdialog;
35 void Leleja::on_calcButton_clicked()
37 QDate leleDate;
38 QDate dayinDate;
39 int daysLeft;
40 int daysOff;
41 int totalDays;
43 std::cout << "on_calcButton_clicked()\n";
45 // Get dates
46 dayinDate = dayinDateEdit->date();
47 leleDate = leleDateEdit->date();
49 // Calculate days
50 daysOff = daysoffLineEdit->text().toInt();
51 totalDays = dayinDate.daysTo(leleDate);
52 daysLeft = QDate::currentDate().daysTo(leleDate) - daysOff;
54 // Debug prints
55 std::cout << "Leleja::totalDays = " << totalDays << std::endl;
56 std::cout << "Lelela::daysLeft = " << daysLeft << std::endl;
57 std::cout << "Leleja::daysOff = " << daysOff << std::endl;
59 // Validate user input
60 if (dayinDate > QDate::currentDate()) {
61 QMessageBox::warning(this, tr("Leleja reloaded"),
62 tr("You haven't joined the army yet!\n"),
63 QMessageBox::Ok);
64 return;
67 if (daysLeft < 0) {
68 QMessageBox::warning(this, tr("Leleja reloaded"),
69 tr("You are a citizen!\n"),
70 QMessageBox::Ok);
71 return;
74 // Pass parameters to report dialog
75 myreportdialog->setDaysLeft(daysLeft);
76 myreportdialog->setDaysOff(daysOff);
77 myreportdialog->setDaysTotal(totalDays);
79 // Show report dialog
80 if (!myreportdialog->isVisible())
81 myreportdialog->show();
82 else {
83 emit myreportdialog->redrawContent();
84 myreportdialog->repaint();