/** * Add a new group definition to the ELSTABLE. Returns 0 if OK, -1 if parsing FORMULA * fails. Assumes the syntax of grpname is correct. */ QString KMolCalc::defineGroup (const QString& grpname, const QString& formula) { ElementList* els = new ElementList(grpname); QString error = readGroup(formula, els); if (error != "OK") return error; if (els->contains(grpname)) return QString("Can't define a group recursively!\n"); elstable->replace(grpname, els); return QString("OK"); }
void TimeEntryDialog::setElementList( ElementList list ) { if( list.isEmpty() ) return; // Go through the element list and make sure that // each element is in the same project and has // the same asset type ElementList valid; ElementList invalid; AssetType type; Project p; foreach( Element e, list ) { if( p.isRecord() && e.project() != p ) continue; QVariant v = e.getValue( "allowTime" ); if( v.toBool() || (v.isNull() && (e.children().size()==0) ) ) { if( !type.isRecord() ) { type = e.assetType(); p = e.project(); } else if( e.assetType() != type ) continue; if( !valid.contains( e ) ) valid += e; } else invalid += e; } mAssetTree->setSelection( RecordList() ); if( valid.isEmpty() ) { if( !invalid.isEmpty() ) { setProject( invalid[0].project() ); QStringList sl; foreach( Element e, invalid ) sl += e.displayName(true); mAssetFilterEdit->setText( sl.join(",") ); } } else { Element first = valid[0]; QStringList sl; foreach( Element e, valid ) sl += e.displayName(true); mAssetFilterEdit->setText( sl.join(",") ); if( first.isRecord() ) { setProject( first.project() ); setAssetType( type ); mAssetTree->setSelection( valid ); mAssetTree->scrollTo( first ); } } }