radioapp/radiopresetstorage/src/radiopresetstorage_win32.cpp
changeset 14 63aabac4416d
parent 13 46974bebc798
child 37 451b2e1545b2
equal deleted inserted replaced
13:46974bebc798 14:63aabac4416d
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <qstring>
    19 #include <QString>
    20 #include <qsettings>
    20 #include <QSettings>
    21 #include <qdatastream>
    21 #include <QDataStream>
    22 
    22 
    23 // User includes
    23 // User includes
    24 #include "radiopresetstorage.h"
    24 #include "radiopresetstorage.h"
    25 #include "radiopresetstorage_win32_p.h"
    25 #include "radiopresetstorage_win32_p.h"
    26 #include "radiostationif.h"
    26 #include "radiostationif.h"
   150  *
   150  *
   151  */
   151  */
   152 bool RadioPresetStorage::deletePreset( int presetIndex )
   152 bool RadioPresetStorage::deletePreset( int presetIndex )
   153 {
   153 {
   154     Q_D( RadioPresetStorage );
   154     Q_D( RadioPresetStorage );
   155     int index = d->mBookKeeping.indexOf( presetIndex );
   155     if ( presetIndex > -1 ) {
   156     if ( index > -1 ) {
   156         int index = d->mBookKeeping.indexOf( presetIndex );
   157         d->mBookKeeping.remove( index, 1 );
   157         if ( index > -1 ) {
   158         d->mSettings->remove( makeKey( presetIndex ) );
   158             d->mBookKeeping.remove( index, 1 );
   159         d->removeIndex( presetIndex );
   159             d->mSettings->remove( makeKey( presetIndex ) );
       
   160             d->removeIndex( presetIndex );
       
   161             return true;
       
   162         }
       
   163     } else if ( presetIndex == -1 ) {
       
   164         for ( int i = d->mBookKeeping.count() - 1; i >= 0; --i ) {
       
   165             d->mSettings->remove( makeKey( d->mBookKeeping.at( i ) ) );
       
   166         }
       
   167         d->mBookKeeping.clear();
   160         return true;
   168         return true;
   161     }
   169     }
   162     return false;
   170     return false;
   163 }
   171 }
   164 
   172