23 #include "resourcelocalconfig.h"
25 #include "resourcelocal_p.h"
30 #include <kmessagebox.h>
32 #include <kstandarddirs.h>
34 #include <QtGui/QLabel>
35 #include <QtGui/QGridLayout>
36 #include <QtGui/QGroupBox>
40 #include "resourcelocalconfig.moc"
49 class KCal::ResourceLocalConfig::Private
55 QGroupBox *mFormatGroup;
56 QRadioButton *mIcalButton;
57 QRadioButton *mVcalButton;
65 QGridLayout *mainLayout =
new QGridLayout(
this );
67 QLabel *label =
new QLabel( i18n(
"Location:" ),
this );
68 d->mURL =
new KUrlRequester(
this );
69 d->mURL->setFilter( i18n(
"*.ics *.vcs|Calendar Files" ) );
70 mainLayout->addWidget( label, 1, 0 );
71 mainLayout->addWidget( d->mURL, 1, 1 );
73 d->mFormatGroup =
new QGroupBox( i18n(
"Calendar Format" ),
this );
75 d->mIcalButton =
new QRadioButton( i18n(
"iCalendar" ), d->mFormatGroup );
76 d->mVcalButton =
new QRadioButton( i18n(
"vCalendar" ), d->mFormatGroup );
78 QVBoxLayout *vbox =
new QVBoxLayout;
79 vbox->addWidget( d->mIcalButton );
80 vbox->addWidget( d->mVcalButton );
81 vbox->addStretch( 1 );
82 d->mFormatGroup->setLayout( vbox );
84 mainLayout->addWidget( d->mFormatGroup, 2, 1 );
87 ResourceLocalConfig::~ResourceLocalConfig()
96 d->mURL->setUrl( res->d->mURL.prettyUrl() );
97 kDebug() <<
"Format typeid().name():" <<
typeid( res->d->mFormat ).name();
98 if (
typeid( *(res->d->mFormat) ) ==
typeid(
ICalFormat ) ) {
99 d->mIcalButton->setChecked(
true);
100 }
else if (
typeid( *(res->d->mFormat) ) ==
typeid( VCalFormat ) ) {
101 d->mVcalButton->setChecked(
true);
103 kDebug() <<
"ERROR: Unknown format type";
106 kDebug() <<
"ERROR: no ResourceLocal, cast failed";
110 void ResourceLocalConfig::saveSettings(
KRES::Resource *resource )
112 KUrl url = d->mURL->url();
114 if( url.isEmpty() ) {
116 QString saveFolder = dirs.saveLocation(
"data",
"korganizer" );
117 QFile file( saveFolder +
"/std.ics" );
120 for (
int i = 0; file.exists(); ++i ) {
121 file.setFileName( saveFolder +
"/std" + QString::number(i) +
".ics" );
124 KMessageBox::information(
126 i18n(
"You did not specify a URL for this resource. "
127 "Therefore, the resource will be saved in %1. "
128 "It is still possible to change this location "
129 "by editing the resource properties.", file.fileName() ) );
131 url = KUrl::fromPath( file.fileName() );
138 delete res->d->mFormat;
139 if ( d->mIcalButton->isDown() ) {
142 res->d->mFormat =
new VCalFormat();
145 kDebug() <<
"ERROR: no ResourceLocal, cast failed";