Removed some dead code from QWidgetLineControl

There was a big processEvents() method which was actually getting
called for a single type of events.

Change-Id: I66ac70c7ac6e2f9136b24541d42a4185f8797583
Reviewed-on: http://codereview.qt-project.org/6132
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
This commit is contained in:
Pekka Vuorela 2011-09-30 16:50:10 +03:00 committed by Qt by Nokia
parent 2bf2bb3daf
commit 8fb15f3a75
3 changed files with 46 additions and 147 deletions

View File

@ -1347,8 +1347,11 @@ bool QLineEdit::event(QEvent * e)
//d->separate();
} else if (e->type() == QEvent::WindowActivate) {
QTimer::singleShot(0, this, SLOT(_q_handleWindowActivate()));
#ifndef QT_NO_SHORTCUT
} else if (e->type() == QEvent::ShortcutOverride) {
d->control->processEvent(e);
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
d->control->processShortcutOverrideEvent(ke);
#endif
} else if (e->type() == QEvent::KeyRelease) {
d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
} else if (e->type() == QEvent::Show) {

View File

@ -1380,58 +1380,12 @@ void QWidgetLineControl::timerEvent(QTimerEvent *event)
}
}
bool QWidgetLineControl::processEvent(QEvent* ev)
{
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled()) {
if ((ev->type() == QEvent::KeyPress) || (ev->type() == QEvent::KeyRelease)) {
QKeyEvent *ke = (QKeyEvent *)ev;
if (ke->key() == Qt::Key_Back) {
if (ke->isAutoRepeat()) {
// Swallow it. We don't want back keys running amok.
ke->accept();
return true;
}
if ((ev->type() == QEvent::KeyRelease)
&& !isReadOnly()
&& m_deleteAllTimer) {
killTimer(m_deleteAllTimer);
m_deleteAllTimer = 0;
backspace();
ke->accept();
return true;
}
}
}
}
#endif
switch(ev->type()){
#ifndef QT_NO_GRAPHICSVIEW
case QEvent::GraphicsSceneMouseDoubleClick:
case QEvent::GraphicsSceneMouseMove:
case QEvent::GraphicsSceneMouseRelease:
case QEvent::GraphicsSceneMousePress:{
QGraphicsSceneMouseEvent *gvEv = static_cast<QGraphicsSceneMouseEvent*>(ev);
QMouseEvent mouse(ev->type(),
gvEv->pos(), gvEv->pos(), gvEv->screenPos(), gvEv->button(), gvEv->buttons(), gvEv->modifiers());
processMouseEvent(&mouse); break;
}
#endif
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
processMouseEvent(static_cast<QMouseEvent*>(ev)); break;
case QEvent::KeyPress:
case QEvent::KeyRelease:
processKeyEvent(static_cast<QKeyEvent*>(ev)); break;
case QEvent::InputMethod:
processInputMethodEvent(static_cast<QInputMethodEvent*>(ev)); break;
#ifndef QT_NO_SHORTCUT
case QEvent::ShortcutOverride:{
void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke)
{
if (isReadOnly())
return false;
QKeyEvent* ke = static_cast<QKeyEvent*>(ev);
return;
if (ke == QKeySequence::Copy
|| ke == QKeySequence::Paste
|| ke == QKeySequence::Cut
@ -1471,65 +1425,6 @@ bool QWidgetLineControl::processEvent(QEvent* ev)
}
}
#endif
default:
return false;
}
return true;
}
void QWidgetLineControl::processMouseEvent(QMouseEvent* ev)
{
switch (ev->type()) {
case QEvent::GraphicsSceneMousePress:
case QEvent::MouseButtonPress:{
if (m_tripleClickTimer
&& (ev->pos() - m_tripleClick).manhattanLength()
< QApplication::startDragDistance()) {
selectAll();
return;
}
if (ev->button() == Qt::RightButton)
return;
bool mark = ev->modifiers() & Qt::ShiftModifier;
int cursor = xToPos(ev->pos().x());
moveCursor(cursor, mark);
break;
}
case QEvent::GraphicsSceneMouseDoubleClick:
case QEvent::MouseButtonDblClick:
if (ev->button() == Qt::LeftButton) {
selectWordAtPos(xToPos(ev->pos().x()));
if (m_tripleClickTimer)
killTimer(m_tripleClickTimer);
m_tripleClickTimer = startTimer(QApplication::doubleClickInterval());
m_tripleClick = ev->pos();
}
break;
case QEvent::GraphicsSceneMouseRelease:
case QEvent::MouseButtonRelease:
#ifndef QT_NO_CLIPBOARD
if (QApplication::clipboard()->supportsSelection()) {
if (ev->button() == Qt::LeftButton) {
copy(QClipboard::Selection);
} else if (!isReadOnly() && ev->button() == Qt::MidButton) {
deselect();
insert(QApplication::clipboard()->text(QClipboard::Selection));
}
}
#endif
break;
case QEvent::GraphicsSceneMouseMove:
case QEvent::MouseMove:
if (ev->buttons() & Qt::LeftButton) {
moveCursor(xToPos(ev->pos().x()), true);
}
break;
default:
break;
}
}
void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
{

View File

@ -308,7 +308,6 @@ public:
void setFont(const QFont &font) { m_textLayout.setFont(font); updateDisplayText(); }
void processInputMethodEvent(QInputMethodEvent *event);
void processMouseEvent(QMouseEvent* ev);
void processKeyEvent(QKeyEvent* ev);
int cursorBlinkPeriod() const { return m_blinkPeriod; }
@ -331,7 +330,9 @@ public:
};
void draw(QPainter *, const QPoint &, const QRect &, int flags = DrawAll);
bool processEvent(QEvent *ev);
#ifndef QT_NO_SHORTCUT
void processShortcutOverrideEvent(QKeyEvent *ke);
#endif
QTextLayout *textLayout() const
{