void KNMusicDatabase::recoverData() { int recoverCount=size(); QString dateTimeStringCache; QDateTime dateTimeCache; for(int i=0; i<recoverCount; i++) { QStringList textList; KNMusicGlobal::MusicDetailsInfo currentDetails; QJsonObject currentSong=row(i); QJsonArray displayText=currentSong["Text"].toArray(); for(int j=0; j<KNMusicGlobal::MusicDataCount; j++) { textList.append(displayText.at(j).toString()); } currentDetails.filePath=currentSong["FilePath"].toString(); currentDetails.coverImageHash=currentSong["CoverImage"].toString(); currentDetails.duration=(int)currentSong["Time"].toDouble(); currentDetails.size=(int)currentSong["Size"].toDouble(); currentDetails.bitRate=(float)currentSong["BitRate"].toDouble(); currentDetails.samplingRate=(float)currentSong["SampleRate"].toDouble(); currentDetails.rating=(int)currentSong["Rating"].toInt(); dateTimeStringCache=currentSong["DateModified"].toString(); dateTimeCache=stringToDateTime(dateTimeStringCache); currentDetails.dateModified=dateTimeCache; textList[KNMusicGlobal::DateModified]=dateTimeCache.toString("yyyy-MM-dd APhh:mm"); dateTimeStringCache=currentSong["LastPlayed"].toString(); dateTimeCache=stringToDateTime(dateTimeStringCache); currentDetails.lastPlayed=dateTimeCache; textList[KNMusicGlobal::LastPlayed]=dateTimeCache.toString("yyyy-MM-dd APhh:mm"); dateTimeStringCache=currentSong["DateAdded"].toString(); dateTimeCache=stringToDateTime(dateTimeStringCache); currentDetails.dateAdded=dateTimeCache; textList[KNMusicGlobal::DateAdded]=dateTimeCache.toString("yyyy-MM-dd APhh:mm"); m_model->recoverFile(textList, currentDetails); } emit recoverComplete(); }
void KNMusicLibraryImageManager::recoverFromFolder() { //Check is the path exist or it's a file. QFileInfo pathChecker(m_imageFolderPath); QDir imageDir(m_imageFolderPath); //Check it's existance and it's file or not. if(pathChecker.exists() && pathChecker.isFile()) { //Delete the file. QFile fileRemover(pathChecker.absoluteFilePath()); fileRemover.remove(); } //Check if it's not exist, simply generate the folder. if(!pathChecker.exists()) { //Generate the folder. imageDir.mkpath(imageDir.absolutePath()); //Do nothing, return. return; } //Load the image in the dir. QFileInfoList contentInfos=imageDir.entryInfoList(); //Check each file. for(QFileInfoList::iterator i=contentInfos.begin(); i!=contentInfos.end(); ++i) { //Load all the png image to hash list. if((*i).isFile() && (*i).suffix().toLower()=="png") { //Load the image. QImage currentImage=QImage((*i).absoluteFilePath(), "png"); //If there's image data, insert to pixmap list. if(!currentImage.isNull()) { m_pixmapList->setImage((*i).completeBaseName(), currentImage); } } } //Emit recover complete signal. emit recoverComplete(); }