28 #include <tdelocale.h>
29 #include <tdemessagebox.h>
31 #include <kstandarddirs.h>
34 #include "vcalformat.h"
35 #include "icalformat.h"
37 #include "resourcelocal.h"
39 #include "resourcelocalconfig.h"
43 ResourceLocalConfig::ResourceLocalConfig( TQWidget* parent, const char* name )
44 : KRES::ConfigWidget( parent, name )
47 TQGridLayout *mainLayout = new TQGridLayout( this, 2, 2 );
49 TQLabel *label = new TQLabel( i18n( "Location:" ), this );
50 mURL = new KURLRequester( this );
51 mainLayout->addWidget( label, 1, 0 );
52 mainLayout->addWidget( mURL, 1, 1 );
54 formatGroup = new TQButtonGroup( 1, TQt::Horizontal, i18n( "Calendar Format" ), this );
56 icalButton = new TQRadioButton( i18n( "iCalendar"), formatGroup );
57 vcalButton = new TQRadioButton( i18n( "vCalendar"), formatGroup );
59 mainLayout->addWidget( formatGroup, 2, 1 );
62 void ResourceLocalConfig::loadSettings( KRES::Resource *resource )
66 mURL->setURL( res->mURL.prettyURL() );
67 kdDebug(5800) << "Format typeid().name(): " << typeid( res->mFormat ).name() << endl;
68 if ( typeid( *(res->mFormat) ) == typeid( ICalFormat ) )
69 formatGroup->setButton( 0 );
70 else if ( typeid( *(res->mFormat) ) == typeid( VCalFormat ) )
71 formatGroup->setButton( 1 );
73 kdDebug(5800) << "ERROR: ResourceLocalConfig::loadSettings(): Unknown format type" << endl;
75 kdDebug(5800) << "ERROR: ResourceLocalConfig::loadSettings(): no ResourceLocal, cast failed" << endl;
78 void ResourceLocalConfig::saveSettings( KRES::Resource *resource )
80 TQString url = mURL->url();
84 TQString saveFolder = dirs.saveLocation( "data", "korganizer" );
85 TQFile file( saveFolder + "/std.ics" );
88 for( int i = 0; file.exists(); ++i )
89 file.setName( saveFolder + "/std" + TQString::number(i) + ".ics" );
91 KMessageBox::information( this, i18n( "You did not specify a URL for this resource. Therefore, the resource will be saved in %1. It is still possible to change this location by editing the resource properties." ).arg( file.name() ) );
101 if ( icalButton->isOn() ) {
107 kdDebug(5800) << "ERROR: ResourceLocalConfig::saveSettings(): no ResourceLocal, cast failed" << endl;
110 #include "resourcelocalconfig.moc"
This class provides a calendar resource stored as a local file.
Namespace KCal is for global classes, objects and/or functions in libkcal.
|