Exemple #1
0
void MusicScanner::scan(const QString &folder, const QString &cacheFile, bool readCache, const QSet<FileOnlySong> &existingSongs)
{
    lastCacheProg=-1;
    if (!cacheFile.isEmpty() && readCache) {
        MusicLibraryItemRoot *lib=new MusicLibraryItemRoot;
        MusicLibraryModel::convertCache(cacheFile);
        readProgress(0.0);
        if (lib->fromXML(cacheFile, QDateTime(), folder)) {
            lib->applyGrouping();
            if (!stopRequested) {
                emit libraryUpdated(lib);
            } else {
                delete lib;
            }
            return;
        } else {
            delete lib;
        }
    }

    if (stopRequested) {
        return;
    }
    count=0;
    lastUpdate=0;
    MusicLibraryItemRoot *library = new MusicLibraryItemRoot;
    QString topLevel=Utils::fixPath(QDir(folder).absolutePath());
    QSet<FileOnlySong> existing=existingSongs;
    scanFolder(library, topLevel, topLevel, existing, 0);

    if (!stopRequested) {
        library->applyGrouping();
        if (!cacheFile.isEmpty()) {
            writeProgress(0.0);
            library->toXML(cacheFile, QDateTime(), this);
        }
        emit libraryUpdated(library);
    } else {
        delete library;
    }
}
Exemple #2
0
void MusicScanner::scan(const QString &folder, const QString &cacheFile, bool readCache, const QSet<FileOnlySong> &existingSongs)
{
    if (!cacheFile.isEmpty() && readCache) {
        MusicLibraryItemRoot *lib=new MusicLibraryItemRoot;
        readProgress(0.0);
        if (lib->fromXML(cacheFile, 0, 0, folder)) {
            if (!stopRequested) {
                emit libraryUpdated(lib);
            } else {
                delete lib;
            }
            return;
        } else {
            delete lib;
        }
    }

    if (stopRequested) {
        return;
    }
    count=0;
    MusicLibraryItemRoot *library = new MusicLibraryItemRoot;
    QString topLevel=Utils::fixPath(QDir(folder).absolutePath());
    QSet<FileOnlySong> existing=existingSongs;
    timer.start();
    scanFolder(library, topLevel, topLevel, existing, 0);

    if (!stopRequested) {
        if (!cacheFile.isEmpty()) {
            writeProgress(0.0);
            library->toXML(cacheFile, 0, false, this);
        }
        emit libraryUpdated(library);
    } else {
        delete library;
    }
}