Warning, file /office/calligra/libs/widgets/KoVBox.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE libraries 0002 Copyright (C) 2005 David Faure <faure@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License version 2 as published by the Free Software Foundation. 0007 0008 This library is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 Library General Public License for more details. 0012 0013 You should have received a copy of the GNU Library General Public License 0014 along with this library; see the file COPYING.LIB. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "KoVBox.h" 0020 0021 #include <QEvent> 0022 #include <QApplication> 0023 #include <QVBoxLayout> 0024 0025 KoVBox::KoVBox(QWidget *parent) 0026 : QFrame(parent), 0027 d(0) 0028 { 0029 QVBoxLayout *layout = new QVBoxLayout(this); 0030 layout->setSpacing(0); 0031 layout->setMargin(0); 0032 0033 setLayout(layout); 0034 } 0035 0036 KoVBox::~KoVBox() 0037 { 0038 } 0039 0040 void KoVBox::childEvent(QChildEvent *event) 0041 { 0042 switch (event->type()) { 0043 case QEvent::ChildAdded: { 0044 QChildEvent *childEvent = static_cast<QChildEvent *>(event); 0045 if (childEvent->child()->isWidgetType()) { 0046 QWidget *widget = static_cast<QWidget *>(childEvent->child()); 0047 static_cast<QBoxLayout *>(layout())->addWidget(widget); 0048 } 0049 0050 break; 0051 } 0052 case QEvent::ChildRemoved: { 0053 QChildEvent *childEvent = static_cast<QChildEvent *>(event); 0054 if (childEvent->child()->isWidgetType()) { 0055 QWidget *widget = static_cast<QWidget *>(childEvent->child()); 0056 static_cast<QBoxLayout *>(layout())->removeWidget(widget); 0057 } 0058 0059 break; 0060 } 0061 default: 0062 break; 0063 } 0064 QFrame::childEvent(event); 0065 } 0066 0067 QSize KoVBox::sizeHint() const 0068 { 0069 KoVBox *that = const_cast<KoVBox *>(this); 0070 QApplication::sendPostedEvents(that, QEvent::ChildAdded); 0071 0072 return QFrame::sizeHint(); 0073 } 0074 0075 QSize KoVBox::minimumSizeHint() const 0076 { 0077 KoVBox *that = const_cast<KoVBox *>(this); 0078 QApplication::sendPostedEvents(that, QEvent::ChildAdded); 0079 0080 return QFrame::minimumSizeHint(); 0081 } 0082 0083 void KoVBox::setSpacing(int spacing) 0084 { 0085 layout()->setSpacing(spacing); 0086 } 0087 0088 void KoVBox::setStretchFactor(QWidget *widget, int stretch) 0089 { 0090 static_cast<QBoxLayout *>(layout())->setStretchFactor(widget, stretch); 0091 } 0092 0093 void KoVBox::setMargin(int margin) 0094 { 0095 layout()->setMargin(margin); 0096 } 0097