resourcenetconfig.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qlabel.h>
00022 #include <qlayout.h>
00023
00024 #include <klocale.h>
00025 #include <kstandarddirs.h>
00026
00027 #include "formatfactory.h"
00028 #include "stdaddressbook.h"
00029
00030 #include "resourcenetconfig.h"
00031
00032 using namespace KABC;
00033
00034 ResourceNetConfig::ResourceNetConfig( QWidget* parent, const char* name )
00035 : ResourceConfigWidget( parent, name )
00036 {
00037 resize( 245, 115 );
00038 QGridLayout *mainLayout = new QGridLayout( this, 2, 2 );
00039
00040 QLabel *label = new QLabel( i18n( "Format:" ), this );
00041 mFormatBox = new KComboBox( this );
00042
00043 mainLayout->addWidget( label, 0, 0 );
00044 mainLayout->addWidget( mFormatBox, 0, 1 );
00045
00046 label = new QLabel( i18n( "Location:" ), this );
00047 mUrlEdit = new KURLRequester( this );
00048 mUrlEdit->setMode( KFile::Directory );
00049
00050 mainLayout->addWidget( label, 1, 0 );
00051 mainLayout->addWidget( mUrlEdit, 1, 1 );
00052
00053 FormatFactory *factory = FormatFactory::self();
00054 QStringList formats = factory->formats();
00055 QStringList::Iterator it;
00056 for ( it = formats.begin(); it != formats.end(); ++it ) {
00057 FormatInfo *info = factory->info( *it );
00058 if ( info ) {
00059 mFormatTypes << (*it);
00060 mFormatBox->insertItem( info->nameLabel );
00061 }
00062 }
00063 }
00064
00065 void ResourceNetConfig::loadSettings( KConfig *config )
00066 {
00067 QString format = config->readEntry( "NetFormat" );
00068 mFormatBox->setCurrentItem( mFormatTypes.findIndex( format ) );
00069
00070 mUrlEdit->setURL( config->readPathEntry( "NetUrl" ) );
00071 if ( mUrlEdit->url().isEmpty() )
00072 mUrlEdit->setURL( KABC::StdAddressBook::directoryName() );
00073 }
00074
00075 void ResourceNetConfig::saveSettings( KConfig *config )
00076 {
00077 config->writeEntry( "NetFormat", mFormatTypes[ mFormatBox->currentItem() ] );
00078 config->writeEntry( "NetUrl", mUrlEdit->url() );
00079 }
00080
00081 #include "resourcenetconfig.moc"
This file is part of the documentation for kdelibs Version 3.1.5.