QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent, const ErrorLine &item, const bool hide, const QString &icon) { if (!parent) { return 0; } QList<QStandardItem*> list; // Ensure shown path is with native separators const QString file = QDir::toNativeSeparators(item.file); list << CreateNormalItem(file); const QString severity = SeverityToTranslatedString(item.severity); list << CreateNormalItem(severity); list << CreateLineNumberItem(QString("%1").arg(item.line)); list << CreateNormalItem(item.errorId); //TODO message has parameter names so we'll need changes to the core //cppcheck so we can get proper translations QString summary; if (item.inconclusive) { summary = tr("[Inconclusive]"); summary += " "; } summary += item.summary.toLatin1(); list << CreateNormalItem(summary); // Check for duplicate rows and don't add them if found for (int i = 0; i < parent->rowCount(); i++) { // The first column is the file name and is always the same // the third column is the line number so check it first if (parent->child(i, 2)->text() == list[2]->text()) { // the second column is the severity so check it next if (parent->child(i, 1)->text() == list[1]->text()) { // the fourth column is the summary so check it last if (parent->child(i, 4)->text() == list[4]->text()) { // this row matches so don't add it return 0; } } } } parent->appendRow(list); setRowHidden(parent->rowCount() - 1, parent->index(), hide); if (!icon.isEmpty()) { list[0]->setIcon(QIcon(icon)); } //TODO Does this leak memory? Should items from list be deleted? return list[0]; }
QStandardItem *ResultsTree::EnsureFileItem(const QString &fullpath, const QString &file0, bool hide) { QString name = StripPath(fullpath, false); // Since item has path with native separators we must use path with // native separators to find it. QStandardItem *item = FindFileItem(QDir::toNativeSeparators(name)); if (item) { return item; } // Ensure shown path is with native separators name = QDir::toNativeSeparators(name); item = CreateNormalItem(name); item->setIcon(QIcon(":images/text-x-generic.png")); //Add user data to that item QMap<QString, QVariant> data; data["file"] = fullpath; data["file0"] = file0; item->setData(QVariant(data)); mModel.appendRow(item); setRowHidden(mModel.rowCount() - 1, QModelIndex(), hide); return item; }
QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent, const ErrorLine &item, const bool hide, const QString &icon) { if (!parent) { return 0; } QList<QStandardItem*> list; // Ensure shown path is with native separators const QString file = QDir::toNativeSeparators(item.file); list << CreateNormalItem(file); const QString severity = GuiSeverity::toString(item.severity); list << CreateNormalItem(severity.toLatin1()); list << CreateLineNumberItem(QString("%1").arg(item.line)); //TODO message has parameter names so we'll need changes to the core //cppcheck so we can get proper translations QString summary; if (item.inconclusive) { summary = tr("[Inconclusive]"); summary += " "; } summary += item.summary.toLatin1(); list << CreateNormalItem(summary); // Check for duplicate rows and don't add them if found for (int i = 0; i < parent->rowCount(); i++) { // The first column is the file name and is always the same so // we skip it in other platforms than Windows, where filename case // is ignored. So in Windows we can get filenames "header.h" and // "Header.h" and must compare them as identical filenames. // the third column is the line number so check it first if (parent->child(i, 2)->text() == list[2]->text()) { // the second column is the severity so check it next if (parent->child(i, 1)->text() == list[1]->text()) { // the fourth column is the summary so check it last if (parent->child(i, 3)->text() == list[3]->text()) { #if defined(_WIN32) const QString first = parent->child(i, 0)->text().toLower(); const QString second = list[0]->text().toLower(); if (first == second) return 0; #else // this row matches so don't add it return 0; #endif // _WIN32 } } } } parent->appendRow(list); setRowHidden(parent->rowCount() - 1, parent->index(), hide); if (!icon.isEmpty()) { list[0]->setIcon(QIcon(icon)); } //TODO Does this leak memory? Should items from list be deleted? return list[0]; }