Ejemplo n.º 1
0
void
SqlScanResultProcessor::commitDirectory( QSharedPointer<CollectionScanner::Directory> directory )
{
    QString path = directory->path();
    // a bit of paranoia:
    if( m_foundDirectories.contains( path ) )
        warning() << "commitDirectory(): duplicate directory path" << path << "in"
                  << "collectionscanner output. This shouldn't happen.";

    // getDirectory() updates the directory entry mtime:
    int dirId = m_collection->registry()->getDirectory( path, directory->mtime() );
    // we never dereference key of m_directoryIds, it is safe to add it as a plain pointer
    m_directoryIds.insert( directory.data(), dirId );
    m_foundDirectories.insert( path, dirId );

    AbstractScanResultProcessor::commitDirectory( directory );

    // --- unblock every 5 second. Maybe not really needed, but still nice
    if( m_blockedTime.secsTo( QDateTime::currentDateTime() ) >= 5 )
    {
        unblockUpdates();
        m_blockedTime = QDateTime::currentDateTime();
        blockUpdates();
    }
}
Ejemplo n.º 2
0
    void SurfaceAnd::transform(const Transform& transform)
    {
        blockUpdates();

        for(auto& surf : _surfs)
            applyTransformation(surf, transform);

        unblockUpdates();
    }
Ejemplo n.º 3
0
    void SurfaceAnd::setOuterMaterial(const std::shared_ptr<Material>& mat)
    {
        blockUpdates();

        for(auto& surf : _surfs)
            surf->setOuterMaterial(mat);

        unblockUpdates();
    }
Ejemplo n.º 4
0
    void SurfaceAnd::setCoating(const std::shared_ptr<Coating>& coating)
    {
        blockUpdates();

        for(auto& surf : _surfs)
            surf->setCoating(coating);

        unblockUpdates();
    }
Ejemplo n.º 5
0
    foreach( const QString &key, keys )
    {
        // --- commit the albums as compilation or normal album

        QList<CollectionScanner::Album*> albums = m_albumNames.values( key );
        // debug() << "commit got" <<albums.count() << "x" << key;

        // if we have multiple albums with the same name, check if it
        // might be a compilation

        for( int i = albums.count() - 1; i >= 0; --i )
        {
            CollectionScanner::Album *album = albums.at( i );
            // commit all albums with a track with the noCompilation flag
            if( album->isNoCompilation() ||
                    nonCompilationAlbumNames.contains( album->name(), Qt::CaseInsensitive ) )
                commitAlbum( albums.takeAt( i ) );
        }

        // only one album left. It's no compilation.
        if( albums.count() == 1 )
        {
            commitAlbum( albums.takeFirst() );
        }

        // compilation
        else if( albums.count() > 1 )
        {
            CollectionScanner::Album compilation( key, QString() );
            for( int i = albums.count() - 1; i >= 0; --i )
            {
                CollectionScanner::Album *album = albums.takeAt( i );
                foreach( CollectionScanner::Track *track, album->tracks() )
                    compilation.addTrack( track );
                compilation.setCovers( album->covers() + compilation.covers() );
            }
            commitAlbum( &compilation );
        }

        // --- unblock every 5 second. Maybe not really needed, but still nice
        if( blockedTime.secsTo( QDateTime::currentDateTime() ) >= 5 )
        {
            unblockUpdates();
            blockedTime = QDateTime::currentDateTime();
            blockUpdates();
        }
    }
Ejemplo n.º 6
0
void
SqlScanResultProcessor::scanSucceeded()
{
    DEBUG_BLOCK;

    // we are blocking the updated signal for maximum of one second.
    m_blockedTime = QDateTime::currentDateTime();
    blockUpdates();

    urlsCacheInit();

    // -- call the base implementation
    AbstractScanResultProcessor::scanSucceeded();

    // -- error reporting
    m_messages.append( m_collection->sqlStorage()->getLastErrors() );

    if( !m_messages.isEmpty() && QApplication::type() != QApplication::Tty )
        QTimer::singleShot(0, this, SLOT(displayMessages())); // do in the UI thread

    unblockUpdates();
}