void TemplKatalogListView::addCalcParts( FloskelTemplate *tmpl ) { QTreeWidgetItem *item = tmpl->getListViewItem(); if( ! item ) return; CalcPartList parts = tmpl->getCalcPartsList(); CalcPartListIterator it(parts); while( it.hasNext() ) { CalcPart *cp = it.next(); QString title = cp->getName(); QString type = cp->getType(); kDebug() << "Type is " << type << endl; if( type == KALKPART_TIME ) { TimeCalcPart *zcp = static_cast<TimeCalcPart*>(cp); StdSatz stdsatz = zcp->getStundensatz(); title = QString( "%1, %2 Min. %3" ).arg( cp->getName() ) .arg( QString::number( zcp->getMinuten() ) ) .arg( stdsatz.getName() ); } QStringList list; list << title; list << cp->kosten().toString( catalog()->locale() ); list << cp->getType(); QTreeWidgetItem *cpItem = new QTreeWidgetItem( item, list ); cpItem->setDisabled(true); } }
/* * Attention: returning non deep copy here ! */ CalcPartList CalcPartList::decoupledCalcPartsList() { CalcPartList parts; CalcPart *newcp = 0; CalcPart *cp; QListIterator<CalcPart*> i( *this ); while( i.hasNext()) { cp = i.next(); if ( cp->getType() == KALKPART_FIX ) { newcp = new FixCalcPart( ); *newcp = *( static_cast<FixCalcPart*>( cp ) ); } else if ( cp->getType ()== KALKPART_TIME ) { newcp = new TimeCalcPart( ); *newcp = *( static_cast<TimeCalcPart*>( cp ) ); } else if ( cp->getType() == KALKPART_MATERIAL ) { newcp = new MaterialCalcPart( ); *newcp = *( static_cast<MaterialCalcPart*>( cp ) ); } if ( newcp ) newcp->setDbID( -1 ); parts.append( newcp ); } return( parts ); }
Geld CalcPartList::costPerCalcPart( const QString& calcPart ) { CalcPart *cp; Geld g; /* suche nach einer speziellen Kalkulationsart */ QListIterator<CalcPart*> i( *this ); while( i.hasNext()) { cp = i.next(); if( ( calcPart == ALL_KALKPARTS || calcPart == cp->getType() ) && ! cp->isToDelete() ) { g += cp->basisKosten(); } } return g; }
/* * Attention: returning non deep copy here ! */ CalcPartList CalcPartList::getCalcPartsList( const QString& calcPart ) { CalcPartList parts; if( calcPart == ALL_KALKPARTS ) return *this; else { CalcPart *cp; /* suche nach einer speziellen Kalkulationsart */ QListIterator<CalcPart*> i( *this ); while( i.hasNext()) { cp = i.next(); if( calcPart == cp->getType() && ! cp->isToDelete() ) { parts.append(cp); } } } return( parts ); }