18 static QVariant null(
const QVariant& x) {
19 if (x.isValid() && !x.isNull()) {
return x; }
25QVariantMap Users::toMap()
const {
28 data[
"login"] = login;
31 data[
"enabled"] = enabled;
32 data[
"admin"] = admin;
37Users Users::fromMap(
const QVariantMap& data) {
39 x.user = data[
"user"].toInt();
40 x.login = data[
"login"].toString();
41 x.name = data[
"name"].toString();
42 x.lang = data[
"lang"].toString();
43 x.enabled = data[
"enabled"].toBool();
44 x.admin = data[
"admin"].toBool();
49QVariantMap ClientSettings::toMap()
const {
51 x[
"multiple_timesheets"] = multiple_timesheets;
52 x[
"show_price"] = show_price;
53 x[
"can_change_category"] = can_change_category;
54 x[
"edit_categories"] = edit_categories;
55 x[
"show_multiple_timesheets"] = show_multiple_timesheets;
56 x[
"show_show_price"] = show_show_price;
57 x[
"show_can_change_category"] = show_can_change_category;
58 x[
"show_edit_categories"] = show_edit_categories;
63ServerInfo ServerInfo::fromMap(
const QVariantMap& data) {
65 x.name = data[
"name"].toString();
66 x.description = data[
"description"].toString();
73 x.multiple_timesheets = map[
"multiple_timesheets"].toBool();
74 x.show_price = map[
"show_price"].toBool();
75 x.can_change_category = map[
"can_change_category"].toBool();
76 x.edit_categories = map[
"edit_categories"].toBool();
77 x.show_multiple_timesheets = map[
"show_multiple_timesheets"].toBool();
78 x.show_show_price = map[
"show_show_price"].toBool();
79 x.show_can_change_category = map[
"show_can_change_category"].toBool();
80 x.show_edit_categories = map[
"show_edit_categories"].toBool();
87QVariantMap Categories::toMap()
const {
89 data[
"category"] = category;
90 data[
"parent_category"] = null(parent_category);
91 data[
"description"] = description;
92 data[
"description_tree"] = description_tree;
93 data[
"price"] = price;
94 data[
"users"] = users;
99Categories Categories::fromMap(
const QVariantMap& data) {
101 x.category = data[
"category"].toString();
102 x.parent_category = data[
"parent_category"].toString();
103 x.description = data[
"description"].toString();
104 x.price = data[
"price"].toDouble();
105 x.users = data[
"users"].toList();
112 x.id = data[
"id"].toInt();
113 x.user = data[
"user"].toInt();
114 x.category = data[
"category"].toString();
119QVariantMap UsersCategories::toMap()
const {
123 data[
"category"] = null(category);
128QVariantMap StatusOrder::toMap()
const {
130 data[
"id"] = null(
id);
131 data[
"category"] = null(category);
132 data[
"previous_status"] = null(previous_status);
133 data[
"next_status"] = null(next_status);
138StatusOrder StatusOrder::fromMap(
const QVariantMap& data) {
141 x.category = data[
"category"];
142 x.previous_status = data[
"previous_status"];
143 x.next_status = data[
"next_status"];
148QVariantMap Statuses::toMap()
const {
150 data[
"status"] = status;
151 data[
"description"] = description;
152 data[
"abbreviation"] = abbreviation;
153 data[
"color"] = color;
154 data[
"closed"] = closed;
155 data[
"can_be_run"] = can_be_run;
156 data[
"ignored"] = ignored;
158 data[
"next"] = toList(next);
164Statuses Statuses::fromMap(
const QVariantMap& data) {
166 x.status = data[
"status"].toString();
167 x.description = data[
"description"].toString();
168 x.abbreviation = data[
"abbreviation"].toString();
169 x.color = data[
"color"].toString();
170 x.closed= data[
"closed"].toBool();
171 x.can_be_run = data[
"can_be_run"].toBool();
172 x.ignored = data[
"ignored"].toBool();
173 if (data.contains(
"next")) {
174 const QVariantList next = data[
"next"].toList();
175 for (
int i=0; i<next.size(); i++) {
176 x.next << Statuses::fromMap(next[i].toMap());
183QVariantMap StatusTemplates::toMap()
const {
186 data[
"status"] = status;
187 data[
"category"] = category;
189 data[
"title"] = title;
190 data[
"description"] = description;
195Tickets Tickets::fromMap(
const QVariantMap& map) {
197 x.ticket = map[
"ticket"];
198 x.category = map[
"category"];
199 x.price = map[
"price"].toDouble();
200 x.date = map[
"date"].toDateTime();
201 x.user = map[
"user"].toInt();
202 x.description = map[
"description"].toString();
203 x.created = map[
"created"].toBool();
204 x.modified = map[
"modified"].toBool();
209QVariantMap Tickets::toMap()
const {
212 data[
"ticket"] = null(ticket);
213 data[
"category"] = null(category);
215 data[
"price"] = price;
216 data[
"description"] = description;
218 data[
"created"] = created;
219 data[
"modified"] = modified;
225QVariantMap TicketsVw::toMap()
const {
226 QVariantMap data = Tickets::toMap();
227 data[
"timesheets"] = toList(timesheets);
228 data[
"statuses"] = toList(statuses);
229 data[
"values"] = toList(values);
230 data[
"files"] = toList(files);
235TicketsVw TicketsVw::fromMap(
const QVariantMap& map) {
237 x.timesheets = TicketTimesheets::fromList(map[
"timesheets"].toList());
238 x.statuses = TicketStatus::fromList(map[
"statuses"].toList());
239 x.values = TicketValues::fromList(map[
"values"].toList());
240 x.files = TicketFiles::fromList(map[
"files"].toList());
245Mutable Mutable::fromMap(
const QVariantMap& data) {
247 x.id = data[
"id"].toInt();
248 x.user = data[
"user"];
249 x.ticket = data[
"ticket"];
254QVariantMap Mutable::toMap()
const {
258 data[
"ticket"] = ticket;
267 x.date_from = data[
"date_from"].toDateTime();
268 x.date_to = data[
"date_to"].toDateTime();
273TicketFiles TicketFiles::fromMap(
const QVariantMap& data) {
275 x.date = data[
"date"].toDateTime();
276 x.name = data[
"name"].toString();
277 x.type = data[
"type"].toString();
278 x.content = QByteArray::fromBase64(data[
"content"].toByteArray());
283TicketValues TicketValues::fromMap(
const QVariantMap& data) {
285 x.date = data[
"date"].toDateTime();
286 x.name = data[
"name"].toString();
287 x.value = data[
"value"];
294TicketStatus TicketStatus::fromMap(
const QVariantMap& data) {
296 x.date = data[
"date"].toDateTime();
297 x.status = data[
"status"].toString();
298 x.description = data[
"description"].toString();
299 x.description2 = data[
"description2"].toMap();
304QVariantMap TicketTimesheets::toMap()
const {
305 QVariantMap data = Mutable::toMap();
306 data[
"date_from"] = date_from;
307 data[
"date_to"] = date_to;
312QVariantMap TicketFiles::toMap()
const {
313 QVariantMap data = Mutable::toMap();
317 data[
"content"] = content.toBase64();
322QVariantMap TicketValues::toMap()
const {
323 QVariantMap data = Mutable::toMap();
326 data[
"value"] = value;
331QVariantMap TicketStatus::toMap()
const {
332 QVariantMap data = Mutable::toMap();
333 data[
"status"] = status;
335 data[
"description"] = description;
336 data[
"description2"] = description2;
337 data[
"status_description"] = status_description;
338 data[
"status_color"] = status_color;
339 data[
"status_can_be_run"] = status_can_be_run;
340 data[
"status_ignored"] = status_ignored;
341 data[
"status_closed"] = status_closed;
346QList<TicketTimesheets> TicketTimesheets::fromList(
const QVariantList& list) {
347 QList<TicketTimesheets> x;
348 QListIterator<QVariant> iterator(list);
349 while (iterator.hasNext()) {
350 x << TicketTimesheets::fromMap(iterator.next().toMap());
356QList<TicketValues> TicketValues::fromList(
const QVariantList& list) {
357 QList<TicketValues> x;
358 QListIterator<QVariant> iterator(list);
359 while (iterator.hasNext()) {
360 x << TicketValues::fromMap(iterator.next().toMap());
366QList<TicketFiles> TicketFiles::fromList(
const QVariantList& list) {
367 QList<TicketFiles> x;
368 QListIterator<QVariant> iterator(list);
369 while (iterator.hasNext()) {
370 x << TicketFiles::fromMap(iterator.next().toMap());
376QList<TicketStatus> TicketStatus::fromList(
const QVariantList& list) {
377 QList<TicketStatus> x;
378 QListIterator<QVariant> iterator(list);
379 while (iterator.hasNext()) {
380 x << TicketStatus::fromMap(iterator.next().toMap());
386QVariantMap OverviewList::toMap()
const {
389 data[
"category"] = category.toMap();
390 data[
"statuses"] = toList(statuses);
396QVariantMap Overview::Days::toMap()
const {
398 data[
"ticket"] = ticket;
399 data[
"description"] = description;
401 data[
"user_name"] = user_name;
403 data[
"hour_price"] = hour_price;
404 data[
"duration"] = duration;
405 data[
"price"] = price;
410QVariantMap Overview::Sum::toMap()
const {
412 data[
"duration"] = duration;
413 data[
"price"] = price;
418QVariantMap Overview::Tickets::toMap()
const {
420 data[
"ticket"] = ticket;
421 data[
"description"] = description;
423 data[
"user_name"] = user_name;
424 data[
"hour_price"] = hour_price;
425 data[
"duration"] = duration;
426 data[
"price"] = price;
427 data[
"status"] = status;
432QVariantMap Overview::TicketsSum::toMap()
const {
434 data[
"ticket"] = ticket;
435 data[
"description"] = description;
436 data[
"duration"] = duration;
437 data[
"price"] = price;
438 data[
"status"] = status;
443QVariantMap Overview::StatusSum::toMap()
const {
445 data[
"duration"] = duration;
446 data[
"price"] = price;
447 data[
"status"] = status;
452QVariantMap Overview::UserSum::toMap()
const {
454 data[
"duration"] = duration;
455 data[
"price"] = price;
456 data[
"user_name"] = user_name;
461QVariantMap Overview::toMap()
const {
463 data[
"category"] = category.toMap();
464 data[
"tickets"] = toList(tickets);
467 xdays[
"records"] = toList(days);
468 xdays[
"sum"] = sum.toMap();
469 data[
"days"] = xdays;
471 QVariantMap xtickets;
472 xtickets[
"records"] = toList(tickets);
473 xtickets[
"sum"] = toList(ticketsSum);
474 data[
"tickets"] = xtickets;
476 data[
"status_sum"] = toList(statusSum);
477 data[
"people_sum"] = toList(userSum);
486QVariantMap CategoriesOverview::toMap()
const {
489 data[
"depth"] = depth;
490 data[
"tickets_count"] = tickets_count;
491 data[
"category"] = category;
492 data[
"description"] = description;
493 data[
"price"] = price;
495 data[
"ordering"] = ordering;
504 x.
status = data[
"status"].toString();
510QVariantMap AppendStatuses::toMap()
const {
512 data[
"categories"] = categories;
513 data[
"recent_status"] = recent_status;
514 data[
"status"] = status;
515 data[
"description"] = description;
520QVariantMap Departments::toMap()
const {
522 data[
"department"] = department;
524 data[
"description"] = description;
529Departments Departments::fromMap(
const QVariantMap& data) {
531 x.department = data[
"department"].toInt();
532 x.abbr = data[
"abbr"].toString();
533 x.description = data[
"description"] .toString();
537QVariantMap EventTypes::toMap()
const {
539 data[
"event_type"] = event_type;
540 data[
"description"] = description;
541 data[
"event_type"] = event_type;
542 data[
"description"] = description;
543 data[
"end_state"] = end_state;
544 data[
"passage"] = passage;
545 data[
"arrival"] = arrival;
546 data[
"vacation"] = vacation;
547 data[
"sick_leave"] = sick_leave;
548 data[
"compensatory_leave"] = compensatory_leave;
549 data[
"business_trip"] = business_trip;
550 data[
"break_time"] = break_time;
551 data[
"unpaid_leave"] = unpaid_leave;
552 data[
"sick_care"] = sick_care;
556EventTypes EventTypes::fromMap(
const QVariantMap& data) {
558 x.event_type = data[
"event_type"].toInt();
559 x.description = data[
"description"].toString();
560 x.end_state = data[
"end_state"].toBool();
561 x.passage = data[
"passage"].toBool();
562 x.arrival = data[
"arrival"].toBool();
563 x.vacation = data[
"vacation"].toBool();
564 x.sick_leave = data[
"sick_leave"].toBool();
565 x.compensatory_leave = data[
"compensatory_leave"].toBool();
566 x.business_trip = data[
"business_trip"].toBool();
567 x.break_time = data[
"break_time"].toBool();
568 x.unpaid_leave = data[
"unpaid_leave"].toBool();
569 x.sick_care = data[
"sick_care"].toBool();
573QVariantMap Events::toMap()
const {
575 data[
"event"] = event;
577 data[
"event_type"] = event_type;
578 data[
"employee"] = employee;
579 data[
"valid"] = valid;
580 data[
"user_edited"] = user_edited;
584Events Events::fromMap(
const QVariantMap& data) {
586 x.event = data[
"event"].toInt();
587 x.date = data[
"date"].toDateTime();
588 x.event_type = data[
"event_type"].toInt();
589 x.employee = data[
"employee"].toInt();
590 x.valid = data[
"valid"].toBool();
591 x.user_edited = data[
"user_edited"].toInt();
595QVariantMap DepartmentHasManager::toMap()
const {
597 data[
"department"] = department;
604 x.department = data[
"department"].toInt();
605 x.user = data[
"user"].toInt();
609QVariantMap DepartmentHasMember::toMap()
const {
611 data[
"department"] = department;
612 data[
"employee"] = employee;
618 x.department = data[
"department"].toInt();
619 x.employee = data[
"employee"].toInt();
623QVariantMap EmployeeCanOpenDoor::toMap()
const {
625 data[
"employee"] = employee;
632 x.employee = data[
"employee"].toInt();
633 x.door = data[
"door"].toInt();
637QVariantMap EmployeeHasRfid::toMap()
const {
639 data[
"employee"] = employee;
646 x.employee = data[
"employee"].toInt();
647 x.rfid = data[
"rfid"].toInt();
Konvertuje null variant na invalid variant - QJsonDocument jinak konvertuje int null hodnoty špatně n...
QVariantList categories
categories which are appended with new statuse
QString description
new status description
QVariantList recent_status
recent statuses