tools/triage: Load results from file instead of pasting them
This commit is contained in:
parent
255b788d4d
commit
5eee9d6d18
|
@ -6,6 +6,7 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
const QString WORK_FOLDER(QDir::homePath() + "/triage");
|
const QString WORK_FOLDER(QDir::homePath() + "/triage");
|
||||||
|
|
||||||
|
@ -21,12 +22,20 @@ MainWindow::~MainWindow()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::pasteResults()
|
void MainWindow::loadFile()
|
||||||
{
|
{
|
||||||
|
const QString fileName = QFileDialog::getOpenFileName(this, tr("daca results file"), WORK_FOLDER, tr("Text files (*.txt)"));
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
return;
|
||||||
ui->results->clear();
|
ui->results->clear();
|
||||||
const QStringList lines = QApplication::clipboard()->text().split("\n");
|
QFile file(fileName);
|
||||||
|
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
QTextStream textStream(&file);
|
||||||
QString url;
|
QString url;
|
||||||
foreach (const QString line, lines) {
|
while (true) {
|
||||||
|
const QString line = textStream.readLine();
|
||||||
|
if (line.isNull())
|
||||||
|
break;
|
||||||
if (line.startsWith("ftp://"))
|
if (line.startsWith("ftp://"))
|
||||||
url = line;
|
url = line;
|
||||||
else if (!url.isEmpty()) {
|
else if (!url.isEmpty()) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void pasteResults();
|
void loadFile();
|
||||||
void showResult(QListWidgetItem *item);
|
void showResult(QListWidgetItem *item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pasteResults">
|
<widget class="QPushButton" name="loadFile">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Paste results</string>
|
<string>Load</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>pasteResults</sender>
|
<sender>loadFile</sender>
|
||||||
<signal>clicked()</signal>
|
<signal>clicked()</signal>
|
||||||
<receiver>MainWindow</receiver>
|
<receiver>MainWindow</receiver>
|
||||||
<slot>pasteResults()</slot>
|
<slot>pasteResults()</slot>
|
||||||
|
@ -117,9 +117,25 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>loadFile</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>MainWindow</receiver>
|
||||||
|
<slot>loadFile()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>22</x>
|
||||||
|
<y>65</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>22</x>
|
||||||
|
<y>46</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>pasteResults()</slot>
|
<slot>loadFile()</slot>
|
||||||
<slot>showResult(QListWidgetItem*)</slot>
|
<slot>showResult(QListWidgetItem*)</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in New Issue