Communi  3.5.0
A cross-platform IRC framework written with Qt
Public Slots | Signals | Public Member Functions | Properties | List of all members
IrcCompleter Class Reference

Provides command and name completion. More...

Inherits QObject.

Public Slots

void complete (const QString &text, int cursor, Direction direction=Forward)
 
void reset ()
 

Signals

void completed (const QString &text, int cursor)
 

Public Member Functions

 IrcCompleter (QObject *parent=0)
 
virtual ~IrcCompleter ()
 

Properties

IrcBuffer buffer
 
IrcCommandParser parser
 
QString suffix
 

Detailed Description

Since
3.1

IrcCompleter provides command and name completion for a text input field. The completer is made context aware by assigning a command parser and a buffer that is currently active in the GUI. The parser is used for completing commands, and the buffer is used for completing buffer and user names.

In order to perform a completion, call complete() with the current text input field content and the cursor position. If a suitable completion is found, the completed() signal is emitted with a suggestion for a new content and cursor position for the text input field.

TextField {
id: textField
Keys.onTabPressed: completer.complete(text, cursorPosition)
id: completer
buffer: ...
parser: ...
onCompleted: {
textField.text = text
textField.cursorPosition = cursor
}
}
}
See also
IrcCommandParser, IrcBuffer

Constructor & Destructor Documentation

IrcCompleter::IrcCompleter ( QObject parent = 0)
explicit

Constructs a completer with parent.

IrcCompleter::~IrcCompleter ( )
virtual

Destructs the completer.

Member Function Documentation

void IrcCompleter::complete ( const QString text,
int  cursor,
Direction  direction = Forward 
)
slot

Completes text at cursor position, iterating multiple matches to the specified direction, and emits completed() if a suitable completion is found.

void IrcCompleter::completed ( const QString text,
int  cursor 
)
signal

This signal is emitted when a suitable completion with text and cursor position is found.

void IrcCompleter::reset ( )
slot

Resets the completer state.

Property Documentation

IrcBuffer * IrcCompleter::buffer
readwrite

This property holds the buffer used for name completion.

Access functions:
Notifier signal:
IrcCommandParser * IrcCompleter::parser
readwrite

This property holds the parser used for command completion.

Access functions:
Notifier signal:
QString IrcCompleter::suffix
readwrite

This property holds the completion suffix.

The suffix is appended to the end of a completed nick name, but only when the nick name is in the beginning of completed text.

The default value is ":".

Access functions:
Notifier signal:
  • void suffixChanged(const QString& suffix)