You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.3 KiB

#include "historydialog.hpp"
#include "requestlogging.hpp"
#include "ui_historydialog.h"
#include <monospacetextdialog.hpp>
using requestlogging::LoggedRequest;
HistoryDialog::HistoryDialog(QWidget *parent) : QDialog(parent), ui(new Ui::HistoryDialog) {
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
ui->treeWidget->setColumnWidth(0, 50);
ui->treeWidget->setColumnWidth(1, 150);
ui->treeWidget->setColumnWidth(2, 50);
ui->treeWidget->setColumnWidth(3, 100);
QList<LoggedRequest> requests = requestlogging::getRequests();
for (LoggedRequest req : requests) {
ui->treeWidget->addTopLevelItem(new QTreeWidgetItem(
{ req.getType(), req.getUrl(), QString::number(req.getResponseCode()), req.getTime() + " UTC" }));
}
}
HistoryDialog::~HistoryDialog() {
delete ui;
}
void HistoryDialog::on_treeWidget_doubleClicked(const QModelIndex &) {
QString file = ui->treeWidget->currentItem()->text(3);
file = settings::dir().absoluteFilePath("responses/" + file.left(file.length() - 4));
QFile dataFile(file);
if (!dataFile.open(QIODevice::ReadOnly)) return;
MonospaceTextDialog *dialog = new MonospaceTextDialog(file, dataFile.readAll());
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}