use const & for foreach "iterators" when the "iterator" is an object to avoid a call to the copy-constructor
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=758094
KEduVocExpression::KEduVocExpression( const QStringList & translations)
: d( new KEduVocExpressionPrivate( this ) )
{
- foreach ( QString translation, translations ) {
+ foreach ( const QString &translation, translations ) {
setTranslation(d->m_translations.count(), translation);
}
}
bool KEduVocKvtml2Writer::writeTenses( QDomElement &tensesElement )
{
- foreach( QString tense, m_doc->tenseDescriptions() ) {
+ foreach( const QString &tense, m_doc->tenseDescriptions() ) {
if ( !( tense.isNull() ) ) {
tensesElement.appendChild( newTextElement( KVTML_TENSE, tense ) );
}
}
// <usage></usage>
- foreach( QString usage, translation->usages() ) {
+ foreach( const QString &usage, translation->usages() ) {
translationElement.appendChild( newTextElement( KVTML_USAGE, usage ) );
}
}
// conjugation
- foreach ( QString tense, translation->conjugationTenses() ) {
+ foreach ( const QString &tense, translation->conjugationTenses() ) {
QDomElement thisElement = m_domDoc.createElement( KVTML_CONJUGATION );
writeConjugation( thisElement, translation->conjugation(tense), tense );
translationElement.appendChild( thisElement );
</multiplechoice>
*/
{
- foreach ( QString choice, translation->multipleChoice() ) {
+ foreach ( const QString &choice, translation->multipleChoice() ) {
multipleChoiceElement.appendChild( newTextElement( KVTML_CHOICE, choice ) );
}
return true;
<< i18nc( "The grammatical type of a word", "Preposition" )
<< i18nc( "The grammatical type of an entry", "Question" );
- foreach (QString typeName, wordTypeNames) {
+ foreach (const QString &typeName, wordTypeNames) {
KEduVocWordType* wordType = new KEduVocWordType(typeName, parent);
parent->appendChildContainer(wordType);
m_userdefinedTypeCounter++;
QDomElement domElementType = m_domDoc.createElement(KV_TYPE_GRP);
int count = 1;
- foreach(QString type, m_doc->typeDescriptions())
+ foreach(const QString &type, m_doc->typeDescriptions())
{
if (!(type.isNull()) )
{
QDomElement domElementTense = m_domDoc.createElement( KV_TENSE_GRP );
int count = 1;
- foreach( QString tense, m_doc->tenseDescriptions() ) {
+ foreach( const QString &tense, m_doc->tenseDescriptions() ) {
if ( !( tense.isNull() ) ) {
QDomElement domElementDesc = m_domDoc.createElement( KV_TENSE_DESC );
QDomText domTextDesc = m_domDoc.createTextNode( tense );
QDomElement domElementUsage = m_domDoc.createElement(KV_USAGE_GRP);
int count = 1;
- foreach(QString usage, m_doc->usageDescriptions())
+ foreach(const QString &usage, m_doc->usageDescriptions())
{
if (!(usage.isNull()))
{
// curr_conjug.cleanUp();
QDomElement domElementConjug = m_domDoc.createElement( KV_CONJUG_GRP );
- foreach ( QString tense, translation.conjugationTenses() ) {
+ foreach ( const QString &tense, translation.conjugationTenses() ) {
QDomElement domElementType = m_domDoc.createElement( KV_CON_TYPE );
domElementType.setAttribute( KV_CON_NAME, m_compability.oldTense(tense) );
KEduVocMultipleChoice::KEduVocMultipleChoice( const QStringList &choices )
: d( new KEduVocMultipleChoicePrivate )
{
- foreach ( QString choice, choices ) {
+ foreach ( const QString &choice, choices ) {
// use appendChoice to check for empty entries
appendChoice(choice);
}
QVariant Element::dataAsVariant( ChemicalDataObject::BlueObelisk type ) const
{
- foreach( ChemicalDataObject o, dataList ) {
+ foreach( const ChemicalDataObject &o, dataList ) {
if ( o.type() == type )
return o.value();
}
QString Element::dataAsString(ChemicalDataObject::BlueObelisk type) const
{
- foreach( ChemicalDataObject o, dataList ) {
+ foreach( const ChemicalDataObject &o, dataList ) {
if ( o.type() == type )
return o.valueAsString();
}
QList<ChemicalDataObject> list = e->data();
//Test: give me all data available
- foreach( ChemicalDataObject o, list ){
+ foreach( const ChemicalDataObject &o, list ){
QString unit = o.unitAsString();
if ( unit == "bo:noUnit" )
unit = "";