API Documentation
Loading...
Searching...
No Matches
LogTable.h
Go to the documentation of this file.
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 <QAbstractTableModel>
36#include <QObject>
37#include <QSortFilterProxyModel>
38namespace NDEVR
39{
40 /**--------------------------------------------------------------------------------------------------
41 \brief A model for creating a table that displays logged records.
42 **/
43 class NDEVR_WIDGETS_API LogViewTable : public QAbstractTableModel
44 {
45 public:
46 LogViewTable(QObject* parent = nullptr);
47 LogViewTable(const Buffer<LogMessage>& messages, QObject* parent = nullptr);
48 void setMessageSearchTerms(const Buffer<String>& search_terms, uint04 range);
49 virtual ~LogViewTable() {}
50 int rowCount(const QModelIndex& parent) const override;
51 int columnCount(const QModelIndex& parent) const override;
52 QVariant data(const QModelIndex& index, int role) const override;
53 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
54 Qt::ItemFlags flags(const QModelIndex& index) const override;
55 void clear();
56 void setMessages(const Buffer<LogMessage>& messages);
57 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
58 bool insertRows(int position, int rows, const QModelIndex& index = QModelIndex()) override;
59 bool removeRows(int position, int rows, const QModelIndex& index = QModelIndex()) override;
60 void addMessage(const LogMessage& message);
61 void addMessages(const Buffer<LogMessage>& messages);
62 const Buffer<LogMessage>& messages() const { return m_messages; }
63 void setDetectNewLines(bool detect_new_lines);
64 void setShowMicroSeconds(bool show_microseconds);
65 bool showMicroSeconds() const;
66 private:
67 Buffer<String> m_message_search_terms;
68 uint04 m_search_range = 0;
69 Buffer<LogMessage> m_messages;
70 bool m_detect_new_lines;
71 bool m_show_micro_seconds = false;
72 };
73 /**--------------------------------------------------------------------------------------------------
74 \brief Sorts the logged entries in time-order.
75 **/
76 class SortedLogViewTable : public QSortFilterProxyModel
77 {
78 public:
79 SortedLogViewTable(QObject* parent = nullptr);
81 void setMessageSearchTerms(const Buffer<String>& search_terms, uint04 range);
82 void setTimeSearchTerms(const Buffer<String>& search_terms);
83 void setMinimumLevel(uint01 minimal_level);
84 virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
85 virtual bool filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const override;
86 virtual bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override;
87 protected:
93 };
94}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:59
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A class that allows for specific log information to be conveyed to a ProgressInfo object including in...
Definition LogMessage.h:44
A model for creating a table that displays logged records.
Definition LogTable.h:44
int rowCount(const QModelIndex &parent) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
LogViewTable(const Buffer< LogMessage > &messages, QObject *parent=nullptr)
virtual ~LogViewTable()
Definition LogTable.h:49
bool showMicroSeconds() const
Qt::ItemFlags flags(const QModelIndex &index) const override
void addMessages(const Buffer< LogMessage > &messages)
void setDetectNewLines(bool detect_new_lines)
void setMessageSearchTerms(const Buffer< String > &search_terms, uint04 range)
bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex()) override
int columnCount(const QModelIndex &parent) const override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setShowMicroSeconds(bool show_microseconds)
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex()) override
void addMessage(const LogMessage &message)
void setMessages(const Buffer< LogMessage > &messages)
QVariant data(const QModelIndex &index, int role) const override
const Buffer< LogMessage > & messages() const
Definition LogTable.h:62
LogViewTable(QObject *parent=nullptr)
Sorts the logged entries in time-order.
Definition LogTable.h:77
uint01 m_minimum_level
Definition LogTable.h:90
Buffer< String > m_message_search_terms
Definition LogTable.h:88
void setTimeSearchTerms(const Buffer< String > &search_terms)
void setLogViewTable(LogViewTable *table)
LogViewTable * m_raw_log_view
Definition LogTable.h:91
SortedLogViewTable(QObject *parent=nullptr)
void setMessageSearchTerms(const Buffer< String > &search_terms, uint04 range)
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
Buffer< String > m_time_search_terms
Definition LogTable.h:89
virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override
uint04 m_search_range
Definition LogTable.h:92
void setMinimumLevel(uint01 minimal_level)
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition ACIColor.h:37
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96