void Test_KCompletion::cycleMatches_Weighted() { KCompletion completion; completion.setSoundsEnabled(false); completion.setOrder(KCompletion::Weighted); completion.setItems(wstrings); completion.setCompletionMode(KGlobalSettings::CompletionAuto); completion.makeCompletion("ca"); QCOMPARE(completion.nextMatch(), carpet); QCOMPARE(completion.nextMatch(), carp); QCOMPARE(completion.previousMatch(), carpet); QCOMPARE(completion.previousMatch(), carp); }
void Test_KCompletion::cycleMatches_Sorted() { KCompletion completion; completion.setSoundsEnabled(false); completion.setOrder(KCompletion::Sorted); completion.setItems(strings); completion.setCompletionMode(KCompletion::CompletionAuto); completion.makeCompletion(QStringLiteral("ca")); QCOMPARE(completion.nextMatch(), carp); QCOMPARE(completion.nextMatch(), carpet); QCOMPARE(completion.previousMatch(), carp); QCOMPARE(completion.previousMatch(), carpet); }
void KLineEdit::rotateText( KCompletionBase::KeyBindingType type ) { KCompletion* comp = compObj(); if ( comp && (type == KCompletionBase::PrevCompletionMatch || type == KCompletionBase::NextCompletionMatch ) ) { QString input; if (type == KCompletionBase::PrevCompletionMatch) comp->previousMatch(); else comp->nextMatch(); // Skip rotation if previous/next match is null or the same text if ( input.isNull() || input == displayText() ) return; setCompletedText( input, hasSelectedText() ); } }
void LogMessageEdit::rotateMatches(KeyBindingType type) { KCompletion* completionObj = compObj(); if( completionObj && m_completing && (type == PrevCompletionMatch || type == NextCompletionMatch) ) { QString match = (type == PrevCompletionMatch) ? completionObj->previousMatch() : completionObj->nextMatch(); int pos = textCursor().position(); QString text = toPlainText(); QString word = text.mid(m_completionStartPos, pos - m_completionStartPos); if( match.isEmpty() || match == word ) return; setCompletedText(match); } }
void KreTextEdit::rotateText( KCompletionBase::KeyBindingType type ) { KCompletion * comp = compObj(); if ( comp && completing && ( type == KCompletionBase::PrevCompletionMatch || type == KCompletionBase::NextCompletionMatch ) ) { #if 0 QString input = ( type == KCompletionBase::PrevCompletionMatch ) ? comp->previousMatch() : comp->nextMatch(); // Skip rotation if previous/next match is null or the same text int para, index; getCursorPosition( ¶, &index ); QString para_text = text( para ); QString complete_word = para_text.mid( completion_begin, index - completion_begin ); if ( input.isNull() || input == complete_word ) return ; setCompletedText( input ); #endif } }