message: Add arrow key navigation of the periodic table
  Fixes typing lower case elements "n" = "N"
  Fixes
diff: @@ -67,24 +67,72 @@ void PeriodicTableView::keyPressEvent(QKeyEvent* event_)
  {
  if (m_keyPressBuffer.isEmpty()) {
  // This is the first character typed.
  - // Qait for 2 seconds, then clear the buffer,
  + // Wait for 2 seconds, then clear the buffer,
  // this ensures we can get multi-character elements.
  QTimer::singleShot(2000, this, SLOT(clearKeyPressBuffer()));
  }
  - m_keyPressBuffer.append(event_->text());
  + if (event_->key() == Qt::Key_Escape || event_->key() == Qt::Key_Return ||
  + event_->key() == Qt::Key_Enter) {
  + close();
  + return;
  + }
  +
  + // check for arrow keys
  + int elem = m_element;
  + if (event_->key() == Qt::Key_Left) {
  + elem -= 1;
  + } else if (event_->key() == Qt::Key_Right) {
  + elem += 1;
  + } else if (event_->key() == Qt::Key_Up) {
  +
  + // What row are we?
  + if (elem == 3) { // ignore other 2nd row
  + elem = 1;
  + } else if (elem >= 10 && elem <= 20) {
  + elem -= 8;
  + } else if (elem >= 21 && elem <= 30) {
  + // nothing to do, top row of transition metals
  + } else if (elem >= 31 && elem <= 56) {
  + elem -= 18; // go up a row
  + } else if (elem >= 57 && elem <= 70) {
  + // nothing to do, top row of lanthanides
  + } else if (elem >= 71 && elem <= 118) {
  + elem -= 32; // go up a row
  + }
  + } else if (event_->key() == Qt::Key_Down) {
  + // What row are we?
  + if (elem == 1) {
  + elem = 3;
  + } else if (elem == 2) {
  + elem = 10;
  + } else if (elem >= 3 && elem <= 12) {
  + elem += 8; // down one row
  + } else if (elem >= 13 && elem <= 38) {
  + elem += 18; // down one row
  + } else if (elem >= 39 && elem <= 86) {
  + elem += 32; // down one row
  + } else if (elem >= 87 && elem <= 118) {
  + // last row, nothing to do
  + }
  + } else {
  + // This is a normal character.
  + m_keyPressBuffer += event_->text();
  // Try setting an element symbol from this string.
  - int elem = m_keyPressBuffer.toInt();
  + elem = m_keyPressBuffer.toInt();
  if (elem <= 0 || elem > 119) {
  // Not a valid number, have we tried 2- and 3-character symbols?
  if (m_keyPressBuffer.length() > 3) {
  clearKeyPressBuffer();
  } else {
  - // try parsing as a symbol
  + // try parsing as a symbol .. first character should be uppercase
  + m_keyPressBuffer[0] = m_keyPressBuffer[0].toUpper();
  +
  elem = static_cast<int>(
  Elements::atomicNumberFromSymbol(m_keyPressBuffer.toLatin1().data()));
  }
  }
  + }
  // got a valid symbol
  if (elem > 0 && elem < 119)
  @@ -100,5 +148,5 @@ void PeriodicTableView::resizeEvent(QResizeEvent* e)
  setTransform(scaleTransform);
  }
  -} // End QtGui namespace
  -} // End Avogadro namespace
  +} // namespace QtGui
  +} // namespace Avogadro
  