Commit 1b9fae17 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use for(...:...) + const

parent 6c4e9648
Pipeline #119988 passed with stage
in 1 minute and 25 seconds
......@@ -26,7 +26,7 @@ QVariant Element::dataAsVariant(ChemicalDataObject::BlueObelisk type) const
QVariant Element::dataAsVariant(ChemicalDataObject::BlueObelisk type, int unit) const
{
foreach (const ChemicalDataObject &o, dataList) {
for (const ChemicalDataObject &o : dataList) {
if (o.type() == type) {
if (unit == KUnitConversion::NoUnit) {
return o.value();
......
......@@ -25,7 +25,7 @@ ElementCountMap::~ElementCountMap()
ElementCount *ElementCountMap::search(Element *_element)
{
foreach (ElementCount *c, m_map) {
for (ElementCount *c : std::as_const(m_map)) {
if (c->element() == _element) {
return c;
}
......@@ -36,7 +36,7 @@ ElementCount *ElementCountMap::search(Element *_element)
void ElementCountMap::add(ElementCountMap &_map)
{
foreach (ElementCount *c, _map.m_map) {
for (ElementCount *c : std::as_const(_map.m_map)) {
add(c->m_element, c->m_count);
}
}
......@@ -45,7 +45,7 @@ QList<Element*> ElementCountMap::elements()
{
QList<Element*> list;
foreach (ElementCount* c, m_map) {
for (ElementCount* c : std::as_const(m_map)) {
Element* e = c->m_element;
if (!list.contains(e)) {
list << e;
......
......@@ -111,7 +111,7 @@ bool SpectrumParser::characters(const QString &ch)
return true;
}
QList<Spectrum*> SpectrumParser::getSpectrums()
QList<Spectrum*> SpectrumParser::getSpectrums() const
{
return d->spectra;
}
......@@ -35,7 +35,7 @@ public:
bool characters(const QString &ch) override;
QList<Spectrum*> getSpectrums();
QList<Spectrum*> getSpectrums() const;
private:
QString currentElementID;
......
......@@ -77,7 +77,7 @@ ExportDialog::ExportDialog(QWidget * parent)
: QDialog(parent),m_outputStream(nullptr)
{
qCDebug(KALZIUM_LOG) << "ExportDialog::ExportDialog";
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Help);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Help, this);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
......
......@@ -36,7 +36,7 @@ void IsotopeScene::updateContextHelp(IsotopeItem * item)
void IsotopeScene::drawIsotopes()
{
QList<Element*> elist = KalziumDataObject::instance()->ElementList;
const QList<Element*> elist = KalziumDataObject::instance()->ElementList;
int mode = 0;
foreach (Element *e, elist) {
......
......@@ -63,7 +63,7 @@ void RSDialog::filter()
if (!ui.r_le->text().isEmpty())
{
const QStringList rSplit = ui.r_le->text().split('-');
foreach (const QString &st, rSplit) {
for (const QString &st : rSplit) {
r << st.toInt();
}
}
......@@ -72,7 +72,7 @@ void RSDialog::filter()
if (!ui.s_le->text().isEmpty())
{
const QStringList sSplit = ui.s_le->text().split('-');
foreach (const QString &st, sSplit) {
for (const QString &st : sSplit) {
s << st.toInt();
}
}
......@@ -84,15 +84,15 @@ void RSDialog::filterRS(const QList<int>& r, const QList<int>& s)
{
QString string(QStringLiteral("<qt>"));
if (r.count() > 0) {
if (!r.isEmpty()) {
string.append("<h2>" + i18n("R-Phrases:") + "</h2>");
foreach (int i, r) {
for (int i : r) {
QString phrase("<b>" + QString::number(i) + " - ");
phrase.append(rphrase(i) + "</b>");
string.append(phrase + "<br>");
}
}
if (s.count() > 0) {
if (!s.isEmpty()) {
string.append("<h2>" + i18n("S-Phrases:") + "</h2>");
foreach (int i, s) {
QString phrase("<b>" + QString::number(i) + " - ");
......@@ -100,7 +100,7 @@ void RSDialog::filterRS(const QList<int>& r, const QList<int>& s)
string.append(phrase + "<br>");
}
}
if (s.count() == 0 && r.count() == 0)
if (s.isEmpty() && r.isEmpty())
string.append("<h2>" + i18n("You asked for no R/S-Phrases.") + "</h2>");
string.append("</qt>");
......
......@@ -73,8 +73,8 @@ void SearchWidget::doSearch()
return;
}
QString txt = m_searchLine->text();
if (txt.length() > 0) {
const QString txt = m_searchLine->text();
if (!txt.isEmpty()) {
s->doSearch(txt, Search::SearchAll);
} else {
s->resetSearch();
......
......@@ -85,7 +85,7 @@ void SpectrumViewImpl::updatePeakInformation(Spectrum::peak *peak)
{
double peakWavelength = peak->wavelengthToUnit(Prefs::spectrumWavelengthUnit());
QList<QTreeWidgetItem *> foundItems = peakListTable->findItems(QString::number(peakWavelength),
const QList<QTreeWidgetItem *> foundItems = peakListTable->findItems(QString::number(peakWavelength),
Qt::MatchExactly);
if (foundItems.isEmpty()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment