void ParametersToolBox::setupUi() { this->removeItem(0); // remove dummy page used in .ui QWidget * currentItem = 0; const ParametersMap & parameters = Settings::getParameters(); for(ParametersMap::const_iterator iter=parameters.constBegin(); iter!=parameters.constEnd(); ++iter) { QStringList splitted = iter.key().split('/'); QString group = splitted.first(); QString name = splitted.last(); if(currentItem == 0 || currentItem->objectName().compare(group) != 0) { currentItem = new QWidget(this); this->addItem(currentItem, group); currentItem->setObjectName(group); QVBoxLayout * layout = new QVBoxLayout(currentItem); currentItem->setLayout(layout); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); layout->addSpacerItem(new QSpacerItem(0,0, QSizePolicy::Minimum, QSizePolicy::Expanding)); addParameter(layout, iter.key(), iter.value()); } else { addParameter((QVBoxLayout*)currentItem->layout(), iter.key(), iter.value()); } } updateParametersVisibility(); }
void ParametersToolBox::setupUi(const QSet<QString> & ignoredGroups) { ignoredGroups_ = ignoredGroups; QWidget * currentItem = 0; const ParametersMap & parameters = Parameters::getDefaultParameters(); QStringList groups; for(ParametersMap::const_iterator iter=parameters.begin(); iter!=parameters.end(); ++iter) { QStringList splitted = QString::fromStdString(iter->first).split('/'); QString group = splitted.first(); if(!ignoredGroups_.contains(group)) { QString name = splitted.last(); if(currentItem == 0 || currentItem->objectName().compare(group) != 0) { groups.push_back(group); QScrollArea * area = new QScrollArea(this); stackedWidget_->addWidget(area); currentItem = new QWidget(); currentItem->setObjectName(group); QVBoxLayout * layout = new QVBoxLayout(currentItem); layout->setSizeConstraint(QLayout::SetMinimumSize); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); area->setWidget(currentItem); addParameter(layout, iter->first, iter->second); } else { addParameter((QVBoxLayout*)currentItem->layout(), iter->first, iter->second); } } } comboBox_->addItems(groups); connect(comboBox_, SIGNAL(currentIndexChanged(int)), stackedWidget_, SLOT(setCurrentIndex(int))); updateParametersVisibility(); }