Пример #1
0
void NewstuffModel::mapUninstalled()
{
    QModelIndex const affected = index( d->m_currentAction.first );
    emit uninstallationFinished( 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();
}
Пример #2
0
void NewstuffModel::cancel( int index )
{
    if ( !d->isTransitioning( index ) ) {
        return;
    }

    { // <-- do not remove, mutex locker scope
        QMutexLocker locker( &d->m_mutex );
        if ( d->m_currentAction.first == index ) {
            if ( d->m_currentAction.second == NewstuffModelPrivate::Install ) {
                if ( d->m_currentReply ) {
                    d->m_currentReply->abort();
                    d->m_currentReply->deleteLater();
                    d->m_currentReply = nullptr;
                }

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

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

                d->m_items[d->m_currentAction.first].m_downloadedSize = 0;

                emit installationFailed( d->m_currentAction.first, tr( "Installation aborted by user." ) );
                d->m_currentAction = NewstuffModelPrivate::Action( -1, NewstuffModelPrivate::Install );
            } else {
                // Shall we interrupt this?
            }
        } else {
            if ( d->m_currentAction.second == NewstuffModelPrivate::Install ) {
                NewstuffModelPrivate::Action install( index, NewstuffModelPrivate::Install );
                d->m_actionQueue.removeAll( install );
                emit installationFailed( index, tr( "Installation aborted by user." ) );
            } else {
                NewstuffModelPrivate::Action uninstall( index, NewstuffModelPrivate::Uninstall );
                d->m_actionQueue.removeAll( uninstall );
                emit uninstallationFinished( index ); // do we need failed here?
            }
        }
    }

    d->processQueue();
}
Пример #3
0
void NewstuffModel::uninstall( int idx )
{
    if ( idx < 0 || idx >= d->m_items.size() ) {
        return;
    }

    if ( d->m_items[idx].m_registryNode.isNull() ) {
        emit uninstallationFinished( idx );
    }

    NewstuffModelPrivate::Action action( idx, NewstuffModelPrivate::Uninstall );
    { // <-- do not remove, mutex locker scope
        QMutexLocker locker( &d->m_mutex );
        if ( d->m_actionQueue.contains( action ) ) {
            return;
        }
        d->m_actionQueue << action;
    }

    d->processQueue();
}
Пример #4
0
void OfflineDataModel::handleUninstallationFinished( int index )
{
    emit uninstallationFinished( fromSource( index ) );
}