NDEVR
API Documentation
LogView.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: LogView
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/LogStream.h>
35#include <QWidget>
36#include <QPointer>
37class QPushButton;
38class QComboBox;
39class QLabel;
40class QProgressBar;
41class QTableView;
42namespace NDEVR
43{
46 class LogViewTable;
47 class SortedLogViewTable;
48 class Button;
49 class Toggle;
50 class QCustomLineEdit;
51 class QCustomComboBox;
56 class NDEVR_WIDGETS_API LogView : public QWidget, public LogStream
57 {
58 Q_OBJECT
59 public:
62 LogView(QWidget *parent = nullptr);
67 void showTimes(bool show_times);
70 void showLogConsole(bool show_log_console);
73 QSize sizeHint() const override;
77 QPointer<QProgressBar> createProgressBar(bool auto_hide = true);
81 void attachProgressBar(QPointer<QProgressBar> bar, bool auto_hide = true);
83 void clearLog();
88 void addWidgetToTop(QWidget* widget);
91 bool isAtBottom() const;
94 void changeEvent(QEvent* e) override;
97 void setProgressFormat(const String& format);
100 void setTimeSpans(const Buffer<TimeSpan>& time_spans);
103 void resizeEvent(QResizeEvent* size) override;
106 void setDetectNewLines(bool detect);
110 void setProgress(uint04 id, fltp04 progress) final override;
114 void addMessage(uint04 idx, const LogMessage& message) final override;
118 void addMessages(uint04 idx, const Buffer<LogMessage>& messages) final override;
121 void attach(InfoPipe* stream) final override;
124 void setMinimumLogLevel(uint01 log_level);
129 void setOptionsVisible(bool visible);
130 signals:
133 private slots:
136 void contextMenu(const QPoint &pos);
138 void updateLog();
140 void setLogFile();
144 void moveSliderToBottom(int min, int max);
146 void selected();
148 void updateSearch();
151 void clickedSlot(const QModelIndex& index);
152 private:
154 void createMessageTable();
156 void allowCancel(bool) final override {}
157 private:
158 QWidget* m_options_widget;
159 Button* m_save_button;
160 QCustomLineEdit* m_search_show_span;
161 QCustomComboBox* m_log_level;
162 QCustomLineEdit* m_search_edit;
163 QTableView* m_message_view;
164 LogViewTable* m_message_table;
165 SortedLogViewTable* m_sorted_table;
166 Buffer<QPointer<QProgressBar>> m_progress_bars;
167 Buffer<bool> m_progress_auto_hide;
168 Buffer<LogMessage> m_pending_messages;
169 FileChooserDialog* m_file_chooser;
170 AsciiFileOutputStream* m_ascii_stream;
171 Time m_last_scroll_time;
172 Toggle* m_show_micro_seconds;
173 fltp04 m_progress;
174 bool m_update_messages;
175 bool m_show_times;
176 bool m_show_log_console;
177 bool m_auto_scroll_to_bottom;
178 };
179}
A LogStream that writes log messages directly to a specified ASCII text file.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
A dialog designed to allow the user to navigate a filesytem and select or create one or more files or...
A light-weight base class for Log that allows processes to update, without the need for additional in...
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
Definition LogMessage.h:48
A listener that receives and processes log messages and progress updates from an InfoPipe.
Definition LogStream.h:49
A model for creating a table that displays logged records.
Definition LogTable.h:45
void attach(InfoPipe *stream) final override
Attaches an InfoPipe as a log message source.
void setDetectNewLines(bool detect)
Sets whether embedded newline characters in messages create additional rows.
void showLogConsole(bool show_log_console)
Sets whether the log console input area is visible.
void jumpToBottom()
Scrolls the log view to the bottom to show the latest messages.
void setMinimumLogLevel(uint01 log_level)
Sets the minimum severity level for displayed log messages.
QSize sizeHint() const override
Returns the preferred size hint for the log view.
~LogView()
Destructor.
void setProgress(uint04 id, fltp04 progress) final override
Updates the progress bar value for a given operation.
void changeEvent(QEvent *e) override
Handles change events such as palette or font changes.
void addMessage(uint04 idx, const LogMessage &message) final override
Adds a single log message to the view.
void addMessages(uint04 idx, const Buffer< LogMessage > &messages) final override
Adds multiple log messages to the view.
void resizeEvent(QResizeEvent *size) override
Handles resize events for the log view.
QPointer< QProgressBar > createProgressBar(bool auto_hide=true)
Creates and returns a new progress bar attached to this log view.
void attachProgressBar(QPointer< QProgressBar > bar, bool auto_hide=true)
Attaches an existing progress bar to this log view.
void requestUpdateLogSignal()
Emitted to request that the log display be refreshed.
void setOptionsVisible(bool visible)
Sets whether the options toolbar is visible.
void clearLog()
Clears all messages from the log view.
void setTimeSpans(const Buffer< TimeSpan > &time_spans)
Sets the selectable time spans used to filter log entries.
void addWidgetToTop(QWidget *widget)
Adds a widget above the log table view.
bool isAtBottom() const
Checks whether the log view is currently scrolled to the bottom.
void allowCancel(bool) final override
No-op override for the cancel allowance callback.
Definition LogView.h:156
void resizeToContents()
Resizes the table columns to fit their contents.
LogView(QWidget *parent=nullptr)
Constructs a LogView widget.
void setProgressFormat(const String &format)
Sets the format string for the progress bar display.
void showTimes(bool show_times)
Sets whether timestamp columns are visible in the log table.
A compact way to present a list of options to the user.
A line edit allows users to enter and edit a single line of plain text with useful editing functions,...
The core String class for the NDEVR API.
Definition String.h:95
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A Button that toggles between on and off.
Definition Toggle.h:50
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...