22 #include <kbuttonbox.h>
23 #include <tdelistbox.h>
24 #include <kstdguiitem.h>
26 #include <tqgroupbox.h>
30 #include "addressbook.h"
32 #include "resourceselectdialog.h"
36 ResourceSelectDialog::ResourceSelectDialog(
AddressBook *ab, TQWidget *parent,
const char *name )
39 setCaption( i18n(
"Resource Selection" ) );
42 TQVBoxLayout *mainLayout =
new TQVBoxLayout(
this );
43 mainLayout->setMargin( marginHint() );
45 TQGroupBox *groupBox =
new TQGroupBox( 2, TQt::Horizontal,
this );
46 groupBox->setTitle( i18n(
"Resources" ) );
50 mainLayout->addWidget( groupBox );
52 mainLayout->addSpacing( 10 );
57 buttonBox->
addButton( KStdGuiItem::ok(),
this, TQ_SLOT( accept() ) );
58 buttonBox->
addButton( KStdGuiItem::cancel(),
this, TQ_SLOT( reject() ) );
61 mainLayout->addWidget( buttonBox );
65 TQPtrList<Resource> list = ab->
resources();
66 for ( uint i = 0; i < list.count(); ++i ) {
67 Resource *resource = list.at( i );
68 if ( resource && !resource->readOnly() ) {
69 mResourceMap.insert( counter, resource );
70 mResourceId->insertItem( resource->resourceName() );
75 mResourceId->setCurrentItem( 0 );
78 Resource *ResourceSelectDialog::resource()
80 if ( mResourceId->currentItem() != -1 )
81 return mResourceMap[ mResourceId->currentItem() ];
86 Resource *ResourceSelectDialog::getResource(
AddressBook *ab, TQWidget *parent )
88 TQPtrList<Resource> resources = ab->
resources();
89 if ( resources.count() == 1 )
return resources.first();
92 Resource *r = resources.first();
94 if ( !r->readOnly() ) {
102 r = resources.next();
104 if ( found )
return found;
107 if ( dlg.exec() == KDialog::Accepted )
return dlg.resource();
111 #include "resourceselectdialog.moc"
TQPtrList< Resource > resources()
Returns a list of all resources.
static data, shared by ALL addressee objects
TQString name(StdAccel id)