@@ -114,11 +114,11 @@ QStandardItem *ResultsTree::CreateLineNumberItem(const QString &linenumber)
114114
115115bool ResultsTree::AddErrorItem (const ErrorItem &item)
116116{
117- if (item.files .isEmpty ()) {
117+ if (item.errorPath .isEmpty ()) {
118118 return false ;
119119 }
120120
121- QString realfile = StripPath (item.files [ 0 ] , false );
121+ QString realfile = StripPath (item.errorPath . back (). file , false );
122122
123123 if (realfile.isEmpty ()) {
124124 realfile = tr (" Undefined file" );
@@ -130,7 +130,7 @@ bool ResultsTree::AddErrorItem(const ErrorItem &item)
130130 if (!hide && !mFilter .isEmpty ()) {
131131 if (!item.summary .contains (mFilter , Qt::CaseInsensitive) &&
132132 !item.message .contains (mFilter , Qt::CaseInsensitive) &&
133- !item.file .contains (mFilter , Qt::CaseInsensitive) &&
133+ !item.errorPath . back (). file .contains (mFilter , Qt::CaseInsensitive) &&
134134 !item.errorId .contains (mFilter , Qt::CaseInsensitive)) {
135135 hide = true ;
136136 }
@@ -143,15 +143,15 @@ bool ResultsTree::AddErrorItem(const ErrorItem &item)
143143
144144 ErrorLine line;
145145 line.file = realfile;
146+ line.line = item.errorPath .back ().line ;
146147 line.errorId = item.errorId ;
147148 line.inconclusive = item.inconclusive ;
148- line.line = item.lines [0 ];
149149 line.summary = item.summary ;
150150 line.message = item.message ;
151151 line.severity = item.severity ;
152152 // Create the base item for the error and ensure it has a proper
153153 // file item as a parent
154- QStandardItem* fileItem = EnsureFileItem (item.files [ 0 ] , item.file0 , hide);
154+ QStandardItem* fileItem = EnsureFileItem (item.errorPath . back (). file , item.file0 , hide);
155155 QStandardItem* stditem = AddBacktraceFiles (fileItem,
156156 line,
157157 hide,
@@ -167,34 +167,38 @@ bool ResultsTree::AddErrorItem(const ErrorItem &item)
167167 data[" severity" ] = ShowTypes::SeverityToShowType (item.severity );
168168 data[" summary" ] = item.summary ;
169169 data[" message" ] = item.message ;
170- data[" file" ] = item.files [ 0 ] ;
171- data[" line" ] = item.lines [ 0 ] ;
170+ data[" file" ] = item.errorPath . back (). file ;
171+ data[" line" ] = item.errorPath . back (). line ;
172172 data[" id" ] = item.errorId ;
173173 data[" inconclusive" ] = item.inconclusive ;
174174 data[" file0" ] = StripPath (item.file0 , true );
175175 stditem->setData (QVariant (data));
176176
177177 // Add backtrace files as children
178- for (int i = 1 ; i < item.files .size (); i++) {
179- line.file = StripPath (item.files [i], false );
180- line.line = item.lines [i];
181- QStandardItem *child_item;
182- child_item = AddBacktraceFiles (stditem,
183- line,
184- hide,
185- " :images/go-down.png" ,
186- true );
187-
188- // Add user data to that item
189- QMap<QString, QVariant> child_data;
190- child_data[" severity" ] = ShowTypes::SeverityToShowType (line.severity );
191- child_data[" summary" ] = line.summary ;
192- child_data[" message" ] = line.message ;
193- child_data[" file" ] = item.files [i];
194- child_data[" line" ] = line.line ;
195- child_data[" id" ] = line.errorId ;
196- child_data[" inconclusive" ] = line.inconclusive ;
197- child_item->setData (QVariant (child_data));
178+ if (item.errorPath .size () > 1U ) {
179+ for (int i = 0 ; i < item.errorPath .size (); i++) {
180+ const QErrorPathItem &e = item.errorPath [i];
181+ line.file = e.file ;
182+ line.line = e.line ;
183+ line.message = line.summary = e.info ;
184+ QStandardItem *child_item;
185+ child_item = AddBacktraceFiles (stditem,
186+ line,
187+ hide,
188+ " :images/go-down.png" ,
189+ true );
190+
191+ // Add user data to that item
192+ QMap<QString, QVariant> child_data;
193+ child_data[" severity" ] = ShowTypes::SeverityToShowType (line.severity );
194+ child_data[" summary" ] = line.summary ;
195+ child_data[" message" ] = line.message ;
196+ child_data[" file" ] = e.file ;
197+ child_data[" line" ] = e.line ;
198+ child_data[" id" ] = line.errorId ;
199+ child_data[" inconclusive" ] = line.inconclusive ;
200+ child_item->setData (QVariant (child_data));
201+ }
198202 }
199203
200204 // Partially refresh the tree: Unhide file item if necessary
@@ -209,37 +213,21 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
209213 const bool hide,
210214 const QString &icon,
211215 bool childOfMessage)
212-
213216{
214217 if (!parent) {
215218 return 0 ;
216219 }
217220
218221 QList<QStandardItem*> list;
219222 // Ensure shown path is with native separators
220- const QString file = QDir::toNativeSeparators (item.file );
221- list << CreateNormalItem (file);
222- if (childOfMessage)
223- list << CreateNormalItem (" " );
224- else {
225- const QString severity = SeverityToTranslatedString (item.severity );
226- list << CreateNormalItem (severity);
227- }
228- list << CreateLineNumberItem (QString (" %1" ).arg (item.line ));
229- if (childOfMessage)
230- list << CreateNormalItem (" " );
231- else
232- list << CreateNormalItem (item.errorId );
233- if (childOfMessage)
234- list << CreateNormalItem (" " );
235- else
236- list << CreateCheckboxItem (item.inconclusive );
223+ list << CreateNormalItem (QDir::toNativeSeparators (item.file ))
224+ << CreateNormalItem (childOfMessage ? tr (" note" ) : SeverityToTranslatedString (item.severity ))
225+ << CreateLineNumberItem (QString::number (item.line ))
226+ << CreateNormalItem (childOfMessage ? QString () : item.errorId )
227+ << (childOfMessage ? CreateNormalItem (QString ()) : CreateCheckboxItem (item.inconclusive ))
228+ << CreateNormalItem (item.summary );
237229 // TODO message has parameter names so we'll need changes to the core
238230 // cppcheck so we can get proper translations
239- if (childOfMessage)
240- list << CreateNormalItem (" " );
241- else
242- list << CreateNormalItem (item.summary .toLatin1 ());
243231
244232 // Check for duplicate rows and don't add them if found
245233 for (int i = 0 ; i < parent->rowCount (); i++) {
@@ -1014,11 +1002,14 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const
10141002 item.errorId = data[" id" ].toString ();
10151003 item.inconclusive = data[" inconclusive" ].toBool ();
10161004 item.file0 = data[" file0" ].toString ();
1017- QString file = StripPath (data[" file" ].toString (), true );
1018- unsigned int line = data[" line" ].toUInt ();
10191005
1020- item.files << file;
1021- item.lines << line;
1006+ if (error->rowCount () == 0 ) {
1007+ QErrorPathItem e;
1008+ e.file = StripPath (data[" file" ].toString (), true );
1009+ e.line = data[" line" ].toUInt ();
1010+ e.info = data[" message" ].toString ();
1011+ item.errorPath << e;
1012+ }
10221013
10231014 for (int j = 0 ; j < error->rowCount (); j++) {
10241015 QStandardItem *child_error = error->child (j, 0 );
@@ -1027,11 +1018,11 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) const
10271018 // Convert it to QVariantMap
10281019 QVariantMap child_data = child_userdata.toMap ();
10291020
1030- file = StripPath (child_data[ " file " ]. toString (), true ) ;
1031- line = child_data[" line " ].toUInt ( );
1032-
1033- item. files << file ;
1034- item.lines << line ;
1021+ QErrorPathItem e ;
1022+ e. file = StripPath ( child_data[" file " ].toString (), true );
1023+ e. line = child_data[ " line " ]. toUInt ();
1024+ e. info = child_data[ " message " ]. toString () ;
1025+ item.errorPath << e ;
10351026 }
10361027
10371028 report->WriteError (item);
0 commit comments