Add support of leaves
This commit is contained in:
@@ -7,6 +7,7 @@ Day::Day()
|
||||
BreakPoint *lunch = new BreakPoint(QTime(12, 0, 0, 0), QTime(12, 45, 0, 0));
|
||||
breaks.append(lunch);
|
||||
validate = false;
|
||||
notWorking = false;
|
||||
}
|
||||
|
||||
Day::Day(Day *old)
|
||||
@@ -16,6 +17,7 @@ Day::Day(Day *old)
|
||||
BreakPoint *lunch = new BreakPoint(QTime(12, 0, 0, 0), QTime(12, 45, 0, 0));
|
||||
breaks.append(lunch);
|
||||
validate = false;
|
||||
notWorking = false;
|
||||
update(old);
|
||||
}
|
||||
|
||||
@@ -51,7 +53,7 @@ void Day::set_validate(bool value) {
|
||||
validate = value;
|
||||
}
|
||||
|
||||
void Day::set_working(bool value)
|
||||
void Day::set_not_working(bool value)
|
||||
{
|
||||
this->notWorking = value;
|
||||
}
|
||||
@@ -86,7 +88,8 @@ QJsonObject Day::to_json()
|
||||
{KEY_START, start.toString(Qt::DateFormat::ISODate)},
|
||||
{KEY_END, end.toString(Qt::DateFormat::ISODate)},
|
||||
{KEY_BREAKS, arr},
|
||||
{KEY_VALIDATE, validate}
|
||||
{KEY_VALIDATE, validate},
|
||||
{KEY_NOT_WORKING, notWorking}
|
||||
};
|
||||
|
||||
return obj;
|
||||
@@ -112,7 +115,8 @@ Day* Day::from_json(QJsonObject obj)
|
||||
|
||||
result->start = QTime::fromString(obj[KEY_START].toString(), Qt::DateFormat::ISODate);
|
||||
result->end = QTime::fromString(obj[KEY_END].toString(), Qt::DateFormat::ISODate);
|
||||
result->validate = obj[KEY_VALIDATE].toBool();
|
||||
result->validate = obj[KEY_VALIDATE].toBool(false);
|
||||
result->notWorking = obj[KEY_NOT_WORKING].toBool(false);
|
||||
|
||||
result->breaks.clear();
|
||||
QJsonArray arr = obj[KEY_BREAKS].toArray();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#define KEY_END "end"
|
||||
#define KEY_BREAKS "breaks"
|
||||
#define KEY_VALIDATE "validate"
|
||||
#define KEY_NOT_WORKING "not_working"
|
||||
|
||||
#include <QTime>
|
||||
#include <QJsonObject>
|
||||
@@ -31,7 +32,7 @@ public:
|
||||
void set_start(QTime value);
|
||||
void set_end(QTime value);
|
||||
void set_validate(bool);
|
||||
void set_working(bool);
|
||||
void set_not_working(bool);
|
||||
void setBreaks(QVector<BreakPoint*>);
|
||||
|
||||
QTime get_start();
|
||||
|
||||
@@ -61,6 +61,37 @@ double Week::total() {
|
||||
return mon->get_total() + tue->get_total() + wed->get_total() + thu->get_total() + fri->get_total();
|
||||
}
|
||||
|
||||
double Week::total(Week *wtemplate)
|
||||
{
|
||||
double t = 0.0;
|
||||
if (mon->not_working()) {
|
||||
t += wtemplate->mon->get_total();
|
||||
} else {
|
||||
t += mon->get_total();
|
||||
}
|
||||
if (tue->not_working()) {
|
||||
t += wtemplate->tue->get_total();
|
||||
} else {
|
||||
t += tue->get_total();
|
||||
}
|
||||
if (wed->not_working()) {
|
||||
t += wtemplate->wed->get_total();
|
||||
} else {
|
||||
t += wed->get_total();
|
||||
}
|
||||
if (thu->not_working()) {
|
||||
t += wtemplate->thu->get_total();
|
||||
} else {
|
||||
t += thu->get_total();
|
||||
}
|
||||
if (fri->not_working()) {
|
||||
t += wtemplate->fri->get_total();
|
||||
} else {
|
||||
t += fri->get_total();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
Day* Week::getMon() {
|
||||
return mon;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
Week(Week*);
|
||||
~Week();
|
||||
double total();
|
||||
double total(Week *wtemplate);
|
||||
|
||||
void setMon(Day*);
|
||||
void setTue(Day*);
|
||||
|
||||
Reference in New Issue
Block a user