initial commit
This commit is contained in:
+38
-1
@@ -1,15 +1,52 @@
|
||||
#include "cmainwindow.h"
|
||||
#include "ui_cmainwindow.h"
|
||||
|
||||
#include <QDate>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow)
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpMonthlyView(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings;
|
||||
qint32 iX = settings.value("main/x", QVariant::fromValue(-1)).toInt();
|
||||
qint32 iY = settings.value("main/y", QVariant::fromValue(-1)).toInt();
|
||||
qint32 iWidth = settings.value("main/width", QVariant::fromValue(-1)).toInt();
|
||||
qint32 iHeight = settings.value("main/height", QVariant::fromValue(-1)).toInt();
|
||||
|
||||
if(iWidth != -1 && iHeight != -1)
|
||||
resize(iWidth, iHeight);
|
||||
if(iX != -1 && iY != -1)
|
||||
move(iX, iY);
|
||||
|
||||
m_lpMonthlyView = new cMonthlyView(QDate(2019, 10, 8), this);
|
||||
ui->m_lpMainTab->addTab(m_lpMonthlyView, "Monthly");
|
||||
}
|
||||
|
||||
cMainWindow::~cMainWindow()
|
||||
{
|
||||
if(m_lpMonthlyView)
|
||||
delete m_lpMonthlyView;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cMainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("main/width", QVariant::fromValue(size().width()));
|
||||
settings.setValue("main/height", QVariant::fromValue(size().height()));
|
||||
settings.setValue("main/x", QVariant::fromValue(x()));
|
||||
settings.setValue("main/y", QVariant::fromValue(y()));
|
||||
if(this->isMaximized())
|
||||
settings.setValue("main/maximized", QVariant::fromValue(true));
|
||||
else
|
||||
settings.setValue("main/maximized", QVariant::fromValue(false));
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
+8
-1
@@ -2,7 +2,10 @@
|
||||
#define CMAINWINDOW_H
|
||||
|
||||
|
||||
#include "cmonthlyview.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QCloseEvent>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
@@ -18,7 +21,11 @@ public:
|
||||
~cMainWindow();
|
||||
|
||||
private:
|
||||
Ui::cMainWindow *ui;
|
||||
Ui::cMainWindow* ui;
|
||||
cMonthlyView* m_lpMonthlyView;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+33
-11
@@ -1,24 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cMainWindow</class>
|
||||
<widget class="QMainWindow" name="cMainWindow" >
|
||||
<property name="geometry" >
|
||||
<widget class="QMainWindow" name="cMainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>939</width>
|
||||
<height>742</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>cMainWindow</string>
|
||||
</property>
|
||||
<widget class="QMenuBar" name="menuBar" />
|
||||
<widget class="QToolBar" name="mainToolBar" />
|
||||
<widget class="QWidget" name="centralWidget" />
|
||||
<widget class="QStatusBar" name="statusBar" />
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="m_lpMainTab"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>939</width>
|
||||
<height>21</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"/>
|
||||
</widget>
|
||||
<layoutDefault spacing="6" margin="11" />
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#include "cmonthlyitemdelegate.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
cMonthlyItemDelegate::cMonthlyItemDelegate(const QMap<QString, QString>& code, QObject* parent) :
|
||||
QStyledItemDelegate(parent),
|
||||
m_code(code)
|
||||
{
|
||||
}
|
||||
|
||||
cMonthlyItemDelegate::~cMonthlyItemDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* cMonthlyItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case COL_COME1:
|
||||
case COL_GO1:
|
||||
case COL_COME2:
|
||||
case COL_GO2:
|
||||
case COL_COME3:
|
||||
case COL_GO3:
|
||||
case COL_BREAK:
|
||||
{
|
||||
QTimeEdit* lpTimeEdit = new QTimeEdit(parent);
|
||||
lpTimeEdit->setDisplayFormat("HH:mm:ss");
|
||||
return(lpTimeEdit);
|
||||
}
|
||||
case COL_CODE:
|
||||
{
|
||||
QComboBox* lpComboBox = new QComboBox(parent);
|
||||
|
||||
for(QMap<QString, QString>::const_iterator i = m_code.constBegin();i != m_code.constEnd();i++)
|
||||
lpComboBox->addItem(i.value());
|
||||
return(lpComboBox);
|
||||
}
|
||||
case COL_INFORMATION:
|
||||
return(QStyledItemDelegate::createEditor(parent, option, index));
|
||||
default:
|
||||
return(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void cMonthlyItemDelegate::setEditorData ( QWidget *editor, const QModelIndex &index ) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case COL_COME1:
|
||||
case COL_GO1:
|
||||
case COL_COME2:
|
||||
case COL_GO2:
|
||||
case COL_COME3:
|
||||
case COL_GO3:
|
||||
case COL_BREAK:
|
||||
{
|
||||
QTimeEdit* lpTimeEdit = qobject_cast<QTimeEdit*>(editor);
|
||||
lpTimeEdit->setTime(QTime::fromString(index.data(Qt::EditRole).toString()));
|
||||
break;
|
||||
}
|
||||
case COL_CODE:
|
||||
{
|
||||
QComboBox* lpComboBox = qobject_cast<QComboBox*>(editor);
|
||||
QString currentText = index.data(Qt::EditRole).toString();
|
||||
int cbIndex = lpComboBox->findText(m_code.value(currentText));
|
||||
|
||||
if(cbIndex >= 0)
|
||||
lpComboBox->setCurrentIndex(cbIndex);
|
||||
|
||||
break;
|
||||
}
|
||||
case COL_INFORMATION:
|
||||
QStyledItemDelegate::setEditorData(editor, index);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cMonthlyItemDelegate::setModelData ( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case COL_COME1:
|
||||
case COL_GO1:
|
||||
case COL_COME2:
|
||||
case COL_GO2:
|
||||
case COL_COME3:
|
||||
case COL_GO3:
|
||||
case COL_BREAK:
|
||||
{
|
||||
QTimeEdit* lpTimeEdit = qobject_cast<QTimeEdit*>(editor);
|
||||
if(!lpTimeEdit->time().hour() &&
|
||||
!lpTimeEdit->time().minute() &&
|
||||
!lpTimeEdit->time().second())
|
||||
model->setData(index, "", Qt::EditRole);
|
||||
else
|
||||
model->setData(index, lpTimeEdit->time().toString(), Qt::EditRole);
|
||||
break;
|
||||
}
|
||||
case COL_CODE:
|
||||
{
|
||||
QComboBox* lpComboBox = qobject_cast<QComboBox*>(editor);
|
||||
model->setData(index, m_code.key(lpComboBox->currentText()), Qt::EditRole);
|
||||
break;
|
||||
}
|
||||
case COL_INFORMATION:
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef CMONTHLYITEMDELEGATE_H
|
||||
#define CMONTHLYITEMDELEGATE_H
|
||||
|
||||
|
||||
#include <QTimeEdit>
|
||||
#include <QComboBox>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QStandardItem>
|
||||
|
||||
#include <QMap>
|
||||
|
||||
|
||||
class cMonthlyItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
cMonthlyItemDelegate(const QMap<QString, QString>& code, QObject* parent = nullptr);
|
||||
~cMonthlyItemDelegate();
|
||||
|
||||
virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
QMap<QString, QString> m_code;
|
||||
};
|
||||
|
||||
#endif // CMONTHLYITEMDELEGATE_H
|
||||
@@ -0,0 +1,118 @@
|
||||
#include "cmonthlyview.h"
|
||||
#include "ui_cmonthlyview.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
cMonthlyView::cMonthlyView(const QDate& date, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::cMonthlyView)
|
||||
{
|
||||
m_code.insert(" ", tr(""));
|
||||
m_code.insert("G", tr("Gleitzeit"));
|
||||
m_code.insert("U", tr("Urlaub"));
|
||||
m_code.insert("K", tr("Krank"));
|
||||
m_code.insert("SU", tr("Sonderurlaub"));
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
m_lpMonthlyListModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpMonthlyList->setModel(m_lpMonthlyListModel);
|
||||
ui->m_lpMonthlyList->setItemDelegate(new cMonthlyItemDelegate(m_code));
|
||||
|
||||
setDate(date);
|
||||
}
|
||||
|
||||
void cMonthlyView::setDate(const QDate& date)
|
||||
{
|
||||
m_lpMonthlyListModel->clear();
|
||||
|
||||
QStringList header;
|
||||
header << tr("day") << tr("public holiday") << tr("come1") << tr("go1") << tr("come2") << tr("go2") << tr("come3") << tr("go3") << tr("break") << tr("code") << tr("is") << tr("should") << tr("+/-") << tr("information") << tr("current +/-") << tr("hours dec") << tr("day");
|
||||
m_lpMonthlyListModel->setHorizontalHeaderLabels(header);
|
||||
|
||||
QList<QStandardItem*> items;
|
||||
for(int y = 0;y < header.count();y++)
|
||||
items.append(new QStandardItem);
|
||||
|
||||
items[COL_DAY1]->setText("99");
|
||||
items[COL_PUBLIC_HOLIDAY]->setText("");
|
||||
items[COL_COME1]->setText("00:00:00");
|
||||
items[COL_GO1]->setText("00:00:00");
|
||||
items[COL_COME2]->setText("00:00:00");
|
||||
items[COL_GO2]->setText("00:00:00");
|
||||
items[COL_COME3]->setText("00:00:00");
|
||||
items[COL_GO3]->setText("00:00:00");
|
||||
items[COL_BREAK]->setText("00:00:00");
|
||||
items[COL_CODE]->setText("");
|
||||
items[COL_IS]->setText("00:00:00");
|
||||
items[COL_SHOULD]->setText("00:00:00");
|
||||
items[COL_DIFF]->setText("00:00:00");
|
||||
items[COL_INFORMATION]->setText("");
|
||||
items[COL_CURRENT]->setText("00:00:00");
|
||||
items[COL_HOURS_DEC]->setText("0.0");
|
||||
items[COL_DAY2]->setText("99");
|
||||
|
||||
m_lpMonthlyListModel->appendRow(items);
|
||||
|
||||
for(int y = 0;y < header.count();y++)
|
||||
ui->m_lpMonthlyList->resizeColumnToContents(y);
|
||||
|
||||
m_lpMonthlyListModel->removeRows(0, 1);
|
||||
|
||||
QDate date1 = date;
|
||||
date1.setDate(date.year(), date.month(), 1);
|
||||
|
||||
for(;date1.month() == date.month();date1 = date1.addDays(1))
|
||||
{
|
||||
items.clear();
|
||||
|
||||
for(int y = 0;y < header.count();y++)
|
||||
items.append(new QStandardItem);
|
||||
|
||||
items[COL_DAY1]->setText(date1.toString("dddd dd"));
|
||||
items[COL_PUBLIC_HOLIDAY]->setText("");
|
||||
items[COL_COME1]->setText("");
|
||||
items[COL_GO1]->setText("");
|
||||
items[COL_COME2]->setText("");
|
||||
items[COL_GO2]->setText("");
|
||||
items[COL_COME3]->setText("");
|
||||
items[COL_GO3]->setText("");
|
||||
items[COL_BREAK]->setText("00:00:00");
|
||||
items[COL_CODE]->setText("");
|
||||
items[COL_IS]->setText("00:00:00");
|
||||
items[COL_SHOULD]->setText("00:00:00");
|
||||
items[COL_DIFF]->setText("00:00:00");
|
||||
items[COL_INFORMATION]->setText("");
|
||||
items[COL_CURRENT]->setText("00:00:00");
|
||||
items[COL_HOURS_DEC]->setText("0.0");
|
||||
items[COL_DAY2]->setText(date1.toString("dd dddd"));
|
||||
|
||||
items[COL_DAY1]->setTextAlignment(Qt::AlignRight);
|
||||
items[COL_PUBLIC_HOLIDAY]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_COME1]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_GO1]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_COME2]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_GO2]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_COME3]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_GO3]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_BREAK]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_CODE]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_IS]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_SHOULD]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_DIFF]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_INFORMATION]->setTextAlignment(Qt::AlignLeft);
|
||||
items[COL_CURRENT]->setTextAlignment(Qt::AlignHCenter);
|
||||
items[COL_HOURS_DEC]->setTextAlignment(Qt::AlignRight);
|
||||
items[COL_DAY2]->setTextAlignment(Qt::AlignLeft);
|
||||
|
||||
m_lpMonthlyListModel->appendRow(items);
|
||||
}
|
||||
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY1);
|
||||
ui->m_lpMonthlyList->resizeColumnToContents(COL_DAY2);
|
||||
}
|
||||
|
||||
cMonthlyView::~cMonthlyView()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef CMONTHLYVIEW_H
|
||||
#define CMONTHLYVIEW_H
|
||||
|
||||
|
||||
#include "cmonthlyitemdelegate.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class cMonthlyView;
|
||||
}
|
||||
|
||||
class cMonthlyView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit cMonthlyView(const QDate& date, QWidget *parent = nullptr);
|
||||
~cMonthlyView();
|
||||
|
||||
void setDate(const QDate& date);
|
||||
private:
|
||||
Ui::cMonthlyView* ui;
|
||||
QStandardItemModel* m_lpMonthlyListModel;
|
||||
QMap<QString, QString> m_code;
|
||||
};
|
||||
|
||||
#endif // CMONTHLYVIEW_H
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cMonthlyView</class>
|
||||
<widget class="QWidget" name="cMonthlyView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>996</width>
|
||||
<height>525</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>976</width>
|
||||
<height>505</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="m_lpMonthlyList">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#define COL_DAY1 0
|
||||
#define COL_PUBLIC_HOLIDAY 1
|
||||
#define COL_COME1 2
|
||||
#define COL_GO1 3
|
||||
#define COL_COME2 4
|
||||
#define COL_GO2 5
|
||||
#define COL_COME3 6
|
||||
#define COL_GO3 7
|
||||
#define COL_BREAK 8
|
||||
#define COL_CODE 9
|
||||
#define COL_IS 10
|
||||
#define COL_SHOULD 11
|
||||
#define COL_DIFF 12
|
||||
#define COL_INFORMATION 13
|
||||
#define COL_CURRENT 14
|
||||
#define COL_HOURS_DEC 15
|
||||
#define COL_DAY2 16
|
||||
|
||||
|
||||
#endif // COMMON_H
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "cpublicholiday.h"
|
||||
|
||||
|
||||
cPublicHoliday::cPublicHoliday()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef CPUBLICHOLIDAY_H
|
||||
#define CPUBLICHOLIDAY_H
|
||||
|
||||
|
||||
class cPublicHoliday
|
||||
{
|
||||
public:
|
||||
cPublicHoliday();
|
||||
};
|
||||
|
||||
#endif // CPUBLICHOLIDAY_H
|
||||
@@ -1,11 +1,26 @@
|
||||
#include "cmainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
a.setApplicationDisplayName("workingHours");
|
||||
a.setOrganizationName("WIN-DESIGN");
|
||||
a.setOrganizationDomain("windesign.at");
|
||||
a.setApplicationName("workingHours");
|
||||
|
||||
QSettings settings;
|
||||
|
||||
cMainWindow w;
|
||||
w.show();
|
||||
|
||||
if(settings.value("main/maximized").toBool())
|
||||
w.showMaximized();
|
||||
else
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
+10
-2
@@ -25,14 +25,22 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
CONFIG += c++11
|
||||
|
||||
SOURCES += \
|
||||
cmonthlyitemdelegate.cpp \
|
||||
cmonthlyview.cpp \
|
||||
cpublicholiday.cpp \
|
||||
main.cpp \
|
||||
cmainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
cmainwindow.h
|
||||
cmainwindow.h \
|
||||
cmonthlyitemdelegate.h \
|
||||
cmonthlyview.h \
|
||||
common.h \
|
||||
cpublicholiday.h
|
||||
|
||||
FORMS += \
|
||||
cmainwindow.ui
|
||||
cmainwindow.ui \
|
||||
cmonthlyview.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
|
||||
Reference in New Issue
Block a user