forked from qt-creator/qt-creator
Improve code-assist API isSortable
Now IGenericProposalModel::isSortable also takes the current prefix as a parameter. This is particularly useful for cases like in the C++ completion: For global completions it will only sort if there's already a content prefix - Notice, however, that the "sorting threshold" for a maximum number of items is still kept in IGenericProposalModel::sort. Task-number: QTCREATORBUG-6404 Change-Id: I3c2f282aa565287b8b4989930b6a27093862ef25 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -183,16 +183,14 @@ class CppAssistProposalModel : public TextEditor::BasicProposalItemListModel
|
||||
public:
|
||||
CppAssistProposalModel()
|
||||
: TextEditor::BasicProposalItemListModel()
|
||||
, m_sortable(false)
|
||||
, m_completionOperator(T_EOF_SYMBOL)
|
||||
, m_replaceDotForArrow(false)
|
||||
, m_typeOfExpression(new TypeOfExpression)
|
||||
{}
|
||||
|
||||
virtual bool isSortable() const { return m_sortable; }
|
||||
virtual bool isSortable(const QString &prefix) const;
|
||||
virtual IAssistProposalItem *proposalItem(int index) const;
|
||||
|
||||
bool m_sortable;
|
||||
unsigned m_completionOperator;
|
||||
bool m_replaceDotForArrow;
|
||||
QSharedPointer<TypeOfExpression> m_typeOfExpression;
|
||||
@@ -229,6 +227,14 @@ private:
|
||||
|
||||
Q_DECLARE_METATYPE(CppTools::Internal::CompleteFunctionDeclaration)
|
||||
|
||||
bool CppAssistProposalModel::isSortable(const QString &prefix) const
|
||||
{
|
||||
if (m_completionOperator != T_EOF_SYMBOL)
|
||||
return true;
|
||||
|
||||
return !prefix.isEmpty();
|
||||
}
|
||||
|
||||
IAssistProposalItem *CppAssistProposalModel::proposalItem(int index) const
|
||||
{
|
||||
BasicProposalItem *item =
|
||||
@@ -699,10 +705,6 @@ IAssistProposal * CppCompletionAssistProcessor::perform(const IAssistInterface *
|
||||
if (m_hintProposal)
|
||||
return m_hintProposal;
|
||||
|
||||
if (m_model->m_completionOperator != T_EOF_SYMBOL)
|
||||
m_model->m_sortable = true;
|
||||
else
|
||||
m_model->m_sortable = false;
|
||||
return createContentProposal();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user