BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MessageService Class Reference

Description

The service to collect messages from different senders.

Definition at line 27 of file MessageService.h.

Public Member Functions

void addError (QObject *sender, const QString &description)
 
void addWarning (QObject *sender, const QString &description)
 
QStringList errors (bool includeSenders=false) const
 
QStringList warnings (bool includeSenders=false) const
 

Private Types

using Messages = QList< QPair< QString, QString > >
 

Private Member Functions

QStringList descriptions (const Messages &messages, bool includeSenders) const
 

Private Attributes

Messages m_errors
 
Messages m_warnings
 

Member Typedef Documentation

◆ Messages

using MessageService::Messages = QList<QPair<QString, QString> >
private

Definition at line 36 of file MessageService.h.

Member Function Documentation

◆ addError()

void MessageService::addError ( QObject *  sender,
const QString &  description 
)

Definition at line 31 of file MessageService.cpp.

32 {
33  m_errors.append(qMakePair(sender->objectName(), description));
34 }
Messages m_errors

References m_errors.

Referenced by ProjectDocument::loadProjectFile(), and ProjectDocument::readProject().

◆ addWarning()

void MessageService::addWarning ( QObject *  sender,
const QString &  description 
)

Definition at line 36 of file MessageService.cpp.

37 {
38  m_warnings.append(qMakePair(sender->objectName(), description));
39 }
Messages m_warnings

References m_warnings.

Referenced by DatafieldIOService::loadDataFiles().

◆ descriptions()

QStringList MessageService::descriptions ( const Messages messages,
bool  includeSenders 
) const
private

Definition at line 18 of file MessageService.cpp.

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 }

Referenced by errors(), and warnings().

◆ errors()

QStringList MessageService::errors ( bool  includeSenders = false) const

Definition at line 41 of file MessageService.cpp.

42 {
43  return descriptions(m_errors, includeSenders);
44 }
QStringList descriptions(const Messages &messages, bool includeSenders) const

References descriptions(), and m_errors.

Referenced by ProjectManager::riseProjectLoadFailedDialog().

Here is the call graph for this function:

◆ warnings()

QStringList MessageService::warnings ( bool  includeSenders = false) const

Definition at line 46 of file MessageService.cpp.

47 {
48  return descriptions(m_warnings, includeSenders);
49 }

References descriptions(), and m_warnings.

Referenced by ProjectDocument::loadProjectFile(), ProjectDocument::readProject(), and ProjectManager::riseProjectLoadProblemDialog().

Here is the call graph for this function:

Member Data Documentation

◆ m_errors

Messages MessageService::m_errors
private

Definition at line 41 of file MessageService.h.

Referenced by addError(), and errors().

◆ m_warnings

Messages MessageService::m_warnings
private

Definition at line 40 of file MessageService.h.

Referenced by addWarning(), and warnings().


The documentation for this class was generated from the following files: