NDEVR
API Documentation
LogTable.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: LogTable
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/LogMessage.h>
35#include <NDEVR/TimeSpan.h>
36#include <QAbstractTableModel>
37#include <QSortFilterProxyModel>
38#include <QFont>
39namespace NDEVR
40{
44 class NDEVR_WIDGETS_API LogViewTable : public QAbstractTableModel
45 {
46 public:
49 LogViewTable(QObject* parent = nullptr);
53 LogViewTable(const Buffer<LogMessage>& messages, QObject* parent = nullptr);
57 void setMessageSearchTerms(const Buffer<String>& search_terms, uint04 range);
59 virtual ~LogViewTable() {}
63 int rowCount(const QModelIndex& parent) const override;
67 int columnCount(const QModelIndex& parent) const override;
72 QVariant data(const QModelIndex& index, int role) const override;
78 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
82 Qt::ItemFlags flags(const QModelIndex& index) const override;
84 void clear();
87 void setTimeSpans(const Buffer<TimeSpan>& time_spans);
90 void setMinimumLevel(uint01 minimal_level);
94 void updateFilter(bool can_use_active, uint04 start_index = 0U);
97 void setMessages(const Buffer<LogMessage>& messages);
103 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
106 void addMessage(const LogMessage& message);
109 void addMessages(const Buffer<LogMessage>& messages);
112 const Buffer<LogMessage>& allMessages() const { return m_all_messages; }
115 const Buffer<uint04>& activeMessages() const { return m_active_messages; }
119 const LogMessage& activeMessage(uint04 i) const { return m_all_messages[m_active_messages[i]]; }
122 void setDetectNewLines(bool detect_new_lines);
125 void setShowMicroSeconds(bool show_microseconds);
128 bool showMicroSeconds() const;
132 virtual bool filterAcceptsRow(uint04 source_row) const;
137 virtual bool filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const;
138 private:
139 QFont m_font;
140 Buffer<String> m_message_search_terms;
141 uint04 m_search_range = 0;
142 Buffer<LogMessage> m_all_messages;
143 Buffer<uint04> m_active_messages;
144 Buffer<TimeSpan> m_time_spans;
145 uint01 m_minimum_level = 0;
146 bool m_detect_new_lines;
147 bool m_show_micro_seconds = false;
148 };
149}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
Definition LogMessage.h:48
virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const
Determines whether a given column should be displayed.
void setTimeSpans(const Buffer< TimeSpan > &time_spans)
Sets the time span filters used to limit displayed messages.
int columnCount(const QModelIndex &parent) const override
Returns the number of columns in the model.
virtual bool filterAcceptsRow(uint04 source_row) const
Determines whether a given row passes the current filter criteria.
bool showMicroSeconds() const
Checks whether microsecond timestamp precision is enabled.
void updateFilter(bool can_use_active, uint04 start_index=0U)
Recomputes the active message filter based on current settings.
QVariant data(const QModelIndex &index, int role) const override
Returns display data for the given cell and role.
int rowCount(const QModelIndex &parent) const override
Returns the number of visible rows in the model.
const LogMessage & activeMessage(uint04 i) const
Returns the active message at the given filtered index.
Definition LogTable.h:119
virtual ~LogViewTable()
Destructor.
Definition LogTable.h:59
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
void addMessage(const LogMessage &message)
Appends a single log message to the model.
void setDetectNewLines(bool detect_new_lines)
Sets whether embedded newline characters in messages create additional rows.
LogViewTable(QObject *parent=nullptr)
Constructs an empty log view table model.
void setMessages(const Buffer< LogMessage > &messages)
Replaces all messages in the model.
void setMessageSearchTerms(const Buffer< String > &search_terms, uint04 range)
Sets search terms used to filter or highlight log messages.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets data for the given cell (e.g., for editing).
const Buffer< uint04 > & activeMessages() const
Returns the indices of messages that pass the current filter.
Definition LogTable.h:115
void clear()
Removes all messages from the model.
void addMessages(const Buffer< LogMessage > &messages)
Appends multiple log messages to the model.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns header data for the given section.
void setShowMicroSeconds(bool show_microseconds)
Sets whether timestamps display microsecond precision.
LogViewTable(const Buffer< LogMessage > &messages, QObject *parent=nullptr)
Constructs a log view table model pre-populated with messages.
const Buffer< LogMessage > & allMessages() const
Returns all stored log messages, including filtered ones.
Definition LogTable.h:112
void setMinimumLevel(uint01 minimal_level)
Sets the minimum log severity level for displayed messages.
The primary namespace for the NDEVR SDK.
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...