Skip to content

Commit

Permalink
Merge pull request #1327 from ghutchis/fix-coord-editor
Browse files Browse the repository at this point in the history
Fix #1317 - editor wasn't using the format specification for parsing
  • Loading branch information
ghutchis authored Sep 1, 2023
2 parents 31423e0 + 27c9a04 commit fc24a96
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions avogadro/qtplugins/coordinateeditor/coordinateeditordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -564,6 +575,7 @@ void CoordinateEditorDialog::applyFinish(bool valid)
newMolecule.atomPositions3d());
} else {
newMolecule.perceiveBondsSimple();
newMolecule.perceiveBondOrders();
}

m_ui->text->document()->setModified(false);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fc24a96

Please sign in to comment.