This commit is contained in:
Tim Blume 2020-09-01 14:55:49 +02:00
parent 3b01e35783
commit 4f608586a9
4 changed files with 27 additions and 5 deletions

View file

@ -1,4 +1,5 @@
#include "historymodel.h"
#include <mutex>
#include <QDateTime>
HistoryModel::HistoryModel(QObject *parent)
@ -25,6 +26,7 @@ int HistoryModel::columnCount(const QModelIndex &parent) const
QVariant HistoryModel::data(const QModelIndex &index, int role) const
{
const std::lock_guard<std::mutex> lock(history_mutex);
if(role != Qt::DisplayRole) {
return QVariant();
}
@ -72,6 +74,7 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const
{
const std::lock_guard<std::mutex> lock(history_mutex);
if(role != Qt::DisplayRole) {
return QVariant();
}
@ -105,11 +108,11 @@ QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int
void HistoryModel::update(std::vector<HistoryItem> *items)
{
const std::lock_guard<std::mutex> lock(history_mutex);
if(current_items) {
delete current_items;
}
current_items = items;
emit layoutChanged();
}
bool HistoryProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const

View file

@ -22,6 +22,7 @@ class HistoryModel : public QAbstractTableModel
{
Q_OBJECT
private:
mutable std::mutex history_mutex;
std::vector<HistoryItem>* current_items = nullptr;
public:
HistoryModel(QObject *parent = nullptr);

View file

@ -37,12 +37,12 @@ MainWindow::~MainWindow()
void MainWindow::updateHistory() {
history_model.update(current_session->getHistoryItems());
history_proxy.invalidate();
ui->historyHTTPTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
}
void MainWindow::on_searchEdit_textEdited(const QString &arg1)
{
emit updateHistory();
}
void MainWindow::on_historyHTTPTable_cellClicked(int row, int column)

View file

@ -137,15 +137,30 @@
<height>100</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QTextEdit" name="textEdit_3">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QTextEdit" name="textEdit_3"/>
</widget>
<widget class="QSplitter" name="splitter_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QTextEdit" name="textEdit_2"/>
<widget class="QTextEdit" name="textEdit_4"/>
<widget class="QTextEdit" name="textEdit_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QTextEdit" name="textEdit_4">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</widget>
</widget>
</item>
@ -246,6 +261,9 @@
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>