LogTableModel.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 #include <QAbstractTableModel>
26 
27 // ArmarX
30 #include <ArmarXCore/interface/core/Log.h>
31 
32 // C++
33 #include <vector>
34 #include <mutex>
35 
36 namespace armarx
37 {
38  class LogTableModel : public QAbstractTableModel
39  {
40  Q_OBJECT
41  public:
42  enum class UserRoles : int
43  {
44  FullMsgRole = Qt::UserRole + 1
45  };
46 
47  explicit LogTableModel(QObject* parent = 0);
48  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
49  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
50  QVariant data(const QModelIndex& index, int role) const override;
51  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
52  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
53  Qt::ItemFlags flags(const QModelIndex& index) const override;
54  void updateView();
55  bool insertRows(int row, int count, const QModelIndex& parent) override;
56 
57  void addFilter(const std::string& columnName, const std::string& filter);
58  void reapplyAllFilters();
59  void resetFilters();
60  bool rowContainsString(int row, const QString& searchStr) const;
61  bool msgContainsString(const LogMessage& logMsg, QString searchStr) const;
62  bool rowContainsSameContent(int row, const LogMessage& logMsg) const;
63 
64  void search(const QString& searchStr);
66  {
67  return activeSearchStr;
68  }
69 
70  MessageType getMaxNewLogLevelType()
71  {
72  return maxNewLogLevelType;
73  }
74 
75  int getColumn(const std::string& columnName) const;
76  int clearData();
77  const std::vector<std::pair<std::string, std::string> >& getFilters() const
78  {
79  return activeFilters;
80  }
81 
82  // thread-unsafe access!
83  const LogMessage& getLogEntry(size_t row) const;
84 
85 
86  signals:
87 
88  protected slots:
89 
90  public slots:
91  bool addEntry(const LogMessage& entry, int* entriesAdded = NULL);
92  int addEntries(const std::vector<LogMessage>& entryList, const QString& filterStr);
93 
94  protected:
95  bool applyFilter(std::pair<std::string, std::string> filter, const LogMessage& logMsg);
96  // bool applyFilter(std::pair<std::string, std::string> filter, int row);
97  bool applyFilter(std::string filter, int row, int column);
98  bool applyFilters(int row);
99  bool applyFilters(const LogMessage& logMsg);
100  private:
101  QString activeSearchStr;
102  int newEntryCount;
103  MessageType maxNewLogLevelType;
104  std::vector<std::pair<std::string, std::string> > activeFilters;
105 
106  std::vector < LogMessage> logEntries;
107  std::vector <bool> rowMatchesSearch;
108  mutable std::mutex logEntriesMutex;
109 
111  };
112 }
armarx::LogTableModel::updateView
void updateView()
Definition: LogTableModel.cpp:533
armarx::LogTableModel::UserRoles
UserRoles
Definition: LogTableModel.h:42
armarx::LogTableModel::addEntries
int addEntries(const std::vector< LogMessage > &entryList, const QString &filterStr)
Definition: LogTableModel.cpp:637
armarx::LogTableModel::getFilters
const std::vector< std::pair< std::string, std::string > > & getFilters() const
Definition: LogTableModel.h:77
armarx::LogTableModel::resetFilters
void resetFilters()
Definition: LogTableModel.cpp:592
armarx::LogTableModel::getMaxNewLogLevelType
MessageType getMaxNewLogLevelType()
Definition: LogTableModel.h:70
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:9
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::LogTableModel::getCurrentSearchStr
QString getCurrentSearchStr()
Definition: LogTableModel.h:65
armarx::LogTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: LogTableModel.cpp:412
armarx::LogTableModel::applyFilter
bool applyFilter(std::pair< std::string, std::string > filter, const LogMessage &logMsg)
Definition: LogTableModel.cpp:708
armarx::LogTableModel::msgContainsString
bool msgContainsString(const LogMessage &logMsg, QString searchStr) const
Definition: LogTableModel.cpp:316
armarx::LogTableModel::UserRoles::FullMsgRole
@ FullMsgRole
armarx::LogTableModel::addFilter
void addFilter(const std::string &columnName, const std::string &filter)
Definition: LogTableModel.cpp:559
armarx::LogTableModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: LogTableModel.cpp:37
RunningTask.h
armarx::LogTableModel
Definition: LogTableModel.h:38
armarx::LogTableModel::search
void search(const QString &searchStr)
Definition: LogTableModel.cpp:398
armarx::LogTableModel::applyFilters
bool applyFilters(int row)
Definition: LogTableModel.cpp:817
armarx::LogTableModel::addEntry
bool addEntry(const LogMessage &entry, int *entriesAdded=NULL)
Definition: LogTableModel.cpp:597
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::LogTableModel::rowContainsSameContent
bool rowContainsSameContent(int row, const LogMessage &logMsg) const
Definition: LogTableModel.cpp:356
armarx::LogTableModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Definition: LogTableModel.cpp:516
armarx::LogTableModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: LogTableModel.cpp:521
armarx::LogTableModel::insertRows
bool insertRows(int row, int count, const QModelIndex &parent) override
Definition: LogTableModel.cpp:545
armarx::LogTableModel::getLogEntry
const LogMessage & getLogEntry(size_t row) const
Definition: LogTableModel.cpp:701
armarx::LogTableModel::LogTableModel
LogTableModel(QObject *parent=0)
Definition: LogTableModel.cpp:30
armarx::LogTableModel::rowContainsString
bool rowContainsString(int row, const QString &searchStr) const
Definition: LogTableModel.cpp:298
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::LogTableModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: LogTableModel.cpp:43
armarx::LogTableModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: LogTableModel.cpp:48
armarx::LogTableModel::clearData
int clearData()
Definition: LogTableModel.cpp:686
armarx::LogTableModel::getColumn
int getColumn(const std::string &columnName) const
Definition: LogTableModel.cpp:666
Logging.h
armarx::LogTableModel::reapplyAllFilters
void reapplyAllFilters()
Definition: LogTableModel.cpp:564
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28