From 43184cf8d4458fe622861f197e2c59068c79bf3c Mon Sep 17 00:00:00 2001 From: mkossick Date: Thu, 12 Jul 2007 09:32:29 +0000 Subject: [PATCH] use the Qt4 foreach macro instead of the old ones defined in amarok.h git-svn-id: svn+ssh://ianmonroe@svn.kde.org/home/kde/trunk/extragear/multimedia/amarok@686860 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- HACKING | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/HACKING b/HACKING index 9f9011021..c6efb339c 100644 --- a/HACKING +++ b/HACKING @@ -23,22 +23,27 @@ Formatting although brackets are not needed for single statements. * Function and class definitions have their brackets on separate lines * A function implementation's return type is on its own line. -* amarok.h contains some helpful macros, foreach and foreachType. Use them, - they improve coding style and readability. * CamelCase.{cpp,h} style file names. +* Qt 4 includes a foreach keyword which makes it very easy to iterate over all + elements of a container. Example: | bool - | MyClass::myMethod( QPtrList items, const QString &name ) + | MyClass::myMethod( QStringList list, const QString &name ) | { - | if( items.isEmpty() ) + | if( list.isEmpty() ) | return false; | - | foreachType( QPtrList, items ) + | /* + | Define the temporary variable like this to restrict its scope + | when you do not need it outside the loop. Let the compiler + | optimise it. + | */ + | foreach( QString string, list ) | { - | (*it)->setText( 0, name ); - | debug() << "Setting item name: " << name << endl; + | + | debug() << "Current string is " << string << endl; | } | } -- 2.11.4.GIT