# eric4.Helpviewer.History.HistoryCompleter

Module implementing a special completer for the history.

### Global Attributes

None

### Classes

HistoryCompleter |
HistoryCompletionModel | Class implementing a special model for history based completions.
HistoryCompletionView | Class implementing a special completer view for history based completions.

### Functions

None

## HistoryCompleter

### Derived from

QCompleter

### Class Attributes

None

### Class Methods

None

### Methods

HistoryCompleter | Constructor
__updateFilter | Private slot to update the search string.
pathFromIndex | Public method to get a path for a given index.
splitPath | Public method to split the given path into strings, that are used to match at each level in the model.

### Static Methods

None

#### HistoryCompleter (Constructor)

HistoryCompleter(model, parent = None)

Constructor

model
  reference to the model (QAbstractItemModel)
parent
  reference to the parent object (QObject)

#### HistoryCompleter.__updateFilter

__updateFilter()

Private slot to update the search string.

#### HistoryCompleter.pathFromIndex

pathFromIndex(idx)

Public method to get a path for a given index.

idx
  reference to the index (QModelIndex)

Returns:
  the actual URL from the history (QString)

#### HistoryCompleter.splitPath

splitPath(path)

Public method to split the given path into strings, that are used to match at each level in the model.

path
  path to be split (QString)

Returns:
  list of path elements (QStringList)

Up

## HistoryCompletionModel

Class implementing a special model for history based completions.

### Derived from

QSortFilterProxyModel

### Class Attributes

HistoryCompletionRole

### Class Methods

None

### Methods

HistoryCompletionModel | Constructor
data | Public method to get data from the model.
filterAcceptsRow | Protected method to determine, if the row is acceptable.
isValid | Public method to check the model for validity.
lessThan | Protected method used to sort the displayed items.
searchString | Public method to get the current search string.
setSearchString | Public method to set the current search string.
setValid | Public method to set the model's validity.

### Static Methods

None

#### HistoryCompletionModel (Constructor)

HistoryCompletionModel(parent = None)

Constructor

parent
  reference to the parent object (QObject)

#### HistoryCompletionModel.data

data(index, role = Qt.DisplayRole)

Public method to get data from the model.

index
  index of history entry to get data for (QModelIndex)
role
  data role (integer)

Returns:
  history entry data (QVariant)

#### HistoryCompletionModel.filterAcceptsRow

filterAcceptsRow(sourceRow, sourceParent)

Protected method to determine, if the row is acceptable.

sourceRow
  row number in the source model (integer)
sourceParent
  index of the source item (QModelIndex)

Returns:
  flag indicating acceptance (boolean)

#### HistoryCompletionModel.isValid

isValid()

Public method to check the model for validity.

flag
  indicating a valid status (boolean)

#### HistoryCompletionModel.lessThan

lessThan(left, right)

Protected method used to sort the displayed items.

It implements a special sorting function based on the history entry's frequency giving a bonus to hits that match on a word boundary so that e.g. "dot.python-projects.org" is a better result for typing "dot" than "slashdot.org". However, it only looks for the string in the host name, not the entire URL, since while it makes sense to e.g. give "www.phoronix.com" a bonus for "ph", it does NOT make sense to give "www.yadda.com/foo.php" the bonus.

left
  index of left item (QModelIndex)
right
  index of right item (QModelIndex)

Returns:
  true, if left is less than right (boolean)

#### HistoryCompletionModel.searchString

searchString()

Public method to get the current search string.

Returns:
  current search string (QString)

#### HistoryCompletionModel.setSearchString

setSearchString(string)

Public method to set the current search string.

string
  new search string (QString)

#### HistoryCompletionModel.setValid

setValid(valid)

Public method to set the model's validity.

valid
  flag indicating the new valid status (boolean)

Up

## HistoryCompletionView

Class implementing a special completer view for history based completions.

### Derived from

QTableView

### Class Attributes

None

### Class Methods

None

### Methods

HistoryCompletionView | Constructor
resizeEvent | Protected method handling resize events.
sizeHintForRow | Public method to give a size hint for rows.

### Static Methods

None

#### HistoryCompletionView (Constructor)

HistoryCompletionView(parent = None)

Constructor

parent
  reference to the parent widget (QWidget)

#### HistoryCompletionView.resizeEvent

resizeEvent(evt)

Protected method handling resize events.

evt
  reference to the resize event (QResizeEvent)

#### HistoryCompletionView.sizeHintForRow

sizeHintForRow(row)

Public method to give a size hint for rows.

row
  row number (integer)

Up