ktoolbar and index value

Benjamin Meyer ben at meyerhome.net
Mon Jul 19 15:44:30 BST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 19 July 2004 10:25 am, David Faure wrote:
> On Monday 19 July 2004 16:06, Benjamin Meyer wrote:
> > How about this?  If there is only 1 toolbar don't store the Index.  I
> > added another parameter to KToolBar::saveSettings with a default value. 
> > And then in KMainWindow it passes the arg stating if it is a lone toolbar
> > or not.
>
> You can't add an argument (even with a default value) to a public method,
> that's BIC. And IMHO this is an implementation detail, it shouldn't be a
> method argument.
>
> How about
>
>     KMainWindow *kmw = dynamic_cast<KMainWindow *>(mainWindow());
>     if ( !kmw || kmw->toolBarIterator().count() > 1 ); // don't save if
> there's only one toolbar config->writeEntry("Index", index);

Other than the ';' at the end of the if it looks good and works.  Would having 
revertToDefault as the else case cause any problems?  You wouldn't have to do 
the config->hasDefault("Index") check because it will always be 0 in that 
case and can be removed.

    KMainWindow *kmw = dynamic_cast<KMainWindow *>(mainWindow());
    // don't save if there's only one toolbar
    if ( !kmw || kmw->toolBarIterator().count() > 1 )
      config->writeEntry("Index", index);
    else
      config->revertToDefault("Index");

- -Benjamin Meyer 

- -- 
aka icefox
Public Key: http://www.csh.rit.edu/~benjamin/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFA+95S1rZ3LTw38vIRAiiuAKC6L1Yk4YeRfsIGmykGst32Y7p6gwCgimA8
kN8HE9iPZ27L2P/xclss+7o=
=7/Zj
-----END PGP SIGNATURE-----




More information about the kde-core-devel mailing list