kdeui
ktoolbarradiogroup.cpp
Go to the documentation of this file.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., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #include <config.h> 00024 00025 #include "ktoolbarradiogroup.h" 00026 #include "ktoolbar.h" 00027 #include "ktoolbarbutton.h" 00028 00029 /************************************************************************* 00030 * KToolBarRadioGroup * 00031 *************************************************************************/ 00032 00033 00034 KToolBarRadioGroup::KToolBarRadioGroup (KToolBar *_parent, const char *_name) 00035 : QObject(_parent, _name) 00036 { 00037 buttons = new KToolBarButtonList(); 00038 tb = _parent; 00039 connect (tb, SIGNAL(toggled(int)), this, SLOT(slotToggled(int))); 00040 } 00041 00042 KToolBarRadioGroup::~KToolBarRadioGroup() 00043 { 00044 delete buttons; 00045 } 00046 00047 void KToolBarRadioGroup::addButton (int id) 00048 { 00049 KToolBarButton *b = tb->getButton( id ); 00050 b->setRadio( true ); 00051 buttons->insert( id, b ); 00052 } 00053 00054 void KToolBarRadioGroup::removeButton (int id) 00055 { 00056 if (!buttons->find(id)) 00057 return; 00058 buttons->find(id)->setRadio(false); 00059 buttons->remove(id); 00060 } 00061 00062 void KToolBarRadioGroup::slotToggled(int id) 00063 { 00064 if (buttons->find(id) && buttons->find(id)->isOn()) 00065 { 00066 QIntDictIterator<KToolBarButton> it(*buttons); 00067 while (it.current()) 00068 { 00069 if (it.currentKey() != id) 00070 it.current()->on(false); 00071 ++it; 00072 } 00073 } 00074 } 00075 00076 #include "ktoolbarradiogroup.moc" 00077