From 27c9a0472672d8637a9ac315dfa7c20835b4965d Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 31 Aug 2023 23:27:30 -0400 Subject: [PATCH] Fix #1317 - editor wasn't using the format specification for parsing Signed-off-by: Geoff Hutchison --- .../coordinateeditor/coordinateeditordialog.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/avogadro/qtplugins/coordinateeditor/coordinateeditordialog.cpp b/avogadro/qtplugins/coordinateeditor/coordinateeditordialog.cpp index 8aa4103eb..96b76c368 100644 --- a/avogadro/qtplugins/coordinateeditor/coordinateeditordialog.cpp +++ b/avogadro/qtplugins/coordinateeditor/coordinateeditordialog.cpp @@ -385,6 +385,17 @@ void CoordinateEditorDialog::validateInputWorker() break; } + case '#': { + // Validate integer: + bool isInt; + int index = tokenCursor.selectedText().toInt(&isInt); + if (!isInt) + m_ui->text->markInvalid(tokenCursor, tr("Invalid atomic index.")); + else + m_ui->text->markValid(tokenCursor, tr("Atomic index.")); + break; + } + case 'Z': { // Validate integer: bool isInt; @@ -564,6 +575,7 @@ void CoordinateEditorDialog::applyFinish(bool valid) newMolecule.atomPositions3d()); } else { newMolecule.perceiveBondsSimple(); + newMolecule.perceiveBondOrders(); } m_ui->text->document()->setModified(false); @@ -625,6 +637,9 @@ QString CoordinateEditorDialog::detectInputFormat() const if (m_ui->text->document()->isEmpty()) return QString(); + if (!m_ui->spec->text().isEmpty()) + return m_ui->spec->text(); + // Extract the first non-empty line of text from the document. QTextCursor cur(m_ui->text->document()); QString sample;