virtual QList<QStandardItem *> valueWalker(ExtcapValueList list, QStringList &defaults) { ExtcapValueList::iterator iter = list.begin(); QList<QStandardItem *> items; while ( iter != list.end() ) { QStandardItem * item = new QStandardItem((*iter).value()); if ( (*iter).enabled() == false ) { item->setSelectable(false); } else item->setSelectable(true); item->setData((*iter).call(), Qt::UserRole); if ((*iter).isDefault()) defaults << (*iter).call(); item->setEditable(false); QList<QStandardItem *> childs = valueWalker((*iter).children(), defaults); if ( childs.length() > 0 ) item->appendRows(childs); items << item; ++iter; } return items; }
ExtcapValueList ExtcapArgument::loadValues(QString parent) { if (_argument == 0 || _argument->values == 0 ) return ExtcapValueList(); GList * walker = 0; extcap_value * v; ExtcapValueList elements; for (walker = g_list_first((GList *)(_argument->values)); walker != NULL ; walker = walker->next) { v = (extcap_value *) walker->data; if (v == NULL || v->display == NULL || v->call == NULL ) break; QString valParent(v->parent == 0 ? "" : QString().fromUtf8(v->parent)); if ( parent.compare(valParent) == 0 ) { QString display = QString().fromUtf8(v->display); QString call = QString().fromUtf8(v->call); ExtcapValue element = ExtcapValue(display, call, v->enabled == (gboolean)TRUE, v->is_default == (gboolean)TRUE); element.setChildren(this->loadValues(call)); elements.append(element); } } return elements; }
ExtcapArgument::ExtcapArgument(extcap_arg * argument, QObject *parent) : QObject(parent), _argument(argument), _default(0) { if ( _argument->values != 0 ) { ExtcapValueList elements = loadValues(QString("")); if ( elements.length() > 0 ) values.append(elements); } }
ExtcapArgument::ExtcapArgument(const ExtcapArgument &obj) : QObject(obj.parent()), _argument(obj._argument), _label(0), label_style(QString("QLabel { color: %1; }")) { if ( _argument->values != 0 ) { ExtcapValueList elements = loadValues(QString("")); if ( elements.length() > 0 ) values.append(elements); } }
ExtcapArgument::ExtcapArgument(extcap_arg * argument, QObject *parent) : QObject(parent), _argument(argument), _label(0), label_style(QString("QLabel { color: %1; }")) { if ( _argument->values != 0 ) { ExtcapValueList elements = loadValues(QString("")); if ( elements.length() > 0 ) values.append(elements); } }
void ExtcapValue::setChildren(ExtcapValueList children) { ExtcapValueList::iterator iter = children.begin(); while ( iter != children.end() ) { (*iter)._depth = _depth + 1; ++iter; } _children.append(children); }
bool ExtcapArgument::reloadValues() { if ( ! qobject_cast<ExtcapOptionsDialog*> ( parent() ) ) return false; ExtcapOptionsDialog * dialog = qobject_cast<ExtcapOptionsDialog*>(parent()); ExtcapValueList list = dialog->loadValuesFor(_argument->arg_num, _argument->call); if ( list.size() > 0 ) { values.clear(); values << list; return true; } return false; }