QString OCompletion::makeCompletion( const QString& string ) { if ( myCompletionMode == OGlobalSettings::CompletionNone ) return QString::null; //qDebug( "OCompletion: completing: %s", string ); d->matches.clear(); myRotationIndex = 0; myHasMultipleMatches = false; myLastMatch = myCurrentMatch; // in Shell-completion-mode, emit all matches when we get the same // complete-string twice if ( myCompletionMode == OGlobalSettings::CompletionShell && string == myLastString ) { // Don't use d->matches since calling postProcessMatches() // on d->matches here would interfere with call to // postProcessMatch() during rotation findAllCompletions( string, &d->matches, myHasMultipleMatches ); QStringList l = d->matches.list(); postProcessMatches( &l ); emit matches( l ); if ( l.isEmpty() ) doBeep( NoMatch ); return QString::null; } QString completion; // in case-insensitive popup mode, we search all completions at once if ( myCompletionMode == OGlobalSettings::CompletionPopup || myCompletionMode == OGlobalSettings::CompletionPopupAuto ) { findAllCompletions( string, &d->matches, myHasMultipleMatches ); if ( !d->matches.isEmpty() ) completion = d->matches.first(); } else completion = findCompletion( string ); if ( myHasMultipleMatches ) emit multipleMatches(); myLastString = string; myCurrentMatch = completion; postProcessMatch( &completion ); if ( !string.isEmpty() ) { // only emit match when string != "" //qDebug( "OCompletion: Match: %s", completion ); emit match( completion ); } if ( completion.isNull() ) doBeep( NoMatch ); return completion; }
QString OCompletion::previousMatch() { QString completion; myLastMatch = myCurrentMatch; if ( d->matches.isEmpty() ) { findAllCompletions( myLastString, &d->matches, myHasMultipleMatches ); completion = d->matches.last(); myCurrentMatch = completion; myRotationIndex = 0; postProcessMatch( &completion ); emit match( completion ); return completion; } QStringList matches = d->matches.list(); myLastMatch = matches[ myRotationIndex ]; if ( myRotationIndex == 1 ) doBeep( Rotation ); // indicate first item -> rotating else if ( myRotationIndex == 0 ) myRotationIndex = matches.count(); myRotationIndex--; completion = matches[ myRotationIndex ]; myCurrentMatch = completion; postProcessMatch( &completion ); emit match( completion ); return completion; }
TQString TDECompletion::nextMatch() { TQString completion; myLastMatch = myCurrentMatch; if ( d->matches.isEmpty() ) { findAllCompletions( myLastString, &d->matches, myHasMultipleMatches ); completion = d->matches.first(); myCurrentMatch = completion; myRotationIndex = 0; postProcessMatch( &completion ); emit match( completion ); return completion; } TQStringList matches = d->matches.list(); myLastMatch = matches[ myRotationIndex++ ]; if ( myRotationIndex == matches.count() -1 ) doBeep( Rotation ); // indicate last matching item -> rotating else if ( myRotationIndex == matches.count() ) myRotationIndex = 0; completion = matches[ myRotationIndex ]; myCurrentMatch = completion; postProcessMatch( &completion ); emit match( completion ); return completion; }
OCompletionMatches OCompletion::allWeightedMatches( const QString &string ) { OCompletionMatchesWrapper matches( myOrder == Weighted ); bool dummy; findAllCompletions( string, &matches, dummy ); OCompletionMatches ret( matches ); postProcessMatches( &ret ); return ret; }
QStringList OCompletion::allMatches( const QString &string ) { OCompletionMatchesWrapper matches( myOrder == Weighted ); bool dummy; findAllCompletions( string, &matches, dummy ); QStringList l = matches.list(); postProcessMatches( &l ); return l; }
OCompletionMatches OCompletion::allWeightedMatches() { // Don't use d->matches since calling postProcessMatches() // on d->matches here would interfere with call to // postProcessMatch() during rotation OCompletionMatchesWrapper matches( myOrder == Weighted ); bool dummy; findAllCompletions( myLastString, &matches, dummy ); OCompletionMatches ret( matches ); postProcessMatches( &ret ); return ret; }
QStringList OCompletion::allMatches() { // Don't use d->matches since calling postProcessMatches() // on d->matches here would interfere with call to // postProcessMatch() during rotation OCompletionMatchesWrapper matches( myOrder == Weighted ); bool dummy; findAllCompletions( myLastString, &matches, dummy ); QStringList l = matches.list(); postProcessMatches( &l ); return l; }