kalarm Library API Documentation

buttongroup.cpp

00001 /*
00002  *  buttongroup.cpp  -  QButtonGroup with an extra signal and KDE 2 compatibility
00003  *  Program:  kalarm
00004  *  (C) 2002 by David Jarvie  software@astrojar.org.uk
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *
00020  *  As a special exception, permission is given to link this program
00021  *  with any edition of Qt, and distribute the resulting executable,
00022  *  without including the source code for Qt in the source distribution.
00023  */
00024 #include "kalarm.h"
00025 
00026 #include <qlayout.h>
00027 #include <kdialog.h>
00028 
00029 #include "buttongroup.moc"
00030 
00031 
00032 ButtonGroup::ButtonGroup(QWidget* parent, const char* name)
00033         : QButtonGroup(parent, name)
00034 #if QT_VERSION < 300
00035         , defaultAlignment(-1)
00036 #endif
00037 {
00038         connect(this, SIGNAL(clicked(int)), SIGNAL(buttonSet(int)));
00039 }
00040 
00041 ButtonGroup::ButtonGroup(const QString& title, QWidget* parent, const char* name)
00042         : QButtonGroup(title, parent, name)
00043 #if QT_VERSION < 300
00044         , defaultAlignment(-1)
00045 #endif
00046 {
00047         connect(this, SIGNAL(clicked(int)), SIGNAL(buttonSet(int)));
00048 }
00049 
00050 ButtonGroup::ButtonGroup(int strips, Qt::Orientation orient, QWidget* parent, const char* name)
00051         : QButtonGroup(strips, orient, parent, name)
00052 #if QT_VERSION < 300
00053         , defaultAlignment(orient == Qt::Horizontal ? Qt::AlignLeft : 0)
00054 #endif
00055 {
00056         connect(this, SIGNAL(clicked(int)), SIGNAL(buttonSet(int)));
00057 }
00058 
00059 ButtonGroup::ButtonGroup(int strips, Qt::Orientation orient, const QString& title, QWidget* parent, const char* name)
00060         : QButtonGroup(strips, orient, title, parent, name)
00061 #if QT_VERSION < 300
00062         , defaultAlignment(orient == Qt::Horizontal ? Qt::AlignLeft : 0)
00063 #endif
00064 {
00065         connect(this, SIGNAL(clicked(int)), SIGNAL(buttonSet(int)));
00066 }
00067 
00068 #if QT_VERSION < 300
00069 /******************************************************************************
00070  * In a vertical layout, this adds widgets left aligned instead of QT 2's
00071  * centre aligned default.
00072  */
00073 void ButtonGroup::childEvent(QChildEvent *ce)
00074 {
00075         if (defaultAlignment != -1  &&  ce->inserted()  &&  ce->child()->isWidgetType())
00076         {
00077                 QWidget* child = (QWidget*)ce->child();
00078                 if (!child->isTopLevel())    //ignore dialogs etc.
00079                 {
00080                         ((QBoxLayout*)layout())->addWidget(child, 0, defaultAlignment);
00081                         QApplication::postEvent(this, new QEvent(QEvent::LayoutHint));
00082                 }
00083         }
00084 }
00085 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:26 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001