24 #include <kbuttonbox.h>
25 #include <tdelistbox.h>
26 #include <tdelocale.h>
27 #include <tdemessagebox.h>
29 #include <tqgroupbox.h>
34 #include "selectdialog.h"
40 : KDialog( parent, name, true )
42 setCaption( i18n(
"Resource Selection" ) );
45 TQVBoxLayout *mainLayout =
new TQVBoxLayout(
this );
46 mainLayout->setMargin( marginHint() );
48 TQGroupBox *groupBox =
new TQGroupBox( 2, TQt::Horizontal,
this );
49 groupBox->setTitle( i18n(
"Resources" ) );
51 mResourceId =
new TDEListBox( groupBox );
53 mainLayout->addWidget( groupBox );
55 mainLayout->addSpacing( 10 );
57 KButtonBox *buttonBox =
new KButtonBox(
this );
59 buttonBox->addStretch();
60 buttonBox->addButton( KStdGuiItem::ok(),
this, TQ_SLOT( accept() ) );
61 buttonBox->addButton( KStdGuiItem::cancel(),
this, TQ_SLOT( reject() ) );
64 mainLayout->addWidget( buttonBox );
68 for ( uint i = 0; i < list.count(); ++i ) {
71 mResourceMap.insert( counter,
resource );
77 mResourceId->setCurrentItem( 0 );
78 connect( mResourceId, TQ_SIGNAL(returnPressed(TQListBoxItem*)),
80 connect( mResourceId, TQ_SIGNAL( executed( TQListBoxItem* ) ),
81 TQ_SLOT( accept() ) );
86 if ( mResourceId->currentItem() != -1 )
87 return mResourceMap[ mResourceId->currentItem() ];
94 if ( list.count() == 0 ) {
95 KMessageBox::error( parent, i18n(
"There is no resource available!" ) );
99 if ( list.count() == 1 )
return list.first();
120 if ( dlg.exec() == KDialog::Accepted )
return dlg.
resource();
This class provides a resource which is managed in a general way.
virtual bool readOnly() const
Returns, if the resource is read-only.
virtual TQString resourceName() const
Returns the name of resource.
Dialog for selecting a resource.
static Resource * getResource(TQPtrList< Resource > list, TQWidget *parent=0)
Opens a dialog showing the available resources and returns the resource the user has selected.
Resource * resource()
Returns selected resource.
SelectDialog(TQPtrList< Resource > list, TQWidget *parent=0, const char *name=0)
Constructor.