2020-08-05 00:08:41 +00:00
|
|
|
#include "mainwindow.h"
|
2020-08-26 18:58:36 +00:00
|
|
|
#include <historymodel.h>
|
2020-08-05 00:08:41 +00:00
|
|
|
#include "./ui_mainwindow.h"
|
|
|
|
#include <QtGui>
|
2020-08-09 12:07:14 +00:00
|
|
|
#include "networkthread.h"
|
2020-08-05 00:08:41 +00:00
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
: QMainWindow(parent),
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
{
|
2020-08-13 03:35:22 +00:00
|
|
|
int metatype_id = qRegisterMetaType<http::Flow>("httpflow");
|
2020-08-09 12:07:14 +00:00
|
|
|
current_session = new Session();
|
|
|
|
current_session->load("/tmp/littlesnitch.session");
|
|
|
|
|
2020-08-05 00:08:41 +00:00
|
|
|
thread = new QThread;
|
2020-08-09 12:07:14 +00:00
|
|
|
NetworkThread* worker = new NetworkThread();
|
2020-08-05 00:08:41 +00:00
|
|
|
worker->moveToThread(thread);
|
|
|
|
connect(thread, SIGNAL (started()), worker, SLOT (process()));
|
2020-08-09 12:07:14 +00:00
|
|
|
//connect(worker, SIGNAL (error(QString)), this, SLOT (errorString(QString)));
|
2020-08-18 13:13:45 +00:00
|
|
|
connect(worker, SIGNAL (httpMessage(http::Flow)), current_session, SLOT (saveFlow(http::Flow)), Qt::QueuedConnection);
|
2020-08-14 01:37:33 +00:00
|
|
|
connect(worker, SIGNAL (httpMessage(http::Flow)), this, SLOT (updateHistory()), Qt::QueuedConnection);
|
2020-08-05 00:08:41 +00:00
|
|
|
thread->start();
|
|
|
|
|
2020-08-26 18:58:36 +00:00
|
|
|
history_model.update(current_session->getHistoryItems());
|
2020-08-28 23:09:41 +00:00
|
|
|
history_proxy.setSourceModel(&history_model);
|
2020-08-26 18:58:36 +00:00
|
|
|
|
2020-08-05 00:08:41 +00:00
|
|
|
ui->setupUi(this);
|
|
|
|
ui->historyHTTPTable->setShowGrid(true);
|
|
|
|
ui->historyHTTPTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
2020-08-28 23:09:41 +00:00
|
|
|
ui->historyHTTPTable->setModel(&history_proxy);
|
2020-08-05 00:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2020-08-14 01:37:33 +00:00
|
|
|
void MainWindow::updateHistory() {
|
2020-08-26 18:58:36 +00:00
|
|
|
history_model.update(current_session->getHistoryItems());
|
2020-09-01 12:55:49 +00:00
|
|
|
history_proxy.invalidate();
|
2020-08-18 13:13:45 +00:00
|
|
|
ui->historyHTTPTable->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
|
2020-08-14 01:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_searchEdit_textEdited(const QString &arg1)
|
|
|
|
{
|
2020-08-05 00:08:41 +00:00
|
|
|
}
|
2020-08-26 18:58:36 +00:00
|
|
|
|
|
|
|
void MainWindow::on_historyHTTPTable_cellClicked(int row, int column)
|
|
|
|
{
|
|
|
|
}
|