bigsnitch/historymodel.h
2021-03-03 17:12:12 +01:00

33 lines
1.1 KiB
C++

#pragma once
#include <includes.h>
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include <mutex>
#include <sstream>
class HistoryModel : public QAbstractTableModel
{
Q_OBJECT
private:
mutable std::mutex history_mutex;
std::vector<HistoryItem>* current_items = nullptr;
std::string getRequestHeader(const HistoryItem& item) const;
std::string getResponseHeader(const HistoryItem& item) const;
public:
HistoryModel(QObject *parent = nullptr);
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) const override;
void update(std::vector<HistoryItem>* items);
};
class HistoryProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
private:
public:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
};