1 //=============================================================================
2 //
3 // File : KviTalVBox.cpp
4 // Creation date : Mon Jan 22 2007 11:25:08 by Szymon Stefanek
5 //
6 // This file is part of the KVIrc IRC client distribution
7 // Copyright (C) 2007 Szymon Stefanek (pragma at kvirc dot net)
8 // Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org)
9 //
10 // This program is FREE software. You can redistribute it and/or
11 // modify it under the terms of the GNU General Public License
12 // as published by the Free Software Foundation; either version 2
13 // of the License, or (at your option) any later version.
14 //
15 // This program is distributed in the HOPE that it will be USEFUL,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 // See the GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, write to the Free Software Foundation,
22 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 //=============================================================================
25
26 #include "KviTalVBox.h"
27
28 #include <QChildEvent>
29
KviTalVBox(QWidget * pParent,char * pcName)30 KviTalVBox::KviTalVBox(QWidget * pParent, char * pcName)
31 : QWidget(pParent)
32 {
33 setObjectName(pcName);
34
35 m_pLayout = new QVBoxLayout(this);
36 m_pLayout->setMargin(3);
37 m_pLayout->setSpacing(2);
38
39 setLayout(m_pLayout);
40 }
41
42 KviTalVBox::~KviTalVBox()
43 = default;
44
childEvent(QChildEvent * e)45 void KviTalVBox::childEvent(QChildEvent * e)
46 {
47 if(!e->child()->isWidgetType())
48 return;
49 if(e->child()->parent() != this)
50 return;
51
52 switch(e->type())
53 {
54 case QEvent::ChildAdded:
55 m_pLayout->addWidget((QWidget *)(e->child()));
56 break;
57 case QEvent::ChildRemoved:
58 m_pLayout->removeWidget((QWidget *)(e->child()));
59 break;
60 default:
61 break;
62 }
63 }
64
setStretchFactor(QWidget * pChild,int iStretch)65 void KviTalVBox::setStretchFactor(QWidget * pChild, int iStretch)
66 {
67 m_pLayout->setStretchFactor(pChild, iStretch);
68 }
69
setSpacing(int iSpacing)70 void KviTalVBox::setSpacing(int iSpacing)
71 {
72 m_pLayout->setSpacing(iSpacing);
73 }
74
addStretch(int iStretch)75 void KviTalVBox::addStretch(int iStretch)
76 {
77 m_pLayout->addStretch(iStretch);
78 }
79
setMargin(int iMargin)80 void KviTalVBox::setMargin(int iMargin)
81 {
82 m_pLayout->setContentsMargins(iMargin, iMargin, iMargin, iMargin);
83 }
84
setAlignment(Qt::Alignment alignment)85 void KviTalVBox::setAlignment(Qt::Alignment alignment)
86 {
87 m_pLayout->setAlignment(alignment);
88 }
89
setAlignment(QWidget * pChild,Qt::Alignment alignment)90 void KviTalVBox::setAlignment(QWidget * pChild, Qt::Alignment alignment)
91 {
92 m_pLayout->setAlignment(pChild, alignment);
93 }
94