00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "resourcelocaldirconfig.h"
00023 #include "resourcelocaldir.h"
00024 #include "resourcelocaldir_p.h"
00025
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 #include <kstandarddirs.h>
00029 #include <kurlrequester.h>
00030 #include <KMessageBox>
00031
00032 #include <QtGui/QLabel>
00033 #include <QtGui/QLayout>
00034 #include <QtGui/QGridLayout>
00035
00036 #include <typeinfo>
00037
00038 #include "resourcelocaldirconfig.moc"
00039
00040 using namespace KCal;
00041
00046
00047 class KCal::ResourceLocalDirConfig::Private
00048 {
00049 public:
00050 Private()
00051 {}
00052 KUrlRequester *mURL;
00053 };
00054
00055
00056 ResourceLocalDirConfig::ResourceLocalDirConfig( QWidget *parent )
00057 : KRES::ConfigWidget( parent ), d( new KCal::ResourceLocalDirConfig::Private )
00058 {
00059 resize( 245, 115 );
00060 QGridLayout *mainLayout = new QGridLayout( this );
00061
00062 QLabel *label = new QLabel( i18n( "Location:" ), this );
00063 d->mURL = new KUrlRequester( this );
00064 d->mURL->setMode( KFile::Directory | KFile::LocalOnly );
00065 mainLayout->addWidget( label, 1, 0 );
00066 mainLayout->addWidget( d->mURL, 1, 1 );
00067 }
00068
00069 ResourceLocalDirConfig::~ResourceLocalDirConfig()
00070 {
00071 delete d;
00072 }
00073
00074 void ResourceLocalDirConfig::loadSettings( KRES::Resource *resource )
00075 {
00076 ResourceLocalDir *res = static_cast<ResourceLocalDir*>( resource );
00077 if ( res ) {
00078 d->mURL->setUrl( res->d->mURL.prettyUrl() );
00079 } else {
00080 kDebug() << "ERROR: no ResourceLocalDir, cast failed";
00081 }
00082 }
00083
00084 void ResourceLocalDirConfig::saveSettings( KRES::Resource *resource )
00085 {
00086 ResourceLocalDir *res = static_cast<ResourceLocalDir*>( resource );
00087 if (res) {
00088 res->d->mURL = d->mURL->url();
00089 if ( d->mURL->url().isEmpty() && !resource->readOnly() ) {
00090 KMessageBox::information(
00091 this,
00092 i18nc( "@info", "No location specified. The calendar will be invalid." ),
00093 QString(),
00094 "ResourceLocalDirUrl");
00095 resource->setReadOnly( true );
00096 }
00097 } else {
00098 kDebug() << "ERROR: no ResourceLocalDir, cast failed";
00099 }
00100 }