qtinternetradio/ui/src/irsonghistorymodel.cpp
branchGCC_SURGE
changeset 13 c9471d26c7f2
parent 12 608f67c22514
child 17 38bbf2dcd608
equal deleted inserted replaced
9:bfc95e24a059 13:c9471d26c7f2
    66         QVariantList list;      
    66         QVariantList list;      
    67              
    67              
    68         QString artistName = mSongHistoryList.at(row)->getArtistName().trimmed();
    68         QString artistName = mSongHistoryList.at(row)->getArtistName().trimmed();
    69         if( "" == artistName )
    69         if( "" == artistName )
    70         {
    70         {
    71             artistName = hbTrId("txt_irad_list_unknown_artist");
    71 #ifdef SUBTITLE_STR_BY_LOCID
       
    72             artistName = hbTrId("txt_irad_list_unknown_artist_p");
       
    73 #else
       
    74             artistName = hbTrId("Unknown artist");            
       
    75 #endif
    72         }
    76         }
    73       
    77       
    74         QString songName = mSongHistoryList.at(row)->getSongName().trimmed();
    78         QString songName = mSongHistoryList.at(row)->getSongName().trimmed();
    75         if( "" == songName )
    79         if( "" == songName )
    76         {
    80         {
    77             songName = hbTrId("txt_irad_list_unknown_song");
    81 #ifdef SUBTITLE_STR_BY_LOCID
       
    82             songName = hbTrId("txt_irad_list_unknown_song_p");
       
    83 #else
       
    84             songName = hbTrId("Unknown song");
       
    85 #endif
    78         }
    86         }
    79         
    87         
       
    88         QString stationName = mSongHistoryList.at(row)->getStationName().trimmed();       
    80         if (Qt::Vertical == mOrientation)
    89         if (Qt::Vertical == mOrientation)
    81         {
    90         {
    82             list.append("<" + artistName + ">");
    91             list.append(artistName);
    83             list.append("<" + songName + ">");
    92             list.append(songName);
    84         }
    93         }
    85         else
    94         else
    86         {
    95         {
    87             list.append("<" + artistName +"> - <" + songName + ">");
    96             list.append(artistName + " - " + songName);
    88             list.append("<Not ready>");
    97             list.append(stationName);
    89         }
    98         }
    90         return list;
    99         return list;
    91     }
   100     }
    92 
   101 
    93     return QVariant();
   102     return QVariant();
   101     }
   110     }
   102 
   111 
   103     return NULL;
   112     return NULL;
   104 }
   113 }
   105 
   114 
   106 void IRSongHistoryModel::clearAllList()
   115 void IRSongHistoryModel::clearList()
   107 {
   116 {
   108     while (!mSongHistoryList.isEmpty())
   117     while (!mSongHistoryList.isEmpty())
   109     {
   118     {
   110         IRQSongInfo *firstItem = mSongHistoryList.takeFirst();
   119         IRQSongInfo *firstItem = mSongHistoryList.takeFirst();
   111         delete firstItem;
   120         delete firstItem;
   112     }
   121     }
   113      
   122 
       
   123     mHistoryEngine->clearAllSongHistory();
       
   124 
   114     emit modelChanged();
   125     emit modelChanged();
   115 }
   126 }
   116 
   127 
   117 bool IRSongHistoryModel::checkSongHistoryUpdate()
   128 bool IRSongHistoryModel::checkSongHistoryUpdate()
   118 {     
   129 {     
   124 void IRSongHistoryModel::getAllList()
   135 void IRSongHistoryModel::getAllList()
   125 {
   136 {
   126     mHistoryEngine->getAllSongHistory(mSongHistoryList);
   137     mHistoryEngine->getAllSongHistory(mSongHistoryList);
   127 
   138 
   128     emit modelChanged();
   139     emit modelChanged();
   129 } 
       
   130 
       
   131 void IRSongHistoryModel::clearHisotrySongDB()
       
   132 {
       
   133     while (!mSongHistoryList.isEmpty())
       
   134     {
       
   135         IRQSongInfo *firstItem = mSongHistoryList.takeFirst();
       
   136         delete firstItem;
       
   137     }
       
   138     mHistoryEngine->clearAllSongHistory();     
       
   139     emit modelChanged();
       
   140 }
   140 }
   141 
   141 
   142 void IRSongHistoryModel::setOrientation(Qt::Orientation aOrientation)
   142 void IRSongHistoryModel::setOrientation(Qt::Orientation aOrientation)
   143 {
   143 {
   144     mOrientation = aOrientation;
   144     mOrientation = aOrientation;
   145 }
   145 }
       
   146 
       
   147 bool IRSongHistoryModel::deleteOneItem(int aIndex)
       
   148 {
       
   149     bool ret = mHistoryEngine->deleteOneSongHistoryItem(aIndex);
       
   150 
       
   151     if( !ret )
       
   152     {
       
   153         return false;                
       
   154     }
       
   155     
       
   156     beginRemoveRows(QModelIndex(), aIndex, aIndex);
       
   157     mSongHistoryList.removeAt(aIndex);
       
   158     endRemoveRows(); 
       
   159     
       
   160     emit modelChanged();    
       
   161     return true;
       
   162 }