60
60
#include < QSettings>
61
61
#include < QSignalMapper>
62
62
#include < QStandardItem>
63
- #include < QStandardItemModel>
64
63
#include < QUrl>
65
64
#include < QVariant>
66
65
#include < QVariantMap>
@@ -146,10 +145,9 @@ static QStringList getLabels() {
146
145
}
147
146
148
147
ResultsTree::ResultsTree (QWidget * parent) :
149
- QTreeView(parent),
150
- mModel(new QStandardItemModel)
148
+ QTreeView(parent)
151
149
{
152
- setModel (mModel );
150
+ setModel (& mModel );
153
151
translate (); // Adds columns to grid
154
152
clear ();
155
153
setExpandsOnDoubleClick (false );
@@ -171,8 +169,8 @@ void ResultsTree::setReportType(ReportType reportType) {
171
169
172
170
mGuideline = createGuidelineMapping (reportType);
173
171
174
- for (int i = 0 ; i < mModel -> rowCount (); ++i) {
175
- const QStandardItem *fileItem = mModel -> item (i, COLUMN_FILE);
172
+ for (int i = 0 ; i < mModel . rowCount (); ++i) {
173
+ const QStandardItem *fileItem = mModel . item (i, COLUMN_FILE);
176
174
if (!fileItem)
177
175
continue ;
178
176
for (int j = 0 ; j < fileItem->rowCount (); ++j) {
@@ -475,20 +473,20 @@ QStandardItem *ResultsTree::findFileItem(const QString &name) const
475
473
// The first column contains the file name. In Windows we can get filenames
476
474
// "header.h" and "Header.h" and must compare them as identical.
477
475
478
- for (int i = 0 ; i < mModel -> rowCount (); i++) {
476
+ for (int i = 0 ; i < mModel . rowCount (); i++) {
479
477
#ifdef _WIN32
480
- if (QString::compare (mModel -> item (i, COLUMN_FILE)->text (), name, Qt::CaseInsensitive) == 0 )
478
+ if (QString::compare (mModel . item (i, COLUMN_FILE)->text (), name, Qt::CaseInsensitive) == 0 )
481
479
#else
482
- if (mModel -> item (i, COLUMN_FILE)->text () == name)
480
+ if (mModel . item (i, COLUMN_FILE)->text () == name)
483
481
#endif
484
- return mModel -> item (i, COLUMN_FILE);
482
+ return mModel . item (i, COLUMN_FILE);
485
483
}
486
484
return nullptr ;
487
485
}
488
486
489
487
void ResultsTree::clear ()
490
488
{
491
- mModel -> removeRows (0 , mModel -> rowCount ());
489
+ mModel . removeRows (0 , mModel . rowCount ());
492
490
493
491
if (const ProjectFile *activeProject = ProjectFile::getActiveProject ()) {
494
492
hideColumn (COLUMN_SINCE_DATE);
@@ -506,24 +504,24 @@ void ResultsTree::clear(const QString &filename)
506
504
{
507
505
const QString stripped = stripPath (filename, false );
508
506
509
- for (int i = 0 ; i < mModel -> rowCount (); ++i) {
510
- const QStandardItem *fileItem = mModel -> item (i, COLUMN_FILE);
507
+ for (int i = 0 ; i < mModel . rowCount (); ++i) {
508
+ const QStandardItem *fileItem = mModel . item (i, COLUMN_FILE);
511
509
if (!fileItem)
512
510
continue ;
513
511
514
512
QVariantMap fitemdata = fileItem->data ().toMap ();
515
513
if (stripped == fitemdata[FILENAME].toString () ||
516
514
filename == fitemdata[FILE0].toString ()) {
517
- mModel -> removeRow (i);
515
+ mModel . removeRow (i);
518
516
break ;
519
517
}
520
518
}
521
519
}
522
520
523
521
void ResultsTree::clearRecheckFile (const QString &filename)
524
522
{
525
- for (int i = 0 ; i < mModel -> rowCount (); ++i) {
526
- const QStandardItem *fileItem = mModel -> item (i, COLUMN_FILE);
523
+ for (int i = 0 ; i < mModel . rowCount (); ++i) {
524
+ const QStandardItem *fileItem = mModel . item (i, COLUMN_FILE);
527
525
if (!fileItem)
528
526
continue ;
529
527
@@ -532,7 +530,7 @@ void ResultsTree::clearRecheckFile(const QString &filename)
532
530
QString storedfile = fitemdata[FILENAME].toString ();
533
531
storedfile = ((!mCheckPath .isEmpty () && storedfile.startsWith (mCheckPath )) ? storedfile.mid (mCheckPath .length () + 1 ) : storedfile);
534
532
if (actualfile == storedfile) {
535
- mModel -> removeRow (i);
533
+ mModel . removeRow (i);
536
534
break ;
537
535
}
538
536
}
@@ -541,9 +539,9 @@ void ResultsTree::clearRecheckFile(const QString &filename)
541
539
542
540
void ResultsTree::loadSettings ()
543
541
{
544
- for (int i = 0 ; i < mModel -> columnCount (); i++) {
542
+ for (int i = 0 ; i < mModel . columnCount (); i++) {
545
543
QString temp = QString (SETTINGS_RESULT_COLUMN_WIDTH).arg (i);
546
- setColumnWidth (i, qMax (20 , mSettings ->value (temp, 800 / mModel -> columnCount ()).toInt ()));
544
+ setColumnWidth (i, qMax (20 , mSettings ->value (temp, 800 / mModel . columnCount ()).toInt ()));
547
545
}
548
546
549
547
mSaveFullPath = mSettings ->value (SETTINGS_SAVE_FULL_PATH, false ).toBool ();
@@ -556,7 +554,7 @@ void ResultsTree::loadSettings()
556
554
557
555
void ResultsTree::saveSettings () const
558
556
{
559
- for (int i = 0 ; i < mModel -> columnCount (); i++) {
557
+ for (int i = 0 ; i < mModel . columnCount (); i++) {
560
558
QString temp = QString (SETTINGS_RESULT_COLUMN_WIDTH).arg (i);
561
559
mSettings ->setValue (temp, columnWidth (i));
562
560
}
@@ -601,11 +599,11 @@ void ResultsTree::refreshTree()
601
599
{
602
600
mVisibleErrors = false ;
603
601
// Get the amount of files in the tree
604
- const int filecount = mModel -> rowCount ();
602
+ const int filecount = mModel . rowCount ();
605
603
606
604
for (int i = 0 ; i < filecount; i++) {
607
605
// Get file i
608
- QStandardItem *fileItem = mModel -> item (i, 0 );
606
+ QStandardItem *fileItem = mModel . item (i, 0 );
609
607
if (!fileItem) {
610
608
continue ;
611
609
}
@@ -695,7 +693,7 @@ QStandardItem *ResultsTree::ensureFileItem(const QString &fullpath, const QStrin
695
693
itemdata[FILENAME] = fullpath;
696
694
itemdata[FILE0] = file0;
697
695
item->setData (QVariant (itemdata));
698
- mModel -> appendRow (item);
696
+ mModel . appendRow (item);
699
697
700
698
setRowHidden (item->row (), QModelIndex (), hide);
701
699
@@ -712,7 +710,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
712
710
if (mSelectionModel ->selectedRows ().count () > 1 )
713
711
multipleSelection = true ;
714
712
715
- mContextItem = mModel -> itemFromIndex (index);
713
+ mContextItem = mModel . itemFromIndex (index);
716
714
717
715
// Create a new context menu
718
716
QMenu menu (this );
@@ -753,7 +751,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
753
751
int selectedResults = 0 ;
754
752
755
753
for (auto row : mSelectionModel ->selectedRows ()) {
756
- auto *item = mModel -> itemFromIndex (row);
754
+ auto *item = mModel . itemFromIndex (row);
757
755
if (!item->parent ())
758
756
selectedFiles++;
759
757
else if (!item->parent ()->parent ())
@@ -832,7 +830,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
832
830
menu.exec (e->globalPos ());
833
831
index = indexAt (e->pos ());
834
832
if (index.isValid ()) {
835
- mContextItem = mModel -> itemFromIndex (index);
833
+ mContextItem = mModel . itemFromIndex (index);
836
834
}
837
835
}
838
836
}
@@ -998,7 +996,7 @@ void ResultsTree::copy()
998
996
999
997
QString text;
1000
998
for (const QModelIndex& index : mSelectionModel ->selectedRows ()) {
1001
- const QStandardItem *item = mModel -> itemFromIndex (index);
999
+ const QStandardItem *item = mModel . itemFromIndex (index);
1002
1000
if (!item->parent ()) {
1003
1001
text += item->text () + ' \n ' ;
1004
1002
continue ;
@@ -1029,7 +1027,7 @@ void ResultsTree::hideResult()
1029
1027
return ;
1030
1028
1031
1029
for (QModelIndex index : mSelectionModel ->selectedRows ()) {
1032
- QStandardItem *item = mModel -> itemFromIndex (index);
1030
+ QStandardItem *item = mModel . itemFromIndex (index);
1033
1031
// Set the "hide" flag for this item
1034
1032
QVariantMap itemdata = item->data ().toMap ();
1035
1033
itemdata[HIDE] = true ;
@@ -1047,7 +1045,7 @@ void ResultsTree::recheckSelectedFiles()
1047
1045
1048
1046
QStringList selectedItems;
1049
1047
for (QModelIndex index : mSelectionModel ->selectedRows ()) {
1050
- QStandardItem *item = mModel -> itemFromIndex (index);
1048
+ QStandardItem *item = mModel . itemFromIndex (index);
1051
1049
while (item->parent ())
1052
1050
item = item->parent ();
1053
1051
QVariantMap itemdata = item->data ().toMap ();
@@ -1102,7 +1100,7 @@ void ResultsTree::suppressSelectedIds()
1102
1100
1103
1101
QSet<QString> selectedIds;
1104
1102
for (QModelIndex index : mSelectionModel ->selectedRows ()) {
1105
- QStandardItem *item = mModel -> itemFromIndex (index);
1103
+ QStandardItem *item = mModel . itemFromIndex (index);
1106
1104
if (!item->parent ())
1107
1105
continue ;
1108
1106
if (item->parent ()->parent ())
@@ -1114,8 +1112,8 @@ void ResultsTree::suppressSelectedIds()
1114
1112
}
1115
1113
1116
1114
// delete all errors with selected message Ids
1117
- for (int i = 0 ; i < mModel -> rowCount (); i++) {
1118
- QStandardItem * const file = mModel -> item (i, 0 );
1115
+ for (int i = 0 ; i < mModel . rowCount (); i++) {
1116
+ QStandardItem * const file = mModel . item (i, 0 );
1119
1117
for (int j = 0 ; j < file->rowCount ();) {
1120
1118
QStandardItem *errorItem = file->child (j, 0 );
1121
1119
QVariantMap userdata = errorItem->data ().toMap ();
@@ -1126,7 +1124,7 @@ void ResultsTree::suppressSelectedIds()
1126
1124
}
1127
1125
}
1128
1126
if (file->rowCount () == 0 )
1129
- mModel -> removeRow (file->row ());
1127
+ mModel . removeRow (file->row ());
1130
1128
}
1131
1129
1132
1130
@@ -1141,7 +1139,7 @@ void ResultsTree::suppressHash()
1141
1139
// Extract selected warnings
1142
1140
QSet<QStandardItem *> selectedWarnings;
1143
1141
for (QModelIndex index : mSelectionModel ->selectedRows ()) {
1144
- QStandardItem *item = mModel -> itemFromIndex (index);
1142
+ QStandardItem *item = mModel . itemFromIndex (index);
1145
1143
if (!item->parent ())
1146
1144
continue ;
1147
1145
while (item->parent ()->parent ())
@@ -1165,7 +1163,7 @@ void ResultsTree::suppressHash()
1165
1163
}
1166
1164
fileItem->removeRow (item->row ());
1167
1165
if (fileItem->rowCount () == 0 )
1168
- mModel -> removeRow (fileItem->row ());
1166
+ mModel . removeRow (fileItem->row ());
1169
1167
}
1170
1168
1171
1169
if (changed)
@@ -1188,7 +1186,7 @@ void ResultsTree::tagSelectedItems(const QString &tag)
1188
1186
bool isTagged = false ;
1189
1187
ProjectFile *currentProject = ProjectFile::getActiveProject ();
1190
1188
for (QModelIndex index : mSelectionModel ->selectedRows ()) {
1191
- QStandardItem *item = mModel -> itemFromIndex (index);
1189
+ QStandardItem *item = mModel . itemFromIndex (index);
1192
1190
QVariantMap itemdata = item->data ().toMap ();
1193
1191
if (itemdata.contains (" tags" )) {
1194
1192
itemdata[TAGS] = tag;
@@ -1211,7 +1209,7 @@ void ResultsTree::context(int application)
1211
1209
1212
1210
void ResultsTree::quickStartApplication (const QModelIndex &index)
1213
1211
{
1214
- startApplication (mModel -> itemFromIndex (index));
1212
+ startApplication (mModel . itemFromIndex (index));
1215
1213
}
1216
1214
1217
1215
QString ResultsTree::getFilePath (const QStandardItem *target, bool fullPath)
@@ -1261,9 +1259,9 @@ void ResultsTree::saveResults(Report *report) const
1261
1259
{
1262
1260
report->writeHeader ();
1263
1261
1264
- for (int i = 0 ; i < mModel -> rowCount (); i++) {
1262
+ for (int i = 0 ; i < mModel . rowCount (); i++) {
1265
1263
if (mSaveAllErrors || !isRowHidden (i, QModelIndex ()))
1266
- saveErrors (report, mModel -> item (i, 0 ));
1264
+ saveErrors (report, mModel . item (i, 0 ));
1267
1265
}
1268
1266
1269
1267
report->writeFooter ();
@@ -1313,8 +1311,8 @@ void ResultsTree::updateFromOldReport(const QString &filename)
1313
1311
}
1314
1312
1315
1313
// Read current results..
1316
- for (int i = 0 ; i < mModel -> rowCount (); i++) {
1317
- QStandardItem *fileItem = mModel -> item (i,0 );
1314
+ for (int i = 0 ; i < mModel . rowCount (); i++) {
1315
+ QStandardItem *fileItem = mModel . item (i,0 );
1318
1316
for (int j = 0 ; j < fileItem->rowCount (); j++) {
1319
1317
QStandardItem *error = fileItem->child (j,0 );
1320
1318
ErrorItem errorItem;
@@ -1493,8 +1491,8 @@ void ResultsTree::refreshFilePaths()
1493
1491
qDebug (" Refreshing file paths" );
1494
1492
1495
1493
// Go through all file items (these are parent items that contain the errors)
1496
- for (int i = 0 ; i < mModel -> rowCount (); i++) {
1497
- refreshFilePaths (mModel -> item (i, 0 ));
1494
+ for (int i = 0 ; i < mModel . rowCount (); i++) {
1495
+ refreshFilePaths (mModel . item (i, 0 ));
1498
1496
}
1499
1497
}
1500
1498
@@ -1505,12 +1503,12 @@ bool ResultsTree::hasVisibleResults() const
1505
1503
1506
1504
bool ResultsTree::hasResults () const
1507
1505
{
1508
- return mModel -> rowCount () > 0 ;
1506
+ return mModel . rowCount () > 0 ;
1509
1507
}
1510
1508
1511
1509
void ResultsTree::translate ()
1512
1510
{
1513
- mModel -> setHorizontalHeaderLabels (getLabels ());
1511
+ mModel . setHorizontalHeaderLabels (getLabels ());
1514
1512
// TODO go through all the errors in the tree and translate severity and message
1515
1513
}
1516
1514
0 commit comments