From 2b3058238a6798e5786f8e753c62e63bded0c424 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Tue, 16 Oct 2012 19:19:26 +0200 Subject: [PATCH] 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 Reviewed-by: hjk --- src/libs/utils/historycompleter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp index 19f0787e713..ff092dc04b4 100644 --- a/src/libs/utils/historycompleter.cpp +++ b/src/libs/utils/historycompleter.cpp @@ -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);