| 1 |
#if defined(Hiro_ComboButton) |
| 2 |
|
| 3 |
namespace hiro { |
| 4 |
|
| 5 |
auto pComboButtonItem::construct() -> void { |
| 6 |
if(auto parent = _parent()) { |
| 7 |
parent->lock(); |
| 8 |
parent->qtComboButton->addItem(""); |
| 9 |
_setState(); |
| 10 |
parent->unlock(); |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
auto pComboButtonItem::destruct() -> void { |
| 15 |
if(auto parent = _parent()) { |
| 16 |
parent->lock(); |
| 17 |
parent->qtComboButton->removeItem(self().offset()); |
| 18 |
parent->unlock(); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
auto pComboButtonItem::setIcon(const image& icon) -> void { |
| 23 |
_setState(); |
| 24 |
} |
| 25 |
|
| 26 |
auto pComboButtonItem::setSelected() -> void { |
| 27 |
_setState(); |
| 28 |
} |
| 29 |
|
| 30 |
auto pComboButtonItem::setText(const string& text) -> void { |
| 31 |
_setState(); |
| 32 |
} |
| 33 |
|
| 34 |
auto pComboButtonItem::_parent() -> maybe<pComboButton&> { |
| 35 |
if(auto parent = self().parentComboButton()) { |
| 36 |
if(auto self = parent->self()) return *self; |
| 37 |
} |
| 38 |
return nothing; |
| 39 |
} |
| 40 |
|
| 41 |
auto pComboButtonItem::_setState() -> void { |
| 42 |
if(auto parent = _parent()) { |
| 43 |
auto lock = parent->acquire(); |
| 44 |
parent->qtComboButton->setItemIcon(self().offset(), CreateIcon(state().icon)); |
| 45 |
if(state().selected) parent->qtComboButton->setCurrentIndex(self().offset()); |
| 46 |
parent->qtComboButton->setItemText(self().offset(), QString::fromUtf8(state().text)); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
#endif |