Skip to content

Commit afb3554

Browse files
committed
revert [skip ci]
1 parent f508660 commit afb3554

File tree

2 files changed

+45
-48
lines changed

2 files changed

+45
-48
lines changed

gui/resultstree.cpp

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include <QSettings>
6161
#include <QSignalMapper>
6262
#include <QStandardItem>
63-
#include <QStandardItemModel>
6463
#include <QUrl>
6564
#include <QVariant>
6665
#include <QVariantMap>
@@ -146,10 +145,9 @@ static QStringList getLabels() {
146145
}
147146

148147
ResultsTree::ResultsTree(QWidget * parent) :
149-
QTreeView(parent),
150-
mModel(new QStandardItemModel)
148+
QTreeView(parent)
151149
{
152-
setModel(mModel);
150+
setModel(&mModel);
153151
translate(); // Adds columns to grid
154152
clear();
155153
setExpandsOnDoubleClick(false);
@@ -171,8 +169,8 @@ void ResultsTree::setReportType(ReportType reportType) {
171169

172170
mGuideline = createGuidelineMapping(reportType);
173171

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);
176174
if (!fileItem)
177175
continue;
178176
for (int j = 0; j < fileItem->rowCount(); ++j) {
@@ -475,20 +473,20 @@ QStandardItem *ResultsTree::findFileItem(const QString &name) const
475473
// The first column contains the file name. In Windows we can get filenames
476474
// "header.h" and "Header.h" and must compare them as identical.
477475

478-
for (int i = 0; i < mModel->rowCount(); i++) {
476+
for (int i = 0; i < mModel.rowCount(); i++) {
479477
#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)
481479
#else
482-
if (mModel->item(i, COLUMN_FILE)->text() == name)
480+
if (mModel.item(i, COLUMN_FILE)->text() == name)
483481
#endif
484-
return mModel->item(i, COLUMN_FILE);
482+
return mModel.item(i, COLUMN_FILE);
485483
}
486484
return nullptr;
487485
}
488486

489487
void ResultsTree::clear()
490488
{
491-
mModel->removeRows(0, mModel->rowCount());
489+
mModel.removeRows(0, mModel.rowCount());
492490

493491
if (const ProjectFile *activeProject = ProjectFile::getActiveProject()) {
494492
hideColumn(COLUMN_SINCE_DATE);
@@ -506,24 +504,24 @@ void ResultsTree::clear(const QString &filename)
506504
{
507505
const QString stripped = stripPath(filename, false);
508506

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);
511509
if (!fileItem)
512510
continue;
513511

514512
QVariantMap fitemdata = fileItem->data().toMap();
515513
if (stripped == fitemdata[FILENAME].toString() ||
516514
filename == fitemdata[FILE0].toString()) {
517-
mModel->removeRow(i);
515+
mModel.removeRow(i);
518516
break;
519517
}
520518
}
521519
}
522520

523521
void ResultsTree::clearRecheckFile(const QString &filename)
524522
{
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);
527525
if (!fileItem)
528526
continue;
529527

@@ -532,7 +530,7 @@ void ResultsTree::clearRecheckFile(const QString &filename)
532530
QString storedfile = fitemdata[FILENAME].toString();
533531
storedfile = ((!mCheckPath.isEmpty() && storedfile.startsWith(mCheckPath)) ? storedfile.mid(mCheckPath.length() + 1) : storedfile);
534532
if (actualfile == storedfile) {
535-
mModel->removeRow(i);
533+
mModel.removeRow(i);
536534
break;
537535
}
538536
}
@@ -541,9 +539,9 @@ void ResultsTree::clearRecheckFile(const QString &filename)
541539

542540
void ResultsTree::loadSettings()
543541
{
544-
for (int i = 0; i < mModel->columnCount(); i++) {
542+
for (int i = 0; i < mModel.columnCount(); i++) {
545543
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()));
547545
}
548546

549547
mSaveFullPath = mSettings->value(SETTINGS_SAVE_FULL_PATH, false).toBool();
@@ -556,7 +554,7 @@ void ResultsTree::loadSettings()
556554

557555
void ResultsTree::saveSettings() const
558556
{
559-
for (int i = 0; i < mModel->columnCount(); i++) {
557+
for (int i = 0; i < mModel.columnCount(); i++) {
560558
QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(i);
561559
mSettings->setValue(temp, columnWidth(i));
562560
}
@@ -601,11 +599,11 @@ void ResultsTree::refreshTree()
601599
{
602600
mVisibleErrors = false;
603601
//Get the amount of files in the tree
604-
const int filecount = mModel->rowCount();
602+
const int filecount = mModel.rowCount();
605603

606604
for (int i = 0; i < filecount; i++) {
607605
//Get file i
608-
QStandardItem *fileItem = mModel->item(i, 0);
606+
QStandardItem *fileItem = mModel.item(i, 0);
609607
if (!fileItem) {
610608
continue;
611609
}
@@ -695,7 +693,7 @@ QStandardItem *ResultsTree::ensureFileItem(const QString &fullpath, const QStrin
695693
itemdata[FILENAME] = fullpath;
696694
itemdata[FILE0] = file0;
697695
item->setData(QVariant(itemdata));
698-
mModel->appendRow(item);
696+
mModel.appendRow(item);
699697

700698
setRowHidden(item->row(), QModelIndex(), hide);
701699

@@ -712,7 +710,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
712710
if (mSelectionModel->selectedRows().count() > 1)
713711
multipleSelection = true;
714712

715-
mContextItem = mModel->itemFromIndex(index);
713+
mContextItem = mModel.itemFromIndex(index);
716714

717715
//Create a new context menu
718716
QMenu menu(this);
@@ -753,7 +751,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
753751
int selectedResults = 0;
754752

755753
for (auto row : mSelectionModel->selectedRows()) {
756-
auto *item = mModel->itemFromIndex(row);
754+
auto *item = mModel.itemFromIndex(row);
757755
if (!item->parent())
758756
selectedFiles++;
759757
else if (!item->parent()->parent())
@@ -832,7 +830,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
832830
menu.exec(e->globalPos());
833831
index = indexAt(e->pos());
834832
if (index.isValid()) {
835-
mContextItem = mModel->itemFromIndex(index);
833+
mContextItem = mModel.itemFromIndex(index);
836834
}
837835
}
838836
}
@@ -998,7 +996,7 @@ void ResultsTree::copy()
998996

999997
QString text;
1000998
for (const QModelIndex& index : mSelectionModel->selectedRows()) {
1001-
const QStandardItem *item = mModel->itemFromIndex(index);
999+
const QStandardItem *item = mModel.itemFromIndex(index);
10021000
if (!item->parent()) {
10031001
text += item->text() + '\n';
10041002
continue;
@@ -1029,7 +1027,7 @@ void ResultsTree::hideResult()
10291027
return;
10301028

10311029
for (QModelIndex index : mSelectionModel->selectedRows()) {
1032-
QStandardItem *item = mModel->itemFromIndex(index);
1030+
QStandardItem *item = mModel.itemFromIndex(index);
10331031
//Set the "hide" flag for this item
10341032
QVariantMap itemdata = item->data().toMap();
10351033
itemdata[HIDE] = true;
@@ -1047,7 +1045,7 @@ void ResultsTree::recheckSelectedFiles()
10471045

10481046
QStringList selectedItems;
10491047
for (QModelIndex index : mSelectionModel->selectedRows()) {
1050-
QStandardItem *item = mModel->itemFromIndex(index);
1048+
QStandardItem *item = mModel.itemFromIndex(index);
10511049
while (item->parent())
10521050
item = item->parent();
10531051
QVariantMap itemdata = item->data().toMap();
@@ -1102,7 +1100,7 @@ void ResultsTree::suppressSelectedIds()
11021100

11031101
QSet<QString> selectedIds;
11041102
for (QModelIndex index : mSelectionModel->selectedRows()) {
1105-
QStandardItem *item = mModel->itemFromIndex(index);
1103+
QStandardItem *item = mModel.itemFromIndex(index);
11061104
if (!item->parent())
11071105
continue;
11081106
if (item->parent()->parent())
@@ -1114,8 +1112,8 @@ void ResultsTree::suppressSelectedIds()
11141112
}
11151113

11161114
// 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);
11191117
for (int j = 0; j < file->rowCount();) {
11201118
QStandardItem *errorItem = file->child(j, 0);
11211119
QVariantMap userdata = errorItem->data().toMap();
@@ -1126,7 +1124,7 @@ void ResultsTree::suppressSelectedIds()
11261124
}
11271125
}
11281126
if (file->rowCount() == 0)
1129-
mModel->removeRow(file->row());
1127+
mModel.removeRow(file->row());
11301128
}
11311129

11321130

@@ -1141,7 +1139,7 @@ void ResultsTree::suppressHash()
11411139
// Extract selected warnings
11421140
QSet<QStandardItem *> selectedWarnings;
11431141
for (QModelIndex index : mSelectionModel->selectedRows()) {
1144-
QStandardItem *item = mModel->itemFromIndex(index);
1142+
QStandardItem *item = mModel.itemFromIndex(index);
11451143
if (!item->parent())
11461144
continue;
11471145
while (item->parent()->parent())
@@ -1165,7 +1163,7 @@ void ResultsTree::suppressHash()
11651163
}
11661164
fileItem->removeRow(item->row());
11671165
if (fileItem->rowCount() == 0)
1168-
mModel->removeRow(fileItem->row());
1166+
mModel.removeRow(fileItem->row());
11691167
}
11701168

11711169
if (changed)
@@ -1188,7 +1186,7 @@ void ResultsTree::tagSelectedItems(const QString &tag)
11881186
bool isTagged = false;
11891187
ProjectFile *currentProject = ProjectFile::getActiveProject();
11901188
for (QModelIndex index : mSelectionModel->selectedRows()) {
1191-
QStandardItem *item = mModel->itemFromIndex(index);
1189+
QStandardItem *item = mModel.itemFromIndex(index);
11921190
QVariantMap itemdata = item->data().toMap();
11931191
if (itemdata.contains("tags")) {
11941192
itemdata[TAGS] = tag;
@@ -1211,7 +1209,7 @@ void ResultsTree::context(int application)
12111209

12121210
void ResultsTree::quickStartApplication(const QModelIndex &index)
12131211
{
1214-
startApplication(mModel->itemFromIndex(index));
1212+
startApplication(mModel.itemFromIndex(index));
12151213
}
12161214

12171215
QString ResultsTree::getFilePath(const QStandardItem *target, bool fullPath)
@@ -1261,9 +1259,9 @@ void ResultsTree::saveResults(Report *report) const
12611259
{
12621260
report->writeHeader();
12631261

1264-
for (int i = 0; i < mModel->rowCount(); i++) {
1262+
for (int i = 0; i < mModel.rowCount(); i++) {
12651263
if (mSaveAllErrors || !isRowHidden(i, QModelIndex()))
1266-
saveErrors(report, mModel->item(i, 0));
1264+
saveErrors(report, mModel.item(i, 0));
12671265
}
12681266

12691267
report->writeFooter();
@@ -1313,8 +1311,8 @@ void ResultsTree::updateFromOldReport(const QString &filename)
13131311
}
13141312

13151313
// 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);
13181316
for (int j = 0; j < fileItem->rowCount(); j++) {
13191317
QStandardItem *error = fileItem->child(j,0);
13201318
ErrorItem errorItem;
@@ -1493,8 +1491,8 @@ void ResultsTree::refreshFilePaths()
14931491
qDebug("Refreshing file paths");
14941492

14951493
//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));
14981496
}
14991497
}
15001498

@@ -1505,12 +1503,12 @@ bool ResultsTree::hasVisibleResults() const
15051503

15061504
bool ResultsTree::hasResults() const
15071505
{
1508-
return mModel->rowCount() > 0;
1506+
return mModel.rowCount() > 0;
15091507
}
15101508

15111509
void ResultsTree::translate()
15121510
{
1513-
mModel->setHorizontalHeaderLabels(getLabels());
1511+
mModel.setHorizontalHeaderLabels(getLabels());
15141512
//TODO go through all the errors in the tree and translate severity and message
15151513
}
15161514

gui/resultstree.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <string>
2929

3030
#include <QObject>
31+
#include <QStandardItemModel>
3132
#include <QString>
3233
#include <QStringList>
3334
#include <QTreeView>
@@ -41,8 +42,6 @@ class QWidget;
4142
class QItemSelectionModel;
4243
class ThreadHandler;
4344
class QSettings;
44-
class QStandardItem;
45-
class QStandardItemModel;
4645
enum class Severity : std::uint8_t;
4746

4847
/// @addtogroup GUI
@@ -470,7 +469,7 @@ protected slots:
470469
* @brief Item model for tree
471470
*
472471
*/
473-
QStandardItemModel* mModel;
472+
QStandardItemModel mModel;
474473

475474
/**
476475
* @brief Program settings

0 commit comments

Comments
 (0)