00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include <typeinfo>
00024
00025
#include <qlabel.h>
00026
#include <qlayout.h>
00027
00028
#include <klocale.h>
00029
#include <kdebug.h>
00030
#include <kstandarddirs.h>
00031
00032
#include "vcaldrag.h"
00033
#include "vcalformat.h"
00034
#include "icalformat.h"
00035
00036
#include "resourcelocal.h"
00037
00038
#include "resourcelocalconfig.h"
00039
00040
using namespace KCal;
00041
00042 ResourceLocalConfig::ResourceLocalConfig( QWidget* parent,
const char* name )
00043 : KRES::ConfigWidget( parent, name )
00044 {
00045 resize( 245, 115 );
00046 QGridLayout *mainLayout =
new QGridLayout(
this, 2, 2 );
00047
00048 QLabel *label =
new QLabel( i18n(
"Location:" ),
this );
00049 mURL =
new KURLRequester(
this );
00050 mainLayout->addWidget( label, 1, 0 );
00051 mainLayout->addWidget( mURL, 1, 1 );
00052
00053 formatGroup =
new QButtonGroup( 1, Horizontal, i18n(
"Calendar Format" ),
this );
00054
00055
00056
00057 icalButton =
new QRadioButton( i18n(
"iCalendar"), formatGroup );
00058 vcalButton =
new QRadioButton( i18n(
"vCalendar"), formatGroup );
00059
00060 mainLayout->addWidget( formatGroup, 2, 1 );
00061 }
00062
00063
void ResourceLocalConfig::loadSettings( KRES::Resource *resource )
00064 {
00065 ResourceLocal* res = static_cast<ResourceLocal*>( resource );
00066
if ( res ) {
00067 mURL->setURL( res->mURL.prettyURL() );
00068 kdDebug() <<
"Format typeid().name(): " <<
typeid( res->mFormat ).name() << endl;
00069
if (
typeid( *(res->mFormat) ) ==
typeid(
ICalFormat ) )
00070 formatGroup->setButton( 0 );
00071
else if (
typeid( *(res->mFormat) ) ==
typeid(
VCalFormat ) )
00072 formatGroup->setButton( 1 );
00073
else
00074 kdDebug() <<
"ERROR: ResourceLocalConfig::loadSettings(): Unknown format type" << endl;
00075 }
else
00076 kdDebug(5700) <<
"ERROR: ResourceLocalConfig::loadSettings(): no ResourceLocal, cast failed" << endl;
00077 }
00078
00079
void ResourceLocalConfig::saveSettings( KRES::Resource *resource )
00080 {
00081 ResourceLocal* res = static_cast<ResourceLocal*>( resource );
00082
if (res) {
00083 res->mURL = mURL->url();
00084
00085
delete res->mFormat;
00086
if ( icalButton->isOn() ) {
00087 res->mFormat =
new ICalFormat();
00088 }
else {
00089 res->mFormat =
new VCalFormat();
00090 }
00091 }
else
00092 kdDebug(5700) <<
"ERROR: ResourceLocalConfig::saveSettings(): no ResourceLocal, cast failed" << endl;
00093 }
00094
00095
#include "resourcelocalconfig.moc"