triage tool: Add "Load from clipboard" functionality (#1599)

The user now can choose to "Load from file" or "Load from clipboard".
readme.txt has been adapted.
This commit is contained in:
Sebastian 2019-01-14 17:49:10 +01:00 committed by GitHub
parent aa40e374ac
commit 37f2aa0e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 24 deletions

View File

@ -35,13 +35,26 @@ void MainWindow::loadFile()
const QString fileName = QFileDialog::getOpenFileName(this, tr("daca results file"), WORK_FOLDER, tr("Text files (*.txt);;All (*.*)")); const QString fileName = QFileDialog::getOpenFileName(this, tr("daca results file"), WORK_FOLDER, tr("Text files (*.txt);;All (*.*)"));
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
ui->results->clear();
QFile file(fileName); QFile file(fileName);
file.open(QIODevice::ReadOnly | QIODevice::Text); file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream textStream(&file); QTextStream textStream(&file);
load(textStream);
}
void MainWindow::loadFromClipboard()
{
ui->statusBar->clearMessage();
QString clipboardContent = QApplication::clipboard()->text();
QTextStream textStream(&clipboardContent);
load(textStream);
}
void MainWindow::load(QTextStream &textStream)
{
QString url; QString url;
QString errorMessage; QString errorMessage;
QStringList allErrors; QStringList allErrors;
ui->results->clear();
while (true) { while (true) {
QString line = textStream.readLine(); QString line = textStream.readLine();
if (line.isNull()) if (line.isNull())

View File

@ -3,6 +3,8 @@
#include <QMainWindow> #include <QMainWindow>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QString>
#include <QTextStream>
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
@ -19,11 +21,13 @@ public:
public slots: public slots:
void loadFile(); void loadFile();
void loadFromClipboard();
void showResult(QListWidgetItem *item); void showResult(QListWidgetItem *item);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
void load(QTextStream &textStream);
bool runProcess(const QString &programName, const QStringList & arguments); bool runProcess(const QString &programName, const QStringList & arguments);
bool wget(const QString url); bool wget(const QString url);
bool unpackArchive(const QString archiveName); bool unpackArchive(const QString archiveName);

View File

@ -22,7 +22,14 @@
<item> <item>
<widget class="QPushButton" name="loadFile"> <widget class="QPushButton" name="loadFile">
<property name="text"> <property name="text">
<string>Load</string> <string>Load from file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadFromClipboard">
<property name="text">
<string>Load from clipboard</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -89,7 +96,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1057</width> <width>1057</width>
<height>25</height> <height>21</height>
</rect> </rect>
</property> </property>
</widget> </widget>
@ -113,22 +120,6 @@
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection>
<sender>loadFile</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>pasteResults()</slot>
<hints>
<hint type="sourcelabel">
<x>86</x>
<y>68</y>
</hint>
<hint type="destinationlabel">
<x>135</x>
<y>68</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>results</sender> <sender>results</sender>
<signal>itemDoubleClicked(QListWidgetItem*)</signal> <signal>itemDoubleClicked(QListWidgetItem*)</signal>
@ -161,9 +152,26 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>loadFromClipboard</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>loadFromClipboard()</slot>
<hints>
<hint type="sourcelabel">
<x>142</x>
<y>55</y>
</hint>
<hint type="destinationlabel">
<x>528</x>
<y>268</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>loadFile()</slot> <slot>loadFile()</slot>
<slot>showResult(QListWidgetItem*)</slot> <slot>showResult(QListWidgetItem*)</slot>
<slot>loadFromClipboard()</slot>
</slots> </slots>
</ui> </ui>

View File

@ -9,10 +9,12 @@ On Windows something like Cygwin is necessary and the directory containing the e
in the PATH environment variable (for example "C:\cygwin\bin"). in the PATH environment variable (for example "C:\cygwin\bin").
Usage: Usage:
After triage has been started you have to load a daca results file via the "Load" button. After triage has been started you have to load daca results from a file via the "Load from file"
The file must contain the package URL line beginning with "ftp://" and the Cppcheck messages. button or from the clipboard via the "Load from clipboard" button.
When the results file has been parsed successfully you can see a list of Cppcheck messages directly The file or clipboard text must contain the package URL line beginning with "ftp://" and the
beneath the "Load" button. Double-click any entry to let the tool show the source code and jump to Cppcheck messages.
and mark the corresponding line. If the package is not found it is downloaded and extracted When the results data has been parsed successfully you can see a list of Cppcheck messages directly
beneath the "Load ..." buttons. Double-click any entry to let the tool show the source code and jump
to and mark the corresponding line. If the package is not found it is downloaded and extracted
automatically. So after the first double-click it is normal that it takes some time until the automatically. So after the first double-click it is normal that it takes some time until the
source code is shown. source code is shown.