Beispiel #1
0
void NewstuffModel::mapInstalled( int exitStatus )
{
    if ( d->m_unpackProcess ) {
        d->m_unpackProcess->deleteLater();
        d->m_unpackProcess = nullptr;
    }

    if ( d->m_currentFile ) {
        d->m_currentFile->deleteLater();
        d->m_currentFile = nullptr;
    }

    emit installationProgressed( d->m_currentAction.first, 1.0 );
    d->m_items[d->m_currentAction.first].m_downloadedSize = 0;
    if ( exitStatus == 0 ) {
        emit installationFinished( d->m_currentAction.first );
    } else {
        mDebug() << "Process exit status " << exitStatus << " indicates an error.";
        emit installationFailed( d->m_currentAction.first , QString( "Unable to unpack file. Process exited with status code %1." ).arg( exitStatus ) );
    }
    QModelIndex const affected = index( d->m_currentAction.first );

    { // <-- do not remove, mutex locker scope
        QMutexLocker locker( &d->m_mutex );
        d->m_currentAction = NewstuffModelPrivate::Action( -1, NewstuffModelPrivate::Install );
    }
    emit dataChanged( affected, affected );
    d->processQueue();
}
Beispiel #2
0
void NewstuffModel::updateProgress( qint64 bytesReceived, qint64 bytesTotal )
{
    qreal const progress = qBound<qreal>( 0.0, 0.9 * bytesReceived / qreal( bytesTotal ), 1.0 );
    emit installationProgressed( d->m_currentAction.first, progress );
    NewstuffItem &item = d->m_items[d->m_currentAction.first];
    item.m_payloadSize = bytesTotal;
    if ( qreal(bytesReceived-item.m_downloadedSize)/bytesTotal >= 0.01 || progress >= 0.9 ) {
        // Only consider download progress of 1% and more as a data change
        item.m_downloadedSize = bytesReceived;
        QModelIndex const affected = index( d->m_currentAction.first );
        emit dataChanged( affected, affected );
    }
}
Beispiel #3
0
void OfflineDataModel::handleInstallationProgress( int index, qreal progress )
{
    emit installationProgressed( fromSource( index ), progress );
}