32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <includes.h>
|
|
#include <QAbstractTableModel>
|
|
#include <QSortFilterProxyModel>
|
|
#include <mutex>
|
|
|
|
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;
|
|
};
|