CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Types | Public Member Functions | Protected Attributes | Properties | List of all members
ctkCompleter Class Reference

#include <Libs/Widgets/ctkCompleter.h>

Inheritance diagram for ctkCompleter:
Inheritance graph
[legend]
Collaboration diagram for ctkCompleter:
Collaboration graph
[legend]

Public Types

enum  ModelFiltering { FilterStartsWith =0 , FilterContains , FilterWordStartsWith }
 

Public Member Functions

 ctkCompleter (const QStringList &list, QObject *parent=0)
 
 ctkCompleter (QAbstractItemModel *model, QObject *parent=0)
 
 ctkCompleter (QObject *parent=0)
 
ModelFiltering modelFiltering () const
 
void setModelFiltering (ModelFiltering filter)
 
void setSourceModel (QAbstractItemModel *model)
 
QAbstractItemModel * sourceModel () const
 
virtual QStringList splitPath (const QString &s) const
 
virtual ~ctkCompleter ()
 

Protected Attributes

QScopedPointer< ctkCompleterPrivate > d_ptr
 

Properties

ModelFiltering modelFiltering
 

Detailed Description

ctkCompleter is a QCompleter that allows different way of filtering the model, not just by filtering strings that start with the

See also
completionPrefix (default behavior). ctkCompleter is a bit hackish as it reimplements a methods (splitPath) from QCompleter in a way that is not intended. Disclaimer, it might not work in all contexts, but seems to work fine with a QLineEdit. e.g.: QStringList model; model << "toto tata tutu"; model << "tata toto tutu"; ctkCompleter completer(model); completer.setModelFiltering(ctkCompleter::FilterWordStartsWith); QLineEdit lineEdit; lineEdit.setCompleter(&completer); ... If the user types "ta", both entries will show up in the completer If the user types "ot", no entries will show up in the completer however using
FilterContains would have shown both.

Definition at line 52 of file ctkCompleter.h.

Member Enumeration Documentation

◆ ModelFiltering

Enumerator
FilterStartsWith 
FilterContains 
FilterWordStartsWith 

Definition at line 71 of file ctkCompleter.h.

Constructor & Destructor Documentation

◆ ctkCompleter() [1/3]

ctkCompleter::ctkCompleter ( QObject *  parent = 0)

◆ ctkCompleter() [2/3]

ctkCompleter::ctkCompleter ( QAbstractItemModel *  model,
QObject *  parent = 0 
)

◆ ctkCompleter() [3/3]

ctkCompleter::ctkCompleter ( const QStringList &  list,
QObject *  parent = 0 
)

◆ ~ctkCompleter()

virtual ctkCompleter::~ctkCompleter ( )
virtual

Member Function Documentation

◆ modelFiltering()

ModelFiltering ctkCompleter::modelFiltering ( ) const

◆ setModelFiltering()

void ctkCompleter::setModelFiltering ( ModelFiltering  filter)

◆ setSourceModel()

void ctkCompleter::setSourceModel ( QAbstractItemModel *  model)

◆ sourceModel()

QAbstractItemModel* ctkCompleter::sourceModel ( ) const

ctkCompleter::model() might return a filtered model (QSortFilterAbstractModel) different from the one that was set. QCompleter::setModel should not be used and setSourceModel used instead.

◆ splitPath()

virtual QStringList ctkCompleter::splitPath ( const QString &  s) const
virtual

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkCompleterPrivate> ctkCompleter::d_ptr
protected

Definition at line 91 of file ctkCompleter.h.

Property Documentation

◆ modelFiltering

ModelFiltering ctkCompleter::modelFiltering
readwrite

FilterStartsWith is the default behavior (same as QCompleter).The completer filters out strings that don't start with

See also
completionPrefix FilterContains is the most permissive filter, the completer filters out only strings that don't contain the characters from
completionPrefix FilterWordStartsWith is useful when strings contain space separated words and
completionPrefix applies to the beginnig of any of the words in the string.

Definition at line 1 of file ctkCompleter.h.


The documentation for this class was generated from the following file: