Move event-response code into dedicated event handlers
Address ### Qt 6 comments. Change-Id: I4c90265293ddf539f860630901ab6d9487e2a1b5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
a494da3b20
commit
55fe46fd58
@ -1237,6 +1237,22 @@ void QTreeView::scrollTo(const QModelIndex &index, ScrollHint hint)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QTreeView::changeEvent(QEvent *event)
|
||||
{
|
||||
Q_D(QTreeView);
|
||||
if (event->type() == QEvent::StyleChange) {
|
||||
if (!d->customIndent) {
|
||||
// QAbstractItemView calls this method in case of a style change,
|
||||
// so update the indentation here if it wasn't set manually.
|
||||
d->updateIndentationFromStyle();
|
||||
}
|
||||
}
|
||||
QAbstractItemView::changeEvent(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
@ -2097,12 +2113,6 @@ QModelIndex QTreeView::indexBelow(const QModelIndex &index) const
|
||||
void QTreeView::doItemsLayout()
|
||||
{
|
||||
Q_D(QTreeView);
|
||||
if (!d->customIndent) {
|
||||
// ### Qt 6: move to event()
|
||||
// QAbstractItemView calls this method in case of a style change,
|
||||
// so update the indentation here if it wasn't set manually.
|
||||
d->updateIndentationFromStyle();
|
||||
}
|
||||
if (d->hasRemovedItems) {
|
||||
//clean the QSet that may contains old (and this invalid) indexes
|
||||
d->hasRemovedItems = false;
|
||||
|
@ -185,6 +185,7 @@ protected:
|
||||
QRegion visualRegionForSelection(const QItemSelection &selection) const override;
|
||||
QModelIndexList selectedIndexes() const override;
|
||||
|
||||
void changeEvent(QEvent *event) override;
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
|
@ -1436,23 +1436,29 @@ void QLineEdit::paste()
|
||||
|
||||
#endif // !QT_NO_CLIPBOARD
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QLineEdit::timerEvent(QTimerEvent *e)
|
||||
{
|
||||
Q_D(QLineEdit);
|
||||
int timerId = ((QTimerEvent*)e)->timerId();
|
||||
if (false) {
|
||||
#if QT_CONFIG(draganddrop)
|
||||
} else if (timerId == d->dndTimer.timerId()) {
|
||||
d->drag();
|
||||
#endif
|
||||
}
|
||||
else if (timerId == d->tripleClickTimer.timerId())
|
||||
d->tripleClickTimer.stop();
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
*/
|
||||
bool QLineEdit::event(QEvent * e)
|
||||
{
|
||||
Q_D(QLineEdit);
|
||||
if (e->type() == QEvent::Timer) {
|
||||
// ### Qt6: move to timerEvent, is here for binary compatibility
|
||||
int timerId = ((QTimerEvent*)e)->timerId();
|
||||
if (false) {
|
||||
#if QT_CONFIG(draganddrop)
|
||||
} else if (timerId == d->dndTimer.timerId()) {
|
||||
d->drag();
|
||||
#endif
|
||||
}
|
||||
else if (timerId == d->tripleClickTimer.timerId())
|
||||
d->tripleClickTimer.stop();
|
||||
} else if (e->type() == QEvent::ContextMenu) {
|
||||
if (e->type() == QEvent::ContextMenu) {
|
||||
#ifndef QT_NO_IM
|
||||
if (d->control->composeMode())
|
||||
return true;
|
||||
@ -1465,8 +1471,6 @@ bool QLineEdit::event(QEvent * e)
|
||||
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
|
||||
d->control->processShortcutOverrideEvent(ke);
|
||||
#endif
|
||||
} else if (e->type() == QEvent::KeyRelease) {
|
||||
d->control->updateCursorBlinking();
|
||||
} else if (e->type() == QEvent::Show) {
|
||||
//In order to get the cursor blinking if QComboBox::setEditable is called when the combobox has focus
|
||||
if (hasFocus()) {
|
||||
@ -1774,6 +1778,15 @@ void QLineEdit::keyPressEvent(QKeyEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QLineEdit::keyReleaseEvent(QKeyEvent *)
|
||||
{
|
||||
Q_D(QLineEdit);
|
||||
d->control->updateCursorBlinking();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.4
|
||||
|
||||
|
@ -214,6 +214,7 @@ protected:
|
||||
void mouseReleaseEvent(QMouseEvent *) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *) override;
|
||||
void keyPressEvent(QKeyEvent *) override;
|
||||
void keyReleaseEvent(QKeyEvent *) override;
|
||||
void focusInEvent(QFocusEvent *) override;
|
||||
void focusOutEvent(QFocusEvent *) override;
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
@ -233,6 +234,7 @@ protected:
|
||||
public:
|
||||
QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
|
||||
Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const;
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
bool event(QEvent *) override;
|
||||
protected:
|
||||
QRect cursorRect() const;
|
||||
|
Loading…
Reference in New Issue
Block a user