///Interception de la frappe au clavier void RzxTextEdit::keyPressEvent(QKeyEvent *e) { QKeyEvent *eMapped = e; bool down=false; //Saut de ligne - Envoie du message switch(eMapped->key()) { case Qt::Key_Enter: case Qt::Key_Return: if(eMapped->modifiers() != Qt::SHIFT) { emit enterPressed(); break; } QTextEdit::keyPressEvent(eMapped); break; //Autocompletion case Qt::Key_Tab: //Pour que quand on appuie sur tab ça fasse la complétion du nick if(!nickAutocompletion()) { QTextEdit::keyPressEvent(eMapped); onTextEdited(); } break; //Parcours de l'historique case Qt::Key_Down: down=true; case Qt::Key_Up: //Et op, parcours de l'historique si les conditions sont réunies if((eMapped->modifiers() & Qt::ShiftModifier) || (eMapped->modifiers() & Qt::ControlModifier) || (down && atEnd()) || (!down && atBeginning())) { onArrowPressed(down); break; } eMapped = new QKeyEvent(QEvent::KeyRelease, e->key(), e->modifiers(), e->text()); //Texte normal default: QTextEdit::keyPressEvent(eMapped); onTextEdited(); } }
int Q3MultiLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Q3TextEdit::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = numLines(); break; case 1: *reinterpret_cast< bool*>(_v) = atBeginning(); break; case 2: *reinterpret_cast< bool*>(_v) = atEnd(); break; case 3: *reinterpret_cast< Qt::Alignment*>(_v) = alignment(); break; case 4: *reinterpret_cast< bool*>(_v) = edited(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 3: setAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break; case 4: setEdited(*reinterpret_cast< bool*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
/** Get cursor position in one dimension manner. */ int TextFieldBody::getCursorPosition() { int position; if (atBeginning()) { position = 0; } else if (atEnd()) { position = length(); } else { int line, col; QMultiLineEdit::getCursorPosition(&line, &col); /* Iterate each line's length */ for (position = col, line--; line >= 0; line--) { position += lineLength(line) + 1; /* EOL is counted as one char */ } } return position; }
void YZHistory::goBackInTime() { if ( !atBeginning() ) { --d->current; } }