KCompletionMatches Class

List for keeping matches returned from KCompletion. More...

Header: #include <KCompletionMatches>
CMake: find_package(KF6 REQUIRED COMPONENTS Completion)
target_link_libraries(mytarget PRIVATE KF6::Completion)

Public Functions

KCompletionMatches(bool sort)
KCompletionMatches(const KCompletionMatches &)
QStringList list(bool sort = true) const
void removeDuplicates()
bool sorting() const

Detailed Description

This structure is returned by KCompletion::allWeightedMatches(). It also keeps the weight of the matches, allowing you to modify some matches or merge them with matches from another call to allWeightedMatches(), and sort the matches after that in order to have the matches ordered correctly.

Example (a simplified example of what Konqueror's completion does):

KCompletionMatches matches = completion->allWeightedMatches(location);
if(!location.startsWith("www."))
    matches += completion->allWeightedmatches("www." + location");
matches.removeDuplicates();
QStringList list = matches.list();

Member Function Documentation

KCompletionMatches::KCompletionMatches(bool sort)

Default constructor.

sort if false, the matches won't be sorted before the conversion, use only if you're sure the sorting is not needed

KCompletionMatches::KCompletionMatches(const KCompletionMatches &)

copy constructor.

QStringList KCompletionMatches::list(bool sort = true) const

Returns the matches as a QStringList.

sort if false, the matches won't be sorted before the conversion, use only if you're sure the sorting is not needed

Returns the list of matches

void KCompletionMatches::removeDuplicates()

Removes duplicate matches. Needed only when you merged several matches results and there's a possibility of duplicates.

bool KCompletionMatches::sorting() const

If sorting() returns false, the matches aren't sorted by their weight, even if true is passed to list().

true if the matches won't be sorted

Related Non-Members

KCompletionMatchesList