Skip to content

Commit 1dde1b4

Browse files
committed
Resolved clang warnings: refactor output handling and signal emissions across multiple classes for improved clarity and performance
1 parent c6e61e8 commit 1dde1b4

9 files changed

+49
-45
lines changed

source/AbstractOutputCatalog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ void AbstractOutputCatalog::setApproach(int approach) {
3838

3939
// Disable time series only outputs
4040
if (_approach == MotionLibrary::RandomVibrationTheory) {
41-
for (auto *ao : outputs()) {
41+
const auto outputList = outputs();
42+
for (auto *ao : outputList) {
4243
auto *apo = qobject_cast<AbstractProfileOutput *>(ao);
4344
if (apo && apo->timeSeriesOnly())
4445
apo->setEnabled(false);

source/AbstractOutputCatalog.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public slots:
4545
void setApproach(int approach);
4646

4747
signals:
48-
void timesAreNeededChanged(bool timesAreNeeded) const;
49-
void periodIsNeededChanged(bool periodIsNeeded) const;
50-
void frequencyIsNeededChanged(bool frequencyIsNeeded) const;
48+
void timesAreNeededChanged(bool timesAreNeeded);
49+
void periodIsNeededChanged(bool periodIsNeeded);
50+
void frequencyIsNeededChanged(bool frequencyIsNeeded);
5151

5252
void wasModified();
5353

source/BatchRunner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#define BATCHRUNNER_H
2424

2525
#include <QElapsedTimer>
26+
#include <QStringList>
2627
#include <QTextStream>
27-
#include <QtCore>
2828

2929
#include "SiteResponseModel.h"
3030

source/CustomNonlinearProperty.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ auto CustomNonlinearProperty::setData(const QModelIndex &index,
5252
gsl_interp_accel_reset(_acc);
5353
break;
5454
}
55-
dataChanged(index, index);
55+
emit dataChanged(index, index);
5656
return true;
5757
} else {
5858
return false;
@@ -69,13 +69,13 @@ auto CustomNonlinearProperty::insertRows(int row, int count,
6969
if (!count)
7070
return false;
7171

72-
emit beginInsertRows(parent, row, row + count - 1);
72+
beginInsertRows(parent, row, row + count - 1);
7373

7474
_strain.insert(row, count, 0);
7575
_average.insert(row, count, 0);
7676
_varied.insert(row, count, 0);
7777

78-
emit endInsertRows();
78+
endInsertRows();
7979
return true;
8080
}
8181

@@ -84,12 +84,12 @@ auto CustomNonlinearProperty::removeRows(int row, int count,
8484
if (!count)
8585
return false;
8686

87-
emit beginRemoveRows(parent, row, row + count - 1);
87+
beginRemoveRows(parent, row, row + count - 1);
8888

8989
_strain.remove(row, count);
9090
_average.remove(row, count);
9191
_varied.remove(row, count);
9292

93-
emit endRemoveRows();
93+
endRemoveRows();
9494
return true;
9595
}

source/OutputCatalog.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,9 @@ auto OutputCatalog::motionNameAt(int row) const -> const QString {
370370
void OutputCatalog::initialize(int siteCount, MotionLibrary *motionLibrary) {
371371
// Create a list of all enabled outputs
372372
_outputs.clear();
373-
for (auto *catalog : _catalogs) {
374-
for (auto *output : catalog->outputs()) {
373+
for (auto *catalog : std::as_const(_catalogs)) {
374+
const auto catalogOutputs = catalog->outputs();
375+
for (auto *output : catalogOutputs) {
375376
if (!output->needsTime() ||
376377
(output->needsTime() &&
377378
motionLibrary->approach() == MotionLibrary::TimeSeries)) {
@@ -420,8 +421,9 @@ void OutputCatalog::clear() {
420421

421422
// Need to loop over the catalogs as _outputs my have previously deleted
422423
// pointers
423-
for (auto *catalog : _catalogs) {
424-
for (auto *output : catalog->outputs()) {
424+
for (auto *catalog : std::as_const(_catalogs)) {
425+
const auto catalogOutputs = catalog->outputs();
426+
for (auto *output : catalogOutputs) {
425427
output->clear();
426428
}
427429
}
@@ -430,14 +432,14 @@ void OutputCatalog::clear() {
430432
}
431433

432434
void OutputCatalog::finalize() {
433-
for (AbstractOutput *output : _outputs)
435+
for (AbstractOutput *output : std::as_const(_outputs))
434436
output->finalize();
435437

436438
emit wasModified();
437439
}
438440

439441
void OutputCatalog::setReadOnly(bool readOnly) {
440-
for (AbstractOutputCatalog *catalog : _catalogs)
442+
for (AbstractOutputCatalog *catalog : std::as_const(_catalogs))
441443
catalog->setReadOnly(readOnly);
442444
}
443445

@@ -447,13 +449,13 @@ void OutputCatalog::saveResults(int motion,
447449
// sublayer. These depths are updated as the velocity profile is varied.
448450
populateDepthVector(calculator->site()->subLayers().last().depthToBase());
449451

450-
for (AbstractOutput *output : _outputs) {
452+
for (AbstractOutput *output : std::as_const(_outputs)) {
451453
output->addData(motion, calculator);
452454
}
453455
}
454456

455457
void OutputCatalog::removeLastSite() {
456-
for (AbstractOutput *output : _outputs)
458+
for (AbstractOutput *output : std::as_const(_outputs))
457459
output->removeLastSite();
458460
}
459461

@@ -486,7 +488,7 @@ void OutputCatalog::setFrequencyIsNeeded(bool frequencyIsNeeded) {
486488
auto OutputCatalog::outputNames() const -> QStringList {
487489
QStringList list;
488490

489-
for (AbstractOutput *output : _outputs)
491+
for (AbstractOutput *output : std::as_const(_outputs))
490492
list << output->fullName();
491493

492494
return list;
@@ -498,7 +500,7 @@ auto OutputCatalog::outputs() const -> const QList<AbstractOutput *> & {
498500

499501
void OutputCatalog::exportData(const QString &path, const QString &separator,
500502
const QString &prefix) {
501-
for (AbstractOutput *output : _outputs) {
503+
for (AbstractOutput *output : std::as_const(_outputs)) {
502504
if (output->exportEnabled())
503505
output->exportData(path, separator, prefix);
504506
}
@@ -561,9 +563,11 @@ void OutputCatalog::fromJson(const QJsonObject &json) {
561563
}
562564

563565
_enabled.clear();
564-
for (const QJsonValue &value : json["enabled"].toArray()) {
566+
const QJsonArray enabledArray = json["enabled"].toArray();
567+
for (const QJsonValue &value : enabledArray) {
565568
QList<bool> l;
566-
for (const QJsonValue &v : value.toArray())
569+
const QJsonArray innerArray = value.toArray();
570+
for (const QJsonValue &v : innerArray)
567571
l << v.toBool();
568572
_enabled << l;
569573
}

source/ProfilesOutputCatalog.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ProfilesOutputCatalog::ProfilesOutputCatalog(OutputCatalog *outputCatalog)
6262
<< new VerticalTotalStressProfileOutput(_outputCatalog)
6363
<< new VerticalEffectiveStressProfileOutput(_outputCatalog);
6464

65-
for (auto *output : _outputs)
65+
for (auto *output : std::as_const(_outputs))
6666
connect(output, &AbstractOutput::wasModified, this,
6767
&ProfilesOutputCatalog::wasModified);
6868
}
@@ -144,19 +144,19 @@ auto ProfilesOutputCatalog::removeRows(int row, int count,
144144
const QModelIndex &parent) -> bool {
145145
if (!count)
146146
return false;
147-
emit beginRemoveRows(parent, row, row + count - 1);
147+
beginRemoveRows(parent, row, row + count - 1);
148148

149149
for (int i = 0; i < count; ++i)
150150
_outputs.takeAt(row)->deleteLater();
151151

152-
emit endRemoveRows();
152+
endRemoveRows();
153153
return true;
154154
}
155155

156156
auto ProfilesOutputCatalog::outputs() const -> QList<AbstractOutput *> {
157157
QList<AbstractOutput *> list;
158158

159-
for (AbstractProfileOutput *apo : _outputs)
159+
for (AbstractProfileOutput *apo : std::as_const(_outputs))
160160
if (apo->enabled())
161161
list << static_cast<AbstractOutput *>(apo);
162162

@@ -167,7 +167,7 @@ void ProfilesOutputCatalog::fromJson(const QJsonArray &json) {
167167
beginResetModel();
168168

169169
QMap<QString, AbstractProfileOutput *> output_map;
170-
for (AbstractProfileOutput *o : _outputs)
170+
for (AbstractProfileOutput *o : std::as_const(_outputs))
171171
output_map.insert(o->metaObject()->className(), o);
172172

173173
for (const QJsonValue &qjv : json) {
@@ -182,7 +182,7 @@ void ProfilesOutputCatalog::fromJson(const QJsonArray &json) {
182182

183183
auto ProfilesOutputCatalog::toJson() const -> QJsonArray {
184184
QJsonArray json;
185-
for (AbstractProfileOutput *apo : _outputs) {
185+
for (AbstractProfileOutput *apo : std::as_const(_outputs)) {
186186
json << apo->toJson();
187187
}
188188

@@ -193,7 +193,7 @@ auto operator<<(QDataStream &out, const ProfilesOutputCatalog *poc)
193193
-> QDataStream & {
194194
out << (quint8)4;
195195

196-
for (AbstractProfileOutput *apo : poc->_outputs) {
196+
for (AbstractProfileOutput *apo : std::as_const(poc->_outputs)) {
197197
out << apo;
198198
}
199199

@@ -205,7 +205,7 @@ auto operator>>(QDataStream &in, ProfilesOutputCatalog *poc) -> QDataStream & {
205205
in >> ver;
206206
poc->beginResetModel();
207207

208-
for (AbstractProfileOutput *apo : poc->_outputs) {
208+
for (AbstractProfileOutput *apo : std::as_const(poc->_outputs)) {
209209
// Skip profiles not included in earlier versions
210210
if (ver < 2 && qobject_cast<MaxDispProfileOutput *>(apo))
211211
continue;

source/SiteResponseModel.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,9 @@ auto SiteResponseModel::toHtml() -> QString {
615615
"<tr><th>Units System:</th><td>%4</td></tr>"
616616
"</table>"
617617
"</li>")
618-
.arg(_outputCatalog->title())
619-
.arg(_notes->toHtml())
620-
.arg(_outputCatalog->filePrefix())
621-
.arg(Units::instance()->systemList().at(Units::instance()->system()));
618+
.arg(_outputCatalog->title(), _notes->toHtml(),
619+
_outputCatalog->filePrefix(),
620+
Units::instance()->systemList().at(Units::instance()->system()));
622621

623622
// Type of Analysis
624623
html += tr("<li>Type of Analysis"
@@ -628,9 +627,9 @@ auto SiteResponseModel::toHtml() -> QString {
628627
"<tr><th>Properties Varied:</th><td>%3</td></tr>"
629628
"</table>"
630629
"</li>")
631-
.arg(methodList().at(_method))
632-
.arg(MotionLibrary::approachList().at(_motionLibrary->approach()))
633-
.arg(boolToString(_siteProfile->isVaried()));
630+
.arg(methodList().at(_method),
631+
MotionLibrary::approachList().at(_motionLibrary->approach()),
632+
boolToString(_siteProfile->isVaried()));
634633

635634
// Site Variation
636635
if (_siteProfile->isVaried())
@@ -644,8 +643,8 @@ auto SiteResponseModel::toHtml() -> QString {
644643
"</li>")
645644
.arg(_siteProfile->profileCount())
646645
.arg(boolToString(
647-
_siteProfile->nonlinearPropertyRandomizer()->enabled()))
648-
.arg(boolToString(_siteProfile->profileRandomizer()->enabled()));
646+
_siteProfile->nonlinearPropertyRandomizer()->enabled()),
647+
boolToString(_siteProfile->profileRandomizer()->enabled()));
649648

650649
// Layer Discretization
651650
html += tr("<li>Layer Discretization"

source/SoilTypeCatalog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ auto SoilTypeCatalog::insertRows(int row, int count, const QModelIndex &parent)
233233
if (!count)
234234
return false;
235235

236-
emit beginInsertRows(parent, row, row + count - 1);
236+
beginInsertRows(parent, row, row + count - 1);
237237

238238
for (int i = 0; i < count; ++i) {
239239
_soilTypes.insert(row, new SoilType(this));
240240
emit soilTypeAdded(_soilTypes.at(row));
241241
}
242242

243-
emit endInsertRows();
243+
endInsertRows();
244244
return true;
245245
}
246246

@@ -249,14 +249,14 @@ auto SoilTypeCatalog::removeRows(int row, int count, const QModelIndex &parent)
249249
if (!count)
250250
return false;
251251

252-
emit beginRemoveRows(parent, row, row + count - 1);
252+
beginRemoveRows(parent, row, row + count - 1);
253253

254254
for (int i = 0; i < count; ++i) {
255255
emit soilTypeRemoved(_soilTypes.at(row));
256256
_soilTypes.takeAt(row)->deleteLater();
257257
}
258258

259-
emit endRemoveRows();
259+
endRemoveRows();
260260

261261
return true;
262262
}
@@ -314,7 +314,7 @@ void SoilTypeCatalog::fromJson(const QJsonArray &json) {
314314
while (_soilTypes.size())
315315
_soilTypes.takeLast()->deleteLater();
316316

317-
foreach (const QJsonValue &v, json) {
317+
for (const QJsonValue &v : json) {
318318
auto *st = new SoilType(this);
319319
st->fromJson(v.toObject());
320320
_soilTypes << st;

source/SpectraOutputCatalog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void SpectraOutputCatalog::fromJson(const QJsonArray &array) {
243243
while (_outputs.size())
244244
_outputs.takeLast()->deleteLater();
245245

246-
foreach (const QJsonValue &v, array) {
246+
for (const QJsonValue &v : array) {
247247
QJsonObject json = v.toObject();
248248
AbstractLocationOutput *alo =
249249
factory(json["className"].toString(), _outputCatalog);

0 commit comments

Comments
 (0)