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 <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QFileDialog>
|
||||
|
||||
const QString WORK_FOLDER(QDir::homePath() + "/triage");
|
||||
|
||||
|
@ -21,12 +22,20 @@ MainWindow::~MainWindow()
|
|||
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();
|
||||
const QStringList lines = QApplication::clipboard()->text().split("\n");
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
QTextStream textStream(&file);
|
||||
QString url;
|
||||
foreach (const QString line, lines) {
|
||||
while (true) {
|
||||
const QString line = textStream.readLine();
|
||||
if (line.isNull())
|
||||
break;
|
||||
if (line.startsWith("ftp://"))
|
||||
url = line;
|
||||
else if (!url.isEmpty()) {
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void pasteResults();
|
||||
void loadFile();
|
||||
void showResult(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pasteResults">
|
||||
<widget class="QPushButton" name="loadFile">
|
||||
<property name="text">
|
||||
<string>Paste results</string>
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -86,7 +86,7 @@
|
|||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pasteResults</sender>
|
||||
<sender>loadFile</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>pasteResults()</slot>
|
||||
|
@ -117,9 +117,25 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</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>
|
||||
<slots>
|
||||
<slot>pasteResults()</slot>
|
||||
<slot>loadFile()</slot>
|
||||
<slot>showResult(QListWidgetItem*)</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in New Issue