kdeui Library API Documentation

ktoolbarradiogroup.cpp

00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
00003               (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
00004               (C) 1997, 1998 Sven Radej (radej@kde.org)
00005               (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
00006               (C) 1999 Chris Schlaeger (cs@kde.org)
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License version 2 as published by the Free Software Foundation.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020     Boston, MA 02111-1307, USA.
00021 */
00022 
00023 // $Id: ktoolbarradiogroup.cpp,v 1.7 2000/07/11 19:24:15 reggie Exp $
00024 #include <config.h>
00025 
00026 #include "ktoolbarradiogroup.h"
00027 #include "ktoolbar.h"
00028 #include "ktoolbarbutton.h"
00029 
00030 /*************************************************************************
00031  *                          KToolBarRadioGroup                                  *
00032  *************************************************************************/
00033 
00034 
00035 KToolBarRadioGroup::KToolBarRadioGroup (KToolBar *_parent, const char *_name)
00036 : QObject(_parent, _name)
00037 {
00038   buttons = new KToolBarButtonList();
00039   tb = _parent;
00040   connect (tb, SIGNAL(toggled(int)), this, SLOT(slotToggled(int)));
00041 }
00042 
00043 KToolBarRadioGroup::~KToolBarRadioGroup()
00044 {
00045   delete buttons;
00046 }
00047 
00048 void KToolBarRadioGroup::addButton (int id)
00049 {
00050     KToolBarButton *b = tb->getButton( id );
00051     b->setRadio( TRUE );
00052     buttons->insert( id, b );
00053 }
00054 
00055 void KToolBarRadioGroup::removeButton (int id)
00056 {
00057   if (!buttons->find(id))
00058      return;
00059   buttons->find(id)->setRadio(false);
00060   buttons->remove(id);
00061 }
00062 
00063 void KToolBarRadioGroup::slotToggled(int id)
00064 {
00065   if (buttons->find(id) && buttons->find(id)->isOn())
00066   {
00067     QIntDictIterator<KToolBarButton> it(*buttons);
00068     while (it.current())
00069     {
00070       if (it.currentKey() != id)
00071         it.current()->on(false);
00072       ++it;
00073     }
00074   }
00075 }
00076 
00077 #include "ktoolbarradiogroup.moc"
00078 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:02 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001