26 #include <kstandarddirs.h>
31 #include "formatfactory.h"
32 #include "resourcefile.h"
33 #include "stdaddressbook.h"
35 #include "resourcefileconfig.h"
37 using namespace TDEABC;
39 ResourceFileConfig::ResourceFileConfig( TQWidget* parent,
const char* name )
40 : ConfigWidget( parent, name )
42 TQGridLayout *mainLayout =
new TQGridLayout(
this, 2, 2, 0,
45 TQLabel *
label =
new TQLabel( i18n(
"Format:" ),
this );
48 mainLayout->addWidget( label, 0, 0 );
49 mainLayout->addWidget( mFormatBox, 0, 1 );
51 label =
new TQLabel( i18n(
"Location:" ),
this );
52 mFileNameEdit =
new KURLRequester(
this );
54 connect( mFileNameEdit, TQT_SIGNAL( textChanged(
const TQString & ) ),
55 TQT_SLOT( checkFilePermissions(
const TQString & ) ) );
57 mainLayout->addWidget( label, 1, 0 );
58 mainLayout->addWidget( mFileNameEdit, 1, 1 );
61 TQStringList formats = factory->
formats();
62 TQStringList::Iterator it;
63 for ( it = formats.begin(); it != formats.end(); ++it ) {
64 FormatInfo *info = factory->
info( *it );
66 mFormatTypes << (*it);
67 mFormatBox->insertItem( info->nameLabel );
74 void ResourceFileConfig::setEditMode(
bool value )
76 mFormatBox->setEnabled( !value );
80 void ResourceFileConfig::loadSettings( KRES::Resource *res )
85 kdDebug(5700) <<
"ResourceFileConfig::loadSettings(): cast failed" <<
endl;
89 mFormatBox->setCurrentItem( mFormatTypes.findIndex( resource->
format() ) );
91 mFileNameEdit->setURL( resource->
fileName() );
92 if ( mFileNameEdit->url().isEmpty() )
96 void ResourceFileConfig::saveSettings( KRES::Resource *res )
101 kdDebug(5700) <<
"ResourceFileConfig::saveSettings(): cast failed" <<
endl;
106 resource->
setFormat( mFormatTypes[ mFormatBox->currentItem() ] );
111 void ResourceFileConfig::checkFilePermissions(
const TQString& fileName )
114 if ( access( TQFile::encodeName( fileName ), F_OK ) == 0 )
115 emit setReadOnly( access( TQFile::encodeName( fileName ), W_OK ) < 0 );
118 #include "resourcefileconfig.moc"