|
16 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/ |
17 | 17 | */ |
18 | 18 |
|
19 | | - |
20 | | -#include "resultstree.h" |
21 | 19 | #include <QApplication> |
22 | 20 | #include <QDebug> |
23 | 21 | #include <QMenu> |
|
27 | 25 | #include <QMessageBox> |
28 | 26 | #include <QFileInfo> |
29 | 27 | #include <QClipboard> |
| 28 | +#include "resultstree.h" |
| 29 | +#include "xmlreport.h" |
30 | 30 |
|
31 | 31 | ResultsTree::ResultsTree(QSettings &settings, ApplicationList &list) : |
32 | 32 | mSettings(settings), |
@@ -533,26 +533,20 @@ QString ResultsTree::SeverityToIcon(const QString &severity) |
533 | 533 | return ""; |
534 | 534 | } |
535 | 535 |
|
536 | | -void ResultsTree::SaveResults(QTextStream &out, bool xml) |
| 536 | +void ResultsTree::SaveResults(Report *report) |
537 | 537 | { |
538 | | - if (xml) |
539 | | - { |
540 | | - out << "<?xml version=\"1.0\"?>" << endl << "<results>" << endl; |
541 | | - } |
| 538 | + report->WriteHeader(); |
542 | 539 |
|
543 | 540 | for (int i = 0;i < mModel.rowCount();i++) |
544 | 541 | { |
545 | 542 | QStandardItem *item = mModel.item(i, 0); |
546 | | - SaveErrors(out, item, xml); |
| 543 | + SaveErrors(report, item); |
547 | 544 | } |
548 | 545 |
|
549 | | - if (xml) |
550 | | - { |
551 | | - out << "</results>" << endl; |
552 | | - } |
| 546 | + report->WriteFooter(); |
553 | 547 | } |
554 | 548 |
|
555 | | -void ResultsTree::SaveErrors(QTextStream &out, QStandardItem *item, bool xml) |
| 549 | +void ResultsTree::SaveErrors(Report *report, QStandardItem *item) |
556 | 550 | { |
557 | 551 | if (!item) |
558 | 552 | { |
@@ -592,47 +586,14 @@ void ResultsTree::SaveErrors(QTextStream &out, QStandardItem *item, bool xml) |
592 | 586 | continue; |
593 | 587 | } |
594 | 588 |
|
| 589 | + for (int i = 0; i < files.count(); i++) |
| 590 | + files[i] = StripPath(files[i], true); |
595 | 591 |
|
| 592 | + QStringList linesStr; |
| 593 | + for (int i = 0; i < lines.count(); i++) |
| 594 | + linesStr << lines[i].toString(); |
596 | 595 |
|
597 | | - if (xml) |
598 | | - { |
599 | | - /* |
600 | | - Error example from the core program in xml |
601 | | - <error file="gui/test.cpp" line="14" id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"/> |
602 | | - The callstack seems to be ignored here aswell, instead last item of the stack is used |
603 | | - */ |
604 | | - line = QString("<error file=\"%1\" line=\"%2\" id=\"%3\" severity=\"%4\" msg=\"%5\"/>"). |
605 | | - arg(StripPath(files[files.size()-1], true)). //filename |
606 | | - arg(lines[lines.size()-1].toInt()). //line |
607 | | - arg(id). //ID |
608 | | - arg(severity). //severity |
609 | | - arg(message); //Message |
610 | | - |
611 | | - } |
612 | | - else |
613 | | - { |
614 | | - /* |
615 | | - Error example from the core program in text |
616 | | - [gui/test.cpp:23] -> [gui/test.cpp:14]: (error) Mismatching allocation and deallocation: k |
617 | | - */ |
618 | | - for (int i = 0;i < lines.size();i++) |
619 | | - { |
620 | | - line += QString("[%1:%2]").arg(StripPath(files[i], true)).arg(lines[i].toInt()); |
621 | | - if (i < lines.size() - 1 && lines.size() > 0) |
622 | | - { |
623 | | - line += " -> "; |
624 | | - } |
625 | | - |
626 | | - if (i == lines.size() - 1) |
627 | | - { |
628 | | - line += ": "; |
629 | | - } |
630 | | - } |
631 | | - |
632 | | - line += QString("(%1) %2").arg(severity).arg(message); |
633 | | - } |
634 | | - |
635 | | - out << line << endl; |
| 596 | + report->WriteError(files, linesStr, id, severity, message); |
636 | 597 | } |
637 | 598 | } |
638 | 599 |
|
|
0 commit comments