|
|
@ -32,11 +32,11 @@
|
|
|
|
#include <ksortablevaluelist.h>
|
|
|
|
#include <ksortablevaluelist.h>
|
|
|
|
#include <tdeshortcut.h>
|
|
|
|
#include <tdeshortcut.h>
|
|
|
|
|
|
|
|
|
|
|
|
class KCompTreeNode;
|
|
|
|
class TDECompTreeNode;
|
|
|
|
class KCompletionPrivate;
|
|
|
|
class TDECompletionPrivate;
|
|
|
|
class KCompletionBasePrivate;
|
|
|
|
class TDECompletionBasePrivate;
|
|
|
|
class KCompletionMatchesWrapper;
|
|
|
|
class TDECompletionMatchesWrapper;
|
|
|
|
class KCompletionMatches;
|
|
|
|
class TDECompletionMatches;
|
|
|
|
class TQPopupMenu;
|
|
|
|
class TQPopupMenu;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -49,13 +49,13 @@ class TQPopupMenu;
|
|
|
|
* The user should be able to complete email-addresses, telephone-numbers,
|
|
|
|
* The user should be able to complete email-addresses, telephone-numbers,
|
|
|
|
* commands, SQL queries, ...
|
|
|
|
* commands, SQL queries, ...
|
|
|
|
* Every time your program knows what the user can type into an edit-field, you
|
|
|
|
* Every time your program knows what the user can type into an edit-field, you
|
|
|
|
* should offer completion. With KCompletion, this is very easy, and if you are
|
|
|
|
* should offer completion. With TDECompletion, this is very easy, and if you are
|
|
|
|
* using a line edit widget ( KLineEdit), it is even more easy.
|
|
|
|
* using a line edit widget ( KLineEdit), it is even more easy.
|
|
|
|
* Basically, you tell a KCompletion object what strings should be completable
|
|
|
|
* Basically, you tell a TDECompletion object what strings should be completable
|
|
|
|
* and whenever completion should be invoked, you call makeCompletion().
|
|
|
|
* and whenever completion should be invoked, you call makeCompletion().
|
|
|
|
* KLineEdit and (an editable) KComboBox even do this automatically for you.
|
|
|
|
* KLineEdit and (an editable) KComboBox even do this automatically for you.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* KCompletion offers the completed string via the signal match() and
|
|
|
|
* TDECompletion offers the completed string via the signal match() and
|
|
|
|
* all matching strings (when the result is ambiguous) via the method
|
|
|
|
* all matching strings (when the result is ambiguous) via the method
|
|
|
|
* allMatches().
|
|
|
|
* allMatches().
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -75,11 +75,11 @@ class TQPopupMenu;
|
|
|
|
* subtle difference is, that it isn't invoked automatically while the user
|
|
|
|
* subtle difference is, that it isn't invoked automatically while the user
|
|
|
|
* is typing, but only when the user presses a special key. The difference
|
|
|
|
* is typing, but only when the user presses a special key. The difference
|
|
|
|
* of manual and auto-completion is therefore only visible in UI classes,
|
|
|
|
* of manual and auto-completion is therefore only visible in UI classes,
|
|
|
|
* KCompletion needs to know whether to deliver partial matches
|
|
|
|
* TDECompletion needs to know whether to deliver partial matches
|
|
|
|
* (shell completion) or whole matches (auto/manual completion), therefore
|
|
|
|
* (shell completion) or whole matches (auto/manual completion), therefore
|
|
|
|
* TDEGlobalSettings::CompletionMan and
|
|
|
|
* TDEGlobalSettings::CompletionMan and
|
|
|
|
* TDEGlobalSettings::CompletionAuto have the exact same effect in
|
|
|
|
* TDEGlobalSettings::CompletionAuto have the exact same effect in
|
|
|
|
* KCompletion.
|
|
|
|
* TDECompletion.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @li shell completion works like how shells complete filenames:
|
|
|
|
* @li shell completion works like how shells complete filenames:
|
|
|
|
* when multiple matches are available, the longest possible string of all
|
|
|
|
* when multiple matches are available, the longest possible string of all
|
|
|
@ -87,15 +87,15 @@ class TQPopupMenu;
|
|
|
|
* Iterating over all matching items (complete, not partial) is possible
|
|
|
|
* Iterating over all matching items (complete, not partial) is possible
|
|
|
|
* via nextMatch() and previousMatch().
|
|
|
|
* via nextMatch() and previousMatch().
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* You don't have to worry much about that though, KCompletion handles
|
|
|
|
* You don't have to worry much about that though, TDECompletion handles
|
|
|
|
* that for you, according to the setting setCompletionMode().
|
|
|
|
* that for you, according to the setting setCompletionMode().
|
|
|
|
* The default setting is globally configured by the user and read
|
|
|
|
* The default setting is globally configured by the user and read
|
|
|
|
* from TDEGlobalSettings::completionMode().
|
|
|
|
* from TDEGlobalSettings::completionMode().
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* A short example:
|
|
|
|
* A short example:
|
|
|
|
* \code
|
|
|
|
* \code
|
|
|
|
* KCompletion completion;
|
|
|
|
* TDECompletion completion;
|
|
|
|
* completion.setOrder( KCompletion::Sorted );
|
|
|
|
* completion.setOrder( TDECompletion::Sorted );
|
|
|
|
* completion.addItem( "pfeiffer@kde.org" );
|
|
|
|
* completion.addItem( "pfeiffer@kde.org" );
|
|
|
|
* completion.addItem( "coolo@kde.org" );
|
|
|
|
* completion.addItem( "coolo@kde.org" );
|
|
|
|
* completion.addItem( "carpdjih@sp.zrz.tu-berlin.de" );
|
|
|
|
* completion.addItem( "carpdjih@sp.zrz.tu-berlin.de" );
|
|
|
@ -113,23 +113,23 @@ class TQPopupMenu;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* You can dynamically update the completable items by removing and adding them
|
|
|
|
* You can dynamically update the completable items by removing and adding them
|
|
|
|
* whenever you want.
|
|
|
|
* whenever you want.
|
|
|
|
* For advanced usage, you could even use multiple KCompletion objects. E.g.
|
|
|
|
* For advanced usage, you could even use multiple TDECompletion objects. E.g.
|
|
|
|
* imagine an editor like kwrite with multiple open files. You could store
|
|
|
|
* 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
|
|
|
|
* items of each file in a different TDECompletion object, so that you know (and
|
|
|
|
* tell the user) where a completion comes from.
|
|
|
|
* tell the user) where a completion comes from.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Note: KCompletion does not work with strings that contain 0x0 characters
|
|
|
|
* Note: TDECompletion does not work with strings that contain 0x0 characters
|
|
|
|
* (unicode nul), as this is used internally as a delimiter.
|
|
|
|
* (unicode nul), as this is used internally as a delimiter.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* You may inherit from KCompletion and override makeCompletion() in
|
|
|
|
* You may inherit from TDECompletion and override makeCompletion() in
|
|
|
|
* special cases (like reading directories/urls and then supplying the
|
|
|
|
* special cases (like reading directories/urls and then supplying the
|
|
|
|
* contents to KCompletion, as KURLCompletion does), but generally, this is
|
|
|
|
* contents to TDECompletion, as KURLCompletion does), but generally, this is
|
|
|
|
* not necessary.
|
|
|
|
* not necessary.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Carsten Pfeiffer <pfeiffer@kde.org>
|
|
|
|
* @author Carsten Pfeiffer <pfeiffer@kde.org>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class TDECORE_EXPORT KCompletion : public TQObject
|
|
|
|
class TDECORE_EXPORT TDECompletion : public TQObject
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQ_ENUMS( CompOrder )
|
|
|
|
TQ_ENUMS( CompOrder )
|
|
|
|
TQ_PROPERTY( CompOrder order READ order WRITE setOrder )
|
|
|
|
TQ_PROPERTY( CompOrder order READ order WRITE setOrder )
|
|
|
@ -139,7 +139,7 @@ class TDECORE_EXPORT KCompletion : public TQObject
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Constants that represent the order in which KCompletion performs
|
|
|
|
* Constants that represent the order in which TDECompletion performs
|
|
|
|
* completion-lookups.
|
|
|
|
* completion-lookups.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
enum CompOrder { Sorted, ///< Use alphabetically sorted order
|
|
|
|
enum CompOrder { Sorted, ///< Use alphabetically sorted order
|
|
|
@ -150,14 +150,14 @@ public:
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Constructor, nothing special here :)
|
|
|
|
* Constructor, nothing special here :)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletion();
|
|
|
|
TDECompletion();
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: copy constructor, assignment operator...
|
|
|
|
// FIXME: copy constructor, assignment operator...
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Destructor, nothing special here, either.
|
|
|
|
* Destructor, nothing special here, either.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
virtual ~KCompletion();
|
|
|
|
virtual ~TDECompletion();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Attempts to find an item in the list of available completions,
|
|
|
|
* Attempts to find an item in the list of available completions,
|
|
|
@ -224,8 +224,8 @@ public:
|
|
|
|
virtual const TQString& lastMatch() const { return myLastMatch; }
|
|
|
|
virtual const TQString& lastMatch() const { return myLastMatch; }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns a list of all items inserted into KCompletion. This is useful
|
|
|
|
* Returns a list of all items inserted into TDECompletion. This is useful
|
|
|
|
* if you need to save the state of a KCompletion object and restore it
|
|
|
|
* if you need to save the state of a TDECompletion object and restore it
|
|
|
|
* later.
|
|
|
|
* later.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Important note: when order() == Weighted, then every item in the
|
|
|
|
* Important note: when order() == Weighted, then every item in the
|
|
|
@ -235,7 +235,7 @@ public:
|
|
|
|
* This is necessary so that you can save the items along with its
|
|
|
|
* This is necessary so that you can save the items along with its
|
|
|
|
* weighting on disk and load them back with setItems(), restoring 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
|
|
|
|
* weight as well. If you really don't want the appended weightings, call
|
|
|
|
* setOrder( KCompletion::Insertion )
|
|
|
|
* setOrder( TDECompletion::Insertion )
|
|
|
|
* before calling items().
|
|
|
|
* before calling items().
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return a list of all items
|
|
|
|
* @return a list of all items
|
|
|
@ -271,12 +271,12 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* KCompletion offers three different ways in which it offers its items:
|
|
|
|
* TDECompletion offers three different ways in which it offers its items:
|
|
|
|
* @li in the order of insertion
|
|
|
|
* @li in the order of insertion
|
|
|
|
* @li sorted alphabetically
|
|
|
|
* @li sorted alphabetically
|
|
|
|
* @li weighted
|
|
|
|
* @li weighted
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Choosing weighted makes KCompletion perform an implicit weighting based
|
|
|
|
* Choosing weighted makes TDECompletion perform an implicit weighting based
|
|
|
|
* on how often an item is inserted. Imagine a web browser with a location
|
|
|
|
* on how often an item is inserted. Imagine a web browser with a location
|
|
|
|
* bar, where the user enters URLs. The more often a URL is entered, the
|
|
|
|
* bar, where the user enters URLs. The more often a URL is entered, the
|
|
|
|
* higher priority it gets.
|
|
|
|
* higher priority it gets.
|
|
|
@ -300,7 +300,7 @@ public:
|
|
|
|
CompOrder order() const { return myOrder; }
|
|
|
|
CompOrder order() const { return myOrder; }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Setting this to true makes KCompletion behave case insensitively.
|
|
|
|
* Setting this to true makes TDECompletion behave case insensitively.
|
|
|
|
* E.g. makeCompletion( "CA" ); might return "carp\@cs.tu-berlin.de".
|
|
|
|
* E.g. makeCompletion( "CA" ); might return "carp\@cs.tu-berlin.de".
|
|
|
|
* Default is false (case sensitive).
|
|
|
|
* Default is false (case sensitive).
|
|
|
|
* @param ignoreCase true to ignore the case
|
|
|
|
* @param ignoreCase true to ignore the case
|
|
|
@ -309,7 +309,7 @@ public:
|
|
|
|
virtual void setIgnoreCase( bool ignoreCase );
|
|
|
|
virtual void setIgnoreCase( bool ignoreCase );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Return whether KCompletion acts case insensitively or not.
|
|
|
|
* Return whether TDECompletion acts case insensitively or not.
|
|
|
|
* Default is false (case sensitive).
|
|
|
|
* Default is false (case sensitive).
|
|
|
|
* @return true if the case will be ignored
|
|
|
|
* @return true if the case will be ignored
|
|
|
|
* @see setIgnoreCase
|
|
|
|
* @see setIgnoreCase
|
|
|
@ -334,7 +334,7 @@ public:
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns a list of all items matching the last completed string.
|
|
|
|
* Returns a list of all items matching the last completed string.
|
|
|
|
* Might take some time, when you have LOTS of items.
|
|
|
|
* Might take some time, when you have LOTS of items.
|
|
|
|
* The matches are returned as KCompletionMatches, which also
|
|
|
|
* The matches are returned as TDECompletionMatches, which also
|
|
|
|
* keeps the weight of the matches, allowing
|
|
|
|
* keeps the weight of the matches, allowing
|
|
|
|
* you to modify some matches or merge them with matches
|
|
|
|
* you to modify some matches or merge them with matches
|
|
|
|
* from another call to allWeightedMatches(), and sort the matches
|
|
|
|
* from another call to allWeightedMatches(), and sort the matches
|
|
|
@ -343,14 +343,14 @@ public:
|
|
|
|
* @return a list of all completion matches
|
|
|
|
* @return a list of all completion matches
|
|
|
|
* @see substringCompletion
|
|
|
|
* @see substringCompletion
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletionMatches allWeightedMatches();
|
|
|
|
TDECompletionMatches allWeightedMatches();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns a list of all items matching @p string.
|
|
|
|
* Returns a list of all items matching @p string.
|
|
|
|
* @param string the string to match
|
|
|
|
* @param string the string to match
|
|
|
|
* @return a list of all matches
|
|
|
|
* @return a list of all matches
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletionMatches allWeightedMatches( const TQString& string );
|
|
|
|
TDECompletionMatches allWeightedMatches( const TQString& string );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Enables/disables playing a sound when
|
|
|
|
* Enables/disables playing a sound when
|
|
|
@ -368,7 +368,7 @@ public:
|
|
|
|
virtual void setEnableSounds( bool enable ) { myBeep = enable; }
|
|
|
|
virtual void setEnableSounds( bool enable ) { myBeep = enable; }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tells you whether KCompletion will play sounds on certain occasions.
|
|
|
|
* Tells you whether TDECompletion will play sounds on certain occasions.
|
|
|
|
* Default is enabled.
|
|
|
|
* Default is enabled.
|
|
|
|
* @return true if sounds are enabled
|
|
|
|
* @return true if sounds are enabled
|
|
|
|
* @see enableSounds
|
|
|
|
* @see enableSounds
|
|
|
@ -444,7 +444,7 @@ public slots:
|
|
|
|
* where number is an unsigned integer, specifying the weighting.
|
|
|
|
* where number is an unsigned integer, specifying the weighting.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* If you don't like this, call
|
|
|
|
* If you don't like this, call
|
|
|
|
* setOrder( KCompletion::Insertion )
|
|
|
|
* setOrder( TDECompletion::Insertion )
|
|
|
|
* before calling setItems().
|
|
|
|
* before calling setItems().
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param list the list of items that are available for completion
|
|
|
|
* @param list the list of items that are available for completion
|
|
|
@ -518,7 +518,7 @@ protected:
|
|
|
|
* string that will be emitted.
|
|
|
|
* string that will be emitted.
|
|
|
|
* This is necessary e.g. in KURLCompletion(), where files with spaces
|
|
|
|
* This is necessary e.g. in KURLCompletion(), where files with spaces
|
|
|
|
* in their names are shown escaped ("filename\ with\ spaces"), but stored
|
|
|
|
* in their names are shown escaped ("filename\ with\ spaces"), but stored
|
|
|
|
* unescaped inside KCompletion.
|
|
|
|
* unescaped inside TDECompletion.
|
|
|
|
* Never delete that pointer!
|
|
|
|
* Never delete that pointer!
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Default implementation does nothing.
|
|
|
|
* Default implementation does nothing.
|
|
|
@ -549,23 +549,23 @@ protected:
|
|
|
|
* @param matches the matches to process
|
|
|
|
* @param matches the matches to process
|
|
|
|
* @see postProcessMatch
|
|
|
|
* @see postProcessMatch
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
virtual void postProcessMatches( KCompletionMatches * matches ) const {Q_UNUSED(matches)}
|
|
|
|
virtual void postProcessMatches( TDECompletionMatches * matches ) const {Q_UNUSED(matches)}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
void addWeightedItem( const TQString& );
|
|
|
|
void addWeightedItem( const TQString& );
|
|
|
|
TQString findCompletion( const TQString& string );
|
|
|
|
TQString findCompletion( const TQString& string );
|
|
|
|
void findAllCompletions( const TQString&,
|
|
|
|
void findAllCompletions( const TQString&,
|
|
|
|
KCompletionMatchesWrapper *matches,
|
|
|
|
TDECompletionMatchesWrapper *matches,
|
|
|
|
bool& hasMultipleMatches ) const;
|
|
|
|
bool& hasMultipleMatches ) const;
|
|
|
|
|
|
|
|
|
|
|
|
void extractStringsFromNode( const KCompTreeNode *,
|
|
|
|
void extractStringsFromNode( const TDECompTreeNode *,
|
|
|
|
const TQString& beginning,
|
|
|
|
const TQString& beginning,
|
|
|
|
KCompletionMatchesWrapper *matches,
|
|
|
|
TDECompletionMatchesWrapper *matches,
|
|
|
|
bool addWeight = false ) const;
|
|
|
|
bool addWeight = false ) const;
|
|
|
|
void extractStringsFromNodeCI( const KCompTreeNode *,
|
|
|
|
void extractStringsFromNodeCI( const TDECompTreeNode *,
|
|
|
|
const TQString& beginning,
|
|
|
|
const TQString& beginning,
|
|
|
|
const TQString& restString,
|
|
|
|
const TQString& restString,
|
|
|
|
KCompletionMatchesWrapper *matches) const;
|
|
|
|
TDECompletionMatchesWrapper *matches) const;
|
|
|
|
|
|
|
|
|
|
|
|
enum BeepMode { NoMatch, PartialMatch, Rotation };
|
|
|
|
enum BeepMode { NoMatch, PartialMatch, Rotation };
|
|
|
|
void doBeep( BeepMode ) const;
|
|
|
|
void doBeep( BeepMode ) const;
|
|
|
@ -576,7 +576,7 @@ private:
|
|
|
|
TQString myLastString;
|
|
|
|
TQString myLastString;
|
|
|
|
TQString myLastMatch;
|
|
|
|
TQString myLastMatch;
|
|
|
|
TQString myCurrentMatch;
|
|
|
|
TQString myCurrentMatch;
|
|
|
|
KCompTreeNode * myTreeRoot;
|
|
|
|
TDECompTreeNode * myTreeRoot;
|
|
|
|
TQStringList myRotations;
|
|
|
|
TQStringList myRotations;
|
|
|
|
bool myBeep;
|
|
|
|
bool myBeep;
|
|
|
|
bool myIgnoreCase;
|
|
|
|
bool myIgnoreCase;
|
|
|
@ -587,15 +587,15 @@ private:
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
virtual void virtual_hook( int id, void* data );
|
|
|
|
virtual void virtual_hook( int id, void* data );
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
KCompletionPrivate *d;
|
|
|
|
TDECompletionPrivate *d;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// some more helper stuff
|
|
|
|
// some more helper stuff
|
|
|
|
typedef KSortableValueList<TQString> KCompletionMatchesList;
|
|
|
|
typedef KSortableValueList<TQString> TDECompletionMatchesList;
|
|
|
|
class KCompletionMatchesPrivate;
|
|
|
|
class TDECompletionMatchesPrivate;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This structure is returned by KCompletion::allWeightedMatches .
|
|
|
|
* This structure is returned by TDECompletion::allWeightedMatches .
|
|
|
|
* It also keeps the weight of the matches, allowing
|
|
|
|
* It also keeps the weight of the matches, allowing
|
|
|
|
* you to modify some matches or merge them with matches
|
|
|
|
* you to modify some matches or merge them with matches
|
|
|
|
* from another call to allWeightedMatches(), and sort the matches
|
|
|
|
* from another call to allWeightedMatches(), and sort the matches
|
|
|
@ -603,24 +603,24 @@ class KCompletionMatchesPrivate;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Example (a simplified example of what Konqueror's completion does):
|
|
|
|
* Example (a simplified example of what Konqueror's completion does):
|
|
|
|
* \code
|
|
|
|
* \code
|
|
|
|
* KCompletionMatches matches = completion->allWeightedMatches( location );
|
|
|
|
* TDECompletionMatches matches = completion->allWeightedMatches( location );
|
|
|
|
* if( !location.startsWith( "www." ))
|
|
|
|
* if( !location.startsWith( "www." ))
|
|
|
|
matches += completion->allWeightedmatches( "www." + location" );
|
|
|
|
matches += completion->allWeightedmatches( "www." + location" );
|
|
|
|
* matches.removeDuplicates();
|
|
|
|
* matches.removeDuplicates();
|
|
|
|
* TQStringList list = matches.list();
|
|
|
|
* TQStringList list = matches.list();
|
|
|
|
* \endcode
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @short List for keeping matches returned from KCompletion
|
|
|
|
* @short List for keeping matches returned from TDECompletion
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class TDECORE_EXPORT KCompletionMatches : public KCompletionMatchesList
|
|
|
|
class TDECORE_EXPORT TDECompletionMatches : public TDECompletionMatchesList
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
KCompletionMatches( bool sort );
|
|
|
|
TDECompletionMatches( bool sort );
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletionMatches( const KCompletionMatchesWrapper& matches );
|
|
|
|
TDECompletionMatches( const TDECompletionMatchesWrapper& matches );
|
|
|
|
~KCompletionMatches();
|
|
|
|
~TDECompletionMatches();
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Removes duplicate matches. Needed only when you merged several matches
|
|
|
|
* Removes duplicate matches. Needed only when you merged several matches
|
|
|
|
* results and there's a possibility of duplicates.
|
|
|
|
* results and there's a possibility of duplicates.
|
|
|
@ -643,7 +643,7 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
bool _sorting;
|
|
|
|
bool _sorting;
|
|
|
|
KCompletionMatchesPrivate* d;
|
|
|
|
TDECompletionMatchesPrivate* d;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -660,7 +660,7 @@ private:
|
|
|
|
* @short An abstract class for adding text completion support to widgets.
|
|
|
|
* @short An abstract class for adding text completion support to widgets.
|
|
|
|
* @author Dawit Alemayehu <adawit@kde.org>
|
|
|
|
* @author Dawit Alemayehu <adawit@kde.org>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class TDECORE_EXPORT KCompletionBase
|
|
|
|
class TDECORE_EXPORT TDECompletionBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -694,12 +694,12 @@ public:
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Default constructor.
|
|
|
|
* Default constructor.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletionBase();
|
|
|
|
TDECompletionBase();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Destructor.
|
|
|
|
* Destructor.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
virtual ~KCompletionBase();
|
|
|
|
virtual ~TDECompletionBase();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns a pointer to the current completion object.
|
|
|
|
* Returns a pointer to the current completion object.
|
|
|
@ -716,7 +716,7 @@ public:
|
|
|
|
* @param hsig if true, handles completion signals internally.
|
|
|
|
* @param hsig if true, handles completion signals internally.
|
|
|
|
* @return a pointer the completion object.
|
|
|
|
* @return a pointer the completion object.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletion* completionObject( bool hsig = true );
|
|
|
|
TDECompletion* completionObject( bool hsig = true );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Sets up the completion object to be used.
|
|
|
|
* Sets up the completion object to be used.
|
|
|
@ -731,10 +731,10 @@ public:
|
|
|
|
* after calling this method. Be sure to set the bool argument to false, if
|
|
|
|
* after calling this method. Be sure to set the bool argument to false, if
|
|
|
|
* you want to handle the completion signals yourself.
|
|
|
|
* you want to handle the completion signals yourself.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param compObj a KCompletion() or a derived child object.
|
|
|
|
* @param compObj a TDECompletion() or a derived child object.
|
|
|
|
* @param hsig if true, handles completion signals internally.
|
|
|
|
* @param hsig if true, handles completion signals internally.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
virtual void setCompletionObject( KCompletion* compObj, bool hsig = true );
|
|
|
|
virtual void setCompletionObject( TDECompletion* compObj, bool hsig = true );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Enables this object to handle completion and rotation
|
|
|
|
* Enables this object to handle completion and rotation
|
|
|
@ -924,7 +924,7 @@ public:
|
|
|
|
* implementations to set completed text appropriately. It
|
|
|
|
* implementations to set completed text appropriately. It
|
|
|
|
* is mostly relevant when the completion mode is set to
|
|
|
|
* is mostly relevant when the completion mode is set to
|
|
|
|
* CompletionAuto and CompletionManual modes. See
|
|
|
|
* CompletionAuto and CompletionManual modes. See
|
|
|
|
* KCompletionBase::setCompletedText.
|
|
|
|
* TDECompletionBase::setCompletedText.
|
|
|
|
* Does nothing in CompletionPopup mode, as all available
|
|
|
|
* Does nothing in CompletionPopup mode, as all available
|
|
|
|
* matches will be shown in the popup.
|
|
|
|
* matches will be shown in the popup.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -943,14 +943,14 @@ public:
|
|
|
|
* Returns a pointer to the completion object.
|
|
|
|
* Returns a pointer to the completion object.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This method is only different from completionObject()
|
|
|
|
* This method is only different from completionObject()
|
|
|
|
* in that it does not create a new KCompletion object even if
|
|
|
|
* in that it does not create a new TDECompletion object even if
|
|
|
|
* the internal pointer is @p NULL. Use this method to get the
|
|
|
|
* the internal pointer is @p NULL. Use this method to get the
|
|
|
|
* pointer to a completion object when inheriting so that you
|
|
|
|
* pointer to a completion object when inheriting so that you
|
|
|
|
* won't inadvertently create it!!
|
|
|
|
* won't inadvertently create it!!
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return the completion object or NULL if one does not exist.
|
|
|
|
* @return the completion object or NULL if one does not exist.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletion* compObj() const { return m_delegate ? m_delegate->compObj() : (KCompletion*) m_pCompObj; }
|
|
|
|
TDECompletion* compObj() const { return m_delegate ? m_delegate->compObj() : (TDECompletion*) m_pCompObj; }
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -968,14 +968,14 @@ protected:
|
|
|
|
* set, all function calls will be forwarded to the delegation object.
|
|
|
|
* set, all function calls will be forwarded to the delegation object.
|
|
|
|
* @param delegate the delegation object, or 0 to remove it
|
|
|
|
* @param delegate the delegation object, or 0 to remove it
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void setDelegate( KCompletionBase *delegate );
|
|
|
|
void setDelegate( TDECompletionBase *delegate );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the delegation object.
|
|
|
|
* Returns the delegation object.
|
|
|
|
* @return the delegation object, or 0 if there is none
|
|
|
|
* @return the delegation object, or 0 if there is none
|
|
|
|
* @see setDelegate()
|
|
|
|
* @see setDelegate()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
KCompletionBase *delegate() const { return m_delegate; }
|
|
|
|
TDECompletionBase *delegate() const { return m_delegate; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
// This method simply sets the autodelete boolean for
|
|
|
|
// This method simply sets the autodelete boolean for
|
|
|
@ -994,17 +994,17 @@ private:
|
|
|
|
// Stores the completion mode locally.
|
|
|
|
// Stores the completion mode locally.
|
|
|
|
TDEGlobalSettings::Completion m_iCompletionMode;
|
|
|
|
TDEGlobalSettings::Completion m_iCompletionMode;
|
|
|
|
// Pointer to Completion object.
|
|
|
|
// Pointer to Completion object.
|
|
|
|
TQGuardedPtr<KCompletion> m_pCompObj;
|
|
|
|
TQGuardedPtr<TDECompletion> m_pCompObj;
|
|
|
|
// Keybindings
|
|
|
|
// Keybindings
|
|
|
|
KeyBindingMap m_keyMap;
|
|
|
|
KeyBindingMap m_keyMap;
|
|
|
|
// we may act as a proxy to another KCompletionBase object
|
|
|
|
// we may act as a proxy to another TDECompletionBase object
|
|
|
|
KCompletionBase *m_delegate;
|
|
|
|
TDECompletionBase *m_delegate;
|
|
|
|
|
|
|
|
|
|
|
|
// BCI
|
|
|
|
// BCI
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
virtual void virtual_hook( int id, void* data );
|
|
|
|
virtual void virtual_hook( int id, void* data );
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
KCompletionBasePrivate *d;
|
|
|
|
TDECompletionBasePrivate *d;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // KCOMPLETION_H
|
|
|
|
#endif // KCOMPLETION_H
|
|
|
|