desktop version
authornicola <nicola@nicola-x910.(none)>
Fri, 11 Dec 2009 11:03:33 +0000 (12:03 +0100)
committernicola <nicola@nicola-x910.(none)>
Fri, 11 Dec 2009 11:03:33 +0000 (12:03 +0100)
18 files changed:
desktop/badge.pro [new file with mode: 0644]
desktop/badgedata.cpp [new file with mode: 0644]
desktop/badgedata.h [new file with mode: 0644]
desktop/badgewindow.cpp [new file with mode: 0644]
desktop/badgewindow.h [new file with mode: 0644]
desktop/badgewindow.ui [new file with mode: 0644]
desktop/dialogcalendar.cpp [new file with mode: 0644]
desktop/dialogcalendar.h [new file with mode: 0644]
desktop/dialogcalendar.ui [new file with mode: 0644]
desktop/dialogday.cpp [new file with mode: 0644]
desktop/dialogday.h [new file with mode: 0644]
desktop/dialogday.ui [new file with mode: 0644]
desktop/dialogsearch.cpp [new file with mode: 0644]
desktop/dialogsearch.h [new file with mode: 0644]
desktop/dialogsearch.ui [new file with mode: 0644]
desktop/main.cpp [new file with mode: 0644]
desktop/timetable.cpp [new file with mode: 0644]
desktop/timetable.h [new file with mode: 0644]

