23 #include "resourcelocalconfig.h"
25 #include "resourcelocal_p.h"
29 #include <klocalizedstring.h>
30 #include <kmessagebox.h>
32 #include <kstandarddirs.h>
35 #include <QGridLayout>
48 class KCal::ResourceLocalConfig::Private
54 QGroupBox *mFormatGroup;
55 QRadioButton *mIcalButton;
56 QRadioButton *mVcalButton;
64 QGridLayout *mainLayout =
new QGridLayout(
this );
66 QLabel *label =
new QLabel( i18n(
"Location:" ),
this );
67 d->mURL =
new KUrlRequester(
this );
68 d->mURL->setFilter( i18n(
"*.ics *.vcs|Calendar Files" ) );
69 mainLayout->addWidget( label, 1, 0 );
70 mainLayout->addWidget( d->mURL, 1, 1 );
72 d->mFormatGroup =
new QGroupBox( i18n(
"Calendar Format" ),
this );
74 d->mIcalButton =
new QRadioButton( i18n(
"iCalendar" ), d->mFormatGroup );
75 d->mVcalButton =
new QRadioButton( i18n(
"vCalendar" ), d->mFormatGroup );
77 QVBoxLayout *vbox =
new QVBoxLayout;
78 vbox->addWidget( d->mIcalButton );
79 vbox->addWidget( d->mVcalButton );
80 vbox->addStretch( 1 );
81 d->mFormatGroup->setLayout( vbox );
83 mainLayout->addWidget( d->mFormatGroup, 2, 1 );
86 ResourceLocalConfig::~ResourceLocalConfig()
95 d->mURL->setUrl( res->d->mURL.prettyUrl() );
96 kDebug() <<
"Format typeid().name():" <<
typeid( res->d->mFormat ).name();
97 if (
typeid( *(res->d->mFormat) ) ==
typeid(
ICalFormat ) ) {
98 d->mIcalButton->setChecked(
true);
99 }
else if (
typeid( *(res->d->mFormat) ) ==
typeid( VCalFormat ) ) {
100 d->mVcalButton->setChecked(
true);
102 kDebug() <<
"ERROR: Unknown format type";
105 kDebug() <<
"ERROR: no ResourceLocal, cast failed";
109 void ResourceLocalConfig::saveSettings(
KRES::Resource *resource )
111 KUrl url = d->mURL->url();
113 if( url.isEmpty() ) {
115 QString saveFolder = dirs.saveLocation(
"data",
"korganizer" );
116 QFile file( saveFolder +
"/std.ics" );
119 for (
int i = 0; file.exists(); ++i ) {
120 file.setFileName( saveFolder +
"/std" + QString::number(i) +
".ics" );
123 KMessageBox::information(
125 i18n(
"You did not specify a URL for this resource. "
126 "Therefore, the resource will be saved in %1. "
127 "It is still possible to change this location "
128 "by editing the resource properties.", file.fileName() ) );
130 url = KUrl::fromPath( file.fileName() );
137 delete res->d->mFormat;
138 if ( d->mIcalButton->isDown() ) {
141 res->d->mFormat =
new VCalFormat();
144 kDebug() <<
"ERROR: no ResourceLocal, cast failed";
ResourceLocalConfig(QWidget *parent=0)
Private class that helps to provide binary compatibility between releases.
This file is part of the API for handling calendar data and defines the ResourceLocal class...
Provides a calendar resource stored as a local file.
Configuration widget for local file resource.