Commit 6393e153 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use clang-format

parent cd0f3232
Pipeline #177951 passed with stage
in 6 minutes and 6 seconds
......@@ -7,8 +7,8 @@
#include "iowrapper.h"
#include <iostream>
#include <fstream>
#include <iostream>
#include <avogadro/core/molecule.h>
#include <avogadro/io/cmlformat.h>
......@@ -27,22 +27,20 @@ std::unique_ptr<Avogadro::Core::Molecule> 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<Avogadro::Core::Molecule>();
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;
}
......
......@@ -27,7 +27,7 @@ public:
*/
static std::unique_ptr<Avogadro::Core::Molecule> 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);
......
......@@ -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<KalziumGLPart>();)
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);
......
......@@ -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
......@@ -45,8 +45,7 @@ KalziumGLWidget::KalziumGLWidget(QWidget *parent)
manager->load();
// load render engines
QList<Avogadro::QtGui::ScenePluginFactory*> scenePluginFactories =
manager->pluginFactories<Avogadro::QtGui::ScenePluginFactory>();
QList<Avogadro::QtGui::ScenePluginFactory *> scenePluginFactories = manager->pluginFactories<Avogadro::QtGui::ScenePluginFactory>();
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<Avogadro::QtGui::ToolPluginFactory>();
auto toolPluginFactories = manager->pluginFactories<Avogadro::QtGui::ToolPluginFactory>();
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();
}
......
......@@ -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);
......
......@@ -25,16 +25,15 @@ public:
//########################
ChemicalDataObjectPrivate::ChemicalDataObjectPrivate()
: QSharedData()
: QSharedData()
{
}
ChemicalDataObjectPrivate::~ChemicalDataObjectPrivate()
= default;
ChemicalDataObjectPrivate::~ChemicalDataObjectPrivate() = default;
//##############
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;
......@@ -43,21 +42,19 @@ 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)
= default;
ChemicalDataObject::~ChemicalDataObject()
= default;
= default;
ChemicalDataObject& ChemicalDataObject::operator=(const ChemicalDataObject &other)
= default;
ChemicalDataObject::~ChemicalDataObject() = default;
ChemicalDataObject &ChemicalDataObject::operator=(const ChemicalDataObject &other) = default;
bool ChemicalDataObject::operator==(const int v) const
{
......@@ -86,7 +83,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;
......@@ -135,12 +132,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;
}
......@@ -152,7 +149,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
......
......@@ -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;
......
......@@ -10,8 +10,7 @@
#include <KUnitConversion/Converter>
Element::Element()
= default;
Element::Element() = default;
QVariant Element::dataAsVariant(ChemicalDataObject::BlueObelisk type) const
{
......@@ -60,15 +59,14 @@ QString Element::dataAsStringWithUnit(ChemicalDataObject::BlueObelisk type, int
return valueAndUnit;
}
Element::~Element()
= default;
Element::~Element() = default;
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);
......
......@@ -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<ChemicalDataObject> data()const
QList<ChemicalDataObject> data() const
{
return dataList;
}
......
......@@ -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<Element*> elements;
QList<Element *> 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")) {