36 #include <QButtonGroup>
37 #include <QVBoxLayout>
38 #include <QHBoxLayout>
39 #include <QGridLayout>
46 mSelectionList(selectionList),
47 mButtonGroup(new QButtonGroup(parent))
49 if (orientation==Qt::Vertical)
50 mLayout =
new QVBoxLayout(
this);
52 mLayout =
new QHBoxLayout(
this);
54 this->setTitle(title);
56 this->populate(exclusive);
65 QList<QAbstractButton*> applicationButtonList = mButtonGroup->buttons();
66 foreach(QAbstractButton* button, applicationButtonList)
68 if(button->isChecked())
69 retval << button->text();
76 this->filter(selectedlist);
81 QList<QAbstractButton*> applicationButtonList = mButtonGroup->buttons();
82 foreach(QAbstractButton* button, applicationButtonList)
84 button->setEnabled(value);
88 void SelectionGroupBox::populate(
bool exclusive)
90 mButtonGroup->setExclusive(exclusive);
91 foreach(QString
string, mSelectionList)
96 string =
string.toLower();
97 string[0] =
string[0].toUpper();
99 QCheckBox* box =
new QCheckBox(
string);
100 mButtonGroup->addButton(box);
101 mLayout->addWidget(box);
105 connect(box, SIGNAL(clicked(
bool)),
this, SIGNAL(
userClicked()));
108 QHBoxLayout* hbox =
dynamic_cast<QHBoxLayout*
>(mLayout);
113 void SelectionGroupBox::filter(QStringList filter)
115 bool exclusive = mButtonGroup->exclusive();
117 mButtonGroup->setExclusive(
false);
118 QList<QAbstractButton*> applicationButtonList = mButtonGroup->buttons();
119 foreach(QAbstractButton* button, applicationButtonList)
121 bool on = filter.contains(button->text(), Qt::CaseInsensitive);
122 button->setChecked(on);
124 mButtonGroup->setExclusive(exclusive);
void setEnabledButtons(bool value)
enables or disables all buttons
virtual QStringList getSelected()
get a list of selected button text
virtual ~SelectionGroupBox()
void userClicked()
emitted when a user has clicked a button inside the groupbox
virtual void setSelected(QStringList selectedlist)
set the selected buttons
void selectionChanged()
emitted when the selection of application changed
SelectionGroupBox(QString title, QStringList selectionList, Qt::Orientation orientation, bool exclusive=false, QWidget *parent=NULL)