bigsnitch/historymodel.h

33 lines
1.1 KiB
C
Raw Normal View History

2020-08-26 18:58:36 +00:00
#pragma once
#include <includes.h>
#include <QAbstractTableModel>
2020-08-28 23:09:41 +00:00
#include <QSortFilterProxyModel>
2020-09-04 00:26:25 +00:00
#include <mutex>
2020-08-26 18:58:36 +00:00
class HistoryModel : public QAbstractTableModel
{
Q_OBJECT
private:
2020-09-01 12:55:49 +00:00
mutable std::mutex history_mutex;
2020-08-26 18:58:36 +00:00
std::vector<HistoryItem>* current_items = nullptr;
2020-09-02 22:23:37 +00:00
std::string getRequestHeader(const HistoryItem& item) const;
std::string getResponseHeader(const HistoryItem& item) const;
2020-08-26 18:58:36 +00:00
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;
2020-08-28 23:09:41 +00:00
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
2020-08-26 18:58:36 +00:00
void update(std::vector<HistoryItem>* items);
};
2020-08-28 23:09:41 +00:00
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;
};