radioapp/radiouiengine/src/radiostationmodel.cpp
changeset 54 a8ba0c289b44
parent 51 bbebb0235466
child 57 21be958eb3ce
--- a/radioapp/radiouiengine/src/radiostationmodel.cpp	Mon Sep 20 18:04:48 2010 +0300
+++ b/radioapp/radiouiengine/src/radiostationmodel.cpp	Tue Oct 05 09:31:22 2010 +0300
@@ -449,6 +449,28 @@
         endRemoveRows();
     }
 }
+/*!
+ * Removes stations based on model indices
+ */
+void RadioStationModel::removeByModelIndices( QModelIndexList& indices, bool removefavorite )
+{
+    // List needs to be sorted and indices needs to go throught from largest to smallest.
+    // This is for keeping QmodelIndexing in sync after begin- and endremoverows, which
+    // are needed for each item separately
+    qSort( indices );
+    QModelIndexList::const_iterator iter = indices.constEnd();
+    QModelIndexList::const_iterator begin = indices.constBegin();
+    RadioStation station;  
+    while( iter != begin ) {
+       iter--;
+       station = stationAt( (*iter).row() );
+       if( removefavorite ) {
+          setFavoriteByPreset( station.presetIndex(), false );   
+      } else {                     
+          removeStation( station );
+      }                     
+    }
+}
 
 /*!
  * Public slot