void ViewModel::disconnectModel(Model* model) { if (model) { if (!disconnect(model, SIGNAL(listContentChanged()), this, SLOT(onModelListContentChanged()))) { qDebug() << "Unabled to disconnect from model listChanged signal"; } } }
void KNMusicOnlineLyricsDownloader::onActionDownloadFinished( uint identifier, const KNMusicDetailInfo &detailInfo, QList<KNMusicLyricsDownloader::KNMusicLyricsDetails> lyricsList) { //Check the identifier first. if(identifier!=m_identifier || detailInfo.textLists[Name]!=m_workingDetailInfo.textLists[Name] || detailInfo.textLists[Artist]!=m_workingDetailInfo.textLists[Artist]) { //This signal is not for me. return; } //Increase the counter of the completed downloader. ++m_completeDownloader; //Emit the server changed signal. emit serverChanged(m_completeDownloader, m_downloaders.size()); //Check out the cancel flag. if(m_cancelFlag) { //Reset the running flag. m_running=false; //Emit signal. emit downloadCancel(); //Won't download more. return; } //Check the lyrics list size and emit signal. if(!lyricsList.isEmpty()) { //Increase the new lyrics list to the cached list. m_lyricsList.append(lyricsList); //Sort the lyrics list right now. std::sort(m_lyricsList.begin(), m_lyricsList.end(), KNMusicLyricsDownloader::lyricsDetailLessThan); //Emit the have content signal. emit listContentChanged(m_lyricsList); } //Check out the cancel flag. if(m_cancelFlag) { //Reset the running flag. m_running=false; //Emit signal. emit downloadCancel(); //Won't download more. return; } //Check whether the completed downloader count is the same as the size of //the downloaders. if(m_completeDownloader==m_downloaders.size()) { //After download all the data, emit the signal. emit downloadComplete(); //Reset the running flag. m_running=false; } }
void KNMusicOnlineLyricsDownloader::downloadLyrics( const KNMusicDetailInfo &detailInfo) { //Check the running flag. if(m_running) { //Cancel the current running mission first. cancelDownload(); } //Reset the cancel flag. m_cancelFlag=false; //Set up the running flag. m_running=true; //Save the new detail info. m_workingDetailInfo=detailInfo; //Clear the lyrics list. m_lyricsList=QList<KNMusicLyricsDownloader::KNMusicLyricsDetails>(); m_completeDownloader=0; //Emit the empty list data right now. emit listContentChanged(m_lyricsList); //Emit the server changed signal. emit serverChanged(0, m_downloaders.size()); //Download the lyrics data via all the plugins. for(auto i : m_downloaders) { //Before doing downloading, checking the cancel flag first. if(m_cancelFlag) { //Reset the running flag. m_running=false; //Emit signal. emit downloadCancel(); //Won't download before calling the download. return; } //Try to download the lyrics from all the remote server. i->downloadLyrics(m_identifier, detailInfo); } }