[PATCH] Make KJanusWidget consistent
Ravikiran Rajagopal
ravi at ee.eng.ohio-state.edu
Tue Feb 18 19:42:54 GMT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
KJanusWidget has a consistency problem. The function showPage(int) is
virtual but it is not used by slotShowPage() to show actual pages. Hence, if
we want to do some processing in a derived class after showing a page, we
cannot do so. For example, somthing like the following does not work (MyClass
is derived from KJanusWidget):
bool MyClass::showPage(int index)
{
boot ret = KJanusWidget::showPage(index);
doSomeProcessing();
return ret;
}
Thus, the whole point of KJanusWidget::showPage(int) being virtual is
defeated! The following patch makes showPage(int) overrides usable:
- --- kjanuswidget.cpp.orig 2003-02-18 14:18:27.000000000 -0500
+++ kjanuswidget.cpp 2003-02-18 14:19:47.000000000 -0500
@@ -540,14 +540,14 @@
if( node == 0 ) { return( false ); }
QWidget *stackItem = mTreeListToPageStack[node];
- - return showPage(stackItem);
+ return showPage(pageIndex(stackItem));
}
else if( mFace == IconList )
{
QListBoxItem *node = mIconList->item( mIconList->currentItem() );
if( node == 0 ) { return( false ); }
QWidget *stackItem = mIconListToPageStack[node];
- - return showPage(stackItem);
+ return showPage(pageIndex(stackItem));
}
return( false );
Note that we should NOT make showPage(QWidget *) virtual because it would be
BIC and, more importantly, it does not perform sanity checks. Actual usage
instance: give the newly shown page widget the focus (like in KControl). This
can be done only after the widget is already shown, and hence we cannot
connect to the aboutToShowPage() signal.
I am surprised that no one has noticed this sooner as KJanusWidget is such an
important base class. Please cc me on any replies as I am not subscribed to
this list.
Thank you for your attention,
Ravi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE+UozHbI8Y8y0oVXcRAkO0AJ4oXieZqyx/EFw1UrLASNU7KiyPNgCfdz5P
L2Sb+xmbgCyjzQJwyQUfwzE=
=deyw
-----END PGP SIGNATURE-----
More information about the kde-core-devel
mailing list