Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
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() );
    }
}
Ejemplo n.º 4
0
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);
    }
}
Ejemplo n.º 5
0
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( &para, &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
	}
}