foo
This commit is contained in:
parent
3b01e35783
commit
4f608586a9
4 changed files with 27 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "historymodel.h"
|
#include "historymodel.h"
|
||||||
|
#include <mutex>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
HistoryModel::HistoryModel(QObject *parent)
|
HistoryModel::HistoryModel(QObject *parent)
|
||||||
|
@ -25,6 +26,7 @@ int HistoryModel::columnCount(const QModelIndex &parent) const
|
||||||
|
|
||||||
QVariant HistoryModel::data(const QModelIndex &index, int role) const
|
QVariant HistoryModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
|
const std::lock_guard<std::mutex> lock(history_mutex);
|
||||||
if(role != Qt::DisplayRole) {
|
if(role != Qt::DisplayRole) {
|
||||||
return QVariant();
|
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
|
QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
|
const std::lock_guard<std::mutex> lock(history_mutex);
|
||||||
if(role != Qt::DisplayRole) {
|
if(role != Qt::DisplayRole) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -105,11 +108,11 @@ QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int
|
||||||
|
|
||||||
void HistoryModel::update(std::vector<HistoryItem> *items)
|
void HistoryModel::update(std::vector<HistoryItem> *items)
|
||||||
{
|
{
|
||||||
|
const std::lock_guard<std::mutex> lock(history_mutex);
|
||||||
if(current_items) {
|
if(current_items) {
|
||||||
delete current_items;
|
delete current_items;
|
||||||
}
|
}
|
||||||
current_items = items;
|
current_items = items;
|
||||||
emit layoutChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
bool HistoryProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||||
|
|
|
@ -22,6 +22,7 @@ class HistoryModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
mutable std::mutex history_mutex;
|
||||||
std::vector<HistoryItem>* current_items = nullptr;
|
std::vector<HistoryItem>* current_items = nullptr;
|
||||||
public:
|
public:
|
||||||
HistoryModel(QObject *parent = nullptr);
|
HistoryModel(QObject *parent = nullptr);
|
||||||
|
|
|
@ -37,12 +37,12 @@ MainWindow::~MainWindow()
|
||||||
|
|
||||||
void MainWindow::updateHistory() {
|
void MainWindow::updateHistory() {
|
||||||
history_model.update(current_session->getHistoryItems());
|
history_model.update(current_session->getHistoryItems());
|
||||||
|
history_proxy.invalidate();
|
||||||
ui->historyHTTPTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
|
ui->historyHTTPTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_searchEdit_textEdited(const QString &arg1)
|
void MainWindow::on_searchEdit_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
emit updateHistory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_historyHTTPTable_cellClicked(int row, int column)
|
void MainWindow::on_historyHTTPTable_cellClicked(int row, int column)
|
||||||
|
|
|
@ -137,15 +137,30 @@
|
||||||
<height>100</height>
|
<height>100</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextEdit" name="textEdit_3">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextEdit" name="textEdit_3"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QSplitter" name="splitter_4">
|
<widget class="QSplitter" name="splitter_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QTextEdit" name="textEdit_2"/>
|
<widget class="QTextEdit" name="textEdit_2">
|
||||||
<widget class="QTextEdit" name="textEdit_4"/>
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextEdit" name="textEdit_4">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -246,6 +261,9 @@
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
<property name="selectionBehavior">
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in a new issue