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>
29 
30 
31 // Qt
32 #include <QApplication>
33 #include <QTableWidget>
34 
35 // C++
36 #include <vector>
37 #include <mutex>
38 
39 #define ARMARX_LOG_TIMESTR "Time"
40 #define ARMARX_LOG_COMPONENTSTR "Component"
41 #define ARMARX_LOG_TAGSTR "Tag"
42 #define ARMARX_LOG_VERBOSITYSTR "Verbosity"
43 #define ARMARX_LOG_MESSAGESTR "Message"
44 #define ARMARX_LOG_FILESTR "File"
45 #define ARMARX_LOG_FUNCTIONSTR "Function"
46 #define ARMARX_LOG_LOGGINGGROUPSTR "Group"
47 
48 namespace armarx
49 {
50 
51 
52  class LogTableModel;
53 
54 
55 
56  class LogTable :
57  public QTableView,
58  public Logging
59  {
60  Q_OBJECT
61  protected:
63  {
64  newMessageCount = 0;
65  maxNewLogLevelType = eUNDEFINED;
66  }
67  void showEvent(QShowEvent* event) override;
68  void hideEvent(QHideEvent*) override;
69  public:
70  explicit LogTable(QWidget* parent = 0);
71  ~LogTable() override;
73  {
74  return newMessageCount;
75  }
76  MessageType getMaxNewLogLevelType()
77  {
78  return maxNewLogLevelType;
79  }
80  QString getCurrentLiveFilter() const;
81  void liveFilter(const QString& search, int startRow = 0);
82  bool liveSearch(const QString& search);
83  void resetLiveFilter();
84  void resetLiveSearch();
85  QString getLiveFilterStr()
86  {
87  return lastLiveFilter;
88  }
90  void fillSearchResults();
91  void liveFilterRow(const QString& filterStr, int row);
92  public slots:
93  bool checkAutoScroll(const QModelIndex& parent, int start, int end);
94  bool checkAutoScroll(int dummy = 0);
95  void itemsAdded(QModelIndex leftTop, QModelIndex bottomRight);
96  void rowsInserted(const QModelIndex& parent, int start, int end) override;
97  void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
98  bool selectNextSearchResult(bool backwards = true, bool keepSelectionIfPossible = false);
99  void doubleClickOnCell(const QModelIndex& index);
100  protected:
103  MessageType maxNewLogLevelType;
104  std::mutex bufferMutex;
105  std::vector<LogMessage> logBuffer;
109 
110 
111 
112  friend class LogSearch;
113  };
114 }
115 
armarx::LogTable::selectNextSearchResult
bool selectNextSearchResult(bool backwards=true, bool keepSelectionIfPossible=false)
Definition: LogTable.cpp:360
armarx::LogTable
Definition: LogTable.h:56
armarx::LogTable::getMaxNewLogLevelType
MessageType getMaxNewLogLevelType()
Definition: LogTable.h:76
armarx::LogTable::fillSearchResults
void fillSearchResults()
armarx::LogTable::newMessageCount
int newMessageCount
Definition: LogTable.h:102
armarx::LogTable::bufferMutex
std::mutex bufferMutex
Definition: LogTable.h:104
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::LogTable::lastLiveFilter
QString lastLiveFilter
Definition: LogTable.h:106
armarx::LogTable::itemsAdded
void itemsAdded(QModelIndex leftTop, QModelIndex bottomRight)
Definition: LogTable.cpp:262
armarx::LogTable::getModel
LogTableModel * getModel()
Definition: LogTable.cpp:234
armarx::LogTable::logBuffer
std::vector< LogMessage > logBuffer
Definition: LogTable.h:105
armarx::LogTable::resetNewMessageCount
void resetNewMessageCount()
Definition: LogTable.h:62
armarx::LogTable::liveFilterRow
void liveFilterRow(const QString &filterStr, int row)
Definition: LogTable.cpp:121
armarx::EditorFileOpener
The EditorFileOpener class.
Definition: editorfileopener.h:40
armarx::LogTable::LogSearch
friend class LogSearch
Definition: LogTable.h:112
armarx::LogTableModel
Definition: LogTableModel.h:38
armarx::LogTable::rowsAboutToBeRemoved
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override
Definition: LogTable.cpp:351
armarx::LogTable::selectedSearchIndex
int selectedSearchIndex
Definition: LogTable.h:107
armarx::LogTable::liveSearch
bool liveSearch(const QString &search)
Definition: LogTable.cpp:209
armarx::LogTable::getNewMessageCount
int getNewMessageCount()
Definition: LogTable.h:72
armarx::LogTable::showEvent
void showEvent(QShowEvent *event) override
Definition: LogTable.cpp:267
armarx::LogTable::doubleClickOnCell
void doubleClickOnCell(const QModelIndex &index)
Definition: LogTable.cpp:416
armarx::LogTable::checkAutoScroll
bool checkAutoScroll(const QModelIndex &parent, int start, int end)
Definition: LogTable.cpp:240
armarx::LogTable::resetLiveFilter
void resetLiveFilter()
Definition: LogTable.cpp:218
armarx::LogTable::currentLiveFilter
QString currentLiveFilter
Definition: LogTable.h:106
armarx::LogTable::hideEvent
void hideEvent(QHideEvent *) override
Definition: LogTable.cpp:285
editorfileopener.h
armarx::LogTable::~LogTable
~LogTable() override
Definition: LogTable.cpp:110
armarx::LogTable::LogTable
LogTable(QWidget *parent=0)
Definition: LogTable.cpp:39
armarx::LogTable::resetLiveSearch
void resetLiveSearch()
Definition: LogTable.cpp:227
armarx::LogTable::maxNewLogLevelType
MessageType maxNewLogLevelType
Definition: LogTable.h:103
armarx::Logging
Base Class for all Logging classes.
Definition: Logging.h:232
armarx::LogTable::rowsInserted
void rowsInserted(const QModelIndex &parent, int start, int end) override
Definition: LogTable.cpp:298
armarx::LogTable::getCurrentLiveFilter
QString getCurrentLiveFilter() const
Definition: LogTable.cpp:115
armarx::LogTable::getLiveFilterStr
QString getLiveFilterStr()
Definition: LogTable.h:85
Logging.h
armarx::LogTable::liveFilter
void liveFilter(const QString &search, int startRow=0)
Definition: LogTable.cpp:136
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::LogTable::autoscrollActive
bool autoscrollActive
Definition: LogTable.h:101
armarx::LogTable::fileOpener
EditorFileOpener fileOpener
Definition: LogTable.h:108