Commit a6ef3573 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some foreach

parent 463be3b3
Pipeline #176181 failed with stage
in 2 minutes and 4 seconds
......@@ -68,7 +68,7 @@ void ElementCountMap::add(Element *_element, int _count)
void ElementCountMap::multiply(int _factor)
{
foreach (ElementCount * count, m_map) {
for (ElementCount * count : std::as_const(m_map)) {
count->multiply(_factor);
}
}
......
......@@ -88,11 +88,11 @@ void nuclearCalculator::init()
{
const int ISOTOPE_NUM = 22;
// Add all isotope names of Uranium (by default)to the isotope comboBox
QList<Isotope*> list = KalziumDataObject::instance()->isotopes(92);
const QList<Isotope*> list = KalziumDataObject::instance()->isotopes(92);
QString isotope;
ui.isotope->clear();
foreach (Isotope *i, list) {
for (Isotope *i : list) {
isotope.setNum(i->mass());
ui.isotope->addItem(isotope);
}
......@@ -177,12 +177,12 @@ void nuclearCalculator::elementChanged(int index)
m_element = * KalziumDataObject::instance()->element(index + 1);
// Add all isotope names of Uranium (by default) to the isotope comboBox
QList<Isotope*> list = KalziumDataObject::instance()->isotopes(index + 1);
const QList<Isotope*> list = KalziumDataObject::instance()->isotopes(index + 1);
QString isotope; // A temporary string
ui.isotope->clear(); // Clear the contents of the combo box
// update the combobox with isotopes of the new element
foreach (Isotope *i, list) {
for (Isotope *i : list) {
isotope.setNum(i->mass());
ui.isotope->addItem(isotope);
}
......
......@@ -43,11 +43,11 @@ void IsotopeScene::drawIsotopes()
const QList<Element*> elist = KalziumDataObject::instance()->ElementList;
foreach (Element *e, elist) {
for (Element *e : elist) {
int elementNumber = e->dataAsVariant(ChemicalDataObject::atomicNumber).toInt();
const QList<Isotope*> ilist = KalziumDataObject::instance()->isotopes(elementNumber);
foreach (Isotope *i, ilist) {
for (Isotope *i : ilist) {
int x = elementNumber * m_itemSize;
int y = (300 - i->nucleons()) * m_itemSize;
......
......@@ -78,12 +78,12 @@ KalziumDataObject::KalziumDataObject()
isoreader.setContentHandler(isoparser);
isoreader.parse(isosource);
QList<Isotope*> isotopes = isoparser->getIsotopes();
const QList<Isotope*> isotopes = isoparser->getIsotopes();
//we don't need isoparser anymore, let's free its memory
delete isoparser;
foreach (Isotope *iso, isotopes)
for (Isotope *iso : isotopes)
{
int num = iso->parentElementNumber();
if (m_isotopes.contains(num)) {
......
......@@ -93,7 +93,7 @@ void RSDialog::filterRS(const QList<int>& r, const QList<int>& s)
}
if (!s.isEmpty()) {
string.append("<h2>" + i18n("S-Phrases:") + "</h2>");
foreach (int i, s) {
for (int i : s) {
QString phrase("<b>" + QString::number(i) + " - ");
phrase.append(sphrase(i) + "</b>");
string.append(phrase + "<br>");
......
Supports Markdown
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