HistoryCompleter: Fix current text() handling

Can be seen in the Debugger's "Command:" input: Selecting a
history entry with "Return" properly executes the selected
item, but put something else into the line edit.

Change-Id: I2efa05374d9c31e8a80219794f2dbaaf50a01f9b
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-07-07 15:04:52 +02:00
parent a4f5f7f748
commit b70377c872
4 changed files with 29 additions and 23 deletions

View File

@@ -299,8 +299,20 @@ bool FancyLineEdit::hasAutoHideButton(Side side) const
void FancyLineEdit::setHistoryCompleter(const QString &historyKey)
{
QTC_ASSERT(!d->m_historyCompleter, return);
d->m_historyCompleter = new HistoryCompleter(this, historyKey, this);
d->m_historyCompleter = new HistoryCompleter(historyKey, this);
QLineEdit::setCompleter(d->m_historyCompleter);
// Hitting <Return> in the popup first causes editingFinished()
// being emitted and more updates finally calling setText() (again).
// To make sure we report the "final" content delay the addEntry()
// "a bit".
connect(this, SIGNAL(editingFinished()),
this, SLOT(onEditingFinished()), Qt::QueuedConnection);
}
void FancyLineEdit::onEditingFinished()
{
d->m_historyCompleter->addEntry(text());
}
void FancyLineEdit::setSpecialCompleter(QCompleter *completer)