コード例 #1
0
void KProgress::setProgress(int progress)
{
    QProgressBar::setProgress(progress);

    if (totalSteps())
    {
        emit percentageChanged((progress * 100) / totalSteps());
    }
}
コード例 #2
0
ファイル: qprogressdialog.cpp プロジェクト: aroraujjwal/qt3
void QProgressDialog::setProgress( int progress )
{
    if ( progress == bar()->progress() ||
	 bar()->progress() == -1 && progress == bar()->totalSteps() )
	return;

    bar()->setProgress(progress);

    if ( d->shown_once ) {
	if (testWFlags(WShowModal))
	    qApp->processEvents();
    } else {
	if ( progress == 0 ) {
#ifndef QT_NO_CURSOR
	    if ( d->creator ) {
		d->parentCursor = d->creator->cursor();
		d->creator->setCursor( waitCursor );
	    }
#endif
	    d->starttime.start();
	    forceTimer->start( d->showTime );
	    return;
	} else {
	    bool need_show;
	    int elapsed = d->starttime.elapsed();
	    if ( elapsed >= d->showTime ) {
		need_show = TRUE;
	    } else {
		if ( elapsed > minWaitTime ) {
		    int estimate;
		    if ( (totalSteps() - progress) >= INT_MAX / elapsed )
			estimate = (totalSteps() - progress) / progress * elapsed;
		    else
			estimate = elapsed * (totalSteps() - progress) / progress;
		    need_show = estimate >= d->showTime;
		} else {
		    need_show = FALSE;
		}
	    }
	    if ( need_show ) {
		int w = QMAX( isVisible() ? width() : 0, sizeHint().width() );
		int h = QMAX( isVisible() ? height() : 0, sizeHint().height() );
		resize( w, h );
		show();
		d->shown_once = TRUE;
	    }
	}
#ifdef Q_WS_MACX
	QApplication::flush();
#endif
    }

    if ( progress == bar()->totalSteps() && d->autoReset )
	reset();
}
コード例 #3
0
ファイル: synctasklistitem.cpp プロジェクト: asmblur/SynCE
bool SyncTaskListItem::synchronize(SyncDialogImpl *syncDialog)
{
    bool ret = false;

    setTaskLabel(i18n("Started").utf8());
    setTotalSteps( 1);
    KApplication::kApplication()->processEvents();
    this->syncDialog = syncDialog;

    if (syncPlugin != NULL) {
        kdDebug(2120) << "----------------------------------------------" << endl;
        kdDebug(2120) << i18n("*** Started synchronous syncing with") << " " << syncPlugin->serviceName() << endl;

        ret = syncPlugin->doSync(firstSynchronization, partnerId);
        kdDebug(2120) << i18n("*** Finished synchronous syncing with") << " " << syncPlugin->serviceName() << endl;
        kdDebug(2120) << "----------------------------------------------" << endl;

        setProgress( totalSteps());

        if (ret) {
            lastSynchronized = QDateTime(QDate::currentDate(),
                    QTime::currentTime());
            firstSynchronization = false;
            setTaskLabel(i18n("Finished").utf8());
            KApplication::kApplication()->processEvents();
        } else {
            setTaskLabel(i18n("Error during synchronization").utf8());
        }
    }

    return ret;
}
コード例 #4
0
int QwtAbstractSlider::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QwtAbstractScale::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 5)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 5;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< double*>(_v) = value(); break;
        case 1: *reinterpret_cast< uint*>(_v) = totalSteps(); break;
        case 2: *reinterpret_cast< uint*>(_v) = singleSteps(); break;
        case 3: *reinterpret_cast< uint*>(_v) = pageSteps(); break;
        case 4: *reinterpret_cast< bool*>(_v) = stepAlignment(); break;
        case 5: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isTracking(); break;
        case 7: *reinterpret_cast< bool*>(_v) = wrapping(); break;
        case 8: *reinterpret_cast< bool*>(_v) = invertedControls(); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setValue(*reinterpret_cast< double*>(_v)); break;
        case 1: setTotalSteps(*reinterpret_cast< uint*>(_v)); break;
        case 2: setSingleSteps(*reinterpret_cast< uint*>(_v)); break;
        case 3: setPageSteps(*reinterpret_cast< uint*>(_v)); break;
        case 4: setStepAlignment(*reinterpret_cast< bool*>(_v)); break;
        case 5: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 6: setTracking(*reinterpret_cast< bool*>(_v)); break;
        case 7: setWrapping(*reinterpret_cast< bool*>(_v)); break;
        case 8: setInvertedControls(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 9;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #5
0
ファイル: synctasklistitem.cpp プロジェクト: asmblur/SynCE
bool SyncTaskListItem::postSync()
{
    bool ret;

    ret = syncPlugin->postSync(firstSynchronization, partnerId);

    int totSteps = totalSteps();
    setProgress(totSteps);

    return ret;
}
コード例 #6
0
void QProgressDialog::setProgress( int progress )
{
    int old_progress = bar()->progress();

    if ( progress <= old_progress ||
	 progress == 0 && old_progress > 0 ||
	 progress != 0 && old_progress < 0 )
	 return;

    bar()->setProgress(progress);

    if ( d->shown_once ) {
	if (testWFlags(WType_Modal))
	    qApp->processEvents();
    } else {
	if ( progress == 0 ) {
	    if ( d->creator ) {
		d->parentCursor = d->creator->cursor();
		d->creator->setCursor( waitCursor );
	    }
	    d->starttime.start();
	} else {
	    int elapsed = d->starttime.elapsed();
	    if ( !d->showTime || elapsed > minWaitTime ) {
		int estimate = elapsed * (totalSteps() - progress) / progress;
		if ( estimate >= d->showTime ) {
		    resize(sizeHint());
		    center();
		    show();
		    d->shown_once = TRUE;
		}
	    }
	}
    }

    if ( progress == totalSteps() )
	reset();

    return;
}
コード例 #7
0
ファイル: ConstraintSolver.cpp プロジェクト: KDE/amarok
void
APG::ConstraintSolver::run()
{
    if ( !m_readyToRun ) {
        error() << "DANGER WILL ROBINSON!  A ConstraintSolver (serial no:" << m_serialNumber << ") tried to run before its QueryMaker finished!";
        m_abortRequested = true;
        return;
    }

    if ( m_domain.empty() ) {
        debug() << "The QueryMaker returned no tracks";
        return;
    } else {
        debug() << "Domain has" << m_domain.size() << "tracks";
    }

    debug() << "Running ConstraintSolver" << m_serialNumber;

    emit totalSteps( m_maxGenerations );

    // GENETIC ALGORITHM LOOP
    Population population;
    quint32 generation = 0;
    Meta::TrackList* best = NULL;
    while ( !m_abortRequested && ( generation < m_maxGenerations ) ) {
        quint32 s = m_constraintTreeRoot->suggestPlaylistSize();
        m_suggestedPlaylistSize = (s > 0) ? s : m_suggestedPlaylistSize;
        fill_population( population );
        best = find_best( population );
        if ( population.value( best ) < m_satisfactionThreshold ) {
            select_population( population, best );
            mutate_population( population );
            generation++;
            emit incrementProgress();
        } else {
            break;
        }
    }
    debug() << "solution at" << (void*)(best);
    
    m_solvedPlaylist = best->mid( 0 );
    m_finalSatisfaction = m_constraintTreeRoot->satisfaction( m_solvedPlaylist );

    /* clean up */
    Population::iterator it = population.begin();
    while ( it != population.end() ) {
        delete it.key();
        it = population.erase( it );
    }

    emit endProgressOperation( this );
}
コード例 #8
0
// ### KDE 4 remove
int KProgress::maxValue()
{
    return totalSteps();
}