11 #include <QCoreApplication> 12 #include <QGridLayout> 15 #include <QMouseEvent> 17 #include <QSizePolicy> 18 #include <QVBoxLayout> 24 const QString ERROR_HTML =
"<font color=\"#DF0000\">";
25 const QString WARNING_HTML =
"<font color=\"#FF8000\">";
26 const QString INFO_HTML =
"<font color=\"Black\">";
27 const QString END_HTML =
"</font>";
32 : QWidget(aParent, aFlags)
35 , m_MessageListFrame(NULL)
36 , m_MessageTextEdit(NULL)
37 , m_DisplayMessageCallbackTag(0)
40 this->setMinimumSize(18, 18);
41 this->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
44 QGridLayout* grid =
new QGridLayout();
46 grid->setContentsMargins(0, 0, 0, 0);
50 this->setLayout(grid);
52 auto pix = QPixmap(
":/icons/Resources/icon_DotGreen.png");
53 m_DotLabel->setPixmap(pix.scaled(
m_DotLabel->width() - 1,
m_DotLabel->height() - 1, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
57 LOG_ERROR(
"Status icon cannot be initialized!");
62 vtkSmartPointer<vtkDisplayMessageCallback> cb = vtkSmartPointer<vtkDisplayMessageCallback>::New();
69 this->installEventFilter(
this);
73 LOG_ERROR(
"Message list widget cannot be initialized!");
109 unsigned int pos = aInputString.indexOf(
'|');
111 int logLevel = aInputString.left(pos).toInt(&ok);
122 case vtkPlusLogger::LOG_LEVEL_ERROR:
123 if (
m_Level > vtkPlusLogger::LOG_LEVEL_ERROR)
125 m_Level = vtkPlusLogger::LOG_LEVEL_ERROR;
126 m_DotLabel->setPixmap(QPixmap(
":/icons/Resources/icon_DotRed.png").scaled(
m_DotLabel->width() - 1,
m_DotLabel->height() - 1, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
130 case vtkPlusLogger::LOG_LEVEL_WARNING:
131 if (
m_Level > vtkPlusLogger::LOG_LEVEL_WARNING)
133 m_Level = vtkPlusLogger::LOG_LEVEL_WARNING;
134 m_DotLabel->setPixmap(QPixmap(
":/icons/Resources/icon_DotOrange.png").scaled(
m_DotLabel->width() - 1,
m_DotLabel->height() - 1, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
143 message =
message.append(aInputString.right(aInputString.size() - pos - 1)).append(END_HTML);
150 int originalSelectionStart = tc.selectionStart();
151 int originalSelectionLength = tc.selectionEnd() - originalSelectionStart;
155 tc.movePosition(QTextCursor::Start);
156 for (
int i = 0;
i < linesToDelete;
i++)
158 tc.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
159 tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
161 originalSelectionStart -= (tc.selectionEnd() - tc.selectionStart());
162 tc.removeSelectedText();
165 if (originalSelectionStart > 0 && originalSelectionLength > 0)
168 tc.movePosition(QTextCursor::Start);
169 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, originalSelectionStart);
172 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, originalSelectionLength);
181 QCoreApplication::processEvents();
185 vScrollBar->triggerAction(QScrollBar::SliderToMaximum);
196 LOG_TRACE(
"ToolStateDisplayWidget::ConstructMessageListWidget");
208 m_MessageListFrame =
new QFrame(
this, Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
214 LOG_ERROR(
"Message list widget cannot be created!");
224 vbox->setContentsMargins(0, 0, 0, 0);
225 vbox->setAlignment(Qt::AlignTop);
230 m_MessageTextEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
236 QFrame* filterFrame =
new QFrame();
237 filterFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
238 QHBoxLayout* filterLayout =
new QHBoxLayout(filterFrame);
239 filterLayout->setDirection(QBoxLayout::RightToLeft);
240 filterLayout->setContentsMargins(0, 0, 0, 0);
241 filterLayout->setSpacing(0);
254 filterLayout->addWidget(
new QLabel(
"Message log filter: "));
255 filterLayout->addStretch(1);
256 vbox->addWidget(filterFrame);
259 tc.movePosition(QTextCursor::End);
270 if (ev->type() == QEvent::MouseButtonPress)
272 QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(ev);
273 if (mouseEvent != NULL)
275 if (mouseEvent->buttons() == Qt::LeftButton)
279 m_Level = vtkPlusLogger::LOG_LEVEL_INFO;
280 m_DotLabel->setPixmap(QPixmap(
":/icons/Resources/icon_DotGreen.png").scaled(
m_DotLabel->width() - 1,
m_DotLabel->height() - 1, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
283 cursor.movePosition(QTextCursor::End);
284 cursor.movePosition(QTextCursor::StartOfLine);
303 m_Level = vtkPlusLogger::LOG_LEVEL_INFO;
304 m_DotLabel->setPixmap(QPixmap(
":/icons/Resources/icon_DotGreen.png").scaled(
m_DotLabel->width() - 1,
m_DotLabel->height() - 1, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
308 return QWidget::eventFilter(obj, ev);
315 m_DotLabel->setPixmap(pix->scaled(
m_DotLabel->width() - 1,
m_DotLabel->height() - 1, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
317 QWidget::resizeEvent(event);
324 QAction* clear =
new QAction(
"Clear",
this);
325 menu->addAction(clear);
388 m_Level = vtkPlusLogger::LOG_LEVEL_INFO;
389 m_DotLabel->setPixmap(QPixmap(
":/icons/Resources/icon_DotGreen.png").scaled(
m_DotLabel->width() - 1,
m_DotLabel->height() - 1, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation));
397 count = vtkPlusLogger::UnlimitedLogMessages();
405 if (vtkPlusLogger::MessageLogged == eventId)
407 char* callDataChars = reinterpret_cast<char*>(callData);
409 emit
AddMessage(QString::fromLatin1(callDataChars));
411 else if (vtkPlusLogger::WideMessageLogged == eventId)
413 wchar_t* callDataChars = reinterpret_cast<wchar_t*>(callData);
415 emit
AddMessage(QString::fromWCharArray(callDataChars));
void ClearFilterButtonClicked()
void FilterLineEditEdited(const QString &)
void resizeEvent(QResizeEvent *event)
void ApplyFilterTimerFired()
Class to abstract away specific sequence file read/write details.
void SetMaxMessageCount(int count)
QTextEdit * m_MessageTextEdit
QLineEdit * m_FilterLineEdit
QTimer m_FilterInputTimer
QPushButton * m_ClearFilterButton
QPlusStatusIcon(QWidget *aParent=0, Qt::WindowFlags aFlags=0)
void ParseMessage(QString &aInputString)
unsigned long m_DisplayMessageCallbackTag
unsigned long m_DisplayWideMessageCallbackTag
bool eventFilter(QObject *obj, QEvent *ev)
void AddMessage(QString aInputString)
void CreateCustomContextMenu(const QPoint &aPoint)
PlusStatus ConstructMessageListWidget()
Phidget_ChannelClass uint32_t * count
static vtkIGSIOLogger * Instance()
virtual void Execute(vtkObject *caller, unsigned long eventId, void *callData)
QFrame * m_MessageListFrame
std::vector< QString > m_MessageLog