fix search result
[badge] / badgewindow.cpp
index a030ede..77f346d 100644 (file)
@@ -6,14 +6,18 @@
 #include "badgedata.h"
 #include "dialogsearch.h"
 #include <QMessageBox>
+#include <QtMaemo5/QMaemo5InformationBox>
 
 BadgeWindow::BadgeWindow(QWidget *parent)
     : QMainWindow(parent), ui(new Ui::BadgeWindow)
 {
     ui->setupUi(this);
+    setAttribute(Qt::WA_Maemo5StackedWindow);
     ui->menuBar->addAction(ui->actionSearch);
     ui->menuBar->addAction(ui->actionInfo);
+#ifndef Q_WS_MAEMO_5
     ui->menuBar->addAction(ui->actionClose);
+#endif
     connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
     connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()));
     connect(ui->actionInfo, SIGNAL(triggered()), this, SLOT(info()));
@@ -31,7 +35,15 @@ void BadgeWindow::selectedDay(QDate date)
 
     TimeTable tt;
     tt.day = date;
-    data.getTimetable(tt);
+    if (data.getTimetable(tt) == false) {
+        tt.entrance = QTime::currentTime();
+        tt.exit = QTime::currentTime();
+        tt.firstPause = QTime::currentTime();
+        tt.endFirstPause = QTime::currentTime();
+        tt.secondPause = QTime::currentTime();
+        tt.endSecondPause = QTime::currentTime();
+    }
+
     tt = day.getTimes(tt);
     if (tt.wrong() != TimeTable::WRONG) {
         BadgeData data;
@@ -43,7 +55,7 @@ void BadgeWindow::selectedDay(QDate date)
 void BadgeWindow::search()
 {
     DialogSearch searchDialog;
-    QTime total;
+    int total;
     QString message;
     QString hours;
     QString minutes;
@@ -51,8 +63,9 @@ void BadgeWindow::search()
 
     total = searchDialog.totalHours(ok);
     if (ok) {
-        hours.setNum(total.hour());
-        minutes.setNum(total.minute());
+            qDebug() << "TIME " << total;
+        hours.setNum((int)(total / 3600));
+        minutes.setNum((int) ((total % 3600) / 60));
         message = "Total time is: " + hours + " hours and " + minutes + " minutes";
         QMessageBox::information(this, tr("Badge"), tr(message.toLatin1()));
     }
@@ -62,7 +75,7 @@ void BadgeWindow::search()
 void BadgeWindow::info()
 {
     QMessageBox::aboutQt(this);
-    QMessageBox::about(this, tr("Badge"), tr("(c) 2009 Nicola De Filippo - nicola@nicoladefilippo.it\n"
+    QMaemo5InformationBox::information(this, tr("(c) 2009 Nicola De Filippo - nicola@nicoladefilippo.it\n"
                          "This program is licensed to you under terms of the GNU General Public\n"
                         "License Version 2 as published by Free Software Foundation. This gives\n"
                         "you legal permission to copy, distribute and/or modify this software under\n"