refresh treeview on new upload

This commit is contained in:
Niklas 2019-05-08 22:16:51 +02:00
parent b41d7418dd
commit 53f79673ee
3 changed files with 21 additions and 10 deletions

View File

@ -45,6 +45,12 @@ void requestlogging::addEntry(RequestContext context) {
<< timeNow.replace(" ", "_") << endl
<< flush; // $time
requestFile.close();
MainWindow::inst()->addResponse(
context.reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(),
context.filename,
context.reply->url().toString(),
timeNow);
}
using requestlogging::LoggedRequest;

View File

@ -132,16 +132,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
QList<LoggedRequest> requests = requestlogging::getRequests();
for (LoggedRequest req : requests) {
QString httpStatus = ioutils::httpString(req.getResponseCode());
QTreeWidgetItem* tw = new QTreeWidgetItem({ QString::number(req.getResponseCode()) + " " + httpStatus, req.getFilename(), req.getUrl(), req.getTime() + " UTC" });
if(req.getResponseCode() >= 200 && req.getResponseCode() < 300) {
tw->setIcon(0, *(new QIcon(":/icons/checked.png")));
} else {
tw->setIcon(0, *(new QIcon(":/icons/error.png")));
}
ui->treeWidget->addTopLevelItem(tw);
addResponse(req.getResponseCode(), req.getFilename(), req.getUrl(), req.getTime());
}
}
@ -262,3 +253,16 @@ void MainWindow::openScreenshotFolder() {
void MainWindow::setTrayIcon(QIcon icon) {
tray->setIcon(icon);
}
void MainWindow::addResponse(int httpCode, QString filename, QString url, QString time) {
QString httpStatus = ioutils::httpString(httpCode);
QTreeWidgetItem* tw = new QTreeWidgetItem({ QString::number(httpCode) + " " + httpStatus, filename, url, time + " UTC" });
if(httpCode >= 200 && httpCode < 300) {
tw->setIcon(0, *(new QIcon(":/icons/checked.png")));
} else {
tw->setIcon(0, *(new QIcon(":/icons/error.png")));
}
ui->treeWidget->addTopLevelItem(tw);
}

View File

@ -39,6 +39,7 @@ public:
~MainWindow();
bool valid();
void setTrayIcon(QIcon icon);
void addResponse(int httpCode, QString filename, QString url, QString time);
RecordingController *controller = new RecordingController;
QSystemTrayIcon *tray;