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