Debian Codegraph @

phoenix/qt/action/radio-item.cpp

raw
1 namespace phoenix {
2
3 void pRadioItem::setChecked() {
4 locked = true;
5 for(auto& item : radioItem.state.group) {
6 bool checkState = item.p.qtAction == qtAction;
7 item.state.checked = checkState;
8 item.p.qtAction->setChecked(checkState);
9 }
10 locked = false;
11 }
12
13 void pRadioItem::setGroup(const group<RadioItem>& group) {
14 }
15
16 void pRadioItem::setText(string text) {
17 qtAction->setText(QString::fromUtf8(text));
18 }
19
20 void pRadioItem::constructor() {
21 qtAction = new QAction(0);
22 qtGroup = new QActionGroup(0);
23 qtAction->setCheckable(true);
24 qtAction->setActionGroup(qtGroup);
25 qtAction->setChecked(true);
26 connect(qtAction, SIGNAL(triggered()), SLOT(onActivate()));
27 }
28
29 void pRadioItem::destructor() {
30 if(action.state.menu) action.state.menu->remove(radioItem);
31 delete qtAction;
32 qtAction = nullptr;
33 }
34
35 void pRadioItem::onActivate() {
36 if(!radioItem.state.checked) {
37 setChecked();
38 if(!locked && radioItem.onActivate) radioItem.onActivate();
39 }
40 }
41
42 }