diff --git a/src/lib/definition.h b/src/lib/definition.h --- a/src/lib/definition.h +++ b/src/lib/definition.h @@ -333,6 +333,12 @@ */ QStringList keywordList(const QString& name) const; + /** + * Set content of keyword list with name @p name to @p content + * @since 5.62 + */ + bool setKeywordList(const QString& name, const QStringList& content); + /** * Returns a list of all Format items used by this definition. * The order of the Format items equals the order of the itemDatas in the xml file. diff --git a/src/lib/definition.cpp b/src/lib/definition.cpp --- a/src/lib/definition.cpp +++ b/src/lib/definition.cpp @@ -234,6 +234,19 @@ return list ? list->keywords() : QStringList(); } +bool Definition::setKeywordList(const QString& name, const QStringList& content) +{ + d->load(DefinitionData::OnlyKeywords(true)); + KeywordList* list = d->keywordList(name); + if (list) + { + list->setKeywordList(content); + return true; + } + else + return false; +} + QVector Definition::formats() const { d->load(); diff --git a/src/lib/keywordlist_p.h b/src/lib/keywordlist_p.h --- a/src/lib/keywordlist_p.h +++ b/src/lib/keywordlist_p.h @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -60,6 +61,12 @@ return m_keywords; } + void setKeywordList(const QStringList& keywords) + { + m_keywords = keywords; + initLookupForCaseSensitivity(m_caseSensitive); + } + /** Checks if @p str is a keyword in this list. */ bool contains(const QStringRef &str) const {