Debian Codegraph @

hiro/qt/widget/table-view-item.cpp

raw
1 #if defined(Hiro_TableView)
2
3 namespace hiro {
4
5 auto pTableViewItem::construct() -> void {
6 }
7
8 auto pTableViewItem::destruct() -> void {
9 if(auto parent = _parent()) {
10 auto lock = parent->acquire();
11 if(qtItem) {
12 delete qtItem;
13 qtItem = nullptr;
14 }
15 }
16 }
17
18 auto pTableViewItem::append(sTableViewCell cell) -> void {
19 _setState();
20 }
21
22 auto pTableViewItem::remove(sTableViewCell cell) -> void {
23 _setState();
24 }
25
26 auto pTableViewItem::setAlignment(Alignment alignment) -> void {
27 _setState();
28 }
29
30 auto pTableViewItem::setBackgroundColor(Color color) -> void {
31 _setState();
32 }
33
34 auto pTableViewItem::setFont(const Font& font) -> void {
35 _setState();
36 }
37
38 auto pTableViewItem::setForegroundColor(Color color) -> void {
39 _setState();
40 }
41
42 auto pTableViewItem::setSelected(bool selected) -> void {
43 _setState();
44 }
45
46 auto pTableViewItem::_parent() -> maybe<pTableView&> {
47 if(auto parent = self().parentTableView()) {
48 if(auto delegate = parent->self()) return *delegate;
49 }
50 return nothing;
51 }
52
53 auto pTableViewItem::_setState() -> void {
54 if(auto parent = _parent()) {
55 auto lock = parent->acquire();
56 qtItem->setSelected(state().selected);
57 if(state().selected) {
58 parent->qtTableView->setCurrentItem(qtItem);
59 }
60 for(auto& cell : state().cells) {
61 if(auto self = cell->self()) self->_setState();
62 }
63 }
64 }
65
66 }
67
68 #endif