32 #include "kwidgetlister.h"
37 #include <tqpushbutton.h>
43 #include <kpushbutton.h>
46 KWidgetLister::KWidgetLister(
int minWidgets,
int maxWidgets, TQWidget *parent,
const char* name )
47 : TQWidget( parent, name )
49 mWidgetList.setAutoDelete(TRUE);
51 mMinWidgets = TQMAX( minWidgets, 1 );
52 mMaxWidgets = TQMAX( maxWidgets, mMinWidgets + 1 );
55 mLayout =
new TQVBoxLayout(
this, 0, 4);
56 mButtonBox =
new TQHBox(
this);
57 mButtonBox->setSpacing( KDialog::spacingHint() );
58 mLayout->addWidget( mButtonBox );
60 mBtnMore =
new KPushButton( KGuiItem( i18n(
"more widgets",
"More" ),
"button_more" ), mButtonBox );
61 mButtonBox->setStretchFactor( mBtnMore, 0 );
63 mBtnFewer =
new KPushButton( KGuiItem( i18n(
"fewer widgets",
"Fewer" ),
"button_fewer" ), mButtonBox );
64 mButtonBox->setStretchFactor( mBtnFewer, 0 );
66 TQWidget *spacer =
new TQWidget( mButtonBox );
67 mButtonBox->setStretchFactor( spacer, 1 );
70 mBtnClear =
new KPushButton( KGuiItem( i18n(
"clear widgets",
"Clear" ),
"locationbar_erase" ), mButtonBox );
71 mButtonBox->setStretchFactor( mBtnClear, 0 );
74 connect( mBtnMore, TQT_SIGNAL(clicked()),
75 this, TQT_SLOT(slotMore()) );
76 connect( mBtnFewer, TQT_SIGNAL(clicked()),
77 this, TQT_SLOT(slotFewer()) );
78 connect( mBtnClear, TQT_SIGNAL(clicked()),
79 this, TQT_SLOT(slotClear()) );
84 KWidgetLister::~KWidgetLister()
116 for ( it.toFirst() ; it.current() ; ++it )
128 mLayout->insertWidget( mLayout->findWidget( mButtonBox ), w );
151 return new TQWidget( parent );
156 int superfluousWidgets = TQMAX( (
int)
mWidgetList.count() - aNum, 0 );
157 int missingWidgets = TQMAX( aNum - (
int)
mWidgetList.count(), 0 );
160 for ( ; superfluousWidgets ; superfluousWidgets-- )
164 for ( ; missingWidgets ; missingWidgets-- )
168 void KWidgetLister::enableControls()
174 mBtnMore->setEnabled( !isMaxWidgets );
175 mBtnFewer->setEnabled( !isMinWidgets );
178 #include "kwidgetlister.moc"