OpenMS
LogWindow.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
15 
16 #include <QTextEdit>
17 
18 namespace OpenMS
19 {
20  class String;
21 
27  class LogWindow
28  : public QTextEdit
29  {
30  Q_OBJECT
31  Q_PROPERTY(int max_length READ maxLength WRITE setMaxLength)
32 
33  public:
35  enum LogState
36  {
39  CRITICAL
40  };
41 
43  LogWindow(QWidget* parent);
44 
46  void appendText(const QString& text);
47 
49  void appendNewHeader(const LogState state, const String& heading, const String& body);
50 
52  void addNewline();
53 
55  int maxLength() const;
58 
59  signals:
60 
61  protected slots:
63  void trimText_();
64 
65  private:
66  void contextMenuEvent(QContextMenuEvent* event) override;
67  int max_length_ { -1 };
68  };
69 
70 } //namespace
71 
A log window (QTextEdit) with convenience functions.
Definition: LogWindow.h:29
LogState
Log message states.
Definition: LogWindow.h:36
@ WARNING
Warning.
Definition: LogWindow.h:38
@ CRITICAL
Fatal error.
Definition: LogWindow.h:39
@ NOTICE
Notice.
Definition: LogWindow.h:37
void contextMenuEvent(QContextMenuEvent *event) override
LogWindow(QWidget *parent)
Default constructor.
int max_length_
-1 by default, which means there is no maximum length
Definition: LogWindow.h:67
void trimText_()
if text length reached max_length_, then delete prefix until length of text is 1/2 of max_length_
int maxLength() const
read max_length
void setMaxLength(int max_length)
set max_length
void appendNewHeader(const LogState state, const String &heading, const String &body)
appends a new block with heading and a body
int max_length
Definition: LogWindow.h:31
void appendText(const QString &text)
appends text without adding line breaks and shows the log-window
void addNewline()
appends a line break (same as append(""))
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22