Completion: Don't propose when there's a "good" candidate

This also generalizes some code previously specific to C++.

Change-Id: I5774d04a45f28a4e276a0ef282ce0aa5a2f2e552
Reviewed-on: http://codereview.qt.nokia.com/48
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
Leandro Melo
2011-05-20 15:01:45 +02:00
committed by Leandro T. C. Melo
parent 1b374905f9
commit 0350314b22
3 changed files with 46 additions and 31 deletions

View File

@@ -241,14 +241,6 @@ QString BasicProposalItemListModel::proposalPrefix() const
// Compute common prefix
QString firstKey = m_currentItems.first()->text();
int ignore = 0;
for (int i = firstKey.length() - 1; i >= 0; --i, ++ignore) {
const QChar &c = firstKey.at(i);
if (c.isLetterOrNumber() || c == QLatin1Char('_'))
break;
}
if (ignore)
firstKey.chop(ignore);
QString lastKey = m_currentItems.last()->text();
const int length = qMin(firstKey.length(), lastKey.length());
firstKey.truncate(length);