Snippets: Add groupId getter/setter to SnippetAssistCollector

Handle unusual groupId settings more gracefully now that they are
more easy to change.

Change-Id: I80e46d62e8db9c866e7d68b3e601ce6841da53ab
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Tobias Hunger
2016-08-22 11:13:48 +02:00
parent da29da9bbd
commit 2f0c253b27
2 changed files with 17 additions and 1 deletions

View File

@@ -58,10 +58,23 @@ SnippetAssistCollector::SnippetAssistCollector(const QString &groupId, const QIc
, m_order(order)
{}
void SnippetAssistCollector::setGroupId(const QString &gid)
{
m_groupId = gid;
}
QString SnippetAssistCollector::groupId() const
{
return m_groupId;
}
QList<AssistProposalItemInterface *> SnippetAssistCollector::collect() const
{
QList<AssistProposalItemInterface *> snippets;
if (m_groupId.isEmpty())
return snippets;
appendSnippets(&snippets, m_groupId, m_icon, m_order);
appendSnippets(&snippets, QLatin1String(Constants::TEXT_SNIPPET_GROUP_ID), m_icon, m_order);
if (m_groupId != Constants::TEXT_SNIPPET_GROUP_ID)
appendSnippets(&snippets, Constants::TEXT_SNIPPET_GROUP_ID, m_icon, m_order);
return snippets;
}