13 changed files with 329 additions and 33 deletions
@ -0,0 +1,37 @@
|
||||
#include "historydialog.h" |
||||
#include "requestlogging.hpp" |
||||
#include "ui_historydialog.h" |
||||
|
||||
#include <monospacetextdialog.h> |
||||
|
||||
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(); |
||||
} |
@ -0,0 +1,24 @@
|
||||
#ifndef HISTORYDIALOG_H |
||||
#define HISTORYDIALOG_H |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui { |
||||
class HistoryDialog; |
||||
} |
||||
|
||||
class HistoryDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit HistoryDialog(QWidget *parent = 0); |
||||
~HistoryDialog(); |
||||
|
||||
private slots: |
||||
void on_treeWidget_doubleClicked(const QModelIndex &); |
||||
|
||||
private: |
||||
Ui::HistoryDialog *ui; |
||||
}; |
||||
|
||||
#endif // HISTORYDIALOG_H
|
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>HistoryDialog</class> |
||||
<widget class="QDialog" name="HistoryDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>400</width> |
||||
<height>300</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Request History</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QTreeWidget" name="treeWidget"> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Type</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>URL</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Status</string> |
||||
</property> |
||||
</column> |
||||
<column> |
||||
<property name="text"> |
||||
<string>Time</string> |
||||
</property> |
||||
</column> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>HistoryDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>HistoryDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
@ -0,0 +1,13 @@
|
||||
#include "monospacetextdialog.h" |
||||
#include "ui_monospacetextdialog.h" |
||||
|
||||
MonospaceTextDialog::MonospaceTextDialog(QString name, QByteArray data, QWidget *parent) |
||||
: QDialog(parent), ui(new Ui::MonospaceTextDialog) { |
||||
ui->setupUi(this); |
||||
setWindowTitle(name); |
||||
ui->textEdit->setText(data); |
||||
} |
||||
|
||||
MonospaceTextDialog::~MonospaceTextDialog() { |
||||
delete ui; |
||||
} |
@ -0,0 +1,21 @@
|
||||
#ifndef MONOSPACETEXTDIALOG_H |
||||
#define MONOSPACETEXTDIALOG_H |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui { |
||||
class MonospaceTextDialog; |
||||
} |
||||
|
||||
class MonospaceTextDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit MonospaceTextDialog(QString name, QByteArray data, QWidget *parent = 0); |
||||
~MonospaceTextDialog(); |
||||
|
||||
private: |
||||
Ui::MonospaceTextDialog *ui; |
||||
}; |
||||
|
||||
#endif // MONOSPACETEXTDIALOG_H
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>MonospaceTextDialog</class> |
||||
<widget class="QDialog" name="MonospaceTextDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>400</width> |
||||
<height>300</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Dialog</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QTextEdit" name="textEdit"> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Monospace</family> |
||||
</font> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Close</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>MonospaceTextDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>MonospaceTextDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
Loading…
Reference in new issue