NFC support
[badge] / badgewindow.cpp
1 #include "badgewindow.h"
2 #include "ui_badgewindow.h"
3
4 #include "dialogday.h"
5 #include <QDebug>
6 #include "badgedata.h"
7 #include "dialogsearch.h"
8 #include <QMessageBox>
9 #include <QtMaemo5/QMaemo5InformationBox>
10
11 BadgeWindow::BadgeWindow(QWidget *parent)
12     : QMainWindow(parent), ui(new Ui::BadgeWindow)
13 {
14     ui->setupUi(this);
15     setAttribute(Qt::WA_Maemo5StackedWindow);
16     ui->menuBar->addAction(ui->actionSearch);
17     ui->menuBar->addAction(ui->actionInfo);
18 #ifndef Q_WS_MAEMO_5
19     ui->menuBar->addAction(ui->actionClose);
20 #endif
21     connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
22     connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()));
23     connect(ui->actionInfo, SIGNAL(triggered()), this, SLOT(info()));
24
25
26     showMaximized();
27 }
28
29
30
31 void BadgeWindow::selectedDay(QDate date)
32 {
33     DialogDay day;
34     BadgeData data;
35
36     TimeTable tt;
37     tt.day = date;
38     if (data.getTimetable(tt) == false) {
39         tt.entrance = QTime::currentTime();
40         tt.exit = QTime::currentTime();
41         tt.firstPause = QTime::currentTime();
42         tt.endFirstPause = QTime::currentTime();
43         tt.secondPause = QTime::currentTime();
44         tt.endSecondPause = QTime::currentTime();
45     }
46
47     tt = day.getTimes(tt);
48     if (tt.wrong() != TimeTable::WRONG) {
49         BadgeData data;
50         data.setTimetable(tt);
51     }
52
53 }
54
55 void BadgeWindow::search()
56 {
57     DialogSearch searchDialog;
58     int total;
59     QString message;
60     QString hours;
61     QString minutes;
62     bool ok;
63
64     total = searchDialog.totalHours(ok);
65     if (ok) {
66             qDebug() << "TIME " << total;
67         hours.setNum((int)(total / 3600));
68         minutes.setNum((int) ((total % 3600) / 60));
69         message = "Total time is: " + hours + " hours and " + minutes + " minutes";
70         QMessageBox::information(this, tr("Badge"), tr(message.toLatin1()));
71     }
72
73 }
74
75 void BadgeWindow::info()
76 {
77     QMessageBox::aboutQt(this);
78     QMaemo5InformationBox::information(this, tr("(c) 2009 Nicola De Filippo - nicola@nicoladefilippo.it\n"
79                          "This program is licensed to you under terms of the GNU General Public\n"
80                         "License Version 2 as published by Free Software Foundation. This gives\n"
81                         "you legal permission to copy, distribute and/or modify this software under\n"
82                         "certain conditions. For details, see the file 'COPYING' that came with this\n"
83                         "software distribution. If you did not get the file, send email to author.\n\n"
84                         "The program is provided AS IS with No WARRANTY OF ANY KIND,\n"
85                         "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND\n"
86                         "FITNESS FOR PARTICULAR PURPOSE"));
87 }
88
89 BadgeWindow::~BadgeWindow()
90 {
91     delete ui;
92 }