qtinternetradio/ui/src/irsonghistorymodel.cpp
changeset 5 0930554dc389
parent 3 ee64f059b8e1
child 8 3b03c28289e6
equal deleted inserted replaced
3:ee64f059b8e1 5:0930554dc389
   101     }
   101     }
   102 
   102 
   103     return NULL;
   103     return NULL;
   104 }
   104 }
   105 
   105 
   106 void IRSongHistoryModel::clearAllList()
   106 void IRSongHistoryModel::clearList()
   107 {
   107 {
   108     while (!mSongHistoryList.isEmpty())
   108     while (!mSongHistoryList.isEmpty())
   109     {
   109     {
   110         IRQSongInfo *firstItem = mSongHistoryList.takeFirst();
   110         IRQSongInfo *firstItem = mSongHistoryList.takeFirst();
   111         delete firstItem;
   111         delete firstItem;
   112     }
   112     }
   113      
   113 
       
   114     mHistoryEngine->clearAllSongHistory();
       
   115 
   114     emit modelChanged();
   116     emit modelChanged();
   115 }
   117 }
   116 
   118 
   117 bool IRSongHistoryModel::checkSongHistoryUpdate()
   119 bool IRSongHistoryModel::checkSongHistoryUpdate()
   118 {     
   120 {     
   124 void IRSongHistoryModel::getAllList()
   126 void IRSongHistoryModel::getAllList()
   125 {
   127 {
   126     mHistoryEngine->getAllSongHistory(mSongHistoryList);
   128     mHistoryEngine->getAllSongHistory(mSongHistoryList);
   127 
   129 
   128     emit modelChanged();
   130     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 }
   131 }
   141 
   132 
   142 void IRSongHistoryModel::setOrientation(Qt::Orientation aOrientation)
   133 void IRSongHistoryModel::setOrientation(Qt::Orientation aOrientation)
   143 {
   134 {
   144     mOrientation = aOrientation;
   135     mOrientation = aOrientation;
   145 }
   136 }
       
   137 
       
   138 bool IRSongHistoryModel::deleteOneItem(int aIndex)
       
   139 {
       
   140     bool ret = mHistoryEngine->deleteOneSongHistoryItem(aIndex);
       
   141 
       
   142     if( !ret )
       
   143     {
       
   144         return false;                
       
   145     }
       
   146     
       
   147     beginRemoveRows(QModelIndex(), aIndex, aIndex);
       
   148     mSongHistoryList.removeAt(aIndex);
       
   149     endRemoveRows(); 
       
   150     
       
   151     emit modelChanged();    
       
   152     return true;
       
   153 }