From 66fe29003342b941e915b897e0e0905883e4aee9 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Sat, 9 Jan 2016 18:49:44 +0000 Subject: [PATCH] refs #567 CStatusMessageList::setCategories and related methods. --- src/blackmisc/statusmessage.h | 6 ++++++ src/blackmisc/statusmessagelist.cpp | 16 ++++++++++++++++ src/blackmisc/statusmessagelist.h | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/src/blackmisc/statusmessage.h b/src/blackmisc/statusmessage.h index 005080fb3..5cacc75eb 100644 --- a/src/blackmisc/statusmessage.h +++ b/src/blackmisc/statusmessage.h @@ -129,6 +129,12 @@ namespace BlackMisc //! Add categories void addCategories(const CLogCategoryList &categories) { this->m_categories.push_back(categories); } + //! Reset category + void setCategory(const CLogCategory &category) { this->m_categories = CLogCategoryList { category }; } + + //! Reset categories + void setCategories(const CLogCategoryList &categories) { this->m_categories = categories; } + //! Representing icon CIcon toIcon() const { return convertToIcon(*this); } diff --git a/src/blackmisc/statusmessagelist.cpp b/src/blackmisc/statusmessagelist.cpp index 995a0b052..2d14bc8bf 100644 --- a/src/blackmisc/statusmessagelist.cpp +++ b/src/blackmisc/statusmessagelist.cpp @@ -58,6 +58,22 @@ namespace BlackMisc } } + void CStatusMessageList::setCategory(const CLogCategory &category) + { + for (auto &msg : *this) + { + msg.setCategory(category); + } + } + + void CStatusMessageList::setCategories(const CLogCategoryList &categories) + { + for (auto &msg : *this) + { + msg.setCategories(categories); + } + } + CStatusMessageList CStatusMessageList::fromDatabaseJson(const QJsonArray &array) { CStatusMessageList messages; diff --git a/src/blackmisc/statusmessagelist.h b/src/blackmisc/statusmessagelist.h index 3a5608ffb..57f3144f8 100644 --- a/src/blackmisc/statusmessagelist.h +++ b/src/blackmisc/statusmessagelist.h @@ -58,6 +58,12 @@ namespace BlackMisc //! Add some categories to all messages in the list void addCategories(const CLogCategoryList &categories); + //! Reset the category of all messages in the list + void setCategory(const CLogCategory &category); + + //! Reset the categories of all messages in the list + void setCategories(const CLogCategoryList &categories); + //! From our database JSON format static CStatusMessageList fromDatabaseJson(const QJsonArray &array); };