NorMIT-nav  18.04
An IGT application
cxConsoleWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 #ifndef CXCONSOLEWIDGET_H_
14 #define CXCONSOLEWIDGET_H_
15 
16 #include "cxResourceWidgetsExport.h"
17 
18 #include "cxBaseWidget.h"
19 #include "cxReporter.h"
20 #include <QTextBrowser>
21 #include <QTextCharFormat>
22 #include "cxStringProperty.h"
23 class QTableWidget;
24 class QTableWidgetItem;
25 
26 
27 class QContextMenuEvent;
28 class QAction;
29 class QStackedLayout;
30 
31 namespace cx
32 {
33 class PopupToolbarWidget;
34 typedef boost::shared_ptr<class MessageListener> MessageListenerPtr;
35 
36 class LogMessageDisplayWidget : public QWidget
37 {
38 public:
39  LogMessageDisplayWidget(QWidget *parent);
41  virtual void clear() = 0;
42  virtual void add(const Message& message) = 0;
43  virtual void normalize() = 0;
44  virtual QString getType() const = 0;
45  virtual void setScrollToBottom(bool on) = 0;
46  virtual void showHeader(bool on) = 0;
47 protected:
48  void createTextCharFormats();
49  std::map<MESSAGE_LEVEL, QTextCharFormat> mFormat;
50 };
51 
53 {
54 public:
55  DetailedLogMessageDisplayWidget(QWidget* parent, XmlOptionFile options);
57  virtual void clear();
58  virtual void add(const Message& message);
59  virtual void normalize();
60  virtual QString getType() const { return "detail";}
61  virtual void setScrollToBottom(bool on);
62  virtual void showHeader(bool on);
63 
64 protected:
66  QTableWidget* mTable;
67  QTableWidgetItem *addItem(int column, QString text, const Message& message);
68  void scrollToBottom();
70 };
71 
73 {
74 public:
75  SimpleLogMessageDisplayWidget(QWidget* parent=NULL);
77  virtual void clear();
78  virtual void add(const Message& message);
79  virtual void normalize();
80  virtual QString getType() const { return "simple";}
81  virtual void setScrollToBottom(bool on);
82  virtual void showHeader(bool on) {}
83 
84  QTextBrowser* mBrowser;
85  void format(const Message &message);
86  QString getCompactMessage(Message message);
87 private:
88  void scrollToBottom();
89  bool mScrollToBottomEnabled;
90 };
91 
92 
100 class cxResourceWidgets_EXPORT ConsoleWidget: public BaseWidget
101 {
102 Q_OBJECT
103 
104 public:
105  ConsoleWidget(QWidget* parent, QString uid="console_widget", QString name="Console");
106  ConsoleWidget(QWidget* parent, QString uid, QString name, XmlOptionFile options, LogPtr log);
107  ~ConsoleWidget();
108 
109  void setDetails(bool on);
110 
111 protected slots:
112  void contextMenuEvent(QContextMenuEvent* event);
113  virtual void showEvent(QShowEvent* event);
114 
115 protected:
116  virtual void prePaintEvent();
117 
118 private slots:
119  void onChannelSelectorChanged();
120  void onLoggingFolderChanged();
121  void receivedMessage(Message message);
122  void receivedChannel(QString channel);
123 
124  void onSeverityUp();
125  void onSeverityDown();
126  void onSeverityChange(int delta);
127  void updateUI();
128  void clearTable();
129  void updateShowHeader();
130 
131 private:
132  XmlOptionItem option(QString name);
133  void createUI();
134  void printMessage(const Message& message);
135  void addSeverityButtons(QBoxLayout* buttonLayout);
136  void addDetailsButton(QBoxLayout* buttonLayout);
137  void createChannelSelector();
138  void updateSeverityIndicator(QString iconname, QString help);
139  void addSeverityIndicator(QBoxLayout* buttonLayout);
140  void updateSeverityIndicator();
141  QString getDetailTypeFromButton() const;
142  void selectMessagesWidget();
143  void createButtonWidget(QWidget *widget);
144 
145 // QAction* mLineWrappingAction;
146  QAction* mSeverityAction;
147  LogMessageDisplayWidget* mMessagesWidget;
148  QVBoxLayout* mMessagesLayout;
149 
150  QAction* mDetailsAction;
151  StringPropertyPtr mChannelSelector;
152  QStringList mChannels;
153  MessageListenerPtr mMessageListener;
154  boost::shared_ptr<class MessageFilterConsole> mMessageFilter;
155  XmlOptionFile mOptions;
156  PopupToolbarWidget* mPopupWidget;
157 
158  LogPtr mLog;
159 };
160 } // namespace cx
161 #endif /* CXCONSOLEWIDGET_H_ */
virtual void showHeader(bool on)=0
virtual QString getType() const
Widget for displaying status messages.
virtual QString getType() const =0
virtual void showHeader(bool on)
Helper class for storing one string value in an xml document.
boost::shared_ptr< class StringProperty > StringPropertyPtr
boost::shared_ptr< class Log > LogPtr
Definition: cxLog.h:47
std::map< MESSAGE_LEVEL, QTextCharFormat > mFormat
void createTextCharFormats()
sets up the formating rules for the message levels
virtual void add(const Message &message)=0
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:88
virtual QString getType() const
LogMessageDisplayWidget(QWidget *parent)
virtual void normalize()=0
virtual void setScrollToBottom(bool on)=0
Helper class for xml files used to store ssc/cx data.
boost::shared_ptr< class MessageListener > MessageListenerPtr
Definition: cxLog.h:45
Namespace for all CustusX production code.