diff --git a/libscience/chemicaldataobject.cpp b/libscience/chemicaldataobject.cpp --- a/libscience/chemicaldataobject.cpp +++ b/libscience/chemicaldataobject.cpp @@ -171,7 +171,7 @@ void ChemicalDataObject::setType(int type) { - d->m_type = (ChemicalDataObject::BlueObelisk) type; + d->m_type = static_cast(type); } QString ChemicalDataObject::unitAsString() const diff --git a/libscience/isotope.cpp b/libscience/isotope.cpp --- a/libscience/isotope.cpp +++ b/libscience/isotope.cpp @@ -94,7 +94,6 @@ QString Isotope::abundance() const { return m_abundance.value().toString(); - return QString(); } double Isotope::halflife() const diff --git a/libscience/parser.cpp b/libscience/parser.cpp --- a/libscience/parser.cpp +++ b/libscience/parser.cpp @@ -107,7 +107,7 @@ // The integer. while (isdigit(m_nextChar)) { - result = result * 10.0 + (double)(m_nextChar - '0'); + result = result * 10.0 + static_cast(m_nextChar - '0'); getNextChar(); } *_result = result; @@ -119,7 +119,7 @@ double decimal = 0.1; while (isdigit(m_nextChar)) { - result += decimal * (double)(m_nextChar - '0'); + result += decimal * static_cast(m_nextChar - '0'); decimal /= 10.0; getNextChar(); } diff --git a/libscience/spectrum.cpp b/libscience/spectrum.cpp --- a/libscience/spectrum.cpp +++ b/libscience/spectrum.cpp @@ -95,7 +95,7 @@ foreach (Spectrum::peak *p, m_peaklist) { double newInt = p->intensity * 1000 / maxInt; - p->intensity = (int)qRound(newInt); + p->intensity = qRound(newInt); } } diff --git a/src/calculator/calculator.cpp b/src/calculator/calculator.cpp --- a/src/calculator/calculator.cpp +++ b/src/calculator/calculator.cpp @@ -86,7 +86,7 @@ void calculator::slotItemSelection(QTreeWidgetItem *item) { - if (item == 0L) { + if (item == nullptr) { return; } diff --git a/src/calculator/concCalculator.cpp b/src/calculator/concCalculator.cpp --- a/src/calculator/concCalculator.cpp +++ b/src/calculator/concCalculator.cpp @@ -288,15 +288,15 @@ case 1: // cannot be calculated (insufficient data) error(INSUFFICIENT_DATA_MOLE); return; - break; + case 2: // molality specified numMoles = massSolvent() / 1000.0 * m_concentration; break; case 3: // cannot be calculated (insufficient data) case 4: error(INSUFFICIENT_DATA_MOLE); return; - break; + case 5: // mole fraction specified numMoles = m_concentration / (100.0 - m_concentration) * molesSolvent(); break; @@ -328,7 +328,7 @@ case 0: // molarity not sufficient error(INSUFFICIENT_DATA_EQT); return; - break; + case 1: // normality specified numEqts = volumeSolvent() * m_concentration; break; @@ -338,7 +338,7 @@ case 5: error(INSUFFICIENT_DATA_EQT); return; - break; + } if (type2 == 2) { // Amount of solute specified in moles, cannot calculate @@ -368,8 +368,8 @@ case 3: // mass fraction specified case 4: // volume fraction specified error(INSUFFICIENT_DATA_SOLVENT); - return; - break; // cannot be calculated (insufficient data) + return; // cannot be calculated (insufficient data) + case 5: // mole fraction specified numMoles = (100.0 - m_concentration) / m_concentration * molesSolute(); break; @@ -623,6 +623,7 @@ break; case 2: volume = massSolute() / densitySolute(); + break; default: volume = 0; break; diff --git a/src/calculator/gasCalculator.cpp b/src/calculator/gasCalculator.cpp --- a/src/calculator/gasCalculator.cpp +++ b/src/calculator/gasCalculator.cpp @@ -334,7 +334,5 @@ break; case GAS_MOLAR_MASS_ZERO: ui.error->setText(i18n("Molar mass cannot be zero, please enter a non-zero value.")); - default: - break; } } diff --git a/src/detailinfodlg.cpp b/src/detailinfodlg.cpp --- a/src/detailinfodlg.cpp +++ b/src/detailinfodlg.cpp @@ -164,7 +164,7 @@ DOM::HTMLElement element = htmlpart->htmlDocument().body(); if (element.tagName() == "body") { const QColor backgroundColor = palette().background().color(); - ((DOM::HTMLBodyElement)element).setBgColor(backgroundColor.name()); + (static_cast(element)).setBgColor(backgroundColor.name()); } htmlpart->end(); diff --git a/src/exportdialog.cpp b/src/exportdialog.cpp --- a/src/exportdialog.cpp +++ b/src/exportdialog.cpp @@ -179,16 +179,18 @@ { *m_outputStream << HTML_HEADER << "\n"; foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { + ElementListEntry* element_entry = static_cast (element); + *m_outputStream << "\n\n\n"; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { + PropertyListEntry* property_entry = static_cast (property); + *m_outputStream << "\n\n\n\n"; } } @@ -199,16 +201,18 @@ { *m_outputStream << XML_HEADER << "\n"; foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { + ElementListEntry* element_entry = static_cast (element); + *m_outputStream << " m_element->dataAsString(ChemicalDataObject::name) + << element_entry->m_element->dataAsString(ChemicalDataObject::name) << "\">\n"; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { + PropertyListEntry* property_entry = static_cast (property); + *m_outputStream << " text() + << property_entry->text() << "\">" - << KalziumUtils::prettyUnit( - ((ElementListEntry*) element)->m_element, - ((PropertyListEntry*) property)->m_type) + << KalziumUtils::prettyUnit(element_entry->m_element,property_entry->m_type) << "\n"; } *m_outputStream << " \n"; @@ -220,20 +224,25 @@ { *m_outputStream << "Name"; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { + PropertyListEntry* property_entry = static_cast (property); + *m_outputStream << ", \"" - << ((PropertyListEntry*) property)->text() + << property_entry->text() << "\""; } + *m_outputStream << "\n"; foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { + ElementListEntry* element_entry = static_cast (element); + *m_outputStream << "\"" - << ((ElementListEntry*) element)->m_element->dataAsString(ChemicalDataObject::name) + << element_entry->m_element->dataAsString(ChemicalDataObject::name) << "\""; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { + PropertyListEntry* property_entry = static_cast (property); + *m_outputStream << ", \"" - << KalziumUtils::prettyUnit( - ((ElementListEntry*) element)->m_element, - ((PropertyListEntry*) property)->m_type) + << KalziumUtils::prettyUnit(element_entry->m_element,property_entry->m_type) << "\""; } *m_outputStream << "\n"; diff --git a/src/gradientwidget_impl.cpp b/src/gradientwidget_impl.cpp --- a/src/gradientwidget_impl.cpp +++ b/src/gradientwidget_impl.cpp @@ -63,8 +63,8 @@ double dblMin = elementProperty->gradient()->minValue(); // saving the decimals in the int - const int intMax = dblMax * MULTIPLIKATOR; - const int intMin = dblMin * MULTIPLIKATOR; + const int intMax = static_cast(dblMax * MULTIPLIKATOR); + const int intMin = static_cast(dblMin * MULTIPLIKATOR); // now we have the slider numbers, so put the speed to a adequate value. Speed->setMaximum(intMax / 100); @@ -112,7 +112,7 @@ gradient_slider->blockSignals(true); // setting the decimals in int - int intvar = doubleVar * MULTIPLIKATOR; + int intvar = static_cast(doubleVar * MULTIPLIKATOR); gradient_slider->setValue(intvar); diff --git a/src/isotopetable/isotopeguideview.cpp b/src/isotopetable/isotopeguideview.cpp --- a/src/isotopetable/isotopeguideview.cpp +++ b/src/isotopetable/isotopeguideview.cpp @@ -24,7 +24,7 @@ IsotopeGuideView::IsotopeGuideView(QWidget *parent) : QGraphicsView(parent) { - m_guidedView = 0; + m_guidedView = nullptr; m_scale = 1.0; setCursor(Qt::OpenHandCursor); diff --git a/src/kdeeduglossary.cpp b/src/kdeeduglossary.cpp --- a/src/kdeeduglossary.cpp +++ b/src/kdeeduglossary.cpp @@ -232,19 +232,19 @@ QStringList reflist; itemList = itemDocument.elementsByTagName("item"); + const int num = itemList.count(); - const uint num = itemList.count(); - for (uint i = 0; i < num; ++i) { + for (int i = 0; i < num; ++i) { reflist.clear(); GlossaryItem *item = new GlossaryItem(); - itemElement = (const QDomElement&) itemList.item(i).toElement(); + itemElement = itemList.item(i).toElement(); QDomNode nameNode = itemElement.namedItem("name"); QDomNode descNode = itemElement.namedItem("desc"); QString picName = itemElement.namedItem("picture").toElement().text(); - QDomElement refNode = (const QDomElement&) itemElement.namedItem("references").toElement(); + QDomElement refNode = itemElement.namedItem("references").toElement(); QString desc = i18n(descNode.toElement().text().toUtf8()); if (!picName.isEmpty()) { diff --git a/src/molcalcwidget.cpp b/src/molcalcwidget.cpp --- a/src/molcalcwidget.cpp +++ b/src/molcalcwidget.cpp @@ -98,7 +98,7 @@ for (i = 0; i < length; ++i) { shortForm = shortList.takeFirst (); fullForm = fullList.takeFirst (); - ui.user_defined->setItem((int)i, 0, new QTableWidgetItem + ui.user_defined->setItem(i, 0, new QTableWidgetItem (i18n("%1",shortForm + " : " + fullForm))); } } else { @@ -134,7 +134,7 @@ for (i = 0; i < length; ++i) { shortForm = shortList.takeFirst(); fullForm = fullList.takeFirst(); - ui.pre_defined->setItem((int)i, 0, new QTableWidgetItem + ui.pre_defined->setItem(i, 0, new QTableWidgetItem (i18n("%1",shortForm + " : " + fullForm))); } } else { diff --git a/src/orbitswidget.cpp b/src/orbitswidget.cpp --- a/src/orbitswidget.cpp +++ b/src/orbitswidget.cpp @@ -239,8 +239,8 @@ DC.setPen(Qt::NoPen); for (int e = 0; e < *it; ++e) { - int x = (int)translateToDX(d / 2.0, (double)e, *it); - int y = (int)translateToDY(d / 2.0, (double)e, *it); + int x = static_cast (translateToDX(d / 2.0, static_cast (e), *it)); + int y = static_cast (translateToDY(d / 2.0, static_cast (e), *it)); //Creating a gradient for the current electron. QRadialGradient grad(QPointF(x + mx + d / 2 - r_electron / 2, y + my + d / 2 - r_electron / 2), r_electron); diff --git a/src/spectrumviewimpl.cpp b/src/spectrumviewimpl.cpp --- a/src/spectrumviewimpl.cpp +++ b/src/spectrumviewimpl.cpp @@ -72,8 +72,7 @@ QStringList row = QStringList() << QString::number(peakWavelength) << QString::number(peak->intensity); - - items.append(new QTreeWidgetItem((QTreeWidget*)0, row)); + items.append(new QTreeWidgetItem(static_cast (nullptr), row)); } peakListTable->insertTopLevelItems(0, items); } diff --git a/src/spectrumwidget.cpp b/src/spectrumwidget.cpp --- a/src/spectrumwidget.cpp +++ b/src/spectrumwidget.cpp @@ -152,7 +152,7 @@ wavelength = KUnitConversion::Value(wavelength,KUnitConversion::UnitId(Prefs::spectrumWavelengthUnit())) .convertTo(KUnitConversion::Nanometer).number(); - int wavelength_ = (int)floor(wavelength); + int wavelength_ = static_cast (floor(wavelength)); if (wavelength_ < 380 || wavelength_ > 780) { return QColor(Qt::white); @@ -203,7 +203,7 @@ return 0; } else { // return qRound(m_intensityMax * pow(color*factor, m_gamma)); FIXME - return m_intensityMax * color; + return static_cast (m_intensityMax * color); } } @@ -216,7 +216,7 @@ const int d = 10; //the total number of tickmarks to draw (small and long) - const int numberOfTickmarks = (int)floor((double)(width() / d)); + const int numberOfTickmarks = static_cast (floor(width() / d)); double pos = 0.0; @@ -227,7 +227,7 @@ if (i % 10 == 0 && i * d > space && i * d < width() - space) { - pos = (double)(i * d) / width(); + pos = static_cast (i * d) / width(); p->fillRect(i * d - space, m_realHeight + 12, 2 * space, 15, Qt::white); p->drawText(i * d - space, m_realHeight + 12, 2 * space, 15, Qt::AlignCenter, QString::number(KalziumUtils::strippedValue(Wavelength(pos)))); @@ -315,13 +315,13 @@ resetSpectrum(); } - findPeakFromMouseposition(Wavelength((double)e->pos().x() / width())); + findPeakFromMouseposition(Wavelength(static_cast (e->pos().x()) / width())); } void SpectrumWidget::findPeakFromMouseposition(double wavelength) { qDebug() << "SpectrumWidget::findPeakFromMouseposition()"; - Spectrum::peak *peak = NULL; + Spectrum::peak *peak = nullptr; //find the difference in percent (1.0 is 100%, 0.1 is 10%) double dif = 0.0; @@ -358,8 +358,8 @@ void SpectrumWidget::mouseReleaseEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { - int left = (int)Wavelength((double)m_LMBPointPress.x() / width()); - int right = (int)Wavelength((double)e->pos().x() / width()); + int left = static_cast (Wavelength(m_LMBPointPress.x()) / width()); + int right = static_cast (Wavelength(e->pos().x()) / width()); if (left == right) { return; diff --git a/src/tablesdialog.cpp b/src/tablesdialog.cpp --- a/src/tablesdialog.cpp +++ b/src/tablesdialog.cpp @@ -267,7 +267,7 @@ void MyTableWidget::contextMenuEvent(QContextMenuEvent* event) { - QMenu* menu = new QMenu((QWidget*) sender()); + QMenu* menu = new QMenu(static_cast (sender())); menu->addAction(i18n("&Copy"), this, SLOT(copyToClipboard()), QKeySequence(Qt::Key_C | Qt::CTRL)); menu->exec(event->globalPos()); } diff --git a/src/tools/moleculeview.cpp b/src/tools/moleculeview.cpp --- a/src/tools/moleculeview.cpp +++ b/src/tools/moleculeview.cpp @@ -171,7 +171,7 @@ m_molecule = *IoWrapper::readMolecule(filename); if (m_molecule.atomCount() != 0) { - disconnect(ui.glWidget->molecule(), 0, this, 0); + disconnect(ui.glWidget->molecule(), nullptr, this, nullptr); ui.glWidget->setMolecule(&m_molecule); ui.glWidget->update(); slotUpdateStatistics(); diff --git a/src/tools/obconverter.cpp b/src/tools/obconverter.cpp --- a/src/tools/obconverter.cpp +++ b/src/tools/obconverter.cpp @@ -61,7 +61,7 @@ KOpenBabel::~KOpenBabel() { delete OBConvObject; - OBConvObject = NULL; + OBConvObject = nullptr; } void KOpenBabel::setupWindow()
" - << ((ElementListEntry*)element)->m_element->dataAsString(ChemicalDataObject::name) + << element_entry->m_element->dataAsString(ChemicalDataObject::name) << "
" - << ((PropertyListEntry*) property)->text() + << property_entry->text() << "" - << KalziumUtils::prettyUnit( - ((ElementListEntry*) element)->m_element, - ((PropertyListEntry*) property)->m_type) + << KalziumUtils::prettyUnit(element_entry->m_element,property_entry->m_type) << "