@@ -27,11 +27,11 @@ IgnoreListTableWidget::IgnoreListTableWidget(QWidget *parent)
27
27
" This is useful for meta data." ));
28
28
29
29
ui->removePushButton ->setEnabled (false );
30
- connect (ui->tableWidget , &QTableWidget::itemSelectionChanged,
30
+ connect (ui->tableWidget , &QTableWidget::itemSelectionChanged,
31
31
this , &IgnoreListTableWidget::slotItemSelectionChanged);
32
- connect (ui->removePushButton , &QAbstractButton::clicked,
32
+ connect (ui->removePushButton , &QAbstractButton::clicked,
33
33
this , &IgnoreListTableWidget::slotRemoveCurrentItem);
34
- connect (ui->addPushButton , &QAbstractButton::clicked,
34
+ connect (ui->addPushButton , &QAbstractButton::clicked,
35
35
this , &IgnoreListTableWidget::slotAddPattern);
36
36
connect (ui->removeAllPushButton , &QAbstractButton::clicked,
37
37
this , &IgnoreListTableWidget::slotRemoveAllItems);
@@ -48,13 +48,13 @@ IgnoreListTableWidget::~IgnoreListTableWidget()
48
48
49
49
void IgnoreListTableWidget::slotItemSelectionChanged ()
50
50
{
51
- QTableWidgetItem * item = ui->tableWidget ->currentItem ();
51
+ const auto item = ui->tableWidget ->currentItem ();
52
52
if (!item) {
53
53
ui->removePushButton ->setEnabled (false );
54
54
return ;
55
55
}
56
56
57
- bool enable = item->flags () & Qt::ItemIsEnabled;
57
+ const auto enable = item->flags () & Qt::ItemIsEnabled;
58
58
ui->removePushButton ->setEnabled (enable);
59
59
}
60
60
@@ -70,15 +70,18 @@ void IgnoreListTableWidget::slotRemoveAllItems()
70
70
ui->tableWidget ->setRowCount (0 );
71
71
}
72
72
73
- void IgnoreListTableWidget::slotWriteIgnoreFile (const QString & file)
73
+ void IgnoreListTableWidget::slotWriteIgnoreFile (const QString &file)
74
74
{
75
75
QFile ignores (file);
76
+
76
77
if (ignores.open (QIODevice::WriteOnly)) {
77
78
// rewrites the whole file since now the user can also remove system patterns
78
79
QFile::resize (file, 0 );
79
- for (int row = 0 ; row < ui->tableWidget ->rowCount (); ++row) {
80
- QTableWidgetItem *patternItem = ui->tableWidget ->item (row, patternCol);
81
- QTableWidgetItem *deletableItem = ui->tableWidget ->item (row, deletableCol);
80
+
81
+ for (auto row = 0 ; row < ui->tableWidget ->rowCount (); ++row) {
82
+ const auto patternItem = ui->tableWidget ->item (row, patternCol);
83
+ const auto deletableItem = ui->tableWidget ->item (row, deletableCol);
84
+
82
85
if (patternItem->flags () & Qt::ItemIsEnabled) {
83
86
QByteArray prepend;
84
87
if (deletableItem->checkState () == Qt::Checked) {
@@ -90,12 +93,13 @@ void IgnoreListTableWidget::slotWriteIgnoreFile(const QString & file)
90
93
}
91
94
}
92
95
} else {
93
- QMessageBox::warning (this , tr (" Could not open file" ),
94
- tr (" Cannot write changes to \" %1\" ." ).arg (file));
96
+ QMessageBox::warning (this ,
97
+ tr (" Could not open file" ),
98
+ tr (" Cannot write changes to \" %1\" ." ).arg (file));
95
99
}
96
100
ignores.close (); // close the file before reloading stuff.
97
101
98
- FolderMan * folderMan = FolderMan::instance ();
102
+ const auto folderMan = FolderMan::instance ();
99
103
100
104
// We need to force a remote discovery after a change of the ignore list.
101
105
// Otherwise we would not download the files/directories that are no longer
@@ -108,10 +112,13 @@ void IgnoreListTableWidget::slotWriteIgnoreFile(const QString & file)
108
112
109
113
void IgnoreListTableWidget::slotAddPattern ()
110
114
{
111
- bool okClicked = false ;
112
- QString pattern = QInputDialog::getText (this , tr (" Add Ignore Pattern" ),
113
- tr (" Add a new ignore pattern:" ),
114
- QLineEdit::Normal, QString (), &okClicked);
115
+ auto okClicked = false ;
116
+ const auto pattern = QInputDialog::getText (this ,
117
+ tr (" Add Ignore Pattern" ),
118
+ tr (" Add a new ignore pattern:" ),
119
+ QLineEdit::Normal,
120
+ {},
121
+ &okClicked);
115
122
116
123
if (!okClicked || pattern.isEmpty ())
117
124
return ;
@@ -120,18 +127,20 @@ void IgnoreListTableWidget::slotAddPattern()
120
127
ui->tableWidget ->scrollToBottom ();
121
128
}
122
129
123
- void IgnoreListTableWidget::readIgnoreFile (const QString &file, bool readOnly)
130
+ void IgnoreListTableWidget::readIgnoreFile (const QString &file, const bool readOnly)
124
131
{
125
132
QFile ignores (file);
133
+
126
134
if (ignores.open (QIODevice::ReadOnly)) {
127
135
while (!ignores.atEnd ()) {
128
- QString line = QString::fromUtf8 (ignores.readLine ());
136
+ auto line = QString::fromUtf8 (ignores.readLine ());
129
137
line.chop (1 );
130
138
if (line == QStringLiteral (" \\ #*#" )) {
131
139
continue ;
132
140
}
141
+
133
142
if (!line.isEmpty () && !line.startsWith (" #" )) {
134
- bool deletable = false ;
143
+ auto deletable = false ;
135
144
if (line.startsWith (' ]' )) {
136
145
deletable = true ;
137
146
line = line.mid (1 );
@@ -142,16 +151,16 @@ void IgnoreListTableWidget::readIgnoreFile(const QString &file, bool readOnly)
142
151
}
143
152
}
144
153
145
- int IgnoreListTableWidget::addPattern (const QString &pattern, bool deletable, bool readOnly)
154
+ int IgnoreListTableWidget::addPattern (const QString &pattern, const bool deletable, const bool readOnly)
146
155
{
147
- int newRow = ui->tableWidget ->rowCount ();
156
+ const auto newRow = ui->tableWidget ->rowCount ();
148
157
ui->tableWidget ->setRowCount (newRow + 1 );
149
158
150
- auto * patternItem = new QTableWidgetItem;
159
+ const auto patternItem = new QTableWidgetItem;
151
160
patternItem->setText (pattern);
152
161
ui->tableWidget ->setItem (newRow, patternCol, patternItem);
153
162
154
- auto * deletableItem = new QTableWidgetItem;
163
+ const auto deletableItem = new QTableWidgetItem;
155
164
deletableItem->setFlags (Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
156
165
deletableItem->setCheckState (deletable ? Qt::Checked : Qt::Unchecked);
157
166
ui->tableWidget ->setItem (newRow, deletableCol, deletableItem);
0 commit comments