#include "mainwindow.h" #include #include "./ui_mainwindow.h" #include #include "networkthread.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { int metatype_id = qRegisterMetaType("httpflow"); current_session = new Session(); current_session->load("/tmp/littlesnitch.session"); thread = new QThread; NetworkThread* worker = new NetworkThread(); worker->moveToThread(thread); connect(thread, SIGNAL (started()), worker, SLOT (process())); //connect(worker, SIGNAL (error(QString)), this, SLOT (errorString(QString))); connect(worker, SIGNAL (httpMessage(http::Flow)), current_session, SLOT (saveFlow(http::Flow)), Qt::QueuedConnection); connect(worker, SIGNAL (httpMessage(http::Flow)), this, SLOT (updateHistory()), Qt::QueuedConnection); thread->start(); history_model.update(current_session->getHistoryItems()); ui->setupUi(this); ui->historyHTTPTable->setShowGrid(true); ui->historyHTTPTable->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->historyHTTPTable->setModel(&history_model); } MainWindow::~MainWindow() { delete ui; } void MainWindow::updateHistory() { history_model.update(current_session->getHistoryItems()); 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) { }