525 void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, const QMatchData& m) |
525 void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, const QMatchData& m) |
526 { |
526 { |
527 QMatchData old = cache[parent].take(part); |
527 QMatchData old = cache[parent].take(part); |
528 cost = cost + m.indices.cost() - old.indices.cost(); |
528 cost = cost + m.indices.cost() - old.indices.cost(); |
529 if (cost * sizeof(int) > 1024 * 1024) { |
529 if (cost * sizeof(int) > 1024 * 1024) { |
530 QMap<QModelIndex, CacheItem>::iterator it1 ; |
530 QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin(); |
531 for (it1 = cache.begin(); it1 != cache.end(); ++it1) { |
531 while (it1 != cache.end()) { |
532 CacheItem& ci = it1.value(); |
532 CacheItem& ci = it1.value(); |
533 int sz = ci.count()/2; |
533 int sz = ci.count()/2; |
534 QMap<QString, QMatchData>::iterator it2 = ci.begin(); |
534 QMap<QString, QMatchData>::iterator it2 = ci.begin(); |
535 for (int i = 0; it2 != ci.end() && i < sz; i++, ++it2) { |
535 int i = 0; |
|
536 while (it2 != ci.end() && i < sz) { |
536 cost -= it2.value().indices.cost(); |
537 cost -= it2.value().indices.cost(); |
537 ci.erase(it2); |
538 it2 = ci.erase(it2); |
|
539 i++; |
538 } |
540 } |
539 if (ci.count() == 0) |
541 if (ci.count() == 0) { |
540 cache.erase(it1); |
542 it1 = cache.erase(it1); |
|
543 } else { |
|
544 ++it1; |
|
545 } |
541 } |
546 } |
542 } |
547 } |
543 |
548 |
544 if (c->cs == Qt::CaseInsensitive) |
549 if (c->cs == Qt::CaseInsensitive) |
545 part = part.toLower(); |
550 part = part.toLower(); |
1746 /*! |
1751 /*! |
1747 \fn void QCompleter::highlighted(const QString &text) |
1752 \fn void QCompleter::highlighted(const QString &text) |
1748 |
1753 |
1749 This signal is sent when an item in the popup() is highlighted by |
1754 This signal is sent when an item in the popup() is highlighted by |
1750 the user. It is also sent if complete() is called with the completionMode() |
1755 the user. It is also sent if complete() is called with the completionMode() |
1751 set to QCOmpleter::InlineCompletion. The item's \a text is given. |
1756 set to QCompleter::InlineCompletion. The item's \a text is given. |
1752 */ |
1757 */ |
1753 |
1758 |
1754 QT_END_NAMESPACE |
1759 QT_END_NAMESPACE |
1755 |
1760 |
1756 #include "moc_qcompleter.cpp" |
1761 #include "moc_qcompleter.cpp" |