Ali Hatami Tajik
6 months ago
4 changed files with 128 additions and 6 deletions
@ -0,0 +1,65 @@ |
|||
#include "viewmodel/table/LogTableModel.h" |
|||
|
|||
/*************************************************************************************************/ |
|||
LogTableModel::LogTableModel(LogWarehouse_ptr warehouse) : _warehouse(warehouse) |
|||
{ |
|||
initColumnMap(); |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
LogTableModel::~LogTableModel() |
|||
{ |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
int LogTableModel::rowCount(const QModelIndex& parent) const { |
|||
Q_UNUSED(parent) |
|||
|
|||
auto size = _warehouse->getLength(); |
|||
|
|||
return size; |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
int LogTableModel::columnCount(const QModelIndex& parent) const { |
|||
Q_UNUSED(parent) |
|||
|
|||
return _columnMap.size(); |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
QVariant LogTableModel::data(const QModelIndex& index, int role) const { |
|||
if(!index.isValid() || role != Qt::DisplayRole) |
|||
{ |
|||
return QVariant(); |
|||
} |
|||
|
|||
return QVariant(); |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
QVariant LogTableModel::headerData(int section, Qt::Orientation orientation, int role) const { |
|||
if(role == Qt::DisplayRole) |
|||
{ |
|||
if(orientation == Qt::Horizontal) |
|||
{ |
|||
return _columnMap[section]; |
|||
} |
|||
} |
|||
|
|||
return QVariant(); |
|||
} |
|||
|
|||
/*************************************************************************************************/ |
|||
void LogTableModel::initColumnMap() |
|||
{ |
|||
_columnMap[id] = "Logger Id"; |
|||
_columnMap[level] = "Level"; |
|||
_columnMap[timestamp] = "Time"; |
|||
_columnMap[file] = "File Address"; |
|||
_columnMap[func] = "Function"; |
|||
_columnMap[lineno] = "Line Number"; |
|||
_columnMap[msg] = "Message"; |
|||
_columnMap[scope] = "Scope"; |
|||
_columnMap[threadId] = "Thread"; |
|||
} |
@ -0,0 +1,51 @@ |
|||
#ifndef BASEJSONMODEL_H |
|||
#define BASEJSONMODEL_H |
|||
|
|||
#include <QJsonDocument> |
|||
#include <QJsonObject> |
|||
#include <QJsonArray> |
|||
#include <QFile> |
|||
#include <QVector> |
|||
|
|||
#include <QAbstractTableModel> |
|||
#include "LogWarehouse.h" |
|||
|
|||
class LogTableModel : public QAbstractTableModel |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
LogTableModel(LogWarehouse_ptr warehouse); |
|||
|
|||
~LogTableModel() override; |
|||
|
|||
int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
|||
|
|||
int columnCount(const QModelIndex& parent = QModelIndex()) const override; |
|||
|
|||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
|||
|
|||
QVariant headerData(int section, Qt::Orientation orientation, |
|||
int role = Qt::DisplayRole) const override; |
|||
|
|||
private: |
|||
enum ELogColumn : int |
|||
{ |
|||
id, |
|||
level, |
|||
timestamp, |
|||
file, |
|||
func, |
|||
lineno, |
|||
msg, |
|||
scope, |
|||
threadId, |
|||
}; |
|||
|
|||
QMap<int, QString> _columnMap; |
|||
LogWarehouse_ptr _warehouse; |
|||
|
|||
void initColumnMap(); |
|||
}; |
|||
|
|||
#endif //BASEJSONMODEL_H
|
Loading…
Reference in new issue