BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MessageService.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Util/MessageService.cpp
6 //! @brief Implements MessageService class
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include <QObject>
17 
18 QStringList MessageService::descriptions(const Messages& messages, bool includeSenders) const
19 {
20  QStringList result;
21 
22  for (const auto& message : messages)
23  if (includeSenders)
24  result.push_back(message.first + ": " + message.second);
25  else
26  result.push_back(message.second);
27 
28  return result;
29 }
30 
31 void MessageService::addError(QObject* sender, const QString& description)
32 {
33  m_errors.append(qMakePair(sender->objectName(), description));
34 }
35 
36 void MessageService::addWarning(QObject* sender, const QString& description)
37 {
38  m_warnings.append(qMakePair(sender->objectName(), description));
39 }
40 
41 QStringList MessageService::errors(bool includeSenders /*= false*/) const
42 {
43  return descriptions(m_errors, includeSenders);
44 }
45 
46 QStringList MessageService::warnings(bool includeSenders /*= false*/) const
47 {
48  return descriptions(m_warnings, includeSenders);
49 }
Defines MessageService class.
QStringList descriptions(const Messages &messages, bool includeSenders) const
QList< QPair< QString, QString > > Messages
QStringList errors(bool includeSenders=false) const
QStringList warnings(bool includeSenders=false) const
void addWarning(QObject *sender, const QString &description)
void addError(QObject *sender, const QString &description)
Messages m_warnings
Messages m_errors