obsolete(?) code in KApplication::notify()
Andreas Hartmetz
ahartmetz at gmail.com
Fri Nov 17 16:45:41 GMT 2006
Hi!
While browsing kdelibs(4) to find use cases of KShortcut, I found some
really wrong looking and undocumented code in KApplication::notify().
To get you a quick impression, here is the beginning of the code in
question:
## snip ##
bool KApplication::notify(QObject *receiver, QEvent *event)
{
QEvent::Type t = event->type();
if ((t == QEvent::ShortcutOverride) || (t == QEvent::KeyPress))
{
static const KShortcut& _selectAll = KStdAccel::selectAll();
QLineEdit *edit = ::qobject_cast<QLineEdit *>(receiver);
if (edit)
{
// We have a keypress for a lineedit...
QKeyEvent *kevent = static_cast<QKeyEvent *>(event);
int key = kevent->key() | kevent->modifiers();
if (_selectAll.contains(key))
{
if (t == QEvent::KeyPress)
{
edit->selectAll();
return true;
}
else
{
kevent->accept();
}
}
## snip ##
Strangely, other widgets seem to get their events just fine without
special hacks in KApplication.
Was anybody there when this was implemented? Can you see what it is or
was good for?
Cheers,
Andreas
More information about the kde-core-devel
mailing list