26 #include <kstandarddirs.h>
31 #include "formatfactory.h"
32 #include "resourcefile.h"
33 #include "stdaddressbook.h"
35 #include "resourcefileconfig.h"
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, TQ_SIGNAL( textChanged(
const TQString & ) ),
55 TQ_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"
This resource allows access to a local file.
void setFileName(const TQString &)
Set name of file to be used for saving.
void setFormat(const TQString &name)
Sets a new format by name.
TQString fileName() const
Return name of file used for loading and saving the address book.
TQString format() const
Returns the format name.
static TQString fileName()
Returns the default file name for vcard-based addressbook.
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
static data, shared by ALL addressee objects
TQString name(StdAccel id)
TQString label(StdAccel id)