Skip to content

Commit

Permalink
Merge pull request #1378 from ghutchis/cjson-default-obabel
Browse files Browse the repository at this point in the history
Switch to using CJSON as the default format with obabel
  • Loading branch information
ghutchis authored Oct 18, 2023
2 parents c9a5066 + c701c3e commit 545f9e4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions avogadro/qtplugins/openbabel/openbabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Avogadro::QtPlugins {
OpenBabel::OpenBabel(QObject* p)
: ExtensionPlugin(p), m_molecule(nullptr), m_process(new OBProcess(this)),
m_readFormatsPending(true), m_writeFormatsPending(true),
m_defaultFormat("cml"), m_progress(nullptr)
m_defaultFormat("cjson"), m_progress(nullptr)
{
auto* action = new QAction(this);
action->setEnabled(true);
Expand Down Expand Up @@ -126,7 +126,7 @@ QList<Io::FileFormat*> OpenBabel::fileFormats() const
std::vector<std::string> fmime;

// Simple lambda to replace toSet in QList
auto toSet = [&] (const QList<QString>& list) {
auto toSet = [&](const QList<QString>& list) {
return QSet<QString>(list.begin(), list.end());
};

Expand Down Expand Up @@ -259,9 +259,9 @@ void OpenBabel::handleReadFormatUpdate(const QMultiMap<QString, QString>& fmts)
emit fileFormatsReady();

// Update the default format if cjson is available
if (m_readFormats.contains("Chemical JSON") &&
m_writeFormats.contains("Chemical JSON")) {
m_defaultFormat = "cjson";
if (!m_readFormats.contains("Chemical JSON") &&
!m_writeFormats.contains("Chemical JSON")) {
m_defaultFormat = "cml";
}
}
}
Expand Down Expand Up @@ -294,9 +294,9 @@ void OpenBabel::handleWriteFormatUpdate(const QMultiMap<QString, QString>& fmts)
emit fileFormatsReady();

// Update the default format if cjson is available
if (m_readFormats.contains("Chemical JSON") &&
m_writeFormats.contains("Chemical JSON")) {
m_defaultFormat = "cjson";
if (!m_readFormats.contains("Chemical JSON") &&
!m_writeFormats.contains("Chemical JSON")) {
m_defaultFormat = "cml";
}
}
}
Expand All @@ -313,7 +313,8 @@ void OpenBabel::refreshForceFields()
proc->queryForceFields();
}

void OpenBabel::handleForceFieldsUpdate(const QMultiMap<QString, QString>& ffMap)
void OpenBabel::handleForceFieldsUpdate(
const QMultiMap<QString, QString>& ffMap)
{
auto* proc = qobject_cast<OBProcess*>(sender());
if (proc)
Expand All @@ -334,7 +335,8 @@ void OpenBabel::refreshCharges()
proc->queryCharges();
}

void OpenBabel::handleChargesUpdate(const QMultiMap<QString, QString>& chargeMap)
void OpenBabel::handleChargesUpdate(
const QMultiMap<QString, QString>& chargeMap)
{
auto* proc = qobject_cast<OBProcess*>(sender());
if (proc)
Expand Down Expand Up @@ -860,4 +862,4 @@ QString OpenBabel::autoDetectForceField() const

return result;
}
} // namespace Avogadro
} // namespace Avogadro::QtPlugins

0 comments on commit 545f9e4

Please sign in to comment.