HistoryCompleter: Keep list in order/allow empty entries

The HistoryCompleter ctor sets the initial lineedit value to the first
entry, thus adjust the code to store the most recent value, even if that
was already in the history.

Also allow empty entries in the history.

Change-Id: I1e88fb9eb1474896732d49583e5fc6b7acda0500
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Daniel Teske
2012-10-16 19:19:26 +02:00
committed by hjk
parent 59367be8d7
commit 2b3058238a

View File

@@ -146,10 +146,12 @@ void HistoryCompleterPrivate::clearHistory()
void HistoryCompleterPrivate::saveEntry(const QString &str)
{
QTC_ASSERT(theSettings, return);
if (str.isEmpty())
return;
if (list.contains(str))
return;
int removeIndex = list.indexOf(str);
if (removeIndex != -1) {
beginRemoveRows(QModelIndex(), removeIndex, removeIndex);
list.removeAt(removeIndex);
endRemoveRows();
}
beginInsertRows (QModelIndex(), list.count(), list.count());
list.prepend(str);
list = list.mid(0, maxLines);