int eListboxPythonStringContent::cursorMove(int count) { m_cursor += count; if (m_cursor < 0) cursorHome(); else if (m_cursor > size()) cursorEnd(); return 0; }
int eListboxPythonStringContent::cursorSet(int n) { m_cursor = n; if (m_cursor < 0) cursorHome(); else if (m_cursor > size()) cursorEnd(); return 0; }
///////////////////////////////////////////////////////////////////// // Keyboard Event overrides ///////////////////////////////////////////////////////////////////// void CFreqCtrl::keyPressEvent( QKeyEvent * event ) { //call base class if dont over ride key bool fSkipMsg = FALSE; qint64 tmp; //qDebug() <<event->key(); switch(event->key()) { case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9: if (m_ActiveEditDigit >= 0) { if (m_DigitInfo[m_ActiveEditDigit].editmode) { tmp = (m_freq/m_DigitInfo[m_ActiveEditDigit].weight) % 10; m_freq -= tmp*m_DigitInfo[m_ActiveEditDigit].weight; m_freq = m_freq+(event->key()-'0')*m_DigitInfo[m_ActiveEditDigit].weight; setFrequency(m_freq); } } moveCursorRight(); fSkipMsg = TRUE; break; case Qt::Key_Left: if (m_ActiveEditDigit != -1) { moveCursorLeft(); fSkipMsg = TRUE; } break; case Qt::Key_Up: if (m_ActiveEditDigit != -1) { incFreq(); fSkipMsg = TRUE; } break; case Qt::Key_Down: if (m_ActiveEditDigit != -1) { decFreq(); fSkipMsg = TRUE; } break; case Qt::Key_Right: if (m_ActiveEditDigit != -1) { moveCursorRight(); fSkipMsg = TRUE; } break; case Qt::Key_Home: cursorHome(); fSkipMsg = TRUE; break; case Qt::Key_End: cursorEnd(); fSkipMsg = TRUE; break; default: break; } if (!fSkipMsg) QFrame::keyPressEvent(event); }