Commit 7bfd08e3 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Removed the completion item relevance

parent 7ee5ea0a
...@@ -492,19 +492,7 @@ void CompletionListView::setQuickFix(bool quickFix) ...@@ -492,19 +492,7 @@ void CompletionListView::setQuickFix(bool quickFix)
void CompletionListView::setCompletionItems(const QList<TextEditor::CompletionItem> &completionItems) void CompletionListView::setCompletionItems(const QList<TextEditor::CompletionItem> &completionItems)
{ {
m_model->setItems(completionItems); m_model->setItems(completionItems);
setCurrentIndex(m_model->index(0)); // Select the first item
// Select the first of the most relevant completion items
int relevance = INT_MIN;
int mostRelevantIndex = 0;
for (int i = 0; i < completionItems.size(); ++i) {
const CompletionItem &item = completionItems.at(i);
if (item.relevance > relevance) {
relevance = item.relevance;
mostRelevantIndex = i;
}
}
setCurrentIndex(m_model->index(mostRelevantIndex));
} }
void CompletionListView::closeList(const QModelIndex &index) void CompletionListView::closeList(const QModelIndex &index)
......
...@@ -207,20 +207,9 @@ void ICompletionCollector::filter(const QList<TextEditor::CompletionItem> &items ...@@ -207,20 +207,9 @@ void ICompletionCollector::filter(const QList<TextEditor::CompletionItem> &items
} }
const QRegExp regExp(keyRegExp); const QRegExp regExp(keyRegExp);
const bool hasKey = !key.isEmpty(); foreach (TextEditor::CompletionItem item, items)
foreach (TextEditor::CompletionItem item, items) { if (regExp.indexIn(item.text) == 0)
if (regExp.indexIn(item.text) == 0) {
if (hasKey) {
if (item.text.startsWith(key, Qt::CaseSensitive)) {
item.relevance = 2;
} else if (caseSensitivity != TextEditor::CaseSensitive
&& item.text.startsWith(key, Qt::CaseInsensitive)) {
item.relevance = 1;
}
}
filteredItems->append(item); filteredItems->append(item);
}
}
} }
bool ICompletionCollector::shouldRestartCompletion() bool ICompletionCollector::shouldRestartCompletion()
......
...@@ -54,8 +54,7 @@ class CompletionItem ...@@ -54,8 +54,7 @@ class CompletionItem
{ {
public: public:
CompletionItem(ICompletionCollector *collector = 0) CompletionItem(ICompletionCollector *collector = 0)
: relevance(0), : duplicateCount(0),
duplicateCount(0),
order(0), order(0),
originalIndex(0), originalIndex(0),
collector(collector), collector(collector),
...@@ -69,7 +68,6 @@ public: ...@@ -69,7 +68,6 @@ public:
QString details; QString details;
QIcon icon; QIcon icon;
QVariant data; QVariant data;
int relevance;
int duplicateCount; int duplicateCount;
int order; int order;
int originalIndex; int originalIndex;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment