-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.hpp
107 lines (89 loc) · 3.48 KB
/
category.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*****************************************************************************
* Copyright (C) 2021 by Lorenzo Buzzi ([email protected]) *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
*****************************************************************************/
#ifndef CATEGORY_H
#define CATEGORY_H
#include <QCoreApplication>
#include <QDataStream>
namespace category {
class Category;
class CategorySorter;
}
class Category {
Q_DECLARE_TR_FUNCTIONS(Category)
public:
enum class Type
{
MALE = 0,
FEMALE = 1,
RELAY_MF = 2,
RELAY_Y = 3,
RELAY_X = 4
};
enum class Field
{
CTF_FIRST = 0,
CTF_FULL_DESCR = 0,
CTF_SHORT_DESCR = 1,
CTF_TYPE = 2,
CTF_FROM_YEAR = 3,
CTF_TO_YEAR = 4,
CTF_LAST = 4,
CTF_COUNT = 5
};
private:
Type type { Type::MALE };
uint toYear { 0u };
uint fromYear { 0u };
QString fullDescription { "" };
QString shortDescription { "" };
void illegalType(quint32 value) const;
public:
Category() = default;
friend QDataStream &operator<<(QDataStream &out, Category const &category);
friend QDataStream &operator>>(QDataStream &in, Category &category);
uint getFromYear() const;
void setFromYear(uint newFromYear);
QString const &getFullDescription() const;
void setFullDescription(QString const &newFullDescription);
Type getType() const;
void setType(Type const newType);
QString const &getShortDescription() const;
void setShortDescription(QString const &newShortDescription);
uint getToYear() const;
void setToYear(unsigned int newToYear);
uint getWeight() const;
bool isValid() const;
bool operator< (Category const &rhs) const;
bool operator> (Category const &rhs) const;
bool operator<= (Category const &rhs) const;
bool operator>= (Category const &rhs) const;
bool operator== (Category const &rhs) const;
};
Category::Field &operator++(Category::Field &field);
Category::Field operator++(Category::Field &field, int);
class CategorySorter {
private:
static Qt::SortOrder sortingOrder;
static Category::Field sortingField;
public:
static Qt::SortOrder getSortingOrder();
static void setSortingOrder(Qt::SortOrder const &value);
static Category::Field getSortingField();
static void setSortingField(Category::Field const &value);
bool operator() (Category const &lhs, Category const &rhs) const;
};
#endif // CATEGORY_H