diff --git a/CMakeLists.txt b/CMakeLists.txt index de0cf8416d094ffe81cf4ce26332d0de54655a03..604d1c22c0f45cd07f615454c54b320866b2dbc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,8 @@ include(CheckIncludeFiles) include(ECMSetupVersion) include(ECMQtDeclareLoggingCategory) include(GenerateExportHeader) +include(KDEClangFormat) +include(KDEGitCommitHooks) find_package(Gettext REQUIRED) find_package(PythonInterp REQUIRED) @@ -149,4 +151,9 @@ ecm_qt_install_logging_categories( DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) +file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) +kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) + +kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT) + feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/compoundviewer/iowrapper.cpp b/compoundviewer/iowrapper.cpp index b7c015113b52a6aeca3d92ebeb31c5bce64b8cb9..4c31992d4a2cbdeddac9688b0b7878bb4cd5bfc0 100644 --- a/compoundviewer/iowrapper.cpp +++ b/compoundviewer/iowrapper.cpp @@ -7,8 +7,8 @@ #include "iowrapper.h" -#include #include +#include #include #include @@ -27,22 +27,20 @@ std::unique_ptr IoWrapper::readMolecule(const QString { std::ifstream inFileStream(QFile::encodeName(filename).constData()); if (!inFileStream) { - QMessageBox::warning(nullptr, i18n("Problem while opening the file"), - i18n("Cannot open the specified file.")); + QMessageBox::warning(nullptr, i18n("Problem while opening the file"), i18n("Cannot open the specified file.")); return nullptr; } auto mol = std::make_unique(); auto format = getFileReader(QFileInfo(filename).suffix()); - if (!format){ + if (!format) { qCritical() << "Could not initialize file reader for file " << filename; return nullptr; } if (!format->read(inFileStream, *mol)) { - qCritical() << "Could not read file " << filename << "; Error message: " - << QString().fromStdString(format->error()); + qCritical() << "Could not read file " << filename << "; Error message: " << QString().fromStdString(format->error()); return nullptr; } diff --git a/compoundviewer/iowrapper.h b/compoundviewer/iowrapper.h index 51de5e1ba43393deb54d95d662d0345e0a7d5081..c34984fe248b8cbd488dd95a1a1387ab0019effb 100644 --- a/compoundviewer/iowrapper.h +++ b/compoundviewer/iowrapper.h @@ -27,7 +27,7 @@ public: */ static std::unique_ptr readMolecule(const QString &filename); - static bool writeMolecule(const QString& filename, Avogadro::Core::Molecule *); + static bool writeMolecule(const QString &filename, Avogadro::Core::Molecule *); static QString getFormula(Avogadro::QtGui::Molecule *molecule); diff --git a/compoundviewer/kalziumglpart.cpp b/compoundviewer/kalziumglpart.cpp index 2ed88198e8e3de0756e19f6830baf0cddb43f0c9..372590dd758a723cb8274af7397a1adac299db79 100644 --- a/compoundviewer/kalziumglpart.cpp +++ b/compoundviewer/kalziumglpart.cpp @@ -12,13 +12,15 @@ KAboutData kalziumGLPartAboutData() { - KAboutData aboutData( - "kalzium", QByteArray(), ki18n("Kalzium OpenGL Part"), "1.1.1", - ki18n("A cool thing"), - KAboutLicense::GPL, ki18n("(c) 2006, Carsten Niehaus"), - KLocalizedString(), - "https://edu.kde.org/kalzium/" - ); + KAboutData aboutData("kalzium", + QByteArray(), + ki18n("Kalzium OpenGL Part"), + "1.1.1", + ki18n("A cool thing"), + KAboutLicense::GPL, + ki18n("(c) 2006, Carsten Niehaus"), + KLocalizedString(), + "https://edu.kde.org/kalzium/"); aboutData.addAuthor(ki18n("Carsten Niehaus"), KLocalizedString(), "cniehaus@kde.org"); aboutData.addAuthor(ki18n("Marcus D. Hanwell"), KLocalizedString(), "marcus@cryos.org"); @@ -28,7 +30,7 @@ KAboutData kalziumGLPartAboutData() K_PLUGIN_FACTORY(KalziumGLPartFactory, registerPlugin();) K_EXPORT_PLUGIN(KalziumGLPartFactory(kalziumGLPartAboutData())) -KalziumGLPart::KalziumGLPart(QWidget* parentWidget, QObject* parent, const QVariantList& args) +KalziumGLPart::KalziumGLPart(QWidget *parentWidget, QObject *parent, const QVariantList &args) { Q_UNUSED(parent); Q_UNUSED(parentWidget); diff --git a/compoundviewer/kalziumglpart.h b/compoundviewer/kalziumglpart.h index 976d8743dd93ab16dc5fc941ff84fd690d63d4aa..589ef78bbbd6c3246bb3833d0559c21d61031e67 100644 --- a/compoundviewer/kalziumglpart.h +++ b/compoundviewer/kalziumglpart.h @@ -15,13 +15,13 @@ class KalziumGLPart : public KParts::ReadOnlyPart { Q_OBJECT public: - KalziumGLPart(QWidget*, QObject*, const QVariantList&); + KalziumGLPart(QWidget *, QObject *, const QVariantList &); virtual ~KalziumGLPart(); protected: bool openFile(); - KalziumGLWidget* m_widget; + KalziumGLWidget *m_widget; }; #endif // KALZIUMGLPART_H diff --git a/compoundviewer/kalziumglwidget.cpp b/compoundviewer/kalziumglwidget.cpp index fff2b48e992d897f2a22b2c6a307054c2f36ef26..5254538ab554ce691bb87fdd7bfac8dbc0d72dc9 100644 --- a/compoundviewer/kalziumglwidget.cpp +++ b/compoundviewer/kalziumglwidget.cpp @@ -45,8 +45,7 @@ KalziumGLWidget::KalziumGLWidget(QWidget *parent) manager->load(); // load render engines - QList scenePluginFactories = - manager->pluginFactories(); + QList scenePluginFactories = manager->pluginFactories(); foreach (auto *factory, scenePluginFactories) { auto *scenePlugin = factory->createInstance(); // enable Ball-and-Sticks @@ -61,8 +60,7 @@ KalziumGLWidget::KalziumGLWidget(QWidget *parent) qCritical() << "Updating non-empty toolset, erasing first."; qDeleteAll(tools()); } - auto toolPluginFactories = - manager->pluginFactories(); + auto toolPluginFactories = manager->pluginFactories(); foreach (auto *factory, toolPluginFactories) { auto *tool = factory->createInstance(); if (tool) { @@ -80,7 +78,7 @@ KalziumGLWidget::KalziumGLWidget(QWidget *parent) KalziumGLWidget::~KalziumGLWidget() { - //restore the LC_NUMERIC locale. + // restore the LC_NUMERIC locale. setlocale(LC_NUMERIC, m_lc_numeric.constData()); } @@ -94,7 +92,7 @@ bool KalziumGLWidget::openFile(const QString &file) if (!mol) { return false; } - Avogadro::QtGui::Molecule* oldmol = molecule(); + Avogadro::QtGui::Molecule *oldmol = molecule(); if (oldmol) { oldmol->deleteLater(); } diff --git a/compoundviewer/kalziumglwidget.h b/compoundviewer/kalziumglwidget.h index 82c23e6dfce03e8d311c892bc17ee0b774ec5107..522cce8a589c7ef35f40748ddfe07852be7e5568 100644 --- a/compoundviewer/kalziumglwidget.h +++ b/compoundviewer/kalziumglwidget.h @@ -11,7 +11,8 @@ #include "compoundviewer_export.h" -class COMPOUNDVIEWER_EXPORT KalziumGLWidget : public Avogadro::QtOpenGL::GLWidget { +class COMPOUNDVIEWER_EXPORT KalziumGLWidget : public Avogadro::QtOpenGL::GLWidget +{ Q_OBJECT public: explicit KalziumGLWidget(QWidget *parent = nullptr); diff --git a/libscience/chemicaldataobject.cpp b/libscience/chemicaldataobject.cpp index 3fd5d7cf18d8b9b9f630f62f52e1ab1f5d12e8f7..f5649be0d43611bc6c3a2e02d74b21709f838036 100644 --- a/libscience/chemicaldataobject.cpp +++ b/libscience/chemicaldataobject.cpp @@ -25,7 +25,7 @@ public: //######################## ChemicalDataObjectPrivate::ChemicalDataObjectPrivate() - : QSharedData() + : QSharedData() { } @@ -34,8 +34,8 @@ ChemicalDataObjectPrivate::~ChemicalDataObjectPrivate() } //############## -ChemicalDataObject::ChemicalDataObject(const QVariant& v, BlueObelisk type, const QVariant& errorValue) - : d(new ChemicalDataObjectPrivate) +ChemicalDataObject::ChemicalDataObject(const QVariant &v, BlueObelisk type, const QVariant &errorValue) + : d(new ChemicalDataObjectPrivate) { d->m_value = v; d->m_errorValue = errorValue; @@ -44,14 +44,14 @@ ChemicalDataObject::ChemicalDataObject(const QVariant& v, BlueObelisk type, cons } ChemicalDataObject::ChemicalDataObject() - : d(new ChemicalDataObjectPrivate) + : d(new ChemicalDataObjectPrivate) { d->m_errorValue = QVariant(); d->m_unit = KUnitConversion::NoUnit; } ChemicalDataObject::ChemicalDataObject(const ChemicalDataObject &other) - : d(other.d) + : d(other.d) { } @@ -59,7 +59,7 @@ ChemicalDataObject::~ChemicalDataObject() { } -ChemicalDataObject& ChemicalDataObject::operator=(const ChemicalDataObject &other) +ChemicalDataObject &ChemicalDataObject::operator=(const ChemicalDataObject &other) { d = other.d; return *this; @@ -92,7 +92,7 @@ bool ChemicalDataObject::operator==(const double v) const return d->m_value.toDouble() == v; } -bool ChemicalDataObject::operator==(const QString& v) const +bool ChemicalDataObject::operator==(const QString &v) const { if (d->m_value.type() != QVariant::String) { return false; @@ -141,12 +141,12 @@ int ChemicalDataObject::unit() const return d->m_unit; } -void ChemicalDataObject::setData(const QVariant& v) +void ChemicalDataObject::setData(const QVariant &v) { d->m_value = v; } -void ChemicalDataObject::setErrorValue(const QVariant& v) +void ChemicalDataObject::setErrorValue(const QVariant &v) { d->m_errorValue = v; } @@ -158,7 +158,7 @@ void ChemicalDataObject::setType(BlueObelisk type) void ChemicalDataObject::setType(int type) { - d->m_type = (ChemicalDataObject::BlueObelisk) type; + d->m_type = (ChemicalDataObject::BlueObelisk)type; } QString ChemicalDataObject::unitAsString() const diff --git a/libscience/chemicaldataobject.h b/libscience/chemicaldataobject.h index ca21732f7b45f0dfcce26ee8d5bccf73c5f09d82..54a792d68c9e9dedbdd24ab871b1d708937cf58a 100644 --- a/libscience/chemicaldataobject.h +++ b/libscience/chemicaldataobject.h @@ -33,74 +33,76 @@ public: */ enum BlueObelisk { atomicNumber = 0 /**< The atomic number of the element */, - symbol/**< the symbol of the element */, - name/**< The IUPAC name of the element */, - mass/**< # IUPAC Official Masses */, - exactMass/**< exact masses of the most common isotopes for each element */, - ionization/**< First inizationenergy */, - electronAffinity/**< the electron affinity of the element */, - electronegativityPauling/**< the electronegativity in the definition of Pauling*/, - radiusCovalent/**< the covalent radius */, - radiusVDW/**< the van der Waals radius */, - meltingpoint/**< the meltingpoint */, - boilingpoint/**< the boilingpoint */, - periodTableBlock/**< the block of the element */, - family/**< "Noblegas" "Non-Metal" "Rare_Earth" "Alkaline_Earth" "Alkali_Earth" "Transition" "Other_Metal" "Metalloids" "Halogene" */, - acidicbehaviour/**< 0 means acidic, 1 means basic, 2 means neutral, 3 means amphoteric*/, - crystalstructure/**< own, bcc, hdp, ccp, hcp, fcc, d, sc, tet, rh, or, mono*/, - electronicConfiguration/**< the electronic configuration, for example 1s2 for He*/, - group/**< This is a value between 1 and 8*/, - nameOrigin/**< the origin of the name */, - orbit/**< the quantumorbit of the element */, - period/**< the period of the element */, - date/**< date of discovery of the element. When 0, the element has been known in ancient times. When the value is -1 the element has not yet been officially recognized by the IUPAC */, - discoverers/** The name of the discoverers, separated by semicolomns */, - relativeAbundance/** The abundance, relative to 100 */, - spin/**< The spin */, - magneticMoment/**< The magnetic dipole moment */, - halfLife/**< The halflife */, - alphaDecayLikeliness/**< The percentage of alphadecay */, - alphaDecay/**< The decayenergy of alphadecay in MeV */, - alphabetaminusDecayLikeliness/**< The percentage of alphadecay */, - alphabetaminusDecay/**< The decayenergy of alphadecay in MeV */, - betaplusDecayLikeliness/**< The percentage of betaplusdecay */, - betaplusDecay/**< The decayenergy of betaplusdecay in MeV */, + symbol /**< the symbol of the element */, + name /**< The IUPAC name of the element */, + mass /**< # IUPAC Official Masses */, + exactMass /**< exact masses of the most common isotopes for each element */, + ionization /**< First inizationenergy */, + electronAffinity /**< the electron affinity of the element */, + electronegativityPauling /**< the electronegativity in the definition of Pauling*/, + radiusCovalent /**< the covalent radius */, + radiusVDW /**< the van der Waals radius */, + meltingpoint /**< the meltingpoint */, + boilingpoint /**< the boilingpoint */, + periodTableBlock /**< the block of the element */, + family /**< "Noblegas" "Non-Metal" "Rare_Earth" "Alkaline_Earth" "Alkali_Earth" "Transition" "Other_Metal" "Metalloids" "Halogene" */, + acidicbehaviour /**< 0 means acidic, 1 means basic, 2 means neutral, 3 means amphoteric*/, + crystalstructure /**< own, bcc, hdp, ccp, hcp, fcc, d, sc, tet, rh, or, mono*/, + electronicConfiguration /**< the electronic configuration, for example 1s2 for He*/, + group /**< This is a value between 1 and 8*/, + nameOrigin /**< the origin of the name */, + orbit /**< the quantumorbit of the element */, + period /**< the period of the element */, + date /**< date of discovery of the element. When 0, the element has been known in ancient times. When the value is -1 the element has not yet been + officially recognized by the IUPAC */ + , + discoverers /** The name of the discoverers, separated by semicolomns */, + relativeAbundance /** The abundance, relative to 100 */, + spin /**< The spin */, + magneticMoment /**< The magnetic dipole moment */, + halfLife /**< The halflife */, + alphaDecayLikeliness /**< The percentage of alphadecay */, + alphaDecay /**< The decayenergy of alphadecay in MeV */, + alphabetaminusDecayLikeliness /**< The percentage of alphadecay */, + alphabetaminusDecay /**< The decayenergy of alphadecay in MeV */, + betaplusDecayLikeliness /**< The percentage of betaplusdecay */, + betaplusDecay /**< The decayenergy of betaplusdecay in MeV */, twobetaplusDecayLikeliness, twobetaplusDecay, - betaplusprotonDecayLikeliness/**< The percentage of betaplusdecay */, - betaplusprotonDecay/**< The decayenergy of betaplusdecay in MeV */, + betaplusprotonDecayLikeliness /**< The percentage of betaplusdecay */, + betaplusprotonDecay /**< The decayenergy of betaplusdecay in MeV */, betaplustwoprotonDecayLikeliness, betaplustwoprotonDecay, - betaplusalphaDecayLikeliness/**< The percentage of betaplusdecay */, - betaplusalphaDecay/**< The decayenergy of betaplusdecay in MeV */, + betaplusalphaDecayLikeliness /**< The percentage of betaplusdecay */, + betaplusalphaDecay /**< The decayenergy of betaplusdecay in MeV */, betaplustwoalphaDecayLikeliness, betaplustwoalphaDecay, betaplusthreealphaDecayLikeliness, betaplusthreealphaDecay, - betaminusDecayLikeliness/**< The percentage of betaminusdecay */, - betaminusDecay/**< The decayenergy of betaminusdecay in MeV */, + betaminusDecayLikeliness /**< The percentage of betaminusdecay */, + betaminusDecay /**< The decayenergy of betaminusdecay in MeV */, twobetaminusDecayLikeliness, twobetaminusDecay, - betaminusneutronDecayLikeliness/**< The percentage of betaminusdecay */, - betaminusneutronDecay/**< The decayenergy of betaminusdecay in MeV */, + betaminusneutronDecayLikeliness /**< The percentage of betaminusdecay */, + betaminusneutronDecay /**< The decayenergy of betaminusdecay in MeV */, betaminustwoneutronDecayLikeliness, betaminustwoneutronDecay, betaminusthreeneutronDecayLikeliness, betaminusthreeneutronDecay, betaminusfourneutronDecayLikeliness, betaminusfourneutronDecay, - betaminusfissionDecayLikeliness/**< The percentage of betaminusdecay */, - betaminusfissionDecay/**< The decayenergy of betaminusdecay in MeV */, - betaminusalphaDecayLikeliness/**< The percentage of betaminusdecay */, - betaminusalphaDecay/**< The decayenergy of betaminusdecay in MeV */, + betaminusfissionDecayLikeliness /**< The percentage of betaminusdecay */, + betaminusfissionDecay /**< The decayenergy of betaminusdecay in MeV */, + betaminusalphaDecayLikeliness /**< The percentage of betaminusdecay */, + betaminusalphaDecay /**< The decayenergy of betaminusdecay in MeV */, betaminustwoalphaDecayLikeliness, betaminustwoalphaDecay, betaminusthreealphaDecayLikeliness, betaminusthreealphaDecay, betaminusalphaneutronDecay, betaminusalphaneutronDecayLikeliness, - ecDecayLikeliness/**< The percentage of ecdecay */, - ecDecay/**< The decayenergy of ecminusdecay in MeV */, + ecDecayLikeliness /**< The percentage of ecdecay */, + ecDecay /**< The decayenergy of ecminusdecay in MeV */, twoecDecayLikeliness, twoecDecay, ecalphaDecayLikeliness, @@ -113,23 +115,23 @@ public: ectwoprotonDecay, ecthreeprotonDecayLikeliness, ecthreeprotonDecay, - protonDecayLikeliness/**< The percentage of protondecay */, - protonDecay/**< The decayenergy of protonminusdecay in MeV */, + protonDecayLikeliness /**< The percentage of protondecay */, + protonDecay /**< The decayenergy of protonminusdecay in MeV */, twoprotonDecayLikeliness, twoprotonDecay, - protonalphaDecayLikeliness/**< The percentage of protondecay */, - protonalphaDecay/**< The decayenergy of protonminusdecay in MeV */, - neutronDecayLikeliness/**< The percentage of neutrondecay */, - neutronDecay/**< The decayenergy of neutronminusdecay in MeV */, + protonalphaDecayLikeliness /**< The percentage of protondecay */, + protonalphaDecay /**< The decayenergy of protonminusdecay in MeV */, + neutronDecayLikeliness /**< The percentage of neutrondecay */, + neutronDecay /**< The decayenergy of neutronminusdecay in MeV */, twoneutronDecayLikeliness, twoneutronDecay, spontfissionDecayLikeliness, spontfissionDecay, - dangerSymbol/**< the danger symbols are the dangers associated with an element, for example Xn,T+ */, - RPhrase/**< */, - SPhrase/**< */, + dangerSymbol /**< the danger symbols are the dangers associated with an element, for example Xn,T+ */, + RPhrase /**< */, + SPhrase /**< */, discoveryCountry, - oxidation/**< Oxidation states*/ + oxidation /**< Oxidation states*/ }; /** @@ -145,9 +147,7 @@ public: * * @see errorValue() */ - ChemicalDataObject(const QVariant& v, - BlueObelisk type, - const QVariant& errorValue = QVariant(0)); + ChemicalDataObject(const QVariant &v, BlueObelisk type, const QVariant &errorValue = QVariant(0)); /** * Copy constructor. @@ -163,14 +163,14 @@ public: * Set the data of this object to @p v * @param v the value of the object */ - void setData(const QVariant& v); + void setData(const QVariant &v); /** * Set the error value of this object to @p v. * The error has to have the same unit as the value. * @param v the value of the object */ - void setErrorValue(const QVariant& v); + void setErrorValue(const QVariant &v); /** * Every ChemicalDataObject contains one data. For example a @@ -217,22 +217,22 @@ public: /** * Compare the value @p v with the data of this object */ - bool operator== (const int v) const; + bool operator==(const int v) const; /** * Compare the value @p v with the data of this object */ - bool operator== (const double v) const; + bool operator==(const double v) const; /** * Compare the value @p v with the data of this object */ - bool operator== (const bool v) const; + bool operator==(const bool v) const; /** * Compare the value @p v with the data of this object */ - bool operator== (const QString& v) const; + bool operator==(const QString &v) const; /** * @return the unit of the object as a QString. For example kelvin @@ -251,7 +251,7 @@ public: */ void setUnit(int unit); - ChemicalDataObject& operator=(const ChemicalDataObject &other); + ChemicalDataObject &operator=(const ChemicalDataObject &other); bool operator==(const ChemicalDataObject &other) const; diff --git a/libscience/element.cpp b/libscience/element.cpp index 25c2b354d981c82f6ce80441973f9a0401e78a73..dc2a90823d0a3c61b452569eee78a982808e6e2d 100644 --- a/libscience/element.cpp +++ b/libscience/element.cpp @@ -65,12 +65,12 @@ Element::~Element() { } -void Element::addData(const ChemicalDataObject& o) +void Element::addData(const ChemicalDataObject &o) { dataList.append(o); } -void Element::addData(const QVariant& value, ChemicalDataObject::BlueObelisk type) +void Element::addData(const QVariant &value, ChemicalDataObject::BlueObelisk type) { ChemicalDataObject tmp(value, type); dataList.append(tmp); diff --git a/libscience/element.h b/libscience/element.h index 09ee43b6f3d5e510544b11461485870447c6ad81..2d3d40656c9bce51b6fbc912b9c01cf96d3dbcd4 100644 --- a/libscience/element.h +++ b/libscience/element.h @@ -14,14 +14,13 @@ #include "chemicaldataobject.h" - /** * In this class all information about an element are stored. This means that * both the chemical date and the data about the position are stored * in this class. * @short This class is the representation of a chemical element * @author Carsten Niehaus -*/ + */ class SCIENCE_EXPORT Element { public: @@ -33,7 +32,7 @@ public: * Add the ChemicalDataObject @p o to this Element * @param o the ChemicalDataObject to be added */ - void addData(const ChemicalDataObject& o); + void addData(const ChemicalDataObject &o); /** * Add a ChemicalDataObject with @p value of @p type to this @@ -41,7 +40,7 @@ public: * @param value the QVariant to be added * @param type the BlueObelisk type to be added */ - void addData(const QVariant& value, ChemicalDataObject::BlueObelisk type); + void addData(const QVariant &value, ChemicalDataObject::BlueObelisk type); /** * @return the requested data of the type @p type as a QVariant @@ -71,7 +70,7 @@ public: /** * @return the data of the Element */ - QList data()const + QList data() const { return dataList; } diff --git a/libscience/elementparser.cpp b/libscience/elementparser.cpp index 0f768b18759529fb65e5482d70b63c2b8d76d5d5..e2a863bed8c4bd2e36e50cf7de97679a17a09dc8 100644 --- a/libscience/elementparser.cpp +++ b/libscience/elementparser.cpp @@ -17,49 +17,50 @@ class ElementSaxParser::Private { public: Private() - : currentUnit(KUnitConversion::NoUnit), - currentElement(nullptr), - inElement(false), - inName(false), - inMass(false), - inExactMass(false), - inAtomicNumber(false), - inSymbol(false), - inIonization(false), - inElectronAffinity(false), - inElectronegativityPauling(false), - inRadiusCovalent(false), - inRadiusVDW(false), - inBoilingPoint(false), - inMeltingPoint(false), - inPeriodTableBlock(false), - inNameOrigin(false), - inDiscoveryDate(false), - inDiscoverers(false), - inPeriod(false), - inCrystalstructure(false), - inAcidicbehaviour(false), - inFamily(false), - inGroup(false), - inElectronicconfiguration(false), - inDangerSymbol(false), - inRPhrase(false), - inSPhrase(false), - inCountry(false), - inOxidation(false) - {} + : currentUnit(KUnitConversion::NoUnit) + , currentElement(nullptr) + , inElement(false) + , inName(false) + , inMass(false) + , inExactMass(false) + , inAtomicNumber(false) + , inSymbol(false) + , inIonization(false) + , inElectronAffinity(false) + , inElectronegativityPauling(false) + , inRadiusCovalent(false) + , inRadiusVDW(false) + , inBoilingPoint(false) + , inMeltingPoint(false) + , inPeriodTableBlock(false) + , inNameOrigin(false) + , inDiscoveryDate(false) + , inDiscoverers(false) + , inPeriod(false) + , inCrystalstructure(false) + , inAcidicbehaviour(false) + , inFamily(false) + , inGroup(false) + , inElectronicconfiguration(false) + , inDangerSymbol(false) + , inRPhrase(false) + , inSPhrase(false) + , inCountry(false) + , inOxidation(false) + { + } ~Private() { delete currentElement; - //qDeleteAll(elements); + // qDeleteAll(elements); } ChemicalDataObject currentDataObject; int currentUnit; // KUnitConversion::UnitId Element *currentElement = nullptr; - QList elements; + QList elements; bool inElement; bool inName; @@ -92,7 +93,8 @@ public: }; ElementSaxParser::ElementSaxParser() - : QXmlDefaultHandler(), d(new Private) + : QXmlDefaultHandler() + , d(new Private) { } @@ -101,7 +103,7 @@ ElementSaxParser::~ElementSaxParser() delete d; } -bool ElementSaxParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs) +bool ElementSaxParser::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs) { if (localName == QLatin1String("atom")) { d->currentElement = new Element(); @@ -109,9 +111,9 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co } else if ((d->inElement && localName == QLatin1String("scalar")) || localName == QLatin1String("array")) { for (int i = 0; i < attrs.length(); ++i) { if (attrs.localName(i) == QLatin1String("units")) { -// qCDebug(KALZIUM_LIBSCIENCE_LOG) << "value of the unit: " << attrs.value(i); + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "value of the unit: " << attrs.value(i); d->currentUnit = unit(attrs.value(i)); -// qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Took " << d->currentUnit; + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Took " << d->currentUnit; continue; } @@ -237,7 +239,8 @@ bool ElementSaxParser::characters(const QString &ch) type = ChemicalDataObject::atomicNumber; d->inAtomicNumber = false; } else if (d->inIonization) { - value = ch.toDouble();; + value = ch.toDouble(); + ; type = ChemicalDataObject::ionization; d->inIonization = false; } else if (d->inElectronAffinity) { @@ -329,7 +332,7 @@ bool ElementSaxParser::characters(const QString &ch) value = ch; type = ChemicalDataObject::oxidation; d->inOxidation = false; - } else { //it is a non known value. Do not create a wrong object but return + } else { // it is a non known value. Do not create a wrong object but return return true; } @@ -344,7 +347,7 @@ bool ElementSaxParser::characters(const QString &ch) return true; } -int ElementSaxParser::unit(const QString& unit) const +int ElementSaxParser::unit(const QString &unit) const { if (unit == QLatin1String("siUnits:kelvin")) { return KUnitConversion::Kelvin; @@ -359,7 +362,7 @@ int ElementSaxParser::unit(const QString& unit) const } } -QList ElementSaxParser::getElements() +QList ElementSaxParser::getElements() { return d->elements; } diff --git a/libscience/elementparser.h b/libscience/elementparser.h index 5888541dc8c6223eb48dc5ff1cff9d09a51672af..aaed2d63da0cedce92cca498d8a43dc9d4ca40d6 100644 --- a/libscience/elementparser.h +++ b/libscience/elementparser.h @@ -25,33 +25,32 @@ public: */ ElementSaxParser(); ~ElementSaxParser(); - bool startElement(const QString&, const QString &localName, const QString&, - const QXmlAttributes &attrs) override; + bool startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs) override; - bool endElement(const QString& namespaceURI, const QString &localName, const QString& qName) override; + bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) override; bool characters(const QString &ch) override; - QList getElements(); + QList getElements(); private: /** - * Looks up a name @p unitname. The valid names are - * hard-coded in the C++ code, currently - * - bo:kelvin - * - bo:ev - * - bo:nm - * - bo:pm - * - bo:y - * - bo:s - * - bo:noUnit - * - * @return the BlueObeliskUnit of a ChemicalDataObject - * corresponding to @p unitname, or noUnit if the name - * doesn't match any of the known values. - * @param unitname the attribute-text of the XML parsed - */ - int unit(const QString& unitname) const; + * Looks up a name @p unitname. The valid names are + * hard-coded in the C++ code, currently + * - bo:kelvin + * - bo:ev + * - bo:nm + * - bo:pm + * - bo:y + * - bo:s + * - bo:noUnit + * + * @return the BlueObeliskUnit of a ChemicalDataObject + * corresponding to @p unitname, or noUnit if the name + * doesn't match any of the known values. + * @param unitname the attribute-text of the XML parsed + */ + int unit(const QString &unitname) const; class Private; Private *const d; diff --git a/libscience/isotope.cpp b/libscience/isotope.cpp index 36d6ae6e0e8a43146268d9600609e3f975f2a842..17e8941cdf173cc34b6feaa103eedd000c3b1109 100644 --- a/libscience/isotope.cpp +++ b/libscience/isotope.cpp @@ -166,14 +166,12 @@ void Isotope::addData(const ChemicalDataObject &o) m_spontfissiondecay = o; } else if (o.type() == ChemicalDataObject::spontfissionDecayLikeliness) { m_spontfissionlikeliness = o; - - } } double Isotope::mass() const { - return m_mass.value().toDouble(); + return m_mass.value().toDouble(); } QString Isotope::errorMargin() const @@ -183,7 +181,7 @@ QString Isotope::errorMargin() const int Isotope::parentElementNumber() const { - return m_identifier.value().toInt(); + return m_identifier.value().toInt(); } QString Isotope::spin() const @@ -478,7 +476,6 @@ double Isotope::spontfissionlikeliness() const return m_spontfissionlikeliness.value().toDouble(); } - QString Isotope::parentElementSymbol() const { return m_parentElementSymbol.value().toString(); @@ -522,15 +519,12 @@ Isotope::Nucleons Isotope::nucleonsAfterDecay(Decay kind) n.neutrons += 1; break; case NEUTRON: - n.neutrons -=1; - break; + n.neutrons -= 1; + break; case PROTON: - n.protons -=1; - break; - - + n.protons -= 1; + break; } - return n; } diff --git a/libscience/isotope.h b/libscience/isotope.h index 89dba391f6e3eb50bc1eeb5a4aa83c3646270972..15f2eca632ee54ffd708e277021d363d649be870 100644 --- a/libscience/isotope.h +++ b/libscience/isotope.h @@ -123,7 +123,6 @@ public: */ double twoeclikeliness() const; - /** * @return decay */ @@ -276,7 +275,7 @@ public: /** * @return decay likeliness */ - double betaminusfourneutronlikeliness() const; + double betaminusfourneutronlikeliness() const; /** * @return decay */ @@ -295,7 +294,7 @@ public: */ double betaminusalphalikeliness() const; - /** + /** * @return decay */ double betaminusalphaneutrondecay() const; @@ -304,7 +303,6 @@ public: */ double betaminusalphaneutronlikeliness() const; - /** * @return decay */ @@ -323,8 +321,6 @@ public: */ double betaminusthreealphalikeliness() const; - - /** * @return decay */ @@ -365,8 +361,6 @@ public: */ double betaplustwoprotonlikeliness() const; - - /** * @return decay */ @@ -377,7 +371,7 @@ public: */ double betaplusalphalikeliness() const; - /** + /** * @return decay */ double betaplustwoalphadecay() const; @@ -387,7 +381,7 @@ public: */ double betaplustwoalphalikeliness() const; - /** + /** * @return decay */ double betaplusthreealphadecay() const; @@ -402,19 +396,16 @@ public: */ double alphadecay() const; - /** * @return decay */ double alphalikeliness() const; - /** * @return decay */ double alphabetaminusdecay() const; - /** * @return decay */ @@ -425,7 +416,6 @@ public: */ double spontfissiondecay() const; - /** * @return decay */ @@ -435,13 +425,13 @@ public: * This enum stores the different kinds of decay */ enum Decay { - ALPHA/** isotopes; + QList isotopes; bool inIsotope; bool inElement; @@ -188,7 +188,8 @@ public: }; IsotopeParser::IsotopeParser() - : QXmlDefaultHandler(), d(new Private) + : QXmlDefaultHandler() + , d(new Private) { } @@ -197,12 +198,12 @@ IsotopeParser::~IsotopeParser() delete d; } -bool IsotopeParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs) +bool IsotopeParser::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs) { if (localName == QLatin1String("isotopeList")) { d->inElement = true; - //now save the symbol of the current element + // now save the symbol of the current element for (int i = 0; i < attrs.length(); ++i) { if (attrs.localName(i) == QLatin1String("id")) { d->currentElementSymbol = attrs.value(i); @@ -387,14 +388,14 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const return true; } -bool IsotopeParser::endElement(const QString&, const QString& localName, const QString&) +bool IsotopeParser::endElement(const QString &, const QString &localName, const QString &) { if (localName == QLatin1String("isotope")) { d->isotopes.append(d->currentIsotope); d->currentIsotope = nullptr; d->inIsotope = false; - } else if (localName == QLatin1String("isotopeList")) { //a new list of isotopes start... + } else if (localName == QLatin1String("isotopeList")) { // a new list of isotopes start... d->inElement = false; } @@ -694,7 +695,7 @@ bool IsotopeParser::characters(const QString &ch) value = ch; type = ChemicalDataObject::relativeAbundance; d->inAbundance = false; - } else { //it is a non known value. Do not create a wrong object but return + } else { // it is a non known value. Do not create a wrong object but return return true; } @@ -712,7 +713,7 @@ bool IsotopeParser::characters(const QString &ch) return true; } -QList IsotopeParser::getIsotopes() +QList IsotopeParser::getIsotopes() { return d->isotopes; } diff --git a/libscience/isotopeparser.h b/libscience/isotopeparser.h index 33f6559a5cdf5423ada0abd3f54253ed68890f36..c3ee1a5faac5122f5192b0804087ac32af7be015 100644 --- a/libscience/isotopeparser.h +++ b/libscience/isotopeparser.h @@ -25,18 +25,16 @@ public: */ IsotopeParser(); ~IsotopeParser() override; - bool startElement(const QString &, const QString &localName, const QString &, - const QXmlAttributes &attrs) override; + bool startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs) override; bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) override; bool characters(const QString &ch) override; - QList getIsotopes(); + QList getIsotopes(); private: class Private; Private *const d; }; #endif // ISOTOPEPARSER_H - diff --git a/libscience/moleculeparser.cpp b/libscience/moleculeparser.cpp index d7f9cee6c859b0914c79d762fdd509a0ca1b1ffc..a6eb9d24d5e0bd9595b5bf355dd723f6aa188f44 100644 --- a/libscience/moleculeparser.cpp +++ b/libscience/moleculeparser.cpp @@ -41,12 +41,12 @@ void ElementCountMap::add(ElementCountMap &_map) } } -QList ElementCountMap::elements() +QList ElementCountMap::elements() { - QList list; + QList list; - for (ElementCount* c : std::as_const(m_map)) { - Element* e = c->m_element; + for (ElementCount *c : std::as_const(m_map)) { + Element *e = c->m_element; if (!list.contains(e)) { list << e; } @@ -69,21 +69,23 @@ void ElementCountMap::add(Element *_element, int _count) void ElementCountMap::multiply(int _factor) { - foreach (ElementCount * count, m_map) { - count->multiply(_factor); - } + foreach (ElementCount *count, m_map) { + count->multiply(_factor); + } } // ================================================================ // class MoleculeParser -MoleculeParser::MoleculeParser( const QList &list) : Parser() +MoleculeParser::MoleculeParser(const QList &list) + : Parser() { m_elementList = list; m_aliasList = new QSet; } -MoleculeParser::MoleculeParser(const QString &_str) : Parser(_str) +MoleculeParser::MoleculeParser(const QString &_str) + : Parser(_str) { m_aliasList = new QSet; } @@ -100,16 +102,14 @@ MoleculeParser::~MoleculeParser() // // This method also acts as the main loop. -bool MoleculeParser::weight(const QString &_shortMoleculeString, - double *_resultMass, - ElementCountMap *_resultMap) +bool MoleculeParser::weight(const QString &_shortMoleculeString, double *_resultMass, ElementCountMap *_resultMap) { if (_shortMoleculeString.isEmpty()) { return false; } // Clear the list of aliases and start filling it again. - m_aliasList -> clear(); + m_aliasList->clear(); QString _moleculeString; // Clear the result variables and set m_error to false _resultMap->clear(); @@ -131,7 +131,7 @@ bool MoleculeParser::weight(const QString &_shortMoleculeString, return false; } - if (m_error) {//there was an error in the input... + if (m_error) { // there was an error in the input... return false; } @@ -145,20 +145,18 @@ QSet MoleculeParser::aliasList() // ---------------------------------------------------------------- // helper methods for the public methods - // Parse a submolecule. This is a list of terms. // -bool MoleculeParser::parseSubmolecule(double *_resultMass, - ElementCountMap *_resultMap) +bool MoleculeParser::parseSubmolecule(double *_resultMass, ElementCountMap *_resultMap) { - double subMass = 0.0; + double subMass = 0.0; ElementCountMap subMap; *_resultMass = 0.0; _resultMap->clear(); while (parseTerm(&subMass, &subMap)) { - //qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed a term, weight = " << subresult; + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed a term, weight = " << subresult; // Add the mass and composition of the submolecule to the total. *_resultMass += subMass; @@ -168,26 +166,24 @@ bool MoleculeParser::parseSubmolecule(double *_resultMass, return true; } - // Parse a term within the molecule, i.e. a single atom or a // submolecule within parenthesis followed by an optional number. // Examples: Bk, Mn2, (COOH)2 // -// Return true if correct, otherwise return false. +// Return true if correct, otherwise return false. // If correct, the mass of the term is returned in *_resultMass, and // the flattened composition of the molecule in *_resultMap. // -bool MoleculeParser::parseTerm(double *_resultMass, - ElementCountMap *_resultMap) +bool MoleculeParser::parseTerm(double *_resultMass, ElementCountMap *_resultMap) { *_resultMass = 0.0; _resultMap->clear(); if (nextToken() == ELEMENT_TOKEN) { - //qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed an element: " << m_elementVal->symbol(); - *_resultMass = m_elementVal->dataAsVariant( ChemicalDataObject::mass ).toDouble(); + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed an element: " << m_elementVal->symbol(); + *_resultMass = m_elementVal->dataAsVariant(ChemicalDataObject::mass).toDouble(); _resultMap->add(m_elementVal, 1); getNextToken(); @@ -199,7 +195,7 @@ bool MoleculeParser::parseTerm(double *_resultMass, // Must end in a ")". if (nextToken() == ')') { - //qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed a submolecule. weight = " << *_result; + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed a submolecule. weight = " << *_result; getNextToken(); } else { return false; @@ -211,7 +207,7 @@ bool MoleculeParser::parseTerm(double *_resultMass, // Optional number. if (nextToken() == INT_TOKEN) { - //qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed a number: " << intVal(); + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parsed a number: " << intVal(); *_resultMass *= intVal(); _resultMap->multiply(intVal()); @@ -243,8 +239,8 @@ int MoleculeParser::getNextToken() getNextChar(); if ('a' <= nextChar() && nextChar() <= 'z') { - name.append(char(nextChar())); - getNextChar(); + name.append(char(nextChar())); + getNextChar(); } // Look up the element from the name.. @@ -264,18 +260,18 @@ int MoleculeParser::getNextToken() // ---------------------------------------------------------------- // private methods -Element *MoleculeParser::lookupElement(const QString& _name) +Element *MoleculeParser::lookupElement(const QString &_name) { qCDebug(KALZIUM_LIBSCIENCE_LOG) << "looking up " << _name; - foreach (Element* e, m_elementList) { + foreach (Element *e, m_elementList) { if (e->dataAsVariant(ChemicalDataObject::symbol) == _name) { qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Found element " << _name; return e; } } - //if there is an error make m_error true. + // if there is an error make m_error true. m_error = true; qCDebug(KALZIUM_LIBSCIENCE_LOG) << "no such element!: " << _name; @@ -283,15 +279,15 @@ Element *MoleculeParser::lookupElement(const QString& _name) return nullptr; } -QString MoleculeParser::expandFormula( const QString& _shortString) +QString MoleculeParser::expandFormula(const QString &_shortString) { - QString _fullString; // the expanded string that will be returned + QString _fullString; // the expanded string that will be returned QString::const_iterator i; // iterator - QString temp; // a temporary string that will contain a single element/group - QString expandedTerm; // expansion of a particular term + QString temp; // a temporary string that will contain a single element/group + QString expandedTerm; // expansion of a particular term // Go through all letters in the string. - for (i = _shortString.constBegin(); i != _shortString.constEnd(); ) { + for (i = _shortString.constBegin(); i != _shortString.constEnd();) { temp = QLatin1String(""); // If a capital letter was found @@ -311,7 +307,7 @@ QString MoleculeParser::expandFormula( const QString& _shortString) } else if (!((expandedTerm = expandTerm(temp)).isEmpty())) { // If an expansion was made, return the expansion qCDebug(KALZIUM_LIBSCIENCE_LOG) << "expanded" << temp << "to" << expandedTerm; - _fullString += '('+expandedTerm+')'; + _fullString += '(' + expandedTerm + ')'; } else { // invalid term, append it. (Validation is done later anyway.) _fullString += temp; } @@ -322,9 +318,9 @@ QString MoleculeParser::expandFormula( const QString& _shortString) _fullString += ')'; ++i; } else if (*i == '#') { // If # is found, we have a short-form eg #EDTA# - ++i; // go to the next character + ++i; // go to the next character // Get the term between # and # - while (*i != '#' && i != _shortString.constEnd() ) { + while (*i != '#' && i != _shortString.constEnd()) { temp += *i; ++i; } @@ -356,11 +352,10 @@ QString MoleculeParser::expandFormula( const QString& _shortString) return _fullString; } -QString MoleculeParser::expandTerm (const QString& _group) +QString MoleculeParser::expandTerm(const QString &_group) { - - QString shortForm, fullForm; // short form (symbol) and full form (expansion) - QString temp; // A temporary QString used in Regular expressions + QString shortForm, fullForm; // short form (symbol) and full form (expansion) + QString temp; // A temporary QString used in Regular expressions // Search in User defined aliases. QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libkdeedu/data/symbols2.csv")); @@ -376,7 +371,7 @@ QString MoleculeParser::expandTerm (const QString& _group) QString line = in.readLine(); shortForm = line.section(',', 0, 0); shortForm.remove(QChar('\"')); - fullForm = line.section(',', 1, 1); + fullForm = line.section(',', 1, 1); fullForm.remove(QChar('\"')); // If short term is found, return fullForm @@ -389,7 +384,7 @@ QString MoleculeParser::expandTerm (const QString& _group) qCDebug(KALZIUM_LIBSCIENCE_LOG) << fileName << " could not be opened!"; } - // Find the system defined aliases + // Find the system defined aliases // Open the file fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libkdeedu/data/symbols.csv")); QFile file2(fileName); @@ -404,7 +399,7 @@ QString MoleculeParser::expandTerm (const QString& _group) QString line = in.readLine(); shortForm = line.section(',', 0, 0); shortForm.remove(QChar('\"')); - fullForm = line.section(',', 1, 1); + fullForm = line.section(',', 1, 1); fullForm.remove(QChar('\"')); if (shortForm == _group) { diff --git a/libscience/moleculeparser.h b/libscience/moleculeparser.h index 2e295aa5557bf1c4e547fca5719128ff2b64be4d..22014c2a2313ed5a4292791a2b59a82b9a536028 100644 --- a/libscience/moleculeparser.h +++ b/libscience/moleculeparser.h @@ -27,7 +27,7 @@ public: ElementCount(Element *_element, int _count) { m_element = _element; - m_count = _count; + m_count = _count; } /** @@ -36,7 +36,7 @@ public: explicit ElementCount(Element *_element) { m_element = _element; - m_count = 0; + m_count = 0; } /** * Destructor @@ -54,7 +54,7 @@ public: /** * @return the number of occurrences of the Element */ - int count() const + int count() const { return m_count; } @@ -82,7 +82,6 @@ public: int m_count; }; - /** * This class is used to count the elements in the molecule * which is being calculated @@ -106,7 +105,7 @@ public: /** * Clear the map of ElementCount pointers */ - void clear() + void clear() { m_map.clear(); } @@ -127,7 +126,7 @@ public: * is CO2, a list with C and O will be returned. * @return the elements in the molecule */ - QList elements(); + QList elements(); /** * @param _element @@ -140,17 +139,15 @@ public: */ void multiply(int _factor); - QList map() + QList map() { return m_map; } private: - QList m_map; + QList m_map; }; - - /** * @class MoleculeParser * @@ -186,14 +183,13 @@ private: */ class SCIENCE_EXPORT MoleculeParser : public Parser { - public: /** * @param list This list of chemical elements will be used internally * for searching and matching with searched strings * Constructor */ - explicit MoleculeParser(const QList &list); + explicit MoleculeParser(const QList &list); /** * Constructor @@ -217,11 +213,10 @@ public: * * @return whether the parsing was successful or not */ - bool weight(const QString& _moleculeString, - double *_resultMass, - ElementCountMap *_resultMap); + bool weight(const QString &_moleculeString, double *_resultMass, ElementCountMap *_resultMap); QSet aliasList(); + private: // Helper functions bool parseSubmolecule(double *_resultMass, ElementCountMap *_resultMap); @@ -233,28 +228,27 @@ private: // eg expandTerm(Et) returns (C2H5) QString expandTerm(const QString &_group); - QList m_elementList; + QList m_elementList; - static const int ELEMENT_TOKEN = 300; + static const int ELEMENT_TOKEN = 300; - Element *lookupElement(const QString& _name); + Element *lookupElement(const QString &_name); - QMap m_elementMap; + QMap m_elementMap; // Contains the list of aliases eg, { "Et - C2H5", "Me - CH3"} QSet *m_aliasList; - //if this booloean is "true" the parser found an error + // if this booloean is "true" the parser found an error bool m_error; protected: - /** * Extends the standard tokenizer in Parser::getNextToken(). */ - int getNextToken() override; + int getNextToken() override; private: - Element *m_elementVal; // Valid if m_nextToken == ELEMENT_TOKEN + Element *m_elementVal; // Valid if m_nextToken == ELEMENT_TOKEN }; #endif // MOLECULEPARSER_H diff --git a/libscience/parser.cpp b/libscience/parser.cpp index de84648336ec8dd1b64e92a49112c4bb169d3c46..24c703feb5525f3a0eb327add96be099147090e3 100644 --- a/libscience/parser.cpp +++ b/libscience/parser.cpp @@ -9,46 +9,40 @@ #include "kalzium_libscience_debug.h" - Parser::Parser() { start(QString()); } - -Parser::Parser(const QString& _str) +Parser::Parser(const QString &_str) { start(_str); } - Parser::~Parser() { } - -void Parser::start(const QString& _str) +void Parser::start(const QString &_str) { m_str = _str; if (_str.isNull()) { - m_index = -1; - m_nextChar = -1; + m_index = -1; + m_nextChar = -1; m_nextToken = -1; } else { - m_index = 0; - m_nextChar = m_str.at(0).toLatin1(); + m_index = 0; + m_nextChar = m_str.at(0).toLatin1(); getNextToken(); } } - // ---------------------------------------------------------------- - // Skip whitespace, and try to parse the following characters as an int. // -// Return true if successful. +// Return true if successful. bool Parser::parseInt(int *_result) { @@ -65,7 +59,7 @@ bool Parser::parseInt(int *_result) return false; } - int result = 0; + int result = 0; while (isdigit(m_nextChar)) { result = result * 10 + (m_nextChar - '0'); getNextChar(); @@ -75,15 +69,14 @@ bool Parser::parseInt(int *_result) return true; } - // Skip whitespace, and try to parse the following characters as a // simple float of the type -?[0-9]+'.'?[0-9]* // -// Return true if successful. +// Return true if successful. bool Parser::parseSimpleFloat(double *_result) { - double sign = 1.0; + double sign = 1.0; skipWhitespace(); if (m_nextChar == '-') { @@ -109,7 +102,7 @@ bool Parser::parseSimpleFloat(double *_result) return true; } - double decimal = 0.1; + double decimal = 0.1; while (isdigit(m_nextChar)) { result += decimal * (double)(m_nextChar - '0'); decimal /= 10.0; @@ -125,8 +118,8 @@ bool Parser::parseSimpleFloat(double *_result) int Parser::getNextChar() { -// qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parser::getNextChar(): char = " << m_nextChar; -// qCDebug(KALZIUM_LIBSCIENCE_LOG) << "m_str.size() " << m_str.size() << " with m_str: " << m_str << " and m_index: " << m_index; + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "Parser::getNextChar(): char = " << m_nextChar; + // qCDebug(KALZIUM_LIBSCIENCE_LOG) << "m_str.size() " << m_str.size() << " with m_str: " << m_str << " and m_index: " << m_index; ++m_index; @@ -136,7 +129,7 @@ int Parser::getNextChar() // If end of string, then reset the parser. if (m_index == m_str.size()) { - m_index = -1; + m_index = -1; m_nextChar = -1; } else { m_nextChar = m_str.at(m_index).toLatin1(); @@ -144,14 +137,13 @@ int Parser::getNextChar() // Take care of null-terminated strings. if (m_nextChar == 0) { - m_index = -1; + m_index = -1; m_nextChar = -1; } return m_nextChar; } - int Parser::skipWhitespace() { while (QChar(m_nextChar).isSpace()) { @@ -161,7 +153,6 @@ int Parser::skipWhitespace() return m_nextChar; } - // Get the next token. This corresponds to the lexical analyzer of a // standard parser, e.g as generated by lex. // @@ -185,7 +176,7 @@ int Parser::getNextToken() m_index = saveIndex; // No need to check since we already know it is correct. - (void) parseSimpleFloat(&m_floatVal); + (void)parseSimpleFloat(&m_floatVal); m_nextToken = FLOAT_TOKEN; } else { m_nextToken = INT_TOKEN; diff --git a/libscience/parser.h b/libscience/parser.h index 0c28c35991587a786f9a0da8fbcc672ab8e0aa67..3ad6f18eb0e7ca67b32a4d5805e4fb2218f8fe70 100644 --- a/libscience/parser.h +++ b/libscience/parser.h @@ -10,7 +10,6 @@ #include - /** * @class Parser * This is a general purpose parser originally written by Inge Wallin. @@ -32,7 +31,7 @@ public: * * @param _str @ref start the parsing with @p _str */ - explicit Parser(const QString& _str); + explicit Parser(const QString &_str); /** * Destructor @@ -42,12 +41,12 @@ public: /** * Start a new parse. */ - void start(const QString& _str); + void start(const QString &_str); /** * Peek at the next character; */ - int nextChar() const + int nextChar() const { return m_nextChar; } @@ -63,17 +62,16 @@ public: /** * Get the value stored for different types of tokens. */ - int intVal() const + int intVal() const { return m_intVal; } - float floatVal() const + float floatVal() const { return m_floatVal; } private: - // Try to parse some special datatypes. bool parseInt(int *_result); bool parseSimpleFloat(double *_result); @@ -83,7 +81,7 @@ protected: * All characters are their own token value per default. * Extend this list in your subclass to make a more advanced parser. */ - static const int INT_TOKEN = 257; + static const int INT_TOKEN = 257; /** * All characters are their own token value per default. @@ -107,12 +105,11 @@ protected: virtual int getNextToken(); private: - QString m_str; - int m_index; - int m_nextChar; + QString m_str; + int m_index; + int m_nextChar; protected: - // Lexical analysis and token handling. These members need to be // protected instead of private since we want to be able to // reimplement getNextToken(). @@ -120,7 +117,7 @@ protected: /** * The next token to be used in the parser. */ - int m_nextToken; + int m_nextToken; // Values for the respective token. These could be made into a // union, but I don't think it is necessary to bother, since they @@ -130,12 +127,12 @@ protected: /** * Valid if m_nextToken == INT_TOKEN */ - int m_intVal; // Valid if m_nextToken == INT_TOKEN + int m_intVal; // Valid if m_nextToken == INT_TOKEN /** * Valid if m_nextToken == FLOAT_TOKEN */ - double m_floatVal; // Valid if m_nextToken == FLOAT_TOKEN + double m_floatVal; // Valid if m_nextToken == FLOAT_TOKEN }; #endif // PARSER_H diff --git a/libscience/psetables.cpp b/libscience/psetables.cpp index 0ff5e0a7b5edcf6ee032b0e87d31ebb18e60a280..5dec61f88c28fbc8193da7ed8f44044bf2cadf68 100644 --- a/libscience/psetables.cpp +++ b/libscience/psetables.cpp @@ -12,8 +12,6 @@ #include - - pseTables::pseTables() { m_tables << pseRegularTable::init(); @@ -42,7 +40,7 @@ QStringList pseTables::tables() const return l; } -pseTable* pseTables::getTabletype(const int tableType) +pseTable *pseTables::getTabletype(const int tableType) { if ((tableType < 0) || (tableType >= m_tables.count())) { return nullptr; @@ -51,7 +49,7 @@ pseTable* pseTables::getTabletype(const int tableType) return m_tables.at(tableType); } -pseTable* pseTables::getTabletype(const QString &tableName) +pseTable *pseTables::getTabletype(const QString &tableName) { for (int i = 0; m_tables.count(); ++i) { if (tableName == m_tables.at(i)->name()) { @@ -143,46 +141,35 @@ QPoint pseTable::tableSize() const int pseTable::numerationAtPos(int xPos) const { - if (xPos >= 0 && xPos < m_xCoordsNumeration.count()) { - return m_xCoordsNumeration.at(xPos) - 1; - } - return -1; + if (xPos >= 0 && xPos < m_xCoordsNumeration.count()) { + return m_xCoordsNumeration.at(xPos) - 1; + } + return -1; } /// Regular Table Data pseRegularTable::pseRegularTable() - : pseTable() + : pseTable() { m_name = QStringLiteral("Classic"); m_description = i18n("Classic Periodic Table"); - m_xCoordsNumeration << - 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18; - - m_posX << - 1 << 18 << - 1 << 2 << 13 << 14 << 15 << 16 << 17 << 18 << - 1 << 2 << 13 << 14 << 15 << 16 << 17 << 18 << - 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << - 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << //Element 54 (Xe) - 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << //Element 58 (Ce) 71 (Lu) - 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << - 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << //Element 71 (Lr) - 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 - ; - - m_posY << - 1 << 1 << - 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << - 3 << 3 << 3 << 3 << 3 << 3 << 3 << 3 << - 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << - 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << //Element 54 (Xe) - 6 << 6 << 6 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << //Element 71 (Lr) - 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << - 7 << 7 << 7 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << - 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 - ; + m_xCoordsNumeration << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18; + + m_posX << 1 << 18 << 1 << 2 << 13 << 14 << 15 << 16 << 17 << 18 << 1 << 2 << 13 << 14 << 15 << 16 << 17 << 18 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 + << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 + << 18 << // Element 54 (Xe) + 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << // Element 58 (Ce) 71 (Lu) + 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 + << 14 << 15 << 16 << 17 << // Element 71 (Lr) + 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18; + + m_posY << 1 << 1 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 3 << 3 << 3 << 3 << 3 << 3 << 3 << 3 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 + << 4 << 4 << 4 << 4 << 4 << 4 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << // Element 54 (Xe) + 6 << 6 << 6 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << 9 << // Element 71 (Lr) + 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 7 << 7 << 7 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 << 10 + << 10 << 10 << 10 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7; // The classic PS has all Elements if (m_posX.count() == m_posY.count()) { @@ -200,34 +187,25 @@ pseRegularTable *pseRegularTable::init() /// Long Table Data pseLongTable::pseLongTable() - : pseTable() + : pseTable() { m_name = QStringLiteral("Long"); m_description = i18n("Long Periodic Table"); - m_xCoordsNumeration << - 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12 <<13 <<14 <<15 <<16 <<17 <<18; - - m_posX << - 1 << 32 << - 1 << 2 << 27 <<28 <<29 <<30 <<31 <<32 << - 1 << 2 << 27 <<28 <<29 <<30 <<31 <<32 << - 1 << 2 << 17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32 << - 1 << 2 << 17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32 << - 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12 <<13 <<14 <<15 <<16 <<17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32 << - 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 <<10 <<11 <<12 <<13 <<14 <<15 <<16 <<17 <<18 <<19 <<20 <<21 <<22 <<23 <<24 <<25 <<26 <<27 <<28 <<29 <<30 <<31 <<32 - ; - - m_posY << - 1 << 1 << - 2 << 2 << 2 <<2 <<2 <<2 <<2 <<2 << - 3 << 3 << 3 <<3 <<3 <<3 <<3 <<3 << - 4 << 4 << 4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 <<4 << - 5 << 5 << 5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 <<5 << - 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 <<6 << - 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 <<7 - ; + m_xCoordsNumeration << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 + << 13 << 14 << 15 << 16 << 17 << 18; + + m_posX << 1 << 32 << 1 << 2 << 27 << 28 << 29 << 30 << 31 << 32 << 1 << 2 << 27 << 28 << 29 << 30 << 31 << 32 << 1 << 2 << 17 << 18 << 19 << 20 << 21 << 22 + << 23 << 24 << 25 << 26 << 27 << 28 << 29 << 30 << 31 << 32 << 1 << 2 << 17 << 18 << 19 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27 << 28 << 29 + << 30 << 31 << 32 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 18 << 19 << 20 << 21 << 22 << 23 + << 24 << 25 << 26 << 27 << 28 << 29 << 30 << 31 << 32 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 17 + << 18 << 19 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27 << 28 << 29 << 30 << 31 << 32; + + m_posY << 1 << 1 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 3 << 3 << 3 << 3 << 3 << 3 << 3 << 3 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 << 4 + << 4 << 4 << 4 << 4 << 4 << 4 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 6 << 6 << 6 << 6 << 6 << 6 + << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 6 << 7 << 7 << 7 << 7 + << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7 << 7; // The long PS has all Elements if (m_posX.count() == m_posY.count()) { @@ -245,44 +223,40 @@ pseLongTable *pseLongTable::init() /// Short Table Data pseShortTable::pseShortTable() - : pseTable() + : pseTable() { m_name = QStringLiteral("Short"); m_description = i18n("Short Periodic Table"); - m_xCoordsNumeration << - 1 << 2 <<13 <<14 <<15 <<16 <<17 <<18; - - m_posX << - 1 << 8 < m_tables; - //int m_currentTable; + QList m_tables; + // int m_currentTable; }; - /** * defines a Periodic Table. * Holds the position (x,y) and all the displayed elements @@ -152,11 +151,11 @@ public: */ virtual QPoint tableSize() const; - /** + /** * Returns the Numeration for the current Table according to the position in the Table. * Coordinates beginning with 0. Returns -1 if none is found. */ - virtual int numerationAtPos(int xPos) const; + virtual int numerationAtPos(int xPos) const; protected: pseTable(); @@ -170,8 +169,6 @@ protected: QList m_elementList; }; - - class pseRegularTable : public pseTable { public: diff --git a/libscience/spectrum.cpp b/libscience/spectrum.cpp index 79c922e261cb9b2d157841ea4340ebf326967be0..6f8590eee69a5dcd511eb86ee68061e492f54fa7 100644 --- a/libscience/spectrum.cpp +++ b/libscience/spectrum.cpp @@ -30,7 +30,6 @@ double Spectrum::minPeak(const int unit) return KUnitConversion::Value(minPeak(), KUnitConversion::Angstrom).convertTo(KUnitConversion::UnitId(unit)).number(); } - double Spectrum::maxPeak() { double value = m_peaklist.first()->wavelength; @@ -49,8 +48,7 @@ double Spectrum::maxPeak(const int unit) return KUnitConversion::Value(maxPeak(), KUnitConversion::Angstrom).convertTo(KUnitConversion::UnitId(unit)).number(); } - -Spectrum* Spectrum::adjustToWavelength(double min, double max) +Spectrum *Spectrum::adjustToWavelength(double min, double max) { Spectrum *spec = new Spectrum(); @@ -66,19 +64,19 @@ Spectrum* Spectrum::adjustToWavelength(double min, double max) void Spectrum::adjustIntensities() { int maxInt = 0; - //find the highest intensity + // find the highest intensity for (peak *p : std::as_const(m_peaklist)) { if (p->intensity > maxInt) { maxInt = p->intensity; } } - //check if an adjustment is needed or not + // check if an adjustment is needed or not if (maxInt == 1000) { return; } - //now adjust the intensities. + // now adjust the intensities. for (peak *p : std::as_const(m_peaklist)) { double newInt = p->intensity * 1000 / maxInt; @@ -101,7 +99,7 @@ QList Spectrum::wavelengths(double min, double max) int Spectrum::parentElementNumber() const { - return m_parentElementNumber; + return m_parentElementNumber; } Spectrum::~Spectrum() @@ -111,7 +109,7 @@ Spectrum::~Spectrum() Spectrum::Spectrum() { - //FIXME this shouldn't be hardcoded + // FIXME this shouldn't be hardcoded m_parentElementNumber = 16; } diff --git a/libscience/spectrum.h b/libscience/spectrum.h index e528f3abf60f456d3e0cf62ab1477d2c1816ee7d..60c7f7ad4d1fb621d964518fd7f43fe1db4b79a3 100644 --- a/libscience/spectrum.h +++ b/libscience/spectrum.h @@ -37,17 +37,19 @@ public: class SCIENCE_EXPORT peak { public: - peak() { + peak() + { wavelength = -1.0; intensity = -1; } - peak(double wl, int in) { + peak(double wl, int in) + { wavelength = wl; intensity = in; } - ///relative. The highest is per definition 1000 + /// relative. The highest is per definition 1000 int intensity; double wavelength; @@ -58,7 +60,8 @@ public: * adds the peak @p b to the internal * lists of peaks */ - void addPeak(Spectrum::peak* b) { + void addPeak(Spectrum::peak *b) + { if (b) { m_peaklist.append(b); } @@ -73,7 +76,7 @@ public: * so that the biggest intensity is again 1000 and the * others are adopted. */ - Spectrum* adjustToWavelength(double min, double max); + Spectrum *adjustToWavelength(double min, double max); /** * sets the highest intensity to 1000 and adjusts the @@ -92,14 +95,15 @@ public: /** * @return the list of peaks of the spectrum */ - QList peaklist() { + QList peaklist() + { return m_peaklist; } /** - * If the spectrum belongs to Iron, this method will return "26" - * @return the number of the element the spectrum belongs to - */ + * If the spectrum belongs to Iron, this method will return "26" + * @return the number of the element the spectrum belongs to + */ int parentElementNumber() const; /** @@ -123,7 +127,7 @@ private: /** * the internal dataset */ - QList m_peaklist; + QList m_peaklist; int m_parentElementNumber; }; diff --git a/libscience/spectrumparser.cpp b/libscience/spectrumparser.cpp index 086119a102d126f034acfd417066a413fe30a04b..fe978b069eb67c4cfa8bab1e52ae588ae8e78a93 100644 --- a/libscience/spectrumparser.cpp +++ b/libscience/spectrumparser.cpp @@ -15,8 +15,9 @@ class SpectrumParser::Private { public: Private() - : currentSpectrum(nullptr) - {} + : currentSpectrum(nullptr) + { + } ~Private() { @@ -24,8 +25,8 @@ public: delete currentPeak; } - Spectrum * currentSpectrum = nullptr; - Spectrum::peak * currentPeak = nullptr; + Spectrum *currentSpectrum = nullptr; + Spectrum::peak *currentPeak = nullptr; bool inMetadata_ = false; bool inSpectrum_ = false; @@ -36,11 +37,12 @@ public: double wavelength; int intensity; - QList spectra; + QList spectra; }; SpectrumParser::SpectrumParser() - : QXmlDefaultHandler(), d(new Private) + : QXmlDefaultHandler() + , d(new Private) { } @@ -49,14 +51,13 @@ SpectrumParser::~SpectrumParser() delete d; } -bool SpectrumParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs) +bool SpectrumParser::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs) { if (localName == QLatin1String("spectrum")) { - d->currentSpectrum = new Spectrum(); d->inSpectrum_ = true; - //now save the element of the current spectrum + // now save the element of the current spectrum for (int i = 0; i < attrs.length(); ++i) { if (attrs.localName(i) == QLatin1String("id")) { currentElementID = attrs.value(i); @@ -79,7 +80,7 @@ bool SpectrumParser::startElement(const QString&, const QString &localName, cons return true; } -bool SpectrumParser::endElement(const QString&, const QString& localName, const QString &) +bool SpectrumParser::endElement(const QString &, const QString &localName, const QString &) { if (localName == QLatin1String("spectrum")) { int num = currentElementID.midRef(1).toInt(); @@ -92,7 +93,7 @@ bool SpectrumParser::endElement(const QString&, const QString& localName, const } else if (localName == QLatin1String("peakList")) { d->inSpectrumList_ = false; } else if (localName == QLatin1String("peak")) { -//X qCDebug(KALZIUM_LIBSCIENCE_LOG) << "in 'peak'" << " with this data: " << d->currentPeak->intensity << " (intensity)" ; + // X qCDebug(KALZIUM_LIBSCIENCE_LOG) << "in 'peak'" << " with this data: " << d->currentPeak->intensity << " (intensity)" ; d->currentSpectrum->addPeak(d->currentPeak); d->currentPeak = nullptr; d->inPeak_ = false; @@ -106,7 +107,7 @@ bool SpectrumParser::characters(const QString &ch) return true; } -QList SpectrumParser::getSpectrums() const +QList SpectrumParser::getSpectrums() const { return d->spectra; } diff --git a/libscience/spectrumparser.h b/libscience/spectrumparser.h index e5c55f8811dfd2cccdf26d528a55a13aa1790476..9f4296d3362948b86aad25f2cb3f7c889fd97a87 100644 --- a/libscience/spectrumparser.h +++ b/libscience/spectrumparser.h @@ -9,8 +9,8 @@ #include "science_export.h" #include -#include #include +#include #include "spectrum.h" @@ -29,13 +29,13 @@ public: */ SpectrumParser(); ~SpectrumParser(); - bool startElement( const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs ) override; + bool startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs) override; - bool endElement( const QString& namespaceURI, const QString &localName, const QString& qName ) override; + bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) override; bool characters(const QString &ch) override; - QList getSpectrums() const; + QList getSpectrums() const; private: QString currentElementID; diff --git a/libscience/tests/isotopereadingtest.cpp b/libscience/tests/isotopereadingtest.cpp index 811657795e2ad2ea13f61b58da322236926261b7..2af5760f11bce41eccd1b6f01d8723072e13e152 100644 --- a/libscience/tests/isotopereadingtest.cpp +++ b/libscience/tests/isotopereadingtest.cpp @@ -4,8 +4,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "isotopeparser.h" #include "isotope.h" +#include "isotopeparser.h" #include #include @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) return 1; } - IsotopeParser * parser = new IsotopeParser(); + IsotopeParser *parser = new IsotopeParser(); QFile xmlFile(argv[1]); QXmlInputSource source(&xmlFile); @@ -25,21 +25,22 @@ int main(int argc, char *argv[]) reader.setContentHandler(parser); reader.parse(source); - QList v = parser->getIsotopes(); + QList v = parser->getIsotopes(); - qDebug() << "Found " << v.count() << " isotopes.";; + qDebug() << "Found " << v.count() << " isotopes."; + ; qDebug() << "As a test I am now issuing all isotopes with 50 nuclueons: "; - foreach (Isotope* i, v) { + foreach (Isotope *i, v) { if (i) { -//X if (i->nucleons() == 50 ) { -//X qDebug() << " Isotope of " << i->parentElementSymbol() << " with a mass of " << i->mass(); -//X qDebug() << " Halflife: " << i->halflife() << i->halflifeUnit( ); -//X } + // X if (i->nucleons() == 50 ) { + // X qDebug() << " Isotope of " << i->parentElementSymbol() << " with a mass of " << i->mass(); + // X qDebug() << " Halflife: " << i->halflife() << i->halflifeUnit( ); + // X } if (i->parentElementSymbol() == QLatin1String("Ti")) { qDebug() << " Isotope of " << i->parentElementSymbol() << " with a mass of " << i->mass(); - qDebug() << " Halflife: " << i->halflife() << i->halflifeUnit( ); + qDebug() << " Halflife: " << i->halflife() << i->halflifeUnit(); } } } diff --git a/libscience/tests/spectrumreadingtests.cpp b/libscience/tests/spectrumreadingtests.cpp index 718bac4cb562532beccf8ba0181ebefab3587f8a..ee37dee50018f4d983312ec16c8e505ec4197f7e 100644 --- a/libscience/tests/spectrumreadingtests.cpp +++ b/libscience/tests/spectrumreadingtests.cpp @@ -4,8 +4,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "spectrumparser.h" #include "spectrum.h" +#include "spectrumparser.h" #include #include @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) foreach (Spectrum *s, v) { if (s) { qDebug() << "Element: " << s->parentElementNumber(); - foreach (Spectrum::peak * p , s->peaklist()) { + foreach (Spectrum::peak *p, s->peaklist()) { qDebug() << " Peak: " << p->wavelength; } } diff --git a/libscience/tests/xmlreadingtest.cpp b/libscience/tests/xmlreadingtest.cpp index b84abb7d48125f30a67566e3fed4bccd863a3b8e..aae1fccbd91d2c8358e58a7c510765630132fc00 100644 --- a/libscience/tests/xmlreadingtest.cpp +++ b/libscience/tests/xmlreadingtest.cpp @@ -4,9 +4,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "elementparser.h" -#include "element.h" #include "chemicaldataobject.h" +#include "element.h" +#include "elementparser.h" #include #include @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) return 1; } - ElementSaxParser * parser = new ElementSaxParser(); + ElementSaxParser *parser = new ElementSaxParser(); QFile xmlFile(argv[1]); QXmlInputSource source(&xmlFile); @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) reader.setContentHandler(parser); reader.parse(source); - QList v = parser->getElements(); + QList v = parser->getElements(); std::cout << "Found " << v.count() << " elements." << std::endl; @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) if (e) { QList list = e->data(); - //Test: give me all data available + // Test: give me all data available foreach (const ChemicalDataObject &o, list) { QString unit = o.unitAsString(); if (unit == QLatin1String("bo:noUnit")) { diff --git a/src/calculator/calculator.cpp b/src/calculator/calculator.cpp index c5917d4cc70a451b31b471e637c0dffe9a9dc2fd..e2a74026b6ab1ea7e62ced93c328afb7c55209ae 100644 --- a/src/calculator/calculator.cpp +++ b/src/calculator/calculator.cpp @@ -19,10 +19,11 @@ #include #include -calculator::calculator(QWidget *parent) : QDialog(parent) +calculator::calculator(QWidget *parent) + : QDialog(parent) { setWindowTitle(i18nc("@title:window", "Chemical Calculator")); - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help|QDialogButtonBox::Close, this); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close, this); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); @@ -68,11 +69,10 @@ calculator::calculator(QWidget *parent) : QDialog(parent) ui.stack->addWidget(m_equationBalancer); #endif // Add an image to the file - ui.pic->setPixmap((QIcon::fromTheme(QStringLiteral("calculate"))).pixmap(128,128)); + ui.pic->setPixmap((QIcon::fromTheme(QStringLiteral("calculate"))).pixmap(128, 128)); // Connect the tree item selection signal to the corresponding slot - connect(ui.tree, &QTreeWidget::itemClicked, this, - &calculator::slotItemSelection); + connect(ui.tree, &QTreeWidget::itemClicked, this, &calculator::slotItemSelection); ui.tree->setCurrentItem(ui.tree->topLevelItem(0), 0, QItemSelectionModel::ToggleCurrent); @@ -80,7 +80,7 @@ calculator::calculator(QWidget *parent) : QDialog(parent) connect(buttonBox->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &calculator::slotHelp); } -calculator :: ~calculator() +calculator ::~calculator() { } @@ -90,7 +90,7 @@ void calculator::slotItemSelection(QTreeWidgetItem *item) return; } - //DEBUG + // DEBUG qCDebug(KALZIUM_LOG) << "Item clicked: " << item->text(0); QString s = item->text(0); @@ -107,10 +107,10 @@ void calculator::slotItemSelection(QTreeWidgetItem *item) // if the concentration calculator is selected, show the widget in the UI ui.stack->setCurrentWidget(m_concCalculator); - // The equation balancer needs FACILE library, if it's present HAVE_FACILE = 1 + // The equation balancer needs FACILE library, if it's present HAVE_FACILE = 1 #ifdef HAVE_FACILE } else if (!(s.compare(i18n("Equation Balancer")))) { - // If the equation balancer was selected, open it in the UI. + // If the equation balancer was selected, open it in the UI. ui.stack->setCurrentWidget(m_equationBalancer); #endif @@ -121,7 +121,6 @@ void calculator::slotItemSelection(QTreeWidgetItem *item) } } - void calculator::slotHelp() { KHelpClient::invokeHelp(QStringLiteral("tools.html#perf_calculation"), QStringLiteral("kalzium")); diff --git a/src/calculator/calculator.h b/src/calculator/calculator.h index db60217da43afebb10c6e98fbffe22a8e680e085..2ccac88b0b6352c2970024ed13679743323c8f19 100644 --- a/src/calculator/calculator.h +++ b/src/calculator/calculator.h @@ -11,12 +11,12 @@ #include -#include "ui_calculator.h" -#include "nuclearCalculator.h" -#include "gasCalculator.h" #include "concCalculator.h" -#include "titrationCalculator.h" +#include "gasCalculator.h" #include "molcalcwidget.h" +#include "nuclearCalculator.h" +#include "titrationCalculator.h" +#include "ui_calculator.h" #include #ifdef HAVE_FACILE @@ -37,22 +37,22 @@ public: /* * The class constructor and destructor, takes in a Widget as parent */ - explicit calculator(QWidget *parent = nullptr); // constructor - ~ calculator(); // destructor + explicit calculator(QWidget *parent = nullptr); // constructor + ~calculator(); // destructor private: - Ui::calculator ui; // The user interface - KActionCollection * m_actionCollection; + Ui::calculator ui; // The user interface + KActionCollection *m_actionCollection; // These are the various calculator widgets that will be added to this calculator - nuclearCalculator * m_nuclearCalculator; // The nuclear calculator - gasCalculator * m_gasCalculator; // The gas calculator - concCalculator * m_concCalculator; // The concentration calculator - titrationCalculator * m_titraCalculator; // The concentration calculator - MolcalcWidget * m_moleCalculator; // The molecular mass calculator + nuclearCalculator *m_nuclearCalculator; // The nuclear calculator + gasCalculator *m_gasCalculator; // The gas calculator + concCalculator *m_concCalculator; // The concentration calculator + titrationCalculator *m_titraCalculator; // The concentration calculator + MolcalcWidget *m_moleCalculator; // The molecular mass calculator #ifdef HAVE_FACILE - EQChemDialog * m_equationBalancer; // The equation balancer + EQChemDialog *m_equationBalancer; // The equation balancer #endif protected Q_SLOTS: /** diff --git a/src/calculator/concCalculator.cpp b/src/calculator/concCalculator.cpp index a3875292435f9e907f131cc00bd49d66d35119e5..67ea18b8c96b2a8fd844075113d8f621e4810da7 100644 --- a/src/calculator/concCalculator.cpp +++ b/src/calculator/concCalculator.cpp @@ -16,7 +16,8 @@ using namespace KUnitConversion; -concCalculator::concCalculator(QWidget * parent) : QFrame(parent) +concCalculator::concCalculator(QWidget *parent) + : QFrame(parent) { ui.setupUi(this); @@ -31,48 +32,31 @@ concCalculator::concCalculator(QWidget * parent) : QFrame(parent) // corresponding quantity should be updated in the class.) // Amount of solute changed - connect(ui.amtSolute, SIGNAL(valueChanged(double)), - this, SLOT(amtSoluteChanged())); - connect(ui.amtSltType, SIGNAL(activated(int)), - this, SLOT(amtSoluteTypeChanged())); - connect(ui.amtSlt_unit, SIGNAL(activated(int)), - this, SLOT(amtSoluteChanged())); + connect(ui.amtSolute, SIGNAL(valueChanged(double)), this, SLOT(amtSoluteChanged())); + connect(ui.amtSltType, SIGNAL(activated(int)), this, SLOT(amtSoluteTypeChanged())); + connect(ui.amtSlt_unit, SIGNAL(activated(int)), this, SLOT(amtSoluteChanged())); // Molar mass and equivalent mass change for solvent - connect(ui.molarMass, SIGNAL(valueChanged(double)), - this, SLOT(molarMassChanged(double))); - connect(ui.eqtMass, SIGNAL(valueChanged(double)), - this, SLOT(eqtMassChanged(double))); + connect(ui.molarMass, SIGNAL(valueChanged(double)), this, SLOT(molarMassChanged(double))); + connect(ui.eqtMass, SIGNAL(valueChanged(double)), this, SLOT(eqtMassChanged(double))); // Density change for solute - connect(ui.densitySolute, SIGNAL(valueChanged(double)), - this, SLOT(densitySoluteChanged())); - connect(ui.densSlt_unit, SIGNAL(activated(int)), - this, SLOT(densitySoluteChanged())); + connect(ui.densitySolute, SIGNAL(valueChanged(double)), this, SLOT(densitySoluteChanged())); + connect(ui.densSlt_unit, SIGNAL(activated(int)), this, SLOT(densitySoluteChanged())); // Amount of solvent changed - connect(ui.amtSolvent, SIGNAL(valueChanged(double)), - this, SLOT(amtSolventChanged())); - connect(ui.amtSlvtType, SIGNAL(activated(int)), - this, SLOT(amtSolventTypeChanged())); - connect(ui.amtSlvt_unit, SIGNAL(activated(int)), - this, SLOT(amtSolventChanged())); + connect(ui.amtSolvent, SIGNAL(valueChanged(double)), this, SLOT(amtSolventChanged())); + connect(ui.amtSlvtType, SIGNAL(activated(int)), this, SLOT(amtSolventTypeChanged())); + connect(ui.amtSlvt_unit, SIGNAL(activated(int)), this, SLOT(amtSolventChanged())); // Molar mass change for solvent - connect(ui.molarMassSolvent, SIGNAL(valueChanged(double)), - this, SLOT(molarMassSolventChanged(double))); + connect(ui.molarMassSolvent, SIGNAL(valueChanged(double)), this, SLOT(molarMassSolventChanged(double))); // Density changed - connect(ui.densitySolvent, SIGNAL(valueChanged(double)), - this, SLOT(densitySolventChanged())); - connect(ui.densSlvt_unit, SIGNAL(activated(int)), - this, SLOT(densitySolventChanged())); + connect(ui.densitySolvent, SIGNAL(valueChanged(double)), this, SLOT(densitySolventChanged())); + connect(ui.densSlvt_unit, SIGNAL(activated(int)), this, SLOT(densitySolventChanged())); // concentration change - connect(ui.concentration, SIGNAL(valueChanged(double)), - this, SLOT(concentrationChanged())); - connect(ui.conc_unit, SIGNAL(activated(int)), - this, SLOT(concentrationChanged())); + connect(ui.concentration, SIGNAL(valueChanged(double)), this, SLOT(concentrationChanged())); + connect(ui.conc_unit, SIGNAL(activated(int)), this, SLOT(concentrationChanged())); // Mode change - connect(ui.mode, SIGNAL(activated(int)), - this, SLOT(setMode(int))); + connect(ui.mode, SIGNAL(activated(int)), this, SLOT(setMode(int))); - connect(ui.reset, &QAbstractButton::clicked, - this, &concCalculator::init); + connect(ui.reset, &QAbstractButton::clicked, this, &concCalculator::init); /**************************************************************************/ // concentration Calculator setup complete @@ -85,7 +69,7 @@ concCalculator::concCalculator(QWidget * parent) : QFrame(parent) } } -concCalculator:: ~concCalculator() +concCalculator::~concCalculator() { } @@ -103,22 +87,22 @@ void concCalculator::init() amtSoluteTypeChanged(); amtSolventTypeChanged(); - ui.amtSolute ->setValue(117.0); - ui.molarMass ->setValue(58.5); - ui.eqtMass ->setValue(58.5); - ui.densitySolute ->setValue(2.7); - ui.amtSolvent ->setValue(1.0); - ui.molarMassSolvent-> setValue(18.0); - ui.densitySolvent ->setValue(1000.0); - ui.concentration ->setValue(2.0); - - ui.amtSltType ->setCurrentIndex(0); - ui.amtSlt_unit ->setCurrentIndex(0); - ui.densSlt_unit ->setCurrentIndex(0); - ui.amtSlvtType ->setCurrentIndex(0); - ui.amtSlvt_unit ->setCurrentIndex(0); - ui.densSlvt_unit ->setCurrentIndex(0); - ui.conc_unit ->setCurrentIndex(0); + ui.amtSolute->setValue(117.0); + ui.molarMass->setValue(58.5); + ui.eqtMass->setValue(58.5); + ui.densitySolute->setValue(2.7); + ui.amtSolvent->setValue(1.0); + ui.molarMassSolvent->setValue(18.0); + ui.densitySolvent->setValue(1000.0); + ui.concentration->setValue(2.0); + + ui.amtSltType->setCurrentIndex(0); + ui.amtSlt_unit->setCurrentIndex(0); + ui.densSlt_unit->setCurrentIndex(0); + ui.amtSlvtType->setCurrentIndex(0); + ui.amtSlvt_unit->setCurrentIndex(0); + ui.densSlvt_unit->setCurrentIndex(0); + ui.conc_unit->setCurrentIndex(0); // Initialise values m_amtSolute = Value(117.0, KUnitConversion::Gram); @@ -181,7 +165,7 @@ void concCalculator::calculateAmtSolute() mode = 4; break; // Calculate the moles of solute - case 5: //mole percentage specified + case 5: // mole percentage specified if (m_concentration >= 100.0) { error(PERCENTAGE); } @@ -270,21 +254,21 @@ void concCalculator::calculateMolarMass() int type2 = ui.amtSlvtType->currentIndex(); double numMoles; switch (type) { - case 0: //molarity specified + case 0: // molarity specified // number of moles = volume * concentration numMoles = volumeSolvent() * m_concentration; break; - case 1: // cannot be calculated (insufficient data) + case 1: // cannot be calculated (insufficient data) error(INSUFFICIENT_DATA_MOLE); return; - case 2: // molality specified + case 2: // molality specified numMoles = massSolvent() / 1000.0 * m_concentration; break; - case 3: // cannot be calculated (insufficient data) + case 3: // cannot be calculated (insufficient data) case 4: error(INSUFFICIENT_DATA_MOLE); return; - case 5: // mole fraction specified + case 5: // mole fraction specified numMoles = m_concentration / (100.0 - m_concentration) * molesSolvent(); break; } @@ -326,7 +310,7 @@ void concCalculator::calculateEqtMass() return; } - if (type2 == 2) { // Amount of solute specified in moles, cannot calculate + if (type2 == 2) { // Amount of solute specified in moles, cannot calculate error(INSUFFICIENT_DATA_MOLES); } else { if (numEqts == 0.0) { @@ -347,19 +331,19 @@ void concCalculator::calculateMolarMassSolvent() int type2 = ui.amtSlvtType->currentIndex(); double numMoles; switch (type) { - case 0: // molarity specified - case 1: // normality specified - case 2: // molality specified - case 3: // mass fraction specified - case 4: // volume fraction specified + case 0: // molarity specified + case 1: // normality specified + case 2: // molality specified + case 3: // mass fraction specified + case 4: // volume fraction specified error(INSUFFICIENT_DATA_SOLVENT); - return; // cannot be calculated (insufficient data) - case 5: // mole fraction specified + return; // cannot be calculated (insufficient data) + case 5: // mole fraction specified numMoles = (100.0 - m_concentration) / m_concentration * molesSolute(); break; } - if (type2 == 2) { // amount specified in moles + if (type2 == 2) { // amount specified in moles error(INSUFFICIENT_DATA_MOLES); } else { m_molarMassSolvent = massSolvent() / numMoles; @@ -377,7 +361,7 @@ void concCalculator::calculateAmtSolvent() double moleSolvent, massSolvent, volSolvent; - int mode = 0; // Indicates the mode in which we have calculated the amount of solvent + int mode = 0; // Indicates the mode in which we have calculated the amount of solvent /* * mode = 1 (molessolvent) mode = 2 eqtssolvent, mode = 3 mass, 4 volume */ @@ -416,7 +400,7 @@ void concCalculator::calculateAmtSolvent() mode = 3; break; // Calculate the moles of solvent - case 5: //mole percentage specified + case 5: // mole percentage specified moleSolvent = (100.0 - m_concentration) / m_concentration; moleSolvent *= molesSolute(); mode = 1; @@ -479,7 +463,7 @@ void concCalculator::calculateAmtSolvent() moleSolvent = volSolvent * densitySolvent() / m_molarMassSolvent; break; } - m_molesSolvent = moleSolvent; + m_molesSolvent = moleSolvent; ui.amtSolvent->setValue(moleSolvent); break; } @@ -504,22 +488,22 @@ void concCalculator::calculateConcentration() return; } switch (type) { - case 0: // molarity + case 0: // molarity m_concentration = molesSolute() / volumeSolvent(); break; - case 1: // normality + case 1: // normality m_concentration = eqtsSolute() / volumeSolvent(); break; - case 2: // molality + case 2: // molality m_concentration = molesSolute() * 1000.0 / massSolvent(); break; - case 3: // mass fraction + case 3: // mass fraction m_concentration = massSolute() / (massSolute() + massSolvent()) * 100.0; break; - case 4: // volume fraction + case 4: // volume fraction m_concentration = volumeSolute() / (volumeSolute() + volumeSolvent()) * 100.0; break; - case 5: // mole fraction + case 5: // mole fraction m_concentration = molesSolute() / (molesSolute() + molesSolvent()) * 100.0; break; default: @@ -566,7 +550,6 @@ double concCalculator::molesSolvent() break; } return moles; - } double concCalculator::massSolvent() { @@ -666,7 +649,6 @@ double concCalculator::eqtsSolute() break; } return eqts; - } double concCalculator::massSolute() @@ -695,7 +677,6 @@ double concCalculator::densitySolute() return (m_densitySolute.convertTo(KUnitConversion::GramPerLiter).number()); } - // occurs when the type in which amount of solute is specified is changed void concCalculator::amtSoluteTypeChanged() { @@ -710,48 +691,30 @@ void concCalculator::amtSoluteTypeChanged() volumeUnitCombobox(ui.amtSlt_unit); m_amtSolute = Value(ui.amtSolute->value(), ui.amtSlt_unit->currentText()); - } else { // amount of solute is specified in terms of moles + } else { // amount of solute is specified in terms of moles m_molesSolute = ui.amtSolute->value(); ui.amtSlt_unit->hide(); } calculate(); } -void concCalculator::massUnitCombobox(QComboBox* comboBox) +void concCalculator::massUnitCombobox(QComboBox *comboBox) { comboBox->show(); QList units; - units - << Gram - << Milligram - << Kilogram - << Ton - << Carat - << Pound - << Ounce - << TroyOunce; + units << Gram << Milligram << Kilogram << Ton << Carat << Pound << Ounce << TroyOunce; KalziumUtils::populateUnitCombobox(comboBox, units); comboBox->setCurrentIndex(0); } -void concCalculator::volumeUnitCombobox(QComboBox* comboBox) +void concCalculator::volumeUnitCombobox(QComboBox *comboBox) { comboBox->show(); QList units; - units - << Liter - << Milliliter - << CubicMeter - << CubicFoot - << CubicInch - << CubicMile - << FluidOunce - << Cup - << GallonUS - << PintImperial; + units << Liter << Milliliter << CubicMeter << CubicFoot << CubicInch << CubicMile << FluidOunce << Cup << GallonUS << PintImperial; KalziumUtils::populateUnitCombobox(comboBox, units); comboBox->setCurrentIndex(0); @@ -792,12 +755,11 @@ void concCalculator::amtSolventTypeChanged() calculate(); } - // Occurs when the amount of solute is changed void concCalculator::amtSolventChanged() { int type = ui.amtSlvtType->currentIndex(); - switch (type) { // amount of solvent specified in terms of volume + switch (type) { // amount of solvent specified in terms of volume case 0: case 1: m_amtSolvent = Value(ui.amtSolvent->value(), ui.amtSlvt_unit->currentText()); @@ -868,22 +830,22 @@ void concCalculator::setMode(int mode) // set the value that should be calculated to readOnly switch (mode) { - case AMT_SOLUTE: // Calculate the amount of solute + case AMT_SOLUTE: // Calculate the amount of solute ui.amtSolute->setReadOnly(true); break; - case MOLAR_MASS: // Calculate the molar mass of solute + case MOLAR_MASS: // Calculate the molar mass of solute ui.molarMass->setReadOnly(true); break; - case EQT_MASS: // Calculate the equivalent mass of solute + case EQT_MASS: // Calculate the equivalent mass of solute ui.eqtMass->setReadOnly(true); break; - case AMT_SOLVENT: // Calculate the amount of solvent + case AMT_SOLVENT: // Calculate the amount of solvent ui.amtSolvent->setReadOnly(true); break; - case MOLAR_MASS_SOLVENT:// Calculate the molar mass of solvent + case MOLAR_MASS_SOLVENT: // Calculate the molar mass of solvent ui.molarMassSolvent->setReadOnly(true); break; - case CONCENTRATION: // Calculate the concentration of the solution + case CONCENTRATION: // Calculate the concentration of the solution ui.concentration->setReadOnly(true); break; } @@ -897,26 +859,26 @@ void concCalculator::calculate() error(RESET_CONC_MESSAGE); // Calculate the amount of solute switch (m_mode) { - case AMT_SOLUTE: // Calculate the amount of solute + case AMT_SOLUTE: // Calculate the amount of solute if (ui.conc_unit->currentIndex() > 2 && ui.concentration->value() > 100) { error(PERCENTAGE); return; } calculateAmtSolute(); break; - case MOLAR_MASS: // Calculate the molar mass of solute + case MOLAR_MASS: // Calculate the molar mass of solute calculateMolarMass(); break; - case EQT_MASS: // Calculate the equivalent mass of solute + case EQT_MASS: // Calculate the equivalent mass of solute calculateEqtMass(); break; - case AMT_SOLVENT: // Calculate the amount of solvent - calculateAmtSolvent(); - break; - case MOLAR_MASS_SOLVENT:// Calculate the molar mass of solvent + case AMT_SOLVENT: // Calculate the amount of solvent + calculateAmtSolvent(); + break; + case MOLAR_MASS_SOLVENT: // Calculate the molar mass of solvent calculateMolarMassSolvent(); break; - case CONCENTRATION: // Calculate the concentration of the solution + case CONCENTRATION: // Calculate the concentration of the solution calculateConcentration(); break; } diff --git a/src/calculator/concCalculator.h b/src/calculator/concCalculator.h index 273133f923f9586ebce8171ed1718ebbd810b234..c040b16f3f2ac93370fdd42e8af9631649b53d4d 100644 --- a/src/calculator/concCalculator.h +++ b/src/calculator/concCalculator.h @@ -11,8 +11,8 @@ #include -#include #include +#include #include "ui_concCalculator.h" @@ -42,14 +42,7 @@ enum ERROR_TYPE_CONC { }; // enumeration for the mode of calculation in the setMode(int) function -enum MODE_CALCULATION_CONC { - AMT_SOLUTE = 0, - MOLAR_MASS, - EQT_MASS, - AMT_SOLVENT, - MOLAR_MASS_SOLVENT, - CONCENTRATION -}; +enum MODE_CALCULATION_CONC { AMT_SOLUTE = 0, MOLAR_MASS, EQT_MASS, AMT_SOLVENT, MOLAR_MASS_SOLVENT, CONCENTRATION }; /* * This class implements the concentration calculator. This widget performs basic @@ -65,7 +58,7 @@ public: /* * The constructor and destructor for the class */ - explicit concCalculator(QWidget * parent = nullptr); + explicit concCalculator(QWidget *parent = nullptr); ~concCalculator(); public Q_SLOTS: @@ -176,21 +169,20 @@ public Q_SLOTS: void setMode(int); private: - Ui::concCalculator ui; // The user interface - - Value m_amtSolute; // amount of solute - Value m_amtSolvent; // amount of solvent - double m_molesSolute; // amount of solute in moles - double m_molesSolvent; // amount of solvent in moles - double m_molarMass; // molar mass of solute - double m_eqtMass; // equivalent mass of solute - double m_molarMassSolvent; // molar mass of solvent - Value m_densitySolute; // density of solute - Value m_densitySolvent; // density of the solvent - double m_concentration; // concentration of the solution - - int m_mode; // specifies the mode of calculation - + Ui::concCalculator ui; // The user interface + + Value m_amtSolute; // amount of solute + Value m_amtSolvent; // amount of solvent + double m_molesSolute; // amount of solute in moles + double m_molesSolvent; // amount of solvent in moles + double m_molarMass; // molar mass of solute + double m_eqtMass; // equivalent mass of solute + double m_molarMassSolvent; // molar mass of solvent + Value m_densitySolute; // density of solute + Value m_densitySolvent; // density of the solvent + double m_concentration; // concentration of the solution + + int m_mode; // specifies the mode of calculation }; #endif // CONCCALCULATOR_H diff --git a/src/calculator/gasCalculator.cpp b/src/calculator/gasCalculator.cpp index 1dbad127e6ded52f2b06a24ec1839a06aeb10dc0..aa4aaa6d8b145104e649530f458ccc85cd2e7dd8 100644 --- a/src/calculator/gasCalculator.cpp +++ b/src/calculator/gasCalculator.cpp @@ -10,13 +10,13 @@ #include #include "kalziumunitcombobox.h" -#include "prefs.h" #include "kalziumutils.h" +#include "prefs.h" using namespace KUnitConversion; -gasCalculator::gasCalculator(QWidget * parent) - : QWidget(parent) +gasCalculator::gasCalculator(QWidget *parent) + : QWidget(parent) { ui.setupUi(this); @@ -24,39 +24,24 @@ gasCalculator::gasCalculator(QWidget * parent) init(); - connect(ui.temp, SIGNAL(valueChanged(double)), - this, SLOT(tempChanged())); - connect(ui.temp_unit, SIGNAL(activated(int)), - this, SLOT(tempChanged())); - connect(ui.volume, SIGNAL(valueChanged(double)), - this, SLOT(volChanged())); - connect(ui.volume_unit, SIGNAL(activated(int)), - this, SLOT(volChanged())); - connect(ui.pressure, SIGNAL(valueChanged(double)), - this, SLOT(pressureChanged())); - connect(ui.pressure_unit, SIGNAL(activated(int)), - this, SLOT(pressureChanged())); - connect(ui.mass, SIGNAL(valueChanged(double)), - this, SLOT(massChanged())); - connect(ui.mass_unit, SIGNAL(activated(int)), - this, SLOT(massChanged())); - connect(ui.moles, SIGNAL(valueChanged(double)), - this, SLOT(molesChanged(double))); - connect(ui.molarMass, SIGNAL(valueChanged(double)), - this, SLOT(molarMassChanged(double))); - connect(ui.a, SIGNAL(valueChanged(double)), - this, SLOT(Vand_aChanged())); - connect(ui.b, SIGNAL(valueChanged(double)), - this, SLOT(Vand_bChanged())); - connect(ui.b_unit, SIGNAL(activated(int)), - this, SLOT(Vand_bChanged())); - connect(ui.mode, SIGNAL(activated(int)), - this, SLOT(setMode(int))); - connect(ui.reset, &QAbstractButton::clicked, - this, &gasCalculator::init); + connect(ui.temp, SIGNAL(valueChanged(double)), this, SLOT(tempChanged())); + connect(ui.temp_unit, SIGNAL(activated(int)), this, SLOT(tempChanged())); + connect(ui.volume, SIGNAL(valueChanged(double)), this, SLOT(volChanged())); + connect(ui.volume_unit, SIGNAL(activated(int)), this, SLOT(volChanged())); + connect(ui.pressure, SIGNAL(valueChanged(double)), this, SLOT(pressureChanged())); + connect(ui.pressure_unit, SIGNAL(activated(int)), this, SLOT(pressureChanged())); + connect(ui.mass, SIGNAL(valueChanged(double)), this, SLOT(massChanged())); + connect(ui.mass_unit, SIGNAL(activated(int)), this, SLOT(massChanged())); + connect(ui.moles, SIGNAL(valueChanged(double)), this, SLOT(molesChanged(double))); + connect(ui.molarMass, SIGNAL(valueChanged(double)), this, SLOT(molarMassChanged(double))); + connect(ui.a, SIGNAL(valueChanged(double)), this, SLOT(Vand_aChanged())); + connect(ui.b, SIGNAL(valueChanged(double)), this, SLOT(Vand_bChanged())); + connect(ui.b_unit, SIGNAL(activated(int)), this, SLOT(Vand_bChanged())); + connect(ui.mode, SIGNAL(activated(int)), this, SLOT(setMode(int))); + connect(ui.reset, &QAbstractButton::clicked, this, &gasCalculator::init); } -gasCalculator:: ~gasCalculator() +gasCalculator::~gasCalculator() { } @@ -64,14 +49,14 @@ void gasCalculator::init() { error(RESET_GAS_MESSAGE); - ui.molarMass ->setValue(2.008); - ui.temp ->setValue(273.0); - ui.volume ->setValue(22.400); - ui.pressure ->setValue(1.0); - ui.a ->setValue(0.0); - ui.b ->setValue(0.0); - ui.mass ->setValue(2.016); - ui.moles ->setValue(1.0); + ui.molarMass->setValue(2.008); + ui.temp->setValue(273.0); + ui.volume->setValue(22.400); + ui.pressure->setValue(1.0); + ui.a->setValue(0.0); + ui.b->setValue(0.0); + ui.mass->setValue(2.016); + ui.moles->setValue(1.0); ui.mass_unit->setCurrentIndex(0); ui.pressure_unit->setCurrentIndex(0); @@ -118,8 +103,7 @@ void gasCalculator::setupUnitComboboxes() KalziumUtils::populateUnitCombobox(ui.b_unit, units); } - -int gasCalculator::getCurrentUnitId(QComboBox* comboBox) +int gasCalculator::getCurrentUnitId(QComboBox *comboBox) { return comboBox->itemData(comboBox->currentIndex()).toInt(); } @@ -145,8 +129,7 @@ void gasCalculator::calculateMolarMass() double temp = m_temp.convertTo(KUnitConversion::Kelvin).number(); double b = m_Vand_b.convertTo(KUnitConversion::Liter).number(); - m_molarMass = mass * R * temp / (pressure + m_moles * m_moles * m_Vand_a / volume / volume)\ - / (volume - m_moles * b); + m_molarMass = mass * R * temp / (pressure + m_moles * m_moles * m_Vand_a / volume / volume) / (volume - m_moles * b); ui.molarMass->setValue(m_molarMass); } @@ -168,8 +151,7 @@ void gasCalculator::calculateTemp() double pressure = m_pressure.convertTo(KUnitConversion::Atmosphere).number(); double b = m_Vand_b.convertTo(KUnitConversion::Liter).number(); - double temp = (pressure + (m_moles * m_moles * m_Vand_a / volume / volume))\ - * (volume - m_moles * b) / m_moles / R; + double temp = (pressure + (m_moles * m_moles * m_Vand_a / volume / volume)) * (volume - m_moles * b) / m_moles / R; m_temp = Value(temp, KUnitConversion::Kelvin); m_temp = m_temp.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.temp_unit))); ui.temp->setValue(m_temp.number()); @@ -182,8 +164,7 @@ void gasCalculator::calculateMoles() double temp = m_temp.convertTo(KUnitConversion::Kelvin).number(); double b = m_Vand_b.convertTo(KUnitConversion::Liter).number(); - m_moles = (pressure + m_moles * m_moles * m_Vand_a / volume / volume)\ - * (volume - m_moles * b) / R / temp; + m_moles = (pressure + m_moles * m_moles * m_Vand_a / volume / volume) * (volume - m_moles * b) / R / temp; ui.moles->setValue(m_moles); } @@ -194,14 +175,12 @@ void gasCalculator::calculateMass() double temp = m_temp.convertTo(KUnitConversion::Kelvin).number(); double b = m_Vand_b.convertTo(KUnitConversion::Liter).number(); - double mass = (pressure + m_moles * m_moles * m_Vand_a / volume / volume)\ - * (volume - m_moles * b) * m_molarMass / R / temp; + double mass = (pressure + m_moles * m_moles * m_Vand_a / volume / volume) * (volume - m_moles * b) * m_molarMass / R / temp; m_mass = Value(mass, KUnitConversion::Gram); m_mass = m_mass.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.mass_unit))); ui.mass->setValue(m_mass.number()); } - void gasCalculator::volChanged() { m_vol = Value(ui.volume->value(), KUnitConversion::UnitId(getCurrentUnitId(ui.volume_unit))); @@ -317,7 +296,7 @@ void gasCalculator::error(int mode) case RESET_GAS_MESSAGE: ui.error->setText(QString()); break; - case VOL_ZERO : + case VOL_ZERO: ui.error->setText(i18n("Volume cannot be zero, please enter a valid value.")); break; case GAS_MOLAR_MASS_ZERO: diff --git a/src/calculator/gasCalculator.h b/src/calculator/gasCalculator.h index 47030909ffe2de4df92108eff922871d038b426e..3e6d0876c28378ec9057edf0be502b5d8777abe9 100644 --- a/src/calculator/gasCalculator.h +++ b/src/calculator/gasCalculator.h @@ -22,19 +22,10 @@ const double R = 0.08206; using namespace KUnitConversion; /// This is the enumeration for the error type required in the error(int mode) function -enum ERROR_TYPE_GAS { - RESET_GAS_MESSAGE = 0, - VOL_ZERO, - GAS_MOLAR_MASS_ZERO -}; +enum ERROR_TYPE_GAS { RESET_GAS_MESSAGE = 0, VOL_ZERO, GAS_MOLAR_MASS_ZERO }; /// This is the enumeration for the mode of calculation for the gas calculator -enum MODE_CALCULATION_GAS { - MOLES = 0, - PRESSURE, - TEMPERATURE, - VOLUME -}; +enum MODE_CALCULATION_GAS { MOLES = 0, PRESSURE, TEMPERATURE, VOLUME }; /** * This class implements the gas calculator. It performs basic calculations like @@ -52,13 +43,13 @@ enum MODE_CALCULATION_GAS { * a,b - Van der Val's constants * * @author Kashyap R Puranik -**/ + **/ class gasCalculator : public QWidget { Q_OBJECT public: - explicit gasCalculator(QWidget * parent = nullptr); + explicit gasCalculator(QWidget *parent = nullptr); ~gasCalculator(); public Q_SLOTS: @@ -115,10 +106,10 @@ public Q_SLOTS: void calculate(); /** - * This function is called when an error occurs - * @param mode indicates the mode of error - * Refer ERROR_MODE_GAS for various modes - **/ + * This function is called when an error occurs + * @param mode indicates the mode of error + * Refer ERROR_MODE_GAS for various modes + **/ void error(int); /** diff --git a/src/calculator/nuclearCalculator.cpp b/src/calculator/nuclearCalculator.cpp index 81c8608fd716c9720e2e53d760e5af63a9f62279..5934c4aeb10411209cd89e1d42fa8adfdd2733b6 100644 --- a/src/calculator/nuclearCalculator.cpp +++ b/src/calculator/nuclearCalculator.cpp @@ -10,12 +10,13 @@ #include -#include "prefs.h" #include "kalziumutils.h" +#include "prefs.h" using namespace KUnitConversion; -nuclearCalculator::nuclearCalculator(QWidget * parent) : QFrame(parent) +nuclearCalculator::nuclearCalculator(QWidget *parent) + : QFrame(parent) { ui.setupUi(this); @@ -28,7 +29,7 @@ nuclearCalculator::nuclearCalculator(QWidget * parent) : QFrame(parent) foreach (Element *e, kdo->ElementList) { ui.element->addItem(e->dataAsString(ChemicalDataObject::name)); } -///FIXME + /// FIXME /* The last three elemenents will be removed because information is not available and causes the program to crash when selected. */ int count = ui.element->count(); @@ -39,36 +40,21 @@ nuclearCalculator::nuclearCalculator(QWidget * parent) : QFrame(parent) // initialise data init(); // Connect signals with slots - connect(ui.element, SIGNAL(activated(int)), - this, SLOT(elementChanged(int))); - connect(ui.isotope, SIGNAL(activated(int)), - this, SLOT(isotopeChanged(int))); - connect(ui.halfLife, SIGNAL(valueChanged(double)), - this, SLOT(halfLifeChanged())); - connect(ui.halfLife_unit, SIGNAL(activated(int)), - this, SLOT(halfLifeChanged())); - connect(ui.initAmt, SIGNAL(valueChanged(double)), - this, SLOT(initAmtChanged())); - connect(ui.initAmt_unit, SIGNAL(activated(int)), - this, SLOT(initAmtChanged())); - connect(ui.initAmtType, SIGNAL(activated(int)), - this, SLOT(initAmtChanged())); - connect(ui.finalAmt, SIGNAL(valueChanged(double)), - this, SLOT(finalAmtChanged())); - connect(ui.finalAmt_unit, SIGNAL(activated(int)), - this, SLOT(finalAmtChanged())); - connect(ui.finalAmtType, SIGNAL(activated(int)), - this, SLOT(finalAmtChanged())); - connect(ui.time, SIGNAL(valueChanged(double)), - this, SLOT(timeChanged())); - connect(ui.time_unit, SIGNAL(activated(int)), - this, SLOT(timeChanged())); - connect(ui.slider, &QAbstractSlider::valueChanged, - this, &nuclearCalculator::sliderMoved); - connect(ui.mode, SIGNAL(activated(int)), - this, SLOT(setMode(int))); - connect(ui.reset, &QAbstractButton::clicked, - this, &nuclearCalculator::init); + connect(ui.element, SIGNAL(activated(int)), this, SLOT(elementChanged(int))); + connect(ui.isotope, SIGNAL(activated(int)), this, SLOT(isotopeChanged(int))); + connect(ui.halfLife, SIGNAL(valueChanged(double)), this, SLOT(halfLifeChanged())); + connect(ui.halfLife_unit, SIGNAL(activated(int)), this, SLOT(halfLifeChanged())); + connect(ui.initAmt, SIGNAL(valueChanged(double)), this, SLOT(initAmtChanged())); + connect(ui.initAmt_unit, SIGNAL(activated(int)), this, SLOT(initAmtChanged())); + connect(ui.initAmtType, SIGNAL(activated(int)), this, SLOT(initAmtChanged())); + connect(ui.finalAmt, SIGNAL(valueChanged(double)), this, SLOT(finalAmtChanged())); + connect(ui.finalAmt_unit, SIGNAL(activated(int)), this, SLOT(finalAmtChanged())); + connect(ui.finalAmtType, SIGNAL(activated(int)), this, SLOT(finalAmtChanged())); + connect(ui.time, SIGNAL(valueChanged(double)), this, SLOT(timeChanged())); + connect(ui.time_unit, SIGNAL(activated(int)), this, SLOT(timeChanged())); + connect(ui.slider, &QAbstractSlider::valueChanged, this, &nuclearCalculator::sliderMoved); + connect(ui.mode, SIGNAL(activated(int)), this, SLOT(setMode(int))); + connect(ui.reset, &QAbstractButton::clicked, this, &nuclearCalculator::init); /**************************************************************************/ // Nuclear Calculator setup complete @@ -80,7 +66,7 @@ nuclearCalculator::nuclearCalculator(QWidget * parent) : QFrame(parent) } } -nuclearCalculator:: ~nuclearCalculator() +nuclearCalculator::~nuclearCalculator() { } @@ -89,7 +75,7 @@ void nuclearCalculator::init() { const int ISOTOPE_NUM = 22; // Add all isotope names of Uranium (by default)to the isotope comboBox - QList list = KalziumDataObject::instance()->isotopes(92); + QList list = KalziumDataObject::instance()->isotopes(92); QString isotope; ui.isotope->clear(); @@ -99,12 +85,12 @@ void nuclearCalculator::init() } // initialise the data, initially selected values (Uranium, 92, 238) - ui.element ->setCurrentIndex(91); - ui.isotope ->setCurrentIndex(ISOTOPE_NUM); - ui.halfLife ->setValue(list.at(ISOTOPE_NUM)->halflife()); - ui.initAmt ->setValue(6.0); - ui.finalAmt ->setValue(3.0); - ui.time ->setValue(list.at(ISOTOPE_NUM)->halflife()); + ui.element->setCurrentIndex(91); + ui.isotope->setCurrentIndex(ISOTOPE_NUM); + ui.halfLife->setValue(list.at(ISOTOPE_NUM)->halflife()); + ui.initAmt->setValue(6.0); + ui.finalAmt->setValue(3.0); + ui.time->setValue(list.at(ISOTOPE_NUM)->halflife()); timeUnitCombobox(ui.halfLife_unit); @@ -124,63 +110,48 @@ void nuclearCalculator::init() // Setup of the UI done // Initialise values - m_initAmount = Value(6.0, KUnitConversion::Gram); + m_initAmount = Value(6.0, KUnitConversion::Gram); m_finalAmount = Value(3.0, KUnitConversion::Gram); m_mass = list.at(ISOTOPE_NUM)->mass(); m_time = Value(list.at(ISOTOPE_NUM)->halflife(), KUnitConversion::Year); m_halfLife = Value(list.at(ISOTOPE_NUM)->halflife(), KUnitConversion::Year); - m_element = * KalziumDataObject::instance()->element(92); - m_isotope = * list.at(ISOTOPE_NUM); + m_element = *KalziumDataObject::instance()->element(92); + m_isotope = *list.at(ISOTOPE_NUM); setMode(2); } -void nuclearCalculator::massUnitCombobox(QComboBox* comboBox) +void nuclearCalculator::massUnitCombobox(QComboBox *comboBox) { QList units; - units - << Gram - << Milligram - << Kilogram - << Ton - << Carat - << Pound - << Ounce - << TroyOunce; + units << Gram << Milligram << Kilogram << Ton << Carat << Pound << Ounce << TroyOunce; KalziumUtils::populateUnitCombobox(comboBox, units); comboBox->setCurrentIndex(0); } - -void nuclearCalculator::timeUnitCombobox(QComboBox* comboBox) +void nuclearCalculator::timeUnitCombobox(QComboBox *comboBox) { QList units; - units - << KUnitConversion::Year - << KUnitConversion::Week - << KUnitConversion::Day - << KUnitConversion::Hour - << KUnitConversion::Minute - << KUnitConversion::Second; + units << KUnitConversion::Year << KUnitConversion::Week << KUnitConversion::Day << KUnitConversion::Hour << KUnitConversion::Minute + << KUnitConversion::Second; KalziumUtils::populateUnitCombobox(comboBox, units); comboBox->setCurrentIndex(0); } - // This function is executed when the element is changed void nuclearCalculator::elementChanged(int index) { // set the newly chosen element - m_element = * KalziumDataObject::instance()->element(index + 1); + m_element = *KalziumDataObject::instance()->element(index + 1); // Add all isotope names of Uranium (by default) to the isotope comboBox - QList list = KalziumDataObject::instance()->isotopes(index + 1); - QString isotope; // A temporary string - ui.isotope->clear(); // Clear the contents of the combo box + QList 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) { @@ -189,17 +160,17 @@ void nuclearCalculator::elementChanged(int index) } // Set the halfLife to that of the first isotope of the element. - ui.halfLife->setValue(list. at(0)->halflife()); + ui.halfLife->setValue(list.at(0)->halflife()); // Recalculate and update calculate(); } // This function is executed when the isotope is changed -void nuclearCalculator::isotopeChanged(int index) +void nuclearCalculator::isotopeChanged(int index) { // update the nuclear Calculator int elementNumber = ui.element->currentIndex() + 1; - QList list = KalziumDataObject::instance()->isotopes(elementNumber); + QList list = KalziumDataObject::instance()->isotopes(elementNumber); m_isotope = *list.at(index); // get the halfLife of the new isotope @@ -207,8 +178,7 @@ void nuclearCalculator::isotopeChanged(int index) m_mass = list.at(index)->mass(); // A string in isotope for searching the right unit - int halfLifeUnit = (list.at(index)->halflifeUnit().operator == ("y")) - ? KUnitConversion::Year : KUnitConversion::Second; + int halfLifeUnit = (list.at(index)->halflifeUnit().operator==("y")) ? KUnitConversion::Year : KUnitConversion::Second; QString tempStr; tempStr.setNum(m_mass); @@ -225,7 +195,7 @@ void nuclearCalculator::isotopeChanged(int index) } // This function is executed when the halfLife is changed -void nuclearCalculator::halfLifeChanged() +void nuclearCalculator::halfLifeChanged() { // update the halfLife value m_halfLife = Value(ui.halfLife->value(), getUnitIdFromCombobox(ui.halfLife_unit)); @@ -238,7 +208,7 @@ KUnitConversion::UnitId nuclearCalculator::getUnitIdFromCombobox(QComboBox *comb return KUnitConversion::UnitId(comboBox->itemData(comboBox->currentIndex()).toInt()); } -void nuclearCalculator::initAmtChanged() +void nuclearCalculator::initAmtChanged() { // If quantity is specified in terms of mass, quantity <- (mass, unit) if (ui.initAmtType->currentIndex() == 0) { @@ -246,30 +216,27 @@ void nuclearCalculator::initAmtChanged() m_initAmount = Value(ui.initAmt->value(), getUnitIdFromCombobox(ui.initAmt_unit)); } else { // If quantity is specified in terms of moles quantity <- (moles * atomicMass, unit) ui.initAmt_unit->hide(); - m_initAmount = Value(((ui.initAmt->value()) * m_mass), - getUnitIdFromCombobox(ui.initAmt_unit)); + m_initAmount = Value(((ui.initAmt->value()) * m_mass), getUnitIdFromCombobox(ui.initAmt_unit)); } calculate(); } -void nuclearCalculator::finalAmtChanged() +void nuclearCalculator::finalAmtChanged() { // If quantity is specified in terms of mass, quantity <- (mass, unit) if (ui.finalAmtType->currentIndex() == 0) { - ui.finalAmt_unit ->show(); - m_finalAmount = Value(ui.finalAmt->value(), - getUnitIdFromCombobox(ui.finalAmt_unit)); + ui.finalAmt_unit->show(); + m_finalAmount = Value(ui.finalAmt->value(), getUnitIdFromCombobox(ui.finalAmt_unit)); } else { // If quantity is specified in terms of moles quantity <- (moles * atomicMass, unit) ui.finalAmt_unit->hide(); - m_finalAmount = Value(((ui.finalAmt->value()) * m_mass), - getUnitIdFromCombobox(ui.finalAmt_unit)); + m_finalAmount = Value(((ui.finalAmt->value()) * m_mass), getUnitIdFromCombobox(ui.finalAmt_unit)); } calculate(); } -void nuclearCalculator::sliderMoved(int numHlives) +void nuclearCalculator::sliderMoved(int numHlives) { double num = numHlives / 10.0; m_time = Value(num * m_halfLife.number(), m_halfLife.unit()); @@ -279,12 +246,11 @@ void nuclearCalculator::sliderMoved(int numHlives) ui.numHalfLives->setText(m_time.toString()); } -void nuclearCalculator::timeChanged() +void nuclearCalculator::timeChanged() { m_time = Value(ui.time->value(), getUnitIdFromCombobox(ui.time_unit)); calculate(); - } void nuclearCalculator::setMode(int mode) @@ -323,21 +289,21 @@ void nuclearCalculator::calculate() } switch (m_mode) { - case 0: // calculate initial amount before given time + case 0: // calculate initial amount before given time if (ui.finalAmt->value() == 0.0) { error(FINAL_AMT_ZERO); return; } calculateInitAmount(); break; - case 1: // calculate final amount after given time + case 1: // calculate final amount after given time if (ui.initAmt->value() == 0.0) { error(INIT_AMT_ZERO); return; } calculateFinalAmount(); break; - case 2: // final amount greater than initial + case 2: // final amount greater than initial if (m_finalAmount.number() > m_initAmount.convertTo(m_finalAmount.unit()).number()) { error(FINAL_AMT_GREATER); return; @@ -362,7 +328,7 @@ void nuclearCalculator::calculateInitAmount() // If no time has elapsed, initial and final amounts are the same if (m_time.number() == 0.0) { m_initAmount = m_finalAmount.convertTo(m_initAmount.unit()); - ui.initAmt->setValue (m_initAmount.number()); + ui.initAmt->setValue(m_initAmount.number()); return; } // Calculate the number of halfLives that have elapsed @@ -379,12 +345,11 @@ void nuclearCalculator::calculateFinalAmount() // If no time has elapsed, initial and final amounts are the same if (m_time.number() == 0.0) { m_finalAmount = m_initAmount.convertTo(m_finalAmount.unit()); - ui.finalAmt->setValue (m_finalAmount.number()); + ui.finalAmt->setValue(m_finalAmount.number()); return; } // Calculate the number of halfLives that have elapsed - double ratio = m_time.convertTo(m_halfLife.unit()).number() \ - / m_halfLife.number(); + double ratio = m_time.convertTo(m_halfLife.unit()).number() / m_halfLife.number(); // Calculate the final amount m_finalAmount = Value(m_finalAmount.number() / pow(2.0, ratio), m_initAmount.unit()); // Convert into the required units @@ -396,8 +361,7 @@ void nuclearCalculator::calculateTime() { // If initial and final masses are the same (both units and value) // the time is also 0 - if (m_initAmount.number() == m_finalAmount.number() && - m_initAmount.unit() == m_finalAmount.unit()) { + if (m_initAmount.number() == m_finalAmount.number() && m_initAmount.unit() == m_finalAmount.unit()) { m_time = Value(0.0, m_time.unit()); ui.time->setValue(0.0); return; @@ -408,7 +372,7 @@ void nuclearCalculator::calculateTime() // The number of halfLives (log 2 (x) = log x / log 2) double numHalfLives = log(ratio) / log(2.0); - double time_value = numHalfLives * m_halfLife.number(); + double time_value = numHalfLives * m_halfLife.number(); // Calculate the total time taken Value time = Value(time_value, m_halfLife.unit()); m_time = time.convertTo(getUnitIdFromCombobox(ui.time_unit)); diff --git a/src/calculator/nuclearCalculator.h b/src/calculator/nuclearCalculator.h index 087e981736a168a11f7a602edc2e2490b0d0a329..fbb05e4fd42e4c9a7043ff93d7855321a405973d 100644 --- a/src/calculator/nuclearCalculator.h +++ b/src/calculator/nuclearCalculator.h @@ -9,33 +9,23 @@ #include "kalzium_debug.h" -#include #include +#include +#include "ui_nuclearCalculator.h" #include #include -#include #include -#include "ui_nuclearCalculator.h" +#include // This is required for the unit conversion using namespace KUnitConversion; // This is the enumeration for the error type required in the error(int mode) function -enum ERROR_MODE_NUKE { - RESET_NUKE_MESSAGE = 0, - INIT_AMT_ZERO, - FINAL_AMT_ZERO, - HALFLIFE_ZERO, - FINAL_AMT_GREATER -}; +enum ERROR_MODE_NUKE { RESET_NUKE_MESSAGE = 0, INIT_AMT_ZERO, FINAL_AMT_ZERO, HALFLIFE_ZERO, FINAL_AMT_GREATER }; // This is the enumeration for the mode of calculation in the nuclear calculator -enum MODE_CALCULATION_NUKE { - INIT_AMT =0, - FINAL_AMT, - TIME -}; +enum MODE_CALCULATION_NUKE { INIT_AMT = 0, FINAL_AMT, TIME }; /* * This class implements the nuclear calculator which calculates the amount of substance, @@ -48,7 +38,7 @@ class nuclearCalculator : public QFrame Q_OBJECT public: - explicit nuclearCalculator(QWidget * parent = nullptr); + explicit nuclearCalculator(QWidget *parent = nullptr); ~nuclearCalculator(); public Q_SLOTS: @@ -116,18 +106,18 @@ public Q_SLOTS: void error(int mode); private: - Ui::nuclearCalculator ui; // The user interface + Ui::nuclearCalculator ui; // The user interface - Element m_element; // Current element - Isotope m_isotope; // current isotope + Element m_element; // Current element + Isotope m_isotope; // current isotope - Value m_halfLife; // The halfLife - Value m_initAmount; // initial amount present - Value m_finalAmount; // amount after time - Value m_time; // the time involved in calculation - double m_mass; // the atomic mass of the isotope + Value m_halfLife; // The halfLife + Value m_initAmount; // initial amount present + Value m_finalAmount; // amount after time + Value m_time; // the time involved in calculation + double m_mass; // the atomic mass of the isotope - int m_mode; // the mode of calculation + int m_mode; // the mode of calculation }; #endif // NUCLEARCALCULATOR_H diff --git a/src/calculator/titrationCalculator.cpp b/src/calculator/titrationCalculator.cpp index 5679c9774f6cdfd05f4a7909eabf177f8242d307..e587a60a27e7b669f3429f86cdf5f19f941fca72 100644 --- a/src/calculator/titrationCalculator.cpp +++ b/src/calculator/titrationCalculator.cpp @@ -30,7 +30,8 @@ using namespace std; -titrationCalculator::titrationCalculator(QWidget * parent) : QWidget(parent) +titrationCalculator::titrationCalculator(QWidget *parent) + : QWidget(parent) { xmin = 0; xmax = 50; @@ -44,52 +45,51 @@ titrationCalculator::titrationCalculator(QWidget * parent) : QWidget(parent) uid.tab->setFocus(); plot(); - connect(uid.pushButton, &QAbstractButton::clicked,this, &titrationCalculator::on_pushButton_clicked); - connect(uid.xmin, SIGNAL(valueChanged(double)),this, SLOT(on_xmin_valueChanged(double))); - connect(uid.xmax, SIGNAL(valueChanged(double)),this, SLOT(on_xmax_valueChanged(double))); - connect(uid.ymin, SIGNAL(valueChanged(double)),this, SLOT(on_ymin_valueChanged(double))); - connect(uid.ymax, SIGNAL(valueChanged(double)),this, SLOT(on_ymax_valueChanged(double))); - - - connect(uid.saveimage, &QAbstractButton::clicked,this, &titrationCalculator::on_actionSave_image_triggered); - connect(uid.open, &QAbstractButton::clicked,this, &titrationCalculator::on_actionOpen_triggered); - connect(uid.save, &QAbstractButton::clicked,this, &titrationCalculator::on_actionSave_triggered); - connect(uid.newfile, &QAbstractButton::clicked,this, &titrationCalculator::on_actionNew_triggered); - connect(uid.rapidhelp, &QAbstractButton::clicked,this, &titrationCalculator::on_actionRapid_Help_triggered); + connect(uid.pushButton, &QAbstractButton::clicked, this, &titrationCalculator::on_pushButton_clicked); + connect(uid.xmin, SIGNAL(valueChanged(double)), this, SLOT(on_xmin_valueChanged(double))); + connect(uid.xmax, SIGNAL(valueChanged(double)), this, SLOT(on_xmax_valueChanged(double))); + connect(uid.ymin, SIGNAL(valueChanged(double)), this, SLOT(on_ymin_valueChanged(double))); + connect(uid.ymax, SIGNAL(valueChanged(double)), this, SLOT(on_ymax_valueChanged(double))); + + connect(uid.saveimage, &QAbstractButton::clicked, this, &titrationCalculator::on_actionSave_image_triggered); + connect(uid.open, &QAbstractButton::clicked, this, &titrationCalculator::on_actionOpen_triggered); + connect(uid.save, &QAbstractButton::clicked, this, &titrationCalculator::on_actionSave_triggered); + connect(uid.newfile, &QAbstractButton::clicked, this, &titrationCalculator::on_actionNew_triggered); + connect(uid.rapidhelp, &QAbstractButton::clicked, this, &titrationCalculator::on_actionRapid_Help_triggered); } -titrationCalculator:: ~titrationCalculator() +titrationCalculator::~titrationCalculator() { } void titrationCalculator::plot() { width = int(xmax - xmin); - //now I'm preparing the kplot widget + // now I'm preparing the kplot widget uid.kplotwidget->removeAllPlotObjects(); - uid.kplotwidget->setLimits(xmin, xmax, ymin, ymax); //now I need to set the limits of the plot + uid.kplotwidget->setLimits(xmin, xmax, ymin, ymax); // now I need to set the limits of the plot - KPlotObject *kpor = new KPlotObject(Qt::red,KPlotObject::Lines); + KPlotObject *kpor = new KPlotObject(Qt::red, KPlotObject::Lines); KPlotObject *kpog = new KPlotObject(Qt::green, KPlotObject::Lines); KPlotObject *kpob = new KPlotObject(Qt::blue, KPlotObject::Lines); redplot = QStringLiteral("item(0,0) || uid.tableWidget->item(0,0)->text().isEmpty()) { - //go on + if (!uid.tableWidget->item(0, 0) || uid.tableWidget->item(0, 0)->text().isEmpty()) { + // go on } else { char yvalue[80]; int tmpy = 0; for (int i = 0; i < uid.tableWidget->rowCount(); ++i) { - if (!uid.tableWidget->item(i,0) || uid.tableWidget->item(i,0)->text().isEmpty()) { + if (!uid.tableWidget->item(i, 0) || uid.tableWidget->item(i, 0)->text().isEmpty()) { break; } else { - if (uid.tableWidget->item(i,0)->data(Qt::DisplayRole).toString() == uid.yaxis->text()) { - QString yvalueq = uid.tableWidget->item(i,1)->data(Qt::DisplayRole).toString(); + if (uid.tableWidget->item(i, 0)->data(Qt::DisplayRole).toString() == uid.yaxis->text()) { + QString yvalueq = uid.tableWidget->item(i, 1)->data(Qt::DisplayRole).toString(); QByteArray ba = yvalueq.toLatin1(); char *yvaluen = ba.data(); - strcpy(yvalue,yvaluen); + strcpy(yvalue, yvaluen); tmpy = 1; } } @@ -100,10 +100,10 @@ void titrationCalculator::plot() uid.xaxis->setText(i18n("nothing")); } if (tmpy == 0) { - QMessageBox::critical(this,i18n("Error"),i18n("Unable to find an equation for Y-axis variable.")); + QMessageBox::critical(this, i18n("Error"), i18n("Unable to find an equation for Y-axis variable.")); } else { - //now we have to solve the system of equations NOTE:yvalue contains the equation of Y-axis variable - //we iterates the process until you have an equation in one only unknown variable or a numeric expression + // now we have to solve the system of equations NOTE:yvalue contains the equation of Y-axis variable + // we iterates the process until you have an equation in one only unknown variable or a numeric expression mreporto = solve(yvalue); while (end == 0 || lettere == 1) { QByteArray ba = mreporto.toLatin1(); @@ -113,12 +113,12 @@ void titrationCalculator::plot() break; } if (iter > 100) { - break; //preventing from an endless iteration + break; // preventing from an endless iteration } mreporto = solve(tmreport); } } - //if (mreporto!="") uid.note->setText("Theoretical Curve: "+mreporto); + // if (mreporto!="") uid.note->setText("Theoretical Curve: "+mreporto); if (!mreporto.isEmpty()) { uid.note->setText(i18n("Theoretical curve") + ": " + mreporto); for (int i = int(xmin); i < int(xmax); ++i) { @@ -129,45 +129,41 @@ void titrationCalculator::plot() QString istr; istr.append(QStringLiteral("%1").arg((id))); - //now i'm using QScript language to solve the expression - //in a future we can consider to change it supporting some backends, but it's really complex - QString myscript = solvex(tmreporto,istr); + // now i'm using QScript language to solve the expression + // in a future we can consider to change it supporting some backends, but it's really complex + QString myscript = solvex(tmreporto, istr); QScriptValue three = myEngine.evaluate(myscript); double tvalue = three.toNumber(); kpor->addPoint(id, tvalue); - redplot = redplot - + ' ' - + QString::number((id * 10) + 5).replace(QChar(','), QChar('.')) - + ',' - + QString::number((ymax - tvalue) * 10).replace(QChar(','), QChar('.')); + redplot = redplot + ' ' + QString::number((id * 10) + 5).replace(QChar(','), QChar('.')) + ',' + + QString::number((ymax - tvalue) * 10).replace(QChar(','), QChar('.')); } } temponu = 0; - } //here ends the equations mode + } // here ends the equations mode - //uid.tableWidget_2->sortItems(1, Qt::AscendingOrder); //seems that the sorting doesn't work correctly + // uid.tableWidget_2->sortItems(1, Qt::AscendingOrder); //seems that the sorting doesn't work correctly if (!uid.tableWidget_2->item(0, 0) || uid.tableWidget_2->item(0, 0)->text().isEmpty()) { - //go on + // go on } else { - //now we can plot the values + // now we can plot the values double a, b, c, d, xval; QVarLengthArray px(uid.tableWidget_2->rowCount()); QVarLengthArray py(uid.tableWidget_2->rowCount()); int totaldata = 0; for (int i = 0; i < uid.tableWidget_2->rowCount(); ++i) { - if (!uid.tableWidget_2->item(i,0) || uid.tableWidget_2->item(i, 0)->text().isEmpty()) { + if (!uid.tableWidget_2->item(i, 0) || uid.tableWidget_2->item(i, 0)->text().isEmpty()) { break; } else { ++totaldata; - kpob->addPoint(uid.tableWidget_2->item(i,1)->data(Qt::DisplayRole).toDouble(), uid.tableWidget_2->item(i,0)->data(Qt::DisplayRole).toDouble()); - py[i] = uid.tableWidget_2->item(i,0)->data(Qt::DisplayRole).toDouble(); - px[i] = uid.tableWidget_2->item(i,1)->data(Qt::DisplayRole).toDouble(); - blueplot = blueplot - + ' ' - + QString::number((uid.tableWidget_2->item(i,1)->data(Qt::DisplayRole).toDouble() * 10) + 5).replace(QChar(','), QChar('.')) - + ',' - + QString::number((ymax-uid.tableWidget_2->item(i, 0)->data(Qt::DisplayRole).toDouble()) * 10).replace(QChar(','), QChar('.')); + kpob->addPoint(uid.tableWidget_2->item(i, 1)->data(Qt::DisplayRole).toDouble(), + uid.tableWidget_2->item(i, 0)->data(Qt::DisplayRole).toDouble()); + py[i] = uid.tableWidget_2->item(i, 0)->data(Qt::DisplayRole).toDouble(); + px[i] = uid.tableWidget_2->item(i, 1)->data(Qt::DisplayRole).toDouble(); + blueplot = blueplot + ' ' + + QString::number((uid.tableWidget_2->item(i, 1)->data(Qt::DisplayRole).toDouble() * 10) + 5).replace(QChar(','), QChar('.')) + ',' + + QString::number((ymax - uid.tableWidget_2->item(i, 0)->data(Qt::DisplayRole).toDouble()) * 10).replace(QChar(','), QChar('.')); } } a = py[totaldata - 1] - py[0]; @@ -181,50 +177,36 @@ void titrationCalculator::plot() double cn = 0.0; int th = 0; for (int i = 1; i < (totaldata - 1); ++i) { - //now i'm using the value of the points to fit the curve + // now i'm using the value of the points to fit the curve double ci = ((setttanh((py[i] - d) / a)) / b) - px[i]; if ((ci * 0) == 0) { cn = cn + ci; ++th; } } - //c = cn/(th); it doesn't wok, but i found out this little hack. The strange thing is that in the standalone application it works fine. + // c = cn/(th); it doesn't wok, but i found out this little hack. The strange thing is that in the standalone application it works fine. c = cn / (th * 2); - //THIS IS THE PLOT OF APPROXIMATED CURVE + // THIS IS THE PLOT OF APPROXIMATED CURVE for (int i = int(xmin); i < (int(xmax)); ++i) { double id = i; xval = (a * tanh(b * (id + c))) + d; kpog->addPoint(id, xval); - greenplot = greenplot - + ' ' - + QString::number((id * 10) + 5).replace(QChar(','), QChar('.')) - + ',' - + QString::number((ymax-xval) * 10).replace(QChar(','), QChar('.')); + greenplot = greenplot + ' ' + QString::number((id * 10) + 5).replace(QChar(','), QChar('.')) + ',' + + QString::number((ymax - xval) * 10).replace(QChar(','), QChar('.')); } - //THIS IS THE EQUIVALENCE POINT (THE INFLECTION OF THE CURVE) + // THIS IS THE EQUIVALENCE POINT (THE INFLECTION OF THE CURVE) QString es = QString::number(-c); QString as = QString::number(a); QString bs = QString::number(b); QString cs = QString::number(c); QString ds = QString::number(d); - QString tempon = uid.note->toPlainText()+QChar('\n'); + QString tempon = uid.note->toPlainText() + QChar('\n'); if (temponu != 0) { tempon = QLatin1String(""); } - uid.note->setText(tempon - + '\n' - + i18n("Approximated curve") - + ": " - + as - + "*tanh(" - + bs - + "*(x+"+cs+"))+" - + ds - +'\n' - + i18n("Equivalence point") - + ": " - + es); - } //here ends the experimental values mode + uid.note->setText(tempon + '\n' + i18n("Approximated curve") + ": " + as + "*tanh(" + bs + "*(x+" + cs + "))+" + ds + '\n' + i18n("Equivalence point") + + ": " + es); + } // here ends the experimental values mode uid.kplotwidget->addPlotObject(kpor); uid.kplotwidget->addPlotObject(kpog); @@ -233,7 +215,6 @@ void titrationCalculator::plot() redplot = redplot + "\" style=\"stroke:red;fill:none\"/> "; blueplot = blueplot + "\" style=\"stroke:blue;fill:none\"/> "; greenplot = greenplot + "\" style=\"stroke:green;fill:none\"/> "; - } double titrationCalculator::setttanh(double x) @@ -243,27 +224,44 @@ double titrationCalculator::setttanh(double x) return temp; } - QString titrationCalculator::solve(char *yvalue) { - QString mreport; lettere = 0; - //now we have to solve the system of equations - //yvalue contains the equation of Y-axis variable + // now we have to solve the system of equations + // yvalue contains the equation of Y-axis variable QString tempy = QLatin1String(""); end = 1; mreport = QLatin1String(""); QString tempyval; QString ptem; for (int i = 0; strlen(yvalue) + 1; ++i) { - if (!(yvalue[i]=='q' || yvalue[i]=='w' || yvalue[i]=='e' || yvalue[i]=='r' || yvalue[i]=='t' || yvalue[i]=='y' || yvalue[i]=='u' || yvalue[i]=='i' || yvalue[i]=='o' || yvalue[i]=='p' || yvalue[i]=='a' || yvalue[i]=='s' || yvalue[i]=='d' || yvalue[i]=='f' || yvalue[i]=='g' || yvalue[i]=='h' || yvalue[i]=='j' || yvalue[i]=='k' || yvalue[i]=='l' || yvalue[i]=='z' || yvalue[i]=='x' || yvalue[i]=='c' || yvalue[i]=='v' || yvalue[i]=='b' || yvalue[i]=='n' || yvalue[i]=='m' || yvalue[i]=='+' || yvalue[i]=='-' || yvalue[i]=='^' || yvalue[i]=='*' || yvalue[i]=='/' || yvalue[i]=='(' || yvalue[i]==')' || yvalue[i]=='Q' || yvalue[i]=='W' || yvalue[i]=='E' || yvalue[i]=='R' || yvalue[i]=='T' || yvalue[i]=='Y' || yvalue[i]=='U' || yvalue[i]=='I' || yvalue[i]=='O' || yvalue[i]=='P' || yvalue[i]=='A' || yvalue[i]=='S' || yvalue[i]=='D' || yvalue[i]=='F' || yvalue[i]=='G' || yvalue[i]=='H' || yvalue[i]=='J' || yvalue[i]=='K' || yvalue[i]=='L' || yvalue[i]=='Z' || yvalue[i]=='X' || yvalue[i]=='C' || yvalue[i]=='V' || yvalue[i]=='B' || yvalue[i]=='N' || yvalue[i]=='M' || yvalue[i]=='1' || yvalue[i]=='2' || yvalue[i]=='3' || yvalue[i]=='4' || yvalue[i]=='5' || yvalue[i]=='6' || yvalue[i]=='7' || yvalue[i]=='8' || yvalue[i]=='9' || yvalue[i]=='0' || yvalue[i]=='.' || yvalue[i]==',')) { - break; //if current value is not a permitted value, this means that something is wrong + if (!(yvalue[i] == 'q' || yvalue[i] == 'w' || yvalue[i] == 'e' || yvalue[i] == 'r' || yvalue[i] == 't' || yvalue[i] == 'y' || yvalue[i] == 'u' + || yvalue[i] == 'i' || yvalue[i] == 'o' || yvalue[i] == 'p' || yvalue[i] == 'a' || yvalue[i] == 's' || yvalue[i] == 'd' || yvalue[i] == 'f' + || yvalue[i] == 'g' || yvalue[i] == 'h' || yvalue[i] == 'j' || yvalue[i] == 'k' || yvalue[i] == 'l' || yvalue[i] == 'z' || yvalue[i] == 'x' + || yvalue[i] == 'c' || yvalue[i] == 'v' || yvalue[i] == 'b' || yvalue[i] == 'n' || yvalue[i] == 'm' || yvalue[i] == '+' || yvalue[i] == '-' + || yvalue[i] == '^' || yvalue[i] == '*' || yvalue[i] == '/' || yvalue[i] == '(' || yvalue[i] == ')' || yvalue[i] == 'Q' || yvalue[i] == 'W' + || yvalue[i] == 'E' || yvalue[i] == 'R' || yvalue[i] == 'T' || yvalue[i] == 'Y' || yvalue[i] == 'U' || yvalue[i] == 'I' || yvalue[i] == 'O' + || yvalue[i] == 'P' || yvalue[i] == 'A' || yvalue[i] == 'S' || yvalue[i] == 'D' || yvalue[i] == 'F' || yvalue[i] == 'G' || yvalue[i] == 'H' + || yvalue[i] == 'J' || yvalue[i] == 'K' || yvalue[i] == 'L' || yvalue[i] == 'Z' || yvalue[i] == 'X' || yvalue[i] == 'C' || yvalue[i] == 'V' + || yvalue[i] == 'B' || yvalue[i] == 'N' || yvalue[i] == 'M' || yvalue[i] == '1' || yvalue[i] == '2' || yvalue[i] == '3' || yvalue[i] == '4' + || yvalue[i] == '5' || yvalue[i] == '6' || yvalue[i] == '7' || yvalue[i] == '8' || yvalue[i] == '9' || yvalue[i] == '0' || yvalue[i] == '.' + || yvalue[i] == ',')) { + break; // if current value is not a permitted value, this means that something is wrong } - if (yvalue[i]=='q' || yvalue[i]=='w' || yvalue[i]=='e' || yvalue[i]=='r' || yvalue[i]=='t' || yvalue[i]=='y' || yvalue[i]=='u' || yvalue[i]=='i' || yvalue[i]=='o' || yvalue[i]=='p' || yvalue[i]=='a' || yvalue[i]=='s' || yvalue[i]=='d' || yvalue[i]=='f' || yvalue[i]=='g' || yvalue[i]=='h' || yvalue[i]=='j' || yvalue[i]=='k' || yvalue[i]=='l' || yvalue[i]=='z' || yvalue[i]=='x' || yvalue[i]=='c' || yvalue[i]=='v' || yvalue[i]=='b' || yvalue[i]=='n' || yvalue[i]=='m' || yvalue[i]=='Q' || yvalue[i]=='W' || yvalue[i]=='E' || yvalue[i]=='R' || yvalue[i]=='T' || yvalue[i]=='Y' || yvalue[i]=='U' || yvalue[i]=='I' || yvalue[i]=='O' || yvalue[i]=='P' || yvalue[i]=='A' || yvalue[i]=='S' || yvalue[i]=='D' || yvalue[i]=='F' || yvalue[i]=='G' || yvalue[i]=='H' || yvalue[i]=='J' || yvalue[i]=='K' || yvalue[i]=='L' || yvalue[i]=='Z' || yvalue[i]=='X' || yvalue[i]=='C' || yvalue[i]=='V' || yvalue[i]=='B' || yvalue[i]=='N' || yvalue[i]=='M' || yvalue[i]=='.' || yvalue[i]==',') { - lettere = 1; //if lettere == 0 then the equation contains only mnumbers + if (yvalue[i] == 'q' || yvalue[i] == 'w' || yvalue[i] == 'e' || yvalue[i] == 'r' || yvalue[i] == 't' || yvalue[i] == 'y' || yvalue[i] == 'u' + || yvalue[i] == 'i' || yvalue[i] == 'o' || yvalue[i] == 'p' || yvalue[i] == 'a' || yvalue[i] == 's' || yvalue[i] == 'd' || yvalue[i] == 'f' + || yvalue[i] == 'g' || yvalue[i] == 'h' || yvalue[i] == 'j' || yvalue[i] == 'k' || yvalue[i] == 'l' || yvalue[i] == 'z' || yvalue[i] == 'x' + || yvalue[i] == 'c' || yvalue[i] == 'v' || yvalue[i] == 'b' || yvalue[i] == 'n' || yvalue[i] == 'm' || yvalue[i] == 'Q' || yvalue[i] == 'W' + || yvalue[i] == 'E' || yvalue[i] == 'R' || yvalue[i] == 'T' || yvalue[i] == 'Y' || yvalue[i] == 'U' || yvalue[i] == 'I' || yvalue[i] == 'O' + || yvalue[i] == 'P' || yvalue[i] == 'A' || yvalue[i] == 'S' || yvalue[i] == 'D' || yvalue[i] == 'F' || yvalue[i] == 'G' || yvalue[i] == 'H' + || yvalue[i] == 'J' || yvalue[i] == 'K' || yvalue[i] == 'L' || yvalue[i] == 'Z' || yvalue[i] == 'X' || yvalue[i] == 'C' || yvalue[i] == 'V' + || yvalue[i] == 'B' || yvalue[i] == 'N' || yvalue[i] == 'M' || yvalue[i] == '.' || yvalue[i] == ',') { + lettere = 1; // if lettere == 0 then the equation contains only mnumbers } - if (yvalue[i]=='+' || yvalue[i]=='-' || yvalue[i]=='^' || yvalue[i]=='*' || yvalue[i]=='/' || yvalue[i]=='(' || yvalue[i]==')' || yvalue[i]=='1' || yvalue[i]=='2' || yvalue[i]=='3' || yvalue[i]=='4' || yvalue[i]=='5' || yvalue[i]=='6' || yvalue[i]=='7' || yvalue[i]=='8' || yvalue[i]=='9' || yvalue[i]=='0' || yvalue[i]=='.' || yvalue[i]==',') { + if (yvalue[i] == '+' || yvalue[i] == '-' || yvalue[i] == '^' || yvalue[i] == '*' || yvalue[i] == '/' || yvalue[i] == '(' || yvalue[i] == ')' + || yvalue[i] == '1' || yvalue[i] == '2' || yvalue[i] == '3' || yvalue[i] == '4' || yvalue[i] == '5' || yvalue[i] == '6' || yvalue[i] == '7' + || yvalue[i] == '8' || yvalue[i] == '9' || yvalue[i] == '0' || yvalue[i] == '.' || yvalue[i] == ',') { tempyval = tempyval + QString(yvalue[i]); } else { tempy = tempy + QString(yvalue[i]); @@ -285,9 +283,12 @@ QString titrationCalculator::solve(char *yvalue) tempy = QLatin1String(""); end = 1; } - if (tempy!=uid.xaxis->text()) { - if (yvalue[i]=='+' || yvalue[i]=='-' || yvalue[i]=='^' || yvalue[i]=='*' || yvalue[i]=='/' || yvalue[i]=='(' || yvalue[i]==')' || yvalue[i]=='1' || yvalue[i]=='2' || yvalue[i]=='3' || yvalue[i]=='4' || yvalue[i]=='5' || yvalue[i]=='6' || yvalue[i]=='7' || yvalue[i]=='8' || yvalue[i]=='9' || yvalue[i]=='0' || yvalue[i]=='.' || yvalue[i]==',') { - //actually nothing + if (tempy != uid.xaxis->text()) { + if (yvalue[i] == '+' || yvalue[i] == '-' || yvalue[i] == '^' || yvalue[i] == '*' || yvalue[i] == '/' || yvalue[i] == '(' + || yvalue[i] == ')' || yvalue[i] == '1' || yvalue[i] == '2' || yvalue[i] == '3' || yvalue[i] == '4' || yvalue[i] == '5' + || yvalue[i] == '6' || yvalue[i] == '7' || yvalue[i] == '8' || yvalue[i] == '9' || yvalue[i] == '0' || yvalue[i] == '.' + || yvalue[i] == ',') { + // actually nothing } else { end = 0; } @@ -301,16 +302,15 @@ QString titrationCalculator::solve(char *yvalue) tempyval = QLatin1String(""); } return mreport; - } -QString titrationCalculator::solvex(char *yvalue, const QString &dnum) { - +QString titrationCalculator::solvex(char *yvalue, const QString &dnum) +{ QString mreport = QLatin1String(""); lettere = 0; - //now we have to solve the system of equations - //yvalue contains the equation of Y-axis variable - //Remember that the function to elevate to power is Math.pow(b,e) + // now we have to solve the system of equations + // yvalue contains the equation of Y-axis variable + // Remember that the function to elevate to power is Math.pow(b,e) QString tempy; QString tempyold; QString tempyolda = QLatin1String(""); @@ -319,22 +319,38 @@ QString titrationCalculator::solvex(char *yvalue, const QString &dnum) { QString tempyval; tempy = QLatin1String(""); for (int i = 0; strlen(yvalue) + 1; ++i) { - if (!(yvalue[i]=='q' || yvalue[i]=='w' || yvalue[i]=='e' || yvalue[i]=='r' || yvalue[i]=='t' || yvalue[i]=='y' || yvalue[i]=='u' || yvalue[i]=='i' || yvalue[i]=='o' || yvalue[i]=='p' || yvalue[i]=='a' || yvalue[i]=='s' || yvalue[i]=='d' || yvalue[i]=='f' || yvalue[i]=='g' || yvalue[i]=='h' || yvalue[i]=='j' || yvalue[i]=='k' || yvalue[i]=='l' || yvalue[i]=='z' || yvalue[i]=='x' || yvalue[i]=='c' || yvalue[i]=='v' || yvalue[i]=='b' || yvalue[i]=='n' || yvalue[i]=='m' || yvalue[i]=='+' || yvalue[i]=='-' || yvalue[i]=='^' || yvalue[i]=='*' || yvalue[i]=='/' || yvalue[i]=='(' || yvalue[i]==')' || yvalue[i]=='Q' || yvalue[i]=='W' || yvalue[i]=='E' || yvalue[i]=='R' || yvalue[i]=='T' || yvalue[i]=='Y' || yvalue[i]=='U' || yvalue[i]=='I' || yvalue[i]=='O' || yvalue[i]=='P' || yvalue[i]=='A' || yvalue[i]=='S' || yvalue[i]=='D' || yvalue[i]=='F' || yvalue[i]=='G' || yvalue[i]=='H' || yvalue[i]=='J' || yvalue[i]=='K' || yvalue[i]=='L' || yvalue[i]=='Z' || yvalue[i]=='X' || yvalue[i]=='C' || yvalue[i]=='V' || yvalue[i]=='B' || yvalue[i]=='N' || yvalue[i]=='M' || yvalue[i]=='1' || yvalue[i]=='2' || yvalue[i]=='3' || yvalue[i]=='4' || yvalue[i]=='5' || yvalue[i]=='6' || yvalue[i]=='7' || yvalue[i]=='8' || yvalue[i]=='9' || yvalue[i]=='0' || yvalue[i]=='.' || yvalue[i]==',')) { - break; //if current value is not a permitted value, this means that something is wrong + if (!(yvalue[i] == 'q' || yvalue[i] == 'w' || yvalue[i] == 'e' || yvalue[i] == 'r' || yvalue[i] == 't' || yvalue[i] == 'y' || yvalue[i] == 'u' + || yvalue[i] == 'i' || yvalue[i] == 'o' || yvalue[i] == 'p' || yvalue[i] == 'a' || yvalue[i] == 's' || yvalue[i] == 'd' || yvalue[i] == 'f' + || yvalue[i] == 'g' || yvalue[i] == 'h' || yvalue[i] == 'j' || yvalue[i] == 'k' || yvalue[i] == 'l' || yvalue[i] == 'z' || yvalue[i] == 'x' + || yvalue[i] == 'c' || yvalue[i] == 'v' || yvalue[i] == 'b' || yvalue[i] == 'n' || yvalue[i] == 'm' || yvalue[i] == '+' || yvalue[i] == '-' + || yvalue[i] == '^' || yvalue[i] == '*' || yvalue[i] == '/' || yvalue[i] == '(' || yvalue[i] == ')' || yvalue[i] == 'Q' || yvalue[i] == 'W' + || yvalue[i] == 'E' || yvalue[i] == 'R' || yvalue[i] == 'T' || yvalue[i] == 'Y' || yvalue[i] == 'U' || yvalue[i] == 'I' || yvalue[i] == 'O' + || yvalue[i] == 'P' || yvalue[i] == 'A' || yvalue[i] == 'S' || yvalue[i] == 'D' || yvalue[i] == 'F' || yvalue[i] == 'G' || yvalue[i] == 'H' + || yvalue[i] == 'J' || yvalue[i] == 'K' || yvalue[i] == 'L' || yvalue[i] == 'Z' || yvalue[i] == 'X' || yvalue[i] == 'C' || yvalue[i] == 'V' + || yvalue[i] == 'B' || yvalue[i] == 'N' || yvalue[i] == 'M' || yvalue[i] == '1' || yvalue[i] == '2' || yvalue[i] == '3' || yvalue[i] == '4' + || yvalue[i] == '5' || yvalue[i] == '6' || yvalue[i] == '7' || yvalue[i] == '8' || yvalue[i] == '9' || yvalue[i] == '0' || yvalue[i] == '.' + || yvalue[i] == ',')) { + break; // if current value is not a permitted value, this means that something is wrong } - if (yvalue[i]=='q' || yvalue[i]=='w' || yvalue[i]=='e' || yvalue[i]=='r' || yvalue[i]=='t' || yvalue[i]=='y' || yvalue[i]=='u' || yvalue[i]=='i' || yvalue[i]=='o' || yvalue[i]=='p' || yvalue[i]=='a' || yvalue[i]=='s' || yvalue[i]=='d' || yvalue[i]=='f' || yvalue[i]=='g' || yvalue[i]=='h' || yvalue[i]=='j' || yvalue[i]=='k' || yvalue[i]=='l' || yvalue[i]=='z' || yvalue[i]=='x' || yvalue[i]=='c' || yvalue[i]=='v' || yvalue[i]=='b' || yvalue[i]=='n' || yvalue[i]=='m' || yvalue[i]=='Q' || yvalue[i]=='W' || yvalue[i]=='E' || yvalue[i]=='R' || yvalue[i]=='T' || yvalue[i]=='Y' || yvalue[i]=='U' || yvalue[i]=='I' || yvalue[i]=='O' || yvalue[i]=='P' || yvalue[i]=='A' || yvalue[i]=='S' || yvalue[i]=='D' || yvalue[i]=='F' || yvalue[i]=='G' || yvalue[i]=='H' || yvalue[i]=='J' || yvalue[i]=='K' || yvalue[i]=='L' || yvalue[i]=='Z' || yvalue[i]=='X' || yvalue[i]=='C' || yvalue[i]=='V' || yvalue[i]=='B' || yvalue[i]=='N' || yvalue[i]=='M' || yvalue[i]=='.' || yvalue[i]==',') { - tempy = tempy + yvalue[i]; //if lettere == 0 then the equation contains only mnumbers + if (yvalue[i] == 'q' || yvalue[i] == 'w' || yvalue[i] == 'e' || yvalue[i] == 'r' || yvalue[i] == 't' || yvalue[i] == 'y' || yvalue[i] == 'u' + || yvalue[i] == 'i' || yvalue[i] == 'o' || yvalue[i] == 'p' || yvalue[i] == 'a' || yvalue[i] == 's' || yvalue[i] == 'd' || yvalue[i] == 'f' + || yvalue[i] == 'g' || yvalue[i] == 'h' || yvalue[i] == 'j' || yvalue[i] == 'k' || yvalue[i] == 'l' || yvalue[i] == 'z' || yvalue[i] == 'x' + || yvalue[i] == 'c' || yvalue[i] == 'v' || yvalue[i] == 'b' || yvalue[i] == 'n' || yvalue[i] == 'm' || yvalue[i] == 'Q' || yvalue[i] == 'W' + || yvalue[i] == 'E' || yvalue[i] == 'R' || yvalue[i] == 'T' || yvalue[i] == 'Y' || yvalue[i] == 'U' || yvalue[i] == 'I' || yvalue[i] == 'O' + || yvalue[i] == 'P' || yvalue[i] == 'A' || yvalue[i] == 'S' || yvalue[i] == 'D' || yvalue[i] == 'F' || yvalue[i] == 'G' || yvalue[i] == 'H' + || yvalue[i] == 'J' || yvalue[i] == 'K' || yvalue[i] == 'L' || yvalue[i] == 'Z' || yvalue[i] == 'X' || yvalue[i] == 'C' || yvalue[i] == 'V' + || yvalue[i] == 'B' || yvalue[i] == 'N' || yvalue[i] == 'M' || yvalue[i] == '.' || yvalue[i] == ',') { + tempy = tempy + yvalue[i]; // if lettere == 0 then the equation contains only mnumbers } - if (yvalue[i]=='+' || yvalue[i]=='-' || yvalue[i]=='^' || yvalue[i]=='*' || yvalue[i]=='/' || yvalue[i]=='(' || yvalue[i]==')' || yvalue[i]=='1' || yvalue[i]=='2' || yvalue[i]=='3' || yvalue[i]=='4' || yvalue[i]=='5' || yvalue[i]=='6' || yvalue[i]=='7' || yvalue[i]=='8' || yvalue[i]=='9' || yvalue[i]=='0' || yvalue[i]=='.' || yvalue[i]==',') { + if (yvalue[i] == '+' || yvalue[i] == '-' || yvalue[i] == '^' || yvalue[i] == '*' || yvalue[i] == '/' || yvalue[i] == '(' || yvalue[i] == ')' + || yvalue[i] == '1' || yvalue[i] == '2' || yvalue[i] == '3' || yvalue[i] == '4' || yvalue[i] == '5' || yvalue[i] == '6' || yvalue[i] == '7' + || yvalue[i] == '8' || yvalue[i] == '9' || yvalue[i] == '0' || yvalue[i] == '.' || yvalue[i] == ',') { if (!tempyolda.isEmpty()) { tempy = tempy + yvalue[i]; if (tempyolda == uid.xaxis->text()) { tempyolda = dnum; } - tempyval = tempyval - + QStringLiteral("Math.pow(") - + tempyolda + QChar(',') - + tempy + QChar(')'); + tempyval = tempyval + QStringLiteral("Math.pow(") + tempyolda + QChar(',') + tempy + QChar(')'); tempyolda = QLatin1String(""); tempyold = QLatin1String(""); olda = 1; @@ -343,22 +359,21 @@ QString titrationCalculator::solvex(char *yvalue, const QString &dnum) { tempyolda = tempyold; } else { tempyold = QLatin1String(""); - if (((olda != 1) && (yvalue[i + 1] != '^')) || (yvalue[i] == '+' || yvalue[i] == '-' || yvalue[i] == '^' || yvalue[i] == '*' || yvalue[i] == '/' || yvalue[i] == '(' || yvalue[i] == ')')) { + if (((olda != 1) && (yvalue[i + 1] != '^')) + || (yvalue[i] == '+' || yvalue[i] == '-' || yvalue[i] == '^' || yvalue[i] == '*' || yvalue[i] == '/' || yvalue[i] == '(' + || yvalue[i] == ')')) { tempyval = tempyval + QString(yvalue[i]); } } } else { if (!tempyolda.isEmpty()) { - tempyval = tempyval - + QStringLiteral("Math.pow(") - + tempyolda + QChar(',') - + tempy + QChar(')'); + tempyval = tempyval + QStringLiteral("Math.pow(") + tempyolda + QChar(',') + tempy + QChar(')'); tempyolda = QLatin1String(""); tempyold = QLatin1String(""); olda = 1; } - if ((tempy==uid.xaxis->text()) && (!tempyolda.isEmpty())) { + if ((tempy == uid.xaxis->text()) && (!tempyolda.isEmpty())) { if (yvalue[i + 1] != '^') { tempyval = tempyval + dnum; } @@ -371,32 +386,32 @@ QString titrationCalculator::solvex(char *yvalue, const QString &dnum) { } tempyval = QLatin1String(""); } - //QMessageBox::information(this, "report", mreport); + // QMessageBox::information(this, "report", mreport); return mreport; } void titrationCalculator::on_xmin_valueChanged(double val) { xmin = val; - on_pushButton_clicked(); //please take note that calling directly the plot() function will give a wrong value for equivalence point + on_pushButton_clicked(); // please take note that calling directly the plot() function will give a wrong value for equivalence point } void titrationCalculator::on_xmax_valueChanged(double val) { xmax = val; - on_pushButton_clicked(); //please take note that calling directly the plot() function will give a wrong value for equivalence point + on_pushButton_clicked(); // please take note that calling directly the plot() function will give a wrong value for equivalence point } void titrationCalculator::on_ymin_valueChanged(double val) { ymin = val; - on_pushButton_clicked(); //please take note that calling directly the plot() function will give a wrong value for equivalence point + on_pushButton_clicked(); // please take note that calling directly the plot() function will give a wrong value for equivalence point } void titrationCalculator::on_ymax_valueChanged(double val) { ymax = val; - on_pushButton_clicked(); //please take note that calling directly the plot() function will give a wrong value for equivalence point + on_pushButton_clicked(); // please take note that calling directly the plot() function will give a wrong value for equivalence point } void titrationCalculator::on_pushButton_clicked() @@ -404,74 +419,83 @@ void titrationCalculator::on_pushButton_clicked() plot(); } - - void titrationCalculator::on_actionRapid_Help_triggered() { on_actionNew_triggered(); - //now I'm going to fill the tables with the example values + // now I'm going to fill the tables with the example values - //table1 - QTableWidgetItem *titemo = uid.tableWidget->item(0,0); + // table1 + QTableWidgetItem *titemo = uid.tableWidget->item(0, 0); titemo->setText(QStringLiteral("A")); - titemo = uid.tableWidget->item(0,1); + titemo = uid.tableWidget->item(0, 1); titemo->setText(QStringLiteral("(C*D)/(B*K)")); - titemo = uid.tableWidget->item(1,0); + titemo = uid.tableWidget->item(1, 0); titemo->setText(QStringLiteral("K")); - titemo = uid.tableWidget->item(1,1); + titemo = uid.tableWidget->item(1, 1); titemo->setText(QStringLiteral("10^-3")); - titemo = uid.tableWidget->item(2,0); + titemo = uid.tableWidget->item(2, 0); titemo->setText(QStringLiteral("C")); - titemo = uid.tableWidget->item(2,1); + titemo = uid.tableWidget->item(2, 1); titemo->setText(QStringLiteral("OH")); - titemo = uid.tableWidget->item(3,0); + titemo = uid.tableWidget->item(3, 0); titemo->setText(QStringLiteral("OH")); - titemo = uid.tableWidget->item(3,1); + titemo = uid.tableWidget->item(3, 1); titemo->setText(QStringLiteral("(10^-14)/H")); - titemo = uid.tableWidget->item(4,0); + titemo = uid.tableWidget->item(4, 0); titemo->setText(QStringLiteral("H")); - titemo = uid.tableWidget->item(4,1); + titemo = uid.tableWidget->item(4, 1); titemo->setText(QStringLiteral("10^-4")); - titemo = uid.tableWidget->item(5,0); + titemo = uid.tableWidget->item(5, 0); titemo->setText(QStringLiteral("B")); - titemo = uid.tableWidget->item(5,1); + titemo = uid.tableWidget->item(5, 1); titemo->setText(QStringLiteral("6*(10^-2)")); - //xaxis + // xaxis uid.xaxis->setText(QStringLiteral("D")); - //yaxis + // yaxis uid.yaxis->setText(QStringLiteral("A")); - //table2 - titemo = uid.tableWidget_2->item(0,0); + // table2 + titemo = uid.tableWidget_2->item(0, 0); titemo->setText(QStringLiteral("7,19")); - titemo = uid.tableWidget_2->item(0,1); + titemo = uid.tableWidget_2->item(0, 1); titemo->setText(QStringLiteral("30")); - titemo = uid.tableWidget_2->item(1,0); + titemo = uid.tableWidget_2->item(1, 0); titemo->setText(QStringLiteral("7,64")); - titemo = uid.tableWidget_2->item(1,1); + titemo = uid.tableWidget_2->item(1, 1); titemo->setText(QStringLiteral("30,5")); - titemo = uid.tableWidget_2->item(2,0); + titemo = uid.tableWidget_2->item(2, 0); titemo->setText(QStringLiteral("10,02")); - titemo = uid.tableWidget_2->item(2,1); + titemo = uid.tableWidget_2->item(2, 1); titemo->setText(QStringLiteral("31")); - titemo = uid.tableWidget_2->item(3,0); + titemo = uid.tableWidget_2->item(3, 0); titemo->setText(QStringLiteral("10,45")); - titemo = uid.tableWidget_2->item(3,1); + titemo = uid.tableWidget_2->item(3, 1); titemo->setText(QStringLiteral("31,5")); // I think it's better if I don't give so much information here. // This information could be included into kalzium help, but I don't know how to do - //QMessageBox::information(this, "IceeQt Rapid Help", "There are two ways to use IceeQt:\n\nTheoretical Equations\n Here you can fill the table with the equations you have previously obtained for the chemical equilibria. FOR EXAMPLE if you have this reaction A + B -> C + D then you will have the equation K=(C*D)/(A*B) so you must write 'K' in the Parameter column and '(C*D)/(A*B)' in the Value column. If you want to assign a known value to a parameter you can simply write the numeric value in the Value field. FOR EXAMPLE you can use the system \nA=(C*D)/(B*K) \nK=10^-3 \nC=OH \nOH=(10^-14)/H \nH=10^-4 \nB=6*(10^-2) \nThen you have to write D as X axis and A as Y axis: so you will find out how the concentration of A change in function of D concentration.\nPlease don't use parenthesis for exponents: 10^-3 is correct, while 10^(-3) is wrong. \n\nExperimental Values\n You can use this program to draw the plot of your experimental data obtained during a titration and find out the volume of equivalence. It's strongly recommended to insert a even number of points, because of the best fit algorithm, sorted by volume (the X axis value).\n\nPlot\n The plot shows in red the curve that comes from theoretical equations, in blue the experimental points, and in green the approximated curve for experimental points."); - } + // QMessageBox::information(this, "IceeQt Rapid Help", "There are two ways to use IceeQt:\n\nTheoretical Equations\n Here you can fill the table with the + // equations you have previously obtained for the chemical equilibria. FOR EXAMPLE if you have this reaction A + B -> C + D then you will have the equation + // K=(C*D)/(A*B) so you must write 'K' in the Parameter column and '(C*D)/(A*B)' in the Value column. If you want to assign a known value to a parameter you + // can simply write the numeric value in the Value field. FOR EXAMPLE you can use the system \nA=(C*D)/(B*K) \nK=10^-3 \nC=OH \nOH=(10^-14)/H \nH=10^-4 + // \nB=6*(10^-2) \nThen you have to write D as X axis and A as Y axis: so you will find out how the concentration of A change in function of D + // concentration.\nPlease don't use parenthesis for exponents: 10^-3 is correct, while 10^(-3) is wrong. \n\nExperimental Values\n You can use this program + // to draw the plot of your experimental data obtained during a titration and find out the volume of equivalence. It's strongly recommended to insert a even + // number of points, because of the best fit algorithm, sorted by volume (the X axis value).\n\nPlot\n The plot shows in red the curve that comes from + // theoretical equations, in blue the experimental points, and in green the approximated curve for experimental points."); +} /* void titrationCalculator::on_actionAbout_triggered() { - QMessageBox::information(this, "IceeQt About", "I\nCompute\nEquilibria\nExactly\n\nIceeQt is a program for computing chemical equilibria in a easy way. The first version of Icee was written by Gabriele Balducci(University of Trieste, Italy) using matheval, gnuplot, and tk. This version, called IceeQt, was written by Luca Tringali using Qtopia. \n IceeQt is installable on every system supported by Qt: Windows, MacOS, GNU/Linux, FreeBSD, Solaris, Symbian, etc..\n This program is released under GPL3 licence.\n\nThe website is http://web.archive.org/web/20041207065103/http://www.dsch.units.it/~balducci/lca1/"); + QMessageBox::information(this, "IceeQt About", "I\nCompute\nEquilibria\nExactly\n\nIceeQt is a program for computing chemical equilibria in a easy way. The +first version of Icee was written by Gabriele Balducci(University of Trieste, Italy) using matheval, gnuplot, and tk. This version, called IceeQt, was written +by Luca Tringali using Qtopia. \n IceeQt is installable on every system supported by Qt: Windows, MacOS, GNU/Linux, FreeBSD, Solaris, Symbian, etc..\n This +program is released under GPL3 licence.\n\nThe website is http://web.archive.org/web/20041207065103/http://www.dsch.units.it/~balducci/lca1/"); } */ void titrationCalculator::on_actionNew_triggered() { - //set all the table cells as empty ("") + // set all the table cells as empty ("") for (int i = 0; i < uid.tableWidget->rowCount(); ++i) { QTableWidgetItem *titem = new QTableWidgetItem; titem->setText(QLatin1String("")); @@ -495,28 +519,28 @@ void titrationCalculator::on_actionNew_triggered() void titrationCalculator::on_actionSave_triggered() { - //save all the cells values - // if we have for example: - // table1: - // |a|f| - // |d|h| - // table2: - // |w|q| - // |h|l| - // then the file would be: - // table1| - // a| - // f| - // d| - // h| - // table2| - // w| - // q| - // h| - // l| - // note| - // ewewewww| - // as you can see we don't save also the empty cells, this is obvious. + // save all the cells values + // if we have for example: + // table1: + // |a|f| + // |d|h| + // table2: + // |w|q| + // |h|l| + // then the file would be: + // table1| + // a| + // f| + // d| + // h| + // table2| + // w| + // q| + // h| + // l| + // note| + // ewewewww| + // as you can see we don't save also the empty cells, this is obvious. QString tempyval; tempyval = QStringLiteral("table1|"); @@ -531,11 +555,11 @@ void titrationCalculator::on_actionSave_triggered() tempyval = tempyval + QChar('\n') + valuerq + QStringLiteral("|\n") + yvaluerq + QChar('|'); } } - tempyval = tempyval + QStringLiteral("\nxaxis|"); + tempyval = tempyval + QStringLiteral("\nxaxis|"); tempyval = tempyval + QStringLiteral("\n") + uid.xaxis->text() + QChar('|'); - tempyval = tempyval + QStringLiteral("\nyaxis|"); + tempyval = tempyval + QStringLiteral("\nyaxis|"); tempyval = tempyval + QStringLiteral("\n") + uid.yaxis->text() + QChar('|'); - tempyval = tempyval + QStringLiteral("\ntable2|"); + tempyval = tempyval + QStringLiteral("\ntable2|"); for (int i = 0; i < uid.tableWidget_2->rowCount(); ++i) { QTableWidgetItem *titem = uid.tableWidget_2->item(i, 0); QTableWidgetItem *titemo = uid.tableWidget_2->item(i, 1); @@ -549,7 +573,7 @@ void titrationCalculator::on_actionSave_triggered() } tempyval = tempyval + QStringLiteral("\nnote|\n") + uid.note->toPlainText() + QChar('|'); - QString file = QFileDialog::getSaveFileName(this,i18n("Save work"),QLatin1String(""),i18n("Icee File (*.icee)")); + QString file = QFileDialog::getSaveFileName(this, i18n("Save work"), QLatin1String(""), i18n("Icee File (*.icee)")); if (!file.isEmpty()) { QByteArray ba = tempyval.toLatin1(); char *strsave = ba.data(); @@ -561,24 +585,24 @@ void titrationCalculator::on_actionSave_triggered() cout << filec; cout << "|"; if (!out) { - QMessageBox::critical(this,i18n("Error"),i18n("Unable to create %1", file)); + QMessageBox::critical(this, i18n("Error"), i18n("Unable to create %1", file)); } out << strsave; out.close(); - //if (out) QMessageBox::information(this, "Information", "File " + file + " successfully saved."); + // if (out) QMessageBox::information(this, "Information", "File " + file + " successfully saved."); } } void titrationCalculator::on_actionOpen_triggered() { - //loads all the cells text from a file previously saved - QString file = QFileDialog::getOpenFileName(this,i18n("Open work"),QLatin1String(""),i18n("Icee File (*.icee)")); + // loads all the cells text from a file previously saved + QString file = QFileDialog::getOpenFileName(this, i18n("Open work"), QLatin1String(""), i18n("Icee File (*.icee)")); if (!file.isEmpty()) { QByteArray bac = file.toLatin1(); char *filec = bac.data(); ifstream texto(filec); if (!texto) { - QMessageBox::critical(this,i18n("Error"),i18n("Unable to open %1", file)); + QMessageBox::critical(this, i18n("Error"), i18n("Unable to open %1", file)); } if (texto) { on_actionNew_triggered(); @@ -595,7 +619,8 @@ void titrationCalculator::on_actionOpen_triggered() if (tmpchr != '|') { tempyval = tempyval + tmpchr; } else { - if ((tablea == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { + if ((tablea == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) + && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { if ((i % 2) != 0) { QTableWidgetItem *titemo = uid.tableWidget->item((i - 1) / 2, 1); if (titemo) { @@ -610,7 +635,8 @@ void titrationCalculator::on_actionOpen_triggered() ++i; } - if ((tableb == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { + if ((tableb == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) + && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { if ((i % 2) != 0) { QTableWidgetItem *titemo = uid.tableWidget_2->item((i - 1) / 2, 1); if (titemo) { @@ -621,17 +647,20 @@ void titrationCalculator::on_actionOpen_triggered() if (titem) { titem->setText(tempyval); } - //cout << i; + // cout << i; } ++i; } - if ((xax == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { + if ((xax == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) && (tempyval != QStringLiteral("xaxis")) + && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { uid.xaxis->setText(tempyval); } - if ((yax == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { + if ((yax == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) && (tempyval != QStringLiteral("xaxis")) + && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { uid.yaxis->setText(tempyval); } - if ((notea == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { + if ((notea == 1) && (tempyval != QStringLiteral("table1")) && (tempyval != QStringLiteral("table2")) + && (tempyval != QStringLiteral("xaxis")) && (tempyval != QStringLiteral("yaxis")) && (tempyval != QStringLiteral("note"))) { uid.note->setText(tempyval); } @@ -651,21 +680,21 @@ void titrationCalculator::on_actionOpen_triggered() yax = 0; notea = 0; } - if (tempyval == QStringLiteral("xaxis")) { + if (tempyval == QStringLiteral("xaxis")) { tablea = 0; tableb = 0; xax = 1; yax = 0; notea = 0; } - if (tempyval == QStringLiteral("yaxis")) { + if (tempyval == QStringLiteral("yaxis")) { tablea = 0; tableb = 0; xax = 0; yax = 1; notea = 0; } - if (tempyval == QStringLiteral("note")) { + if (tempyval == QStringLiteral("note")) { tablea = 0; tableb = 0; xax = 0; @@ -682,8 +711,16 @@ void titrationCalculator::on_actionOpen_triggered() void titrationCalculator::on_actionSave_image_triggered() { - //This function saves the plot into a SVG file - QString svgheader = " "; + // This function saves the plot into a SVG file + QString svgheader = + " "; QString svgcomplete = svgheader + redplot + greenplot + blueplot + " "; QString file = QFileDialog::getSaveFileName(this, i18n("Save plot"), QLatin1String(""), i18n("Svg image (*.svg)")); @@ -698,7 +735,7 @@ void titrationCalculator::on_actionSave_image_triggered() cout << filec; cout << "|"; if (!out) { - QMessageBox::critical(this,i18n("Error"),i18n("Unable to create %1", file)); + QMessageBox::critical(this, i18n("Error"), i18n("Unable to create %1", file)); } out << strsave; out.close(); diff --git a/src/calculator/titrationCalculator.h b/src/calculator/titrationCalculator.h index 8f31513db06eda3d6f72135b043adbb31277472f..5e24204d848814b193ea6d02b5be04cec4e7d24c 100644 --- a/src/calculator/titrationCalculator.h +++ b/src/calculator/titrationCalculator.h @@ -32,7 +32,7 @@ class titrationCalculator : public QWidget Q_OBJECT public: - explicit titrationCalculator(QWidget * parent = nullptr); + explicit titrationCalculator(QWidget *parent = nullptr); ~titrationCalculator(); public Q_SLOTS: @@ -68,7 +68,7 @@ private: QString greenplot; QString blueplot; - Ui::titrationCalculator uid; // The user interface + Ui::titrationCalculator uid; // The user interface }; #endif // TITRATIONCALCULATOR_H diff --git a/src/detailedgraphicaloverview.cpp b/src/detailedgraphicaloverview.cpp index 014cd48efd08acf128664eddd6fed10f2f9f5634..70d12a936e985460ce4a5c4ea102e6cd0ecb87db 100644 --- a/src/detailedgraphicaloverview.cpp +++ b/src/detailedgraphicaloverview.cpp @@ -19,11 +19,12 @@ #include #include -#include #include "prefs.h" +#include DetailedGraphicalOverview::DetailedGraphicalOverview(QWidget *parent) - : QWidget(parent), m_element(nullptr) + : QWidget(parent) + , m_element(nullptr) { setAttribute(Qt::WA_OpaquePaintEvent, true); @@ -43,25 +44,25 @@ void DetailedGraphicalOverview::setElement(int el) void DetailedGraphicalOverview::setBackgroundColor(QColor bgColor) { if (bgColor == Qt::transparent) { - bgColor = palette().window().color(); + bgColor = palette().window().color(); } // add a gradient QLinearGradient grad(QPointF(0, 0), QPointF(0, height())); - grad.setColorAt(0,bgColor); + grad.setColorAt(0, bgColor); qreal h, s, v, a; bgColor.getHsvF(&h, &s, &v, &a); - bgColor.setHsvF(h, s, v*0.6, a); - grad.setColorAt(1,bgColor); + bgColor.setHsvF(h, s, v * 0.6, a); + grad.setColorAt(1, bgColor); m_backgroundBrush = QBrush(grad); } -void DetailedGraphicalOverview::paintEvent(QPaintEvent*) +void DetailedGraphicalOverview::paintEvent(QPaintEvent *) { qreal dpr = devicePixelRatioF(); - qreal dprWidth = dpr*width(); - qreal dprHeight = dpr*height(); + qreal dprWidth = dpr * width(); + qreal dprHeight = dpr * height(); QRect rect(0, 0, dprWidth, dprHeight); QPixmap pm(dprWidth, dprHeight); @@ -72,18 +73,17 @@ void DetailedGraphicalOverview::paintEvent(QPaintEvent*) p.setBrush(Qt::SolidPattern); - if (!m_element) - { + if (!m_element) { pm.fill(palette().window().color()); p.drawText(0, 0, width(), height(), Qt::AlignCenter | Qt::TextWordWrap, i18n("No element selected")); - } else if (Prefs::colorschemebox() == 2) { //The iconic view is the 3rd view (0,1,2,...) + } else if (Prefs::colorschemebox() == 2) { // The iconic view is the 3rd view (0,1,2,...) pm.fill(palette().window().color()); QString pathname = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("data/iconsets/"), QStandardPaths::LocateDirectory); int enumii = m_element->dataAsVariant(ChemicalDataObject::atomicNumber).toInt(); - QString filename = pathname + "school" + '/' + QString::number(enumii) + ".svg"; + QString filename = pathname + "school" + '/' + QString::number(enumii) + ".svg"; QSvgRenderer svgrenderer; if (QFile::exists(filename) && svgrenderer.load(filename)) { @@ -91,13 +91,13 @@ void DetailedGraphicalOverview::paintEvent(QPaintEvent*) size.scale(width(), height(), Qt::KeepAspectRatio); QRect bounds(QPoint(0, 0), size); - bounds.moveCenter(QPoint(width()/2, height()/2)); + bounds.moveCenter(QPoint(width() / 2, height() / 2)); svgrenderer.render(&p, bounds); } else { p.drawText(rect, Qt::AlignCenter | Qt::TextWordWrap, i18n("No graphic found")); } } else { - const int h_t = 20; //height of the texts + const int h_t = 20; // height of the texts p.setBrush(m_backgroundBrush); p.drawRect(rect); @@ -108,52 +108,46 @@ void DetailedGraphicalOverview::paintEvent(QPaintEvent*) QFont fB = QFontDatabase::systemFont(QFontDatabase::GeneralFont); QFont fC = QFontDatabase::systemFont(QFontDatabase::GeneralFont); - fA.setPointSize(fA.pointSize() + 20); //Huge font + fA.setPointSize(fA.pointSize() + 20); // Huge font fA.setBold(true); - fB.setPointSize(fB.pointSize() + 6); //Big font - fC.setPointSize(fC.pointSize() + 4); //Big font + fB.setPointSize(fB.pointSize() + 6); // Big font + fC.setPointSize(fC.pointSize() + 4); // Big font fC.setBold(true); QFontMetrics fmA = QFontMetrics(fA); QFontMetrics fmB = QFontMetrics(fB); - //coordinates for element symbol: near the center + // coordinates for element symbol: near the center int xA = 4 * width() / 10; int yA = height() / 2; - //coordinates for the atomic number: offset from element symbol to the upper left + // coordinates for the atomic number: offset from element symbol to the upper left int xB = xA - fmB.boundingRect(m_element->dataAsString(ChemicalDataObject::atomicNumber)).width(); - int yB = yA + fmB.height()/2; + int yB = yA + fmB.height() / 2; - //Element Symbol + // Element Symbol p.setFont(fA); p.drawText(xA, yA, m_element->dataAsString(ChemicalDataObject::symbol)); - //Atomic number + // Atomic number p.setFont(fB); p.drawText(xB, yB, m_element->dataAsString(ChemicalDataObject::atomicNumber)); - //Name and other data + // Name and other data fC.setPointSize(h_t); p.setFont(fC); - //Name + // Name p.drawText(1, 0, width(), height(), Qt::AlignLeft, m_element->dataAsString(ChemicalDataObject::name)); - //TODO Oxidationstates -> not there yet + // TODO Oxidationstates -> not there yet - //Mass + // Mass QString massString = i18nc("For example '1.0079u', the mass of an element in units", "%1 u", m_element->dataAsString(ChemicalDataObject::mass)); int size3 = KalziumUtils::maxSize(massString, rect, fC, &p); fC.setPointSize(size3); p.setFont(fC); int offset = KalziumUtils::StringHeight(massString, fC, &p); - p.drawText(0, - height() - offset, - width(), - offset, - Qt::AlignRight, - massString - ); + p.drawText(0, height() - offset, width(), offset, Qt::AlignRight, massString); } p.end(); @@ -162,4 +156,3 @@ void DetailedGraphicalOverview::paintEvent(QPaintEvent*) p.drawPixmap(0, 0, pm); p.end(); } - diff --git a/src/detailedgraphicaloverview.h b/src/detailedgraphicaloverview.h index df72a3b6a8afb2915feff5056cc2c1c33e6af8b1..0cb72ba54a4555dd8287ee72e7a2df627d7ca8aa 100644 --- a/src/detailedgraphicaloverview.h +++ b/src/detailedgraphicaloverview.h @@ -6,8 +6,8 @@ #ifndef DETAILEDGRAPHICALOVERVIEW_H #define DETAILEDGRAPHICALOVERVIEW_H -#include #include "kalziumelementproperty.h" +#include class Element; @@ -53,7 +53,7 @@ private: QBrush m_backgroundBrush; protected: - void paintEvent(QPaintEvent*) override; + void paintEvent(QPaintEvent *) override; }; #endif // DETAILEDGRAPHICALOVERVIEW_H diff --git a/src/detailinfodlg.cpp b/src/detailinfodlg.cpp index 8de241429038f5de6169280db93c95c906c86975..6ef40d478c781a26d45c1680f08660c9dd6b2e03 100644 --- a/src/detailinfodlg.cpp +++ b/src/detailinfodlg.cpp @@ -34,7 +34,9 @@ #include #include -DetailedInfoDlg::DetailedInfoDlg(int el, QWidget *parent) : KPageDialog(parent), m_tableTyp(0) +DetailedInfoDlg::DetailedInfoDlg(int el, QWidget *parent) + : KPageDialog(parent) + , m_tableTyp(0) { setFaceType(List); @@ -58,8 +60,8 @@ DetailedInfoDlg::DetailedInfoDlg(int el, QWidget *parent) : KPageDialog(parent), m_baseHtml = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("data/htmlview/"), QStandardPaths::LocateDirectory); m_baseHtml2 = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("data/hazardsymbols/"), QStandardPaths::LocateDirectory); -//X m_picsdir = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "elempics/") + "elempics/"; -//X m_picsdir = QFileInfo(m_picsdir).absolutePath(); + // X m_picsdir = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "elempics/") + "elempics/"; + // X m_picsdir = QFileInfo(m_picsdir).absolutePath(); // creating the tabs but not the contents, as that will be done when setting the element createContent(); @@ -67,12 +69,9 @@ DetailedInfoDlg::DetailedInfoDlg(int el, QWidget *parent) : KPageDialog(parent), m_actionCollection = new KActionCollection(this); KStandardAction::quit(this, SLOT(close()), m_actionCollection); - connect(prevButton, &QPushButton::clicked, - this, &DetailedInfoDlg::showPreviousElement); - connect(nextButton, &QPushButton::clicked, - this, &DetailedInfoDlg::showNextElement); - connect(buttonBox(), &QDialogButtonBox::helpRequested, - this, &DetailedInfoDlg::slotHelp); + connect(prevButton, &QPushButton::clicked, this, &DetailedInfoDlg::showPreviousElement); + connect(nextButton, &QPushButton::clicked, this, &DetailedInfoDlg::showNextElement); + connect(buttonBox(), &QDialogButtonBox::helpRequested, this, &DetailedInfoDlg::slotHelp); // setting the element and updating the whole dialog setElement(el); @@ -97,13 +96,13 @@ void DetailedInfoDlg::setElement(int el) reloadContent(); - /* enableButton(User1, true); - user2Button->setEnabled(true); - if (m_elementNumber == 1) { - user2Button->setEnabled(false); - } else if (m_elementNumber == KalziumDataObject::instance()->numberOfElements()) { - user1Button->setEnabled(false); - }*/ + /* enableButton(User1, true); + user2Button->setEnabled(true); + if (m_elementNumber == 1) { + user2Button->setEnabled(false); + } else if (m_elementNumber == KalziumDataObject::instance()->numberOfElements()) { + user1Button->setEnabled(false); + }*/ } // void DetailedInfoDlg::setOverviewBackgroundColor(const QColor &bgColor) @@ -116,9 +115,9 @@ void DetailedInfoDlg::setTableType(int tableTyp) m_tableTyp = tableTyp; } -QTextBrowser* DetailedInfoDlg::addHTMLTab(const QString& title, const QString& icontext, const QString& iconname) +QTextBrowser *DetailedInfoDlg::addHTMLTab(const QString &title, const QString &icontext, const QString &iconname) { - QWidget* frame = new QWidget(this); + QWidget *frame = new QWidget(this); KPageWidgetItem *item = addPage(frame, title); item->setHeader(icontext); item->setIcon(QIcon::fromTheme(iconname)); @@ -130,7 +129,7 @@ QTextBrowser* DetailedInfoDlg::addHTMLTab(const QString& title, const QString& i return browser; } -void DetailedInfoDlg::fillHTMLTab(QTextBrowser *browser, const QString& htmlcode) +void DetailedInfoDlg::fillHTMLTab(QTextBrowser *browser, const QString &htmlcode) { if (!browser) { return; @@ -143,8 +142,7 @@ QString DetailedInfoDlg::getHtml(DATATYPE type) QString html = ""; switch (type) { - case MISC: - { + case MISC: { // discovery date and discoverers html.append(""); } - //X if (m_element->artificial() || m_element->radioactive()) { - //X html.append(""); - //X } + // X if (m_element->artificial() || m_element->radioactive()) { + // X html.append(""); + // X } break; } - case ISOTOPES: - { + case ISOTOPES: { html.append(""); break; } - case DATA: - { + case DATA: { // melting point html.append(""); - //Electronic configuration + // Electronic configuration html.append(""); - // Oxidation numbers + // Oxidation numbers html.append(""); break; } - case EXTRA: - { - //Wikipedia.org -// html.append (""); - - //https://education.jlab.org/itselemental/ele001.html - html.append (""); + case EXTRA: { + // Wikipedia.org + // html.append (""); + + // https://education.jlab.org/itselemental/ele001.html + html.append(""); // FIXME only works with english locals - html.append (""); + html.append("\" target=\"_blank\" >"); + html.append("Webelements"); + html.append(""); - //chemipedia.org - //html.append(""); - //physics.nist.gov - //html.append(""); + // physics.nist.gov + // html.append(""); + // html.append(""); } } @@ -302,7 +298,7 @@ QString DetailedInfoDlg::getHtml(DATATYPE type) QString DetailedInfoDlg::isotopeTable() const { - QList list = KalziumDataObject::instance()->isotopes(m_elementNumber); + QList list = KalziumDataObject::instance()->isotopes(m_elementNumber); QString html; html = QStringLiteral("
\"icon\"/"); html += KalziumUtils::prettyUnit(m_element, ChemicalDataObject::date); @@ -161,28 +159,26 @@ QString DetailedInfoDlg::getHtml(DATATYPE type) html.append(i18n("Origin of the name:
%1", nameorigin)); html.append("
\"icon\"/"); - //X if (!m_element->radioactive()) { - //X html.append(i18n("This element is artificial")); - //X } else if (!m_element->artificial()) { - //X html.append(i18n("This element is radioactive")); - //X } else { - //X html.append(i18n("This element is radioactive and artificial")); - //X } - //X html.append("
\"icon\"/"); + // X if (!m_element->radioactive()) { + // X html.append(i18n("This element is artificial")); + // X } else if (!m_element->artificial()) { + // X html.append(i18n("This element is radioactive")); + // X } else { + // X html.append(i18n("This element is radioactive and artificial")); + // X } + // X html.append("
"); html.append(isotopeTable()); html.append("
\"icon\"/"); html.append(createWikiLink(i18n("Melting Point"))); @@ -204,7 +200,7 @@ QString DetailedInfoDlg::getHtml(DATATYPE type) html.append(KalziumUtils::prettyUnit(m_element, ChemicalDataObject::electronAffinity)); html.append("
\"icon\"/"); html.append(createWikiLink(i18n("Electronic configuration"))); html.append(""); @@ -246,7 +242,7 @@ QString DetailedInfoDlg::getHtml(DATATYPE type) html.append(KalziumUtils::prettyUnit(m_element, ChemicalDataObject::electronegativityPauling)); html.append("
\"icon\"/"); html.append(createWikiLink(i18n("Oxidation states"))); html.append(""); @@ -254,44 +250,44 @@ QString DetailedInfoDlg::getHtml(DATATYPE type) html.append("
\"icon\"/"); - html.append ("
"); - html.append (createWikiLink(m_element->dataAsString(ChemicalDataObject::name), i18nc("Link to element's Wikipedia page, %1 is localized language name", "Wikipedia (%1)", QLocale().nativeLanguageName()))); - html.append ("
"); - html.append ("dataAsString(ChemicalDataObject::atomicNumber), 3, '0')); - html.append (".html"); - html.append ("\" target=\"_blank\" > "); - html.append ("Jefferson Lab"); - html.append (""); - html.append ("
\"icon\"/"); + html.append("
"); + html.append(createWikiLink(m_element->dataAsString(ChemicalDataObject::name), + i18nc("Link to element's Wikipedia page, %1 is localized language name", "Wikipedia (%1)", QLocale().nativeLanguageName()))); + html.append("
"); + html.append("dataAsString(ChemicalDataObject::atomicNumber), 3, '0')); + html.append(".html"); + html.append("\" target=\"_blank\" > "); + html.append("Jefferson Lab"); + html.append(""); + html.append("
"); - html.append (""); + html.append("dataAsString(ChemicalDataObject::name).toLower()); // hydrogen + html.append(m_element->dataAsString(ChemicalDataObject::name).toLower()); // hydrogen } - html.append ("\" target=\"_blank\" >"); - html.append ("Webelements"); - html.append ("
\"icon\"/"); + // chemipedia.org + // html.append("
\"icon\"/"); - //html.append("
\"icon\"/"); + // html.append("
\"icon\"/"); - //html.append("
"); - } html += QLatin1String("
"); @@ -334,51 +330,33 @@ QString DetailedInfoDlg::isotopeTable() const } html.append(""); if ((isotope)->halflife() > 0.0) { - html.append(i18nc("The first argument is the value, the second is the unit. For example '17 s' for '17 seconds',.", "%1 %2", - (isotope)->halflife(), (isotope)->halflifeUnit())); + html.append(i18nc("The first argument is the value, the second is the unit. For example '17 s' for '17 seconds',.", + "%1 %2", + (isotope)->halflife(), + (isotope)->halflifeUnit())); } html.append(""); if ((isotope)->spontfissionlikeliness() > 0.0) { if ((isotope)->spontfissiondecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->spontfissiondecay())); } - html.append(i18nc("Spontaneous fission"," SF")); + html.append(i18nc("Spontaneous fission", " SF")); if ((isotope)->spontfissionlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->spontfissionlikeliness())); } - if ((isotope)->alphalikeliness() > 0.0 || - (isotope)->protonlikeliness() > 0.0 || - (isotope)->twoprotonlikeliness() > 0.0 || - (isotope)->neutronlikeliness() > 0.0 || - (isotope)->twoneutronlikeliness() > 0.0 || - (isotope)->eclikeliness() > 0.0 || - (isotope)->twoeclikeliness() > 0.0 || - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->alphalikeliness() > 0.0 || (isotope)->protonlikeliness() > 0.0 || (isotope)->twoprotonlikeliness() > 0.0 + || (isotope)->neutronlikeliness() > 0.0 || (isotope)->twoneutronlikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0 + || (isotope)->twoeclikeliness() > 0.0 || (isotope)->betaminuslikeliness() > 0.0 || (isotope)->betaminusfissionlikeliness() > 0.0 + || (isotope)->twobetaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 + || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -386,43 +364,22 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->alphadecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->alphadecay())); } - html.append(i18nc("Alpha decay"," %1", QChar(945))); + html.append(i18nc("Alpha decay", " %1", QChar(945))); if ((isotope)->alphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->alphalikeliness())); } - if ( - (isotope)->protonlikeliness() > 0.0 || - (isotope)->twoprotonlikeliness() > 0.0 || - (isotope)->neutronlikeliness() > 0.0 || - (isotope)->twoneutronlikeliness() > 0.0 || - (isotope)->eclikeliness() > 0.0 || - (isotope)->twoeclikeliness() > 0.0 || - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->protonlikeliness() > 0.0 || (isotope)->twoprotonlikeliness() > 0.0 || (isotope)->neutronlikeliness() > 0.0 + || (isotope)->twoneutronlikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0 || (isotope)->twoeclikeliness() > 0.0 + || (isotope)->betaminuslikeliness() > 0.0 || (isotope)->betaminusfissionlikeliness() > 0.0 || (isotope)->twobetaminuslikeliness() > 0.0 + || (isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 + || (isotope)->betaminustwoneutronlikeliness() > 0.0 || (isotope)->betaminusthreeneutronlikeliness() > 0.0 + || (isotope)->betaminusfourneutronlikeliness() > 0.0 || (isotope)->betaminusalphaneutronlikeliness() > 0.0 + || (isotope)->betaminusalphalikeliness() > 0.0 || (isotope)->betaminustwoalphalikeliness() > 0.0 + || (isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -434,38 +391,18 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->protonlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->protonlikeliness())); } - if ( - (isotope)->twoprotonlikeliness() > 0.0 || - (isotope)->neutronlikeliness() > 0.0 || - (isotope)->twoneutronlikeliness() > 0.0 || - (isotope)->eclikeliness() > 0.0 || - (isotope)->twoeclikeliness() > 0.0 || - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->twoprotonlikeliness() > 0.0 || (isotope)->neutronlikeliness() > 0.0 || (isotope)->twoneutronlikeliness() > 0.0 + || (isotope)->eclikeliness() > 0.0 || (isotope)->twoeclikeliness() > 0.0 || (isotope)->betaminuslikeliness() > 0.0 + || (isotope)->betaminusfissionlikeliness() > 0.0 || (isotope)->twobetaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 + || (isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -477,37 +414,18 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->twoprotonlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->twoprotonlikeliness())); } - if ( - (isotope)->neutronlikeliness() > 0.0 || - (isotope)->twoneutronlikeliness() > 0.0 || - (isotope)->eclikeliness() > 0.0 || - (isotope)->twoeclikeliness() > 0.0 || - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->neutronlikeliness() > 0.0 || (isotope)->twoneutronlikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0 + || (isotope)->twoeclikeliness() > 0.0 || (isotope)->betaminuslikeliness() > 0.0 || (isotope)->betaminusfissionlikeliness() > 0.0 + || (isotope)->twobetaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 + || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -515,40 +433,21 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->neutrondecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->neutrondecay())); } - html.append(i18nc("Neutron decay"," n")); + html.append(i18nc("Neutron decay", " n")); if ((isotope)->neutronlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->neutronlikeliness())); } - if ( - (isotope)->twoneutronlikeliness() > 0.0 || - (isotope)->eclikeliness() > 0.0 || - (isotope)->twoeclikeliness() > 0.0 || - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->twoneutronlikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0 || (isotope)->twoeclikeliness() > 0.0 + || (isotope)->betaminuslikeliness() > 0.0 || (isotope)->betaminusfissionlikeliness() > 0.0 || (isotope)->twobetaminuslikeliness() > 0.0 + || (isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 + || (isotope)->betaminustwoneutronlikeliness() > 0.0 || (isotope)->betaminusthreeneutronlikeliness() > 0.0 + || (isotope)->betaminusfourneutronlikeliness() > 0.0 || (isotope)->betaminusalphaneutronlikeliness() > 0.0 + || (isotope)->betaminusalphalikeliness() > 0.0 || (isotope)->betaminustwoalphalikeliness() > 0.0 + || (isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -560,35 +459,17 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->twoneutronlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->twoneutronlikeliness())); } - if ( - (isotope)->eclikeliness() > 0.0 || - (isotope)->twoeclikeliness() > 0.0 || - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->eclikeliness() > 0.0 || (isotope)->twoeclikeliness() > 0.0 || (isotope)->betaminuslikeliness() > 0.0 + || (isotope)->betaminusfissionlikeliness() > 0.0 || (isotope)->twobetaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 + || (isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -600,34 +481,17 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->eclikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->eclikeliness())); } - if ( - (isotope)->twoeclikeliness() > 0.0 || - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->twoeclikeliness() > 0.0 || (isotope)->betaminuslikeliness() > 0.0 || (isotope)->betaminusfissionlikeliness() > 0.0 + || (isotope)->twobetaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 + || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -639,33 +503,16 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->twoeclikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->twoeclikeliness())); } - if ( - (isotope)->betaminuslikeliness() > 0.0 || - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminuslikeliness() > 0.0 || (isotope)->betaminusfissionlikeliness() > 0.0 || (isotope)->twobetaminuslikeliness() > 0.0 + || (isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 + || (isotope)->betaminustwoneutronlikeliness() > 0.0 || (isotope)->betaminusthreeneutronlikeliness() > 0.0 + || (isotope)->betaminusfourneutronlikeliness() > 0.0 || (isotope)->betaminusalphaneutronlikeliness() > 0.0 + || (isotope)->betaminusalphalikeliness() > 0.0 || (isotope)->betaminustwoalphalikeliness() > 0.0 + || (isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -677,32 +524,16 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminuslikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminuslikeliness())); } - if ( - (isotope)->betaminusfissionlikeliness() > 0.0 || - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminusfissionlikeliness() > 0.0 || (isotope)->twobetaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 + || (isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -714,31 +545,16 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminusfissionlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminusfissionlikeliness())); } - if ( - (isotope)->twobetaminuslikeliness() > 0.0 || - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->twobetaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 + || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -750,30 +566,15 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->twobetaminuslikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->twobetaminuslikeliness())); } - if ( - (isotope)->betapluslikeliness() > 0.0 || - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 + || (isotope)->betaminustwoneutronlikeliness() > 0.0 || (isotope)->betaminusthreeneutronlikeliness() > 0.0 + || (isotope)->betaminusfourneutronlikeliness() > 0.0 || (isotope)->betaminusalphaneutronlikeliness() > 0.0 + || (isotope)->betaminusalphalikeliness() > 0.0 || (isotope)->betaminustwoalphalikeliness() > 0.0 + || (isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -785,29 +586,15 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betapluslikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betapluslikeliness())); } - if ( - (isotope)->twobetapluslikeliness() > 0.0 || - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->twobetapluslikeliness() > 0.0 || (isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -819,28 +606,15 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->twobetapluslikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->twobetapluslikeliness())); } - if ( - (isotope)->betaminusneutronlikeliness() > 0.0 || - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminusneutronlikeliness() > 0.0 || (isotope)->betaminustwoneutronlikeliness() > 0.0 + || (isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -852,27 +626,14 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminusneutronlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminusneutronlikeliness())); } - if ( - (isotope)->betaminustwoneutronlikeliness() > 0.0 || - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminustwoneutronlikeliness() > 0.0 || (isotope)->betaminusthreeneutronlikeliness() > 0.0 + || (isotope)->betaminusfourneutronlikeliness() > 0.0 || (isotope)->betaminusalphaneutronlikeliness() > 0.0 + || (isotope)->betaminusalphalikeliness() > 0.0 || (isotope)->betaminustwoalphalikeliness() > 0.0 + || (isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -884,26 +645,14 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminustwoneutronlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminustwoneutronlikeliness())); } - if ( - (isotope)->betaminusthreeneutronlikeliness() > 0.0 || - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminusthreeneutronlikeliness() > 0.0 || (isotope)->betaminusfourneutronlikeliness() > 0.0 + || (isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -915,25 +664,13 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminusthreeneutronlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminusthreeneutronlikeliness())); } - if ( - (isotope)->betaminusfourneutronlikeliness() > 0.0 || - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminusfourneutronlikeliness() > 0.0 || (isotope)->betaminusalphaneutronlikeliness() > 0.0 + || (isotope)->betaminusalphalikeliness() > 0.0 || (isotope)->betaminustwoalphalikeliness() > 0.0 + || (isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -945,24 +682,13 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminusfourneutronlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminusfourneutronlikeliness())); } - if ( - (isotope)->betaminusalphaneutronlikeliness() > 0.0 || - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminusalphaneutronlikeliness() > 0.0 || (isotope)->betaminusalphalikeliness() > 0.0 + || (isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -970,27 +696,16 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminusalphaneutrondecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->betaminusalphaneutrondecay())); } - html.append(i18n(" %1-%2 n", QChar(946),QChar(945))); + html.append(i18n(" %1-%2 n", QChar(946), QChar(945))); if ((isotope)->betaminusalphaneutronlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminusalphaneutronlikeliness())); } - if ( - (isotope)->betaminusalphalikeliness() > 0.0 || - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminusalphalikeliness() > 0.0 || (isotope)->betaminustwoalphalikeliness() > 0.0 + || (isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -998,26 +713,16 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminusalphadecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->betaminusalphadecay())); } - html.append(i18n(" %1-%2", QChar(946),QChar(945))); + html.append(i18n(" %1-%2", QChar(946), QChar(945))); if ((isotope)->betaminusalphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminusalphalikeliness())); } - if ( - (isotope)->betaminustwoalphalikeliness() > 0.0 || - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminustwoalphalikeliness() > 0.0 || (isotope)->betaminusthreealphalikeliness() > 0.0 + || (isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1025,25 +730,15 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminustwoalphadecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->betaminustwoalphadecay())); } - html.append(i18n(" %1-2%2", QChar(946),QChar(945))); + html.append(i18n(" %1-2%2", QChar(946), QChar(945))); if ((isotope)->betaminustwoalphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminustwoalphalikeliness())); } - if ( - (isotope)->betaminusthreealphalikeliness() > 0.0 || - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaminusthreealphalikeliness() > 0.0 || (isotope)->betaplusprotonlikeliness() > 0.0 + || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1051,24 +746,15 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaminusthreealphadecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->betaminusthreealphadecay())); } - html.append(i18n(" %1-3%2", QChar(946),QChar(945))); + html.append(i18n(" %1-3%2", QChar(946), QChar(945))); if ((isotope)->betaminusthreealphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaminusthreealphalikeliness())); } - if ( - (isotope)->betaplusprotonlikeliness() > 0.0 || - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaplusprotonlikeliness() > 0.0 || (isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 + || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1080,19 +766,10 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaplusprotonlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaplusprotonlikeliness())); } - if ( - (isotope)->betaplustwoprotonlikeliness() > 0.0 || - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaplustwoprotonlikeliness() > 0.0 || (isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 + || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1104,18 +781,10 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaplustwoprotonlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaplustwoprotonlikeliness())); } - if ( - (isotope)->betaplusalphalikeliness() > 0.0 || - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaplusalphalikeliness() > 0.0 || (isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 + || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1123,21 +792,14 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaplusalphadecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->betaplusalphadecay())); } - html.append(i18n(" %1+%2", QChar(946),QChar(945))); + html.append(i18n(" %1+%2", QChar(946), QChar(945))); if ((isotope)->betaplusalphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaplusalphalikeliness())); } - if ( - (isotope)->betaplustwoalphalikeliness() > 0.0 || - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaplustwoalphalikeliness() > 0.0 || (isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 + || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 + || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1145,20 +807,13 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaplustwoalphadecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->betaplustwoalphadecay())); } - html.append(i18n(" %1+2%2", QChar(946),QChar(945))); + html.append(i18n(" %1+2%2", QChar(946), QChar(945))); if ((isotope)->betaplustwoalphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaplustwoalphalikeliness())); } - if ( - (isotope)->betaplusthreealphalikeliness() > 0.0 || - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->betaplusthreealphalikeliness() > 0.0 || (isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 + || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1166,19 +821,13 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->betaplusthreealphadecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->betaplusthreealphadecay())); } - html.append(i18n(" %1+3%2", QChar(946),QChar(945))); + html.append(i18n(" %1+3%2", QChar(946), QChar(945))); if ((isotope)->betaplusthreealphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->betaplusthreealphalikeliness())); } - if ( - (isotope)->alphabetaminuslikeliness() > 0.0 || - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->alphabetaminuslikeliness() > 0.0 || (isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 + || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1186,18 +835,13 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->alphabetaminusdecay() > 0.0) { html.append(i18n("%1 MeV", (isotope)->alphabetaminusdecay())); } - html.append(i18n(" %1 %2-", QChar(945),QChar(946))); + html.append(i18n(" %1 %2-", QChar(945), QChar(946))); if ((isotope)->alphabetaminuslikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->alphabetaminuslikeliness())); } - if ( - (isotope)->protonalphalikeliness() > 0.0 || - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->protonalphalikeliness() > 0.0 || (isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 + || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1209,13 +853,8 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->protonalphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->protonalphalikeliness())); } - if ( - (isotope)->ecprotonlikeliness() > 0.0 || - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->ecprotonlikeliness() > 0.0 || (isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 + || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1227,12 +866,8 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->ecprotonlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->ecprotonlikeliness())); } - if ( - (isotope)->ectwoprotonlikeliness() > 0.0 || - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->ectwoprotonlikeliness() > 0.0 || (isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1244,11 +879,8 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->ectwoprotonlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->ectwoprotonlikeliness())); } - if ( - (isotope)->ecthreeprotonlikeliness() > 0.0 || - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->ecthreeprotonlikeliness() > 0.0 || (isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 + || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1260,10 +892,7 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->ecthreeprotonlikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->ecthreeprotonlikeliness())); } - if ( - (isotope)->ecalphalikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->ecalphalikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1275,9 +904,7 @@ QString DetailedInfoDlg::isotopeTable() const if ((isotope)->ecalphalikeliness() < 100.0) { html.append(i18n("(%1%)", (isotope)->ecalphalikeliness())); } - if ( - (isotope)->ecalphaprotonlikeliness() > 0.0 || - (isotope)->ecalphaprotonlikeliness() > 0.0 ) { + if ((isotope)->ecalphaprotonlikeliness() > 0.0 || (isotope)->ecalphaprotonlikeliness() > 0.0) { html.append(i18n(", ")); } } @@ -1291,156 +918,156 @@ QString DetailedInfoDlg::isotopeTable() const } } -/* if ((isotope)->alphalikeliness() > 0.0) { - if ((isotope)->alphadecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->alphadecay())); - } - html.append(i18n(" %1", QChar(945))); - if ((isotope)->alphalikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->alphalikeliness())); - } - if ((isotope)->betaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { - html.append(i18n(", ")); - } - } - if ((isotope)->alphabetaminuslikeliness() > 0.0) { - if ((isotope)->alphabetaminusdecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->alphabetaminusdecay())); - } - html.append(i18n(" %1, %2-", QChar(945), QChar(946) )); - if ((isotope)->alphabetaminuslikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->alphabetaminuslikeliness())); - } - if ((isotope)->betaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { - html.append(i18n(", ")); - } - } - if ((isotope)->betaminuslikeliness() > 0.0) { - if ((isotope)->betaminusdecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->betaminusdecay())); - } - html.append(i18n(" %1-", QChar(946))); - if ((isotope)->betaminuslikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->betaminuslikeliness())); - } - - if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { - html.append(i18n(", ")); - } - } - if ((isotope)->betaminusneutronlikeliness() > 0.0) { - if ((isotope)->betaminusneutrondecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->betaminusneutrondecay())); - } - html.append(i18n(" %1-, n", QChar(946))); - if ((isotope)->betaminusneutronlikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->betaminusneutronlikeliness())); - } - - if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { - html.append(i18n(", ")); - } - } - if ((isotope)->betaminusfissionlikeliness() > 0.0) { - if ((isotope)->betaminusfissiondecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->betaminusfissiondecay())); - } - html.append(i18n(" %1-, fission", QChar(946))); - if ((isotope)->betaminusfissionlikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->betaminusfissionlikeliness())); - } - - if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { - html.append(i18n(", ")); - } - } - if ((isotope)->betaminusalphalikeliness() > 0.0) { - if ((isotope)->betaminusalphadecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->betaminusalphadecay())); - } - html.append(i18n(" %1-, %2", QChar(946), QChar(945))); - if ((isotope)->betaminusalphalikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->betaminusalphalikeliness())); - } - - if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { - html.append(i18n(", ")); - } - } - if ((isotope)->betapluslikeliness() > 0.0) { - if ((isotope)->betaplusdecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->betaplusdecay())); - } - html.append(i18n(" %1+", QChar(946))); - if ((isotope)->betapluslikeliness() == (isotope)->eclikeliness()) { - if ((isotope)->ecdecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->ecdecay())); + /* if ((isotope)->alphalikeliness() > 0.0) { + if ((isotope)->alphadecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->alphadecay())); + } + html.append(i18n(" %1", QChar(945))); + if ((isotope)->alphalikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->alphalikeliness())); + } + if ((isotope)->betaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { + html.append(i18n(", ")); + } + } + if ((isotope)->alphabetaminuslikeliness() > 0.0) { + if ((isotope)->alphabetaminusdecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->alphabetaminusdecay())); + } + html.append(i18n(" %1, %2-", QChar(945), QChar(946) )); + if ((isotope)->alphabetaminuslikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->alphabetaminuslikeliness())); + } + if ((isotope)->betaminuslikeliness() > 0.0 || (isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { + html.append(i18n(", ")); + } + } + if ((isotope)->betaminuslikeliness() > 0.0) { + if ((isotope)->betaminusdecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->betaminusdecay())); + } + html.append(i18n(" %1-", QChar(946))); + if ((isotope)->betaminuslikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->betaminuslikeliness())); + } + + if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { + html.append(i18n(", ")); + } + } + if ((isotope)->betaminusneutronlikeliness() > 0.0) { + if ((isotope)->betaminusneutrondecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->betaminusneutrondecay())); + } + html.append(i18n(" %1-, n", QChar(946))); + if ((isotope)->betaminusneutronlikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->betaminusneutronlikeliness())); + } + + if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { + html.append(i18n(", ")); + } + } + if ((isotope)->betaminusfissionlikeliness() > 0.0) { + if ((isotope)->betaminusfissiondecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->betaminusfissiondecay())); + } + html.append(i18n(" %1-, fission", QChar(946))); + if ((isotope)->betaminusfissionlikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->betaminusfissionlikeliness())); + } + + if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { + html.append(i18n(", ")); + } + } + if ((isotope)->betaminusalphalikeliness() > 0.0) { + if ((isotope)->betaminusalphadecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->betaminusalphadecay())); + } + html.append(i18n(" %1-, %2", QChar(946), QChar(945))); + if ((isotope)->betaminusalphalikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->betaminusalphalikeliness())); + } + + if ((isotope)->betapluslikeliness() > 0.0 || (isotope)->eclikeliness() > 0.0) { + html.append(i18n(", ")); + } + } + if ((isotope)->betapluslikeliness() > 0.0) { + if ((isotope)->betaplusdecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->betaplusdecay())); + } + html.append(i18n(" %1+", QChar(946))); + if ((isotope)->betapluslikeliness() == (isotope)->eclikeliness()) { + if ((isotope)->ecdecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->ecdecay())); + } + html.append(i18nc("Acronym of Electron Capture"," EC")); + } + if ((isotope)->betapluslikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->betapluslikeliness())); + } + html += ' '; + } + if ((isotope)->betaplusprotonlikeliness() > 0.0) { + if ((isotope)->betaplusprotondecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->betaplusprotondecay())); + } + html.append(i18n(" %1+, p", QChar(946))); + if ((isotope)->betaplusprotonlikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->betaplusprotonlikeliness())); + } + html += ' '; + } + if ((isotope)->betaplusalphalikeliness() > 0.0) { + if ((isotope)->betaplusalphadecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->betaplusalphadecay())); + } + html.append(i18n(" %1+, %2", QChar(946),QChar(945))); + if ((isotope)->betaplusalphalikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->betaplusalphalikeliness())); + } + html += ' '; + } + if ((isotope)->eclikeliness() > 0.0) { + if ((isotope)->ecdecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->ecdecay())); + } + html.append(i18nc("Acronym of Electron Capture"," EC")); + if ((isotope)->eclikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->eclikeliness())); + } + } + if ((isotope)->neutronlikeliness() > 0.0) { + if ((isotope)->neutrondecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->neutrondecay())); + } + html.append(i18nc("Acronym of neutron emission"," n")); + if ((isotope)->neutronlikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->neutronlikeliness())); + } + } + if ((isotope)->protonlikeliness() > 0.0) { + if ((isotope)->protondecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->protondecay())); + } + html.append(i18nc("Acronym of proton emission"," p")); + if ((isotope)->protonlikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->protonlikeliness())); + } + } + if ((isotope)->protonalphalikeliness() > 0.0) { + if ((isotope)->protonalphadecay() > 0.0) { + html.append(i18n("%1 MeV", (isotope)->protonalphadecay())); + } + html.append(i18n(" p, %1", QChar(945))); + if ((isotope)->protonlikeliness() < 100.0) { + html.append(i18n("(%1%)", (isotope)->protonlikeliness())); + } } - html.append(i18nc("Acronym of Electron Capture"," EC")); - } - if ((isotope)->betapluslikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->betapluslikeliness())); - } - html += ' '; - } - if ((isotope)->betaplusprotonlikeliness() > 0.0) { - if ((isotope)->betaplusprotondecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->betaplusprotondecay())); - } - html.append(i18n(" %1+, p", QChar(946))); - if ((isotope)->betaplusprotonlikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->betaplusprotonlikeliness())); - } - html += ' '; - } - if ((isotope)->betaplusalphalikeliness() > 0.0) { - if ((isotope)->betaplusalphadecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->betaplusalphadecay())); - } - html.append(i18n(" %1+, %2", QChar(946),QChar(945))); - if ((isotope)->betaplusalphalikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->betaplusalphalikeliness())); - } - html += ' '; - } - if ((isotope)->eclikeliness() > 0.0) { - if ((isotope)->ecdecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->ecdecay())); - } - html.append(i18nc("Acronym of Electron Capture"," EC")); - if ((isotope)->eclikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->eclikeliness())); - } - } - if ((isotope)->neutronlikeliness() > 0.0) { - if ((isotope)->neutrondecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->neutrondecay())); - } - html.append(i18nc("Acronym of neutron emission"," n")); - if ((isotope)->neutronlikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->neutronlikeliness())); - } - } - if ((isotope)->protonlikeliness() > 0.0) { - if ((isotope)->protondecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->protondecay())); - } - html.append(i18nc("Acronym of proton emission"," p")); - if ((isotope)->protonlikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->protonlikeliness())); - } - } - if ((isotope)->protonalphalikeliness() > 0.0) { - if ((isotope)->protonalphadecay() > 0.0) { - html.append(i18n("%1 MeV", (isotope)->protonalphadecay())); - } - html.append(i18n(" p, %1", QChar(945))); - if ((isotope)->protonlikeliness() < 100.0) { - html.append(i18n("(%1%)", (isotope)->protonlikeliness())); - } - } -*/ + */ html.append(""); html.append((isotope)->spin()); html.append(""); @@ -1448,7 +1075,6 @@ QString DetailedInfoDlg::isotopeTable() const html.append(i18n("%1 %2n", (isotope)->magmoment(), QChar(956))); } html.append("
"); @@ -1460,28 +1086,28 @@ void DetailedInfoDlg::createContent() { KPageWidgetItem *item = nullptr; - // Removed the overview Tab, because its an Dockwidget and doesn't show much information. + // Removed the overview Tab, because its an Dockwidget and doesn't show much information. // overview tab -// QWidget *m_pOverviewTab = new QWidget(); -// item = addPage(m_pOverviewTab, i18n("Overview")); -// item->setHeader(i18n("Overview")); -// item->setIcon(QIcon("overview")); -// QVBoxLayout *overviewLayout = new QVBoxLayout(m_pOverviewTab); -// overviewLayout->setMargin(0); -// dTab = new DetailedGraphicalOverview(m_pOverviewTab); -// dTab->setObjectName("DetailedGraphicalOverview"); -// overviewLayout->addWidget(dTab); - -//X // picture tab -//X QWidget *m_pPictureTab = new QWidget(); -//X item = addPage(m_pPictureTab, i18n("Picture")); -//X item->setHeader(i18n("What does this element look like?")); -//X item->setIcon(QIcon("elempic")); -//X QVBoxLayout *mainLayout = new QVBoxLayout(m_pPictureTab); -//X mainLayout->setMargin(0); -//X piclabel = new QLabel(m_pPictureTab); -//X piclabel->setMinimumSize(400, 350); -//X mainLayout->addWidget(piclabel); + // QWidget *m_pOverviewTab = new QWidget(); + // item = addPage(m_pOverviewTab, i18n("Overview")); + // item->setHeader(i18n("Overview")); + // item->setIcon(QIcon("overview")); + // QVBoxLayout *overviewLayout = new QVBoxLayout(m_pOverviewTab); + // overviewLayout->setMargin(0); + // dTab = new DetailedGraphicalOverview(m_pOverviewTab); + // dTab->setObjectName("DetailedGraphicalOverview"); + // overviewLayout->addWidget(dTab); + + // X // picture tab + // X QWidget *m_pPictureTab = new QWidget(); + // X item = addPage(m_pPictureTab, i18n("Picture")); + // X item->setHeader(i18n("What does this element look like?")); + // X item->setIcon(QIcon("elempic")); + // X QVBoxLayout *mainLayout = new QVBoxLayout(m_pPictureTab); + // X mainLayout->setMargin(0); + // X piclabel = new QLabel(m_pPictureTab); + // X piclabel->setMinimumSize(400, 350); + // X mainLayout->addWidget(piclabel); // html tab m_htmlpages[QStringLiteral("new")] = addHTMLTab(i18n("Data Overview"), i18n("Data Overview"), QStringLiteral("applications-science")); @@ -1527,18 +1153,18 @@ void DetailedInfoDlg::reloadContent() const QString element_block = m_element->dataAsString(ChemicalDataObject::periodTableBlock); // updating caption - setWindowTitle(i18nc("@title:window, for example: [C] Carbon (6 - Block p)", "[%1] %2 (%3 - Block %4)", - element_symbol, element_name, m_elementNumber, element_block)); - - //X // updating picture tab - //X QString picpath = m_picsdir + element_symbol + ".jpg"; - //X if (QFile::exists(picpath)) { - //X QImage img(picpath, "JPEG"); - //X img = img.scaled(400, 400, Qt::KeepAspectRatio); - //X piclabel->setPixmap(QPixmap::fromImage(img)); - //X } else { - //X piclabel->setText(i18n("No picture of %1 found.", element_name)); - //X } + setWindowTitle( + i18nc("@title:window, for example: [C] Carbon (6 - Block p)", "[%1] %2 (%3 - Block %4)", element_symbol, element_name, m_elementNumber, element_block)); + + // X // updating picture tab + // X QString picpath = m_picsdir + element_symbol + ".jpg"; + // X if (QFile::exists(picpath)) { + // X QImage img(picpath, "JPEG"); + // X img = img.scaled(400, 400, Qt::KeepAspectRatio); + // X piclabel->setPixmap(QPixmap::fromImage(img)); + // X } else { + // X piclabel->setText(i18n("No picture of %1 found.", element_name)); + // X } // updating atomic model tab wOrbits->setElementNumber(m_elementNumber); @@ -1556,7 +1182,7 @@ void DetailedInfoDlg::reloadContent() fillHTMLTab(m_htmlpages[QStringLiteral("isotopes")], getHtml(ISOTOPES)); fillHTMLTab(m_htmlpages[QStringLiteral("extra")], getHtml(EXTRA)); - Spectrum * spec = KalziumDataObject::instance()->spectrum(m_elementNumber); + Spectrum *spec = KalziumDataObject::instance()->spectrum(m_elementNumber); // updating spectrum widget if (spec) { @@ -1566,28 +1192,26 @@ void DetailedInfoDlg::reloadContent() m_spectrumLabel->setText(i18n("No spectrum of %1 found.", element_name)); m_spectrumStack->setCurrentWidget(m_spectrumLabel); } - } QString DetailedInfoDlg::createWikiLink(QString link) { - return createWikiLink(link, link); + return createWikiLink(link, link); } - QString DetailedInfoDlg::createWikiLink(QString link, QString displayString) { QString html; QString language(QLocale().uiLanguages().first()); - //Wikipedia.org - html.append (" "); - html.append (displayString); - html.append (""); + // Wikipedia.org + html.append(" "); + html.append(displayString); + html.append(""); // Example from the comment "https://en.wikipedia.org/wiki/hydrogen" return html; @@ -1595,7 +1219,7 @@ QString DetailedInfoDlg::createWikiLink(QString link, QString displayString) void DetailedInfoDlg::slotHelp() { - //TODO fix this stuff... + // TODO fix this stuff... #if 0 QString chapter = "infodialog_overview"; switch (activePageIndex()) { @@ -1622,7 +1246,7 @@ void DetailedInfoDlg::slotHelp() break; } #endif - KHelpClient::invokeHelp(QStringLiteral("info-dlg.html#infodialog_spectrum"), QStringLiteral("kalzium")); + KHelpClient::invokeHelp(QStringLiteral("info-dlg.html#infodialog_spectrum"), QStringLiteral("kalzium")); } void DetailedInfoDlg::showNextElement() @@ -1634,4 +1258,3 @@ void DetailedInfoDlg::showPreviousElement() { setElement(pseTables::instance()->getTabletype(m_tableTyp)->previousOf(m_elementNumber)); } - diff --git a/src/detailinfodlg.h b/src/detailinfodlg.h index a363efd9bd763f6172f6b515ccc51d2aec7166d3..9302d88750937f0f2737136f14c88457d2cfbea0 100644 --- a/src/detailinfodlg.h +++ b/src/detailinfodlg.h @@ -36,7 +36,7 @@ public: void setElement(int el); -// void setOverviewBackgroundColor(const QColor &bgColor); + // void setOverviewBackgroundColor(const QColor &bgColor); void setTableType(int ktt); @@ -44,31 +44,31 @@ public: * add to the numbers @return the beatified string */ - QString beautifyOrbitalString(const QString& orbits); + QString beautifyOrbitalString(const QString &orbits); private: enum DATATYPE { MISC = 0, ISOTOPES, DATA, /** m_htmlpages; + QMap m_htmlpages; int m_tableTyp; @@ -83,7 +83,7 @@ private: QString m_baseHtml; QString m_baseHtml2; -//X QString m_picsdir; + // X QString m_picsdir; /** * Add a new HTML page to the dialog. @@ -95,14 +95,14 @@ private: * @returns the pointer to the resulting KHTMLPart, needed for * writing HTML code on it */ - QTextBrowser* addHTMLTab(const QString& title, const QString& icontext, const QString& iconname); + QTextBrowser *addHTMLTab(const QString &title, const QString &icontext, const QString &iconname); /** * Change the HTML code in an HTML page. * * @param browser the QTextBrowser to edit * @param htmlcode the HTML code to display */ - void fillHTMLTab(QTextBrowser *browser, const QString& htmlcode); + void fillHTMLTab(QTextBrowser *browser, const QString &htmlcode); /** * Creates a localized link to Wikipedia. diff --git a/src/elementdataviewer.cpp b/src/elementdataviewer.cpp index b5b35c3930927d839c716142e7fb085f68a51c7e..8aa1dc00cc02cc9b1e3f9ff19492d01c97f49a59 100644 --- a/src/elementdataviewer.cpp +++ b/src/elementdataviewer.cpp @@ -9,7 +9,7 @@ #include "prefs.h" -//Qt-Includes +// Qt-Includes #include "kalzium_debug.h" #include #include @@ -27,7 +27,8 @@ #include #include -AxisData::AxisData(AXISTYPE type) : currentDataType(-1) +AxisData::AxisData(AXISTYPE type) + : currentDataType(-1) { m_type = type; } @@ -41,14 +42,13 @@ double AxisData::value(int element) const return dataList[element - 1]; } - ElementDataViewer::ElementDataViewer(QWidget *parent) - : QDialog(parent), - m_yData(new AxisData(AxisData::Y)), - m_xData(new AxisData(AxisData::X)) + : QDialog(parent) + , m_yData(new AxisData(AxisData::Y)) + , m_xData(new AxisData(AxisData::X)) { setWindowTitle(i18nc("@title:window", "Plot Data")); - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help|QDialogButtonBox::Close); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); @@ -58,7 +58,7 @@ ElementDataViewer::ElementDataViewer(QWidget *parent) mainLayout->addWidget(buttonBox); buttonBox->button(QDialogButtonBox::Close)->setDefault(true); - KalziumDataObject *kdo = KalziumDataObject::instance(); + KalziumDataObject *kdo = KalziumDataObject::instance(); ui.setupUi(mainWidget); @@ -69,33 +69,23 @@ ElementDataViewer::ElementDataViewer(QWidget *parent) foreach (Element *e, kdo->ElementList) { names << e->dataAsString(ChemicalDataObject::name); symbols << e->dataAsString(ChemicalDataObject::symbol); - elecConfig<< e->dataAsString(ChemicalDataObject::electronicConfiguration); + elecConfig << e->dataAsString(ChemicalDataObject::electronicConfiguration); block << e->dataAsString(ChemicalDataObject::periodTableBlock); } - m_actionCollection = new KActionCollection (this); + m_actionCollection = new KActionCollection(this); KStandardAction::quit(this, SLOT(close()), m_actionCollection); - connect(m_timer, &QTimer::timeout, - this, &ElementDataViewer::drawPlot); - connect(ui.KCB_y, QOverload::of(&KComboBox::activated), - this, &ElementDataViewer::rangeChanged); - connect(ui.KCB_x, QOverload::of(&KComboBox::activated), - this, &ElementDataViewer::rangeChanged); - connect(ui.comboElementLabels, QOverload::of(&KComboBox::activated), - this, &ElementDataViewer::rangeChanged); - connect(ui.comboElementType, QOverload::of(&KComboBox::activated), - this, &ElementDataViewer::rangeChanged); - connect(ui.from, QOverload::of(&QSpinBox::valueChanged), - this, &ElementDataViewer::rangeChanged); - connect(ui.to, QOverload::of(&QSpinBox::valueChanged), - this, &ElementDataViewer::rangeChanged); - connect(buttonBox->button(QDialogButtonBox::Help), &QPushButton::clicked, - this, &ElementDataViewer::slotHelp); - connect(ui.full, &QPushButton::clicked, - this, &ElementDataViewer::fullRange); - connect(ui.swapXYAxis, &QPushButton::clicked, - this, &ElementDataViewer::swapXYAxis); + connect(m_timer, &QTimer::timeout, this, &ElementDataViewer::drawPlot); + connect(ui.KCB_y, QOverload::of(&KComboBox::activated), this, &ElementDataViewer::rangeChanged); + connect(ui.KCB_x, QOverload::of(&KComboBox::activated), this, &ElementDataViewer::rangeChanged); + connect(ui.comboElementLabels, QOverload::of(&KComboBox::activated), this, &ElementDataViewer::rangeChanged); + connect(ui.comboElementType, QOverload::of(&KComboBox::activated), this, &ElementDataViewer::rangeChanged); + connect(ui.from, QOverload::of(&QSpinBox::valueChanged), this, &ElementDataViewer::rangeChanged); + connect(ui.to, QOverload::of(&QSpinBox::valueChanged), this, &ElementDataViewer::rangeChanged); + connect(buttonBox->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &ElementDataViewer::slotHelp); + connect(ui.full, &QPushButton::clicked, this, &ElementDataViewer::fullRange); + connect(ui.swapXYAxis, &QPushButton::clicked, this, &ElementDataViewer::swapXYAxis); drawPlot(); resize(650, 500); @@ -124,18 +114,18 @@ void ElementDataViewer::rangeChanged() void ElementDataViewer::fullRange() { - ui.from ->setValue(1); - ui.to ->setValue(116); + ui.from->setValue(1); + ui.to->setValue(116); } void ElementDataViewer::swapXYAxis() { int x = ui.KCB_x->currentIndex(); int y = ui.KCB_y->currentIndex(); - + ui.KCB_x->setCurrentIndex(y); ui.KCB_y->setCurrentIndex(x); - + rangeChanged(); } @@ -148,39 +138,39 @@ void ElementDataViewer::setLimits() getMinMax(x1, x2, m_xData); getMinMax(y1, y2, m_yData); - qCDebug(KALZIUM_LOG) << x1 << " :: " << x2 << " ----- " << y1 << " :: " << y2; + qCDebug(KALZIUM_LOG) << x1 << " :: " << x2 << " ----- " << y1 << " :: " << y2; - //JH: add some padding to show all points - double dx = 0.05*(x2-x1); - double dy = 0.05*(y2-y1); + // JH: add some padding to show all points + double dx = 0.05 * (x2 - x1); + double dy = 0.05 * (y2 - y1); x1 -= dx; x2 += dx; y1 -= dy; y2 += dy; -//X // try to put a small padding to make the points on the axis visible -//X double dx = (to - from + 1) / 25 + 1.0; -//X double dy = (maxY - minY) / 10.0; -//X // in case that dy is quite small (for example, when plotting a single -//X // point) -//X if (dy < 1e-7) -//X dy = maxY / 10.0; -//X ui.plotwidget->setLimits(from - dx, to + dx, minY - dy, maxY + dy); + // X // try to put a small padding to make the points on the axis visible + // X double dx = (to - from + 1) / 25 + 1.0; + // X double dy = (maxY - minY) / 10.0; + // X // in case that dy is quite small (for example, when plotting a single + // X // point) + // X if (dy < 1e-7) + // X dy = maxY / 10.0; + // X ui.plotwidget->setLimits(from - dx, to + dx, minY - dy, maxY + dy); ui.plotwidget->setLimits(x1, x2, y1, y2); } -void ElementDataViewer::getMinMax(double& min, double& max, AxisData * data) +void ElementDataViewer::getMinMax(double &min, double &max, AxisData *data) { int firstElement = ui.from->value(); - int lastElement = ui.to->value(); + int lastElement = ui.to->value(); double minValue = data->value(firstElement); double maxValue = data->value(firstElement); qCDebug(KALZIUM_LOG) << "Taking elements from " << firstElement << " to " << lastElement; - for (int _currentVal = firstElement; _currentVal <= lastElement; ++_currentVal) { //go over all selected elements + for (int _currentVal = firstElement; _currentVal <= lastElement; ++_currentVal) { // go over all selected elements double v = data->value(_currentVal); if (minValue > v) { @@ -191,7 +181,7 @@ void ElementDataViewer::getMinMax(double& min, double& max, AxisData * data) } } - qCDebug(KALZIUM_LOG) << "The value are ]"<< minValue << " , " << maxValue << "[."; + qCDebug(KALZIUM_LOG) << "The value are ]" << minValue << " , " << maxValue << "[."; min = minValue; max = maxValue; @@ -214,8 +204,12 @@ void ElementDataViewer::keyPressEvent(QKeyEvent *e) } } -void ElementDataViewer::slotZoomIn() {} -void ElementDataViewer::slotZoomOut() {} +void ElementDataViewer::slotZoomIn() +{ +} +void ElementDataViewer::slotZoomOut() +{ +} void ElementDataViewer::setupAxisData(AxisData *data) { @@ -234,47 +228,40 @@ void ElementDataViewer::setupAxisData(AxisData *data) int unit = KUnitConversion::NoUnit; switch (selectedData) { - case AxisData::NUMBER: - { + case AxisData::NUMBER: { kind = ChemicalDataObject::atomicNumber; caption = i18n("Atomic Number"); break; } - case AxisData::MASS: - { + case AxisData::MASS: { kind = ChemicalDataObject::mass; caption = i18n("Atomic Mass"); break; } - case AxisData::EN: - { + case AxisData::EN: { kind = ChemicalDataObject::electronegativityPauling; caption = i18n("Electronegativity"); break; } - case AxisData::MELTINGPOINT: - { + case AxisData::MELTINGPOINT: { kind = ChemicalDataObject::meltingpoint; caption = i18n("Melting Point"); unit = Prefs::temperatureUnit(); break; } - case AxisData::BOILINGPOINT: - { + case AxisData::BOILINGPOINT: { kind = ChemicalDataObject::boilingpoint; caption = i18n("Boiling Point"); unit = Prefs::temperatureUnit(); break; } - case AxisData::ATOMICRADIUS: - { + case AxisData::ATOMICRADIUS: { kind = ChemicalDataObject::radiusVDW; caption = i18n("Atomic Radius"); unit = Prefs::lengthUnit(); break; } - case AxisData::COVALENTRADIUS: - { + case AxisData::COVALENTRADIUS: { kind = ChemicalDataObject::radiusCovalent; caption = i18n("Covalent Radius"); unit = Prefs::lengthUnit(); @@ -284,7 +271,7 @@ void ElementDataViewer::setupAxisData(AxisData *data) KalziumDataObject *kdo = KalziumDataObject::instance(); DoubleList dblDataList; - foreach (Element * element, kdo->ElementList) { + foreach (Element *element, kdo->ElementList) { dblDataList << element->dataAsVariant(kind, unit).toDouble(); } @@ -293,7 +280,7 @@ void ElementDataViewer::setupAxisData(AxisData *data) data->kind = kind; if (unit != KUnitConversion::NoUnit) { - QString stringUnit = KalziumDataObject::instance()->unitAsString(unit); + QString stringUnit = KalziumDataObject::instance()->unitAsString(unit); data->unit = QString(' ' + stringUnit); caption.append(" ["); @@ -345,13 +332,13 @@ void ElementDataViewer::drawPlot() QSet metals, metalloids, nonMetals; metals << 3 << 4 << 11 << 12 << 13; - for (int i = 19; i <= 31; ++i) { + for (int i = 19; i <= 31; ++i) { metals << i; } - for (int i = 37; i <= 50; ++i) { + for (int i = 37; i <= 50; ++i) { metals << i; } - for (int i = 55; i <= 83; ++i) { + for (int i = 55; i <= 83; ++i) { metals << i; } for (int i = 87; i <= 116; ++i) { @@ -374,8 +361,8 @@ void ElementDataViewer::drawPlot() */ int whichType = ui.comboElementType->currentIndex(); - KPlotObject* dataPointGreen = nullptr; - KPlotObject* dataPointRed = nullptr; + KPlotObject *dataPointGreen = nullptr; + KPlotObject *dataPointRed = nullptr; double av_x = 0.0; double max_x = m_xData->value(from); @@ -388,18 +375,11 @@ void ElementDataViewer::drawPlot() * iterate for example from element 20 to 30 and construct * the KPlotObjects */ - dataPointGreen = new KPlotObject( - Qt::green, - KPlotObject::Points, - 4, - KPlotObject::Star); + dataPointGreen = new KPlotObject(Qt::green, KPlotObject::Points, 4, KPlotObject::Star); dataPointGreen->setLabelPen(QPen(Qt::blue)); - dataPointRed = new KPlotObject( - Qt::red, - KPlotObject::Points, - 4, - KPlotObject::Star); //Star can be replaced with a cross + dataPointRed = new KPlotObject(Qt::red, KPlotObject::Points, 4, + KPlotObject::Star); // Star can be replaced with a cross dataPointRed->setLabelPen(QPen(Qt::blue)); for (int i = from; i < to + 1; ++i) { @@ -407,64 +387,60 @@ void ElementDataViewer::drawPlot() double value_x = m_xData->value(i); bool known = ((value_y) > 0.0) ? 1 : 0; - //The element is know if its value is not zero + // The element is know if its value is not zero bool belongs = 1; - //The value of belongs is one if it belongs to the particular group + // The value of belongs is one if it belongs to the particular group - //See if the particular element belongs to the selected set or not. - //If a particular group of elements is selected, + // See if the particular element belongs to the selected set or not. + // If a particular group of elements is selected, if (whichType > 0) { belongs = 0; switch (whichType) { - case 1: //Plot only metals - belongs = metals . contains(i); + case 1: // Plot only metals + belongs = metals.contains(i); break; - case 2: //plot only nonmetals and metalloids + case 2: // plot only nonmetals and metalloids belongs = (nonMetals.contains(i) || metalloids.contains(i)); break; - case 3: //Plot s block elements - belongs = (block[i - 1]== QLatin1String("s")); + case 3: // Plot s block elements + belongs = (block[i - 1] == QLatin1String("s")); break; - case 4: //Plot p block elements - belongs = (block[i - 1]== QLatin1String("p")); + case 4: // Plot p block elements + belongs = (block[i - 1] == QLatin1String("p")); break; - case 5: //Plot d block elements - belongs = (block[i - 1]== QLatin1String("d")); + case 5: // Plot d block elements + belongs = (block[i - 1] == QLatin1String("d")); break; - case 6: //plot f block elements - belongs = (block[i - 1]== QLatin1String("f")); + case 6: // plot f block elements + belongs = (block[i - 1] == QLatin1String("f")); break; case 7: // Noble gases - belongs = ((elecConfig[i - 1]) . endsWith(QLatin1String("p6"))); - belongs |= (i == 2); //Include Helium + belongs = ((elecConfig[i - 1]).endsWith(QLatin1String("p6"))); + belongs |= (i == 2); // Include Helium break; case 8: // Alkalie metals - belongs = ((elecConfig[i - 1]) . endsWith(QLatin1String("s1"))); - belongs &= (block[i - 1]== QLatin1String("s")); //exclude chromium - belongs &= (i != 1); //exclude Hydrogen + belongs = ((elecConfig[i - 1]).endsWith(QLatin1String("s1"))); + belongs &= (block[i - 1] == QLatin1String("s")); // exclude chromium + belongs &= (i != 1); // exclude Hydrogen break; case 9: // Alkaline earth metals - belongs = ((elecConfig[i - 1]) . endsWith(QLatin1String("s2"))); - belongs &= (block[i - 1]== QLatin1String("s")); //exclude chromium - belongs &= (i != 2); //exclude Helium + belongs = ((elecConfig[i - 1]).endsWith(QLatin1String("s2"))); + belongs &= (block[i - 1] == QLatin1String("s")); // exclude chromium + belongs &= (i != 2); // exclude Helium break; case 10: // Lanthanides // If element i is an f block element, with // electronic configuration containing "f4" in it // or the element is Lanthanum - belongs = ((block[i - 1]== QLatin1String("f")) && \ - ((elecConfig[i - 1]) . contains (QLatin1String("4f")))) || \ - (i == 57); //Lanthanum 57 + belongs = ((block[i - 1] == QLatin1String("f")) && ((elecConfig[i - 1]).contains(QLatin1String("4f")))) || (i == 57); // Lanthanum 57 break; - case 11: //Actinides - //If element i is an f block element, with - // electronic configuration containing "f5" in it - // or the element is Actinium - belongs = (((block[i - 1]== QLatin1String("f"))) && \ - ((elecConfig[i - 1]) . contains (QLatin1String("5f")))) || \ - (i == 89); //Actinium 89 + case 11: // Actinides + // If element i is an f block element, with + // electronic configuration containing "f5" in it + // or the element is Actinium + belongs = (((block[i - 1] == QLatin1String("f"))) && ((elecConfig[i - 1]).contains(QLatin1String("5f")))) || (i == 89); // Actinium 89 break; - case 12: //Radio active + case 12: // Radio active belongs = ((i == 43) || (i == 61) || (i > 84)); // Technitium prothomium and then polonium onwards. break; @@ -492,27 +468,27 @@ void ElementDataViewer::drawPlot() } QString lbl; - if (whatShow > 0) { //The users wants to see the labels - lbl = whatShow == 1 ? names[i-1] : symbols[i-1]; + if (whatShow > 0) { // The users wants to see the labels + lbl = whatShow == 1 ? names[i - 1] : symbols[i - 1]; } dataPointGreen->addPoint(value_x, value_y, lbl); - } else { //unknown value - //num is required while finding the average, if an element is not - //known it should not contribute to the average. + } else { // unknown value + // num is required while finding the average, if an element is not + // known it should not contribute to the average. --num; QString lbl; - if (whatShow > 0) { //The user wants to see the labels + if (whatShow > 0) { // The user wants to see the labels lbl = whatShow == 1 ? names[i - 1] : symbols[i - 1]; } dataPointRed->addPoint(value_x, value_y, lbl); - //For an Unknown value, use a red point to mark the data-point. + // For an Unknown value, use a red point to mark the data-point. } - } else { //The element does not belong to the set - //num is required while finding average, if an element is - //not in the selected set, it should not contribute to the avg. + } else { // The element does not belong to the set + // num is required while finding average, if an element is + // not in the selected set, it should not contribute to the avg. --num; } } @@ -521,7 +497,7 @@ void ElementDataViewer::drawPlot() ui.plotwidget->addPlotObject(dataPointRed); if (num > 0) { - //now set the values for the min, max and average value + // now set the values for the min, max and average value ui.av_x->setText(QString::number(av_x / num).append(m_xData->unit)); ui.minimum_x->setText(QString::number(min_x).append(m_xData->unit)); ui.maximum_x->setText(QString::number(max_x).append(m_xData->unit)); @@ -544,4 +520,3 @@ void ElementDataViewer::initData() setupAxisData(m_xData); setupAxisData(m_yData); } - diff --git a/src/elementdataviewer.h b/src/elementdataviewer.h index 4a86136e54b87f85db9763736eeb3c776e5ec3f8..fb679954c5cf188522facac5c00012ca016c620c 100644 --- a/src/elementdataviewer.h +++ b/src/elementdataviewer.h @@ -6,10 +6,10 @@ #ifndef ELEMENTDATAVIEWER_H #define ELEMENTDATAVIEWER_H -#include -#include "ui_plotsetupwidget.h" #include "kalziumdataobject.h" #include "kalziumutils.h" +#include "ui_plotsetupwidget.h" +#include class QTimer; class KActionCollection; @@ -26,20 +26,9 @@ public: /** * This represents the possible datasets. */ - enum PAXISDATA { - NUMBER = 0, - MASS, - EN, - MELTINGPOINT, - BOILINGPOINT, - ATOMICRADIUS, - COVALENTRADIUS - }; - - enum AXISTYPE { - X = 0, - Y - }; + enum PAXISDATA { NUMBER = 0, MASS, EN, MELTINGPOINT, BOILINGPOINT, ATOMICRADIUS, COVALENTRADIUS }; + + enum AXISTYPE { X = 0, Y }; explicit AxisData(AxisData::AXISTYPE); @@ -70,7 +59,6 @@ private: AXISTYPE m_type; }; - /** * @short This widget shows the plot and the widget * where you can setup the plot @@ -95,25 +83,24 @@ public: */ AxisData *m_xData; - protected: void keyPressEvent(QKeyEvent *e) override; private: Ui::PlotSetupWidget ui; - void getMinMax(double& min, double& max, AxisData * data); + void getMinMax(double &min, double &max, AxisData *data); - QStringList names; - QStringList symbols; - QStringList elecConfig; //Electronic configuration of elements - QStringList block; //Indicates the periodic table block s,p,d,f... + QStringList names; + QStringList symbols; + QStringList elecConfig; // Electronic configuration of elements + QStringList block; // Indicates the periodic table block s,p,d,f... QTimer *m_timer; - KActionCollection* m_actionCollection; + KActionCollection *m_actionCollection; void initData(); - void setupAxisData(AxisData * data); + void setupAxisData(AxisData *data); void setLimits(); diff --git a/src/eqchemview.cpp b/src/eqchemview.cpp index c1d4e05365e060629f27db104a83bb909ecfe7ae..73fd165d1f42bfaf8b5410ba2ed8a08db5e5870d 100644 --- a/src/eqchemview.cpp +++ b/src/eqchemview.cpp @@ -20,10 +20,11 @@ #ifdef HAVE_FACILE extern "C" { - char* solve_equation(const char *); +char *solve_equation(const char *); } #else -char* solve_equation(const char *) { +char *solve_equation(const char *) +{ return NULL; } #endif @@ -35,7 +36,7 @@ void EQChemDialog::compute() equation.append(' '); equation.prepend(' '); - char * result = solve_equation(equation.toLatin1().constData()); + char *result = solve_equation(equation.toLatin1().constData()); QString answer = QString(result); @@ -47,7 +48,8 @@ void EQChemDialog::compute() free(result); } -EQChemDialog::EQChemDialog(QWidget *parent) : QWidget(parent) +EQChemDialog::EQChemDialog(QWidget *parent) + : QWidget(parent) { ui.setupUi(this); @@ -56,10 +58,8 @@ EQChemDialog::EQChemDialog(QWidget *parent) : QWidget(parent) ui.lblHelp->setText(getHelpText()); - connect(ui.calculateButton, &QAbstractButton::clicked, - this, &EQChemDialog::compute); - connect(ui.btnCopy, &QAbstractButton::clicked, - this, &EQChemDialog::copyAnswer); + connect(ui.calculateButton, &QAbstractButton::clicked, this, &EQChemDialog::compute); + connect(ui.btnCopy, &QAbstractButton::clicked, this, &EQChemDialog::copyAnswer); } void EQChemDialog::copyAnswer() @@ -71,20 +71,18 @@ void EQChemDialog::copyAnswer() const QString EQChemDialog::getHelpText() { - return i18nc( - "Help text for the chemical equation solver", - "The equation solver allows you to balance a chemical equation.
" - "
" - "Using Variables
" - "To express variable quantities of an element, put a single character in front " - "of the element's symbol, as shown in this example:
" - "aH + bO -> 5H2O (Result: 10 H + 5 O -> 5 H2O)
" - "Solving this expression will give you the needed amount of Hydrogen and Oxygen.
" - "
" - "Defining electric charges
" - "Use box brackets to specify the electric charge of an element, as shown in this example:
" - "4H[+] + 2O -> cH2O[2+] (Result: 4 H+ + 2 O -> 2 H2O2+)" - ); + return i18nc("Help text for the chemical equation solver", + "The equation solver allows you to balance a chemical equation.
" + "
" + "Using Variables
" + "To express variable quantities of an element, put a single character in front " + "of the element's symbol, as shown in this example:
" + "aH + bO -> 5H2O (Result: 10 H + 5 O -> 5 H2O)
" + "Solving this expression will give you the needed amount of Hydrogen and Oxygen.
" + "
" + "Defining electric charges
" + "Use box brackets to specify the electric charge of an element, as shown in this example:
" + "4H[+] + 2O -> cH2O[2+] (Result: 4 H+ + 2 O -> 2 H2O2+)"); } QSize EQChemDialog::sizeHint() const diff --git a/src/exportdialog.cpp b/src/exportdialog.cpp index 29c261294d2b8789c17d5f2ea4ca5399f5a04a5b..6a374335d97e3118aa20eb8462c43194f890b753 100644 --- a/src/exportdialog.cpp +++ b/src/exportdialog.cpp @@ -20,7 +20,6 @@ #include #include - static const char HTML_HEADER[] = "" "\n" @@ -45,15 +44,14 @@ static const char HTML_FOOTER[] = "\n" "\n"; -static const char XML_HEADER[] = - "\n"; +static const char XML_HEADER[] = "\n"; -ElementListEntry::ElementListEntry(Element * element) - : QListWidgetItem() +ElementListEntry::ElementListEntry(Element *element) + : QListWidgetItem() { m_atomicNum = element->dataAsVariant(ChemicalDataObject::atomicNumber).toInt(); - m_name = element->dataAsString(ChemicalDataObject::name); - m_element = element; + m_name = element->dataAsString(ChemicalDataObject::name); + m_element = element; setText(m_name); } @@ -62,8 +60,8 @@ ElementListEntry::~ElementListEntry() { } -PropertyListEntry::PropertyListEntry(const QString & name, ChemicalDataObject::BlueObelisk type) - : QListWidgetItem() +PropertyListEntry::PropertyListEntry(const QString &name, ChemicalDataObject::BlueObelisk type) + : QListWidgetItem() { setText(name); m_type = type; @@ -73,11 +71,12 @@ PropertyListEntry::~PropertyListEntry() { } -ExportDialog::ExportDialog(QWidget * parent) - : QDialog(parent),m_outputStream(nullptr) +ExportDialog::ExportDialog(QWidget *parent) + : QDialog(parent) + , m_outputStream(nullptr) { qCDebug(KALZIUM_LOG) << "ExportDialog::ExportDialog"; - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Help, this); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Help, this); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); @@ -139,7 +138,7 @@ void ExportDialog::populateElementList() ui.propertyListWidget->addItem(new PropertyListEntry(i18n("Atomic Number"), ChemicalDataObject::atomicNumber)); ui.propertyListWidget->addItem(new PropertyListEntry(i18n("Symbol"), ChemicalDataObject::symbol)); - //ui.propertyListWidget->addItem(new PropertyListEntry(i18n("Name"), ChemicalDataObject::name)); + // ui.propertyListWidget->addItem(new PropertyListEntry(i18n("Name"), ChemicalDataObject::name)); ui.propertyListWidget->addItem(new PropertyListEntry(i18n("Mass"), ChemicalDataObject::mass)); ui.propertyListWidget->addItem(new PropertyListEntry(i18n("Exact Mass"), ChemicalDataObject::exactMass)); ui.propertyListWidget->addItem(new PropertyListEntry(i18n("Ionization"), ChemicalDataObject::ionization)); @@ -193,17 +192,10 @@ void ExportDialog::exportToHtml() { *m_outputStream << HTML_HEADER << "\n"; foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { - *m_outputStream << "\n\n\n"; + *m_outputStream << "\n\n\n"; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { - *m_outputStream << "\n\n\n\n"; + *m_outputStream << "\n\n\n\n"; } } *m_outputStream << "
" - << ((ElementListEntry*)element)->m_element->dataAsString(ChemicalDataObject::name) - << "
" << ((ElementListEntry *)element)->m_element->dataAsString(ChemicalDataObject::name) << "
" - << ((PropertyListEntry*) property)->text() - << "" - << KalziumUtils::prettyUnit( - ((ElementListEntry*) element)->m_element, - ((PropertyListEntry*) property)->m_type) - << "
" << ((PropertyListEntry *)property)->text() << "" + << KalziumUtils::prettyUnit(((ElementListEntry *)element)->m_element, ((PropertyListEntry *)property)->m_type) << "
\n" << HTML_FOOTER; @@ -213,17 +205,10 @@ void ExportDialog::exportToXml() { *m_outputStream << XML_HEADER << "\n"; foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { - *m_outputStream << " m_element->dataAsString(ChemicalDataObject::name) - << "\">\n"; + *m_outputStream << " m_element->dataAsString(ChemicalDataObject::name) << "\">\n"; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { - *m_outputStream << " text() - << "\">" - << KalziumUtils::prettyUnit( - ((ElementListEntry*) element)->m_element, - ((PropertyListEntry*) property)->m_type) - << "\n"; + *m_outputStream << " text() << "\">" + << KalziumUtils::prettyUnit(((ElementListEntry *)element)->m_element, ((PropertyListEntry *)property)->m_type) << "\n"; } *m_outputStream << " \n"; } @@ -234,21 +219,13 @@ void ExportDialog::exportToCsv() { *m_outputStream << "Name"; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { - *m_outputStream << ", \"" - << ((PropertyListEntry*) property)->text() - << "\""; + *m_outputStream << ", \"" << ((PropertyListEntry *)property)->text() << "\""; } *m_outputStream << "\n"; foreach (QListWidgetItem *element, ui.elementListWidget->selectedItems()) { - *m_outputStream << "\"" - << ((ElementListEntry*) element)->m_element->dataAsString(ChemicalDataObject::name) - << "\""; + *m_outputStream << "\"" << ((ElementListEntry *)element)->m_element->dataAsString(ChemicalDataObject::name) << "\""; foreach (QListWidgetItem *property, ui.propertyListWidget->selectedItems()) { - *m_outputStream << ", \"" - << KalziumUtils::prettyUnit( - ((ElementListEntry*) element)->m_element, - ((PropertyListEntry*) property)->m_type) - << "\""; + *m_outputStream << ", \"" << KalziumUtils::prettyUnit(((ElementListEntry *)element)->m_element, ((PropertyListEntry *)property)->m_type) << "\""; } *m_outputStream << "\n"; } diff --git a/src/exportdialog.h b/src/exportdialog.h index 99b4053a6fc2c8dd167d35db596ba522e3b76e0e..ea79ff1e34cce92415de8edd9f8f17e5eba0763b 100644 --- a/src/exportdialog.h +++ b/src/exportdialog.h @@ -9,10 +9,9 @@ #include #include -#include #include "kalziumdataobject.h" #include "ui_exportdialog.h" - +#include class ElementListEntry : public QListWidgetItem { @@ -20,23 +19,23 @@ public: explicit ElementListEntry(Element *element); ~ElementListEntry(); - int m_atomicNum; - QString m_name; - Element *m_element; + int m_atomicNum; + QString m_name; + Element *m_element; }; class PropertyListEntry : public QListWidgetItem { public: - PropertyListEntry(const QString & name, ChemicalDataObject::BlueObelisk type); + PropertyListEntry(const QString &name, ChemicalDataObject::BlueObelisk type); ~PropertyListEntry(); ChemicalDataObject::BlueObelisk m_type; }; /** -* @author: Johannes Simon -*/ + * @author: Johannes Simon + */ class ExportDialog : public QDialog { Q_OBJECT @@ -60,7 +59,6 @@ public Q_SLOTS: * Open help page */ void slotHelpRequested(); - }; #endif // EXPORTDIALOG_H diff --git a/src/gradientwidget_impl.cpp b/src/gradientwidget_impl.cpp index 504e05453d19efcd27e2f494a898f5cad6a29a94..2f7edabf938615847199cb04ed2928eaea20a0f1 100644 --- a/src/gradientwidget_impl.cpp +++ b/src/gradientwidget_impl.cpp @@ -20,7 +20,9 @@ // used to convert the double variables to int's. (slider <-> spinbox) #define MULTIPLIKATOR 1000 -GradientWidgetImpl::GradientWidgetImpl(QWidget *parent) : QWidget(parent), m_play(false) +GradientWidgetImpl::GradientWidgetImpl(QWidget *parent) + : QWidget(parent) + , m_play(false) { setupUi(this); @@ -94,12 +96,11 @@ void GradientWidgetImpl::slotGradientChanged() } } - void GradientWidgetImpl::doubleToSlider(double doubleVar) { - //the signals need to be blocked as both will return to this slot. But no - //matter which UI elements (slider oder spinbox) was changed, the other - //has to be set to the same value + // the signals need to be blocked as both will return to this slot. But no + // matter which UI elements (slider oder spinbox) was changed, the other + // has to be set to the same value gradient_slider->blockSignals(true); @@ -132,7 +133,6 @@ void GradientWidgetImpl::intToSpinbox(int var) setNewValue(doublevar); } - void GradientWidgetImpl::setNewValue(double newValue) { // Info text currently only for State of mater typ available. @@ -150,7 +150,7 @@ void GradientWidgetImpl::setNewValue(double newValue) QStringList listBoilingPointValue; QStringList listMeltingPointValue; - foreach (Element * element, KalziumDataObject::instance()->ElementList) { + foreach (Element *element, KalziumDataObject::instance()->ElementList) { double melting = element->dataAsVariant(ChemicalDataObject::meltingpoint, Prefs::temperatureUnit()).toDouble(); if ((melting > 0.0) && fabs(melting - newValue) <= threshold) { listMeltingPoint << element->dataAsString(ChemicalDataObject::name); @@ -167,8 +167,7 @@ void GradientWidgetImpl::setNewValue(double newValue) if (listMeltingPoint.count() > 0) { htmlcode += i18n("Elements with melting point around this temperature:") + '\n'; for (int i = 0; i < listMeltingPoint.count(); ++i) { - htmlcode += " - " + i18nc("For example: Carbon (300K)", "%1 (%2%3)", - listMeltingPoint.at(i), listMeltingPointValue.at(i), unitSymbol) + '\n'; + htmlcode += " - " + i18nc("For example: Carbon (300K)", "%1 (%2%3)", listMeltingPoint.at(i), listMeltingPointValue.at(i), unitSymbol) + '\n'; } htmlcode += '\n'; } else { @@ -178,8 +177,7 @@ void GradientWidgetImpl::setNewValue(double newValue) if (listBoilingPoint.count() > 0) { htmlcode += i18n("Elements with boiling point around this temperature:") + '\n'; for (int i = 0; i < listBoilingPoint.count(); ++i) { - htmlcode += " - " + i18nc("For example: Carbon (300K)", "%1 (%2%3)", - listBoilingPoint.at(i), listBoilingPointValue.at(i), unitSymbol) + '\n'; + htmlcode += " - " + i18nc("For example: Carbon (300K)", "%1 (%2%3)", listBoilingPoint.at(i), listBoilingPointValue.at(i), unitSymbol) + '\n'; } htmlcode += '\n'; } else { @@ -192,30 +190,30 @@ void GradientWidgetImpl::setNewValue(double newValue) void GradientWidgetImpl::play(void) { - if (m_play) { //Currently playing - //The Mode is 'Play' so stop + if (m_play) { // Currently playing + // The Mode is 'Play' so stop stop(); return; } - //The mode is not 'play' - //If the slider is at the maximum position bring it to the minimum + // The mode is not 'play' + // If the slider is at the maximum position bring it to the minimum if ((gradient_slider)->value() >= gradient_slider->maximum()) { - gradient_slider->setValue (gradient_slider->minimum ()); + gradient_slider->setValue(gradient_slider->minimum()); } - //start the timer at 200 millisecond time interval with single shot disabled + // start the timer at 200 millisecond time interval with single shot disabled m_timer->start(200); - m_play = true; //start playing + m_play = true; // start playing Play->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-pause"))); } void GradientWidgetImpl::stop(void) { - //Currently playing, stop the timer. - m_timer -> stop(); + // Currently playing, stop the timer. + m_timer->stop(); Play->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start"))); - m_play = false; //Stop + m_play = false; // Stop } void GradientWidgetImpl::tick(void) @@ -226,5 +224,5 @@ void GradientWidgetImpl::tick(void) if (temp + increment > max) { stop(); } - gradient_slider -> setValue (temp + increment); + gradient_slider->setValue(temp + increment); } diff --git a/src/gradientwidget_impl.h b/src/gradientwidget_impl.h index 8dfc8e0c1d149096d5299f0fb1dd3b934f735ae4..11594f4a77c74684754d415fd5d2b85c10ec3987 100644 --- a/src/gradientwidget_impl.h +++ b/src/gradientwidget_impl.h @@ -8,8 +8,8 @@ #ifndef GRADIENTWIDGET_IMPL_H #define GRADIENTWIDGET_IMPL_H -#include #include "ui_gradientwidget.h" +#include #include "kalziumelementproperty.h" @@ -60,7 +60,7 @@ private Q_SLOTS: void setNewValue(double newValue); private: - bool m_play; //Indicates whether mode is play or stop + bool m_play; // Indicates whether mode is play or stop QTimer *m_timer; }; #endif // GRADIENTWIDGET_IMPL_H diff --git a/src/isotopetable/informationitem.h b/src/isotopetable/informationitem.h index 34137912681b48b5281c5769ad62294c876891bd..8c5f1ac16088b70e6e12f6ba1dc71cd088af7ef1 100644 --- a/src/isotopetable/informationitem.h +++ b/src/isotopetable/informationitem.h @@ -26,7 +26,8 @@ public: /** * @return the Type of the item */ - int type() const override { + int type() const override + { return Type; } diff --git a/src/isotopetable/isotopeguideview.cpp b/src/isotopetable/isotopeguideview.cpp index 63b2f94c36ad2c6fb8fd06b13def5f2e73417b5b..82bbcb6ac1020a3b032a3a0d8a9dc3d5b7e19447 100644 --- a/src/isotopetable/isotopeguideview.cpp +++ b/src/isotopetable/isotopeguideview.cpp @@ -9,7 +9,8 @@ #include "isotopescene.h" #include -IsotopeGuideView::IsotopeGuideView(QWidget *parent) : QGraphicsView(parent) +IsotopeGuideView::IsotopeGuideView(QWidget *parent) + : QGraphicsView(parent) { m_guidedView = nullptr; m_scale = 1.0; @@ -20,15 +21,13 @@ IsotopeGuideView::IsotopeGuideView(QWidget *parent) : QGraphicsView(parent) void IsotopeGuideView::setGuidedView(IsotopeView *guidedView) { m_guidedView = guidedView; - connect(m_guidedView, &IsotopeView::zoomLevelChanged, - this, &IsotopeGuideView::setZoomLevel); - connect(m_guidedView, &IsotopeView::visibleSceneRectChanged, - this, &IsotopeGuideView::setVisibleSceneRect); - + connect(m_guidedView, &IsotopeView::zoomLevelChanged, this, &IsotopeGuideView::setZoomLevel); + connect(m_guidedView, &IsotopeView::visibleSceneRectChanged, this, &IsotopeGuideView::setVisibleSceneRect); + updateScene(); } -void IsotopeGuideView::setVisibleSceneRect(const QPolygonF& sceneRect) +void IsotopeGuideView::setVisibleSceneRect(const QPolygonF &sceneRect) { m_visibleSceneRect = sceneRect; viewport()->update(); @@ -39,7 +38,7 @@ void IsotopeGuideView::drawForeground(QPainter *painter, const QRectF &rect) if (m_guidedView && m_visibleSceneRect.boundingRect().intersects(rect)) { QRectF drawRect = m_visibleSceneRect.boundingRect().adjusted(0, 0, -1, -1); painter->setPen(QPen(Qt::yellow, 1.0 / m_scale)); - painter->fillRect(drawRect, QBrush(QColor(0, 0 , 0 , 100))); + painter->fillRect(drawRect, QBrush(QColor(0, 0, 0, 100))); painter->drawRect(drawRect); } } @@ -47,8 +46,7 @@ void IsotopeGuideView::drawForeground(QPainter *painter, const QRectF &rect) void IsotopeGuideView::resizeEvent(QResizeEvent *event) { Q_UNUSED(event) - m_scale = qMin(qreal(viewport()->width()) / sceneRect().width(), - qreal(viewport()->height()) / sceneRect().height()); + m_scale = qMin(qreal(viewport()->width()) / sceneRect().width(), qreal(viewport()->height()) / sceneRect().height()); setTransform(QTransform::fromScale(m_scale, m_scale)); } @@ -73,10 +71,8 @@ void IsotopeGuideView::mouseMoveEvent(QMouseEvent *event) if (m_dragEvent && event->buttons() & Qt::LeftButton) { const QPoint p1(m_guidedView->mapFromScene(mapToScene(m_lastMousePos))); const QPoint p2(m_guidedView->mapFromScene(mapToScene(event->pos()))); - m_guidedView->horizontalScrollBar()->setValue(m_guidedView->horizontalScrollBar()->value() - + p2.x() - p1.x()); - m_guidedView->verticalScrollBar()->setValue(m_guidedView->verticalScrollBar()->value() - + p2.y() - p1.y()); + m_guidedView->horizontalScrollBar()->setValue(m_guidedView->horizontalScrollBar()->value() + p2.x() - p1.x()); + m_guidedView->verticalScrollBar()->setValue(m_guidedView->verticalScrollBar()->value() + p2.y() - p1.y()); m_lastMousePos = event->pos(); m_visibleSceneRect = m_guidedView->visibleSceneRect(); @@ -97,4 +93,3 @@ void IsotopeGuideView::updateScene() ensureVisible(scene()->sceneRect()); resizeEvent(nullptr); } - diff --git a/src/isotopetable/isotopeguideview.h b/src/isotopetable/isotopeguideview.h index 6ab493d11ac441079b17439d8c0a640ece4dfde5..25b7c6a6621df8ed7c16753002fa6e53fc41e19c 100644 --- a/src/isotopetable/isotopeguideview.h +++ b/src/isotopetable/isotopeguideview.h @@ -8,8 +8,8 @@ #define ISOTOPEGUIDEVIEW_H #include -#include #include +#include #include "isotopeview.h" diff --git a/src/isotopetable/isotopeitem.cpp b/src/isotopetable/isotopeitem.cpp index 0bd0ce8e66ce616dda014f8a338d7093224da88f..5ab13e9d04b21165a4bb870b0045cc79a924b03e 100644 --- a/src/isotopetable/isotopeitem.cpp +++ b/src/isotopetable/isotopeitem.cpp @@ -55,16 +55,14 @@ IsotopeItem::IsotopeItem(Isotope *i, qreal x, qreal y, qreal width, qreal height } setBrush(b); - m_symbolFont = QFont(QStringLiteral("Arial"), 3 ,QFont::Bold); - m_otherFont = QFont(QStringLiteral("Arial"), 1 ,QFont::Bold); + m_symbolFont = QFont(QStringLiteral("Arial"), 3, QFont::Bold); + m_otherFont = QFont(QStringLiteral("Arial"), 1, QFont::Bold); setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemIsSelectable, false); setCacheMode(QGraphicsItem::DeviceCoordinateCache); - setToolTip(i18n("Isotope of Element %1 (%2)", - m_isotope->parentElementNumber(), - m_isotope->parentElementSymbol())); + setToolTip(i18n("Isotope of Element %1 (%2)", m_isotope->parentElementNumber(), m_isotope->parentElementSymbol())); } void IsotopeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) @@ -85,26 +83,22 @@ void IsotopeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio const QRectF r1(m_rect.translated(0.0, 2.5)); painter->setFont(m_symbolFont); - painter->drawText(r1, Qt::AlignHCenter | Qt::TextDontClip, m_isotope->parentElementSymbol());//, s->parentElementNumber() + painter->drawText(r1, Qt::AlignHCenter | Qt::TextDontClip, m_isotope->parentElementSymbol()); //, s->parentElementNumber() if (lod >= 4.0) { const QRectF r2(m_rect.topLeft() + QPointF(1.0, 0.5), m_rect.size() / 2.0); - const QRectF r3(m_rect.topLeft() + QPointF(6.0, 0.5) , m_rect.size() / 2.0); + const QRectF r3(m_rect.topLeft() + QPointF(6.0, 0.5), m_rect.size() / 2.0); painter->setFont(m_otherFont); - painter->drawText(r2, - Qt::AlignHCenter | Qt::TextDontClip, - QString::number(m_isotope->parentElementNumber())); - painter->drawText(r3, - Qt::AlignHCenter | Qt::TextDontClip, - QString::number(m_isotope->nucleons())); + painter->drawText(r2, Qt::AlignHCenter | Qt::TextDontClip, QString::number(m_isotope->parentElementNumber())); + painter->drawText(r3, Qt::AlignHCenter | Qt::TextDontClip, QString::number(m_isotope->nucleons())); } } } -IsotopeItem::IsotopeType IsotopeItem::getType(Isotope * isotope) +IsotopeItem::IsotopeType IsotopeItem::getType(Isotope *isotope) { - //TODO Here I need a clever way to find out *what* to return. + // TODO Here I need a clever way to find out *what* to return. if (isotope->alphalikeliness() > 60.0) { return IsotopeItem::alpha; } @@ -131,7 +125,7 @@ void IsotopeItem::mousePressEvent(QGraphicsSceneMouseEvent *event) return; } - IsotopeScene *scene2 = static_cast(scene()); + IsotopeScene *scene2 = static_cast(scene()); scene2->updateContextHelp(this); } @@ -142,6 +136,6 @@ void IsotopeItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) return; } - IsotopeScene *scene2 = static_cast(scene()); + IsotopeScene *scene2 = static_cast(scene()); scene2->updateContextHelp(this); } diff --git a/src/isotopetable/isotopeitem.h b/src/isotopetable/isotopeitem.h index 4837f510b417adeef44da72a0e90002772c4d37a..0fac01b0229e5de08f2031ab142d7ab5f2395338 100644 --- a/src/isotopetable/isotopeitem.h +++ b/src/isotopetable/isotopeitem.h @@ -33,20 +33,23 @@ public: IsotopeItem(Isotope *isotope, qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = nullptr); /** - * @return the Isotope the item represents - */ - Isotope* isotope() const{ + * @return the Isotope the item represents + */ + Isotope *isotope() const + { return m_isotope; } - QRectF boundingRect() const override { + QRectF boundingRect() const override + { return m_rect; } /** * @return the Type of the item */ - int type() const override { + int type() const override + { return Type; } @@ -54,7 +57,7 @@ public: private: IsotopeType m_type; - Isotope* m_isotope; + Isotope *m_isotope; QRectF m_rect; QFont m_symbolFont; QFont m_otherFont; diff --git a/src/isotopetable/isotopescene.cpp b/src/isotopetable/isotopescene.cpp index df489be6488c5cce7acb75d091e57d7667835ae4..481d89cb479282613d51f759e98b5e523bc7c4e9 100644 --- a/src/isotopetable/isotopescene.cpp +++ b/src/isotopetable/isotopescene.cpp @@ -12,7 +12,8 @@ #include #include -IsotopeScene::IsotopeScene(QObject *parent, int mode) : QGraphicsScene(parent) +IsotopeScene::IsotopeScene(QObject *parent, int mode) + : QGraphicsScene(parent) { m_mode = mode; m_isotopeGroup = new QGraphicsItemGroup(); @@ -28,8 +29,7 @@ IsotopeScene::~IsotopeScene() delete m_isotopeGroup; } - -void IsotopeScene::updateContextHelp(IsotopeItem * item) +void IsotopeScene::updateContextHelp(IsotopeItem *item) { Q_EMIT itemSelected(item); } @@ -41,12 +41,12 @@ void IsotopeScene::drawIsotopes() delete item; } - const QList elist = KalziumDataObject::instance()->ElementList; + const QList elist = KalziumDataObject::instance()->ElementList; foreach (Element *e, elist) { int elementNumber = e->dataAsVariant(ChemicalDataObject::atomicNumber).toInt(); - const QList ilist = KalziumDataObject::instance()->isotopes(elementNumber); + const QList ilist = KalziumDataObject::instance()->isotopes(elementNumber); foreach (Isotope *i, ilist) { int x = elementNumber * m_itemSize; int y = (300 - i->nucleons()) * m_itemSize; @@ -70,14 +70,14 @@ void IsotopeScene::drawIsotopes() x = (i->nucleons() - elementNumber) * m_itemSize; } - IsotopeItem *item = new IsotopeItem(i, x, y, m_itemSize,m_itemSize); + IsotopeItem *item = new IsotopeItem(i, x, y, m_itemSize, m_itemSize); m_isotopeGroup->addToGroup(item); } } } -void IsotopeScene::setMode(int mode) { +void IsotopeScene::setMode(int mode) +{ m_mode = mode; drawIsotopes(); } - diff --git a/src/isotopetable/isotopescene.h b/src/isotopetable/isotopescene.h index dd4f3c4fc4d71f52fcbb658abdddfb1ff3ffe535..ddd747c5d00d6e31ff10ba5d0f49033dd7278620 100644 --- a/src/isotopetable/isotopescene.h +++ b/src/isotopetable/isotopescene.h @@ -16,10 +16,10 @@ class IsotopeScene : public QGraphicsScene Q_OBJECT public: - explicit IsotopeScene(QObject * parent, int mode); + explicit IsotopeScene(QObject *parent, int mode); virtual ~IsotopeScene(); - void updateContextHelp(IsotopeItem * item); + void updateContextHelp(IsotopeItem *item); private: void initialize(); @@ -27,15 +27,16 @@ private: private: void drawIsotopes(void); - //the size of each item + // the size of each item int m_itemSize; int m_mode; - ///this group stores all IsotopeItems + /// this group stores all IsotopeItems QGraphicsItemGroup *m_isotopeGroup; public: - int mode() const { + int mode() const + { return m_mode; } @@ -44,7 +45,6 @@ Q_SIGNALS: public: void setMode(int mode); - }; #endif // ISOTOPESCENE_H diff --git a/src/isotopetable/isotopetabledialog.cpp b/src/isotopetable/isotopetabledialog.cpp index cde7e87c232efed563edff69a1fb0cfbaa4243f2..699868a9823b9905fa13935343da9f8c3dd1206a 100644 --- a/src/isotopetable/isotopetabledialog.cpp +++ b/src/isotopetable/isotopetabledialog.cpp @@ -8,8 +8,8 @@ #include "isotopeitem.h" #include "isotopescene.h" -#include "legendwidget.h" #include "kalziumschemetype.h" +#include "legendwidget.h" #include @@ -23,7 +23,8 @@ #include -IsotopeTableDialog::IsotopeTableDialog(QWidget* parent) : QDialog(parent) +IsotopeTableDialog::IsotopeTableDialog(QWidget *parent) + : QDialog(parent) { setWindowTitle(i18nc("@title:window", "Isotope Table")); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); @@ -37,15 +38,12 @@ IsotopeTableDialog::IsotopeTableDialog(QWidget* parent) : QDialog(parent) ui.setupUi(mainWidget); ui.guide->setGuidedView(ui.gv); - connect(ui.gv->scene(), SIGNAL(itemSelected(IsotopeItem*)), - this, SLOT(updateDockWidget(IsotopeItem*))); - connect(ui.gv, &IsotopeView::zoomLevelChanged, - this, &IsotopeTableDialog::slotZoomLevelChanged); - connect(ui.Slider, &QAbstractSlider::valueChanged, - this, &IsotopeTableDialog::zoom); + connect(ui.gv->scene(), SIGNAL(itemSelected(IsotopeItem *)), this, SLOT(updateDockWidget(IsotopeItem *))); + connect(ui.gv, &IsotopeView::zoomLevelChanged, this, &IsotopeTableDialog::slotZoomLevelChanged); + connect(ui.Slider, &QAbstractSlider::valueChanged, this, &IsotopeTableDialog::zoom); - //Here comes the legend part - QList< QPair > items; + // Here comes the legend part + QList> items; items << qMakePair(i18nc("alpha ray emission", "alpha"), QColor(Qt::red)); items << qMakePair(i18nc("Electron capture method", "EC"), QColor(Qt::blue)); @@ -62,36 +60,32 @@ IsotopeTableDialog::IsotopeTableDialog(QWidget* parent) : QDialog(parent) ui.infoWidget->setMinimumWidth(150); } -void IsotopeTableDialog::zoom (int level) +void IsotopeTableDialog::zoom(int level) { double zoom = qPow(M_E, level / 10.0); (ui.gv)->setZoom(zoom); } -void IsotopeTableDialog::updateDockWidget(IsotopeItem * item) +void IsotopeTableDialog::updateDockWidget(IsotopeItem *item) { Isotope *s = item->isotope(); const QString header = i18n("

%1 (%2)

", s->parentElementSymbol(), s->parentElementNumber()); - const QString mag = i18n("Magnetic moment: %1", - s->magmoment().isEmpty()? - i18nc("Unknown magnetic moment", "Unknown"):s->magmoment()); + const QString mag = i18n("Magnetic moment: %1", s->magmoment().isEmpty() ? i18nc("Unknown magnetic moment", "Unknown") : s->magmoment()); QString halflife; - if (s -> halflife() > 0.0) { - halflife = i18n ("Halflife: %1 %2", s->halflife(), s->halflifeUnit()); + if (s->halflife() > 0.0) { + halflife = i18n("Halflife: %1 %2", s->halflife(), s->halflifeUnit()); } else { - halflife = i18n ("Halflife: Unknown"); + halflife = i18n("Halflife: Unknown"); } const QString abundance = i18n("Abundance: %1 %", !s->abundance().isEmpty() ? s->abundance() : QStringLiteral("0")); const QString nucleons = i18n("Number of nucleons: %1", s->nucleons()); - const QString spin = i18n("Spin: %1", s->spin().isEmpty()? - i18nc("Unknown spin", "Unknown"): s->spin()); + const QString spin = i18n("Spin: %1", s->spin().isEmpty() ? i18nc("Unknown spin", "Unknown") : s->spin()); const QString exactMass = i18n("Exact mass: %1 u", s->mass()); - const QString html = header + "
" + nucleons + "
" + mag + "
" + exactMass + "
" - + spin +"
" + abundance + "
" + halflife; + const QString html = header + "
" + nucleons + "
" + mag + "
" + exactMass + "
" + spin + "
" + abundance + "
" + halflife; ui.label->setText(html); } @@ -103,11 +97,13 @@ void IsotopeTableDialog::slotZoomLevelChanged(double value) ui.Slider->blockSignals(b); } -void IsotopeTableDialog::setMode(int mode) { +void IsotopeTableDialog::setMode(int mode) +{ ui.gv->setMode(mode); ui.guide->updateScene(); } -void IsotopeTableDialog::updateMode() { +void IsotopeTableDialog::updateMode() +{ setMode(Prefs::isotopeTableMode()); } diff --git a/src/isotopetable/isotopetabledialog.h b/src/isotopetable/isotopetabledialog.h index 00cacb1a4c9336843e7c11675237b4e4ac65932b..1be88ca6f30d2a1c185e7b3a4474e789582d79a9 100644 --- a/src/isotopetable/isotopetabledialog.h +++ b/src/isotopetable/isotopetabledialog.h @@ -24,7 +24,7 @@ class IsotopeTableDialog : public QDialog Q_OBJECT public: - explicit IsotopeTableDialog(QWidget* parent = nullptr); + explicit IsotopeTableDialog(QWidget *parent = nullptr); private: Ui::isotopeWidget ui; @@ -37,7 +37,6 @@ private Q_SLOTS: void updateDockWidget(IsotopeItem *); void zoom(int); void slotZoomLevelChanged(double); - }; #endif // ISOTOPETABLEDIALOG_H diff --git a/src/isotopetable/isotopeview.cpp b/src/isotopetable/isotopeview.cpp index 0a0d4e3f8c4355f1e259fe359d8a07e17a0f92f1..24410f2055c566f7fd77a7965cd0eaec0db68d18 100644 --- a/src/isotopetable/isotopeview.cpp +++ b/src/isotopetable/isotopeview.cpp @@ -9,14 +9,16 @@ #include "isotopescene.h" #include "prefs.h" -IsotopeView::IsotopeView(QWidget *parent) : QGraphicsView(parent) +IsotopeView::IsotopeView(QWidget *parent) + : QGraphicsView(parent) { m_scene = new IsotopeScene(this, Prefs::isotopeTableMode()); m_zoomLevel = 1.0; initialize(); } -IsotopeView::IsotopeView(QWidget *parent, int mode) : QGraphicsView(parent) +IsotopeView::IsotopeView(QWidget *parent, int mode) + : QGraphicsView(parent) { m_scene = new IsotopeScene(this, mode); m_zoomLevel = 1.0; @@ -43,10 +45,8 @@ IsotopeView::~IsotopeView() void IsotopeView::resizeEvent(QResizeEvent *event) { Q_UNUSED(event) - if (!isInteractive()) - { - qreal scale = qMin(qreal(viewport()->width()) / sceneRect().width(), - qreal(viewport()->height()) / sceneRect().height()); + if (!isInteractive()) { + qreal scale = qMin(qreal(viewport()->width()) / sceneRect().width(), qreal(viewport()->height()) / sceneRect().height()); setTransform(QTransform::fromScale(scale, scale)); } } @@ -61,8 +61,7 @@ void IsotopeView::mouseMoveEvent(QMouseEvent *event) void IsotopeView::wheelEvent(QWheelEvent *event) { - if (!isInteractive()) - { + if (!isInteractive()) { event->accept(); return; } @@ -71,17 +70,13 @@ void IsotopeView::wheelEvent(QWheelEvent *event) double factor = event->angleDelta().y() / 1000.0; m_zoomLevel = oldZoomLevel + oldZoomLevel * factor; - if (m_zoomLevel < 0.3) - { + if (m_zoomLevel < 0.3) { m_zoomLevel = 0.3; - } - else if (m_zoomLevel > 10.0) - { + } else if (m_zoomLevel > 10.0) { m_zoomLevel = 10.0; } - if (oldZoomLevel != m_zoomLevel) - { + if (oldZoomLevel != m_zoomLevel) { factor = m_zoomLevel / oldZoomLevel; scale(factor, factor); Q_EMIT zoomLevelChanged(m_zoomLevel); @@ -99,12 +94,9 @@ void IsotopeView::setZoom(double zoom) m_zoomLevel = zoom; - if (m_zoomLevel < 0.3 && isInteractive()) - { + if (m_zoomLevel < 0.3 && isInteractive()) { m_zoomLevel = 0.3; - } - else if (m_zoomLevel > 10.0 && isInteractive()) - { + } else if (m_zoomLevel > 10.0 && isInteractive()) { m_zoomLevel = 10.0; } diff --git a/src/isotopetable/isotopeview.h b/src/isotopetable/isotopeview.h index e627a40456e48c1dcb593ed9c39cd84f7ca85787..018414f8741b7ee797f6d8b369e083a53ecb2614 100644 --- a/src/isotopetable/isotopeview.h +++ b/src/isotopetable/isotopeview.h @@ -31,10 +31,12 @@ private: int m_mode; public: - double zoomLevel() { + double zoomLevel() + { return m_zoomLevel; } - QPolygonF visibleSceneRect() const { + QPolygonF visibleSceneRect() const + { return mapToScene(viewport()->rect()); } diff --git a/src/kalzium.cpp b/src/kalzium.cpp index 82aa845b217ebc5dc0cb47c02b86d6c91ce3c171..a32465edf667430a1636090fa818a17f701d19f3 100644 --- a/src/kalzium.cpp +++ b/src/kalzium.cpp @@ -5,23 +5,23 @@ #include "kalzium.h" -#include -#include -#include "prefs.h" -#include "detailinfodlg.h" #include "detailedgraphicaloverview.h" +#include "detailinfodlg.h" +#include "exportdialog.h" #include "gradientwidget_impl.h" #include "kalziumdataobject.h" +#include "kalziumgradienttype.h" #include "kalziumnumerationtype.h" #include "kalziumschemetype.h" -#include "kalziumgradienttype.h" #include "legendwidget.h" -#include "exportdialog.h" +#include "prefs.h" +#include "psetables.h" #include "search.h" #include "searchwidget.h" #include "tableinfowidget.h" -#include "psetables.h" #include +#include +#include #ifdef HAVE_FACILE #include "eqchemview.h" @@ -54,9 +54,10 @@ #include #include -#define IDS_ELEMENTINFO 7 +#define IDS_ELEMENTINFO 7 -Kalzium::Kalzium() : KXmlGuiWindow(nullptr) +Kalzium::Kalzium() + : KXmlGuiWindow(nullptr) { setObjectName(QStringLiteral("KalziumMainWindow")); @@ -90,10 +91,8 @@ Kalzium::Kalzium() : KXmlGuiWindow(nullptr) m_periodicTable = new PeriodicTableView(pseTempWidget); // Connecting the search to the periodic table - connect(newsearch, &Search::searchChanged, - KalziumElementProperty::instance(), &KalziumElementProperty::propertyChanged); - connect(newsearch, &Search::searchReset, - KalziumElementProperty::instance(), &KalziumElementProperty::propertyChanged); + connect(newsearch, &Search::searchChanged, KalziumElementProperty::instance(), &KalziumElementProperty::propertyChanged); + connect(newsearch, &Search::searchReset, KalziumElementProperty::instance(), &KalziumElementProperty::propertyChanged); layout->addWidget(searchWidget); layout->addWidget(m_periodicTable); @@ -102,7 +101,7 @@ Kalzium::Kalzium() : KXmlGuiWindow(nullptr) connect(m_periodicTable->pseScene(), &PeriodicTableScene::elementChanged, this, &Kalzium::openInformationDialog); connect(m_periodicTable->pseScene(), &PeriodicTableScene::elementHovered, this, &Kalzium::elementHover); - connect(this, &Kalzium::numerationChanged, m_periodicTable, &PeriodicTableView::numerationChange); + connect(this, &Kalzium::numerationChanged, m_periodicTable, &PeriodicTableView::numerationChange); // layouting setupSidebars(); @@ -118,7 +117,7 @@ void Kalzium::setupActions() connect(export_action, &QAction::triggered, this, &Kalzium::slotShowExportDialog); // the action for switching look: color schemes and gradients - QStringList schemes = KalziumElementProperty::instance()->schemeList(); /*KalziumSchemeTypeFactory::instance()->schemes();*/ + QStringList schemes = KalziumElementProperty::instance()->schemeList(); /*KalziumSchemeTypeFactory::instance()->schemes();*/ QStringList gradients = KalziumElementProperty::instance()->gradientList(); // the action for switching look: schemes @@ -139,7 +138,7 @@ void Kalzium::setupActions() // the action for switching tables QStringList table_schemes = pseTables::instance()->tables(); - table_action = actionCollection()->add(QStringLiteral("view_table")); + table_action = actionCollection()->add(QStringLiteral("view_table")); table_action->setText(i18n("&Tables")); table_action->setItems(table_schemes); table_action->setCurrentItem(Prefs::table()); @@ -165,7 +164,7 @@ void Kalzium::setupActions() m_pcalculator->setWhatsThis(i18nc("WhatsThis Help", "This is the calculator, it performs basic chemical calculations.")); connect(m_pcalculator, &QAction::triggered, this, &Kalzium::showCalculator); - m_pIsotopeTableAction= actionCollection()->addAction(QStringLiteral("tools_isotopetable")); + m_pIsotopeTableAction = actionCollection()->addAction(QStringLiteral("tools_isotopetable")); m_pIsotopeTableAction->setText(i18n("&Isotope Table...")); m_pIsotopeTableAction->setIcon(QIcon::fromTheme(QStringLiteral("isotopemap"))); m_pIsotopeTableAction->setWhatsThis(i18nc("WhatsThis Help", "This table shows all of the known isotopes of the chemical elements.")); @@ -231,7 +230,6 @@ void Kalzium::setupActions() m_legendWidget->LockWidget(); - slotSwitchtoLookGradient(KalziumElementProperty::instance()->gradientId()); slotSwitchtoLookScheme(KalziumElementProperty::instance()->schemeId()); @@ -256,12 +254,9 @@ void Kalzium::setupSidebars() m_legendDock->setFeatures(QDockWidget::AllDockWidgetFeatures); m_legendDock->setWidget(m_legendWidget); - connect(m_legendDock, &QDockWidget::dockLocationChanged, - m_legendWidget, &LegendWidget::setDockArea); - connect(m_legendWidget, &LegendWidget::elementMatched, - m_periodicTable, &PeriodicTableView::slotSelectAdditionalElement); - connect(m_legendWidget, &LegendWidget::resetElementMatch, - m_periodicTable, &PeriodicTableView::slotUnSelectElements); + connect(m_legendDock, &QDockWidget::dockLocationChanged, m_legendWidget, &LegendWidget::setDockArea); + connect(m_legendWidget, &LegendWidget::elementMatched, m_periodicTable, &PeriodicTableView::slotSelectAdditionalElement); + connect(m_legendWidget, &LegendWidget::resetElementMatch, m_periodicTable, &PeriodicTableView::slotUnSelectElements); m_TableInfoWidget = new TableInfoWidget(this); m_tableDock = new QDockWidget(i18n("Table Information"), this); @@ -269,7 +264,6 @@ void Kalzium::setupSidebars() m_tableDock->setObjectName(QStringLiteral("kalzium-tableinfo")); m_tableDock->setFeatures(QDockWidget::AllDockWidgetFeatures); - m_dockWin = new QDockWidget(i18n("Information"), this); m_dockWin->setObjectName(QStringLiteral("kalzium-sidebar")); m_dockWin->setFeatures(QDockWidget::AllDockWidgetFeatures); @@ -287,12 +281,9 @@ void Kalzium::setupSidebars() m_gradientWidget = new GradientWidgetImpl(m_toolbox); m_gradientWidget->setObjectName(QStringLiteral("viewtWidget")); - connect(m_gradientWidget, &GradientWidgetImpl::gradientValueChanged, - KalziumElementProperty::instance(), &KalziumElementProperty::setSliderValue); - connect(m_gradientWidget->scheme_combo, SIGNAL(currentIndexChanged(int)), - this, SLOT(slotSwitchtoLookScheme(int))); - connect(m_gradientWidget->gradient_combo, SIGNAL(currentIndexChanged(int)), - this, SLOT(slotSwitchtoLookGradient(int))); + connect(m_gradientWidget, &GradientWidgetImpl::gradientValueChanged, KalziumElementProperty::instance(), &KalziumElementProperty::setSliderValue); + connect(m_gradientWidget->scheme_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSwitchtoLookScheme(int))); + connect(m_gradientWidget->gradient_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSwitchtoLookGradient(int))); m_toolbox->addItem(m_gradientWidget, QIcon::fromTheme(QStringLiteral("statematter")), i18n("View")); @@ -318,22 +309,22 @@ void Kalzium::slotExportTable() void Kalzium::slotGlossary() { if (!m_glossarydlg) { - // creating the glossary dialog and loading the glossaries we have - m_glossarydlg = new GlossaryDialog(this); - m_glossarydlg->setObjectName(QStringLiteral("glossary")); - QString dir = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("data/"), QStandardPaths::LocateDirectory); - dir = QFileInfo(dir).absolutePath(); - QString picturepath = dir + "/bg.jpg"; - QUrl u = QUrl::fromLocalFile(dir + "/knowledge.xml"); - Glossary *g = new Glossary(u); - g->setName(i18n("Knowledge")); - g->setBackgroundPicture(picturepath); - m_glossarydlg->addGlossary(g, true); - u = QUrl::fromLocalFile(dir + "/tools.xml"); - g = new Glossary(u, dir + "/toolpics/"); - g->setName(i18n("Tools")); - g->setBackgroundPicture(picturepath); - m_glossarydlg->addGlossary(g, true); + // creating the glossary dialog and loading the glossaries we have + m_glossarydlg = new GlossaryDialog(this); + m_glossarydlg->setObjectName(QStringLiteral("glossary")); + QString dir = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("data/"), QStandardPaths::LocateDirectory); + dir = QFileInfo(dir).absolutePath(); + QString picturepath = dir + "/bg.jpg"; + QUrl u = QUrl::fromLocalFile(dir + "/knowledge.xml"); + Glossary *g = new Glossary(u); + g->setName(i18n("Knowledge")); + g->setBackgroundPicture(picturepath); + m_glossarydlg->addGlossary(g, true); + u = QUrl::fromLocalFile(dir + "/tools.xml"); + g = new Glossary(u, dir + "/toolpics/"); + g->setName(i18n("Tools")); + g->setBackgroundPicture(picturepath); + m_glossarydlg->addGlossary(g, true); } m_glossarydlg->show(); @@ -342,7 +333,7 @@ void Kalzium::slotGlossary() void Kalzium::slotRS() { if (!m_rsDialog) { - m_rsDialog = new RSDialog(this); + m_rsDialog = new RSDialog(this); } m_rsDialog->show(); } @@ -350,7 +341,7 @@ void Kalzium::slotRS() void Kalzium::slotOBConverter() { #ifdef HAVE_OPENBABEL - KOpenBabel * d = new KOpenBabel(this); + KOpenBabel *d = new KOpenBabel(this); d->setAttribute(Qt::WA_DeleteOnClose); d->show(); #endif @@ -365,7 +356,7 @@ MoleculeDialog *Kalzium::slotMoleculeviewer() return nullptr; } - MoleculeDialog * d = new MoleculeDialog(this); + MoleculeDialog *d = new MoleculeDialog(this); d->show(); return d; @@ -387,7 +378,7 @@ MoleculeDialog *Kalzium::slotMoleculeviewer() void Kalzium::slotTables() { if (!m_tablesDialog) { - m_tablesDialog = new TablesDialog(this); + m_tablesDialog = new TablesDialog(this); } m_tablesDialog->show(); } @@ -404,7 +395,7 @@ void Kalzium::slotIsotopeTable() void Kalzium::slotPlotData() { if (!m_elementDataPlotter) { - m_elementDataPlotter = new ElementDataViewer(this); + m_elementDataPlotter = new ElementDataViewer(this); } m_elementDataPlotter->show(); } @@ -412,9 +403,9 @@ void Kalzium::slotPlotData() void Kalzium::showCalculator() { if (!m_calculator) { - m_calculator = new calculator(this); + m_calculator = new calculator(this); } - m_calculator -> show(); + m_calculator->show(); } void Kalzium::slotSwitchtoTable(int index) @@ -480,8 +471,8 @@ void Kalzium::showSettingsDialog() return; } - //KalziumConfigDialog didn't find an instance of this dialog, so lets create it : - m_configDialog = new KalziumConfigDialog(this,QStringLiteral("settings"), Prefs::self()); + // KalziumConfigDialog didn't find an instance of this dialog, so lets create it : + m_configDialog = new KalziumConfigDialog(this, QStringLiteral("settings"), Prefs::self()); connect(m_configDialog, &KalziumConfigDialog::settingsChanged, this, &Kalzium::slotUpdateSettings); connect(m_configDialog, &KalziumConfigDialog::settingsChanged, m_gradientWidget, &GradientWidgetImpl::slotGradientChanged); @@ -519,7 +510,8 @@ void Kalzium::elementHover(int num) { // extractIconicInformationAboutElement(num); Element *e = KalziumDataObject::instance()->element(num); - m_elementInfo->setText(i18nc("For example: \"Carbon (6), Mass: 12.0107 u\"", "%1 (%2), Mass: %3 u", + m_elementInfo->setText(i18nc("For example: \"Carbon (6), Mass: 12.0107 u\"", + "%1 (%2), Mass: %3 u", e->dataAsString(ChemicalDataObject::name), e->dataAsString(ChemicalDataObject::atomicNumber), e->dataAsString(ChemicalDataObject::mass))); @@ -552,7 +544,7 @@ void Kalzium::extractIconicInformationAboutElement(int elementNumber) } QString realText = QStringLiteral("Moin dies ist ein test!"); -//X QString realText = infoline.remove(QRegularExpression("\\d+ ")); + // X QString realText = infoline.remove(QRegularExpression("\\d+ ")); } void Kalzium::openInformationDialog(int number) @@ -563,17 +555,14 @@ void Kalzium::openInformationDialog(int number) m_infoDialog = new DetailedInfoDlg(number, this); // Remove the selection when this dialog finishes or hides. - connect(m_infoDialog, &DetailedInfoDlg::elementChanged, - m_periodicTable, &PeriodicTableView::slotSelectOneElement); - connect(m_infoDialog, &DetailedInfoDlg::elementChanged, - this, &Kalzium::elementHover); + connect(m_infoDialog, &DetailedInfoDlg::elementChanged, m_periodicTable, &PeriodicTableView::slotSelectOneElement); + connect(m_infoDialog, &DetailedInfoDlg::elementChanged, this, &Kalzium::elementHover); } m_infoDialog->setTableType(m_periodicTable->table()); m_infoDialog->show(); } - Kalzium::~Kalzium() { delete m_periodicTable; @@ -601,4 +590,3 @@ QSize Kalzium::sizeHint() const { return QSize(700, 500); } - diff --git a/src/kalzium.h b/src/kalzium.h index 55cd36a54de48dd34bf06ec854c86d5f614d8232..dca7b0249d5c8a9e3cecd94825538d563f958de5 100644 --- a/src/kalzium.h +++ b/src/kalzium.h @@ -6,14 +6,14 @@ #ifndef KALZIUM_H #define KALZIUM_H -#include +#include "calculator/calculator.h" +#include "elementdataviewer.h" +#include "isotopetabledialog.h" #include "periodictableview.h" +#include "rsdialog.h" #include "settings/kalziumconfigdialog.h" -#include "isotopetabledialog.h" -#include "elementdataviewer.h" #include "tablesdialog.h" -#include "rsdialog.h" -#include "calculator/calculator.h" +#include class KAction; class KSelectAction; diff --git a/src/kalziumdataobject.cpp b/src/kalziumdataobject.cpp index 9c9150a59ab3529317a7145904cd49993c279e23..1dd37507050a8102fa1c7159f42ef904f2dfc0a7 100644 --- a/src/kalziumdataobject.cpp +++ b/src/kalziumdataobject.cpp @@ -11,8 +11,8 @@ #include #include -#include #include "kalzium_debug.h" +#include #include #include #include @@ -24,14 +24,13 @@ #include -struct StaticKalziumDataObject -{ +struct StaticKalziumDataObject { KalziumDataObject kdo; }; Q_GLOBAL_STATIC(StaticKalziumDataObject, s_kdo) -KalziumDataObject* KalziumDataObject::instance() +KalziumDataObject *KalziumDataObject::instance() { return &s_kdo->kdo; } @@ -39,7 +38,7 @@ KalziumDataObject* KalziumDataObject::instance() KalziumDataObject::KalziumDataObject() { // reading elements - ElementSaxParser * parser = new ElementSaxParser(); + ElementSaxParser *parser = new ElementSaxParser(); QFile xmlFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libkdeedu/data/elements.xml"))); QXmlInputSource source(&xmlFile); @@ -50,11 +49,11 @@ KalziumDataObject::KalziumDataObject() ElementList = parser->getElements(); - //we don't need parser anymore, let's free its memory + // we don't need parser anymore, let's free its memory delete parser; - //read the spectra - SpectrumParser * spectrumparser = new SpectrumParser(); + // read the spectra + SpectrumParser *spectrumparser = new SpectrumParser(); QFile xmlSpFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libkdeedu/data/spectra.xml"))); QXmlInputSource spsource(&xmlSpFile); @@ -65,11 +64,11 @@ KalziumDataObject::KalziumDataObject() m_spectra = spectrumparser->getSpectrums(); - //we don't need spectrumparser anymore, let's free its memory + // we don't need spectrumparser anymore, let's free its memory delete spectrumparser; // reading isotopes - IsotopeParser * isoparser = new IsotopeParser(); + IsotopeParser *isoparser = new IsotopeParser(); QFile xmlIsoFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libkdeedu/data/isotopes.xml"))); QXmlInputSource isosource(&xmlIsoFile); @@ -78,18 +77,17 @@ KalziumDataObject::KalziumDataObject() isoreader.setContentHandler(isoparser); isoreader.parse(isosource); - QList isotopes = isoparser->getIsotopes(); + QList isotopes = isoparser->getIsotopes(); - //we don't need isoparser anymore, let's free its memory + // we don't need isoparser anymore, let's free its memory delete isoparser; - foreach (Isotope *iso, isotopes) - { + foreach (Isotope *iso, isotopes) { int num = iso->parentElementNumber(); if (m_isotopes.contains(num)) { m_isotopes[num].append(iso); } else { - QList newlist; + QList newlist; newlist.append(iso); m_isotopes.insert(num, newlist); } @@ -103,26 +101,26 @@ KalziumDataObject::KalziumDataObject() KalziumDataObject::~KalziumDataObject() { - //Delete all elements + // Delete all elements qDeleteAll(ElementList); - //Delete all isotopes - QHashIterator > i(m_isotopes); + // Delete all isotopes + QHashIterator> i(m_isotopes); while (i.hasNext()) { i.next(); qDeleteAll(i.value()); } - //Delete the spectra + // Delete the spectra qDeleteAll(m_spectra); } -Element* KalziumDataObject::element(int number) +Element *KalziumDataObject::element(int number) { // checking that we are requesting a valid element if ((number <= 0) || (number > m_numOfElements)) return nullptr; - return ElementList[ number-1 ]; + return ElementList[number - 1]; } QString KalziumDataObject::unitAsString(const int unit) const @@ -137,22 +135,22 @@ QPixmap KalziumDataObject::pixmap(int number) return QPixmap(); if (PixmapList.isEmpty()) loadIconSet(); - return PixmapList[ number-1 ]; + return PixmapList[number - 1]; } -QList KalziumDataObject::isotopes(Element * element) +QList KalziumDataObject::isotopes(Element *element) { return isotopes(element->dataAsVariant(ChemicalDataObject::atomicNumber).toInt()); } -QList KalziumDataObject::isotopes(int number) +QList KalziumDataObject::isotopes(int number) { - return m_isotopes.contains(number) ? m_isotopes.value(number) : QList(); + return m_isotopes.contains(number) ? m_isotopes.value(number) : QList(); } -Spectrum * KalziumDataObject::spectrum(int number) +Spectrum *KalziumDataObject::spectrum(int number) { - foreach (Spectrum * s, m_spectra) { + foreach (Spectrum *s, m_spectra) { if (s->parentElementNumber() == number) { return s; } @@ -161,13 +159,12 @@ Spectrum * KalziumDataObject::spectrum(int number) return nullptr; } - void KalziumDataObject::setSearch(Search *srch) { m_search = srch; } -Search* KalziumDataObject::search() const +Search *KalziumDataObject::search() const { return m_search; } @@ -179,12 +176,10 @@ void KalziumDataObject::cleanup() void KalziumDataObject::loadIconSet() { - //FIXME in case we ever get more than one theme we need - //a settings-dialog where we can select the different iconsets... + // FIXME in case we ever get more than one theme we need + // a settings-dialog where we can select the different iconsets... const QString setname = QStringLiteral("school"); - QString pathname = QStandardPaths::locate( - QStandardPaths::AppLocalDataLocation, "data/iconsets/" + setname + '/', - QStandardPaths::LocateDirectory); + QString pathname = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/iconsets/" + setname + '/', QStandardPaths::LocateDirectory); QSvgRenderer renderer; for (int i = 0; i < m_numOfElements; ++i) { @@ -198,7 +193,7 @@ void KalziumDataObject::loadIconSet() Element *e = ElementList.at(i); QString esymbol = e->dataAsString(ChemicalDataObject::symbol); - p.drawText(0,0,40,40, Qt::AlignCenter | Qt::TextWordWrap, esymbol); + p.drawText(0, 0, 40, 40, Qt::AlignCenter | Qt::TextWordWrap, esymbol); p.end(); PixmapList << pix; diff --git a/src/kalziumdataobject.h b/src/kalziumdataobject.h index f08cd637ced8fbbbc3a47bfeec8ac5370e9d27ad..29d3dd495716db57ed12ca1200ccdf9d7bc72b79 100644 --- a/src/kalziumdataobject.h +++ b/src/kalziumdataobject.h @@ -7,9 +7,9 @@ #ifndef KALZIUMDATAOBJECT_H #define KALZIUMDATAOBJECT_H -#include #include #include +#include class Search; class Isotope; @@ -38,12 +38,12 @@ public: /** * @return the instance of this class */ - static KalziumDataObject* instance(); + static KalziumDataObject *instance(); /** * The list of elements */ - QList ElementList; + QList ElementList; /** * Set the main Search to @p srch @@ -53,13 +53,13 @@ public: /** * @return the main Search */ - Search* search() const; + Search *search() const; /** * @return the Element with the number @p number * @param number the number of the Element which will be returned */ - Element* element(int number); + Element *element(int number); /** * retunrs the unit symbol from the given KUnitConversion UnitId. @@ -71,17 +71,17 @@ public: /** * @return the isotopes of the Element with the number @p number */ - QList isotopes(int number); + QList isotopes(int number); /** * @return the isotopes of the Element @p Element */ - QList isotopes(Element * element); + QList isotopes(Element *element); /** - * @return the Spectrum of the Element with the number @p number + * @return the Spectrum of the Element with the number @p number */ - Spectrum * spectrum(int number); + Spectrum *spectrum(int number); QPixmap pixmap(int number); @@ -107,8 +107,8 @@ private: QList PixmapList; - QHash > m_isotopes; - QList m_spectra; + QHash> m_isotopes; + QList m_spectra; /** * Caching the number of elements diff --git a/src/kalziumelementproperty.cpp b/src/kalziumelementproperty.cpp index 542fdd7a6a39f08d2dbac837aa6dae8697a87b9d..5d282db85b052dcf29d029e952f67b790c5859be 100644 --- a/src/kalziumelementproperty.cpp +++ b/src/kalziumelementproperty.cpp @@ -13,14 +13,14 @@ #include -KalziumElementProperty* KalziumElementProperty::instance() +KalziumElementProperty *KalziumElementProperty::instance() { static KalziumElementProperty elementProperty; return &elementProperty; } KalziumElementProperty::KalziumElementProperty() - : m_mode(0) + : m_mode(0) { m_currentScheme = Prefs::colorschemebox(); @@ -78,12 +78,12 @@ QStringList KalziumElementProperty::gradientList() const return customList; } -KalziumSchemeType* KalziumElementProperty::scheme() const +KalziumSchemeType *KalziumElementProperty::scheme() const { return KalziumSchemeTypeFactory::instance()->build(m_currentScheme); } -KalziumGradientType* KalziumElementProperty::gradient() const +KalziumGradientType *KalziumElementProperty::gradient() const { if (m_currentGradient == NOGRADIENT) { return KalziumGradientTypeFactory::instance()->build(NOGRADIENT); @@ -134,18 +134,18 @@ QBrush KalziumElementProperty::getElementBrush(int el) return QBrush(Qt::darkGray, Qt::Dense7Pattern); } - //The iconic view is the 3rd view (0,1,2,...). Pixmaps don't make nice gradients. - if (m_currentScheme == 2) { - elementBrush = scheme()->elementBrush(el); + // The iconic view is the 3rd view (0,1,2,...). Pixmaps don't make nice gradients. + if (m_currentScheme == 2) { + elementBrush = scheme()->elementBrush(el); } else { // add a nice gradient QColor color = getElementColor(el); QLinearGradient grad(QPointF(0, 0), QPointF(0, 40)); - grad.setColorAt(0,color); + grad.setColorAt(0, color); qreal h, s, v, a; color.getHsvF(&h, &s, &v, &a); - color.setHsvF(h, s, v*0.7, a); - grad.setColorAt(1,color); + color.setHsvF(h, s, v * 0.7, a); + grad.setColorAt(1, color); elementBrush = QBrush(grad); } @@ -171,7 +171,6 @@ QColor KalziumElementProperty::getBorderColor(int el) const } return getTextColor(el); - } int KalziumElementProperty::getMode() const @@ -188,16 +187,15 @@ QColor KalziumElementProperty::gradientBrushLogic(int el) const const double boiling = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::boilingpoint).toDouble(); switch (m_currentGradient) { - case SOMGradientType: if (m_slider < melting) { - //the element is solid + // the element is solid gradientColor = Prefs::color_solid(); } else if ((m_slider > melting) && (m_slider < boiling)) { - //the element is liquid + // the element is liquid gradientColor = Prefs::color_liquid(); } else if ((m_slider >= boiling) && (boiling > 0.0)) { - //the element is vaporous + // the element is vaporous gradientColor = Prefs::color_vapor(); } else { gradientColor = Qt::lightGray; @@ -217,7 +215,7 @@ QColor KalziumElementProperty::gradientBrushLogic(int el) const break; } - if (!isActiv && gradientValue != -1) { //FIXME No magic number... Defined in KalziumGradientFactory + if (!isActiv && gradientValue != -1) { // FIXME No magic number... Defined in KalziumGradientFactory gradientColor = Qt::transparent; } else { const double coeff = gradient()->elementCoeff(el); @@ -225,4 +223,3 @@ QColor KalziumElementProperty::gradientBrushLogic(int el) const } return gradientColor; } - diff --git a/src/kalziumelementproperty.h b/src/kalziumelementproperty.h index c4b74e0a5111c9b4249cec6010d86df0a34e7d41..6201aa8bc10a85996da24d38189e61ada6b5cb76 100644 --- a/src/kalziumelementproperty.h +++ b/src/kalziumelementproperty.h @@ -9,8 +9,8 @@ #include -#include "kalziumschemetype.h" #include "kalziumgradienttype.h" +#include "kalziumschemetype.h" /** * The logic of the scheme and the gradients is merged in this class. It provides @@ -19,18 +19,17 @@ * Here is also the place where the gradientslider is evaluated. (see gradientwidget) * @short This class holds the logic of the appearance from the periodic table * @author Etienne Rebetez -*/ + */ class KalziumElementProperty : public QObject { Q_OBJECT public: - /** - * Get the instance of this factory. - */ - static KalziumElementProperty* instance(); + * Get the instance of this factory. + */ + static KalziumElementProperty *instance(); enum ELEMENTTEXTINFORMATIONMODE { NORMAL = 0, // Only Symbol Number @@ -41,7 +40,7 @@ public: enum SPECIALGRADIENTYPDEF { NOGRADIENT = 0, SOMGradientType = 1, - DISCOVERYDATE = 9 + DISCOVERYDATE = 9, }; /** diff --git a/src/kalziumgradienttype.cpp b/src/kalziumgradienttype.cpp index 1ec75f645dce4abebc508327306f112a28e01e8a..182a093f527f88438d2968b209d1cb6e12a1f4f2 100644 --- a/src/kalziumgradienttype.cpp +++ b/src/kalziumgradienttype.cpp @@ -7,8 +7,8 @@ #include "kalziumgradienttype.h" #include "element.h" -#include "prefs.h" #include "kalziumdataobject.h" +#include "prefs.h" #include "kalzium_debug.h" #include @@ -32,13 +32,13 @@ KalziumGradientTypeFactory::KalziumGradientTypeFactory() m_gradients << KalziumIonizationGradientType::instance(); } -KalziumGradientTypeFactory* KalziumGradientTypeFactory::instance() +KalziumGradientTypeFactory *KalziumGradientTypeFactory::instance() { static KalziumGradientTypeFactory kttf; return &kttf; } -KalziumGradientType* KalziumGradientTypeFactory::build(int id) const +KalziumGradientType *KalziumGradientTypeFactory::build(int id) const { if ((id < 0) || (id >= m_gradients.count())) return nullptr; @@ -46,7 +46,7 @@ KalziumGradientType* KalziumGradientTypeFactory::build(int id) const return m_gradients.at(id); } -KalziumGradientType* KalziumGradientTypeFactory::build(const QByteArray& id) const +KalziumGradientType *KalziumGradientTypeFactory::build(const QByteArray &id) const { for (int i = 0; i < m_gradients.count(); ++i) { if (m_gradients.at(i)->name() == id) { @@ -66,7 +66,6 @@ QStringList KalziumGradientTypeFactory::gradients() const return l; } - KalziumGradientType::KalziumGradientType() { } @@ -75,7 +74,7 @@ KalziumGradientType::~KalziumGradientType() { } -KalziumGradientType* KalziumGradientType::instance() +KalziumGradientType *KalziumGradientType::instance() { return nullptr; } @@ -130,7 +129,8 @@ QColor KalziumGradientType::notAvailableColor() const QColor KalziumGradientType::calculateColor(const double coeff) const { - if ((coeff < 0.0) || (coeff > 1.0)) return notAvailableColor(); + if ((coeff < 0.0) || (coeff > 1.0)) + return notAvailableColor(); QColor color2 = secondColor(); QColor color1 = firstColor(); @@ -142,14 +142,14 @@ QColor KalziumGradientType::calculateColor(const double coeff) const return QColor(red, green, blue); } -KalziumCovalentRadiusGradientType* KalziumCovalentRadiusGradientType::instance() +KalziumCovalentRadiusGradientType *KalziumCovalentRadiusGradientType::instance() { static KalziumCovalentRadiusGradientType kcrgt; return &kcrgt; } KalziumCovalentRadiusGradientType::KalziumCovalentRadiusGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -165,9 +165,9 @@ QString KalziumCovalentRadiusGradientType::description() const double KalziumCovalentRadiusGradientType::value(int el) const { - QVariant v = KalziumDataObject::instance()->element(el) - ->dataAsVariant(ChemicalDataObject::radiusCovalent, Prefs::lengthUnit()); - if (v.type() != QVariant::Double) return -1; + QVariant v = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::radiusCovalent, Prefs::lengthUnit()); + if (v.type() != QVariant::Double) + return -1; return v.toDouble(); } @@ -198,15 +198,14 @@ bool KalziumCovalentRadiusGradientType::logarithmicGradient() const return Prefs::logarithmicCovalentRadiusGradient(); } - -KalziumVanDerWaalsRadiusGradientType* KalziumVanDerWaalsRadiusGradientType::instance() +KalziumVanDerWaalsRadiusGradientType *KalziumVanDerWaalsRadiusGradientType::instance() { static KalziumVanDerWaalsRadiusGradientType kvdwrgt; return &kvdwrgt; } KalziumVanDerWaalsRadiusGradientType::KalziumVanDerWaalsRadiusGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -222,9 +221,9 @@ QString KalziumVanDerWaalsRadiusGradientType::description() const double KalziumVanDerWaalsRadiusGradientType::value(int el) const { - QVariant v = KalziumDataObject::instance()->element(el) - ->dataAsVariant(ChemicalDataObject::radiusVDW, Prefs::lengthUnit()); - if (v.type() != QVariant::Double) return -1; + QVariant v = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::radiusVDW, Prefs::lengthUnit()); + if (v.type() != QVariant::Double) + return -1; return v.toDouble(); } @@ -238,7 +237,6 @@ int KalziumVanDerWaalsRadiusGradientType::decimals() const return 1; } - double KalziumVanDerWaalsRadiusGradientType::minValue() const { KUnitConversion::Value minValue(1.2, KUnitConversion::Angstrom); @@ -256,15 +254,14 @@ bool KalziumVanDerWaalsRadiusGradientType::logarithmicGradient() const return Prefs::logarithmicVanDerWaalsRadiusGradient(); } - -KalziumMassGradientType* KalziumMassGradientType::instance() +KalziumMassGradientType *KalziumMassGradientType::instance() { static KalziumMassGradientType kargt; return &kargt; } KalziumMassGradientType::KalziumMassGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -281,7 +278,8 @@ QString KalziumMassGradientType::description() const double KalziumMassGradientType::value(int el) const { QVariant v = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::mass); - if (v.type() != QVariant::Double) return -1; + if (v.type() != QVariant::Double) + return -1; return v.toDouble(); } @@ -310,14 +308,14 @@ bool KalziumMassGradientType::logarithmicGradient() const return Prefs::logarithmicMassGradient(); } -KalziumBoilingPointGradientType* KalziumBoilingPointGradientType::instance() +KalziumBoilingPointGradientType *KalziumBoilingPointGradientType::instance() { static KalziumBoilingPointGradientType kbpgt; return &kbpgt; } KalziumBoilingPointGradientType::KalziumBoilingPointGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -334,7 +332,8 @@ QString KalziumBoilingPointGradientType::description() const double KalziumBoilingPointGradientType::value(int el) const { QVariant v = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::boilingpoint, Prefs::temperatureUnit()); - if (v.type() != QVariant::Double) return -1; + if (v.type() != QVariant::Double) + return -1; return v.toDouble(); } @@ -365,15 +364,14 @@ bool KalziumBoilingPointGradientType::logarithmicGradient() const return Prefs::logarithmicBoilingPointGradient(); } - -KalziumMeltingPointGradientType* KalziumMeltingPointGradientType::instance() +KalziumMeltingPointGradientType *KalziumMeltingPointGradientType::instance() { static KalziumMeltingPointGradientType kmpgt; return &kmpgt; } KalziumMeltingPointGradientType::KalziumMeltingPointGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -390,7 +388,8 @@ QString KalziumMeltingPointGradientType::description() const double KalziumMeltingPointGradientType::value(int el) const { QVariant v = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::meltingpoint, Prefs::temperatureUnit()); - if (v.type() != QVariant::Double) return -1; + if (v.type() != QVariant::Double) + return -1; return v.toDouble(); } @@ -421,14 +420,14 @@ bool KalziumMeltingPointGradientType::logarithmicGradient() const return Prefs::logarithmicMeltingPointGradient(); } -KalziumSOMGradientType* KalziumSOMGradientType::instance() +KalziumSOMGradientType *KalziumSOMGradientType::instance() { static KalziumSOMGradientType kargt; return &kargt; } KalziumSOMGradientType::KalziumSOMGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -450,7 +449,8 @@ double KalziumSOMGradientType::value(int el) const QString KalziumSOMGradientType::unit() const { - return KalziumDataObject::instance()->unitAsString(Prefs::temperatureUnit());; + return KalziumDataObject::instance()->unitAsString(Prefs::temperatureUnit()); + ; } int KalziumSOMGradientType::decimals() const @@ -473,18 +473,17 @@ double KalziumSOMGradientType::maxValue() const bool KalziumSOMGradientType::logarithmicGradient() const { return true; -// return Prefs::logarithmicSOMGradient(); + // return Prefs::logarithmicSOMGradient(); } - -KalziumElectronegativityGradientType* KalziumElectronegativityGradientType::instance() +KalziumElectronegativityGradientType *KalziumElectronegativityGradientType::instance() { static KalziumElectronegativityGradientType kegt; return &kegt; } KalziumElectronegativityGradientType::KalziumElectronegativityGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -501,7 +500,8 @@ QString KalziumElectronegativityGradientType::description() const double KalziumElectronegativityGradientType::value(int el) const { QVariant v = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::electronegativityPauling); - if (v.type() != QVariant::Double) return -1; + if (v.type() != QVariant::Double) + return -1; return v.toDouble(); } @@ -530,16 +530,16 @@ bool KalziumElectronegativityGradientType::logarithmicGradient() const return Prefs::logarithmicElectronegativityGradient(); } -///DISCOVERYDATE/// +/// DISCOVERYDATE/// -KalziumDiscoverydateGradientType* KalziumDiscoverydateGradientType::instance() +KalziumDiscoverydateGradientType *KalziumDiscoverydateGradientType::instance() { static KalziumDiscoverydateGradientType kegt; return &kegt; } KalziumDiscoverydateGradientType::KalziumDiscoverydateGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -556,7 +556,8 @@ QString KalziumDiscoverydateGradientType::description() const double KalziumDiscoverydateGradientType::value(int el) const { QVariant v = KalziumDataObject::instance()->element(el)->dataAsVariant(ChemicalDataObject::date); - if (v.value() == 0) return -1; + if (v.value() == 0) + return -1; return v.toDouble(); } @@ -570,7 +571,6 @@ int KalziumDiscoverydateGradientType::decimals() const return 0; } - double KalziumDiscoverydateGradientType::minValue() const { return 1669.0; @@ -586,17 +586,16 @@ bool KalziumDiscoverydateGradientType::logarithmicGradient() const return Prefs::logarithmicDiscoverydateGradient(); } +/// ELECTRONAFFINITY/// -///ELECTRONAFFINITY/// - -KalziumElectronaffinityGradientType* KalziumElectronaffinityGradientType::instance() +KalziumElectronaffinityGradientType *KalziumElectronaffinityGradientType::instance() { static KalziumElectronaffinityGradientType kegt; return &kegt; } KalziumElectronaffinityGradientType::KalziumElectronaffinityGradientType() - : KalziumGradientType() + : KalziumGradientType() { } @@ -643,15 +642,16 @@ bool KalziumElectronaffinityGradientType::logarithmicGradient() const return Prefs::logarithmicElectronaffinityGradient(); } -///FIRST IONIZATINO/// +/// FIRST IONIZATINO/// -KalziumIonizationGradientType* KalziumIonizationGradientType::instance() +KalziumIonizationGradientType *KalziumIonizationGradientType::instance() { static KalziumIonizationGradientType kegt; return &kegt; } -KalziumIonizationGradientType::KalziumIonizationGradientType() : KalziumGradientType() +KalziumIonizationGradientType::KalziumIonizationGradientType() + : KalziumGradientType() { } diff --git a/src/kalziumgradienttype.h b/src/kalziumgradienttype.h index 9af84be32f6ca6b5900b010733787b9f03d9b406..c620082f1a4fe53afbea3a0f0e66e149f9941cf2 100644 --- a/src/kalziumgradienttype.h +++ b/src/kalziumgradienttype.h @@ -20,7 +20,6 @@ class KalziumGradientType; class KalziumGradientTypeFactory { public: - enum KalziumGradientTypes { SOMGradientType = 0, CovalentRadiusGradientType, @@ -36,32 +35,31 @@ public: /** * Get the instance of this factory. */ - static KalziumGradientTypeFactory* instance(); + static KalziumGradientTypeFactory *instance(); /** * Returns the KalziumGradientType with the @p id specified. * It will gives 0 if none found. */ - KalziumGradientType* build(int id) const; + KalziumGradientType *build(int id) const; /** * Returns the KalziumGradientType whose name is the @p id * specified. * It will gives 0 if none found. */ - KalziumGradientType* build(const QByteArray& id) const; + KalziumGradientType *build(const QByteArray &id) const; /** * Returns a list with the names of the gradients we support. */ QStringList gradients() const; - void setCurrentGradient(int newGradient); private: KalziumGradientTypeFactory(); - QList m_gradients; + QList m_gradients; }; /** @@ -76,7 +74,7 @@ public: /** * Get its instance. */ - static KalziumGradientType* instance(); + static KalziumGradientType *instance(); virtual ~KalziumGradientType(); @@ -161,7 +159,7 @@ protected: class KalziumCovalentRadiusGradientType : public KalziumGradientType { public: - static KalziumCovalentRadiusGradientType* instance(); + static KalziumCovalentRadiusGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -187,7 +185,7 @@ private: class KalziumVanDerWaalsRadiusGradientType : public KalziumGradientType { public: - static KalziumVanDerWaalsRadiusGradientType* instance(); + static KalziumVanDerWaalsRadiusGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -213,7 +211,7 @@ private: class KalziumMassGradientType : public KalziumGradientType { public: - static KalziumMassGradientType* instance(); + static KalziumMassGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -239,7 +237,7 @@ private: class KalziumBoilingPointGradientType : public KalziumGradientType { public: - static KalziumBoilingPointGradientType* instance(); + static KalziumBoilingPointGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -265,7 +263,7 @@ private: class KalziumMeltingPointGradientType : public KalziumGradientType { public: - static KalziumMeltingPointGradientType* instance(); + static KalziumMeltingPointGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -283,7 +281,6 @@ private: KalziumMeltingPointGradientType(); }; - /** * The gradient for SOM Widget * @@ -292,7 +289,7 @@ private: class KalziumSOMGradientType : public KalziumGradientType { public: - static KalziumSOMGradientType* instance(); + static KalziumSOMGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -318,7 +315,7 @@ private: class KalziumElectronegativityGradientType : public KalziumGradientType { public: - static KalziumElectronegativityGradientType* instance(); + static KalziumElectronegativityGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -344,7 +341,7 @@ private: class KalziumDiscoverydateGradientType : public KalziumGradientType { public: - static KalziumDiscoverydateGradientType* instance(); + static KalziumDiscoverydateGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -370,7 +367,7 @@ private: class KalziumElectronaffinityGradientType : public KalziumGradientType { public: - static KalziumElectronaffinityGradientType* instance(); + static KalziumElectronaffinityGradientType *instance(); QByteArray name() const override; QString description() const override; @@ -396,7 +393,7 @@ private: class KalziumIonizationGradientType : public KalziumGradientType { public: - static KalziumIonizationGradientType* instance(); + static KalziumIonizationGradientType *instance(); QByteArray name() const override; QString description() const override; diff --git a/src/kalziumnumerationtype.cpp b/src/kalziumnumerationtype.cpp index 167d3ed8825674a14a8a1be3f2f4901683c08f04..80b7ab21044567da12a3c41dd5f81d21a4464f20 100644 --- a/src/kalziumnumerationtype.cpp +++ b/src/kalziumnumerationtype.cpp @@ -18,13 +18,13 @@ KalziumNumerationTypeFactory::KalziumNumerationTypeFactory() m_numerations << KalziumOldIUPACNumerationType::instance(); } -KalziumNumerationTypeFactory* KalziumNumerationTypeFactory::instance() +KalziumNumerationTypeFactory *KalziumNumerationTypeFactory::instance() { static KalziumNumerationTypeFactory kntf; return &kntf; } -KalziumNumerationType* KalziumNumerationTypeFactory::build(int id) const +KalziumNumerationType *KalziumNumerationTypeFactory::build(int id) const { if ((id < 0) || (id >= m_numerations.count())) { return nullptr; @@ -33,7 +33,7 @@ KalziumNumerationType* KalziumNumerationTypeFactory::build(int id) const return m_numerations.at(id); } -KalziumNumerationType* KalziumNumerationTypeFactory::build(const QByteArray& id) const +KalziumNumerationType *KalziumNumerationTypeFactory::build(const QByteArray &id) const { for (int i = 0; i < m_numerations.count(); ++i) { if (m_numerations.at(i)->name() == id) { @@ -54,8 +54,7 @@ QStringList KalziumNumerationTypeFactory::numerations() const return l; } - -KalziumNumerationType* KalziumNumerationType::instance() +KalziumNumerationType *KalziumNumerationType::instance() { return nullptr; } @@ -82,15 +81,14 @@ QStringList KalziumNumerationType::items() const return m_items; } - -KalziumNoneNumerationType* KalziumNoneNumerationType::instance() +KalziumNoneNumerationType *KalziumNoneNumerationType::instance() { static KalziumNoneNumerationType knnt; return &knnt; } KalziumNoneNumerationType::KalziumNoneNumerationType() - : KalziumNumerationType() + : KalziumNumerationType() { } @@ -115,14 +113,14 @@ QStringList KalziumNoneNumerationType::items() const return QStringList(); } -KalziumIUPACNumerationType* KalziumIUPACNumerationType::instance() +KalziumIUPACNumerationType *KalziumIUPACNumerationType::instance() { static KalziumIUPACNumerationType kint; return &kint; } KalziumIUPACNumerationType::KalziumIUPACNumerationType() - : KalziumNumerationType() + : KalziumNumerationType() { // cache them m_items << QStringLiteral("1"); @@ -155,14 +153,14 @@ QString KalziumIUPACNumerationType::description() const return i18n("IUPAC"); } -KalziumCASNumerationType* KalziumCASNumerationType::instance() +KalziumCASNumerationType *KalziumCASNumerationType::instance() { static KalziumCASNumerationType kcnt; return &kcnt; } KalziumCASNumerationType::KalziumCASNumerationType() - : KalziumNumerationType() + : KalziumNumerationType() { // cache them m_items << QStringLiteral("IA"); @@ -195,14 +193,14 @@ QString KalziumCASNumerationType::description() const return i18n("CAS"); } -KalziumOldIUPACNumerationType* KalziumOldIUPACNumerationType::instance() +KalziumOldIUPACNumerationType *KalziumOldIUPACNumerationType::instance() { static KalziumOldIUPACNumerationType koint; return &koint; } KalziumOldIUPACNumerationType::KalziumOldIUPACNumerationType() - : KalziumNumerationType() + : KalziumNumerationType() { // cache them m_items << QStringLiteral("1A"); diff --git a/src/kalziumnumerationtype.h b/src/kalziumnumerationtype.h index 08e4db031387af4f61cf390a7effeb844ef06aad..c199c02416fbc18a5f7026ddba30cb6549ede010 100644 --- a/src/kalziumnumerationtype.h +++ b/src/kalziumnumerationtype.h @@ -23,19 +23,19 @@ public: /** * Get the instance of this factory. */ - static KalziumNumerationTypeFactory* instance(); + static KalziumNumerationTypeFactory *instance(); /** * Returns the KalziumNumerationType with the @p id specified. * It will gives 0 if none found. */ - KalziumNumerationType* build(int id) const; + KalziumNumerationType *build(int id) const; /** * Returns the KalziumNumerationType whose name is the @p id * specified. * It will gives 0 if none found. */ - KalziumNumerationType* build(const QByteArray& id) const; + KalziumNumerationType *build(const QByteArray &id) const; /** * Returns a list with the names of the numeration types we @@ -46,7 +46,7 @@ public: private: KalziumNumerationTypeFactory(); - QList m_numerations; + QList m_numerations; }; /** @@ -61,7 +61,7 @@ public: /** * Get its instance. */ - static KalziumNumerationType* instance(); + static KalziumNumerationType *instance(); virtual ~KalziumNumerationType(); @@ -101,7 +101,7 @@ protected: class KalziumNoneNumerationType : public KalziumNumerationType { public: - static KalziumNoneNumerationType* instance(); + static KalziumNoneNumerationType *instance(); QByteArray name() const override; QString description() const override; @@ -121,7 +121,7 @@ private: class KalziumIUPACNumerationType : public KalziumNumerationType { public: - static KalziumIUPACNumerationType* instance(); + static KalziumIUPACNumerationType *instance(); QByteArray name() const override; QString description() const override; @@ -138,7 +138,7 @@ private: class KalziumCASNumerationType : public KalziumNumerationType { public: - static KalziumCASNumerationType* instance(); + static KalziumCASNumerationType *instance(); QByteArray name() const override; QString description() const override; @@ -155,7 +155,7 @@ private: class KalziumOldIUPACNumerationType : public KalziumNumerationType { public: - static KalziumOldIUPACNumerationType* instance(); + static KalziumOldIUPACNumerationType *instance(); QByteArray name() const override; QString description() const override; diff --git a/src/kalziumschemetype.cpp b/src/kalziumschemetype.cpp index 4acec46fca376605f296092562b981e12bd275f9..2fa2af68f3261ef13bf44e6f0916c98c19d7c853 100644 --- a/src/kalziumschemetype.cpp +++ b/src/kalziumschemetype.cpp @@ -16,8 +16,8 @@ #include #endif -#include #include "kalzium_debug.h" +#include #include #include @@ -29,18 +29,18 @@ KalziumSchemeTypeFactory::KalziumSchemeTypeFactory() m_schemes << KalziumIconicSchemeType::instance(); m_schemes << KalziumFamilySchemeType::instance(); m_schemes << KalziumGroupsSchemeType::instance(); - #ifdef HAVE_OPENBABEL +#ifdef HAVE_OPENBABEL m_schemes << KalziumColorSchemeType::instance(); - #endif +#endif } -KalziumSchemeTypeFactory* KalziumSchemeTypeFactory::instance() +KalziumSchemeTypeFactory *KalziumSchemeTypeFactory::instance() { static KalziumSchemeTypeFactory kstf; return &kstf; } -KalziumSchemeType* KalziumSchemeTypeFactory::build(int id) const +KalziumSchemeType *KalziumSchemeTypeFactory::build(int id) const { if ((id < 0) || (id >= m_schemes.count())) { return nullptr; @@ -49,7 +49,7 @@ KalziumSchemeType* KalziumSchemeTypeFactory::build(int id) const return m_schemes.at(id); } -KalziumSchemeType* KalziumSchemeTypeFactory::build(const QByteArray& id) const +KalziumSchemeType *KalziumSchemeTypeFactory::build(const QByteArray &id) const { for (int i = 0; i < m_schemes.count(); ++i) { if (m_schemes.at(i)->name() == id) { @@ -69,15 +69,13 @@ QStringList KalziumSchemeTypeFactory::schemes() const return l; } - -KalziumSchemeType* KalziumSchemeType::instance() +KalziumSchemeType *KalziumSchemeType::instance() { return nullptr; } KalziumSchemeType::KalziumSchemeType() { - } KalziumSchemeType::~KalziumSchemeType() @@ -85,11 +83,11 @@ KalziumSchemeType::~KalziumSchemeType() } KalziumMonoColorSchemeType::KalziumMonoColorSchemeType() - : KalziumSchemeType() + : KalziumSchemeType() { } -KalziumMonoColorSchemeType* KalziumMonoColorSchemeType::instance() +KalziumMonoColorSchemeType *KalziumMonoColorSchemeType::instance() { static KalziumMonoColorSchemeType kmcst; return &kmcst; @@ -124,13 +122,12 @@ QList KalziumMonoColorSchemeType::legendItems() const return ll; } - KalziumBlocksSchemeType::KalziumBlocksSchemeType() - : KalziumSchemeType() + : KalziumSchemeType() { } -KalziumBlocksSchemeType* KalziumBlocksSchemeType::instance() +KalziumBlocksSchemeType *KalziumBlocksSchemeType::instance() { static KalziumBlocksSchemeType kbst; return &kbst; @@ -182,14 +179,14 @@ QList KalziumBlocksSchemeType::legendItems() const return ll; } -///ICONIC SCHEME/// +/// ICONIC SCHEME/// KalziumIconicSchemeType::KalziumIconicSchemeType() - : KalziumSchemeType() + : KalziumSchemeType() { } -KalziumIconicSchemeType* KalziumIconicSchemeType::instance() +KalziumIconicSchemeType *KalziumIconicSchemeType::instance() { static KalziumIconicSchemeType kist; return &kist; @@ -223,14 +220,13 @@ QList KalziumIconicSchemeType::legendItems() const return ll; } - -///Family/// +/// Family/// KalziumFamilySchemeType::KalziumFamilySchemeType() - : KalziumSchemeType() + : KalziumSchemeType() { } -KalziumFamilySchemeType* KalziumFamilySchemeType::instance() +KalziumFamilySchemeType *KalziumFamilySchemeType::instance() { static KalziumFamilySchemeType kbst; return &kbst; @@ -285,26 +281,26 @@ QColor KalziumFamilySchemeType::textColor(int) const QList KalziumFamilySchemeType::legendItems() const { QList ll; - ll << qMakePair(i18n("Alkaline"),QColor(Prefs::alkalie())); - ll << qMakePair(i18n("Rare Earth"),QColor(Prefs::rare())); - ll << qMakePair(i18n("Non-Metals"),QColor(Prefs::nonmetal())); - ll << qMakePair(i18n("Alkalie Metal"),QColor(Prefs::alkaline())); - ll << qMakePair(i18n("Other Metal"),QColor(Prefs::other_metal())); - ll << qMakePair(i18n("Halogen"),QColor(Prefs::halogene())); - ll << qMakePair(i18n("Transition Metal"),QColor(Prefs::transition())); - ll << qMakePair(i18n("Noble Gas"),QColor(Prefs::noble_gas())); - ll << qMakePair(i18n("Metalloid"),QColor(Prefs::metalloid())); + ll << qMakePair(i18n("Alkaline"), QColor(Prefs::alkalie())); + ll << qMakePair(i18n("Rare Earth"), QColor(Prefs::rare())); + ll << qMakePair(i18n("Non-Metals"), QColor(Prefs::nonmetal())); + ll << qMakePair(i18n("Alkalie Metal"), QColor(Prefs::alkaline())); + ll << qMakePair(i18n("Other Metal"), QColor(Prefs::other_metal())); + ll << qMakePair(i18n("Halogen"), QColor(Prefs::halogene())); + ll << qMakePair(i18n("Transition Metal"), QColor(Prefs::transition())); + ll << qMakePair(i18n("Noble Gas"), QColor(Prefs::noble_gas())); + ll << qMakePair(i18n("Metalloid"), QColor(Prefs::metalloid())); return ll; } -///GROUPS/// +/// GROUPS/// KalziumGroupsSchemeType::KalziumGroupsSchemeType() - : KalziumSchemeType() + : KalziumSchemeType() { } -KalziumGroupsSchemeType* KalziumGroupsSchemeType::instance() +KalziumGroupsSchemeType *KalziumGroupsSchemeType::instance() { static KalziumGroupsSchemeType kbst; return &kbst; @@ -370,13 +366,13 @@ QList KalziumGroupsSchemeType::legendItems() const } #ifdef HAVE_OPENBABEL -///OpenBabel Color/// +/// OpenBabel Color/// KalziumColorSchemeType::KalziumColorSchemeType() - : KalziumSchemeType() + : KalziumSchemeType() { } -KalziumColorSchemeType* KalziumColorSchemeType::instance() +KalziumColorSchemeType *KalziumColorSchemeType::instance() { static KalziumColorSchemeType kbst; return &kbst; @@ -422,201 +418,200 @@ QList KalziumColorSchemeType::legendItems() const } #endif - -///CRYSTAL/// -//X KalziumCrystalSchemeType::KalziumCrystalSchemeType() -//X : KalziumSchemeType() -//X { -//X } -//X -//X KalziumCrystalSchemeType* KalziumCrystalSchemeType::instance() -//X { -//X static KalziumCrystalSchemeType kbst; -//X return &kbst; -//X } -//X -//X QByteArray KalziumCrystalSchemeType::name() const -//X { -//X return "Crystal"; -//X } -//X -//X QString KalziumCrystalSchemeType::description() const -//X { -//X return i18n("Crystal Structures"); -//X } -//X -//X QBrush KalziumCrystalSchemeType::elementBrush(int el, const QRect& elrect) const -//X { -//X QString crystal = KalziumDataObject::instance()->element(el)->dataAsString(ChemicalDataObject::crystalstructure); -//X -//X qCDebug(KALZIUM_LOG) << "crystal is " << crystal; -//X -//X static QString resourcepath; -//X if (resourcepath.isEmpty()) { -//X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/latticeicons/"); -//X } -//X -//X QString filename; -//X if (crystal == "bcc") { -//X filename = "ci.png"; -//X } else if (crystal == "ccp") { -//X filename = "cp.png"; -//X } else if (crystal == "fcc") { -//X filename = "cf.png"; -//X } else if (crystal == "hcp") { -//X filename = "hp.png"; -//X } else if (crystal == "rh") { -//X filename = "hr.png";//Rhombohedral primitive -//X } else if (crystal == "or") { -//X filename = "op.png";//Orthorhombic primitive -//X } else if (crystal == "mono") { -//X filename = "ms.png";//Monoclinic primitive -//X } else if (crystal == "tri") { -//X filename = "ap.png";//Triclinic -//X } else if (crystal == "tp") { -//X filename = "tp.png";//Tetragonal primitive -//X } -//X -//X filename.prepend(resourcepath); -//X -//X QBrush ret; -//X if (!filename.isEmpty()) { -//X qCDebug(KALZIUM_LOG) << el << ": FILENAME is not EMPTY... " << filename; -//X QPixmap pixmap(resourcepath + filename); -//X ret = QBrush(pixmap.scaled(elrect.size(), Qt::KeepAspectRatio)); -//X } else { -//X qCDebug(KALZIUM_LOG) << el << ": FILENAME EMPTY... " << filename; -//X ret.setColor(Qt::gray); -//X } -//X -//X return ret; -//X } -//X -//X QColor KalziumCrystalSchemeType::textColor(int) const -//X { -//X return Qt::black; -//X } -//X -//X QList KalziumCrystalSchemeType::legendItems() const -//X { -//X static QString resourcepath; -//X if (resourcepath.isEmpty()) -//X { -//X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/latticeicons/"); -//X } -//X -//X QList ll; -//X ll << qMakePair(i18n("bcc, body centered cubic"), QColor(QPixmap(resourcepath + "ci.png"))); -//X ll << qMakePair(i18n("ccp, cubic close packed"), QColor(QPixmap(resourcepath + "cp.png"))); -//X ll << qMakePair(i18n("fcc, face centered cubic"), QColor(QPixmap(resourcepath + "cf.png"))); -//X ll << qMakePair(i18n("hcp, hexagonal close packed"), QColor(QPixmap(resourcepath + "hp.png"))); -//X ll << qMakePair(i18n("rh, rhombohedral"), QColor(QPixmap(resourcepath + "hr.png"))); -//X ll << qMakePair(i18n("or, orthorhombic primitive"), QColor(QPixmap(resourcepath + "op.png"))); -//X ll << qMakePair(i18n("ms, monoclinic"), QColor(QPixmap(resourcepath + "ms.png"))); -//X ll << qMakePair(i18n("ap, triclinic"), QColor(QPixmap(resourcepath + "ap.png"))); -//X ll << qMakePair(i18n("tp, tetragonal primitive"), QColor(QPixmap(resourcepath + "tp.png"))); -//X -//X return ll; -//X } +/// CRYSTAL/// +// X KalziumCrystalSchemeType::KalziumCrystalSchemeType() +// X : KalziumSchemeType() +// X { +// X } +// X +// X KalziumCrystalSchemeType* KalziumCrystalSchemeType::instance() +// X { +// X static KalziumCrystalSchemeType kbst; +// X return &kbst; +// X } +// X +// X QByteArray KalziumCrystalSchemeType::name() const +// X { +// X return "Crystal"; +// X } +// X +// X QString KalziumCrystalSchemeType::description() const +// X { +// X return i18n("Crystal Structures"); +// X } +// X +// X QBrush KalziumCrystalSchemeType::elementBrush(int el, const QRect& elrect) const +// X { +// X QString crystal = KalziumDataObject::instance()->element(el)->dataAsString(ChemicalDataObject::crystalstructure); +// X +// X qCDebug(KALZIUM_LOG) << "crystal is " << crystal; +// X +// X static QString resourcepath; +// X if (resourcepath.isEmpty()) { +// X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/latticeicons/"); +// X } +// X +// X QString filename; +// X if (crystal == "bcc") { +// X filename = "ci.png"; +// X } else if (crystal == "ccp") { +// X filename = "cp.png"; +// X } else if (crystal == "fcc") { +// X filename = "cf.png"; +// X } else if (crystal == "hcp") { +// X filename = "hp.png"; +// X } else if (crystal == "rh") { +// X filename = "hr.png";//Rhombohedral primitive +// X } else if (crystal == "or") { +// X filename = "op.png";//Orthorhombic primitive +// X } else if (crystal == "mono") { +// X filename = "ms.png";//Monoclinic primitive +// X } else if (crystal == "tri") { +// X filename = "ap.png";//Triclinic +// X } else if (crystal == "tp") { +// X filename = "tp.png";//Tetragonal primitive +// X } +// X +// X filename.prepend(resourcepath); +// X +// X QBrush ret; +// X if (!filename.isEmpty()) { +// X qCDebug(KALZIUM_LOG) << el << ": FILENAME is not EMPTY... " << filename; +// X QPixmap pixmap(resourcepath + filename); +// X ret = QBrush(pixmap.scaled(elrect.size(), Qt::KeepAspectRatio)); +// X } else { +// X qCDebug(KALZIUM_LOG) << el << ": FILENAME EMPTY... " << filename; +// X ret.setColor(Qt::gray); +// X } +// X +// X return ret; +// X } +// X +// X QColor KalziumCrystalSchemeType::textColor(int) const +// X { +// X return Qt::black; +// X } +// X +// X QList KalziumCrystalSchemeType::legendItems() const +// X { +// X static QString resourcepath; +// X if (resourcepath.isEmpty()) +// X { +// X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/latticeicons/"); +// X } +// X +// X QList ll; +// X ll << qMakePair(i18n("bcc, body centered cubic"), QColor(QPixmap(resourcepath + "ci.png"))); +// X ll << qMakePair(i18n("ccp, cubic close packed"), QColor(QPixmap(resourcepath + "cp.png"))); +// X ll << qMakePair(i18n("fcc, face centered cubic"), QColor(QPixmap(resourcepath + "cf.png"))); +// X ll << qMakePair(i18n("hcp, hexagonal close packed"), QColor(QPixmap(resourcepath + "hp.png"))); +// X ll << qMakePair(i18n("rh, rhombohedral"), QColor(QPixmap(resourcepath + "hr.png"))); +// X ll << qMakePair(i18n("or, orthorhombic primitive"), QColor(QPixmap(resourcepath + "op.png"))); +// X ll << qMakePair(i18n("ms, monoclinic"), QColor(QPixmap(resourcepath + "ms.png"))); +// X ll << qMakePair(i18n("ap, triclinic"), QColor(QPixmap(resourcepath + "ap.png"))); +// X ll << qMakePair(i18n("tp, tetragonal primitive"), QColor(QPixmap(resourcepath + "tp.png"))); +// X +// X return ll; +// X } //// -//X KalziumDiscoverymapSchemeType::KalziumDiscoverymapSchemeType() -//X : KalziumSchemeType() -//X { -//X } -//X -//X KalziumDiscoverymapSchemeType* KalziumDiscoverymapSchemeType::instance() -//X { -//X static KalziumDiscoverymapSchemeType kbst; -//X return &kbst; -//X } -//X -//X QByteArray KalziumDiscoverymapSchemeType::name() const -//X { -//X return "Crystal"; -//X } -//X -//X QString KalziumDiscoverymapSchemeType::description() const -//X { -//X return i18n("Discovery Country"); -//X } -//X -//X QBrush KalziumDiscoverymapSchemeType::elementBrush(int el, const QRect& elrect) const -//X { -//X QString map = KalziumDataObject::instance()->element(el)->dataAsString(ChemicalDataObject::discoveryCountry); -//X -//X static QString resourcepath; -//X if (resourcepath.isEmpty()) { -//X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/maps/"); -//X } -//X -//X QString filename; -//X if (map == "se") { -//X filename = "se.png"; -//X } else if (map == "uk") { -//X filename = "uk.png"; -//X } else if (map == "us") { -//X filename = "us.png"; -//X } else if (map == "ru") { -//X filename = "ru.png"; -//X } else if (map == "it") { -//X filename = "it.png"; -//X } else if (map == "de") { -//X filename = "de.png"; -//X } else if (map == "dk") { -//X filename = "dk.png"; -//X } else if (map == "fr") { -//X filename = "fr.png"; -//X } else if (map == "fi") { -//X filename = "fi.png"; -//X } else if (map == "es") { -//X filename = "es.png"; -//X } else if (map == "ancient") { -//X return QBrush(Qt::lightGray); -//X } else if (map == "uk,fr") { -//X filename = "ukfr.png"; -//X } else if (map == "se,uk") { -//X filename = "ukse.png"; -//X } else if (map == "ru,us") { -//X filename = "ruus.png"; -//X } else { -//X return QBrush(Qt::blue); -//X } -//X -//X QBrush ret; -//X if (!filename.isEmpty()) { -//X QPixmap pixmap(resourcepath + filename); -//X ret = QBrush(pixmap.scaled(elrect.size(), Qt::KeepAspectRatio)); -//X } else { -//X ret.setColor(Qt::gray); -//X } -//X -//X return ret; -//X } -//X -//X QColor KalziumDiscoverymapSchemeType::textColor(int) const -//X { -//X return Qt::black; -//X } -//X -//X QList KalziumDiscoverymapSchemeType::legendItems() const -//X { -//X static QString resourcepath; -//X if (resourcepath.isEmpty()) { -//X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/maps/"); -//X } -//X -//X QList ll; -//X ll << qMakePair(i18n("Germany"), QColor(QPixmap(resourcepath + "de.png"))); -//X ll << qMakePair(i18n("United Kindom"), QColor(QPixmap(resourcepath + "uk.png"))); -//X ll << qMakePair(i18n("Sweden"), QColor(QPixmap(resourcepath + "se.png"))); -//X ll << qMakePair(i18n("USA"), QColor(QPixmap(resourcepath + "us.png"))); -//X ll << qMakePair(i18n("Russia"), QColor(QPixmap(resourcepath + "ru.png"))); -//X ll << qMakePair(i18n("Italy"), QColor(QPixmap(resourcepath + "it.png"))); -//X ll << qMakePair(i18n("Denmark"), QColor(QPixmap(resourcepath + "dk.png"))); -//X ll << qMakePair(i18n("France"), QColor(QPixmap(resourcepath + "fr.png"))); -//X ll << qMakePair(i18n("Finland"), QColor(QPixmap(resourcepath + "fi.png"))); -//X ll << qMakePair(i18n("Spain"), QColor(QPixmap(resourcepath + "es.png"))); -//X -//X return ll; -//X } +// X KalziumDiscoverymapSchemeType::KalziumDiscoverymapSchemeType() +// X : KalziumSchemeType() +// X { +// X } +// X +// X KalziumDiscoverymapSchemeType* KalziumDiscoverymapSchemeType::instance() +// X { +// X static KalziumDiscoverymapSchemeType kbst; +// X return &kbst; +// X } +// X +// X QByteArray KalziumDiscoverymapSchemeType::name() const +// X { +// X return "Crystal"; +// X } +// X +// X QString KalziumDiscoverymapSchemeType::description() const +// X { +// X return i18n("Discovery Country"); +// X } +// X +// X QBrush KalziumDiscoverymapSchemeType::elementBrush(int el, const QRect& elrect) const +// X { +// X QString map = KalziumDataObject::instance()->element(el)->dataAsString(ChemicalDataObject::discoveryCountry); +// X +// X static QString resourcepath; +// X if (resourcepath.isEmpty()) { +// X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/maps/"); +// X } +// X +// X QString filename; +// X if (map == "se") { +// X filename = "se.png"; +// X } else if (map == "uk") { +// X filename = "uk.png"; +// X } else if (map == "us") { +// X filename = "us.png"; +// X } else if (map == "ru") { +// X filename = "ru.png"; +// X } else if (map == "it") { +// X filename = "it.png"; +// X } else if (map == "de") { +// X filename = "de.png"; +// X } else if (map == "dk") { +// X filename = "dk.png"; +// X } else if (map == "fr") { +// X filename = "fr.png"; +// X } else if (map == "fi") { +// X filename = "fi.png"; +// X } else if (map == "es") { +// X filename = "es.png"; +// X } else if (map == "ancient") { +// X return QBrush(Qt::lightGray); +// X } else if (map == "uk,fr") { +// X filename = "ukfr.png"; +// X } else if (map == "se,uk") { +// X filename = "ukse.png"; +// X } else if (map == "ru,us") { +// X filename = "ruus.png"; +// X } else { +// X return QBrush(Qt::blue); +// X } +// X +// X QBrush ret; +// X if (!filename.isEmpty()) { +// X QPixmap pixmap(resourcepath + filename); +// X ret = QBrush(pixmap.scaled(elrect.size(), Qt::KeepAspectRatio)); +// X } else { +// X ret.setColor(Qt::gray); +// X } +// X +// X return ret; +// X } +// X +// X QColor KalziumDiscoverymapSchemeType::textColor(int) const +// X { +// X return Qt::black; +// X } +// X +// X QList KalziumDiscoverymapSchemeType::legendItems() const +// X { +// X static QString resourcepath; +// X if (resourcepath.isEmpty()) { +// X resourcepath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, "data/maps/"); +// X } +// X +// X QList ll; +// X ll << qMakePair(i18n("Germany"), QColor(QPixmap(resourcepath + "de.png"))); +// X ll << qMakePair(i18n("United Kindom"), QColor(QPixmap(resourcepath + "uk.png"))); +// X ll << qMakePair(i18n("Sweden"), QColor(QPixmap(resourcepath + "se.png"))); +// X ll << qMakePair(i18n("USA"), QColor(QPixmap(resourcepath + "us.png"))); +// X ll << qMakePair(i18n("Russia"), QColor(QPixmap(resourcepath + "ru.png"))); +// X ll << qMakePair(i18n("Italy"), QColor(QPixmap(resourcepath + "it.png"))); +// X ll << qMakePair(i18n("Denmark"), QColor(QPixmap(resourcepath + "dk.png"))); +// X ll << qMakePair(i18n("France"), QColor(QPixmap(resourcepath + "fr.png"))); +// X ll << qMakePair(i18n("Finland"), QColor(QPixmap(resourcepath + "fi.png"))); +// X ll << qMakePair(i18n("Spain"), QColor(QPixmap(resourcepath + "es.png"))); +// X +// X return ll; +// X } diff --git a/src/kalziumschemetype.h b/src/kalziumschemetype.h index d8437203861746c09a1157911f57d9d14acb8a98..ef768e821a544eb3c283cdce874527431e7df1db 100644 --- a/src/kalziumschemetype.h +++ b/src/kalziumschemetype.h @@ -32,19 +32,19 @@ public: /** * Get the instance of this factory. */ - static KalziumSchemeTypeFactory* instance(); + static KalziumSchemeTypeFactory *instance(); /** * Returns the KalziumSchemeType with the @p id specified. * It will gives 0 if none found. */ - KalziumSchemeType* build(int id) const; + KalziumSchemeType *build(int id) const; /** * Returns the KalziumSchemeType whose name is the @p id * specified. * It will gives 0 if none found. */ - KalziumSchemeType* build(const QByteArray& id) const; + KalziumSchemeType *build(const QByteArray &id) const; /** * Returns a list with the names of the schemes we support. @@ -53,7 +53,7 @@ public: private: KalziumSchemeTypeFactory(); - QList m_schemes; + QList m_schemes; }; /** @@ -67,7 +67,7 @@ public: /** * Get its instance. */ - static KalziumSchemeType* instance(); + static KalziumSchemeType *instance(); virtual ~KalziumSchemeType(); @@ -115,7 +115,7 @@ protected: class KalziumMonoColorSchemeType : public KalziumSchemeType { public: - static KalziumMonoColorSchemeType* instance(); + static KalziumMonoColorSchemeType *instance(); QByteArray name() const override; QString description() const override; @@ -137,7 +137,7 @@ private: class KalziumBlocksSchemeType : public KalziumSchemeType { public: - static KalziumBlocksSchemeType* instance(); + static KalziumBlocksSchemeType *instance(); QByteArray name() const override; QString description() const override; @@ -159,7 +159,7 @@ private: class KalziumIconicSchemeType : public KalziumSchemeType { public: - static KalziumIconicSchemeType* instance(); + static KalziumIconicSchemeType *instance(); QByteArray name() const override; QString description() const override; @@ -181,7 +181,7 @@ private: class KalziumFamilySchemeType : public KalziumSchemeType { public: - static KalziumFamilySchemeType* instance(); + static KalziumFamilySchemeType *instance(); QByteArray name() const override; QString description() const override; @@ -203,7 +203,7 @@ private: class KalziumGroupsSchemeType : public KalziumSchemeType { public: - static KalziumGroupsSchemeType* instance(); + static KalziumGroupsSchemeType *instance(); QByteArray name() const override; QString description() const override; @@ -226,7 +226,7 @@ private: class KalziumColorSchemeType : public KalziumSchemeType { public: - static KalziumColorSchemeType* instance(); + static KalziumColorSchemeType *instance(); QByteArray name() const override; QString description() const override; @@ -241,46 +241,46 @@ private: }; #endif -//X /** -//X * The scheme for the crystal structures. -//X * -//X * @author Carsten Niehaus -//X */ -//X class KalziumCrystalSchemeType : public KalziumSchemeType -//X { -//X public: -//X static KalziumCrystalSchemeType* instance(); -//X -//X QByteArray name() const; -//X QString description() const; -//X -//X QBrush elementBrush(int el, const QRect& elrect) const; -//X QColor textColor(int el) const; -//X -//X QList legendItems() const; -//X -//X private: -//X KalziumCrystalSchemeType(); -//X }; - -//X /** -//X * @author Carsten Niehaus -//X */ -//X class KalziumDiscoverymapSchemeType : public KalziumSchemeType -//X { -//X public: -//X static KalziumDiscoverymapSchemeType* instance(); -//X -//X QByteArray name() const; -//X QString description() const; -//X -//X QBrush elementBrush(int el, const QRect& elrect) const; -//X QColor textColor(int el) const; -//X -//X QList legendItems() const; -//X -//X private: -//X KalziumDiscoverymapSchemeType(); -//X }; +// X /** +// X * The scheme for the crystal structures. +// X * +// X * @author Carsten Niehaus +// X */ +// X class KalziumCrystalSchemeType : public KalziumSchemeType +// X { +// X public: +// X static KalziumCrystalSchemeType* instance(); +// X +// X QByteArray name() const; +// X QString description() const; +// X +// X QBrush elementBrush(int el, const QRect& elrect) const; +// X QColor textColor(int el) const; +// X +// X QList legendItems() const; +// X +// X private: +// X KalziumCrystalSchemeType(); +// X }; + +// X /** +// X * @author Carsten Niehaus +// X */ +// X class KalziumDiscoverymapSchemeType : public KalziumSchemeType +// X { +// X public: +// X static KalziumDiscoverymapSchemeType* instance(); +// X +// X QByteArray name() const; +// X QString description() const; +// X +// X QBrush elementBrush(int el, const QRect& elrect) const; +// X QColor textColor(int el) const; +// X +// X QList legendItems() const; +// X +// X private: +// X KalziumDiscoverymapSchemeType(); +// X }; #endif // KALZIUMSCHEMETYPE_H diff --git a/src/kalziumunitcombobox.cpp b/src/kalziumunitcombobox.cpp index 2aeca5334e262216770b91734fc9383eb37bf891..868d43e39a9da6e4fc3d361676fe6c3b0ff03d31 100644 --- a/src/kalziumunitcombobox.cpp +++ b/src/kalziumunitcombobox.cpp @@ -8,17 +8,18 @@ #include "kalziumutils.h" -KalziumUnitCombobox::KalziumUnitCombobox(QWidget* parent): QComboBox(parent) +KalziumUnitCombobox::KalziumUnitCombobox(QWidget *parent) + : QComboBox(parent) { } -KalziumUnitCombobox::KalziumUnitCombobox(const QList< int > &unitList, QWidget* parent) +KalziumUnitCombobox::KalziumUnitCombobox(const QList &unitList, QWidget *parent) : QComboBox(parent) { setUnitList(unitList); } -void KalziumUnitCombobox::setUnitList(const QList< int >& unitList) +void KalziumUnitCombobox::setUnitList(const QList &unitList) { KalziumUtils::populateUnitCombobox(this, unitList); } diff --git a/src/kalziumunitcombobox.h b/src/kalziumunitcombobox.h index 8eb8fc108c25356dbdac8348932958b540a04613..9c57d1efb5f46ce61d4497101a7079a0819857e7 100644 --- a/src/kalziumunitcombobox.h +++ b/src/kalziumunitcombobox.h @@ -11,15 +11,13 @@ class KalziumUnitCombobox : public QComboBox { - public: explicit KalziumUnitCombobox(QWidget *parent = nullptr); - explicit KalziumUnitCombobox(const QList< int > &unitList, QWidget *parent = nullptr); + explicit KalziumUnitCombobox(const QList &unitList, QWidget *parent = nullptr); - void setUnitList(const QList< int > &unitList); + void setUnitList(const QList &unitList); int getCurrentUnitId() const; void setIndexWithUnitId(int unit); - }; #endif // KALZIUMUNITCOMBOBOX_H diff --git a/src/kalziumutils.cpp b/src/kalziumutils.cpp index 9a5388f91a26de017bd8011ba3a7ff6151d91bf4..d910744286789766b8f9207596f21df180181e59 100644 --- a/src/kalziumutils.cpp +++ b/src/kalziumutils.cpp @@ -24,7 +24,7 @@ #include #endif -int KalziumUtils::maxSize(const QString& string, const QRect& rect, QFont font, QPainter* p, int minFontSize, int maxFontSize) +int KalziumUtils::maxSize(const QString &string, const QRect &rect, QFont font, QPainter *p, int minFontSize, int maxFontSize) { bool goodSizeFound = false; int size = maxFontSize; @@ -41,19 +41,18 @@ int KalziumUtils::maxSize(const QString& string, const QRect& rect, QFont font, } else { --size; } - } - while (!goodSizeFound && (size > minFontSize)); + } while (!goodSizeFound && (size > minFontSize)); return size; } -int KalziumUtils::StringHeight(const QString& string, const QFont& font, QPainter* p) +int KalziumUtils::StringHeight(const QString &string, const QFont &font, QPainter *p) { Q_UNUSED(font); return p->boundingRect(QRect(), Qt::AlignTop | Qt::AlignLeft, string).height(); } -int KalziumUtils::StringWidth(const QString& string, const QFont& font, QPainter* p) +int KalziumUtils::StringWidth(const QString &string, const QFont &font, QPainter *p) { Q_UNUSED(font); return p->boundingRect(QRect(), Qt::AlignTop | Qt::AlignLeft, string).width(); @@ -77,14 +76,14 @@ double KalziumUtils::strippedValue(double num) return num * power / 10000; } -QString KalziumUtils::prettyUnit(const Element* el, ChemicalDataObject::BlueObelisk kind) +QString KalziumUtils::prettyUnit(const Element *el, ChemicalDataObject::BlueObelisk kind) { if (!el) { return i18n("Error"); } QString result; - double val = 0.0; //the value to convert + double val = 0.0; // the value to convert switch (kind) { case ChemicalDataObject::meltingpoint: // a temperature @@ -121,8 +120,7 @@ QString KalziumUtils::prettyUnit(const Element* el, ChemicalDataObject::BlueObel { int v_int = el->dataAsVariant(kind).toInt(); if (v_int > 1600) { - result = i18n("This element was discovered in the year %1.", - QString::number(v_int)); + result = i18n("This element was discovered in the year %1.", QString::number(v_int)); } else if (v_int == -1) { result = i18n("The element has not yet been officially recognized by the IUPAC."); } else { // this should now really be 0. If not there is a bug in the database @@ -131,13 +129,11 @@ QString KalziumUtils::prettyUnit(const Element* el, ChemicalDataObject::BlueObel break; } case ChemicalDataObject::radiusCovalent: - case ChemicalDataObject::radiusVDW: - { + case ChemicalDataObject::radiusVDW: { result = el->dataAsStringWithUnit(kind, Prefs::lengthUnit()); break; } - case ChemicalDataObject::electronicConfiguration: - { + case ChemicalDataObject::electronicConfiguration: { QString newOrbit = el->dataAsString(kind); QRegularExpression reg("(.*)([spdf])(\\d+)(.*)"); @@ -148,8 +144,7 @@ QString KalziumUtils::prettyUnit(const Element* el, ChemicalDataObject::BlueObel result = newOrbit; break; } - case ChemicalDataObject::oxidation: - { + case ChemicalDataObject::oxidation: { QStringList oxidationList = el->dataAsString(kind).split(','); result = oxidationList.join(QStringLiteral(", ")); break; @@ -164,7 +159,6 @@ QString KalziumUtils::prettyUnit(const Element* el, ChemicalDataObject::BlueObel return result; } - void KalziumUtils::populateUnitCombobox(QComboBox *comboBox, const QList &unitList) { comboBox->clear(); diff --git a/src/kalziumutils.h b/src/kalziumutils.h index 9147516064b4ff14d2a395179a994d6ef8c15ff1..eb196209b0e3c9f548f0779920bc5476b2ffd01e 100644 --- a/src/kalziumutils.h +++ b/src/kalziumutils.h @@ -12,8 +12,8 @@ class QFont; class QPainter; class Element; -#include #include +#include class KalziumUtils { @@ -26,8 +26,7 @@ public: * @param maxFontSize the maximum fontsize * @param minFontSize the maximum fontsize */ - static int maxSize(const QString &string, const QRect &rect, QFont font, QPainter *painter, - int minFontSize = 4, int maxFontSize = 20); + static int maxSize(const QString &string, const QRect &rect, QFont font, QPainter *painter, int minFontSize = 4, int maxFontSize = 20); /** * calculate the 4-digit value of the value @p w. For @@ -50,7 +49,7 @@ public: * @param painter the used painter * @return the height of the string @p string */ - static int StringHeight(const QString &string, const QFont& font, QPainter *painter); + static int StringHeight(const QString &string, const QFont &font, QPainter *painter); /** * An almost standard way to get an unit well converted for @@ -67,7 +66,6 @@ public: * @param unitList Unit list with enums of KUnitConversion */ static void populateUnitCombobox(QComboBox *comboBox, const QList &unitList); - }; #endif // KALZIUMUTILS_H diff --git a/src/kdeeduglossary.cpp b/src/kdeeduglossary.cpp index 83e5867345998c19999a0d2135bbb62c49df4f1f..58b571cae85e4ce096c1074783a04e97aa516194 100644 --- a/src/kdeeduglossary.cpp +++ b/src/kdeeduglossary.cpp @@ -12,13 +12,13 @@ #include #include -#include #include "kalzium_debug.h" #include #include #include #include #include +#include #include #include #include @@ -36,33 +36,34 @@ static const int GlossaryTreeItemType = QTreeWidgetItem::UserType + 1; class GlossaryTreeItem : public QTreeWidgetItem { - public: - GlossaryTreeItem(Glossary * g, GlossaryItem * gi) - : QTreeWidgetItem(GlossaryTreeItemType), m_g(g), m_gi(gi) - { - setText(0, m_gi->name()); - } +public: + GlossaryTreeItem(Glossary *g, GlossaryItem *gi) + : QTreeWidgetItem(GlossaryTreeItemType) + , m_g(g) + , m_gi(gi) + { + setText(0, m_gi->name()); + } - Glossary *glossary() const - { - return m_g; - } + Glossary *glossary() const + { + return m_g; + } - GlossaryItem *glossaryItem() const - { - return m_gi; - } + GlossaryItem *glossaryItem() const + { + return m_gi; + } - private: - Glossary *m_g; - GlossaryItem *m_gi; +private: + Glossary *m_g; + GlossaryItem *m_gi; }; - -struct GlossaryInfo -{ - GlossaryInfo(Glossary* g) - : glossary(g), folded(true) +struct GlossaryInfo { + GlossaryInfo(Glossary *g) + : glossary(g) + , folded(true) { } @@ -70,46 +71,45 @@ struct GlossaryInfo bool folded; }; - class GlossaryDialog::Private { - public: - Private(GlossaryDialog *qq) : q(qq) - { - } - - ~Private() - { - QList::ConstIterator it = m_glossaries.constBegin(); - QList::ConstIterator itEnd = m_glossaries.constEnd(); - for (; it != itEnd; ++it) { - delete (*it).glossary; - } +public: + Private(GlossaryDialog *qq) + : q(qq) + { + } - delete m_htmlpart; + ~Private() + { + QList::ConstIterator it = m_glossaries.constBegin(); + QList::ConstIterator itEnd = m_glossaries.constEnd(); + for (; it != itEnd; ++it) { + delete (*it).glossary; } - void rebuildTree(); - QTreeWidgetItem* createItem(const GlossaryInfo& gi) const; - QTreeWidgetItem* findTreeWithLetter(const QChar& l, QTreeWidgetItem* item) const; + delete m_htmlpart; + } - // slots - void itemActivated(QTreeWidgetItem * item, int column); + void rebuildTree(); + QTreeWidgetItem *createItem(const GlossaryInfo &gi) const; + QTreeWidgetItem *findTreeWithLetter(const QChar &l, QTreeWidgetItem *item) const; - GlossaryDialog *q; + // slots + void itemActivated(QTreeWidgetItem *item, int column); - QList< GlossaryInfo > m_glossaries; + GlossaryDialog *q; - QTextBrowser *m_htmlpart; - QTreeWidget *m_glosstree; - KTreeWidgetSearchLine *m_search; - QString m_htmlbasestring; + QList m_glossaries; - KActionCollection* m_actionCollection; -}; + QTextBrowser *m_htmlpart; + QTreeWidget *m_glosstree; + KTreeWidgetSearchLine *m_search; + QString m_htmlbasestring; + KActionCollection *m_actionCollection; +}; -Glossary::Glossary(const QUrl &url, const QString& path) +Glossary::Glossary(const QUrl &url, const QString &path) { init(url, path); } @@ -124,7 +124,7 @@ Glossary::~Glossary() qDeleteAll(m_itemlist); } -void Glossary::init(const QUrl &url, const QString& path) +void Glossary::init(const QUrl &url, const QString &path) { // setting a generic name for a new glossary m_name = i18n("Glossary"); @@ -172,7 +172,7 @@ bool Glossary::isEmpty() const return m_itemlist.count() == 0; } -void Glossary::setName(const QString& name) +void Glossary::setName(const QString &name) { if (name.isEmpty()) { return; @@ -180,7 +180,7 @@ void Glossary::setName(const QString& name) m_name = name; } -void Glossary::setPicturePath(const QString& path) +void Glossary::setPicturePath(const QString &path) { if (path.isEmpty()) { return; @@ -188,7 +188,7 @@ void Glossary::setPicturePath(const QString& path) m_picturepath = path; } -void Glossary::setBackgroundPicture(const QString& filename) +void Glossary::setBackgroundPicture(const QString &filename) { if (filename.isEmpty()) { return; @@ -201,18 +201,18 @@ void Glossary::fixImagePath() QString imgtag = ""; QRegularExpression exp("\\[img\\]([^[]+)\\[/img\\]"); - foreach (GlossaryItem * item, m_itemlist) { - QString tmp = item->desc(); - while (exp.match(tmp).hasMatch()) { - tmp = tmp.replace(exp, imgtag); - } - item->setDesc(tmp); - } + foreach (GlossaryItem *item, m_itemlist) { + QString tmp = item->desc(); + while (exp.match(tmp).hasMatch()) { + tmp = tmp.replace(exp, imgtag); + } + item->setDesc(tmp); + } } -QList Glossary::readItems(QDomDocument &itemDocument) +QList Glossary::readItems(QDomDocument &itemDocument) { - QList list; + QList list; QDomNodeList itemList; QDomNodeList refNodeList; @@ -254,8 +254,7 @@ QList Glossary::readItems(QDomDocument &itemDocument) item->setDesc(desc); refNodeList = refNode.elementsByTagName(QStringLiteral("refitem")); - for (int it = 0; it < refNodeList.count(); ++it) - { + for (int it = 0; it < refNodeList.count(); ++it) { reflist << i18n(refNodeList.item(it).toElement().text().toUtf8().constData()); } item->setRef(reflist); @@ -266,12 +265,12 @@ QList Glossary::readItems(QDomDocument &itemDocument) return list; } -void Glossary::addItem(GlossaryItem* item) +void Glossary::addItem(GlossaryItem *item) { m_itemlist.append(item); } -QList Glossary::itemlist()const +QList Glossary::itemlist() const { return m_itemlist; } @@ -281,33 +280,36 @@ void Glossary::clear() m_itemlist.clear(); } -QString Glossary::name()const +QString Glossary::name() const { return m_name; } -void Glossary::setItemlist(QList list) +void Glossary::setItemlist(QList list) { m_itemlist = list; } -QString Glossary::picturePath()const +QString Glossary::picturePath() const { return m_picturepath; } -QString Glossary::backgroundPicture()const +QString Glossary::backgroundPicture() const { return m_backgroundpicture; } -GlossaryDialog::GlossaryDialog(QWidget *parent) : QDialog(parent), d(new Private(this)) +GlossaryDialog::GlossaryDialog(QWidget *parent) + : QDialog(parent) + , d(new Private(this)) { setWindowTitle(i18nc("@title:window", "Glossary")); - //this string will be used for all items. If a backgroundpicture should - //be used call Glossary::setBackgroundPicture(). - d->m_htmlbasestring = QStringLiteral(""); + // this string will be used for all items. If a backgroundpicture should + // be used call Glossary::setBackgroundPicture(). + d->m_htmlbasestring = + QStringLiteral(""); QWidget *main = new QWidget(this); QVBoxLayout *vbox = new QVBoxLayout(main); @@ -336,23 +338,22 @@ GlossaryDialog::GlossaryDialog(QWidget *parent) : QDialog(parent), d(new Private d->m_htmlpart = new QTextBrowser(vs); d->m_htmlpart->setOpenLinks(false); - connect(d->m_glosstree, SIGNAL(itemActivated(QTreeWidgetItem*,int)), - this, SLOT(itemActivated(QTreeWidgetItem*,int))); - connect(d->m_htmlpart, &QTextBrowser::anchorClicked, this, [=](const QUrl &link){ + connect(d->m_glosstree, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this, SLOT(itemActivated(QTreeWidgetItem *, int))); + connect(d->m_htmlpart, &QTextBrowser::anchorClicked, this, [=](const QUrl &link) { // using the "path" part of a qurl as reference QString myurl = link.path().toLower(); QTreeWidgetItemIterator it(this->d->m_glosstree); while (*it) { if ((*it)->type() == GlossaryTreeItemType && (*it)->text(0).toLower() == myurl) { - // force the item to be selected - this->d->m_glosstree->setCurrentItem(*it); - // display its content - Q_EMIT this->d->itemActivated((*it), 0); - break; + // force the item to be selected + this->d->m_glosstree->setCurrentItem(*it); + // display its content + Q_EMIT this->d->itemActivated((*it), 0); + break; } else { ++it; } - } + } }); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); @@ -368,7 +369,7 @@ GlossaryDialog::~GlossaryDialog() delete d; } -void GlossaryDialog::keyPressEvent(QKeyEvent* e) +void GlossaryDialog::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Return) { e->ignore(); @@ -380,14 +381,14 @@ void GlossaryDialog::Private::rebuildTree() { m_glosstree->clear(); - QList< GlossaryInfo >::ConstIterator it = m_glossaries.constBegin(); - QList< GlossaryInfo >::ConstIterator itEnd = m_glossaries.constEnd(); + QList::ConstIterator it = m_glossaries.constBegin(); + QList::ConstIterator itEnd = m_glossaries.constEnd(); for (; it != itEnd; ++it) { m_glosstree->addTopLevelItem(createItem(*it)); } } -QTreeWidgetItem* GlossaryDialog::Private::createItem(const GlossaryInfo& gi) const +QTreeWidgetItem *GlossaryDialog::Private::createItem(const GlossaryInfo &gi) const { Glossary *glossary = gi.glossary; bool folded = gi.folded; @@ -408,12 +409,11 @@ QTreeWidgetItem* GlossaryDialog::Private::createItem(const GlossaryInfo& gi) con } else { main->addChild(new GlossaryTreeItem(glossary, item)); } - } return main; } -void GlossaryDialog::addGlossary(Glossary* newgloss, bool folded) +void GlossaryDialog::addGlossary(Glossary *newgloss, bool folded) { if (!newgloss || newgloss->isEmpty()) { return; @@ -427,7 +427,7 @@ void GlossaryDialog::addGlossary(Glossary* newgloss, bool folded) d->m_glosstree->sortItems(0, Qt::AscendingOrder); } -QTreeWidgetItem* GlossaryDialog::Private::findTreeWithLetter(const QChar& l, QTreeWidgetItem* item) const +QTreeWidgetItem *GlossaryDialog::Private::findTreeWithLetter(const QChar &l, QTreeWidgetItem *item) const { int count = item->childCount(); for (int i = 0; i < count; ++i) { @@ -439,7 +439,7 @@ QTreeWidgetItem* GlossaryDialog::Private::findTreeWithLetter(const QChar& l, QTr return nullptr; } -void GlossaryDialog::Private::itemActivated(QTreeWidgetItem * item, int column) +void GlossaryDialog::Private::itemActivated(QTreeWidgetItem *item, int column) { Q_UNUSED(column) if (!item || item->type() != GlossaryTreeItemType) { @@ -460,7 +460,7 @@ void GlossaryDialog::Private::itemActivated(QTreeWidgetItem * item, int column) m_htmlpart->setHtml(html); } -void GlossaryItem::setRef(const QStringList& s) +void GlossaryItem::setRef(const QStringList &s) { m_ref = s; m_ref.sort(); @@ -482,7 +482,7 @@ QString GlossaryItem::parseReferences() const QString htmlcode = "

" + i18n("References") + "

    "; static QString basehref = QStringLiteral("
  • %3
  • "); - foreach (const QString& ref, m_ref) { + foreach (const QString &ref, m_ref) { htmlcode += basehref.arg(QUrl::toPercentEncoding(ref), i18n("Go to '%1'", ref), ref); } htmlcode += QLatin1String("
"); @@ -490,17 +490,17 @@ QString GlossaryItem::parseReferences() const return htmlcode; } -void GlossaryItem::setName(const QString& s) +void GlossaryItem::setName(const QString &s) { m_name = s; } -void GlossaryItem::setDesc(const QString& s) +void GlossaryItem::setDesc(const QString &s) { m_desc = s; } -void GlossaryItem::setPictures(const QString& s) +void GlossaryItem::setPictures(const QString &s) { m_pic = QStringList(s); } diff --git a/src/kdeeduglossary.h b/src/kdeeduglossary.h index bb667c93734757e6e70a84b64995149df9ed3d41..8b739681418572186f5143bc8e5842bbe142674f 100644 --- a/src/kdeeduglossary.h +++ b/src/kdeeduglossary.h @@ -32,7 +32,7 @@ public: * @param url the path of the file to load * @param path the path of the pictures */ - explicit Glossary(const QUrl& url, const QString& path = QString()); + explicit Glossary(const QUrl &url, const QString &path = QString()); /** * Creates a new empty glossary @@ -44,9 +44,9 @@ public: /** * add the item @p item to the glossary */ - void addItem(GlossaryItem* item); + void addItem(GlossaryItem *item); - QList itemlist()const; + QList itemlist() const; /** * clear the Glossary @@ -62,42 +62,42 @@ public: * Every glossary can have a name. It will be * set to @p name */ - void setName(const QString& name); + void setName(const QString &name); /** * @returns the name of the glossary */ - QString name()const; + QString name() const; /** * sets the internal list of items to @p list */ - void setItemlist(QList list); + void setItemlist(QList list); /** * Every glossaryitem can show pictures. [img src="foo.png] * will look for the file foo.png in the path defined by * @p path */ - void setPicturePath(const QString& path); + void setPicturePath(const QString &path); - QString picturePath()const; + QString picturePath() const; /** * defines which picture to use as the background * of the htmlview. The dialog * will use the file specific by the @p filename */ - void setBackgroundPicture(const QString& filename); + void setBackgroundPicture(const QString &filename); /** * @return the picture used as the background in * this background */ - QString backgroundPicture()const; + QString backgroundPicture() const; protected: - void init(const QUrl& url, const QString& path); + void init(const QUrl &url, const QString &path); private: /** @@ -105,7 +105,7 @@ private: * the information of the items and return them as a * QList */ - virtual QList readItems(QDomDocument &itemDocument); + virtual QList readItems(QDomDocument &itemDocument); QString m_backgroundpicture; @@ -130,9 +130,9 @@ private: * @return a bool indicating whether the loading of the XML was * successful or not */ - bool loadLayout(QDomDocument& doc, const QUrl& url); + bool loadLayout(QDomDocument &doc, const QUrl &url); - QList m_itemlist; + QList m_itemlist; /** * the name of the glossary @@ -152,12 +152,16 @@ private: class GlossaryItem { public: - GlossaryItem() {} - ~GlossaryItem() {} + GlossaryItem() + { + } + ~GlossaryItem() + { + } - void setName(const QString& s); + void setName(const QString &s); - void setDesc(const QString& s); + void setDesc(const QString &s); /** * Set the references for the current GlossaryItem to @@ -165,9 +169,9 @@ public: * There's no need to sort the list before, as they * will be sorted automatically */ - void setRef(const QStringList& s); + void setRef(const QStringList &s); - void setPictures(const QString& s); + void setPictures(const QString &s); QString name() const; @@ -221,14 +225,14 @@ public: * @param folded whether to fold the various items in subtrees depending on the * first letter of every item */ - void addGlossary(Glossary* newgloss, bool folded = true); + void addGlossary(Glossary *newgloss, bool folded = true); protected: - void keyPressEvent(QKeyEvent*) override; + void keyPressEvent(QKeyEvent *) override; private: class Private; - Private * const d; + Private *const d; Q_PRIVATE_SLOT(d, void itemActivated(QTreeWidgetItem *, int)) }; diff --git a/src/legendwidget.cpp b/src/legendwidget.cpp index 480d681df0bb83029ed6a3e14953d54acad097ad..8f8e6bb2b5ac246b2cd7050d14793d327d81d73d 100644 --- a/src/legendwidget.cpp +++ b/src/legendwidget.cpp @@ -14,7 +14,8 @@ #include -LegendWidget::LegendWidget(QWidget *parent) : QWidget(parent) +LegendWidget::LegendWidget(QWidget *parent) + : QWidget(parent) { m_update = true; m_dockArea = Qt::BottomDockWidgetArea; @@ -50,7 +51,7 @@ void LegendWidget::updateContent() } QString gradientDesc; - QList< QPair > items; + QList> items; KalziumElementProperty *elementProperty = KalziumElementProperty::instance(); // Handle different Gradients switch (elementProperty->gradientId()) { @@ -59,17 +60,13 @@ void LegendWidget::updateContent() case KalziumElementProperty::SOMGradientType: items << qMakePair(elementProperty->gradient()->description(), QColor()); - items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", - "Solid"), QColor(Prefs::color_solid())); + items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", "Solid"), QColor(Prefs::color_solid())); - items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", - "Liquid"), QColor(Prefs::color_liquid())); + items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", "Liquid"), QColor(Prefs::color_liquid())); - items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", - "Vaporous"), QColor(Prefs::color_vapor())); + items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", "Vaporous"), QColor(Prefs::color_vapor())); - items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", - "Unknown"), QColor(Qt::lightGray)); + items << qMakePair(i18nc("one of the three states of matter (solid, liquid, vaporous or unknown)", "Unknown"), QColor(Qt::lightGray)); break; default: @@ -80,12 +77,14 @@ void LegendWidget::updateContent() } items << qMakePair(i18n("%1 (%2)", elementProperty->gradient()->description(), gradientDesc), QColor()); items << qMakePair(i18nc("Minimum value of the gradient", - "Minimum: %1", QString::number(elementProperty->gradient()->minValue()) + ' ' + elementProperty->gradient()->unit()), - QColor(elementProperty->gradient()->firstColor())); + "Minimum: %1", + QString::number(elementProperty->gradient()->minValue()) + ' ' + elementProperty->gradient()->unit()), + QColor(elementProperty->gradient()->firstColor())); items << qMakePair(i18nc("Maximum value of the gradient", - "Maximum: %1", QString::number(elementProperty->gradient()->maxValue()) + ' ' + elementProperty->gradient()->unit()), - QColor(elementProperty->gradient()->secondColor())); + "Maximum: %1", + QString::number(elementProperty->gradient()->maxValue()) + ' ' + elementProperty->gradient()->unit()), + QColor(elementProperty->gradient()->secondColor())); break; } // schemes are always there @@ -93,21 +92,20 @@ void LegendWidget::updateContent() items << elementProperty->scheme()->legendItems(); updateLegendItemLayout(items); - } -void LegendWidget::updateLegendItemLayout(const QList& list) +void LegendWidget::updateLegendItemLayout(const QList &list) { if (layout()) { delete layout(); } - foreach (LegendItem * i, m_legendItemList) { + foreach (LegendItem *i, m_legendItemList) { delete i; } m_legendItemList.clear(); - QGridLayout * layout = new QGridLayout(this); + QGridLayout *layout = new QGridLayout(this); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); @@ -149,32 +147,30 @@ void LegendWidget::legendItemAction(QColor color) } } -bool LegendWidget::isElementMatch(int element, QColor &color){ +bool LegendWidget::isElementMatch(int element, QColor &color) +{ QColor elementBackgroundColor; QColor elementBorderColor; elementBackgroundColor = KalziumElementProperty::instance()->getElementColor(element); elementBorderColor = KalziumElementProperty::instance()->getBorderColor(element); - switch(Prefs::colorgradientbox()){ - - case KalziumElementProperty::NOGRADIENT: + switch (Prefs::colorgradientbox()) { + case KalziumElementProperty::NOGRADIENT: if (elementBackgroundColor.operator!=(color)) { return true; } break; - default: // all other gradients - if (elementBorderColor.operator==(color) || - elementBackgroundColor.operator==(color)) { + default: // all other gradients + if (elementBorderColor.operator==(color) || elementBackgroundColor.operator==(color)) { return true; } } return false; } - -LegendItem::LegendItem(const QPair& pair, LegendWidget * parent) +LegendItem::LegendItem(const QPair &pair, LegendWidget *parent) { QHBoxLayout *ItemLayout = new QHBoxLayout(this); ItemLayout->setContentsMargins(0, 0, 0, 0); @@ -188,14 +184,14 @@ LegendItem::LegendItem(const QPair& pair, LegendWidget * parent QPixmap LegendPixmap(20, height()); LegendPixmap.fill(pair.second); - QLabel * LabelPixmap = new QLabel(this); + QLabel *LabelPixmap = new QLabel(this); LabelPixmap->setPixmap(LegendPixmap); ItemLayout->addWidget(LabelPixmap); setFrameShape(QFrame::StyledPanel); setFrameShadow(QFrame::Sunken); } - QLabel * LegendLabel = new QLabel(this); + QLabel *LegendLabel = new QLabel(this); LegendLabel->setText(pair.first); ItemLayout->addWidget(LegendLabel); @@ -203,15 +199,14 @@ LegendItem::LegendItem(const QPair& pair, LegendWidget * parent setLayout(ItemLayout); } -void LegendItem::enterEvent(QEvent* event) +void LegendItem::enterEvent(QEvent *event) { Q_EMIT legenItemHoovered(legendItemColor); QWidget::enterEvent(event); } -void LegendItem::leaveEvent(QEvent* event) +void LegendItem::leaveEvent(QEvent *event) { Q_EMIT legenItemHoovered(QColor()); QWidget::leaveEvent(event); } - diff --git a/src/legendwidget.h b/src/legendwidget.h index 76d540047dde968e3708caf6e43dc7f229994e17..44aa3ecf5004630d469183a201a891ac6bc85992 100644 --- a/src/legendwidget.h +++ b/src/legendwidget.h @@ -50,11 +50,11 @@ private: QPixmap m_pixmap; - QList m_legendItemList; + QList m_legendItemList; Qt::DockWidgetArea m_dockArea; - void updateLegendItemLayout(const QList& list); + void updateLegendItemLayout(const QList &list); }; /** @@ -68,8 +68,10 @@ class LegendItem : public QLabel Q_OBJECT public: - LegendItem(const QPair& pair, LegendWidget * parent = nullptr); - ~LegendItem() {} + LegendItem(const QPair &pair, LegendWidget *parent = nullptr); + ~LegendItem() + { + } Q_SIGNALS: void legenItemHoovered(QColor color); @@ -78,9 +80,8 @@ private: QColor legendItemColor; protected: - void enterEvent(QEvent * event) override; - void leaveEvent(QEvent * event) override; - + void enterEvent(QEvent *event) override; + void leaveEvent(QEvent *event) override; }; #endif // LEGENDWIDGET_H diff --git a/src/main.cpp b/src/main.cpp index 0706f8634eed536060f10193482bbd2a5c9df3e8..dc9b3c5cfd9932646f82345574166694354b692c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,14 +18,14 @@ #ifdef HAVE_FACILE extern "C" { - void caml_startup(char**); +void caml_startup(char **); } #endif int main(int argc, char **argv) { #ifdef HAVE_FACILE - caml_startup(argv); + caml_startup(argv); #endif #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); @@ -35,85 +35,59 @@ int main(int argc, char **argv) KLocalizedString::setApplicationDomain("kalzium"); KAboutData about(QStringLiteral("kalzium"), - i18n("Kalzium"), - QStringLiteral(KALZIUM_VERSION_STRING), - i18n("A periodic table of the elements"), - KAboutLicense::GPL, - i18n("(C) 2002-2016 Carsten Niehaus & the KDE Edu Developers"), - QString(), - QStringLiteral("https://edu.kde.org/kalzium")); + i18n("Kalzium"), + QStringLiteral(KALZIUM_VERSION_STRING), + i18n("A periodic table of the elements"), + KAboutLicense::GPL, + i18n("(C) 2002-2016 Carsten Niehaus & the KDE Edu Developers"), + QString(), + QStringLiteral("https://edu.kde.org/kalzium")); - about.addAuthor(i18n("Carsten Niehaus"), - QString(), - QStringLiteral("cniehaus@kde.org")); + about.addAuthor(i18n("Carsten Niehaus"), QString(), QStringLiteral("cniehaus@kde.org")); + about.addCredit(i18n("Pino Toscano"), i18n("Large code contributions; resident guru helping the other developers")); - about.addCredit(i18n("Pino Toscano"), - i18n("Large code contributions; resident guru helping the other developers")); + about.addCredit(i18n("Benoit Jacob"), i18n("Base work on the molecular viewer, mentored Marcus during his SoC")); - about.addCredit(i18n("Benoit Jacob"), - i18n("Base work on the molecular viewer, mentored Marcus during his SoC")); + about.addCredit(i18n("Marcus Hanwell"), i18n("SoC on the molecular viewer and libavogadro porting/integration")); - about.addCredit(i18n("Marcus Hanwell"), - i18n("SoC on the molecular viewer and libavogadro porting/integration")); + about.addCredit(i18n("Kashyap R Puranik"), i18n("SoC on the calculator widget and a few smaller improvements")); - about.addCredit(i18n("Kashyap R Puranik"), - i18n("SoC on the calculator widget and a few smaller improvements")); + about.addCredit(i18n("Thomas Nagy"), i18n("EqChem, the equation solver")); - about.addCredit(i18n("Thomas Nagy"), - i18n("EqChem, the equation solver")); + about.addCredit(i18n("Inge Wallin"), i18n("Code cleaning, parser for the molecule weight calculator, and a lot of smaller improvements")); - about.addCredit(i18n("Inge Wallin"), - i18n("Code cleaning, parser for the molecule weight calculator, and a lot of smaller improvements")); + about.addCredit(i18n("Anne-Marie Mahfouf"), i18n("A lot of small things and the documentation")); - about.addCredit(i18n("Anne-Marie Mahfouf"), - i18n("A lot of small things and the documentation")); + about.addCredit(i18n("Johannes Simon"), i18n("Code and documentation contributions to the equation solver and molecular viewer")); - about.addCredit(i18n("Johannes Simon"), - i18n("Code and documentation contributions to the equation solver and molecular viewer")); + about.addCredit(i18n("Jarle Akselsen"), i18n("Many beautiful element icons")); - about.addCredit(i18n("Jarle Akselsen"), - i18n("Many beautiful element icons")); + about.addCredit(i18n("Noémie Scherer"), i18n("Many beautiful element icons, too!")); - about.addCredit(i18n("Noémie Scherer"), - i18n("Many beautiful element icons, too!")); + about.addCredit(i18n("Danny Allen"), i18n("Several icons")); - about.addCredit(i18n("Danny Allen"), - i18n("Several icons")); + about.addCredit(i18n("Lee Olson"), i18n("Several icons in the information dialog")); - about.addCredit(i18n("Lee Olson"), - i18n("Several icons in the information dialog")); + about.addCredit(i18n("Jörg Buchwald"), i18n("Contributed most isotope information")); - about.addCredit(i18n("Jörg Buchwald"), - i18n("Contributed most isotope information")); + about.addCredit(i18n("Marco Martin"), i18n("Some icons and inspiration for others")); - about.addCredit(i18n("Marco Martin"), - i18n("Some icons and inspiration for others")); + about.addCredit(i18n("Daniel Haas"), i18n("The design of the information dialog")); - about.addCredit(i18n("Daniel Haas"), - i18n("The design of the information dialog")); + about.addCredit(i18n("Brian Beck"), i18n("The orbits icon")); - about.addCredit(i18n("Brian Beck"), - i18n("The orbits icon")); + about.addCredit(i18n("Paulo Cattai"), i18n("New interface design and usability improvements")); - about.addCredit(i18n("Paulo Cattai"), - i18n("New interface design and usability improvements")); + about.addCredit(i18n("Danilo Balzaque"), i18n("New interface design and usability improvements")); - about.addCredit(i18n("Danilo Balzaque"), - i18n("New interface design and usability improvements")); + about.addCredit(i18n("Roberto Cunha"), i18n("New interface design and usability improvements")); - about.addCredit(i18n("Roberto Cunha"), - i18n("New interface design and usability improvements")); + about.addCredit(i18n("Tadeu Araujo"), i18n("New interface design and usability improvements")); - about.addCredit(i18n("Tadeu Araujo"), - i18n("New interface design and usability improvements")); - - about.addCredit(i18n("Tiago Porangaba"), - i18n("New interface design and usability improvements")); - - about.addCredit(i18n("Etienne Rebetez"), - i18n("Adding new sizable Periodic System")); + about.addCredit(i18n("Tiago Porangaba"), i18n("New interface design and usability improvements")); + about.addCredit(i18n("Etienne Rebetez"), i18n("Adding new sizable Periodic System")); QApplication::setApplicationName(QStringLiteral("kalzium")); QApplication::setApplicationVersion(KALZIUM_VERSION_STRING); @@ -132,9 +106,10 @@ int main(int argc, char **argv) parser.process(app); about.processCommandLine(&parser); - #if defined(HAVE_OPENBABEL) && defined(HAVE_EIGEN) && defined(HAVE_AVOGADRO) - parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("m") << QStringLiteral("molecule"), i18n("Open the given molecule file"), QStringLiteral("file"))); - #endif +#if defined(HAVE_OPENBABEL) && defined(HAVE_EIGEN) && defined(HAVE_AVOGADRO) + parser.addOption( + QCommandLineOption(QStringList() << QStringLiteral("m") << QStringLiteral("molecule"), i18n("Open the given molecule file"), QStringLiteral("file"))); +#endif Kalzium *mainWin = nullptr; @@ -155,7 +130,6 @@ int main(int argc, char **argv) QTextStream ts(stderr); ts << i18n("Can't open more than one molecule at a time"); } - } // mainWin has WDestructiveClose flag by default, so it will delete itself. diff --git a/src/molcalcwidget.cpp b/src/molcalcwidget.cpp index 993181507e0a9da8e79cb4b4e9b647561a4bc695..0402686d342ed63c59abbe821badfa825910177f 100644 --- a/src/molcalcwidget.cpp +++ b/src/molcalcwidget.cpp @@ -8,13 +8,13 @@ #include "molcalcwidget.h" -//libscience +// libscience #include #include "kalziumdataobject.h" #include "kalziumutils.h" -#include "search.h" #include "prefs.h" +#include "search.h" #include "kalzium_debug.h" #include @@ -26,7 +26,8 @@ #include -MolcalcWidget::MolcalcWidget(QWidget *parent) : QWidget(parent) +MolcalcWidget::MolcalcWidget(QWidget *parent) + : QWidget(parent) { m_parser = new MoleculeParser(KalziumDataObject::instance()->ElementList); @@ -52,9 +53,9 @@ MolcalcWidget::MolcalcWidget(QWidget *parent) : QWidget(parent) if (Prefs::addAlias()) { connect(ui.alias, &QAbstractButton::clicked, this, &MolcalcWidget::addAlias); - QString shortForm, fullForm; // short form (symbol) and full form (expansion) + QString shortForm, fullForm; // short form (symbol) and full form (expansion) QList shortList, fullList; // Used to store the short and full forms - int i = 0; // loop counter + int i = 0; // loop counter // Search in User defined aliases. QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libkdeedu/data/symbols2.csv")); @@ -71,7 +72,7 @@ MolcalcWidget::MolcalcWidget(QWidget *parent) : QWidget(parent) QString line = in.readLine(); shortForm = line.section(',', 0, 0); shortForm.remove(QChar('\"')); - fullForm = line.section(',', 1, 1); + fullForm = line.section(',', 1, 1); fullForm.remove(QChar('\"')); shortList << shortForm; fullList << fullForm; @@ -81,10 +82,9 @@ MolcalcWidget::MolcalcWidget(QWidget *parent) : QWidget(parent) ui.user_defined->setRowCount(length); // Put all the aliases on to the table in the user interface for (i = 0; i < length; ++i) { - shortForm = shortList.takeFirst (); - fullForm = fullList.takeFirst (); - ui.user_defined->setItem((int)i, 0, new QTableWidgetItem - (i18n("%1",shortForm + " : " + fullForm))); + shortForm = shortList.takeFirst(); + fullForm = fullList.takeFirst(); + ui.user_defined->setItem((int)i, 0, new QTableWidgetItem(i18n("%1", shortForm + " : " + fullForm))); } } else { qCDebug(KALZIUM_LOG) << fileName << " could not be opened!"; @@ -107,7 +107,7 @@ MolcalcWidget::MolcalcWidget(QWidget *parent) : QWidget(parent) QString line = in.readLine(); shortForm = line.section(',', 0, 0); shortForm.remove(QChar('\"')); - fullForm = line.section(',', 1, 1); + fullForm = line.section(',', 1, 1); fullForm.remove(QChar('\"')); shortList << shortForm; fullList << fullForm; @@ -119,8 +119,7 @@ MolcalcWidget::MolcalcWidget(QWidget *parent) : QWidget(parent) for (i = 0; i < length; ++i) { shortForm = shortList.takeFirst(); fullForm = fullList.takeFirst(); - ui.pre_defined->setItem((int)i, 0, new QTableWidgetItem - (i18n("%1",shortForm + " : " + fullForm))); + ui.pre_defined->setItem((int)i, 0, new QTableWidgetItem(i18n("%1", shortForm + " : " + fullForm))); } } else { qCDebug(KALZIUM_LOG) << fileName << " could not be opened!"; @@ -133,14 +132,13 @@ MolcalcWidget::~MolcalcWidget() delete m_parser; } - void MolcalcWidget::clear() { // Clear the data. m_mass = 0; m_elementMap.clear(); - //stop the selection in the periodic table + // stop the selection in the periodic table KalziumDataObject::instance()->search()->resetSearch(); // Clear the widgets. @@ -176,16 +174,11 @@ void MolcalcWidget::updateUI() // Update the resultLabel mass = count->element()->dataAsVariant(ChemicalDataObject::mass).toDouble(); - ui.table->setItem(i, 0, new QTableWidgetItem - (i18n("%1", count->element()->dataAsString(ChemicalDataObject::name)))); - ui.table->setItem(i, 1, new QTableWidgetItem - (i18n("%1", count->count()))); - ui.table->setItem(i, 2, new QTableWidgetItem - (i18n("%1", count->element()->dataAsString(ChemicalDataObject::mass)))); - ui.table->setItem(i, 3, new QTableWidgetItem - (i18n("%1", mass * count->count()))); - ui.table->setItem(i, 4, new QTableWidgetItem - (i18n("%1", mass * count->count()/ m_mass *100))); + ui.table->setItem(i, 0, new QTableWidgetItem(i18n("%1", count->element()->dataAsString(ChemicalDataObject::name)))); + ui.table->setItem(i, 1, new QTableWidgetItem(i18n("%1", count->count()))); + ui.table->setItem(i, 2, new QTableWidgetItem(i18n("%1", count->element()->dataAsString(ChemicalDataObject::mass)))); + ui.table->setItem(i, 3, new QTableWidgetItem(i18n("%1", mass * count->count()))); + ui.table->setItem(i, 4, new QTableWidgetItem(i18n("%1", mass * count->count() / m_mass * 100))); ++i; } @@ -215,7 +208,7 @@ void MolcalcWidget::updateUI() QList list = m_elementMap.elements(); KalziumDataObject::instance()->findElements(list); #endif - } else { //the input was invalid, so tell this the user + } else { // the input was invalid, so tell this the user qCDebug(KALZIUM_LOG) << "m_validInput == false"; ui.resultComposition->setText(i18n("Invalid input")); ui.resultLabel->setText(QString()); @@ -231,10 +224,8 @@ QString MolcalcWidget::compositionString(ElementCountMap &_map) { QString str; - foreach (ElementCount * count, _map.map()) { - str += i18n("%1%2 ", - count->element()->dataAsString(ChemicalDataObject::symbol), - count->count()); + foreach (ElementCount *count, _map.map()) { + str += i18n("%1%2 ", count->element()->dataAsString(ChemicalDataObject::symbol), count->count()); } return str; @@ -246,13 +237,13 @@ QString MolcalcWidget::compositionString(ElementCountMap &_map) void MolcalcWidget::slotCalculate() { qCDebug(KALZIUM_LOG) << "MolcalcWidget::slotCalcButtonClicked()"; - QString molecule = ui.formulaEdit->text(); + QString molecule = ui.formulaEdit->text(); // Parse the molecule, and at the same time calculate the total // mass, and the composition of it. if (!molecule.isEmpty()) { - m_validInput = m_parser->weight(molecule, &m_mass, &m_elementMap); - m_aliasList = m_parser->aliasList(); + m_validInput = m_parser->weight(molecule, &m_mass, &m_elementMap); + m_aliasList = m_parser->aliasList(); } qCDebug(KALZIUM_LOG) << "done calculating."; @@ -267,7 +258,7 @@ void MolcalcWidget::keyPressEvent(QKeyEvent * /* e */) void MolcalcWidget::addAlias() { QString shortForm = ui.shortForm->text(); - QString fullForm = ui.fullForm ->text(); + QString fullForm = ui.fullForm->text(); // Validate the alias double x; @@ -275,20 +266,17 @@ void MolcalcWidget::addAlias() ui.aliasMessage->setText(QLatin1String("")); if (shortForm.length() < 2) { - ui.aliasMessage->setText(i18n - ("Symbol should consist of two or more letters.")); + ui.aliasMessage->setText(i18n("Symbol should consist of two or more letters.")); return; } if (m_parser->weight(shortForm, &x, &y)) { - ui.aliasMessage->setText(i18n - ("Symbol already being used")); + ui.aliasMessage->setText(i18n("Symbol already being used")); return; } - if (fullForm.isEmpty() || ! m_parser->weight(fullForm, & x, & y)) { - ui.aliasMessage->setText(i18n - ("Expansion is invalid, please specify a valid expansion")); + if (fullForm.isEmpty() || !m_parser->weight(fullForm, &x, &y)) { + ui.aliasMessage->setText(i18n("Expansion is invalid, please specify a valid expansion")); return; } @@ -296,7 +284,7 @@ void MolcalcWidget::addAlias() QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libkdeedu/data/symbols2.csv")); QFile file(fileName); - if (!(!file.open(QIODevice::WriteOnly| QIODevice::Append | QIODevice::Text))) { + if (!(!file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))) { QTextStream out(&file); out << "\"" + shortForm + "\",\"" + fullForm + "\"\n"; qCDebug(KALZIUM_LOG) << fileName << "is the file."; @@ -304,8 +292,7 @@ void MolcalcWidget::addAlias() ui.aliasMessage->setText(i18n("done!")); return; } else { - ui.aliasMessage->setText((i18n - ("Unable to find the user defined alias file."))+fileName); + ui.aliasMessage->setText((i18n("Unable to find the user defined alias file.")) + fileName); return; } } diff --git a/src/molcalcwidget.h b/src/molcalcwidget.h index 40f7e7d13afeb7665074f8ccf4a5f2f3f4ea08fa..d90e37108281693d7e1a8c98fb89ae2104f92960 100644 --- a/src/molcalcwidget.h +++ b/src/molcalcwidget.h @@ -7,8 +7,8 @@ #ifndef MOLCALCWIDGET_H #define MOLCALCWIDGET_H -#include #include "ui_molcalcwidgetbase.h" +#include #include "moleculeparser.h" @@ -60,14 +60,14 @@ private: Ui_MolcalcWidgetBase ui; - QTimer * m_timer; + QTimer *m_timer; private: - MoleculeParser *m_parser; - QSet m_aliasList; - double m_mass; - bool m_validInput; - ElementCountMap m_elementMap; + MoleculeParser *m_parser; + QSet m_aliasList; + double m_mass; + bool m_validInput; + ElementCountMap m_elementMap; }; #endif // MOLCALCWIDGET_H diff --git a/src/orbitswidget.cpp b/src/orbitswidget.cpp index 29958877e88cc70cc131919c7cd7f45684014ec1..fe2fd0a2c51ccc08463a47f49e34fd9f757136c6 100644 --- a/src/orbitswidget.cpp +++ b/src/orbitswidget.cpp @@ -5,10 +5,10 @@ #include "orbitswidget.h" -#include "kalziumutils.h" #include "kalziumdataobject.h" +#include "kalziumutils.h" -//QT-Includes +// QT-Includes #include #include #include @@ -43,7 +43,8 @@ inline static double translateToDY(double r, double angle, int num) return r * cos(t); } -OrbitsWidget::OrbitsWidget(QWidget *parent) : QWidget(parent) +OrbitsWidget::OrbitsWidget(QWidget *parent) + : QWidget(parent) { m_electronConf = new QLabel(this); m_electronConf->setIndent(20); @@ -52,7 +53,7 @@ OrbitsWidget::OrbitsWidget(QWidget *parent) : QWidget(parent) if (hulllist.count() == 0) { hulllist.append(QStringLiteral("1")); - hulllist.append(QStringLiteral("2")); //Helium + hulllist.append(QStringLiteral("2")); // Helium hulllist.append(QStringLiteral("2 1")); hulllist.append(QStringLiteral("2 2")); hulllist.append(QStringLiteral("2 3")); @@ -60,7 +61,7 @@ OrbitsWidget::OrbitsWidget(QWidget *parent) : QWidget(parent) hulllist.append(QStringLiteral("2 5")); hulllist.append(QStringLiteral("2 6")); hulllist.append(QStringLiteral("2 7")); - hulllist.append(QStringLiteral("2 8")); //Neon + hulllist.append(QStringLiteral("2 8")); // Neon hulllist.append(QStringLiteral("2 8 1")); hulllist.append(QStringLiteral("2 8 2")); hulllist.append(QStringLiteral("2 8 3")); @@ -68,100 +69,100 @@ OrbitsWidget::OrbitsWidget(QWidget *parent) : QWidget(parent) hulllist.append(QStringLiteral("2 8 5")); hulllist.append(QStringLiteral("2 8 6")); hulllist.append(QStringLiteral("2 8 7")); - hulllist.append(QStringLiteral("2 8 8")); //Argon + hulllist.append(QStringLiteral("2 8 8")); // Argon hulllist.append(QStringLiteral("2 8 8 1")); - hulllist.append(QStringLiteral("2 8 8 2"));//Calcium + hulllist.append(QStringLiteral("2 8 8 2")); // Calcium hulllist.append(QStringLiteral("2 8 9 2")); hulllist.append(QStringLiteral("2 8 10 2")); hulllist.append(QStringLiteral("2 8 11 2")); hulllist.append(QStringLiteral("2 8 13 1")); - hulllist.append(QStringLiteral("2 8 13 2"));//Manganese + hulllist.append(QStringLiteral("2 8 13 2")); // Manganese hulllist.append(QStringLiteral("2 8 14 2")); hulllist.append(QStringLiteral("2 8 15 2")); hulllist.append(QStringLiteral("2 8 16 2")); - hulllist.append(QStringLiteral("2 8 18 1"));//Copper + hulllist.append(QStringLiteral("2 8 18 1")); // Copper hulllist.append(QStringLiteral("2 8 18 2")); hulllist.append(QStringLiteral("2 8 18 3")); hulllist.append(QStringLiteral("2 8 18 4")); hulllist.append(QStringLiteral("2 8 18 5")); hulllist.append(QStringLiteral("2 8 18 6")); hulllist.append(QStringLiteral("2 8 18 7")); - hulllist.append(QStringLiteral("2 8 18 8"));//Krypton + hulllist.append(QStringLiteral("2 8 18 8")); // Krypton hulllist.append(QStringLiteral("2 8 18 8 1")); - hulllist.append(QStringLiteral("2 8 18 8 2"));//Rubidium + hulllist.append(QStringLiteral("2 8 18 8 2")); // Rubidium hulllist.append(QStringLiteral("2 8 18 9 2")); - hulllist.append(QStringLiteral("2 8 18 10 2"));//Zirconium + hulllist.append(QStringLiteral("2 8 18 10 2")); // Zirconium hulllist.append(QStringLiteral("2 8 18 12 1")); hulllist.append(QStringLiteral("2 8 18 13 1")); - hulllist.append(QStringLiteral("2 8 18 14 1"));//Techneticum + hulllist.append(QStringLiteral("2 8 18 14 1")); // Techneticum hulllist.append(QStringLiteral("2 8 18 15 1")); hulllist.append(QStringLiteral("2 8 18 16 1")); - hulllist.append(QStringLiteral("2 8 18 18")); //Palladium + hulllist.append(QStringLiteral("2 8 18 18")); // Palladium hulllist.append(QStringLiteral("2 8 18 18 1")); hulllist.append(QStringLiteral("2 8 18 18 2")); - hulllist.append(QStringLiteral("2 8 18 18 3"));//Indium + hulllist.append(QStringLiteral("2 8 18 18 3")); // Indium hulllist.append(QStringLiteral("2 8 18 18 4")); hulllist.append(QStringLiteral("2 8 18 18 5")); hulllist.append(QStringLiteral("2 8 18 18 6")); hulllist.append(QStringLiteral("2 8 18 18 7")); - hulllist.append(QStringLiteral("2 8 18 18 8"));//Xenon - hulllist.append(QStringLiteral("2 8 18 18 8 1"));//Caesium - hulllist.append(QStringLiteral("2 8 18 18 8 2"));//Barium + hulllist.append(QStringLiteral("2 8 18 18 8")); // Xenon + hulllist.append(QStringLiteral("2 8 18 18 8 1")); // Caesium + hulllist.append(QStringLiteral("2 8 18 18 8 2")); // Barium hulllist.append(QStringLiteral("2 8 18 18 9 2")); - hulllist.append(QStringLiteral("2 8 18 20 8 2"));//Cerium + hulllist.append(QStringLiteral("2 8 18 20 8 2")); // Cerium hulllist.append(QStringLiteral("2 8 18 21 8 2")); hulllist.append(QStringLiteral("2 8 18 22 8 2")); hulllist.append(QStringLiteral("2 8 18 23 8 2")); hulllist.append(QStringLiteral("2 8 18 24 8 2")); hulllist.append(QStringLiteral("2 8 18 25 8 2")); - hulllist.append(QStringLiteral("2 8 18 25 9 2"));//Gadolinium - hulllist.append(QStringLiteral("2 8 18 27 8 2"));//Terbium + hulllist.append(QStringLiteral("2 8 18 25 9 2")); // Gadolinium + hulllist.append(QStringLiteral("2 8 18 27 8 2")); // Terbium hulllist.append(QStringLiteral("2 8 18 28 8 2")); hulllist.append(QStringLiteral("2 8 18 29 8 2")); hulllist.append(QStringLiteral("2 8 18 30 8 2")); hulllist.append(QStringLiteral("2 8 18 31 8 2")); - hulllist.append(QStringLiteral("2 8 18 32 8 2"));//Ytterbium - hulllist.append(QStringLiteral("2 8 18 32 9 2"));//Lutetium - hulllist.append(QStringLiteral("2 8 18 32 10 2"));//Hafnium + hulllist.append(QStringLiteral("2 8 18 32 8 2")); // Ytterbium + hulllist.append(QStringLiteral("2 8 18 32 9 2")); // Lutetium + hulllist.append(QStringLiteral("2 8 18 32 10 2")); // Hafnium hulllist.append(QStringLiteral("2 8 18 32 11 2")); hulllist.append(QStringLiteral("2 8 18 32 12 2")); hulllist.append(QStringLiteral("2 8 18 32 13 2")); hulllist.append(QStringLiteral("2 8 18 32 14 2")); - hulllist.append(QStringLiteral("2 8 18 32 15 2"));//Irdium + hulllist.append(QStringLiteral("2 8 18 32 15 2")); // Irdium hulllist.append(QStringLiteral("2 8 18 32 17 1")); hulllist.append(QStringLiteral("2 8 18 32 18 1")); - hulllist.append(QStringLiteral("2 8 18 32 18 2"));//Mercury + hulllist.append(QStringLiteral("2 8 18 32 18 2")); // Mercury hulllist.append(QStringLiteral("2 8 18 32 18 3")); hulllist.append(QStringLiteral("2 8 18 32 18 4")); hulllist.append(QStringLiteral("2 8 18 32 18 5")); hulllist.append(QStringLiteral("2 8 18 32 18 6")); hulllist.append(QStringLiteral("2 8 18 32 18 7")); - hulllist.append(QStringLiteral("2 8 18 32 18 8"));//Radon - hulllist.append(QStringLiteral("2 8 18 32 18 8 1"));//Francium - hulllist.append(QStringLiteral("2 8 18 32 18 8 2"));//Radium - hulllist.append(QStringLiteral("2 8 18 32 18 9 2"));//Actinium - hulllist.append(QStringLiteral("2 8 18 32 20 8 2"));//Thorium + hulllist.append(QStringLiteral("2 8 18 32 18 8")); // Radon + hulllist.append(QStringLiteral("2 8 18 32 18 8 1")); // Francium + hulllist.append(QStringLiteral("2 8 18 32 18 8 2")); // Radium + hulllist.append(QStringLiteral("2 8 18 32 18 9 2")); // Actinium + hulllist.append(QStringLiteral("2 8 18 32 20 8 2")); // Thorium hulllist.append(QStringLiteral("2 8 18 32 21 8 2")); - hulllist.append(QStringLiteral("2 8 18 32 22 8 2"));//Uran + hulllist.append(QStringLiteral("2 8 18 32 22 8 2")); // Uran hulllist.append(QStringLiteral("2 8 18 32 23 8 2")); - hulllist.append(QStringLiteral("2 8 18 32 24 8 2"));//Plutonium + hulllist.append(QStringLiteral("2 8 18 32 24 8 2")); // Plutonium hulllist.append(QStringLiteral("2 8 18 32 25 8 2")); - hulllist.append(QStringLiteral("2 8 18 32 26 8 2"));//Cm + hulllist.append(QStringLiteral("2 8 18 32 26 8 2")); // Cm hulllist.append(QStringLiteral("2 8 18 32 27 8 2")); - hulllist.append(QStringLiteral("2 8 18 32 28 8 2"));//Cf + hulllist.append(QStringLiteral("2 8 18 32 28 8 2")); // Cf hulllist.append(QStringLiteral("2 8 18 32 29 8 2")); - hulllist.append(QStringLiteral("2 8 18 32 30 8 2"));//Fm + hulllist.append(QStringLiteral("2 8 18 32 30 8 2")); // Fm hulllist.append(QStringLiteral("2 8 18 32 31 8 2")); - hulllist.append(QStringLiteral("2 8 18 32 32 8 2"));//Nobelium - hulllist.append(QStringLiteral("2 8 18 32 32 9 2"));//Lawrencium + hulllist.append(QStringLiteral("2 8 18 32 32 8 2")); // Nobelium + hulllist.append(QStringLiteral("2 8 18 32 32 9 2")); // Lawrencium hulllist.append(QStringLiteral("2 8 18 32 32 10 2")); - hulllist.append(QStringLiteral("2 8 18 32 32 11 2"));//Dubnium (105) + hulllist.append(QStringLiteral("2 8 18 32 32 11 2")); // Dubnium (105) hulllist.append(QStringLiteral("2 8 18 32 32 12 2")); - hulllist.append(QStringLiteral("2 8 18 32 32 13 2"));//Bohrium + hulllist.append(QStringLiteral("2 8 18 32 32 13 2")); // Bohrium hulllist.append(QStringLiteral("2 8 18 32 32 14 2")); - hulllist.append(QStringLiteral("2 8 18 32 32 15 2"));//Mt - hulllist.append(QStringLiteral("2 8 18 32 32 16 2"));//Darmstadtium - hulllist.append(QStringLiteral("2 8 18 32 32 17 2"));//Roentgenium + hulllist.append(QStringLiteral("2 8 18 32 32 15 2")); // Mt + hulllist.append(QStringLiteral("2 8 18 32 32 16 2")); // Darmstadtium + hulllist.append(QStringLiteral("2 8 18 32 32 17 2")); // Roentgenium } } @@ -175,17 +176,16 @@ void OrbitsWidget::setElementNumber(int num) o = hulllist[Elemno - 1]; } - foreach (const QString& str, o.split(' ', Qt::SkipEmptyParts)) + foreach (const QString &str, o.split(' ', Qt::SkipEmptyParts)) numOfElectrons.append(str.toInt()); m_electronConf->setMinimumWidth(width()); // setting the electronic configuration in the label. - m_electronConf->setText(KalziumUtils::prettyUnit(KalziumDataObject::instance()->element(Elemno), - ChemicalDataObject::electronicConfiguration)); + m_electronConf->setText(KalziumUtils::prettyUnit(KalziumDataObject::instance()->element(Elemno), ChemicalDataObject::electronicConfiguration)); update(); } -void OrbitsWidget::paintEvent(QPaintEvent*) +void OrbitsWidget::paintEvent(QPaintEvent *) { QPainter DC; DC.begin(this); @@ -200,30 +200,30 @@ void OrbitsWidget::paintEvent(QPaintEvent*) return; // no orbits, do nothing } - //make sure the biggest orbit fits in the widget - //diameter + // make sure the biggest orbit fits in the widget + // diameter int d = min_size - 2 * min_delta; - //the radius of the current orbit + // the radius of the current orbit int r = d / 2; - //the radius of an 'electron' + // the radius of an 'electron' int r_electron = r / 20; - //difference to the previous circle + // difference to the previous circle int ddx = r / num; QList::Iterator it = numOfElectrons.end(); --it; for (int i = 0; i < num; ++i) { - int mx = min_delta + ddx * i; //the x-coordinate for the current circle - int my = min_delta + ddx * i; //the y-coordinate for the current circle + int mx = min_delta + ddx * i; // the x-coordinate for the current circle + int my = min_delta + ddx * i; // the y-coordinate for the current circle DC.setBrush(Qt::NoBrush); DC.setPen(Qt::black); - //draw the big ellipses in concentric circles + // draw the big ellipses in concentric circles DC.drawEllipse(mx, my, d, d); DC.setPen(Qt::NoPen); @@ -232,20 +232,16 @@ void OrbitsWidget::paintEvent(QPaintEvent*) int x = (int)translateToDX(d / 2.0, (double)e, *it); int y = (int)translateToDY(d / 2.0, (double)e, *it); - //Creating a gradient for the current electron. + // 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); grad.setColorAt(0, Qt::white); grad.setColorAt(0.2, Qt::yellow); grad.setColorAt(1, QColor(Qt::yellow).darker()); DC.setBrush(QBrush(grad)); - DC.drawEllipse(x + mx + d / 2 - r_electron, - y + my + d / 2 - r_electron, - 2 * r_electron, - 2 * r_electron); + DC.drawEllipse(x + mx + d / 2 - r_electron, y + my + d / 2 - r_electron, 2 * r_electron, 2 * r_electron); } --it; d -= 2 * ddx; } } - diff --git a/src/orbitswidget.h b/src/orbitswidget.h index 3eed26d80c277b6655b5b392465c8a0b7801573d..a261bd2db74a3aef9115cad849f99ef4ad8dc99b 100644 --- a/src/orbitswidget.h +++ b/src/orbitswidget.h @@ -34,7 +34,7 @@ private: QList numOfElectrons; protected Q_SLOTS: - virtual void paintEvent(QPaintEvent*) override; + virtual void paintEvent(QPaintEvent *) override; }; #endif // ORBITSWIDGET_H diff --git a/src/psetable/elementitem.cpp b/src/psetable/elementitem.cpp index 44a975bf6c2f2e2f41dc687fa718c393f20988ae..7fedfa40084ba361e26c574b1143199b04ee8fb9 100644 --- a/src/psetable/elementitem.cpp +++ b/src/psetable/elementitem.cpp @@ -25,8 +25,11 @@ #include -ElementItem::ElementItem(KalziumElementProperty *elProperty, int elementNumber) : m_width(40), - m_height(40), m_element(elementNumber), m_property(elProperty) +ElementItem::ElementItem(KalziumElementProperty *elProperty, int elementNumber) + : m_width(40) + , m_height(40) + , m_element(elementNumber) + , m_property(elProperty) { // Want these items to be selectable setFlags(QGraphicsItem::ItemIsSelectable); @@ -78,7 +81,6 @@ void ElementItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWi QFont symbolFont; switch (m_property->getMode()) { - case KalziumElementProperty::NORMAL: symbolFont.setPointSize(12); symbolFont.setBold(true); @@ -87,19 +89,16 @@ void ElementItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWi symbolFont.setPointSize(7); symbolFont.setBold(false); painter->setFont(symbolFont); - painter->drawText(QRectF(m_width / 14, m_height / 20, m_width, m_height / 2), - Qt::AlignLeft, QString::number(m_element)); + painter->drawText(QRectF(m_width / 14, m_height / 20, m_width, m_height / 2), Qt::AlignLeft, QString::number(m_element)); break; case KalziumElementProperty::GRADIENTVALUE: - painter->drawText(QRectF(0, m_height / 20, m_width, m_height / 2), - Qt::AlignCenter, m_symbol); + painter->drawText(QRectF(0, m_height / 20, m_width, m_height / 2), Qt::AlignCenter, m_symbol); symbolFont.setPointSize(7); painter->setFont(symbolFont); - painter->drawText(QRectF(0, m_height / 2 - m_height / 20, m_width, m_height / 2), - Qt::AlignCenter, m_textValue); + painter->drawText(QRectF(0, m_height / 2 - m_height / 20, m_width, m_height / 2), Qt::AlignCenter, m_textValue); break; } } @@ -124,7 +123,7 @@ QString ElementItem::getCurrentElementValue() return QString::number(value); } -void ElementItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event) +void ElementItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { setZValue(200); moveBy(-m_width / 4, -m_height / 4); @@ -132,7 +131,7 @@ void ElementItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event) QGraphicsItem::hoverEnterEvent(event); } -void ElementItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) +void ElementItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { resetTransform(); moveBy(m_width / 4, m_height / 4); @@ -140,4 +139,3 @@ void ElementItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) setScale(1); QGraphicsItem::hoverLeaveEvent(event); } - diff --git a/src/psetable/elementitem.h b/src/psetable/elementitem.h index 69fa4b590ce396d04b7deff79bd998600b7bcd98..ec088aada7c95e5190bdea0d21f58bb830840774 100644 --- a/src/psetable/elementitem.h +++ b/src/psetable/elementitem.h @@ -21,14 +21,14 @@ #include /** -* @class ElementItem -* @author Marcus D. Hanwell, Etienne Rebetez -* @brief An element item, intended to display a single element. -* -* This class implements a QGraphicsItem for displaying single elements in a -* perdiodic table. It currently allows the setting of the proton number. -* All other information come frome the kalziumElementProperty class. -*/ + * @class ElementItem + * @author Marcus D. Hanwell, Etienne Rebetez + * @brief An element item, intended to display a single element. + * + * This class implements a QGraphicsItem for displaying single elements in a + * perdiodic table. It currently allows the setting of the proton number. + * All other information come frome the kalziumElementProperty class. + */ class ElementItem : public QGraphicsObject { Q_OBJECT diff --git a/src/psetable/numerationitem.cpp b/src/psetable/numerationitem.cpp index fe6d5da6048b7c4f0408063ee78779e44de2ab25..ab9e22470d014a539eff05da9c1f2291008e3bb1 100644 --- a/src/psetable/numerationitem.cpp +++ b/src/psetable/numerationitem.cpp @@ -26,8 +26,10 @@ #include "kalziumnumerationtype.h" -NumerationItem::NumerationItem(int xPosition) : m_width(40), m_height(20), - m_xPosition(xPosition) +NumerationItem::NumerationItem(int xPosition) + : m_width(40) + , m_height(20) + , m_xPosition(xPosition) { setNumerationType(Prefs::numeration()); } @@ -65,10 +67,9 @@ void NumerationItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, void NumerationItem::setNumerationType(int type) { - type == 0 ? m_color = QColor(Qt::transparent) : m_color = QColor(Qt::white); + type == 0 ? m_color = QColor(Qt::transparent) : m_color = QColor(Qt::white); - m_numeration = KalziumNumerationTypeFactory::instance()->build(type)->item(m_xPosition); + m_numeration = KalziumNumerationTypeFactory::instance()->build(type)->item(m_xPosition); - update(); + update(); } - diff --git a/src/psetable/numerationitem.h b/src/psetable/numerationitem.h index 7b4b773e785bf3473540e6a103a4a6041c9f9736..bea9796f72a4becb93683eaca8ef01064c9f2134 100644 --- a/src/psetable/numerationitem.h +++ b/src/psetable/numerationitem.h @@ -87,7 +87,6 @@ private: * The color of the element. */ QColor m_color; - }; #endif // NUMERATIONITEM_H diff --git a/src/psetable/periodictablescene.cpp b/src/psetable/periodictablescene.cpp index 463efb13c0a26b23306eb42a4c3da4b54640b1f1..2775a6fc1473357b6434257562caa19fb6df1289 100644 --- a/src/psetable/periodictablescene.cpp +++ b/src/psetable/periodictablescene.cpp @@ -21,8 +21,8 @@ #include PeriodicTableScene::PeriodicTableScene(QObject *parent) - : QGraphicsScene(parent), - m_prevHoverElement(-1) + : QGraphicsScene(parent) + , m_prevHoverElement(-1) { QPalette widgetPalette = palette(); setBackgroundBrush(QBrush(widgetPalette.window())); @@ -34,7 +34,8 @@ PeriodicTableScene::PeriodicTableScene(QObject *parent) } PeriodicTableScene::~PeriodicTableScene() -{} +{ +} bool PeriodicTableScene::event(QEvent *e) { @@ -61,10 +62,9 @@ void PeriodicTableScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { QGraphicsItem *item = QGraphicsScene::itemAt(m_eventPos, QTransform()); - if ((QApplication::mouseButtons() & Qt::LeftButton) && - (event->pos() - m_eventPos).manhattanLength() > QApplication::startDragDistance() && - item->data(0).toInt() > 0) { - Element* pointedElement = KalziumDataObject::instance()->element(item->data(0).toInt()); + if ((QApplication::mouseButtons() & Qt::LeftButton) && (event->pos() - m_eventPos).manhattanLength() > QApplication::startDragDistance() + && item->data(0).toInt() > 0) { + Element *pointedElement = KalziumDataObject::instance()->element(item->data(0).toInt()); QDrag *drag = new QDrag(event->widget()); QMimeData *mimeData = new QMimeData; @@ -94,7 +94,6 @@ void PeriodicTableScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QGraphicsScene::mouseMoveEvent(event); } - void PeriodicTableScene::slotMouseover() { QGraphicsItem *item = QGraphicsScene::itemAt(m_eventPos, QTransform()); @@ -108,7 +107,6 @@ void PeriodicTableScene::slotMouseover() } } - void PeriodicTableScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() != Qt::LeftButton) { @@ -121,5 +119,3 @@ void PeriodicTableScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } QGraphicsScene::mouseReleaseEvent(event); } - - diff --git a/src/psetable/periodictablescene.h b/src/psetable/periodictablescene.h index d1d9812f433306e7c08fc58a3cd27d4e06a4d5cb..2020523d1b6bb346914913636038a15175402851 100644 --- a/src/psetable/periodictablescene.h +++ b/src/psetable/periodictablescene.h @@ -61,7 +61,6 @@ protected: void mousePressEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; - }; #endif // PERIODICTABLESCENE_H diff --git a/src/psetable/periodictablestates.cpp b/src/psetable/periodictablestates.cpp index 99378b086473cf72c4419857183450fc708d03fe..69bcac64775726d56b52d6bb40e06131fdf87e64 100644 --- a/src/psetable/periodictablestates.cpp +++ b/src/psetable/periodictablestates.cpp @@ -10,15 +10,14 @@ #include -PeriodicTableStates::PeriodicTableStates( - const QList &elementItemList, - const QList &numerationItemList) - : m_elementItemList(elementItemList), - m_numerationItemList(numerationItemList), - m_width(42), m_height(42) // Some space between the elements (px40) looks nice. +PeriodicTableStates::PeriodicTableStates(const QList &elementItemList, const QList &numerationItemList) + : m_elementItemList(elementItemList) + , m_numerationItemList(numerationItemList) + , m_width(42) + , m_height(42) // Some space between the elements (px40) looks nice. { m_stateSwitcher = new StateSwitcher(&m_states); - m_group= new QParallelAnimationGroup; + m_group = new QParallelAnimationGroup; // For every Tabletyp the Position of the Elements are set up. for (int tableIndex = 0; tableIndex < pseTables::instance()->tables().count(); ++tableIndex) { @@ -44,8 +43,7 @@ void PeriodicTableStates::setNumerationItemPositions(const int &tableIndex) int numerationId = pseTables::instance()->getTabletype(tableIndex)->numerationAtPos(x); if (numerationId >= 0) { - m_tableStatesList.at(tableIndex)->assignProperty(m_numerationItemList.at(numerationId), "pos", - QPointF(x * m_width, - m_height * 3 / 4)); + m_tableStatesList.at(tableIndex)->assignProperty(m_numerationItemList.at(numerationId), "pos", QPointF(x * m_width, -m_height * 3 / 4)); addElementAnimation(m_numerationItemList.at(numerationId), x); } } @@ -67,8 +65,7 @@ int PeriodicTableStates::maxNumerationItemXCoordinate(const int &tableIndex) { const int maxTableLenght = pseTables::instance()->getTabletype(tableIndex)->tableSize().x(); - return maxTableLenght > m_numerationItemList.count() ? - maxTableLenght : m_numerationItemList.count(); + return maxTableLenght > m_numerationItemList.count() ? maxTableLenght : m_numerationItemList.count(); } void PeriodicTableStates::addElementAnimation(QGraphicsObject *object, int duration) @@ -90,8 +87,7 @@ void PeriodicTableStates::setElementItemPositions(const int &tableIndex) itemPosition = hiddenPoint(); } - m_tableStatesList.at(tableIndex)->assignProperty(m_elementItemList.at(i), "pos", - QPointF((itemPosition.x()) * m_width, (itemPosition.y()) * m_height)); + m_tableStatesList.at(tableIndex)->assignProperty(m_elementItemList.at(i), "pos", QPointF((itemPosition.x()) * m_width, (itemPosition.y()) * m_height)); addElementAnimation(m_elementItemList.at(i), i); } diff --git a/src/psetable/periodictablestates.h b/src/psetable/periodictablestates.h index a92a87de1939e1d343328f750bc6cd06324d2eb1..7244e322cbf5de7a6cf08e55c8f6064869b594f9 100644 --- a/src/psetable/periodictablestates.h +++ b/src/psetable/periodictablestates.h @@ -34,8 +34,7 @@ public: * @param elementItemList List of the Element items in the table. * @param numerationItemList List of the Numeration items in the table. */ - PeriodicTableStates(const QList &elementItemList, - const QList &numerationItemList); + PeriodicTableStates(const QList &elementItemList, const QList &numerationItemList); virtual ~PeriodicTableStates(); @@ -50,7 +49,7 @@ public: * Set the table index * @param tableIndex Index of the table @see pseTables.. */ - void setTableState(const int &tableIndex) ; + void setTableState(const int &tableIndex); private: void setNumerationItemPositions(const int &tableIndex); diff --git a/src/psetable/periodictableview.cpp b/src/psetable/periodictableview.cpp index 672a3673b13e3abe3c7b569139aa98e5994cbdf3..8e74eedff34be5651522f7efbee0542ba01410ad 100644 --- a/src/psetable/periodictableview.cpp +++ b/src/psetable/periodictableview.cpp @@ -10,14 +10,14 @@ #include "periodictableview.h" -#include #include +#include #include "psetables.h" #include PeriodicTableView::PeriodicTableView(QWidget *parent) - : QGraphicsView(parent) + : QGraphicsView(parent) { setRenderHint(QPainter::Antialiasing); setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); @@ -31,19 +31,17 @@ PeriodicTableView::PeriodicTableView(QWidget *parent) setScene(m_tableScene); connect(m_tableScene, &PeriodicTableScene::freeSpaceClick, this, &PeriodicTableView::fitPseInView); - m_tableStates = new PeriodicTableStates( - createElementItems(), - createNumerationItems()); + m_tableStates = new PeriodicTableStates(createElementItems(), createNumerationItems()); fitPseInView(); } -QList PeriodicTableView::createNumerationItems() const +QList PeriodicTableView::createNumerationItems() const { // Creating Nummerationitems here, we use the classic periodic table as reference (18 elements in a row) const int xMax = 18; - QList numerationItemList; + QList numerationItemList; for (int i = 0; i < xMax; ++i) { numerationItemList << new NumerationItem(i); @@ -54,9 +52,9 @@ QList PeriodicTableView::createNumerationItems() const return numerationItemList; } -QList PeriodicTableView::createElementItems() const +QList PeriodicTableView::createElementItems() const { - QList elementItemList; + QList elementItemList; KalziumElementProperty *elProperty = KalziumElementProperty::instance(); foreach (int intElement, pseTables::instance()->getTabletype(0)->elements()) { @@ -70,9 +68,9 @@ QList PeriodicTableView::createElementItems() const return elementItemList; } -PeriodicTableScene* PeriodicTableView::pseScene() const +PeriodicTableScene *PeriodicTableView::pseScene() const { - return m_tableScene; + return m_tableScene; } int PeriodicTableView::table() const @@ -127,7 +125,7 @@ void PeriodicTableView::setBiggerSceneRect() setSceneRect(newRect); } -void PeriodicTableView::resizeEvent (QResizeEvent * event) +void PeriodicTableView::resizeEvent(QResizeEvent *event) { fitPseInView(); QGraphicsView::resizeEvent(event); @@ -147,7 +145,7 @@ bool PeriodicTableView::event(QEvent *e) return QGraphicsView::event(e); } -void PeriodicTableView::generateSvg(const QString& filename) +void PeriodicTableView::generateSvg(const QString &filename) { QSvgGenerator *svgGen = new QSvgGenerator(); svgGen->setFileName(filename); @@ -166,4 +164,3 @@ PeriodicTableView::~PeriodicTableView() delete scene(); delete m_tableStates; } - diff --git a/src/psetable/periodictableview.h b/src/psetable/periodictableview.h index ee8fa1555456ee73ff458c2b2bd0c23f1aab2bdd..aaf79086e7cbdc8f5c89ce71adafdffc9b38d246 100644 --- a/src/psetable/periodictableview.h +++ b/src/psetable/periodictableview.h @@ -30,7 +30,7 @@ * @author Marcus D. Hanwell * @author Etienne Rebetez * -*/ + */ class PeriodicTableView : public QGraphicsView { @@ -54,8 +54,7 @@ public: * Generates and saves the pse as svg in the given filename. * @param filename filename of the destination. */ - void generateSvg(const QString& filename); - + void generateSvg(const QString &filename); Q_SIGNALS: /** @@ -94,8 +93,8 @@ public Q_SLOTS: void slotUnSelectElements(); private: - QList createElementItems() const; - QList createNumerationItems() const; + QList createElementItems() const; + QList createNumerationItems() const; void setBiggerSceneRect(); @@ -116,7 +115,7 @@ protected: /** * is called every time the view is resized. */ - void resizeEvent(QResizeEvent * event) override; + void resizeEvent(QResizeEvent *event) override; }; #endif // PERIODICTABLEVIEW_H diff --git a/src/psetable/statemachine.cpp b/src/psetable/statemachine.cpp index 7ccb008e722bc8178667fc5097bc81731cb5f399..4ffd736f0e525b0e5acd28b7b8b69d2c249aae28 100644 --- a/src/psetable/statemachine.cpp +++ b/src/psetable/statemachine.cpp @@ -7,7 +7,7 @@ #include "statemachine.h" StateSwitcher::StateSwitcher(QStateMachine *machine) - : QState(machine) + : QState(machine) { } @@ -19,7 +19,6 @@ void StateSwitcher::addState(QState *state, QAbstractAnimation *animation, const trans->addAnimation(animation); } - void StateSwitcher::switchToState(int n) { machine()->postEvent(new StateSwitchEvent(n)); diff --git a/src/psetable/statemachine.h b/src/psetable/statemachine.h index e73679886b418997f5a23bbbdcc061b241ac6522..68e3285788391c9c9c919ee953c0f6982fdeaa1f 100644 --- a/src/psetable/statemachine.h +++ b/src/psetable/statemachine.h @@ -18,14 +18,17 @@ #include #include -class StateSwitchEvent: public QEvent +class StateSwitchEvent : public QEvent { public: - StateSwitchEvent() : QEvent(Type(StateSwitchType)) + StateSwitchEvent() + : QEvent(Type(StateSwitchType)) { } - StateSwitchEvent(int id) : QEvent(Type(StateSwitchType)), m_id(id) + StateSwitchEvent(int id) + : QEvent(Type(StateSwitchType)) + , m_id(id) { } @@ -40,29 +43,29 @@ private: int m_id; }; - -class StateSwitchTransition: public QAbstractTransition +class StateSwitchTransition : public QAbstractTransition { public: - StateSwitchTransition(int id) : QAbstractTransition(), m_id(id) + StateSwitchTransition(int id) + : QAbstractTransition() + , m_id(id) { } protected: - bool eventTest(QEvent *event) override { - return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType)) - && (static_cast(event)->id() == m_id); + return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType)) && (static_cast(event)->id() == m_id); } - void onTransition(QEvent *) override {} + void onTransition(QEvent *) override + { + } private: int m_id; }; - class StateSwitcher : public QState { public: diff --git a/src/rsdialog.cpp b/src/rsdialog.cpp index 6a1cddef40acabba0c11dfea9b90aaf5c49e055a..3a57717594c275b9e437c3e0955d5300f9cfebea 100644 --- a/src/rsdialog.cpp +++ b/src/rsdialog.cpp @@ -19,10 +19,11 @@ #include #include -RSDialog::RSDialog(QWidget* parent) : QDialog(parent) +RSDialog::RSDialog(QWidget *parent) + : QDialog(parent) { setWindowTitle(i18nc("@title:window", "Risks/Security Phrases")); - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help|QDialogButtonBox::Close, this); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close, this); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); @@ -35,23 +36,17 @@ RSDialog::RSDialog(QWidget* parent) : QDialog(parent) ui.setupUi(mainWidget); - connect(ui.filterButton, &QAbstractButton::clicked, - this, &RSDialog::filter); + connect(ui.filterButton, &QAbstractButton::clicked, this, &RSDialog::filter); connect(buttonBox, &QDialogButtonBox::helpRequested, this, &RSDialog::slotHelp); - filter(); + filter(); } void RSDialog::filter() { - //if the RS sentence starts or ends with a - invalidate it. - //It is probably an user error - if ( - ui.r_le->text().startsWith('-') || - ui.r_le->text().endsWith('-') || - ui.s_le->text().startsWith('-') || - ui.s_le->text().endsWith('-') - ) { + // if the RS sentence starts or ends with a - invalidate it. + // It is probably an user error + if (ui.r_le->text().startsWith('-') || ui.r_le->text().endsWith('-') || ui.s_le->text().startsWith('-') || ui.s_le->text().endsWith('-')) { invalidPhaseString(); return; } @@ -59,18 +54,16 @@ void RSDialog::filter() QList r; QList s; - //for now only separation by a - is allowed - if (!ui.r_le->text().isEmpty()) - { + // for now only separation by a - is allowed + if (!ui.r_le->text().isEmpty()) { const QStringList rSplit = ui.r_le->text().split('-'); for (const QString &st : rSplit) { r << st.toInt(); } } - //for now only separation by a - is allowed - if (!ui.s_le->text().isEmpty()) - { + // for now only separation by a - is allowed + if (!ui.s_le->text().isEmpty()) { const QStringList sSplit = ui.s_le->text().split('-'); for (const QString &st : sSplit) { s << st.toInt(); @@ -80,7 +73,7 @@ void RSDialog::filter() filterRS(r, s); } -void RSDialog::filterRS(const QList& r, const QList& s) +void RSDialog::filterRS(const QList &r, const QList &s) { QString string(QStringLiteral("")); @@ -140,64 +133,172 @@ QString RSDialog::sphrase(int number) return p; } - void RSDialog::createSPhrases() { QStringList sphrases; - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S1: Keep locked up"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S2: Keep out of the reach of children"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S3: Keep in a cool place"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S4: Keep away from living quarters"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S5: Keep contents under ... ( appropriate liquid to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S6: Keep under ... ( inert gas to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S7: Keep container tightly closed"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S8: Keep container dry"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S9: Keep container in a well-ventilated place"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S12: Do not keep the container sealed"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S13: Keep away from food, drink and animal feedingstuffs"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S14: Keep away from ... ( incompatible materials to be indicated by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S15: Keep away from heat"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S16: Keep away from sources of ignition - No smoking"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S17: Keep away from combustible material"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S18: Handle and open container with care"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S20: When using do not eat or drink"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S21: When using do not smoke"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S22: Do not breathe dust"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S23: Do not breathe gas/fumes/vapour/spray ( appropriate wording to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S24: Avoid contact with skin"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S25: Avoid contact with eyes"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S26: In case of contact with eyes, rinse immediately with plenty of water and seek medical advice"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S27: Take off immediately all contaminated clothing"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S28: After contact with skin, wash immediately with plenty of ... ( to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S29: Do not empty into drains"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S30: Never add water to this product"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S33: Take precautionary measures against static discharges"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S35: This material and its container must be disposed of in a safe way"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S36: Wear suitable protective clothing"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S37: Wear suitable gloves"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S38: In case of insufficient ventilation wear suitable respiratory equipment"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S39: Wear eye/face protection"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S40: To clean the floor and all objects contaminated by this material use ... ( to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S41: In case of fire and/or explosion do not breathe fumes"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S42: During fumigation/spraying wear suitable respiratory equipment ( appropriate wording to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S43: In case of fire use ... ( indicate in the space the precise type of fire-fighting equipment. If water increases the risk add - Never use water )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S45: In case of accident or if you feel unwell seek medical advice immediately ( show the label where possible )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S46: If swallowed, seek medical advice immediately and show this container or label"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S47: Keep at temperature not exceeding ... °C ( to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S48: Keep wet with ... ( appropriate material to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S49: Keep only in the original container"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S50: Do not mix with ... ( to be specified by the manufacturer )"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S51: Use only in well-ventilated areas"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S52: Not recommended for interior use on large surface areas"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S53: Avoid exposure - obtain special instructions before use"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S56: Dispose of this material and its container at hazardous or special waste collection point"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S57: Use appropriate containment to avoid environmental contamination"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S59: Refer to manufacturer/supplier for information on recovery/recycling"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S60: This material and its container must be disposed of as hazardous waste"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S61: Avoid release to the environment. Refer to special instructions/safety data sheet"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S62: If swallowed, do not induce vomiting: seek medical advice immediately and show this container or label"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S63: In case of accident by inhalation: remove casualty to fresh air and keep at rest"); - sphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "S64: If swallowed, rinse mouth with water ( only if the person is conscious )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S1: Keep locked up"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S2: Keep out of the reach of children"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S3: Keep in a cool place"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S4: Keep away from living quarters"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S5: Keep contents under ... ( appropriate liquid to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S6: Keep under ... ( inert gas to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S7: Keep container tightly closed"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S8: Keep container dry"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S9: Keep container in a well-ventilated place"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S12: Do not keep the container sealed"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S13: Keep away from food, drink and animal feedingstuffs"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S14: Keep away from ... ( incompatible materials to be indicated by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S15: Keep away from heat"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S16: Keep away from sources of ignition - No smoking"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S17: Keep away from combustible material"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S18: Handle and open container with care"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S20: When using do not eat or drink"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S21: When using do not smoke"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S22: Do not breathe dust"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S23: Do not breathe gas/fumes/vapour/spray ( appropriate wording to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S24: Avoid contact with skin"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S25: Avoid contact with eyes"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S26: In case of contact with eyes, rinse immediately with plenty of water and seek medical advice"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S27: Take off immediately all contaminated clothing"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S28: After contact with skin, wash immediately with plenty of ... ( to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S29: Do not empty into drains"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S30: Never add water to this product"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S33: Take precautionary measures against static discharges"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S35: This material and its container must be disposed of in a safe way"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S36: Wear suitable protective clothing"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S37: Wear suitable gloves"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S38: In case of insufficient ventilation wear suitable respiratory equipment"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S39: Wear eye/face protection"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S40: To clean the floor and all objects contaminated by this material use ... ( to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S41: In case of fire and/or explosion do not breathe fumes"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S42: During fumigation/spraying wear suitable respiratory equipment ( appropriate wording to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S43: In case of fire use ... ( indicate in the space the precise type of fire-fighting equipment. If water increases the risk add - Never use water " + ")"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S45: In case of accident or if you feel unwell seek medical advice immediately ( show the label where possible )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S46: If swallowed, seek medical advice immediately and show this container or label"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S47: Keep at temperature not exceeding ... °C ( to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S48: Keep wet with ... ( appropriate material to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S49: Keep only in the original container"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S50: Do not mix with ... ( to be specified by the manufacturer )"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S51: Use only in well-ventilated areas"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S52: Not recommended for interior use on large surface areas"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S53: Avoid exposure - obtain special instructions before use"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S56: Dispose of this material and its container at hazardous or special waste collection point"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S57: Use appropriate containment to avoid environmental contamination"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S59: Refer to manufacturer/supplier for information on recovery/recycling"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S60: This material and its container must be disposed of as hazardous waste"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S61: Avoid release to the environment. Refer to special instructions/safety data sheet"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S62: If swallowed, do not induce vomiting: seek medical advice immediately and show this container or label"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S63: In case of accident by inhalation: remove casualty to fresh air and keep at rest"); + sphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "S64: If swallowed, rinse mouth with water ( only if the person is conscious )"); QRegularExpression reg("(R|S)(\\d+): (.*)"); @@ -221,72 +322,204 @@ void RSDialog::createSPhrases() void RSDialog::createRPhrases() { QStringList rphrases; - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R1: Explosive when dry"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R2: Risk of explosion by shock, friction, fire or other sources of ignition"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R3: Extreme risk of explosion by shock, friction, fire or other sources of ignition"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R4: Forms very sensitive explosive metallic compounds"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R5: Heating may cause an explosion"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R6: Explosive with or without contact with air"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R7: May cause fire"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R8: Contact with combustible material may cause fire"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R9: Explosive when mixed with combustible material"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R10: Flammable"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R11: Highly flammable"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R12: Extremely flammable"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R14: Reacts violently with water"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R15: Contact with water liberates extremely flammable gases"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R16: Explosive when mixed with oxidising substances"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R17: Spontaneously flammable in air"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R18: In use, may form flammable/explosive vapour-air mixture"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R19: May form explosive peroxides"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R20: Harmful by inhalation"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R21: Harmful in contact with skin"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R22: Harmful if swallowed"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R23: Toxic by inhalation"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R24: Toxic in contact with skin"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R25: Toxic if swallowed"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R26: Very toxic by inhalation"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R27: Very toxic in contact with skin"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R28: Very toxic if swallowed"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R29: Contact with water liberates toxic gas."); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R30: Can become highly flammable in use"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R31: Contact with acids liberates toxic gas"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R32: Contact with acids liberates very toxic gas"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R33: Danger of cumulative effects"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R34: Causes burns"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R35: Causes severe burns"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R36: Irritating to eyes"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R37: Irritating to respiratory system"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R38: Irritating to skin"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R39: Danger of very serious irreversible effects"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R40: Limited evidence of a carcinogenic effect"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R41: Risk of serious damage to eyes"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R42: May cause sensitisation by inhalation"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R43: May cause sensitisation by skin contact"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R44: Risk of explosion if heated under confinement"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R45: May cause cancer"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R46: May cause heritable genetic damage"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R48: Danger of serious damage to health by prolonged exposure"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R49: May cause cancer by inhalation"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R50: Very toxic to aquatic organisms"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R51: Toxic to aquatic organisms"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R52: Harmful to aquatic organisms"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R53: May cause long-term adverse effects in the aquatic environment"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R54: Toxic to flora"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R55: Toxic to fauna"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R56: Toxic to soil organisms"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R57: Toxic to bees"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R58: May cause long-term adverse effects in the environment"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R59: Dangerous for the ozone layer"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R60: May impair fertility"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R61: May cause harm to the unborn child"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R62: Possible risk of impaired fertility"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R63: Possible risk of harm to the unborn child"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R64: May cause harm to breast-fed babies"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R65: Harmful: may cause lung damage if swallowed"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R66: Repeated exposure may cause skin dryness or cracking"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R67: Vapours may cause drowsiness and dizziness"); - rphrases << i18nc("Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", "R68: Possible risk of irreversible effects"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R1: Explosive when dry"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R2: Risk of explosion by shock, friction, fire or other sources of ignition"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R3: Extreme risk of explosion by shock, friction, fire or other sources of ignition"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R4: Forms very sensitive explosive metallic compounds"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R5: Heating may cause an explosion"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R6: Explosive with or without contact with air"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R7: May cause fire"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R8: Contact with combustible material may cause fire"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R9: Explosive when mixed with combustible material"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R10: Flammable"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R11: Highly flammable"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R12: Extremely flammable"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R14: Reacts violently with water"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R15: Contact with water liberates extremely flammable gases"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R16: Explosive when mixed with oxidising substances"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R17: Spontaneously flammable in air"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R18: In use, may form flammable/explosive vapour-air mixture"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R19: May form explosive peroxides"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R20: Harmful by inhalation"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R21: Harmful in contact with skin"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R22: Harmful if swallowed"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R23: Toxic by inhalation"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R24: Toxic in contact with skin"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R25: Toxic if swallowed"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R26: Very toxic by inhalation"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R27: Very toxic in contact with skin"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R28: Very toxic if swallowed"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R29: Contact with water liberates toxic gas."); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R30: Can become highly flammable in use"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R31: Contact with acids liberates toxic gas"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R32: Contact with acids liberates very toxic gas"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R33: Danger of cumulative effects"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R34: Causes burns"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R35: Causes severe burns"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R36: Irritating to eyes"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R37: Irritating to respiratory system"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R38: Irritating to skin"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R39: Danger of very serious irreversible effects"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R40: Limited evidence of a carcinogenic effect"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R41: Risk of serious damage to eyes"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R42: May cause sensitisation by inhalation"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R43: May cause sensitisation by skin contact"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R44: Risk of explosion if heated under confinement"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R45: May cause cancer"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R46: May cause heritable genetic damage"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R48: Danger of serious damage to health by prolonged exposure"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R49: May cause cancer by inhalation"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R50: Very toxic to aquatic organisms"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R51: Toxic to aquatic organisms"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R52: Harmful to aquatic organisms"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R53: May cause long-term adverse effects in the aquatic environment"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R54: Toxic to flora"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R55: Toxic to fauna"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R56: Toxic to soil organisms"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R57: Toxic to bees"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R58: May cause long-term adverse effects in the environment"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R59: Dangerous for the ozone layer"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R60: May impair fertility"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R61: May cause harm to the unborn child"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R62: Possible risk of impaired fertility"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R63: Possible risk of harm to the unborn child"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R64: May cause harm to breast-fed babies"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R65: Harmful: may cause lung damage if swallowed"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R66: Repeated exposure may cause skin dryness or cracking"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R67: Vapours may cause drowsiness and dizziness"); + rphrases << i18nc( + "Please take the official translations! You find them here: https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32001L0059:EN:HTML", + "R68: Possible risk of irreversible effects"); QRegularExpression reg("(R|S)(\\d+): (.*)"); @@ -316,4 +549,3 @@ void RSDialog::invalidPhaseString() { KMessageBox::error(nullptr, i18n("At least one of the specified phrases is invalid.")); } - diff --git a/src/rsdialog.h b/src/rsdialog.h index d911abcef4a9c80066f652da09d6ac6b647ee742..aac00e9a47de8ab1ace74bacc10012654ebeefb3 100644 --- a/src/rsdialog.h +++ b/src/rsdialog.h @@ -23,14 +23,14 @@ class RSDialog : public QDialog Q_OBJECT public: - explicit RSDialog(QWidget * parent); + explicit RSDialog(QWidget *parent); Ui::RSWidget ui; /** * Filter the R- and S-Phrases. */ - void filterRS(const QList& r, const QList& s); + void filterRS(const QList &r, const QList &s); QString rphrase(int number); diff --git a/src/search.cpp b/src/search.cpp index 6c2b9f259daf6019db19765837ebacbc723ec4ee..8d0a1f8adbe7ad4bfc3a534b1434b9ea90f3e76b 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -9,7 +9,9 @@ #include "element.h" #include "kalziumdataobject.h" -Search::Search() : m_isActive(false), m_searchKind(Search::SearchAll) +Search::Search() + : m_isActive(false) + , m_searchKind(Search::SearchAll) { } @@ -28,36 +30,34 @@ bool Search::isActive() const return m_isActive; } -const QList& Search::foundElements() const +const QList &Search::foundElements() const { return m_foundElements; } -bool Search::matches(Element* e) const +bool Search::matches(Element *e) const { return m_foundElements.contains(e); } bool Search::matches(int el) const { - Element *element = KalziumDataObject::instance()->element(el); + Element *element = KalziumDataObject::instance()->element(el); return matches(element); } -void Search::doSearch(const QString& text, SearchKind kind) +void Search::doSearch(const QString &text, SearchKind kind) { m_isActive = true; m_searchText = text; m_searchKind = kind; - QList newresults; + QList newresults; foreach (Element *e, KalziumDataObject::instance()->ElementList) { bool found = false; - if (!found - && e->dataAsString(ChemicalDataObject::name).contains(text, Qt::CaseInsensitive)) { + if (!found && e->dataAsString(ChemicalDataObject::name).contains(text, Qt::CaseInsensitive)) { found = true; } - if (!found - && e->dataAsString(ChemicalDataObject::symbol).contains(text, Qt::CaseInsensitive)) { + if (!found && e->dataAsString(ChemicalDataObject::symbol).contains(text, Qt::CaseInsensitive)) { found = true; } if (found) { @@ -80,4 +80,3 @@ void Search::resetSearch() m_isActive = false; Q_EMIT searchReset(); } - diff --git a/src/search.h b/src/search.h index f7adfddf62a66bec921f0949356547bb9eae2993..67633a63ae4dd231fa9d1ad3cafbaa647f66aa8d 100644 --- a/src/search.h +++ b/src/search.h @@ -11,7 +11,7 @@ #include #include "element.h" -//class Element; +// class Element; /** * Represent a search. @@ -29,7 +29,7 @@ public: enum SearchKind { SearchByName = 0x01, SearchBySymbol = 0x02, - SearchAll = 0xFF + SearchAll = 0xFF, }; /** @@ -56,12 +56,12 @@ public: /** * @return the found elements */ - const QList& foundElements() const; + const QList &foundElements() const; /** * @return whether the element @p el matches the search */ - bool matches(Element* el) const; + bool matches(Element *el) const; /** * @return whether the element @p el matches the search @@ -74,7 +74,7 @@ public Q_SLOTS: * Search the @p text by looking at the element using the * specified @p kind */ - void doSearch(const QString& text, SearchKind kind); + void doSearch(const QString &text, SearchKind kind); /** * Reset the current search (and put it not active). */ @@ -97,7 +97,7 @@ private: QString m_searchText; SearchKind m_searchKind; - QList m_foundElements; + QList m_foundElements; }; #endif // KALZIUMSEARCH_H diff --git a/src/searchwidget.cpp b/src/searchwidget.cpp index 89a57d4ab3f5afff3cdaef472269c47cce83c081..1ce001b96e9c61a0a21ae5d525ada40b138c3b4e 100644 --- a/src/searchwidget.cpp +++ b/src/searchwidget.cpp @@ -16,7 +16,9 @@ #include "kalziumdataobject.h" #include "search.h" -SearchWidget::SearchWidget(QWidget *parent) : QWidget(parent), m_timer(nullptr) +SearchWidget::SearchWidget(QWidget *parent) + : QWidget(parent) + , m_timer(nullptr) { QHBoxLayout *mainlay = new QHBoxLayout(this); mainlay->setContentsMargins(2, 2, 2, 2); @@ -26,17 +28,15 @@ SearchWidget::SearchWidget(QWidget *parent) : QWidget(parent), m_timer(nullptr) m_searchLine->setClearButtonEnabled(true); m_searchLine->setPlaceholderText(i18n("Search...")); m_searchLine->setTrapReturnKey(true); - connect(m_searchLine, &QLineEdit::textChanged, - this, &SearchWidget::searchTextChanged); - connect(m_searchLine, SIGNAL(returnPressed()), - this, SLOT(slotReturnPressed())); + connect(m_searchLine, &QLineEdit::textChanged, this, &SearchWidget::searchTextChanged); + connect(m_searchLine, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed())); mainlay->addWidget(m_searchLine); } SearchWidget::~SearchWidget() { - delete m_searchLine; - delete m_timer; + delete m_searchLine; + delete m_timer; } void SearchWidget::giveFocus() @@ -45,7 +45,7 @@ void SearchWidget::giveFocus() m_searchLine->setCursorPosition(m_searchLine->text().length()); } -void SearchWidget::searchTextChanged(const QString&) +void SearchWidget::searchTextChanged(const QString &) { if (m_timer) { m_timer->stop(); diff --git a/src/searchwidget.h b/src/searchwidget.h index 7f5bb56c1b5f5d8199ce19b11c453156cea08091..877fb597cb7823c27dc4306a2a0afe5e59ea5297 100644 --- a/src/searchwidget.h +++ b/src/searchwidget.h @@ -32,7 +32,7 @@ public: void giveFocus(); private Q_SLOTS: - void searchTextChanged(const QString& text); + void searchTextChanged(const QString &text); void slotReturnPressed(); void doSearch(); diff --git a/src/settings/isotopetablesettingscard.cpp b/src/settings/isotopetablesettingscard.cpp index 96cad9bd168f8a47a8a8118a2291d2eac44630a0..f75a0a0d4d1a50352503199709f1050e1d329bb2 100644 --- a/src/settings/isotopetablesettingscard.cpp +++ b/src/settings/isotopetablesettingscard.cpp @@ -8,19 +8,22 @@ #include -IsotopeTableSettingsCard::IsotopeTableSettingsCard(QWidget* parent, int mode): QFrame(parent) +IsotopeTableSettingsCard::IsotopeTableSettingsCard(QWidget *parent, int mode) + : QFrame(parent) { m_isotopeView = new IsotopeView(this, mode); initialize(); } -IsotopeTableSettingsCard::IsotopeTableSettingsCard(QWidget* parent): QFrame(parent) +IsotopeTableSettingsCard::IsotopeTableSettingsCard(QWidget *parent) + : QFrame(parent) { m_isotopeView = new IsotopeView(this); initialize(); } -void IsotopeTableSettingsCard::initialize() { +void IsotopeTableSettingsCard::initialize() +{ QVBoxLayout *vLayout = new QVBoxLayout(); m_isotopeView->setInteractive(false); @@ -30,7 +33,7 @@ void IsotopeTableSettingsCard::initialize() { m_radioButton = new QRadioButton(); m_radioButton->setText("Next to each other"); - connect(m_radioButton, &QRadioButton::toggled, this, [=](){ + connect(m_radioButton, &QRadioButton::toggled, this, [=]() { if (m_radioButton->isChecked()) emit checked(m_isotopeView->mode()); }); @@ -46,7 +49,8 @@ void IsotopeTableSettingsCard::initialize() { setFocusProxy(m_radioButton); } -bool IsotopeTableSettingsCard::eventFilter(QObject *object, QEvent *event) { +bool IsotopeTableSettingsCard::eventFilter(QObject *object, QEvent *event) +{ Q_UNUSED(object); if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) { QMouseEvent *mouseEvent = static_cast(event); diff --git a/src/settings/isotopetablesettingscard.h b/src/settings/isotopetablesettingscard.h index e080500f4a746284261296139a589a985db5d84d..ca95efe3a06600821286617cf07bdffc305a6b4e 100644 --- a/src/settings/isotopetablesettingscard.h +++ b/src/settings/isotopetablesettingscard.h @@ -5,24 +5,27 @@ #ifndef ISOTOPETABLESETTINGSCARD_H #define ISOTOPETABLESETTINGSCARD_H +#include "isotopeview.h" #include #include -#include "isotopeview.h" class IsotopeTableSettingsCard : public QFrame { -Q_OBJECT + Q_OBJECT public: explicit IsotopeTableSettingsCard(QWidget *parent = nullptr); IsotopeTableSettingsCard(QWidget *parent, int mode); - QString text() const { + QString text() const + { return m_radioButton->text(); } - int mode() const { + int mode() const + { return m_isotopeView->mode(); } - bool isChecked() const { + bool isChecked() const + { return m_radioButton->isChecked(); } @@ -34,19 +37,24 @@ private: QRadioButton *m_radioButton; public Q_SLOTS: - void setText(QString text) { + void setText(QString text) + { m_radioButton->setText(text); } - void setMode(int mode) { + void setMode(int mode) + { m_isotopeView->setMode(mode); } - void setZoom(qreal zoom) { + void setZoom(qreal zoom) + { m_isotopeView->setZoom(zoom); } - void setChecked(bool checked) { + void setChecked(bool checked) + { m_radioButton->setChecked(checked); } - void setRadioButtonObjectName(QString name) { + void setRadioButtonObjectName(QString name) + { m_radioButton->setObjectName(name); } @@ -55,7 +63,6 @@ Q_SIGNALS: protected: bool eventFilter(QObject *object, QEvent *event) override; - }; #endif // ISOTOPETABLESETTINGSCARD_H diff --git a/src/settings/isotopetablesettingsdialog.cpp b/src/settings/isotopetablesettingsdialog.cpp index 10de3f4adf36ef801c7643151af9fa54b05dbba7..d3abf5d32826b83e0cad827cd9ec70fcc7d747a3 100644 --- a/src/settings/isotopetablesettingsdialog.cpp +++ b/src/settings/isotopetablesettingsdialog.cpp @@ -5,13 +5,14 @@ #include "isotopetablesettingsdialog.h" #include -#include #include +#include #include #include -IsotopeTableSettingsDialog::IsotopeTableSettingsDialog(QWidget *parent) : QWidget(parent) +IsotopeTableSettingsDialog::IsotopeTableSettingsDialog(QWidget *parent) + : QWidget(parent) { m_mode = Prefs::isotopeTableMode(); @@ -70,8 +71,7 @@ void IsotopeTableSettingsDialog::setMode(int mode) { m_mode = mode; unsigned short i = 0; - for (auto card : m_cards) - { + for (auto card : m_cards) { if (i != m_mode) card->setChecked(false); i++; diff --git a/src/settings/isotopetablesettingsdialog.h b/src/settings/isotopetablesettingsdialog.h index 0942141ae981e67ceed86216c1bd0410a5cfd68e..084bd378006b80c5d434b095cf663cc97ea7a7d3 100644 --- a/src/settings/isotopetablesettingsdialog.h +++ b/src/settings/isotopetablesettingsdialog.h @@ -5,22 +5,23 @@ #ifndef ISOTOPETABLESETTINGSDIALOG_H #define ISOTOPETABLESETTINGSDIALOG_H -#include -#include "kalziumunitcombobox.h" #include "isotopetablesettingscard.h" #include "isotopeview.h" +#include "kalziumunitcombobox.h" #include "prefs.h" +#include -class IsotopeTableSettingsDialog: public QWidget +class IsotopeTableSettingsDialog : public QWidget { -Q_OBJECT + Q_OBJECT public: - explicit IsotopeTableSettingsDialog(QWidget* parent); + explicit IsotopeTableSettingsDialog(QWidget *parent); virtual ~IsotopeTableSettingsDialog(); bool hasChanged() const; bool isDefault() const; - int getMode() const { + int getMode() const + { return m_mode; } @@ -33,7 +34,6 @@ public Q_SLOTS: Q_SIGNALS: void modeChanged(int mode); - }; #endif // ISOTOPETABLESETTINGSDIALOG_H diff --git a/src/settings/kalziumconfigdialog.cpp b/src/settings/kalziumconfigdialog.cpp index 1b3549903fb3b5e64b404565678e0b5897100285..2cc1e9ecfe0c9453ab3d7ac1e37db56782e3beab 100644 --- a/src/settings/kalziumconfigdialog.cpp +++ b/src/settings/kalziumconfigdialog.cpp @@ -1,10 +1,11 @@ #include "kalziumconfigdialog.h" +#include "ui_settings_calc.h" #include "ui_settings_colors.h" #include "ui_settings_gradients.h" -#include "ui_settings_calc.h" -KalziumConfigDialog::KalziumConfigDialog(QWidget *parent, const QString &name, KCoreConfigSkeleton *config) : KConfigDialog(parent, name, config) +KalziumConfigDialog::KalziumConfigDialog(QWidget *parent, const QString &name, KCoreConfigSkeleton *config) + : KConfigDialog(parent, name, config) { // colors page Ui_setupColors ui_colors; diff --git a/src/settings/kalziumconfigdialog.h b/src/settings/kalziumconfigdialog.h index 0d0845358cda0ff9bfb1d5d162e027e460a3e64f..d37ae10a0e398bc51ada42cca7b8a09050933624 100644 --- a/src/settings/kalziumconfigdialog.h +++ b/src/settings/kalziumconfigdialog.h @@ -3,12 +3,12 @@ #include -#include "unitsettingsdialog.h" #include "isotopetablesettingsdialog.h" +#include "unitsettingsdialog.h" class KalziumConfigDialog : public KConfigDialog { -Q_OBJECT + Q_OBJECT public: KalziumConfigDialog(QWidget *parent, const QString &name, KCoreConfigSkeleton *config); @@ -20,8 +20,8 @@ private: bool hasChanged() override; bool isDefault() override; -private Q_SLOT: - void updateWidgetsDefault() override; +private + Q_SLOT : void updateWidgetsDefault() override; void updateSettings() override; }; diff --git a/src/settings/unitsettingsdialog.cpp b/src/settings/unitsettingsdialog.cpp index 7fca6c8b23df6e0899af8bc286da6f4474c88e3d..60ceaed5a6981dd499ae74438f16d8c7b1475d58 100644 --- a/src/settings/unitsettingsdialog.cpp +++ b/src/settings/unitsettingsdialog.cpp @@ -12,12 +12,12 @@ #include #include -UnitSettingsDialog::UnitSettingsDialog(QWidget* parent) : QWidget(parent) +UnitSettingsDialog::UnitSettingsDialog(QWidget *parent) + : QWidget(parent) { QLabel *labelEnergy = new QLabel(i18n("Energy:"), this); QList energy; - energy << KUnitConversion::Electronvolt << KUnitConversion::KiloJoulePerMole << - KUnitConversion::JoulePerMole << KUnitConversion::Joule; + energy << KUnitConversion::Electronvolt << KUnitConversion::KiloJoulePerMole << KUnitConversion::JoulePerMole << KUnitConversion::Joule; m_comboBoxLEnergiesUnit = new KalziumUnitCombobox(energy, this); m_comboBoxLEnergiesUnit->setObjectName(QStringLiteral("kcfg_combobox_energies")); @@ -29,8 +29,7 @@ UnitSettingsDialog::UnitSettingsDialog(QWidget* parent) : QWidget(parent) QLabel *labelTemperature = new QLabel(i18n("Temperature:"), this); QList temperature; - temperature << KUnitConversion::Kelvin << KUnitConversion::Celsius << KUnitConversion::Fahrenheit << - KUnitConversion::Reaumur; + temperature << KUnitConversion::Kelvin << KUnitConversion::Celsius << KUnitConversion::Fahrenheit << KUnitConversion::Reaumur; m_comboBoxLTemperatureUnit = new KalziumUnitCombobox(temperature, this); m_comboBoxLTemperatureUnit->setObjectName(QStringLiteral("kcfg_combobox_temperature")); diff --git a/src/settings/unitsettingsdialog.h b/src/settings/unitsettingsdialog.h index 6298767c43632b63c4aada473d96d36d0b9f187d..af0c0fba7bb046695f281cf1512b16b8113a12c8 100644 --- a/src/settings/unitsettingsdialog.h +++ b/src/settings/unitsettingsdialog.h @@ -7,13 +7,13 @@ #ifndef UNITSETTINGSDIALOG_H #define UNITSETTINGSDIALOG_H -#include #include "kalziumunitcombobox.h" +#include -class UnitSettingsDialog: public QWidget +class UnitSettingsDialog : public QWidget { public: - explicit UnitSettingsDialog(QWidget* parent = nullptr); + explicit UnitSettingsDialog(QWidget *parent = nullptr); virtual ~UnitSettingsDialog(); int getLenghtUnitId() const; @@ -26,7 +26,6 @@ private: KalziumUnitCombobox *m_comboBoxLengthUnit; KalziumUnitCombobox *m_comboBoxLEnergiesUnit; KalziumUnitCombobox *m_comboBoxLTemperatureUnit; - }; #endif // UNITSETTINGSDIALOG_H diff --git a/src/spectrumviewimpl.cpp b/src/spectrumviewimpl.cpp index 54062ddabebd01c63006da5defc6a0ccd5605fb6..ab835af9c5897471356d7637b906961a21b224c3 100644 --- a/src/spectrumviewimpl.cpp +++ b/src/spectrumviewimpl.cpp @@ -15,7 +15,8 @@ #include "kalziumdataobject.h" #include "prefs.h" -SpectrumViewImpl::SpectrumViewImpl(QWidget *parent) : QWidget(parent) +SpectrumViewImpl::SpectrumViewImpl(QWidget *parent) + : QWidget(parent) { setupUi(this); @@ -31,23 +32,17 @@ SpectrumViewImpl::SpectrumViewImpl(QWidget *parent) : QWidget(parent) m_spectrumType->setCurrentIndex(Prefs::spectrumType()); - connect(minimumValue, SIGNAL(valueChanged(int)), - this, SLOT(updateMin(int))); - connect(maximumValue, SIGNAL(valueChanged(int)), - this, SLOT(updateMax(int))); - connect(m_spectrumWidget, &SpectrumWidget::bordersChanged, - this, &SpectrumViewImpl::updateUI); - connect(m_spectrumWidget, &SpectrumWidget::peakSelected, - this, &SpectrumViewImpl::updatePeakInformation); + connect(minimumValue, SIGNAL(valueChanged(int)), this, SLOT(updateMin(int))); + connect(maximumValue, SIGNAL(valueChanged(int)), this, SLOT(updateMax(int))); + connect(m_spectrumWidget, &SpectrumWidget::bordersChanged, this, &SpectrumViewImpl::updateUI); + connect(m_spectrumWidget, &SpectrumWidget::peakSelected, this, &SpectrumViewImpl::updatePeakInformation); - connect(m_spectrumType, SIGNAL(currentIndexChanged(int)), - m_spectrumWidget, SLOT(slotActivateSpectrum(int))); + connect(m_spectrumType, SIGNAL(currentIndexChanged(int)), m_spectrumWidget, SLOT(slotActivateSpectrum(int))); connect(btn_resetZoom, &QAbstractButton::pressed, m_spectrumWidget, &SpectrumWidget::resetSpectrum); connect(this, &SpectrumViewImpl::settingsChanged, m_spectrumWidget, &SpectrumWidget::resetSpectrum); - connect(m_lengthUnit, SIGNAL(currentIndexChanged(int)), - this, SLOT(setUnit())); + connect(m_lengthUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(setUnit())); resize(minimumSizeHint()); } @@ -59,14 +54,13 @@ void SpectrumViewImpl::fillPeakList() QList items; for (int i = 0; i < m_spectrumWidget->spectrum()->peaklist().count(); ++i) { - Spectrum::peak * peak = m_spectrumWidget->spectrum()->peaklist().at(i); + Spectrum::peak *peak = m_spectrumWidget->spectrum()->peaklist().at(i); double peakWavelength = peak->wavelengthToUnit(Prefs::spectrumWavelengthUnit()); - QStringList row = QStringList() << QString::number(peakWavelength) - << QString::number(peak->intensity); + QStringList row = QStringList() << QString::number(peakWavelength) << QString::number(peak->intensity); - items.append(new QTreeWidgetItem((QTreeWidget*)nullptr, row)); + items.append(new QTreeWidgetItem((QTreeWidget *)nullptr, row)); } peakListTable->insertTopLevelItems(0, items); } @@ -75,24 +69,21 @@ void SpectrumViewImpl::updateUI(int l, int r) { minimumValue->setValue(l); maximumValue->setValue(r); - minimumValue->setSuffix(KalziumDataObject::instance()->unitAsString( - Prefs::spectrumWavelengthUnit())); - maximumValue->setSuffix(KalziumDataObject::instance()->unitAsString( - Prefs::spectrumWavelengthUnit())); + minimumValue->setSuffix(KalziumDataObject::instance()->unitAsString(Prefs::spectrumWavelengthUnit())); + maximumValue->setSuffix(KalziumDataObject::instance()->unitAsString(Prefs::spectrumWavelengthUnit())); } void SpectrumViewImpl::updatePeakInformation(Spectrum::peak *peak) { double peakWavelength = peak->wavelengthToUnit(Prefs::spectrumWavelengthUnit()); - const QList foundItems = peakListTable->findItems(QString::number(peakWavelength), - Qt::MatchExactly); + const QList foundItems = peakListTable->findItems(QString::number(peakWavelength), Qt::MatchExactly); if (foundItems.isEmpty()) { return; } - foreach (QTreeWidgetItem * item, peakListTable->selectedItems()) + foreach (QTreeWidgetItem *item, peakListTable->selectedItems()) item->setSelected(false); foundItems.first()->setSelected(true); @@ -120,4 +111,3 @@ void SpectrumViewImpl::updateMax(int right) m_spectrumWidget->setLeftBorder(minimumValue->value()); m_spectrumWidget->setRightBorder(right); } - diff --git a/src/spectrumviewimpl.h b/src/spectrumviewimpl.h index 8d4e919e3685fb84a9dd713cc7efef436c9d2f8a..0ae0536e16b71956c4852c422c6a34fdf8664523 100644 --- a/src/spectrumviewimpl.h +++ b/src/spectrumviewimpl.h @@ -21,13 +21,13 @@ public: /** * @param parent the parent widget */ - explicit SpectrumViewImpl(QWidget* parent); + explicit SpectrumViewImpl(QWidget *parent); /** * sets the spectrum to @p spec * @param spec the spectrum to display */ - void setSpectrum(Spectrum* spec) + void setSpectrum(Spectrum *spec) { m_spectrumWidget->setSpectrum(spec); @@ -48,7 +48,7 @@ private Q_SLOTS: */ void updateUI(int left, int right); - void updatePeakInformation(Spectrum::peak * peak); + void updatePeakInformation(Spectrum::peak *peak); void setUnit(); diff --git a/src/spectrumwidget.cpp b/src/spectrumwidget.cpp index e2b1e3facc0e9a8cae17a64f4539827985bd9536..5bbffe94f46aaead3e90a5d1686bb057f272a7c6 100644 --- a/src/spectrumwidget.cpp +++ b/src/spectrumwidget.cpp @@ -6,8 +6,8 @@ #include "spectrumwidget.h" -#include "spectrum.h" #include "kalziumutils.h" +#include "spectrum.h" #include @@ -27,7 +27,8 @@ #include #endif -SpectrumWidget::SpectrumWidget(QWidget *parent) : QWidget(parent) +SpectrumWidget::SpectrumWidget(QWidget *parent) + : QWidget(parent) { m_startValue = 0; m_endValue = 0; @@ -75,17 +76,15 @@ void SpectrumWidget::paintEvent(QPaintEvent * /*e*/) p2.drawPixmap(0, 0, m_pixmap); } -void SpectrumWidget::drawZoomLine(QPainter* p) +void SpectrumWidget::drawZoomLine(QPainter *p) { p->setPen(Qt::white); p->drawLine(m_LMBPointPress.x(), m_LMBPointPress.y(), m_LMBPointCurrent.x(), m_LMBPointPress.y()); - p->drawLine(m_LMBPointCurrent.x(), m_LMBPointPress.y() + 10, m_LMBPointCurrent.x(), - m_LMBPointPress.y() - 10); - p->drawLine(m_LMBPointPress.x(), m_LMBPointPress.y() + 10, m_LMBPointPress.x(), - m_LMBPointPress.y() - 10); + p->drawLine(m_LMBPointCurrent.x(), m_LMBPointPress.y() + 10, m_LMBPointCurrent.x(), m_LMBPointPress.y() - 10); + p->drawLine(m_LMBPointPress.x(), m_LMBPointPress.y() + 10, m_LMBPointPress.x(), m_LMBPointPress.y() - 10); } -void SpectrumWidget::paintBands(QPainter* p) +void SpectrumWidget::paintBands(QPainter *p) { if (m_type == AbsorptionSpectrum) { for (double va = m_startValue; va <= m_endValue; va += 0.1) { @@ -134,8 +133,7 @@ QColor SpectrumWidget::wavelengthToRGB(double wavelength) double blue = 0.0, green = 0.0, red = 0.0, factor = 0.0; // wavelengthTo RGB function works with nanometers. - wavelength = KUnitConversion::Value(wavelength,KUnitConversion::UnitId(Prefs::spectrumWavelengthUnit())) - .convertTo(KUnitConversion::Nanometer).number(); + wavelength = KUnitConversion::Value(wavelength, KUnitConversion::UnitId(Prefs::spectrumWavelengthUnit())).convertTo(KUnitConversion::Nanometer).number(); int wavelength_ = (int)floor(wavelength); @@ -177,9 +175,7 @@ QColor SpectrumWidget::wavelengthToRGB(double wavelength) factor = 0.0; } - return QColor(Adjust(red, factor), - Adjust(green, factor), - Adjust(blue, factor)); + return QColor(Adjust(red, factor), Adjust(green, factor), Adjust(blue, factor)); } int SpectrumWidget::Adjust(double color, double /*factor*/) @@ -187,37 +183,34 @@ int SpectrumWidget::Adjust(double color, double /*factor*/) if (color == 0.0) { return 0; } else { -// return qRound(m_intensityMax * pow(color*factor, m_gamma)); FIXME + // return qRound(m_intensityMax * pow(color*factor, m_gamma)); FIXME return m_intensityMax * color; } } -void SpectrumWidget::drawTickmarks(QPainter* p) +void SpectrumWidget::drawTickmarks(QPainter *p) { - //the size of the text on the tickmarks + // the size of the text on the tickmarks const int space = 20; - //the distance between the tickmarks in pixel + // the distance between the tickmarks in pixel const int d = 10; - //the total number of tickmarks to draw (small and long) + // the total number of tickmarks to draw (small and long) const int numberOfTickmarks = (int)floor((double)(width() / d)); double pos = 0.0; for (int i = 0; i < numberOfTickmarks; ++i) { if (i % 5 == 0) { - //long tickmarks plus text + // long tickmarks plus text p->drawLine(i * d, m_realHeight, i * d, m_realHeight + 10); - if (i % 10 == 0 && - i * d > space && - i * d < width() - space) { + if (i % 10 == 0 && i * d > space && i * d < width() - space) { pos = (double)(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)))); + p->drawText(i * d - space, m_realHeight + 12, 2 * space, 15, Qt::AlignCenter, QString::number(KalziumUtils::strippedValue(Wavelength(pos)))); } - } else { //small tickmarks + } else { // small tickmarks p->drawLine(i * d, m_realHeight, i * d, m_realHeight + 5); } } @@ -246,12 +239,12 @@ void SpectrumWidget::slotZoomOut() m_endValue = m_endValue + offset; m_startValue = m_startValue - offset; - //check for invalid values + // check for invalid values if (m_startValue < 0.0) { m_startValue = 0.0; } - if (m_endValue > 10000.0) { // FIXME: Magic numbers... + if (m_endValue > 10000.0) { // FIXME: Magic numbers... m_endValue = 40000.0; } @@ -265,7 +258,7 @@ void SpectrumWidget::setBorders(double left, double right) m_startValue = left; m_endValue = right; - //round the startValue down and the endValue up + // round the startValue down and the endValue up Q_EMIT bordersChanged(int(m_startValue + 0.5), int(m_endValue + 0.5)); update(); @@ -308,12 +301,12 @@ void SpectrumWidget::findPeakFromMouseposition(double wavelength) qCDebug(KALZIUM_LOG) << "SpectrumWidget::findPeakFromMouseposition()"; Spectrum::peak *peak = nullptr; - //find the difference in percent (1.0 is 100%, 0.1 is 10%) + // find the difference in percent (1.0 is 100%, 0.1 is 10%) double dif = 0.0; bool foundWavelength = false; - //find the highest intensity + // find the highest intensity foreach (Spectrum::peak *currentPeak, m_spectrum->peaklist()) { double currentWavelength = currentPeak->wavelengthToUnit(Prefs::spectrumWavelengthUnit()); @@ -323,7 +316,7 @@ void SpectrumWidget::findPeakFromMouseposition(double wavelength) continue; } - if (thisdif > 1.0) { //convert for example 1.3 to 0.7 + if (thisdif > 1.0) { // convert for example 1.3 to 0.7 thisdif = thisdif - 1; thisdif = 1 - thisdif; } @@ -361,7 +354,7 @@ void SpectrumWidget::mouseReleaseEvent(QMouseEvent *e) m_LMBPointCurrent.setX(-1); } -void SpectrumWidget::setSpectrum(Spectrum* spec) +void SpectrumWidget::setSpectrum(Spectrum *spec) { m_spectrum = spec; resetSpectrum(); @@ -369,12 +362,10 @@ void SpectrumWidget::setSpectrum(Spectrum* spec) void SpectrumWidget::resetSpectrum() { - //set the minimum and maximum peak to the min/max wavelength - //plus/minus ten. This makes then always visible + // set the minimum and maximum peak to the min/max wavelength + // plus/minus ten. This makes then always visible double minimumPeak = m_spectrum->minPeak(Prefs::spectrumWavelengthUnit()) - 20.0; double maximumPeak = m_spectrum->maxPeak(Prefs::spectrumWavelengthUnit()) + 20.0; setBorders(minimumPeak, maximumPeak); } - - diff --git a/src/spectrumwidget.h b/src/spectrumwidget.h index da5b3a04206be2d8100e2e4f4261e02c32141186..4f642af490c0a54df9c278f62adf9738f782bd33 100644 --- a/src/spectrumwidget.h +++ b/src/spectrumwidget.h @@ -9,8 +9,8 @@ #include -#include "spectrum.h" #include "prefs.h" +#include "spectrum.h" /** * @author Carsten Niehaus @@ -22,11 +22,13 @@ class SpectrumWidget : public QWidget public: explicit SpectrumWidget(QWidget *parent); - ~SpectrumWidget() override {} + ~SpectrumWidget() override + { + } - void setSpectrum(Spectrum* spec); + void setSpectrum(Spectrum *spec); - Spectrum* spectrum()const + Spectrum *spectrum() const { return m_spectrum; } @@ -46,7 +48,7 @@ public: */ enum SpectrumType { EmissionSpectrum = 0, - AbsorptionSpectrum + AbsorptionSpectrum, }; /** @@ -100,7 +102,7 @@ public: */ inline double Wavelength(double xpos) { - return m_startValue + ((m_endValue - m_startValue) * xpos); + return m_startValue + ((m_endValue - m_startValue) * xpos); } /** @@ -148,8 +150,8 @@ private: QPixmap m_pixmap; - void paintBands(QPainter* p); - void drawZoomLine(QPainter* p); + void paintBands(QPainter *p); + void drawZoomLine(QPainter *p); /** * Draw the scale @@ -198,7 +200,7 @@ signals: /** * the user selected a peak */ - void peakSelected(Spectrum::peak * peak); + void peakSelected(Spectrum::peak *peak); private Q_SLOTS: void slotZoomIn(); diff --git a/src/tableinfowidget.cpp b/src/tableinfowidget.cpp index 5f2c08649ac554186ab1323723bc1ada6a7f70cc..4d119cbcb328e15445e4440cc9405e44df8abc60 100644 --- a/src/tableinfowidget.cpp +++ b/src/tableinfowidget.cpp @@ -11,15 +11,16 @@ #include -#include "prefs.h" #include "kalziumschemetype.h" +#include "prefs.h" #include "psetables.h" -TableInfoWidget::TableInfoWidget(QWidget *parent) : QWidget(parent) +TableInfoWidget::TableInfoWidget(QWidget *parent) + : QWidget(parent) { m_tableType = new QLabel(QStringLiteral("test"), this); - QHBoxLayout * la = new QHBoxLayout(this); + QHBoxLayout *la = new QHBoxLayout(this); la->addWidget(m_tableType); setLayout(la); } @@ -28,5 +29,3 @@ void TableInfoWidget::setTableType(int type) { m_tableType->setText(pseTables::instance()->getTabletype(type)->description()); } - - diff --git a/src/tableinfowidget.h b/src/tableinfowidget.h index 7912e304f82b955373403acdce95c988649f561e..7c9800c80a1d744cd66304f928bee3710324311f 100644 --- a/src/tableinfowidget.h +++ b/src/tableinfowidget.h @@ -22,7 +22,9 @@ class TableInfoWidget : public QWidget public: explicit TableInfoWidget(QWidget *parent); - ~TableInfoWidget() {} + ~TableInfoWidget() + { + } private: QLabel *m_tableType; diff --git a/src/tablesdialog.cpp b/src/tablesdialog.cpp index 29ed8ed67f05c73fd393eb6350d95b5e3c1f61a8..f4d4a5e0ea6d4249fbe7b7a3101bfcc8dbe3eb98 100644 --- a/src/tablesdialog.cpp +++ b/src/tablesdialog.cpp @@ -23,12 +23,13 @@ #include #include -TablesDialog::TablesDialog(QWidget *parent) : KPageDialog(parent) +TablesDialog::TablesDialog(QWidget *parent) + : KPageDialog(parent) { setFaceType(List); - //setButtons(Help | Close); - //setDefaultButton(Close); + // setButtons(Help | Close); + // setDefaultButton(Close); createGreekSymbolTable(); createNumbersTable(); @@ -48,22 +49,21 @@ void TablesDialog::createGreekSymbolTable() table->setColumnCount(3); table->setRowCount(24); - table->setHorizontalHeaderLabels(QStringList() << i18n("Uppercase") - << i18n("Lowercase") - << i18nc("The name of the greek letter in your language. For example 'Alpha' for the first letter. ", - "Name")); + table->setHorizontalHeaderLabels( + QStringList() << i18n("Uppercase") << i18n("Lowercase") + << i18nc("The name of the greek letter in your language. For example 'Alpha' for the first letter. ", "Name")); layout->addWidget(table); - table->setItem(0, 0, new MyWidgetItem(QString(QChar(913)))); //capital Alpha - table->setItem(1, 0, new MyWidgetItem(QString(QChar(914)))); - table->setItem(2, 0, new MyWidgetItem(QString(QChar(915)))); - table->setItem(3, 0, new MyWidgetItem(QString(QChar(916)))); - table->setItem(4, 0, new MyWidgetItem(QString(QChar(917)))); - table->setItem(5, 0, new MyWidgetItem(QString(QChar(918)))); - table->setItem(6, 0, new MyWidgetItem(QString(QChar(919)))); - table->setItem(7, 0, new MyWidgetItem(QString(QChar(920)))); - table->setItem(8, 0, new MyWidgetItem(QString(QChar(921)))); - table->setItem(9, 0, new MyWidgetItem(QString(QChar(922)))); + table->setItem(0, 0, new MyWidgetItem(QString(QChar(913)))); // capital Alpha + table->setItem(1, 0, new MyWidgetItem(QString(QChar(914)))); + table->setItem(2, 0, new MyWidgetItem(QString(QChar(915)))); + table->setItem(3, 0, new MyWidgetItem(QString(QChar(916)))); + table->setItem(4, 0, new MyWidgetItem(QString(QChar(917)))); + table->setItem(5, 0, new MyWidgetItem(QString(QChar(918)))); + table->setItem(6, 0, new MyWidgetItem(QString(QChar(919)))); + table->setItem(7, 0, new MyWidgetItem(QString(QChar(920)))); + table->setItem(8, 0, new MyWidgetItem(QString(QChar(921)))); + table->setItem(9, 0, new MyWidgetItem(QString(QChar(922)))); table->setItem(10, 0, new MyWidgetItem(QString(QChar(923)))); table->setItem(11, 0, new MyWidgetItem(QString(QChar(924)))); table->setItem(12, 0, new MyWidgetItem(QString(QChar(925)))); @@ -79,17 +79,17 @@ void TablesDialog::createGreekSymbolTable() table->setItem(22, 0, new MyWidgetItem(QString(QChar(936)))); table->setItem(23, 0, new MyWidgetItem(QString(QChar(937)))); - //small letters - table->setItem(0, 1, new MyWidgetItem(QString(QChar(945)))); //small alpha - table->setItem(1, 1, new MyWidgetItem(QString(QChar(946)))); - table->setItem(2, 1, new MyWidgetItem(QString(QChar(947)))); - table->setItem(3, 1, new MyWidgetItem(QString(QChar(948)))); - table->setItem(4, 1, new MyWidgetItem(QString(QChar(949)))); - table->setItem(5, 1, new MyWidgetItem(QString(QChar(950)))); - table->setItem(6, 1, new MyWidgetItem(QString(QChar(951)))); - table->setItem(7, 1, new MyWidgetItem(QString(QChar(952)))); - table->setItem(8, 1, new MyWidgetItem(QString(QChar(953)))); - table->setItem(9, 1, new MyWidgetItem(QString(QChar(954)))); + // small letters + table->setItem(0, 1, new MyWidgetItem(QString(QChar(945)))); // small alpha + table->setItem(1, 1, new MyWidgetItem(QString(QChar(946)))); + table->setItem(2, 1, new MyWidgetItem(QString(QChar(947)))); + table->setItem(3, 1, new MyWidgetItem(QString(QChar(948)))); + table->setItem(4, 1, new MyWidgetItem(QString(QChar(949)))); + table->setItem(5, 1, new MyWidgetItem(QString(QChar(950)))); + table->setItem(6, 1, new MyWidgetItem(QString(QChar(951)))); + table->setItem(7, 1, new MyWidgetItem(QString(QChar(952)))); + table->setItem(8, 1, new MyWidgetItem(QString(QChar(953)))); + table->setItem(9, 1, new MyWidgetItem(QString(QChar(954)))); table->setItem(10, 1, new MyWidgetItem(QString(QChar(955)))); table->setItem(11, 1, new MyWidgetItem(QString(QChar(956)))); table->setItem(12, 1, new MyWidgetItem(QString(QChar(957)))); @@ -97,7 +97,7 @@ void TablesDialog::createGreekSymbolTable() table->setItem(14, 1, new MyWidgetItem(QString(QChar(959)))); table->setItem(15, 1, new MyWidgetItem(QString(QChar(960)))); table->setItem(16, 1, new MyWidgetItem(QString(QChar(961)))); - //there are two greek letters for sigma + // there are two greek letters for sigma table->setItem(17, 1, new MyWidgetItem(QString(QChar(962)) + ", " + QString(QChar(963)))); table->setItem(18, 1, new MyWidgetItem(QString(QChar(964)))); table->setItem(19, 1, new MyWidgetItem(QString(QChar(965)))); @@ -106,17 +106,17 @@ void TablesDialog::createGreekSymbolTable() table->setItem(22, 1, new MyWidgetItem(QString(QChar(968)))); table->setItem(23, 1, new MyWidgetItem(QString(QChar(969)))); - //english names - table->setItem(0, 2, new MyWidgetItem(i18n("alpha"))); - table->setItem(1, 2, new MyWidgetItem(i18n("beta"))); - table->setItem(2, 2, new MyWidgetItem(i18n("gamma"))); - table->setItem(3, 2, new MyWidgetItem(i18n("delta"))); - table->setItem(4, 2, new MyWidgetItem(i18n("epsilon"))); - table->setItem(5, 2, new MyWidgetItem(i18n("zeta"))); - table->setItem(6, 2, new MyWidgetItem(i18n("eta"))); - table->setItem(7, 2, new MyWidgetItem(i18n("theta"))); - table->setItem(8, 2, new MyWidgetItem(i18n("iota"))); - table->setItem(9, 2, new MyWidgetItem(i18n("kappa"))); + // english names + table->setItem(0, 2, new MyWidgetItem(i18n("alpha"))); + table->setItem(1, 2, new MyWidgetItem(i18n("beta"))); + table->setItem(2, 2, new MyWidgetItem(i18n("gamma"))); + table->setItem(3, 2, new MyWidgetItem(i18n("delta"))); + table->setItem(4, 2, new MyWidgetItem(i18n("epsilon"))); + table->setItem(5, 2, new MyWidgetItem(i18n("zeta"))); + table->setItem(6, 2, new MyWidgetItem(i18n("eta"))); + table->setItem(7, 2, new MyWidgetItem(i18n("theta"))); + table->setItem(8, 2, new MyWidgetItem(i18n("iota"))); + table->setItem(9, 2, new MyWidgetItem(i18n("kappa"))); table->setItem(10, 2, new MyWidgetItem(i18n("lambda"))); table->setItem(11, 2, new MyWidgetItem(i18n("mu"))); table->setItem(12, 2, new MyWidgetItem(i18n("nu"))); @@ -133,8 +133,7 @@ void TablesDialog::createGreekSymbolTable() table->setItem(23, 2, new MyWidgetItem(i18n("omega"))); table->resizeColumnsToContents(); - frame->setMinimumWidth(qMax(table->columnWidth(0) + table->columnWidth(1) + table->columnWidth(2), - table->horizontalHeader()->sizeHint().width()) + 25); + frame->setMinimumWidth(qMax(table->columnWidth(0) + table->columnWidth(1) + table->columnWidth(2), table->horizontalHeader()->sizeHint().width()) + 25); } void TablesDialog::createNumbersTable() @@ -151,21 +150,20 @@ void TablesDialog::createNumbersTable() table->setColumnCount(3); table->setRowCount(28); - table->setHorizontalHeaderLabels(QStringList() << i18n("Number") << - i18nc("For example 'Mono' for 1 and 'Tri' for 3", "Prefix") << i18n("Roman Numerals")); + table->setHorizontalHeaderLabels(QStringList() << i18n("Number") << i18nc("For example 'Mono' for 1 and 'Tri' for 3", "Prefix") << i18n("Roman Numerals")); layout->addWidget(table); - table->setItem(0, 0, new MyWidgetItem(i18n("0.5"))); - table->setItem(1, 0, new MyWidgetItem(i18n("1"))); - table->setItem(2, 0, new MyWidgetItem(i18n("1.5"))); - table->setItem(3, 0, new MyWidgetItem(i18n("2"))); - table->setItem(4, 0, new MyWidgetItem(i18n("2.5"))); - table->setItem(5, 0, new MyWidgetItem(i18n("3"))); - table->setItem(6, 0, new MyWidgetItem(i18n("4"))); - table->setItem(7, 0, new MyWidgetItem(i18n("5"))); - table->setItem(8, 0, new MyWidgetItem(i18n("6"))); - table->setItem(9, 0, new MyWidgetItem(i18n("7"))); + table->setItem(0, 0, new MyWidgetItem(i18n("0.5"))); + table->setItem(1, 0, new MyWidgetItem(i18n("1"))); + table->setItem(2, 0, new MyWidgetItem(i18n("1.5"))); + table->setItem(3, 0, new MyWidgetItem(i18n("2"))); + table->setItem(4, 0, new MyWidgetItem(i18n("2.5"))); + table->setItem(5, 0, new MyWidgetItem(i18n("3"))); + table->setItem(6, 0, new MyWidgetItem(i18n("4"))); + table->setItem(7, 0, new MyWidgetItem(i18n("5"))); + table->setItem(8, 0, new MyWidgetItem(i18n("6"))); + table->setItem(9, 0, new MyWidgetItem(i18n("7"))); table->setItem(10, 0, new MyWidgetItem(i18n("8"))); table->setItem(11, 0, new MyWidgetItem(i18n("9"))); table->setItem(12, 0, new MyWidgetItem(i18n("10"))); @@ -185,17 +183,17 @@ void TablesDialog::createNumbersTable() table->setItem(26, 0, new MyWidgetItem(i18n("90"))); table->setItem(27, 0, new MyWidgetItem(i18n("100"))); - //greek names of the numbers - table->setItem(0, 1, new MyWidgetItem(QStringLiteral("hemi"))); - table->setItem(1, 1, new MyWidgetItem(QStringLiteral("mono"))); - table->setItem(2, 1, new MyWidgetItem(QStringLiteral("sesqui"))); - table->setItem(3, 1, new MyWidgetItem(QStringLiteral("di, bi"))); - table->setItem(4, 1, new MyWidgetItem(QStringLiteral("hemipenta"))); - table->setItem(5, 1, new MyWidgetItem(QStringLiteral("tri"))); - table->setItem(6, 1, new MyWidgetItem(QStringLiteral("tetra"))); - table->setItem(7, 1, new MyWidgetItem(QStringLiteral("penta"))); - table->setItem(8, 1, new MyWidgetItem(QStringLiteral("hexa"))); - table->setItem(9, 1, new MyWidgetItem(QStringLiteral("hepta"))); + // greek names of the numbers + table->setItem(0, 1, new MyWidgetItem(QStringLiteral("hemi"))); + table->setItem(1, 1, new MyWidgetItem(QStringLiteral("mono"))); + table->setItem(2, 1, new MyWidgetItem(QStringLiteral("sesqui"))); + table->setItem(3, 1, new MyWidgetItem(QStringLiteral("di, bi"))); + table->setItem(4, 1, new MyWidgetItem(QStringLiteral("hemipenta"))); + table->setItem(5, 1, new MyWidgetItem(QStringLiteral("tri"))); + table->setItem(6, 1, new MyWidgetItem(QStringLiteral("tetra"))); + table->setItem(7, 1, new MyWidgetItem(QStringLiteral("penta"))); + table->setItem(8, 1, new MyWidgetItem(QStringLiteral("hexa"))); + table->setItem(9, 1, new MyWidgetItem(QStringLiteral("hepta"))); table->setItem(10, 1, new MyWidgetItem(QStringLiteral("octa"))); table->setItem(11, 1, new MyWidgetItem(QStringLiteral("nona, ennea"))); table->setItem(12, 1, new MyWidgetItem(QStringLiteral("deca"))); @@ -215,14 +213,14 @@ void TablesDialog::createNumbersTable() table->setItem(26, 1, new MyWidgetItem(QStringLiteral("nonaconta"))); table->setItem(27, 1, new MyWidgetItem(QStringLiteral("hecta"))); - //roman symbols - table->setItem(1, 2, new MyWidgetItem(QStringLiteral("I"))); - table->setItem(3, 2, new MyWidgetItem(QStringLiteral("II"))); - table->setItem(5, 2, new MyWidgetItem(QStringLiteral("III"))); - table->setItem(6, 2, new MyWidgetItem(QStringLiteral("IV"))); - table->setItem(7, 2, new MyWidgetItem(QStringLiteral("V"))); - table->setItem(8, 2, new MyWidgetItem(QStringLiteral("VI"))); - table->setItem(9, 2, new MyWidgetItem(QStringLiteral("VII"))); + // roman symbols + table->setItem(1, 2, new MyWidgetItem(QStringLiteral("I"))); + table->setItem(3, 2, new MyWidgetItem(QStringLiteral("II"))); + table->setItem(5, 2, new MyWidgetItem(QStringLiteral("III"))); + table->setItem(6, 2, new MyWidgetItem(QStringLiteral("IV"))); + table->setItem(7, 2, new MyWidgetItem(QStringLiteral("V"))); + table->setItem(8, 2, new MyWidgetItem(QStringLiteral("VI"))); + table->setItem(9, 2, new MyWidgetItem(QStringLiteral("VII"))); table->setItem(10, 2, new MyWidgetItem(QStringLiteral("VIII"))); table->setItem(11, 2, new MyWidgetItem(QStringLiteral("IX"))); table->setItem(12, 2, new MyWidgetItem(QStringLiteral("X"))); @@ -243,22 +241,21 @@ void TablesDialog::createNumbersTable() table->setItem(27, 2, new MyWidgetItem(QStringLiteral("C"))); table->resizeColumnsToContents(); - frame->setMinimumWidth(qMax(table->columnWidth(0) + table->columnWidth(1) + table->columnWidth(2), - table->horizontalHeader()->sizeHint().width()) + 25); - + frame->setMinimumWidth(qMax(table->columnWidth(0) + table->columnWidth(1) + table->columnWidth(2), table->horizontalHeader()->sizeHint().width()) + 25); } TablesDialog::~TablesDialog() { } -MyTableWidget::MyTableWidget(QWidget* parent) : QTableWidget(parent) +MyTableWidget::MyTableWidget(QWidget *parent) + : QTableWidget(parent) { } -void MyTableWidget::contextMenuEvent(QContextMenuEvent* event) +void MyTableWidget::contextMenuEvent(QContextMenuEvent *event) { - QMenu* menu = new QMenu((QWidget*) sender()); + QMenu *menu = new QMenu((QWidget *)sender()); menu->addAction(i18n("&Copy"), this, &MyTableWidget::copyToClipboard, QKeySequence(Qt::Key_C | Qt::CTRL)); menu->exec(event->globalPos()); } @@ -267,4 +264,3 @@ void MyTableWidget::copyToClipboard() { QApplication::clipboard()->setText(currentItem()->data(QTableWidgetItem::Type).toString()); } - diff --git a/src/tablesdialog.h b/src/tablesdialog.h index 36edd4ea1d07e3fc48734320c9313465933e6f12..bdda6362fb2060e5a94d07fba7e2b96e79fb99bb 100644 --- a/src/tablesdialog.h +++ b/src/tablesdialog.h @@ -34,11 +34,11 @@ public: class MyWidgetItem : public QTableWidgetItem { public: - explicit MyWidgetItem(const QString& s) : QTableWidgetItem(s) + explicit MyWidgetItem(const QString &s) + : QTableWidgetItem(s) { setFlags(Qt::ItemIsEnabled); } - }; /** @@ -50,9 +50,10 @@ class MyTableWidget : public QTableWidget Q_OBJECT public: - explicit MyTableWidget(QWidget* parent); + explicit MyTableWidget(QWidget *parent); + protected: - void contextMenuEvent(QContextMenuEvent* event) override; + void contextMenuEvent(QContextMenuEvent *event) override; private Q_SLOTS: void copyToClipboard(); }; diff --git a/src/tools/moleculeview.cpp b/src/tools/moleculeview.cpp index 16edf8ac4fed3857c8221a0d2acb191cad56bcca..e905cd0aacc19ba83b82ee07ea45fe04a76dee6e 100644 --- a/src/tools/moleculeview.cpp +++ b/src/tools/moleculeview.cpp @@ -8,8 +8,8 @@ #include "moleculeview.h" #include -#include #include +#include #include #include @@ -30,21 +30,21 @@ #include // This is needed to ensure that the forcefields are set up right with GCC vis #ifdef __KDE_HAVE_GCC_VISIBILITY - #define HAVE_GCC_VISIBILITY +#define HAVE_GCC_VISIBILITY #endif -#include -#include #include +#include #include +#include #include -#include +#include #include -#include +#include using namespace OpenBabel; using namespace Avogadro::QtGui; -MoleculeDialog::MoleculeDialog(QWidget * parent) +MoleculeDialog::MoleculeDialog(QWidget *parent) : QDialog(parent) , m_path(QString()) , m_periodicTable(nullptr) @@ -79,38 +79,30 @@ MoleculeDialog::MoleculeDialog(QWidget * parent) ui.setupUi(mainWidget); // Attempt to set up the UFF forcefield -// m_forceField = OBForceField::FindForceField("UFF"); -// if (!m_forceField) { -// ui.optimizeButton->setEnabled(false); -// } - - ui.styleCombo->addItems({"Ball and Stick", "Licorice", "Van der Waals","Van der Waals (AO)", "Wireframe"}); - connect(ui.styleCombo, static_cast(&QComboBox::currentIndexChanged), - this, &MoleculeDialog::slotUpdateScenePlugin); + // m_forceField = OBForceField::FindForceField("UFF"); + // if (!m_forceField) { + // ui.optimizeButton->setEnabled(false); + // } + + ui.styleCombo->addItems({"Ball and Stick", "Licorice", "Van der Waals", "Van der Waals (AO)", "Wireframe"}); + connect(ui.styleCombo, static_cast(&QComboBox::currentIndexChanged), this, &MoleculeDialog::slotUpdateScenePlugin); slotUpdateScenePlugin(); - connect(ui.tabWidget, &QTabWidget::currentChanged, - this, &MoleculeDialog::setViewEdit); + connect(ui.tabWidget, &QTabWidget::currentChanged, this, &MoleculeDialog::setViewEdit); // Editing parameters -// commented out until we find new API for pumbling to OpenBabel -// connect(ui.optimizeButton, &QPushButton::clicked, -// this, &MoleculeDialog::slotGeometryOptimize); - connect(ui.clearDrawingButton, &QPushButton::clicked, - this, &MoleculeDialog::clearAllElementsInEditor); - - connect(ui.glWidget->molecule(), &Avogadro::QtGui::Molecule::changed, - this, &MoleculeDialog::slotUpdateStatistics); - - connect(user1Button, &QPushButton::clicked, - this, &MoleculeDialog::slotLoadMolecule); - connect(user2Button, &QPushButton::clicked, - this, &MoleculeDialog::slotDownloadNewStuff); - connect(user3Button, &QPushButton::clicked, - this, &MoleculeDialog::slotSaveMolecule); + // commented out until we find new API for pumbling to OpenBabel + // connect(ui.optimizeButton, &QPushButton::clicked, + // this, &MoleculeDialog::slotGeometryOptimize); + connect(ui.clearDrawingButton, &QPushButton::clicked, this, &MoleculeDialog::clearAllElementsInEditor); - mainLayout->addWidget(buttonBox); + connect(ui.glWidget->molecule(), &Avogadro::QtGui::Molecule::changed, this, &MoleculeDialog::slotUpdateStatistics); + connect(user1Button, &QPushButton::clicked, this, &MoleculeDialog::slotLoadMolecule); + connect(user2Button, &QPushButton::clicked, this, &MoleculeDialog::slotDownloadNewStuff); + connect(user3Button, &QPushButton::clicked, this, &MoleculeDialog::slotSaveMolecule); + + mainLayout->addWidget(buttonBox); // Check that we have managed to load up some tools and engines int nTools = ui.glWidget->tools().size(); @@ -133,9 +125,9 @@ void MoleculeDialog::slotLoadMolecule() // Check that we have managed to load up some tools and engines int nTools = ui.glWidget->tools().size(); - if (!nTools) { - QString error = i18n("No tools loaded - it is likely that the Avogadro plugins could not be located. " + QString error = i18n( + "No tools loaded - it is likely that the Avogadro plugins could not be located. " "No molecules can be viewed until this issue is resolved."); KMessageBox::information(this, error); } @@ -157,7 +149,8 @@ void MoleculeDialog::slotLoadMolecule() loadMolecule(filename); } -void MoleculeDialog::slotUpdateScenePlugin() { +void MoleculeDialog::slotUpdateScenePlugin() +{ const QString text = ui.styleCombo->currentText(); for (int i = 0; i < ui.glWidget->sceneModel().rowCount(QModelIndex()); ++i) { QModelIndex index = ui.glWidget->sceneModel().index(i, 0); @@ -180,8 +173,7 @@ void MoleculeDialog::loadMolecule(const QString &filename) // initialize the m_undoMolecule private member variable; // this molecule should be created on the heap instead of the stack auto molecule_ptr = IoWrapper::readMolecule(filename); - if (!molecule_ptr) - { + if (!molecule_ptr) { KMessageBox::error(this, i18n("Could not load molecule"), i18n("Loading the molecule failed.")); return; } @@ -193,8 +185,7 @@ void MoleculeDialog::loadMolecule(const QString &filename) ui.glWidget->setMolecule(&m_molecule); ui.glWidget->update(); slotUpdateStatistics(); - connect(&m_molecule, &Avogadro::QtGui::Molecule::changed, - this, &MoleculeDialog::slotUpdateStatistics); + connect(&m_molecule, &Avogadro::QtGui::Molecule::changed, this, &MoleculeDialog::slotUpdateStatistics); } ui.glWidget->resetCamera(); ui.glWidget->updateScene(); @@ -211,19 +202,22 @@ void MoleculeDialog::slotSaveMolecule() { QString commonMoleculeFormats = i18n("Common molecule formats"); QString allFiles = i18n("All files"); - QString filename = QFileDialog::getSaveFileName(this, i18n("Choose a file to save to"), QString(), - commonMoleculeFormats + QStringLiteral(" (*.cml *.xyz *.ent *.pdb *.alc *.chm *.cdx *.cdxml *.c3d1 *.c3d2" - " *.gpr *.mdl *.mol *.sdf *.sd *.crk3d *.cht *.dmol *.bgf" - " *.gam *.inp *.gamin *.gamout *.tmol *.fract" - " *.mpd *.mol2);;") + allFiles + QStringLiteral(" (*)") - ); + QString filename = QFileDialog::getSaveFileName(this, + i18n("Choose a file to save to"), + QString(), + commonMoleculeFormats + + QStringLiteral(" (*.cml *.xyz *.ent *.pdb *.alc *.chm *.cdx *.cdxml *.c3d1 *.c3d2" + " *.gpr *.mdl *.mol *.sdf *.sd *.crk3d *.cht *.dmol *.bgf" + " *.gam *.inp *.gamin *.gamout *.tmol *.fract" + " *.mpd *.mol2);;") + + allFiles + QStringLiteral(" (*)")); if (!filename.contains(QLatin1String("."))) { filename.append(QLatin1String(".cml")); } - IoWrapper io; - io.writeMolecule(filename, ui.glWidget->molecule()); + IoWrapper io; + io.writeMolecule(filename, ui.glWidget->molecule()); } void MoleculeDialog::setViewEdit(int mode) @@ -243,13 +237,14 @@ MoleculeDialog::~MoleculeDialog() void MoleculeDialog::slotUpdateStatistics() { - Molecule* mol = ui.glWidget->molecule(); + Molecule *mol = ui.glWidget->molecule(); if (!mol) { return; } const std::string name = mol->data(QStringLiteral("name").toStdString()).toString(); ui.nameLabel->setText(QString::fromStdString(name)); - ui.weightLabel->setText(i18nc("This 'u' stands for the chemical unit (u for 'units'). Most likely this does not need to be translated at all!", "%1 u", mol->mass())); + ui.weightLabel->setText( + i18nc("This 'u' stands for the chemical unit (u for 'units'). Most likely this does not need to be translated at all!", "%1 u", mol->mass())); ui.formulaLabel->setText(IoWrapper::getPrettyFormula(mol)); ui.glWidget->update(); } @@ -270,13 +265,14 @@ void MoleculeDialog::slotDownloadNewStuff() bool anySuccess = false; bool moreOneInstalledFile = false; QString exactlyOneFile; - foreach (const KNS3::Entry& entry, dialog.changedEntries()) { + foreach (const KNS3::Entry &entry, dialog.changedEntries()) { // care only about installed ones if (entry.status() == KNS3::Entry::Installed) { qDebug() << "Changed Entry: " << entry.installedFiles(); foreach (const QString &origFile, entry.installedFiles()) { const QString destFile = destinationDir + '/' + QFileInfo(origFile).fileName(); - KJob *job = KIO::file_move(QUrl::fromLocalFile(origFile), QUrl::fromLocalFile(destFile));; + KJob *job = KIO::file_move(QUrl::fromLocalFile(origFile), QUrl::fromLocalFile(destFile)); + ; const bool success = job->exec(); if (success) { if (exactlyOneFile.isEmpty()) { @@ -304,32 +300,32 @@ void MoleculeDialog::slotDownloadNewStuff() } } -//TODO there is currently no API to perform the necessary OpenBabel-Avogadro -// conversions, after the migration to Avogadro2; at least with v0.9 +// TODO there is currently no API to perform the necessary OpenBabel-Avogadro +// conversions, after the migration to Avogadro2; at least with v0.9 void MoleculeDialog::slotGeometryOptimize() { -// // Perform a geometry optimization -// if (!m_forceField) { -// return; -// } -// -// Molecule* molecule = ui.glWidget->molecule(); -// OpenBabel::OBMol obmol;//(molecule->OBMol()); -// -// // Warn the user if the force field cannot be set up for the molecule -// if (!m_forceField->Setup(obmol)) { -// KMessageBox::error(this, -// i18n("Could not set up force field for this molecule"), -// i18n("Kalzium")); -// return; -// } -// -// // Reasonable default values for most users -// m_forceField->SteepestDescentInitialize(500, 1.0e-5); -// // Provide some feedback as the optimization runs -// while (m_forceField->SteepestDescentTakeNSteps(5)) { -// m_forceField->UpdateCoordinates(obmol); -// molecule->setOBMol(&obmol); -// molecule->update(); -// } + // // Perform a geometry optimization + // if (!m_forceField) { + // return; + // } + // + // Molecule* molecule = ui.glWidget->molecule(); + // OpenBabel::OBMol obmol;//(molecule->OBMol()); + // + // // Warn the user if the force field cannot be set up for the molecule + // if (!m_forceField->Setup(obmol)) { + // KMessageBox::error(this, + // i18n("Could not set up force field for this molecule"), + // i18n("Kalzium")); + // return; + // } + // + // // Reasonable default values for most users + // m_forceField->SteepestDescentInitialize(500, 1.0e-5); + // // Provide some feedback as the optimization runs + // while (m_forceField->SteepestDescentTakeNSteps(5)) { + // m_forceField->UpdateCoordinates(obmol); + // molecule->setOBMol(&obmol); + // molecule->update(); + // } } diff --git a/src/tools/moleculeview.h b/src/tools/moleculeview.h index d5a9b66c13c04c00c7cd4f8bae015ca1a390ab61..985cd47b72377b3f06bd1312eb744e1e49d58c2c 100644 --- a/src/tools/moleculeview.h +++ b/src/tools/moleculeview.h @@ -33,16 +33,16 @@ class MoleculeDialog : public QDialog Q_OBJECT public: - explicit MoleculeDialog(QWidget * parent); + explicit MoleculeDialog(QWidget *parent); ~MoleculeDialog(); void loadMolecule(const QString &filename); private: - QString m_path;///to store the path were the molecules are located + QString m_path; /// to store the path were the molecules are located QList m_elementsIndex; // Index storing the element combo index Avogadro::QtGui::PeriodicTableView *m_periodicTable; - OpenBabel::OBForceField* m_forceField; + OpenBabel::OBForceField *m_forceField; QSettings *m_drawSettings; Ui::moleculeViewerForm ui; @@ -64,23 +64,23 @@ private slots: void slotDownloadNewStuff(); /** - * Save a molecule - */ + * Save a molecule + */ void slotSaveMolecule(); /** - * Set view/edit mode - */ + * Set view/edit mode + */ void setViewEdit(int mode); /** - * Update the statistical information about the current molecule - */ + * Update the statistical information about the current molecule + */ void slotUpdateStatistics(); /** - * Geometry optimization - */ + * Geometry optimization + */ void slotGeometryOptimize(); /// Clears the view diff --git a/src/tools/obconverter.cpp b/src/tools/obconverter.cpp index d2318f071e9545453a9ccbf80f93d1627bb64821..5b34bf5ba41d88531ba177aa808d838d0187db20 100644 --- a/src/tools/obconverter.cpp +++ b/src/tools/obconverter.cpp @@ -33,7 +33,7 @@ KOpenBabel::KOpenBabel(QWidget *parent) : QDialog(parent) { setWindowTitle(i18nc("@title:window", "OpenBabel Frontend")); - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help|QDialogButtonBox::Close); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); @@ -70,37 +70,33 @@ void KOpenBabel::setupWindow() // Creating the main layout QStringList InputType; vector InputFormat = OBConvObject->GetSupportedInputFormat(); - for (vector::iterator it = InputFormat.begin(); it!=InputFormat.end(); ++it) { + for (vector::iterator it = InputFormat.begin(); it != InputFormat.end(); ++it) { InputType << QString((*it).c_str()); } ui.InputTypeComboBox->addItems(InputType); QStringList OutputType; vector OutputFormat = OBConvObject->GetSupportedOutputFormat(); - for (vector::iterator it = OutputFormat.begin(); it!=OutputFormat.end(); ++it) { + for (vector::iterator it = OutputFormat.begin(); it != OutputFormat.end(); ++it) { OutputType << QString((*it).c_str()); } ui.OutputTypeComboBox->addItems(OutputType); // Create connection - connect(ui.addFileButton, - &QAbstractButton::clicked, this, &KOpenBabel::slotAddFile); + connect(ui.addFileButton, &QAbstractButton::clicked, this, &KOpenBabel::slotAddFile); - connect(ui.deleteFileButton, - &QAbstractButton::clicked, this, &KOpenBabel::slotDeleteFile); + connect(ui.deleteFileButton, &QAbstractButton::clicked, this, &KOpenBabel::slotDeleteFile); - connect(ui.selectAllFileButton, - &QAbstractButton::clicked, this, &KOpenBabel::slotSelectAll); + connect(ui.selectAllFileButton, &QAbstractButton::clicked, this, &KOpenBabel::slotSelectAll); - connect(ui.FileListView, - &QListWidget::itemSelectionChanged, this, &KOpenBabel::slotGuessInput); + connect(ui.FileListView, &QListWidget::itemSelectionChanged, this, &KOpenBabel::slotGuessInput); } void KOpenBabel::slotAddFile() { QStringList InputType; vector InputFormat = OBConvObject->GetSupportedInputFormat(); - for (vector::iterator it = InputFormat.begin(); it!=InputFormat.end(); ++it) { + for (vector::iterator it = InputFormat.begin(); it != InputFormat.end(); ++it) { InputType << QString((*it).c_str()); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -117,27 +113,25 @@ void KOpenBabel::slotAddFile() ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QList fl = QFileDialog::getOpenFileUrls( - this, - i18n("Open Molecule File"), - QUrl(), - i18n("All Files") + QStringLiteral("(*);;") + tmpList.join(QLatin1String(";;")) //add all possible extensions like "*.cml *.mol" - ); + this, + i18n("Open Molecule File"), + QUrl(), + i18n("All Files") + QStringLiteral("(*);;") + tmpList.join(QLatin1String(";;")) // add all possible extensions like "*.cml *.mol" + ); - foreach (const QUrl &u , fl) { + foreach (const QUrl &u, fl) { new QListWidgetItem(u.toDisplayString(), ui.FileListView); } } - void KOpenBabel::slotSelectAll() { ui.FileListView->selectAll(); } - void KOpenBabel::slotDeleteFile() { - QList p = ui.FileListView->selectedItems(); + QList p = ui.FileListView->selectedItems(); foreach (QListWidgetItem *item, p) { delete item; } @@ -145,11 +139,11 @@ void KOpenBabel::slotDeleteFile() void KOpenBabel::slotGuessInput() { - QList p = ui.FileListView->selectedItems(); + QList p = ui.FileListView->selectedItems(); bool first = true; QString suffix; if (p.count()) { - foreach (QListWidgetItem * item, p) { + foreach (QListWidgetItem *item, p) { if (first) { first = false; suffix = item->text().remove(QRegularExpression("^.*\\.")); @@ -181,18 +175,15 @@ void KOpenBabel::slotConvert() iformat = iformat.remove(QRegularExpression(" --.*")); oformat = oformat.remove(QRegularExpression(" --.*")); - QList p = ui.FileListView->selectedItems(); + QList p = ui.FileListView->selectedItems(); if (p.count() == 0) { - KMessageBox::error(this, - i18n("You must select some files first."), - i18n("No files selected") - ); + KMessageBox::error(this, i18n("You must select some files first."), i18n("No files selected")); return; } - QListIterator it(p); + QListIterator it(p); QStringList cmdList; // Full command QVector cmdArgList; // Arguments only - foreach (QListWidgetItem * item, p) { + foreach (QListWidgetItem *item, p) { QString ifname = QUrl(item->text()).toLocalFile(); QString ofname = ifname; ofname = ofname.remove(QRegularExpression("\\.([^\\.]*$)")); @@ -201,13 +192,10 @@ void KOpenBabel::slotConvert() bool proceed = true; if (QFile::exists(ofname)) { - //something named ofname already exists - switch (KMessageBox::warningContinueCancel( - this, - i18n("The file %1 already exists. Do you want to overwrite if possible?", ofname), - i18n("The File %1 Already Exists -- KOpenBabel", ofname) - ) - ) { + // something named ofname already exists + switch (KMessageBox::warningContinueCancel(this, + i18n("The file %1 already exists. Do you want to overwrite if possible?", ofname), + i18n("The File %1 Already Exists -- KOpenBabel", ofname))) { case KMessageBox::No: proceed = false; break; @@ -223,11 +211,7 @@ void KOpenBabel::slotConvert() } } if (cmdArgList.count() > 0) { - switch (KMessageBox::questionYesNo( - this, cmdList.join(QStringLiteral("\n")), - i18n("Is it okay to run these commands? -- KOpenBabel") - ) - ) { + switch (KMessageBox::questionYesNo(this, cmdList.join(QStringLiteral("\n")), i18n("Is it okay to run these commands? -- KOpenBabel"))) { case KMessageBox::Yes: foreach (const QStringList &s, cmdArgList) { QProcess::startDetached(QStringLiteral("babel"), s); diff --git a/src/tools/obconverter.h b/src/tools/obconverter.h index e04322adbab35cc496717b3b9d5f7c760d974671..0b101d4dc1ccda06d8b4f6a8bcd5519569eca5d1 100644 --- a/src/tools/obconverter.h +++ b/src/tools/obconverter.h @@ -15,7 +15,6 @@ // OpenBabel includes #include - /** * @author Carsten Niehaus * @author Jerome Pansanel @@ -37,7 +36,6 @@ public: */ virtual ~KOpenBabel(); - /** * Add file to the list */ @@ -85,7 +83,6 @@ private slots: * Open help page */ void slotHelpRequested(); - }; #endif // OBCONVERTER_H