-
Notifications
You must be signed in to change notification settings - Fork 1
/
itemdefaults.h
56 lines (46 loc) · 1.17 KB
/
itemdefaults.h
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
#ifndef ITEMDEFAULTS_H
#define ITEMDEFAULTS_H
#include <optional>
#include <QTableWidget>
struct ItemDefaults {
Qt::ItemFlags flags{Qt::ItemIsEnabled};
Qt::Alignment alignment{Qt::AlignCenter};
std::optional<QFont> font{};
std::optional<Qt::CheckState> checked{};
std::optional<QString> text_{};
constexpr auto use(const Qt::ItemFlags &v)
-> ItemDefaults&
{
this->flags = v;
return *this;
}
constexpr auto use(const Qt::Alignment &v)
-> ItemDefaults&
{
this->alignment = v;
return *this;
}
constexpr auto use(const std::optional<QFont> &v)
-> ItemDefaults&
{
this->font = v;
return *this;
}
constexpr auto use(const std::optional<Qt::CheckState> &v)
-> ItemDefaults&
{
this->checked = v;
return *this;
}
constexpr auto text(const QString& v)
-> ItemDefaults&
{
this->text_ = v;
return *this;
}
};
auto createdItem(QTableWidget* parent,
int row, int column,
const ItemDefaults& defaults = ItemDefaults{})
-> QTableWidgetItem *;
#endif // ITEMDEFAULTS_H