#include </home/clem/local/src/opie/libopie2/qt3/opiecore/ocompletion.h>
Collaboration diagram for OCompletion:

This class offers easy use of "auto-completion", "manual-completion" or "shell completion" on QString objects. A common use is completing filenames or URLs (see OURLCompletion()). But it is not limited to URL-completion -- everything should be completable! The user should be able to complete email-addresses, telephone-numbers, commands, SQL queries, ... Every time your program knows what the user can type into an edit-field, you should offer completion. With OCompletion, this is very easy, and if you are using a line edit widget (OLineEdit), it is even more easy. Basically, you tell a OCompletion object what strings should be completable and whenever completion should be invoked, you call makeCompletion(). OLineEdit and (an editable) OComboBox even do this automatically for you.
OCompletion offers the completed string via the signal match() and all matching strings (when the result is ambiguous) via the method allMatches().
Notice: auto-completion, shell completion and manual completion work slightly differently:
A short example:
OCompletion completion; completion.setOrder( OCompletion::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 OCompletion objects. E.g. imagine an editor like kwrite with multiple open files. You could store items of each file in a different OCompletion object, so that you know (and tell the user) where a completion comes from.
Note: OCompletion does not work with strings that contain 0x0 characters (unicode nul), as this is used internally as a delimiter.
You may inherit from OCompletion and override makeCompletion() in special cases (like reading directories/urls and then supplying the contents to OCompletion, as OURLCompletion does), but generally, this is not necessary.
Definition at line 155 of file ocompletion.h.
|
|
Definition at line 526 of file ocompletion.h. |
|
|
Constants that represent the order in which OCompletion performs completion-lookups. Definition at line 168 of file ocompletion.h. |
|
|
Constructor, nothing special here :) Definition at line 231 of file ocompletion.cpp. References d, Insertion, myBeep, myCompletionMode, myHasMultipleMatches, myIgnoreCase, myRotationIndex, myTreeRoot, and setOrder(). |
|
|
Destructor, nothing special here, either. Definition at line 245 of file ocompletion.cpp. References d, and myTreeRoot. |
|
||||||||||||
|
Adds an item to the list of available completions. Resets the current item-state (previousMatch() and nextMatch() won't work anymore).
Sets the weighting of the item to Definition at line 305 of file ocompletion.cpp. References QString::at(), OCompTreeNode::confirm(), i, OCompTreeNode::insert(), QString::isEmpty(), len, QString::length(), myOrder, myTreeRoot, Sorted, and Weighted. |
|
|
Adds an item to the list of available completions. Resets the current item-state (previousMatch() and nextMatch() won't work anymore). Definition at line 295 of file ocompletion.cpp. References OCompletionMatchesWrapper::clear(), d, OCompletionPrivate::matches, myLastString, myRotationIndex, and QString::null. Referenced by addWeightedItem(), and insertItems(). |
|
|
Definition at line 331 of file ocompletion.cpp. References addItem(), QString::findRev(), QString::left(), len, QString::length(), QString::mid(), myOrder, and Weighted. Referenced by insertItems(). |
|
|
Definition at line 511 of file ocompletion.cpp. References findAllCompletions(), l, OCompletionMatchesWrapper::list(), matches(), myOrder, postProcessMatches(), and Weighted. |
|
|
Definition at line 484 of file ocompletion.cpp. References findAllCompletions(), l, OCompletionMatchesWrapper::list(), matches(), myLastString, myOrder, postProcessMatches(), and Weighted. Referenced by OLineEdit::makeCompletion(). |
|
|
Definition at line 521 of file ocompletion.cpp. References findAllCompletions(), matches(), myOrder, postProcessMatches(), and Weighted. |
|
|
Definition at line 498 of file ocompletion.cpp. References findAllCompletions(), matches(), myLastString, myOrder, postProcessMatches(), and Weighted. |
|
|
Removes all inserted items. Definition at line 367 of file ocompletion.cpp. References OCompletionMatchesWrapper::clear(), d, OCompletionPrivate::matches, myLastString, myRotationIndex, myTreeRoot, and QString::null. Referenced by setItems(). |
|
|
Definition at line 276 of file ocompletion.h. References myCompletionMode. |
|
|
Definition at line 811 of file ocompletion.cpp. References QString::fromLatin1(), myBeep, myCompletionMode, NoMatch, PartialMatch, Rotation, text, and tr. Referenced by findCompletion(), makeCompletion(), nextMatch(), previousMatch(), and substringCompletion(). |
|
||||||||||||||||||||
|
Definition at line 734 of file ocompletion.cpp. References OCompletionMatchesWrapper::append(), QString::append(), OCompTreeNodeList::begin(), OCompTreeNode::children(), OCompTreeNode::childrenCount(), OCompTreeNode::firstChild(), QChar::isNull(), QString::setNum(), Opie::Internal::string(), and OCompTreeNode::weight(). Referenced by extractStringsFromNodeCI(), findAllCompletions(), and substringCompletion(). |
|
||||||||||||||||||||
|
Definition at line 775 of file ocompletion.cpp. References QString::at(), extractStringsFromNode(), OCompTreeNode::find(), QString::isEmpty(), QChar::isLetter(), QChar::lower(), QString::mid(), and QChar::upper(). Referenced by findAllCompletions(). |
|
||||||||||||||||
|
Definition at line 679 of file ocompletion.cpp. References OCompletionMatchesWrapper::append(), QString::at(), OCompTreeNode::childrenCount(), OCompletionMatchesWrapper::count(), extractStringsFromNode(), extractStringsFromNodeCI(), OCompTreeNode::find(), i, QString::isEmpty(), QString::length(), myIgnoreCase, myTreeRoot, and QString::null. Referenced by allMatches(), allWeightedMatches(), makeCompletion(), nextMatch(), and previousMatch(). |
|
|
Definition at line 603 of file ocompletion.cpp. References QString::at(), OCompTreeNode::childAt(), OCompTreeNode::childrenCount(), doBeep(), OCompTreeNode::find(), OCompTreeNode::firstChild(), i, QChar::isNull(), QString::length(), myCompletionMode, myHasMultipleMatches, myOrder, myRotationIndex, myTreeRoot, QString::null, PartialMatch, OCompTreeNode::weight(), and Weighted. Referenced by makeCompletion(). |
|
|
Definition at line 377 of file ocompletion.h. References myHasMultipleMatches. |
|
|
Definition at line 318 of file ocompletion.h. References myIgnoreCase. |
|
|
Inserts Definition at line 272 of file ocompletion.cpp. References addItem(), addWeightedItem(), QValueList< T >::begin(), QValueList< T >::end(), myOrder, and Weighted. Referenced by setItems(). |
|
|
Tells you whether OCompletion will play sounds on certain occasions. Default is enabled
Definition at line 371 of file ocompletion.h. References myBeep. |
|
|
Returns a list of all items inserted into OCompletion. This is useful if you need to save the state of a OCompletion object and restore it later. Important note: when order() == Weighted, then every item in the stringlist has its weight appended, delimited by a colon. E.g. an item "www.kde.org" might look like "www.kde.org:4", where 4 is the weight. This is necessary so that you can save the items along with its weighting on disk and load them back with setItems(), restoring its weight as well. If you really don't want the appended weightings, call setOrder( OCompletion::Insertion ) before calling items().
|
|
|
Definition at line 238 of file ocompletion.h. References myLastMatch. |
|
|
Attempts to find an item in the list of available completions, that begins with 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.
Definition at line 378 of file ocompletion.cpp. References OCompletionMatchesWrapper::clear(), d, doBeep(), findAllCompletions(), findCompletion(), OCompletionMatchesWrapper::first(), QString::isEmpty(), OCompletionMatchesWrapper::isEmpty(), QValueList< T >::isEmpty(), QString::isNull(), l, OCompletionMatchesWrapper::list(), match(), matches(), OCompletionPrivate::matches, multipleMatches(), myCompletionMode, myCurrentMatch, myHasMultipleMatches, myLastMatch, myLastString, myRotationIndex, NoMatch, QString::null, postProcessMatch(), and postProcessMatches(). Referenced by OLineEdit::makeCompletion(), and slotMakeCompletion(). |
|
|
The matching item. Will be emitted by makeCompletion(), previousMatch() or nextMatch(). May be QString::null if there is no matching item. Referenced by makeCompletion(), nextMatch(), and previousMatch(). |
|
|
All matching items. Will be emitted by makeCompletion() in shell- completion-mode, when the same string is passed to makeCompletion twice or more often. Referenced by allMatches(), allWeightedMatches(), makeCompletion(), nextMatch(), previousMatch(), and substringCompletion(). |
|
|
This signal is emitted, when calling makeCompletion() and more than one matching item is found.
Referenced by makeCompletion(). |
|
|
Definition at line 535 of file ocompletion.cpp. References QValueList< T >::count(), d, doBeep(), findAllCompletions(), OCompletionMatchesWrapper::first(), OCompletionMatchesWrapper::isEmpty(), OCompletionMatchesWrapper::list(), match(), matches(), OCompletionPrivate::matches, myCurrentMatch, myHasMultipleMatches, myLastMatch, myLastString, myRotationIndex, postProcessMatch(), and Rotation. Referenced by OLineEdit::rotateText(), and slotNextMatch(). |
|
|
Definition at line 303 of file ocompletion.h. References myOrder. |
|
|
This method is called after a completion is found and before the matching string is emitted. You can override this method to modify the string that will be emitted. This is necessary e.g. in OURLCompletion(), where files with spaces in their names are shown escaped ("filename\ with\ spaces"), but stored unescaped inside OCompletion. Never delete that pointer! Default implementation does nothing.
Definition at line 488 of file ocompletion.h. Referenced by makeCompletion(), nextMatch(), previousMatch(), and substringCompletion(). |
|
|
This method is called before a list of all available completions is emitted via matches. You can override this method to modify the found items before match() or matches() are emitted. Never delete that pointer! Default implementation does nothing.
Definition at line 510 of file ocompletion.h. |
|
|
This method is called before a list of all available completions is emitted via matches. You can override this method to modify the found items before match() or matches() are emitted. Never delete that pointer! Default implementation does nothing.
Definition at line 499 of file ocompletion.h. Referenced by allMatches(), allWeightedMatches(), makeCompletion(), and substringCompletion(). |
|
|
Definition at line 568 of file ocompletion.cpp. References QValueList< T >::count(), d, doBeep(), findAllCompletions(), OCompletionMatchesWrapper::isEmpty(), OCompletionMatchesWrapper::last(), OCompletionMatchesWrapper::list(), match(), matches(), OCompletionPrivate::matches, myCurrentMatch, myHasMultipleMatches, myLastMatch, myLastString, myRotationIndex, postProcessMatch(), and Rotation. Referenced by OLineEdit::rotateText(), and slotPreviousMatch(). |
|
|
Removes an item from the list of available completions. Resets the current item-state (previousMatch() and nextMatch() won't work anymore). Definition at line 357 of file ocompletion.cpp. References OCompletionMatchesWrapper::clear(), d, OCompletionPrivate::matches, myLastString, myRotationIndex, myTreeRoot, QString::null, and OCompTreeNode::remove(). |
|
|
Sets the completion mode to Auto/Manual, Shell or None. If you don't set the mode explicitly, the global default value OGlobalSettings::completionMode() is used. OGlobalSettings::CompletionNone disables completion.
Definition at line 478 of file ocompletion.cpp. References myCompletionMode. |
|
|
Enables/disables playing a sound when
Definition at line 363 of file ocompletion.h. References myBeep. |
|
|
Setting this to true makes OCompletion behave case insensitively. E.g. makeCompletion( "CA" ); might return "carp@cs.tu-berlin.de". Default is false (case sensitive).
Definition at line 259 of file ocompletion.cpp. References myIgnoreCase. |
|
|
Sets the list of items available for completion. Removes all previous items. Notice: when order() == Weighted, then the weighting is looked up for every item in the stringlist. Every item should have ":number" appended, where number is an unsigned integer, specifying the weighting. If you don't like this, call setOrder( OCompletion::Insertion ) before calling setItems().
Definition at line 265 of file ocompletion.cpp. References clear(), and insertItems(). Referenced by OpieUIDemo::demoOComboBox(), OpieUIDemo::demoOEditListBox(), OpieUIDemo::demoOLineEdit(), and OHistoryCombo::setHistoryItems(). |
|
|
OCompletion offers three different ways in which it offers its items:
Note: Setting the order to sorted only affects new inserted items, already existing items will stay in the current order. So you probably want to call setOrder( Sorted ) before inserting items, when you want everything sorted. Default is insertion order
Definition at line 252 of file ocompletion.cpp. References d, OCompletionPrivate::matches, myOrder, OCompletionMatchesWrapper::setSorting(), and Weighted. Referenced by OCompletion(), and OHistoryCombo::setHistoryItems(). |
|
|
Attempts to complete "string" and emits the completion via match(). Same as makeCompletion() (just as a slot).
Definition at line 385 of file ocompletion.h. References makeCompletion(). |
|
|
Searches the next matching item and emits it via match() Same as nextMatch() (just as a slot).
Definition at line 399 of file ocompletion.h. References nextMatch(). |
|
|
Searches the previous matching item and emits it via match() Same as previousMatch() (just as a slot).
Definition at line 392 of file ocompletion.h. References previousMatch(). |
|
|
Definition at line 439 of file ocompletion.cpp. References QValueList< T >::append(), QValueList< T >::begin(), doBeep(), QValueList< T >::end(), extractStringsFromNode(), QString::find(), QString::isEmpty(), QValueList< T >::isEmpty(), OCompletionMatchesWrapper::list(), matches(), myOrder, myTreeRoot, NoMatch, QString::null, postProcessMatch(), postProcessMatches(), and Weighted. |
|
|
Definition at line 543 of file ocompletion.h. Referenced by addItem(), clear(), makeCompletion(), nextMatch(), OCompletion(), previousMatch(), removeItem(), setOrder(), and ~OCompletion(). |
|
|
Definition at line 537 of file ocompletion.h. Referenced by doBeep(), isSoundsEnabled(), OCompletion(), and setEnableSounds(). |
|
|
Definition at line 529 of file ocompletion.h. Referenced by completionMode(), doBeep(), findCompletion(), makeCompletion(), OCompletion(), and setCompletionMode(). |
|
|
Definition at line 534 of file ocompletion.h. Referenced by makeCompletion(), nextMatch(), and previousMatch(). |
|
|
Definition at line 539 of file ocompletion.h. Referenced by findCompletion(), hasMultipleMatches(), makeCompletion(), nextMatch(), OCompletion(), and previousMatch(). |
|
|
Definition at line 538 of file ocompletion.h. Referenced by findAllCompletions(), ignoreCase(), OCompletion(), and setIgnoreCase(). |
|
|
Definition at line 533 of file ocompletion.h. Referenced by lastMatch(), makeCompletion(), nextMatch(), and previousMatch(). |
|
|
Definition at line 532 of file ocompletion.h. Referenced by addItem(), allMatches(), allWeightedMatches(), clear(), makeCompletion(), nextMatch(), previousMatch(), and removeItem(). |
|
|
Definition at line 531 of file ocompletion.h. Referenced by addItem(), addWeightedItem(), allMatches(), allWeightedMatches(), findCompletion(), insertItems(), order(), setOrder(), and substringCompletion(). |
|
|
Definition at line 540 of file ocompletion.h. Referenced by addItem(), clear(), findCompletion(), makeCompletion(), nextMatch(), OCompletion(), previousMatch(), and removeItem(). |
|
|
Definition at line 536 of file ocompletion.h. |
|
|
Definition at line 535 of file ocompletion.h. Referenced by addItem(), clear(), findAllCompletions(), findCompletion(), OCompletion(), removeItem(), substringCompletion(), and ~OCompletion(). |
|
|
Definition at line 159 of file ocompletion.h. |
|
|
Definition at line 160 of file ocompletion.h. |
|
|
Definition at line 158 of file ocompletion.h. |
1.4.2