diff --git a/historymodel.cpp b/historymodel.cpp index be46fb7..d16e498 100644 --- a/historymodel.cpp +++ b/historymodel.cpp @@ -1,4 +1,5 @@ #include "historymodel.h" +#include #include 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 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 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 *items) { + const std::lock_guard 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 diff --git a/historymodel.h b/historymodel.h index 99c3705..8cfc913 100644 --- a/historymodel.h +++ b/historymodel.h @@ -22,6 +22,7 @@ class HistoryModel : public QAbstractTableModel { Q_OBJECT private: + mutable std::mutex history_mutex; std::vector* current_items = nullptr; public: HistoryModel(QObject *parent = nullptr); diff --git a/mainwindow.cpp b/mainwindow.cpp index edbada0..13c658d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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) diff --git a/mainwindow.ui b/mainwindow.ui index 40596e4..faf6e17 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -137,15 +137,30 @@ 100 + + true + + + + + true + - Qt::Vertical - - + + + true + + + + + true + + @@ -246,6 +261,9 @@ true + + QAbstractItemView::SingleSelection + QAbstractItemView::SelectRows