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

Description

The JobMessagePanel class shows log messages from FitActivityPanel at the bottom part of JobView.

Definition at line 25 of file JobMessagePanel.h.

Inheritance diagram for JobMessagePanel:
[legend]
Collaboration diagram for JobMessagePanel:
[legend]

Public Member Functions

 JobMessagePanel (QWidget *parent=nullptr)
 
void appendMessage (const FitLog::Message &message)
 
void setLog (FitLog *log)
 

Private Attributes

FitLogm_log
 

Constructor & Destructor Documentation

◆ JobMessagePanel()

JobMessagePanel::JobMessagePanel ( QWidget *  parent = nullptr)

Definition at line 43 of file JobMessagePanel.cpp.

44  : QTextEdit(parent)
45  , m_log(nullptr)
46 {
47  setWindowTitle("Message Panel");
48  setReadOnly(true);
49  setFont(QFont("Courier"));
50 }

Member Function Documentation

◆ appendMessage()

void JobMessagePanel::appendMessage ( const FitLog::Message message)

Definition at line 52 of file JobMessagePanel.cpp.

53 {
54  QScrollBar* scrollbar = verticalScrollBar();
55  bool autoscroll = scrollbar->value() == scrollbar->maximum();
56  setTextColor(color(message.level));
57  append(QString::fromStdString(message.text));
58  if (autoscroll) {
59  QTextCursor c = textCursor();
60  c.movePosition(QTextCursor::End);
61  setTextCursor(c);
62  }
63 }
std::string text
Definition: FitLog.h:31
FitLogLevel level
Definition: FitLog.h:32

References FitLog::Message::level, and FitLog::Message::text.

Referenced by setLog().

◆ setLog()

void JobMessagePanel::setLog ( FitLog log)

Definition at line 65 of file JobMessagePanel.cpp.

66 {
67  if (m_log)
68  m_log->disconnect(this);
69  m_log = log;
70  clear();
71  if (m_log) {
72  for (const auto& record : m_log->messages())
73  appendMessage(record);
74  connect(m_log, &FitLog::cleared, this, &JobMessagePanel::clear);
76  }
77 }
const std::vector< Message > & messages() const
Definition: FitLog.cpp:35
void cleared()
void messageAppended(const Message &message)
void appendMessage(const FitLog::Message &message)

References appendMessage(), FitLog::cleared(), m_log, FitLog::messageAppended(), and FitLog::messages().

Referenced by JobView::connectJobRelated().

Here is the call graph for this function:

Member Data Documentation

◆ m_log

FitLog* JobMessagePanel::m_log
private

Definition at line 34 of file JobMessagePanel.h.

Referenced by setLog().


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