CustusX  15.8
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxConsoleWidget.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 #include "cxConsoleWidget.h"
35 
36 #include <iostream>
37 #include <QVBoxLayout>
38 #include <QMenu>
39 #include <QScrollBar>
40 #include <QContextMenuEvent>
41 #include "cxTypeConversions.h"
42 #include "cxEnumConverter.h"
43 #include "cxDefinitionStrings.h"
44 #include "cxSettings.h"
45 #include "cxStringProperty.h"
46 #include "cxHelperWidgets.h"
48 #include "cxMessageListener.h"
49 #include "cxEnumConverter.h"
50 #include "cxUtilHelpers.h"
51 #include <QTimer>
52 #include <QThread>
53 #include <QTableWidget>
54 #include "cxLogMessageFilter.h"
55 #include <QHeaderView>
56 #include <QStackedLayout>
57 #include <QApplication>
58 #include <QClipboard>
59 #include "cxNullDeleter.h"
60 #include <QPushButton>
61 #include "cxProfile.h"
62 #include "cxTime.h"
63 
64 namespace cx
65 {
66 
68 {
69  this->createTextCharFormats();
70 }
71 
73 {
74  mFormat[mlINFO].setForeground(Qt::black);
75  mFormat[mlSUCCESS].setForeground(QColor(60, 179, 113)); // medium sea green
76  mFormat[mlWARNING].setForeground(QColor(255, 140, 0)); //dark orange
77  mFormat[mlERROR].setForeground(Qt::red);
78  mFormat[mlDEBUG].setForeground(QColor(135, 206, 250)); //sky blue
79  mFormat[mlCERR].setForeground(Qt::red);
80  mFormat[mlCOUT].setForeground(Qt::darkGray);
81 }
82 
86 
87 class MyTableWidget : public QTableWidget
88 {
89 public:
90  MyTableWidget(QWidget* parent=NULL) : QTableWidget(parent) {}
91  virtual ~MyTableWidget() {}
92  virtual void keyPressEvent(QKeyEvent* event);
93 };
94 
95 //source: http://stackoverflow.com/questions/3135737/copying-part-of-qtableview
96 void MyTableWidget::keyPressEvent(QKeyEvent* event)
97 {
98  // If Ctrl-C typed
99  // Or use event->matches(QKeySequence::Copy)
100  if (event->key() == Qt::Key_C && (event->modifiers() & Qt::ControlModifier))
101  {
102  QModelIndexList cells = selectedIndexes();
103  qSort(cells); // Necessary, otherwise they are in column order
104 
105  QString text;
106  int currentRow = 0; // To determine when to insert newlines
107  foreach (const QModelIndex& cell, cells) {
108  if (text.length() == 0) {
109  // First item
110  } else if (cell.row() != currentRow) {
111  // New row
112  text += '\n';
113  } else {
114  // Next cell
115  text += '\t';
116  }
117  currentRow = cell.row();
118  text += cell.data().toString();
119  }
120 
121  QApplication::clipboard()->setText(text);
122  }
123  else
124  {
125  event->ignore();
126  }
127 
128  QTableWidget::keyPressEvent(event);
129 }
130 
132 
134  LogMessageDisplayWidget(parent),
135  mOptions(options),
136  mScrollToBottomEnabled(true)
137 {
138  mTable = new MyTableWidget(this);
139  QVBoxLayout* layout = new QVBoxLayout(this);
140  layout->setMargin(0);
141  this->setLayout(layout);
142  layout->addWidget(mTable);
143 
144  mTable->setShowGrid(false);
145  mTable->setTextElideMode(Qt::ElideLeft);
146  mTable->setWordWrap(false);
147 
148  mTable->setColumnCount(6);
149  mTable->setRowCount(0);
150  mTable->setHorizontalHeaderLabels(QStringList() << "time" << "source" << "function" << "thread" << "level" << "description");
151  mTable->setSelectionBehavior(QAbstractItemView::SelectRows);
152  mTable->verticalHeader()->hide();
153 
154  QFontMetrics metric(this->font());
155  mTable->setColumnWidth(0, metric.width("00:00:00.000xx"));
156  mTable->setColumnWidth(1, metric.width("cxSourceFile.cpp:333xx"));
157  mTable->setColumnWidth(2, metric.width("function()xx"));
158  mTable->setColumnWidth(3, metric.width("mainxx"));
159  mTable->setColumnWidth(4, metric.width("WARNINGxx"));
160  mTable->horizontalHeader()->setStretchLastSection(true);
161 
162  for (int i=0; i<mTable->horizontalHeader()->count(); ++i)
163  {
164  XmlOptionItem headerItem("headerwidth_"+QString::number(i), mOptions.getElement());
165  int value = headerItem.readValue("-1").toInt();
166  if (value<0)
167  continue;
168  mTable->setColumnWidth(i, value);
169  }
170 
171  int textLineHeight = metric.lineSpacing();
172  mTable->verticalHeader()->setDefaultSectionSize(textLineHeight);
173 }
174 
176 {
177  for (int i=0; i<mTable->horizontalHeader()->count(); ++i)
178  {
179  XmlOptionItem headerItem("headerwidth_"+QString::number(i), mOptions.getElement());
180  headerItem.writeValue(QString::number(mTable->columnWidth(i)));
181  }
182 }
183 
185 {
186  mTable->setRowCount(0);
187 }
188 
190 {
191  mTable->horizontalScrollBar()->setValue(mTable->horizontalScrollBar()->minimum());
192 }
193 
195 {
196  int row = mTable->rowCount();
197  mTable->insertRow(row);
198 
199  QTableWidgetItem* item = NULL;
200 
201  QString timestamp = message.getTimeStamp().toString("hh:mm:ss.zzz");
202  item = this->addItem(0, timestamp, message);
203 
204  QString source;
205  if (!message.mSourceFile.isEmpty())
206  source = QString("%1:%2").arg(message.mSourceFile).arg(message.mSourceLine);
207  item = this->addItem(1, source, message);
208 // item->setTextAlignment(Qt::AlignRight);
209 
210  QString function = message.mSourceFunction;
211  item = this->addItem(2, function, message);
212 
213  QString thread = message.mThread;
214  item = this->addItem(3, thread, message);
215 
216  QString level = enum2string(message.getMessageLevel());
217  item = this->addItem(4, level, message);
218 
219  QString desc = message.getText();
220  item = this->addItem(5, desc, message);
221 
222  this->scrollToBottom();
223 }
224 
226 {
228  this->scrollToBottom();
229 }
230 
232 {
233  mTable->horizontalHeader()->setVisible(on);
234 }
235 
237 {
239  QTimer::singleShot(0, mTable, SLOT(scrollToBottom()));
240 }
241 
242 QTableWidgetItem* DetailedLogMessageDisplayWidget::addItem(int column, QString text, const Message& message)
243 {
244  int row = mTable->rowCount();
245 
246  QTableWidgetItem* item = new QTableWidgetItem(text);
247  item->setStatusTip(text);
248  item->setToolTip(text);
249  item->setForeground(mFormat[message.getMessageLevel()].foreground());
250  item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
251  mTable->setItem(row-1, column, item);
252  return item;
253 }
254 
258 
260  LogMessageDisplayWidget(parent),
261  mScrollToBottomEnabled(true)
262 {
263  mBrowser = new QTextBrowser(this);
264  mBrowser->setReadOnly(true);
265  mBrowser->setLineWrapMode(QTextEdit::NoWrap);
266  QVBoxLayout* layout = new QVBoxLayout(this);
267  layout->setMargin(0);
268  this->setLayout(layout);
269  layout->addWidget(mBrowser);
270  this->scrollToBottom();
271 }
272 
274 {
275  mBrowser->clear();
276  this->scrollToBottom();
277 }
278 
280 {
281  mBrowser->horizontalScrollBar()->setValue(mBrowser->horizontalScrollBar()->minimum());
282 }
283 
285 {
286  this->format(message);
287 
288  mBrowser->append(this->getCompactMessage(message));
289 
290  this->scrollToBottom();
291 }
292 
294 {
295  mScrollToBottomEnabled = on;
296  this->scrollToBottom();
297 }
298 
299 void SimpleLogMessageDisplayWidget::scrollToBottom()
300 {
301  if (mScrollToBottomEnabled)
302  mBrowser->verticalScrollBar()->setValue(mBrowser->verticalScrollBar()->maximum());
303 }
304 
306 {
307  if(message.mMessageLevel == mlRAW)
308  return message.mText;
309 
310  QString retval;
311  retval= QString("[%1] %2")
312 // .arg(message.mTimeStamp.toString(timestampSecondsFormatNice()))
313  .arg(message.mTimeStamp.toString("hh:mm"))
314  .arg(message.mText);
315  return retval;
316 }
317 
319 {
320  if (!mFormat.count(message.getMessageLevel()))
321  return;
322  mBrowser->setCurrentCharFormat(mFormat[message.getMessageLevel()]);
323 }
324 
328 
329 PopupButton::PopupButton(QWidget* parent)
330 {
331 // this->setMouseTracking(true);
332  // this->setFrameStyle(QFrame::Box);
333 
334  QVBoxLayout* layout = new QVBoxLayout(this);
335  layout->setMargin(0);
336  this->setLayout(layout);
337 
338  // QToolButton* expandButton = new QToolButton(this);
339  QToolButton* expandButton = new CXSmallToolButton(this);
340  mShowHeaderButton = expandButton;
341  this->setFixedSize(expandButton->sizeHint());
342 
343  QAction* action = new QAction(QIcon(":icons/open_icon_library/layer-lower-3.png"), "Controls", this);
344  QString tip = "Show Controls";
345  action->setStatusTip(tip);
346  action->setWhatsThis(tip);
347  action->setToolTip(tip);
348  connect(action, SIGNAL(triggered()), this, SLOT(onTriggered()));
349  mAction = action;
350 
351  mShowHeaderButton->setDefaultAction(action);
352  layout->addWidget(mShowHeaderButton);
353 
354  action->setCheckable(true);
355 }
356 
357 //void PopupButton::mouseMoveEvent(QMouseEvent* event)
358 //{
359 // std::cout << "mouse move" << std::endl;
360 //}
361 
363 {
364  return mShowHeaderButton->isChecked();
365 }
366 
367 void PopupButton::onTriggered()
368 {
369  if (this->getShowPopup())
370  mAction->setIcon(QIcon(":icons/open_icon_library/layer-raise-3.png"));
371  else
372  mAction->setIcon(QIcon(":icons/open_icon_library/layer-lower-3.png"));
373 
374  emit popup(this->getShowPopup());
375 }
376 
377 
381 
382 ConsoleWidget::ConsoleWidget(QWidget* parent, QString uid, QString name, XmlOptionFile options, LogPtr log) :
383  BaseWidget(parent, uid, name),
384  mSeverityAction(NULL),
385  mMessagesWidget(NULL),
386  mMessagesLayout(NULL),
387  mDetailsAction(NULL)
388 {
389  mOptions = options;
390  mLog = log;
391  connect(mLog.get(), &Log::loggingFolderChanged, this, &ConsoleWidget::onLoggingFolderChanged);
392 
393  this->setModified();
394 }
395 
396 ConsoleWidget::ConsoleWidget(QWidget* parent, QString uid, QString name) :
397  BaseWidget(parent, uid, name),
398  mSeverityAction(NULL),
399  mMessagesWidget(NULL),
400  mMessagesLayout(NULL),
401  mDetailsAction(NULL)
402 {
403  mOptions = profile()->getXmlSettings().descend(this->objectName());
404  mLog = reporter();
405  connect(mLog.get(), &Log::loggingFolderChanged, this, &ConsoleWidget::onLoggingFolderChanged);
406 
407  this->setModified();
408 }
409 
411 {
412  if (!mMessagesLayout)
413  {
414  this->createUI();
415  }
416 
417 }
418 
419 void ConsoleWidget::createUI()
420 {
421  mSeverityAction = NULL;
422  mMessagesWidget = NULL;
423 
424  this->setToolTip("Display system information, warnings and errors.");
425 
426  QVBoxLayout* layout = new QVBoxLayout;
427  layout->setMargin(0);
428  layout->setSpacing(0);
429  this->setLayout(layout);
430 
431  mControlLayout = new QHBoxLayout;
432  mControlLayout->setMargin(0);
433  layout->addLayout(mControlLayout);
434 
435  mShowControlsButton = new PopupButton(this);
436  mControlLayout->addWidget(mShowControlsButton);
437  connect(mShowControlsButton, &PopupButton::popup, this, &ConsoleWidget::updateShowHeader);
438 
439  this->createButtonWidget();
440 
441  mControlLayout->addStretch(1);
442 
443  mMessagesLayout = new QVBoxLayout;
444  mMessagesLayout->setMargin(0);
445  layout->addLayout(mMessagesLayout);
446 
447  mMessageListener = MessageListener::create(mLog);
448  mMessageFilter.reset(new MessageFilterConsole);
449  mMessageListener->installFilter(mMessageFilter);
450  connect(mMessageListener.get(), &MessageListener::newMessage, this, &ConsoleWidget::receivedMessage);
451  connect(mMessageListener.get(), &MessageListener::newChannel, this, &ConsoleWidget::receivedChannel);
452 
453  QString defVal = enum2string<LOG_SEVERITY>(msINFO);
454  LOG_SEVERITY value = string2enum<LOG_SEVERITY>(this->option("showLevel").readValue(defVal));
455  mMessageFilter->setLowestSeverity(value);
456 
457  mMessageFilter->setActiveChannel(mChannelSelector->getValue());
458  mMessageListener->installFilter(mMessageFilter);
459 
460  this->updateUI();
461 }
462 
463 void ConsoleWidget::createButtonWidget()
464 {
465  mButtonWidget = new QWidget(this);
466  mControlLayout->addWidget(mButtonWidget);
467 
468  QHBoxLayout* buttonLayout = new QHBoxLayout;
469  buttonLayout->setMargin(0);
470  buttonLayout->setSpacing(0);
471 
472  mButtonWidget->setLayout(buttonLayout);
473 
474  this->addSeverityButtons(buttonLayout);
475  buttonLayout->addSpacing(8);
476  this->addDetailsButton(buttonLayout);
477 
478  this->createChannelSelector();
479 
480  LabeledComboBoxWidget* channelSelectorWidget = new LabeledComboBoxWidget(this, mChannelSelector);
481  channelSelectorWidget->showLabel(false);
482  buttonLayout->addSpacing(8);
483  buttonLayout->addWidget(channelSelectorWidget);
484  buttonLayout->setStretch(buttonLayout->count()-1, 0);
485 
486  buttonLayout->addStretch(1);
487 }
488 
489 void ConsoleWidget::updateShowHeader()
490 {
491  bool show = mShowControlsButton->getShowPopup();
492 
493  mMessagesWidget->showHeader(show);
494  mButtonWidget->setVisible(show);
495 
496  if (show)
497  {
498  mControlLayout->insertWidget(0, mShowControlsButton);
499  }
500  else
501  {
502  // remove from layout, add to top of this
503  mControlLayout->removeWidget(mShowControlsButton);
504  mShowControlsButton->setParent(NULL);
505  mShowControlsButton->setParent(this);
506  mShowControlsButton->setVisible(true);
507 
508  }
509 }
510 
511 
512 XmlOptionItem ConsoleWidget::option(QString name)
513 {
514  return XmlOptionItem(name, mOptions.getElement());
515 }
516 
518 {
519  if (!mMessageFilter)
520  return;
521 
522  QString levelString = enum2string<LOG_SEVERITY>(mMessageFilter->getLowestSeverity());
523  this->option("showLevel").writeValue(levelString);
524  this->option("showDetails").writeVariant(mDetailsAction->isChecked());
525 }
526 
528 {
529  if (mDetailsAction)
530  {
531  mDetailsAction->setChecked(on);
532  this->updateUI();
533  }
534  else
535  {
536  this->option("showDetails").writeVariant(on);
537  }
538 }
539 
540 void ConsoleWidget::addSeverityButtons(QBoxLayout* buttonLayout)
541 {
542  QAction* actionUp = this->createAction(this,
543  QIcon(":/icons/open_icon_library/zoom-in-3.png"),
544  "More", "More detailed log output",
545  SLOT(onSeverityDown()),
546  buttonLayout, new CXSmallToolButton());
547 
548  this->addSeverityIndicator(buttonLayout);
549 
550  QAction* actionDown = this->createAction(this,
551  QIcon(":/icons/open_icon_library/zoom-out-3.png"),
552  "Less ", "Less detailed log output",
553  SLOT(onSeverityUp()),
554  buttonLayout, new CXSmallToolButton());
555 }
556 
557 void ConsoleWidget::addSeverityIndicator(QBoxLayout* buttonLayout)
558 {
559  QAction* action = new QAction(QIcon(""), "Severity", this);
560  mSeverityAction = action;
561  QString help = "Lowest displayed log severity";
562  action->setStatusTip(help);
563  action->setWhatsThis(help);
564  action->setToolTip(help);
565  QToolButton* button = new CXSmallToolButton();
566  button->setDefaultAction(action);
567  buttonLayout->addWidget(button);
568 }
569 
570 void ConsoleWidget::updateSeverityIndicator()
571 {
572  LOG_SEVERITY severity = mMessageFilter->getLowestSeverity();
573 
574  switch (severity)
575  {
576  case msERROR:
577  this->updateSeverityIndicator("window-close-3.png", "error");
578  break;
579  case msWARNING:
580  this->updateSeverityIndicator("dialog-warning-panel.png", "warning");
581  break;
582  case msINFO:
583  this->updateSeverityIndicator("dialog-information-4.png", "info");
584  break;
585  case msDEBUG:
586  this->updateSeverityIndicator("script-error.png", "debug");
587  break;
588  default:
589  this->updateSeverityIndicator("script-error.png", "");
590  break;
591  }
592 }
593 
594 void ConsoleWidget::updateSeverityIndicator(QString iconname, QString help)
595 {
596  QIcon icon(QString(":/icons/message_levels/%1").arg(iconname));
597  mSeverityAction->setIcon(icon);
598 
599  help = QString("Current log level is %1").arg(help);
600  mSeverityAction->setStatusTip(help);
601  mSeverityAction->setToolTip(help);
602 }
603 
604 void ConsoleWidget::onSeverityUp()
605 {
606  this->onSeverityChange(-1);
607 }
608 
609 void ConsoleWidget::onSeverityDown()
610 {
611  this->onSeverityChange(+1);
612 }
613 
614 void ConsoleWidget::onSeverityChange(int delta)
615 {
616  LOG_SEVERITY severity = mMessageFilter->getLowestSeverity();
617  int val = (int)severity + delta;
618  val = constrainValue(val, 0, int(msCOUNT)-1);
619  severity = static_cast<LOG_SEVERITY>(val);
620 
621  mMessageFilter->setLowestSeverity(severity);
622  mMessageListener->installFilter(mMessageFilter);
623  this->updateUI();
624 }
625 
626 void ConsoleWidget::createChannelSelector()
627 {
628  QString defval = "console";
629  mChannels << "all";
630  mChannels << defval;
631 
632  StringPropertyPtr retval;
633  retval = StringProperty::initialize("ChannelSelector",
634  "", "Log Channel to display",
635  defval, mChannels, mOptions.getElement());
636  connect(retval.get(), &StringPropertyBase::changed, this, &ConsoleWidget::onChannelSelectorChanged);
637  mChannelSelector = retval;
638 }
639 
640 void ConsoleWidget::addDetailsButton(QBoxLayout* buttonLayout)
641 {
642  QIcon icon(":/icons/open_icon_library/system-run-5.png");
643  QAction* action = this->createAction(this,
644  icon,
645  "Details", "Show detailed info on each log entry",
646  SLOT(updateUI()),
647  buttonLayout, new CXSmallToolButton());
648  action->setCheckable(true);
649 
650  bool value = this->option("showDetails").readVariant(false).toBool();
651  action->blockSignals(true);
652  action->setChecked(value);
653  action->blockSignals(false);
654 
655  mDetailsAction = action;
656 }
657 
658 void ConsoleWidget::updateUI()
659 {
660  this->updateSeverityIndicator();
661 
662  this->setWindowTitle("Console: " + mChannelSelector->getValue());
663  this->selectMessagesWidget();
664  this->updateShowHeader();
665 
666  // reset content of browser
667  QTimer::singleShot(0, this, SLOT(clearTable())); // let the messages recently emitted be processed before clearing
668 
669  mMessageListener->restart();
670 }
671 
672 void ConsoleWidget::selectMessagesWidget()
673 {
674  if (mMessagesWidget && (mMessagesWidget->getType()==this->getDetailTypeFromButton()))
675  return;
676 
677  if (mMessagesWidget)
678  {
679  // remove
680  mMessagesLayout->takeAt(0);
681  delete mMessagesWidget;
682  }
683 
684  if (this->getDetailTypeFromButton()=="detail")
685  {
686  mMessagesWidget = new DetailedLogMessageDisplayWidget(this, mOptions);
687  }
688  else
689  {
690  mMessagesWidget = new SimpleLogMessageDisplayWidget(this);
691  }
692 
693  mMessagesLayout->addWidget(mMessagesWidget);
694 }
695 
696 QString ConsoleWidget::getDetailTypeFromButton() const
697 {
698  if (mDetailsAction->isChecked())
699  return "detail";
700  else
701  return "simple";
702 }
703 
704 void ConsoleWidget::clearTable()
705 {
706  if (mMessagesWidget)
707  mMessagesWidget->clear();
708 }
709 
710 void ConsoleWidget::onLoggingFolderChanged()
711 {
712  if (!mMessageFilter)
713  return;
714  mMessageListener->installFilter(mMessageFilter);
715  this->updateUI();
716 }
717 
718 void ConsoleWidget::onChannelSelectorChanged()
719 {
720  mChannelSelector->blockSignals(true);
721 
722  mMessageFilter->setActiveChannel(mChannelSelector->getValue());
723  mMessageListener->installFilter(mMessageFilter);
724  this->updateUI();
725 
726  mChannelSelector->blockSignals(false);
727 }
728 
729 void ConsoleWidget::contextMenuEvent(QContextMenuEvent* event)
730 {
731 // QMenu *menu = mBrowser->createStandardContextMenu();
732 // menu->addSeparator();
733 // menu->addAction(mLineWrappingAction);
734 // menu->exec(event->globalPos());
735 // delete menu;
736 }
737 
738 void ConsoleWidget::showEvent(QShowEvent* event)
739 {
740  if (mMessagesWidget)
741  mMessagesWidget->normalize();
742 }
743 
744 void ConsoleWidget::receivedChannel(QString channel)
745 {
746  if (!mChannels.count(channel))
747  {
748  mChannels.append(channel);
749  mChannelSelector->setValueRange(mChannels);
750  }
751 }
752 
753 void ConsoleWidget::receivedMessage(Message message)
754 {
755  this->receivedChannel(message.mChannel);
756 // if (!mChannels.count(message.mChannel))
757 // {
758 // mChannels.append(message.mChannel);
759 // mChannelSelector->setValueRange(mChannels);
760 // }
761 
762  this->printMessage(message);
763 }
764 
765 void ConsoleWidget::printMessage(const Message& message)
766 {
767  if (mMessagesWidget)
768  mMessagesWidget->add(message);
769 }
770 
771 //void ConsoleWidget::lineWrappingSlot(bool checked)
772 //{
774 //}
775 
776 }//namespace cx
static MessageListenerPtr create(LogPtr log=LogPtr())
mlSUCCESS
Definition: cxDefinitions.h:82
cxResource_EXPORT ProfilePtr profile()
Definition: cxProfile.cpp:169
QString getCompactMessage(Message message)
SimpleLogMessageDisplayWidget(QWidget *parent=NULL)
virtual void showHeader(bool on)=0
mlRAW
Definition: cxDefinitions.h:82
QString mSourceFile
Definition: cxLogMessage.h:98
DetailedLogMessageDisplayWidget(QWidget *parent, XmlOptionFile options)
PopupButton(QWidget *parent=NULL)
MyTableWidget(QWidget *parent=NULL)
virtual void keyPressEvent(QKeyEvent *event)
ReporterPtr reporter()
Definition: cxReporter.cpp:59
void newChannel(QString channel)
msDEBUG
Definition: cxDefinitions.h:96
void writeVariant(const QVariant &val)
void format(const Message &message)
formats the text to suit the message level
void loggingFolderChanged()
mlCERR
Definition: cxDefinitions.h:82
virtual QString getType() const =0
QString getText() const
The raw message.
msINFO
Definition: cxDefinitions.h:96
virtual void setScrollToBottom(bool on)
QString mThread
Definition: cxLogMessage.h:96
QDomElement getElement()
return the current element
mlDEBUG
Definition: cxDefinitions.h:82
QDateTime getTimeStamp() const
The time at which the message was created.
MESSAGE_LEVEL mMessageLevel
Definition: cxLogMessage.h:90
QAction * createAction(QObject *parent, QIcon iconName, QString text, QString tip, T slot, QLayout *layout=NULL, QToolButton *button=new QToolButton())
Definition: cxBaseWidget.h:129
void popup(bool show)
Helper class for storing one string value in an xml document.
boost::shared_ptr< class StringProperty > StringPropertyPtr
QString mChannel
Definition: cxLogMessage.h:95
msERROR
Definition: cxDefinitions.h:96
boost::shared_ptr< class Log > LogPtr
Definition: cxLog.h:68
std::map< MESSAGE_LEVEL, QTextCharFormat > mFormat
double constrainValue(double val, double min, double max)
QTableWidgetItem * addItem(int column, QString text, const Message &message)
void createTextCharFormats()
sets up the formating rules for the message levels
bool getShowPopup() const
virtual void showEvent(QShowEvent *event)
updates internal info before showing the widget
void changed()
emit when the underlying data value is changed: The user interface will be updated.
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
void writeValue(const QString &val)
QDateTime mTimeStamp
Definition: cxLogMessage.h:92
virtual void add(const Message &message)=0
mlINFO
Definition: cxDefinitions.h:82
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
QString mSourceFunction
Definition: cxLogMessage.h:99
void contextMenuEvent(QContextMenuEvent *event)
void setDetails(bool on)
virtual void add(const Message &message)
ConsoleWidget(QWidget *parent, QString uid="ConsoleWidget", QString name="Console")
QVariant readVariant(const QVariant &defval=QVariant()) const
mlCOUT
Definition: cxDefinitions.h:82
QString mText
Definition: cxLogMessage.h:89
LogMessageDisplayWidget(QWidget *parent)
msWARNING
Definition: cxDefinitions.h:96
virtual void normalize()=0
mlWARNING
Definition: cxDefinitions.h:82
virtual void prePaintEvent()
void newMessage(Message message)
virtual void add(const Message &message)
MESSAGE_LEVEL getMessageLevel() const
The category of the message.
mlERROR
Definition: cxDefinitions.h:82
QString enum2string(const ENUM &val)
Helper class for xml files used to store ssc/cx data.
QString readValue(const QString &defval) const