org.kde.koala
public class KCompletion extends QObject
KCompletion completion; completion.setOrder( KCompletion.Sorted ); completion.addItem( "pfeiffer@kde.org" ); completion.addItem( "coolo@kde.org" ); completion.addItem( "carpdjih@sp.zrz.tu-berlin.de" ); completion.addItem( "carp@cs.tu-berlin.de" ); cout << completion.makeCompletion( "ca" ).latin1() << endl;In shell-completion-mode, this will be "carp"; in auto-completion- mode it will be "carp\@cs.tu-berlin.de", as that is alphabetically smaller. If setOrder was set to Insertion, "carpdjih\@sp.zrz.tu-berlin.de" would be completed in auto-completion-mode, as that was inserted before "carp\@cs.tu-berlin.de". You can dynamically update the completable items by removing and adding them whenever you want. For advanced usage, you could even use multiple KCompletion objects. E.g. imagine an editor like kwrite with multiple open files. You could store items of each file in a different KCompletion object, so that you know (and tell the user) where a completion comes from. Note: KCompletion does not work with strings that contain 0x0 characters (unicode nul), as this is used internally as a delimiter. You may inherit from KCompletion and override makeCompletion() in special cases (like reading directories/urls and then supplying the contents to KCompletion, as KURLCompletion does), but generally, this is not necessary. See KCompletionSignals for signals emitted by KCompletion
UNKNOWN: A generic class for completing Strings.
Field Summary | |
---|---|
static int | Insertion |
static int | Sorted
Constants that represent the order in which KCompletion performs
completion-lookups. |
static int | Weighted |
Constructor Summary | |
---|---|
protected | KCompletion(Class dummy) |
KCompletion()
Constructor, nothing special here :) |
Method Summary | |
---|---|
void | addItem(String item)
Adds an item to the list of available completions.
|
void | addItem(String item, int weight)
Adds an item to the list of available completions.
|
ArrayList | allMatches()
Returns a list of all items matching the last completed string.
|
ArrayList | allMatches(String string)
Returns a list of all items matching string. |
String | className() |
void | clear()
Removes all inserted items. |
int | completionMode()
Return the current completion mode.
|
void | dispose() Delete the wrapped C++ instance ahead of finalize() |
protected void | finalize() Deletes the wrapped C++ instance |
boolean | hasMultipleMatches()
Returns true when more than one match is found. |
boolean | ignoreCase()
Return whether KCompletion acts case insensitively or not.
|
void | insertItems(String[] items)
Inserts items into the list of possible completions.
|
boolean | isDisposed() Has the wrapped C++ instance been deleted? |
boolean | isEmpty()
Returns true when the completion object contains no entries. |
boolean | isSoundsEnabled()
Tells you whether KCompletion will play sounds on certain occasions.
|
ArrayList | items()
Returns a list of all items inserted into KCompletion. |
String | lastMatch()
Returns the last match. |
String | makeCompletion(String string)
Attempts to find an item in the list of available completions,
that begins with string. Will either return the first matching item
(if there is more than one match) or null, if no match was
found.
|
QMetaObject | metaObject() |
String | nextMatch()
Returns the next item from the matching-items-list.
|
int | order()
Returns the completion order. |
protected void | postProcessMatch(StringBuffer match)
This method is called after a completion is found and before the
matching string is emitted. |
protected void | postProcessMatches(String[] matches)
This method is called before a list of all available completions is
emitted via #matches. |
String | previousMatch()
Returns the next item from the matching-items-list.
|
void | removeItem(String item)
Removes an item from the list of available completions.
|
void | setCompletionMode(int mode)
Sets the completion mode to Auto/Manual, Shell or None.
|
void | setEnableSounds(boolean enable)
Enables/disables playing a sound when
|
void | setIgnoreCase(boolean ignoreCase)
Setting this to true makes KCompletion behave case insensitively.
|
void | setItems(String[] list)
Sets the list of items available for completion. |
void | setOrder(int order)
KCompletion offers three different ways in which it offers its items:
|
void | slotMakeCompletion(String string)
Attempts to complete "string" and emits the completion via match().
|
void | slotNextMatch()
Searches the next matching item and emits it via match().
|
void | slotPreviousMatch()
Searches the previous matching item and emits it via match().
|
ArrayList | substringCompletion(String string)
Returns a list of all completion items that contain the given string. |
UNKNOWN: Constants that represent the order in which KCompletion performs completion-lookups.
UNKNOWN: Constructor, nothing special here :)
Parameters: item the item to add
UNKNOWN: Adds an item to the list of available completions.
weight
or adds it to the current
weighting if the item is already available. The weight has to be greater
than 1 to take effect (default weight is 1).Parameters: item the item to add weight the weight of the item, default is 1
UNKNOWN: Adds an item to the list of available completions.
Returns: a list of all matches for the last completed string.
See Also: KCompletion
UNKNOWN: Returns a list of all items matching the last completed string.
string.
Parameters: string the string to match
Returns: the list of all matches
UNKNOWN: Returns a list of all items matching string.
UNKNOWN: Removes all inserted items.
Returns: the current completion mode
See Also: KCompletion
UNKNOWN: Return the current completion mode.
Returns: true if there are more than one match
See Also: KCompletion
UNKNOWN: Returns true when more than one match is found.
Returns: true if the case will be ignored
See Also: KCompletion
UNKNOWN: Return whether KCompletion acts case insensitively or not.
items
into the list of possible completions.
Does the same as setItems(), but does not call clear() before.Parameters: items the items to insert
UNKNOWN: Inserts items
into the list of possible completions.
UNKNOWN: Returns true when the completion object contains no entries.
Returns: true if sounds are enabled
See Also: KCompletion KCompletion
UNKNOWN: Tells you whether KCompletion will play sounds on certain occasions.
Returns: a list of all items
See Also: KCompletion
UNKNOWN: Returns a list of all items inserted into KCompletion.
Returns: the last match. null is returned when there is no last match.
UNKNOWN: Returns the last match.
string.
Will either return the first matching item
(if there is more than one match) or null, if no match was
found.
In the latter case, a sound will be issued, depending on
isSoundsEnabled().
If a match was found, it will also be emitted via the signal
match().
If this is called twice or more often with the same string while no
items were added or removed in the meantime, all available completions
will be emitted via the signal #matches().
This happens only in shell-completion-mode.Parameters: string the string to complete
Returns: the matching item, or null if there is no matching item.
See Also: KCompletion KCompletion
UNKNOWN: Attempts to find an item in the list of available completions, that begins with string.
Returns: the next item from the matching-items-list. When there is no match, null is returned and a sound is issued
See Also: KCompletion
UNKNOWN: Returns the next item from the matching-items-list.
Returns: the current completion order.
See Also: KCompletion
UNKNOWN: Returns the completion order.
Parameters: match the match to process
See Also: KCompletion
UNKNOWN: This method is called after a completion is found and before the matching string is emitted.
Parameters: matches the matches to process
See Also: KCompletion
UNKNOWN: This method is called before a list of all available completions is emitted via #matches.
Returns: the next item from the matching-items-list. When there is no match, null is returned and a sound is be issued.
See Also: KCompletion
UNKNOWN: Returns the next item from the matching-items-list.
Parameters: item the item to remove
UNKNOWN: Removes an item from the list of available completions.
Parameters: mode the completion mode
See Also: KCompletion KGlobalSettings
UNKNOWN: Sets the completion mode to Auto/Manual, Shell or None.
Parameters: enable true to enable sounds
See Also: KCompletion
UNKNOWN: Enables/disables playing a sound when
Parameters: ignoreCase true to ignore the case
See Also: KCompletion
UNKNOWN: Setting this to true makes KCompletion behave case insensitively.
Parameters: list the list of items that are available for completion
See Also: KCompletion
UNKNOWN: Sets the list of items available for completion.
Parameters: order the new order
See Also: KCompletion
UNKNOWN: KCompletion offers three different ways in which it offers its items:
Parameters: string the string to complete
See Also: KCompletion
UNKNOWN: Attempts to complete "string" and emits the completion via match().
See Also: KCompletion
UNKNOWN: Searches the next matching item and emits it via match().
See Also: KCompletion
UNKNOWN: Searches the previous matching item and emits it via match().
string.
Parameters: string the string to complete
Returns: a list of items which all contain text
as a substring,
i.e. not necessarily at the beginning.
See Also: KCompletion
UNKNOWN: Returns a list of all completion items that contain the given string.