Skip to content

Commit b2bb19e

Browse files
committed
GUI2: loading old results file
1 parent ff40647 commit b2bb19e

5 files changed

Lines changed: 31 additions & 18 deletions

File tree

‎gui2/mainwindow.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,18 @@ void MainWindow::selectProject(QString projectName)
7676

7777
void MainWindow::scan()
7878
{
79-
resultsForm->show();
80-
8179
const ProjectList::Project *project = projectList.getproject(ui->projectwidget->getProjectName());
8280
if (project) {
81+
resultsForm->show();
8382
resultsForm->scan(*project);
8483
}
8584
}
8685

8786
void MainWindow::log()
8887
{
89-
resultsForm->show();
90-
resultsForm->showResults(ui->projectwidget->getProjectName());
88+
const ProjectList::Project *project = projectList.getproject(ui->projectwidget->getProjectName());
89+
if (project) {
90+
resultsForm->show();
91+
resultsForm->showResults(*project);
92+
}
9193
}

‎gui2/resultsform.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ static QString lastResultFile(const QString &projectName)
247247
return ret;
248248
}
249249

250-
void ResultsForm::showResults(const QString & projectName)
250+
void ResultsForm::showResults(const ProjectList::Project &project)
251251
{
252252
if (currentScan.process == 0) {
253253
ui->progressBar->setVisible(false);
254-
resultsmodel->load(lastResultFile(projectName));
254+
resultsmodel->load(lastResultFile(project.name), project.path);
255255
}
256256
}
257257

@@ -264,7 +264,7 @@ void ResultsForm::triage(QModelIndex index)
264264
ui->truePositive->setEnabled(false);
265265
triageIndex = QModelIndex();
266266
} else {
267-
QFile file(currentScan.project.path + '/' + node.filename);
267+
QFile file(node.fullfilename);
268268
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
269269
ui->codeBrowser->clear();
270270
ui->falsePositive->setEnabled(false);

‎gui2/resultsform.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ResultsForm : public QWidget {
2020
~ResultsForm();
2121

2222
void scan(const ProjectList::Project &project);
23-
void showResults(const QString &projectName);
23+
void showResults(const ProjectList::Project &project);
2424

2525
private slots:
2626
void scanAddResult();

‎gui2/resultsmodel.cpp‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static QString getstr(const QDomElement element, const QString &tagName)
7979
return child.isNull() ? QString() : child.text();
8080
}
8181

82-
bool ResultsModel::load(const QString &fileName)
82+
bool ResultsModel::load(const QString &fileName, const QString &projectPath)
8383
{
8484
QFile file(fileName);
8585
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
@@ -107,13 +107,15 @@ bool ResultsModel::load(const QString &fileName)
107107
if (!rootNode)
108108
rootNode = new Node;
109109

110-
new Node(rootNode,
111-
getstr(element,"file"),
112-
getstr(element,"line"),
113-
getstr(element,"severity"),
114-
getstr(element,"text"),
115-
getstr(element,"id"),
116-
getstr(element,"triage"));
110+
Node *node = new Node(rootNode,
111+
getstr(element,"file"),
112+
getstr(element,"line"),
113+
getstr(element,"severity"),
114+
getstr(element,"text"),
115+
getstr(element,"id"),
116+
getstr(element,"triage"));
117+
if (!node->filename.isEmpty())
118+
node->fullfilename = projectPath + "/" + node->filename;
117119
}
118120
}
119121

@@ -212,7 +214,7 @@ int ResultsModel::rowCount(const QModelIndex &parent) const
212214

213215
int ResultsModel::columnCount(const QModelIndex & /* parent */) const
214216
{
215-
return 5;
217+
return 6;
216218
}
217219

218220
QModelIndex ResultsModel::parent(const QModelIndex &child) const
@@ -250,6 +252,13 @@ QVariant ResultsModel::data(const QModelIndex &index, int role) const
250252
return node->text;
251253
case 4:
252254
return node->id;
255+
case 5:
256+
if (node->triage == ResultsModel::Node::TRUE_POSITIVE)
257+
return "True positive";
258+
else if (node->triage == ResultsModel::Node::FALSE_POSITIVE)
259+
return "False positive";
260+
else
261+
return QVariant();
253262
default:
254263
return QVariant();
255264
}
@@ -269,6 +278,8 @@ QVariant ResultsModel::headerData(int section, Qt::Orientation orientation, int
269278
return tr("Text");
270279
case 4:
271280
return tr("Id");
281+
case 5:
282+
return tr("Triage");
272283
default:
273284
return QVariant();
274285
}

‎gui2/resultsmodel.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ResultsModel : public QAbstractItemModel {
6060
void hideAllOtherId(int row);
6161
void showAll();
6262

63-
bool load(const QString &fileName);
63+
bool load(const QString &fileName, const QString &projectPath);
6464
bool save(const QString &fileName, const QString &projectName) const;
6565

6666
Node getNodeFromIndex(const QModelIndex &index) const {

0 commit comments

Comments
 (0)