forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user