LogTable.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package ArmarX::
17* @author Mirko Waechter ( mirko.waechter at kit dot edu)
18* @date 2012
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
25// ArmarX
27#include <ArmarXCore/interface/core/Log.h>
28
30
31#include "LogStore.h"
32
33// Qt
34#include <QApplication>
35#include <QTableWidget>
36
37// C++
38#include <mutex>
39#include <vector>
40
41#define ARMARX_LOG_TIMESTR "Time"
42#define ARMARX_LOG_COMPONENTSTR "Component"
43#define ARMARX_LOG_TAGSTR "Tag"
44#define ARMARX_LOG_VERBOSITYSTR "Verbosity"
45#define ARMARX_LOG_MESSAGESTR "Message"
46#define ARMARX_LOG_FILESTR "File"
47#define ARMARX_LOG_FUNCTIONSTR "Function"
48#define ARMARX_LOG_LOGGINGGROUPSTR "Group"
49
50namespace armarx
51{
52
53
54 class LogTableModel;
55
56 class LogTable : public QTableView, public Logging
57 {
58 Q_OBJECT
59 protected:
60 void showEvent(QShowEvent* event) override;
61 void hideEvent(QHideEvent*) override;
62
63 public:
64 explicit LogTable(QWidget* parent = 0);
65 ~LogTable() override;
66
67 int
69 {
70 return newMessageCount;
71 }
72
73 MessageType
78
79 //! Clear the new-message badge (count and highest severity seen).
80 //!
81 //! Called when this table is shown, when every row is removed, and explicitly by
82 //! the viewer's clear actions. The last of those matters: a filter that is not
83 //! currently materialised holds no rows, so clearing it emits no row-removal
84 //! signal and the badge would otherwise keep its stale count and colour.
85 void
87 {
89 maxNewLogLevelType = eUNDEFINED;
90 }
91
92 QString getCurrentLiveFilter() const;
93 void liveFilter(const QString& search, int startRow = 0);
94 bool liveSearch(const QString& search);
95 void resetLiveFilter();
96 void resetLiveSearch();
97
98 QString
100 {
101 return lastLiveFilter;
102 }
103
106 void liveFilterRow(const QString& filterStr, int row);
107
108 //! Account for messages this filter accepted while it was hidden. A hidden table's
109 //! model builds no rows, so its rowsInserted is never called and the new-message
110 //! badge has to be fed from the ingestion path instead.
111 void notifyNewMessages(int count, MessageType maxLevel);
112
113 signals:
114 //! Emitted from the context menu to pin the given line (assign a label).
116 //! Emitted from the context menu to remove the pin on the given line.
118
119 public slots:
120 //! Build the right-click menu ("Add label" / "Remove label") for the row under pos.
121 void showContextMenu(const QPoint& pos);
122 bool checkAutoScroll(const QModelIndex& parent, int start, int end);
123 bool checkAutoScroll(int dummy = 0);
124 void itemsAdded(QModelIndex leftTop, QModelIndex bottomRight);
125 void rowsInserted(const QModelIndex& parent, int start, int end) override;
126 void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
127 bool selectNextSearchResult(bool backwards = true, bool keepSelectionIfPossible = false);
128 void doubleClickOnCell(const QModelIndex& index);
129
130 protected:
131 //! Give rows [start, end] the height their message needs. Only ever called while
132 //! this table is visible: every setRowHeight() invalidates and immediately rebuilds
133 //! QHeaderView's start-position cache, which is O(rows) *per call*, and a hidden
134 //! table is never painted.
135 void applyRowHeights(int start, int end);
136
143
144
145 friend class LogSearch;
146 };
147} // namespace armarx
uint8_t index
The EditorFileOpener class.
A filtered view onto the shared LogStore.
MessageType getMaxNewLogLevelType()
Definition LogTable.h:74
void liveFilter(const QString &search, int startRow=0)
Definition LogTable.cpp:183
void doubleClickOnCell(const QModelIndex &index)
Definition LogTable.cpp:456
void showContextMenu(const QPoint &pos)
Build the right-click menu ("Add label" / "Remove label") for the row under pos.
Definition LogTable.cpp:120
bool selectNextSearchResult(bool backwards=true, bool keepSelectionIfPossible=false)
Definition LogTable.cpp:400
void showEvent(QShowEvent *event) override
Definition LogTable.cpp:314
bool autoscrollActive
Definition LogTable.h:137
QString lastLiveFilter
Definition LogTable.h:140
QString currentLiveFilter
Definition LogTable.h:140
void liveFilterRow(const QString &filterStr, int row)
Definition LogTable.cpp:168
bool liveSearch(const QString &search)
Definition LogTable.cpp:256
LogTableModel * getModel()
Definition LogTable.cpp:281
~LogTable() override
Definition LogTable.cpp:115
void fillSearchResults()
void removeLabelRequested(LogSeq seq)
Emitted from the context menu to remove the pin on the given line.
friend class LogSearch
Definition LogTable.h:145
void resetLiveFilter()
Definition LogTable.cpp:265
MessageType maxNewLogLevelType
Definition LogTable.h:139
void hideEvent(QHideEvent *) override
Definition LogTable.cpp:336
QString getCurrentLiveFilter() const
Definition LogTable.cpp:162
LogTable(QWidget *parent=0)
Definition LogTable.cpp:38
bool checkAutoScroll(const QModelIndex &parent, int start, int end)
Definition LogTable.cpp:287
void applyRowHeights(int start, int end)
Give rows [start, end] the height their message needs.
Definition LogTable.cpp:352
void itemsAdded(QModelIndex leftTop, QModelIndex bottomRight)
Definition LogTable.cpp:309
void resetLiveSearch()
Definition LogTable.cpp:274
void resetNewMessageCount()
Clear the new-message badge (count and highest severity seen).
Definition LogTable.h:86
void notifyNewMessages(int count, MessageType maxLevel)
Account for messages this filter accepted while it was hidden.
Definition LogTable.cpp:152
void addLabelRequested(LogSeq seq)
Emitted from the context menu to pin the given line (assign a label).
QString getLiveFilterStr()
Definition LogTable.h:99
int selectedSearchIndex
Definition LogTable.h:141
EditorFileOpener fileOpener
Definition LogTable.h:142
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override
Definition LogTable.cpp:385
void rowsInserted(const QModelIndex &parent, int start, int end) override
Definition LogTable.cpp:370
int getNewMessageCount()
Definition LogTable.h:68
This file offers overloads of toIce() and fromIce() functions for STL container types.
quint64 LogSeq
Identifies a stored log entry for as long as it is retained.
Definition LogStore.h:37