Debian Codegraph @

hiro/qt/widget/combo-button.cpp

raw
1 #if defined(Hiro_ComboButton)
2
3 namespace hiro {
4
5 auto pComboButton::construct() -> void {
6 qtWidget = qtComboButton = new QtComboButton(*this);
7 qtComboButton->connect(qtComboButton, SIGNAL(currentIndexChanged(int)), SLOT(onChange(int)));
8
9 pWidget::construct();
10 }
11
12 auto pComboButton::destruct() -> void {
13 if(Application::state().quit) return; //TODO: hack
14 delete qtComboButton;
15 qtWidget = qtComboButton = nullptr;
16 }
17
18 auto pComboButton::append(sComboButtonItem item) -> void {
19 }
20
21 auto pComboButton::minimumSize() const -> Size {
22 signed maximumWidth = 0;
23 for(auto& item : state().items) {
24 maximumWidth = max(maximumWidth, pFont::size(qtWidget->font(), item->state.text).width());
25 }
26 auto size = pFont::size(qtWidget->font(), " ");
27 return {maximumWidth + 32, size.height() + 12};
28 }
29
30 auto pComboButton::remove(sComboButtonItem item) -> void {
31 }
32
33 auto pComboButton::reset() -> void {
34 auto lock = acquire();
35 while(qtComboButton->count()) qtComboButton->removeItem(0);
36 }
37
38 auto QtComboButton::onChange(int offset) -> void {
39 for(auto& item : p.state().items) {
40 item->state.selected = false;
41 }
42 if(auto item = p.self().item(offset)) {
43 item->state.selected = true;
44 }
45 if(!p.locked()) p.self().doChange();
46 }
47
48 }
49
50 #endif