void ComputeChecksum::start(const QString& filePath)
{
    const QString csType = checksumType();

    // Calculate the checksum in a different thread first.
    connect( &_watcher, SIGNAL(finished()),
             this, SLOT(slotCalculationDone()),
             Qt::UniqueConnection );
    if( csType == checkSumMD5C ) {
        _watcher.setFuture(QtConcurrent::run(FileSystem::calcMd5, filePath));

    } else if( csType == checkSumSHA1C ) {
        _watcher.setFuture(QtConcurrent::run( FileSystem::calcSha1, filePath));
    }
#ifdef ZLIB_FOUND
    else if( csType == checkSumAdlerC) {
        _watcher.setFuture(QtConcurrent::run(FileSystem::calcAdler32, filePath));
    }
#endif
    else {
        // for an unknown checksum or no checksum, we're done right now
        if( !csType.isEmpty() ) {
            qDebug() << "Unknown checksum type:" << csType;
        }
        emit done(QByteArray(), QByteArray());
    }
}
Пример #2
0
void ComputeChecksum::start(const QString& filePath)
{
    // Calculate the checksum in a different thread first.
    connect( &_watcher, SIGNAL(finished()),
             this, SLOT(slotCalculationDone()),
             Qt::UniqueConnection );
    _watcher.setFuture(QtConcurrent::run(ComputeChecksum::computeNow, filePath, checksumType()));
}