diff --git a/desktop/badge.pro b/desktop/badge.pro
new file mode 100644 (file)
index 0000000..fd91c42
--- /dev/null
@@ -0,0 +1,25 @@
+# -------------------------------------------------
+# Project created by QtCreator 2009-11-24T13:07:09
+# -------------------------------------------------
+TARGET = badge
+TEMPLATE = app
+SOURCES += main.cpp \
+    badgewindow.cpp \
+    badgedata.cpp \
+    timetable.cpp \
+    dialogday.cpp \
+    dialogsearch.cpp \
+    dialogcalendar.cpp \
+    ../dialogtask.cpp
+HEADERS += badgewindow.h \
+    badgedata.h \
+    timetable.h \
+    dialogday.h \
+    dialogsearch.h \
+    dialogcalendar.h \
+    ../dialogtask.h
+FORMS += badgewindow.ui \
+    dialogday.ui \
+    dialogsearch.ui \
+    dialogcalendar.ui \
+    ../dialogtask.ui
diff --git a/desktop/badgedata.cpp b/desktop/badgedata.cpp
new file mode 100644 (file)
index 0000000..442c5d0
--- /dev/null
@@ -0,0 +1,89 @@
+#include "badgedata.h"
+#include <QFile>
+#include <QDir>
+#include <QDebug>
+
+BadgeData::BadgeData()
+{
+
+}
+
+bool BadgeData::setTimetable(TimeTable tt)
+{
+    QFile data;
+    TimeTable dum;
+    qint64 pos = 0;
+
+    data.setFileName(QDir::homePath() + QDir::separator() + "badge.data");
+    data.open(QIODevice::ReadWrite);
+    QDataStream out(&data);
+    while (!data.atEnd()) {
+        out >> dum;
+        if (dum.day == tt.day) {
+            data.seek(pos);
+
+            out << tt;
+            data.close();
+            return true;
+        }
+         pos = data.pos();
+    }
+    out << tt;
+    data.close();
+    return true;
+}
+
+bool BadgeData::getTimetable(TimeTable &tt)
+{
+    QFile data;
+    TimeTable dum;
+    data.setFileName(QDir::homePath() + QDir::separator() + "badge.data");
+    data.open(QIODevice::ReadOnly);
+    QDataStream out(&data);
+
+
+
+    while (!data.atEnd()) {
+        out >> dum;
+        if (dum.day == tt.day) {
+            tt = dum;
+            data.close();
+            return true;
+        }
+    }
+    data.close();
+    return false;
+}
+
+QTime BadgeData::totalTime(QDate begin, QDate end)
+{
+    QFile data;
+    TimeTable dum;
+    QTime total(0, 0, 0, 0);
+
+    int totalInSeconds = 0;
+
+    data.setFileName(QDir::homePath() + QDir::separator() + "badge.data");
+    data.open(QIODevice::ReadOnly);
+    QDataStream out(&data);
+    while (!data.atEnd()) {
+        out >> dum;
+        if (dum.day >=  begin && dum.day <= end) {
+            totalInSeconds += dum.entrance.secsTo(dum.exit);
+            if (dum.firstPause != dum.endFirstPause) {
+                totalInSeconds -= dum.firstPause.secsTo(dum.endFirstPause);
+            }
+
+            if (dum.secondPause != dum.endSecondPause) {
+                totalInSeconds -= dum.secondPause.secsTo(dum.endSecondPause);
+            }
+
+
+
+        }
+
+    }
+    data.close();
+    total.setHMS((int)(totalInSeconds / 3600), (int) ((totalInSeconds % 3600) / 60), 0);
+    return total;
+}
diff --git a/desktop/badgedata.h b/desktop/badgedata.h
new file mode 100644 (file)
index 0000000..0a30168
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef BADGEDATA_H
+#define BADGEDATA_H
+
+#include "timetable.h"
+#include <QDate>
+
+class BadgeData
+{
+
+public:
+    BadgeData();
+    bool setTimetable(TimeTable in);
+    bool getTimetable(TimeTable &out);
+    QTime totalTime(QDate begin, QDate end);
+};
+
+#endif // BADGEDATA_H
diff --git a/desktop/badgewindow.cpp b/desktop/badgewindow.cpp
new file mode 100644 (file)
index 0000000..b099259
--- /dev/null
@@ -0,0 +1,81 @@
+#include "badgewindow.h"
+#include "ui_badgewindow.h"
+
+#include "dialogday.h"
+#include <QDebug>
+#include "badgedata.h"
+#include "dialogsearch.h"
+#include <QMessageBox>
+
+BadgeWindow::BadgeWindow(QWidget *parent)
+    : QMainWindow(parent), ui(new Ui::BadgeWindow)
+{
+    ui->setupUi(this);
+    ui->menuBar->addAction(ui->actionSearch);
+    ui->menuBar->addAction(ui->actionInfo);
+#ifndef Q_WS_HILDON
+    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()));
+
+
+    //showMaximized();
+}
+
+
+
+void BadgeWindow::selectedDay(QDate date)
+{
+    DialogDay day;
+    BadgeData data;
+
+    TimeTable tt;
+    tt.day = date;
+    data.getTimetable(tt);
+    tt = day.getTimes(tt);
+    if (tt.wrong() != TimeTable::WRONG) {
+        BadgeData data;
+        data.setTimetable(tt);
+    }
+
+}
+
+void BadgeWindow::search()
+{
+    DialogSearch searchDialog;
+    QTime total;
+    QString message;
+    QString hours;
+    QString minutes;
+    bool ok;
+
+    total = searchDialog.totalHours(ok);
+    if (ok) {
+        hours.setNum(total.hour());
+        minutes.setNum(total.minute());
+        message = "Total time is: " + hours + " hours and " + minutes + " minutes";
+        QMessageBox::information(this, tr("Badge"), tr(message.toLatin1()));
+    }
+
+}
+
+void BadgeWindow::info()
+{
+    QMessageBox::aboutQt(this);
+    QMessageBox::about(this, tr("Badge"), 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"
+                        "certain conditions. For details, see the file 'COPYING' that came with this\n"
+                        "software distribution. If you did not get the file, send email to author.\n\n"
+                        "The program is provided AS IS with No WARRANTY OF ANY KIND,\n"
+                        "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND\n"
+                        "FITNESS FOR PARTICULAR PURPOSE"));
+}
+
+BadgeWindow::~BadgeWindow()
+{
+    delete ui;
+}
diff --git a/desktop/badgewindow.h b/desktop/badgewindow.h
new file mode 100644 (file)
index 0000000..f31f087
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef BADGEWINDOW_H
+#define BADGEWINDOW_H
+
+#include <QtGui/QMainWindow>
+#include <QDate>
+
+namespace Ui
+{
+    class BadgeWindow;
+}
+
+class BadgeWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    BadgeWindow(QWidget *parent = 0);
+    ~BadgeWindow();
+
+private:
+    Ui::BadgeWindow *ui;
+public slots:
+    void selectedDay(QDate);
+    void search();
+    void info();
+};
+
+#endif // BADGEWINDOW_H
diff --git a/desktop/badgewindow.ui b/desktop/badgewindow.ui
new file mode 100644 (file)
index 0000000..f9e6263
--- /dev/null
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BadgeWindow</class>
+ <widget class="QMainWindow" name="BadgeWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>600</width>
+    <height>400</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Badge</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QCalendarWidget" name="calendarWidget"/>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>600</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+  <action name="actionSearch">
+   <property name="text">
+    <string>Search</string>
+   </property>
+  </action>
+  <action name="actionInfo">
+   <property name="text">
+    <string>Info</string>
+   </property>
+  </action>
+  <action name="actionClose">
+   <property name="text">
+    <string>Close</string>
+   </property>
+  </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>calendarWidget</sender>
+   <signal>clicked(QDate)</signal>
+   <receiver>BadgeWindow</receiver>
+   <slot>selectedDay(QDate)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>199</x>
+     <y>351</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>30</x>
+     <y>403</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>selectedDay(QDate)</slot>
+ </slots>
+</ui>
diff --git a/desktop/dialogcalendar.cpp b/desktop/dialogcalendar.cpp
new file mode 100644 (file)
index 0000000..9dfbce1
--- /dev/null
@@ -0,0 +1,34 @@
+#include "dialogcalendar.h"
+#include "ui_dialogcalendar.h"
+
+DialogCalendar::DialogCalendar(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogCalendar)
+{
+    ui->setupUi(this);
+}
+
+DialogCalendar::~DialogCalendar()
+{
+    delete ui;
+}
+
+void DialogCalendar::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+
+QDate DialogCalendar::getDate(QDate date)
+{
+    if (this->exec() == QDialog::Accepted) {
+        return ui->calendarWidget->selectedDate();
+    }
+    return date;
+}
diff --git a/desktop/dialogcalendar.h b/desktop/dialogcalendar.h
new file mode 100644 (file)
index 0000000..c835695
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef DIALOGCALENDAR_H
+#define DIALOGCALENDAR_H
+
+#include <QDialog>
+#include <QDate>
+
+namespace Ui {
+    class DialogCalendar;
+}
+
+class DialogCalendar : public QDialog {
+    Q_OBJECT
+public:
+    DialogCalendar(QWidget *parent = 0);
+    ~DialogCalendar();
+    QDate getDate(QDate date);
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::DialogCalendar *ui;
+};
+
+#endif // DIALOGCALENDAR_H
diff --git a/desktop/dialogcalendar.ui b/desktop/dialogcalendar.ui
new file mode 100644 (file)
index 0000000..1a4cccd
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogCalendar</class>
+ <widget class="QDialog" name="DialogCalendar">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>305</width>
+    <height>181</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QCalendarWidget" name="calendarWidget"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>calendarWidget</sender>
+   <signal>clicked(QDate)</signal>
+   <receiver>DialogCalendar</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>220</x>
+     <y>69</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>299</x>
+     <y>117</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/desktop/dialogday.cpp b/desktop/dialogday.cpp
new file mode 100644 (file)
index 0000000..6402784
--- /dev/null
@@ -0,0 +1,84 @@
+#include "dialogday.h"
+#include "ui_dialogday.h"
+#include <QDebug>
+
+DialogDay::DialogDay(QWidget *parent) :
+    QDialog(parent),
+    m_ui(new Ui::DialogDay)
+{
+    m_ui->setupUi(this);
+}
+
+DialogDay::~DialogDay()
+{
+    delete m_ui;
+}
+
+void DialogDay::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        m_ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+
+void DialogDay::enableFirst(bool enable)
+{
+    m_ui->timeEditFBegin->setEnabled(enable);
+    m_ui->timeEditEndF->setEnabled(enable);
+}
+
+void DialogDay::enableSecond(bool enable)
+{
+    m_ui->timeEditSBegin->setEnabled(enable);
+    m_ui->timeEditEndS->setEnabled(enable);
+}
+
+
+TimeTable DialogDay::getTimes(TimeTable timetable)
+{
+
+    m_ui->timeEditEntrance->setTime(timetable.entrance);
+    m_ui->timeEditExit->setTime(timetable.exit);
+    m_ui->checkBoxFirst->setChecked(false);
+    m_ui->checkBoxSecond->setChecked(false);
+
+    if (timetable.firstPause != timetable.endFirstPause) {
+        m_ui->checkBoxFirst->setChecked(true);
+        m_ui->timeEditFBegin->setTime(timetable.firstPause);
+        m_ui->timeEditFBegin->setEnabled(true);
+        m_ui->timeEditEndF->setTime(timetable.endFirstPause);
+        m_ui->timeEditEndF->setEnabled(true);
+    }
+    if (timetable.secondPause != timetable.endSecondPause) {
+        m_ui->checkBoxSecond->setChecked(true);
+        m_ui->timeEditSBegin->setTime(timetable.secondPause);
+        m_ui->timeEditSBegin->setEnabled(true);
+        m_ui->timeEditEndS->setTime(timetable.endSecondPause);
+        m_ui->timeEditEndS->setEnabled(true);
+    }
+
+
+    if (this->exec() == QDialog::Accepted) {
+
+            timetable.entrance = m_ui->timeEditEntrance->time();
+            timetable.exit = m_ui->timeEditExit->time();
+        if (m_ui->checkBoxFirst->isChecked()) {
+            timetable.firstPause = m_ui->timeEditFBegin->time();
+            timetable.endFirstPause = m_ui->timeEditEndF->time();
+        }
+        if (m_ui->checkBoxSecond->isChecked()) {
+            timetable.secondPause = m_ui->timeEditSBegin->time();
+            timetable.endSecondPause = m_ui->timeEditEndS->time();
+        }
+        return timetable;
+    }
+    timetable.setWrong(true);
+    return timetable;
+}
+
+
diff --git a/desktop/dialogday.h b/desktop/dialogday.h
new file mode 100644 (file)
index 0000000..152009d
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef DIALOGDAY_H
+#define DIALOGDAY_H
+
+#include <QtGui/QDialog>
+#include "timetable.h"
+
+namespace Ui {
+    class DialogDay;
+}
+
+class DialogDay : public QDialog {
+    Q_OBJECT
+
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::DialogDay *m_ui;
+    bool change;
+public:
+    DialogDay(QWidget *parent = 0);
+    ~DialogDay();
+    TimeTable getTimes(TimeTable timetable);
+
+public slots:
+    void enableFirst(bool);
+    void enableSecond(bool);
+
+};
+
+#endif // DIALOGDAY_H
diff --git a/desktop/dialogday.ui b/desktop/dialogday.ui
new file mode 100644 (file)
index 0000000..50de384
--- /dev/null
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogDay</class>
+ <widget class="QDialog" name="DialogDay">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>319</width>
+    <height>236</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Entrance</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTimeEdit" name="timeEditEntrance">
+       <property name="minimumSize">
+        <size>
+         <width>100</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Exit</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTimeEdit" name="timeEditExit">
+       <property name="minimumSize">
+        <size>
+         <width>100</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="0">
+    <widget class="QCheckBox" name="checkBoxFirst">
+     <property name="text">
+      <string>First Pause</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="text">
+        <string>Begin</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTimeEdit" name="timeEditFBegin">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>100</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_4">
+       <property name="text">
+        <string>End</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTimeEdit" name="timeEditEndF">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>100</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="3" column="0">
+    <widget class="QCheckBox" name="checkBoxSecond">
+     <property name="text">
+      <string>Second Pause</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QLabel" name="label_5">
+       <property name="text">
+        <string>Begin</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTimeEdit" name="timeEditSBegin">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>100</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_6">
+       <property name="text">
+        <string>End</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTimeEdit" name="timeEditEndS">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>100</width>
+         <height>0</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="5" column="0">
+    <widget class="QPushButton" name="pushButton">
+     <property name="text">
+      <string>Task</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="0">
+    <widget class="QPushButton" name="pushButton_2">
+     <property name="text">
+      <string>Ok</string>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="0">
+    <widget class="QPushButton" name="pushButton_3">
+     <property name="text">
+      <string>Cancel</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>checkBoxFirst</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>DialogDay</receiver>
+   <slot>enableFirst(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>170</x>
+     <y>58</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>202</x>
+     <y>55</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>checkBoxSecond</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>DialogDay</receiver>
+   <slot>enableSecond(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>137</x>
+     <y>113</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>206</x>
+     <y>121</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButton_2</sender>
+   <signal>clicked()</signal>
+   <receiver>DialogDay</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>296</x>
+     <y>184</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>316</x>
+     <y>186</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButton_3</sender>
+   <signal>clicked()</signal>
+   <receiver>DialogDay</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>303</x>
+     <y>220</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>316</x>
+     <y>220</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButton</sender>
+   <signal>clicked()</signal>
+   <receiver>DialogDay</receiver>
+   <slot>task()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>305</x>
+     <y>159</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>312</x>
+     <y>160</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>enableFirst(bool)</slot>
+  <slot>enableSecond(bool)</slot>
+  <slot>task()</slot>
+ </slots>
+</ui>
diff --git a/desktop/dialogsearch.cpp b/desktop/dialogsearch.cpp
new file mode 100644 (file)
index 0000000..23a9b91
--- /dev/null
@@ -0,0 +1,67 @@
+#include "dialogsearch.h"
+#include "ui_dialogsearch.h"
+#include "dialogcalendar.h"
+#include <QMessageBox>
+#include "badgedata.h"
+
+DialogSearch::DialogSearch(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogSearch)
+{
+    ui->setupUi(this);
+    //move(, 0);
+    //showMaximized();
+}
+
+DialogSearch::~DialogSearch()
+{
+    delete ui;
+}
+
+void DialogSearch::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+
+void DialogSearch::start()
+{
+    DialogCalendar cal;
+    ui->dateEditStart->setDate(cal.getDate(ui->dateEditStart->date()));
+}
+
+void DialogSearch::end()
+{
+    DialogCalendar cal;
+    ui->dateEditEnd->setDate(cal.getDate(ui->dateEditEnd->date()));
+}
+
+QTime DialogSearch::totalHours(bool &ok)
+{
+
+    if (this->exec() == QDialog::Accepted) {
+        BadgeData data;
+        ok = true;
+        return data.totalTime(ui->dateEditStart->date(), ui->dateEditEnd->date());
+    }
+    ok = false;
+
+
+    return QTime(0, 0, 0, 0);
+}
+
+void DialogSearch::accept()
+{
+    if (ui->dateEditEnd->date() < ui->dateEditStart->date()) {
+        QMessageBox::warning(this, tr("Badge"),
+                                        tr("End date must to be major or equal of start date.\n"));
+    }
+    else
+        QDialog::accept();
+}
diff --git a/desktop/dialogsearch.h b/desktop/dialogsearch.h
new file mode 100644 (file)
index 0000000..a413b19
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef DIALOGSEARCH_H
+#define DIALOGSEARCH_H
+
+#include <QDialog>
+
+namespace Ui {
+    class DialogSearch;
+}
+
+class DialogSearch : public QDialog {
+    Q_OBJECT
+public:
+    DialogSearch(QWidget *parent = 0);
+    ~DialogSearch();
+    QTime totalHours(bool &ok);
+protected:
+    void changeEvent(QEvent *e);
+
+private:
+    Ui::DialogSearch *ui;
+public slots:
+    void start();
+    void end();
+    void accept();
+};
+
+#endif // DIALOGSEARCH_H
diff --git a/desktop/dialogsearch.ui b/desktop/dialogsearch.ui
new file mode 100644 (file)
index 0000000..7f9df52
--- /dev/null
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogSearch</class>
+ <widget class="QDialog" name="DialogSearch">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>299</width>
+    <height>229</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QWidget" name="">
+   <property name="geometry">
+    <rect>
+     <x>9</x>
+     <y>9</y>
+     <width>291</width>
+     <height>211</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <widget class="QLabel" name="label">
+        <property name="text">
+         <string>Start</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="pushButtonStart">
+        <property name="maximumSize">
+         <size>
+          <width>31</width>
+          <height>26</height>
+         </size>
+        </property>
+        <property name="text">
+         <string>..</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QDateEdit" name="dateEditStart"/>
+      </item>
+     </layout>
+    </item>
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <item>
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>End</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="pushButtonEnd">
+        <property name="maximumSize">
+         <size>
+          <width>31</width>
+          <height>26</height>
+         </size>
+        </property>
+        <property name="text">
+         <string>..</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QDateEdit" name="dateEditEnd"/>
+      </item>
+     </layout>
+    </item>
+    <item>
+     <spacer name="horizontalSpacer">
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>40</width>
+        <height>20</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item>
+     <widget class="QDialogButtonBox" name="buttonBox">
+      <property name="maximumSize">
+       <size>
+        <width>16777215</width>
+        <height>26</height>
+       </size>
+      </property>
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+      <property name="standardButtons">
+       <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <zorder>label</zorder>
+  <zorder>pushButtonStart</zorder>
+  <zorder>dateEditStart</zorder>
+  <zorder>label_2</zorder>
+  <zorder>pushButtonEnd</zorder>
+  <zorder>dateEditEnd</zorder>
+  <zorder>buttonBox</zorder>
+  <zorder>buttonBox</zorder>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>DialogSearch</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>208</x>
+     <y>149</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>DialogSearch</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>208</x>
+     <y>149</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButtonStart</sender>
+   <signal>clicked()</signal>
+   <receiver>DialogSearch</receiver>
+   <slot>start()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>83</x>
+     <y>38</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>63</x>
+     <y>18</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButtonEnd</sender>
+   <signal>clicked()</signal>
+   <receiver>DialogSearch</receiver>
+   <slot>end()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>89</x>
+     <y>92</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>79</x>
+     <y>105</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>start()</slot>
+  <slot>end()</slot>
+ </slots>
+</ui>
diff --git a/desktop/main.cpp b/desktop/main.cpp
new file mode 100644 (file)
index 0000000..7eed133
--- /dev/null
@@ -0,0 +1,10 @@
+#include <QtGui/QApplication>
+#include "badgewindow.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    BadgeWindow w;
+    w.show();
+    return a.exec();
+}
diff --git a/desktop/timetable.cpp b/desktop/timetable.cpp
new file mode 100644 (file)
index 0000000..6bd31e8
--- /dev/null
@@ -0,0 +1,31 @@
+#include "timetable.h"
+
+
+
+QDataStream &operator<<(QDataStream &out, const TimeTable &timetable)
+{
+    out << timetable.day << timetable.entrance << timetable.firstPause << timetable.endFirstPause << timetable.secondPause
+            << timetable.endSecondPause << timetable.exit;
+
+    return out;
+}
+
+QDataStream &operator>>(QDataStream &in, TimeTable &timetable)
+{
+    in >> timetable.day >> timetable.entrance >> timetable.firstPause >> timetable.endFirstPause >> timetable.secondPause
+            >> timetable.endSecondPause >> timetable.exit;
+    return in;
+}
+
+int TimeTable::wrong()
+{
+    if (isWrong)
+        return WRONG;
+    else
+        return NO_WRONG;
+}
+
+void TimeTable::setWrong(bool wrong)
+{
+    isWrong = wrong;
+}
diff --git a/desktop/timetable.h b/desktop/timetable.h
new file mode 100644 (file)
index 0000000..bace014
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef TIMETABLE_H
+#define TIMETABLE_H
+
+#include <QDataStream>
+#include <QDate>
+#include <QTime>
+
+
+class  TimeTable
+{
+    private:
+        bool isWrong;
+    public:
+    enum {WRONG, NO_WRONG};
+    QDate day;
+    QTime entrance;
+    QTime firstPause;
+    QTime endFirstPause;
+    QTime secondPause;
+    QTime endSecondPause;
+    QTime exit;
+
+
+    TimeTable() {isWrong = false;}
+    int wrong();
+    void setWrong(bool wrong);
+
+};
+
+QDataStream &operator<<(QDataStream &out, const TimeTable &timetable);
+QDataStream &operator>>(QDataStream &in, TimeTable &timetable);
+
+
+
+#endif // TIMETABLE_H