コード例 #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);
}
コード例 #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);
}
コード例 #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() );
    }
}
コード例 #4
0
ファイル: logmessageedit.cpp プロジェクト: KDE/cervisia
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);
    }
}
コード例 #5
0
ファイル: kretextedit.cpp プロジェクト: KDE/krecipes
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
	}
}