21 #include "resourcecached.h"
24 #include <klocalizedstring.h>
26 #include "resourcecachedconfig.h"
29 #include <QRadioButton>
32 #include <QVBoxLayout>
35 #include <QButtonGroup>
42 class ResourceCachedConfigPrivate
45 ResourceCachedConfigPrivate()
50 QSpinBox *mIntervalSpin;
53 class KCal::ResourceCachedReloadConfig::Private
54 :
public ResourceCachedConfigPrivate
58 class KCal::ResourceCachedSaveConfig::Private
59 :
public ResourceCachedConfigPrivate
64 ResourceCachedReloadConfig::ResourceCachedReloadConfig( QWidget *parent )
67 QBoxLayout *topLayout =
new QVBoxLayout(
this );
69 QGroupBox *groupBox =
new QGroupBox( i18nc(
"@title:group",
"Automatic Reload" ),
this );
70 topLayout->addWidget( groupBox );
71 QRadioButton *noAutomaticReload =
73 i18nc(
"@option:radio never reload the cache",
"Never" ), groupBox );
74 QRadioButton *automaticReloadOnStartup =
76 i18nc(
"@option:radio reload the cache on startup",
"On startup" ), groupBox );
77 QRadioButton *intervalRadio =
79 i18nc(
"@option:radio reload the cache at regular intervals",
80 "Regular interval" ), groupBox );
81 d->mGroup =
new QButtonGroup(
this );
82 d->mGroup->addButton( noAutomaticReload, 0 );
83 d->mGroup->addButton( automaticReloadOnStartup, 1 );
84 d->mGroup->addButton( intervalRadio, 2 );
86 connect( intervalRadio, SIGNAL(toggled(
bool)),
87 SLOT(slotIntervalToggled(
bool)) );
89 KHBox *intervalBox =
new KHBox;
90 new QLabel( i18nc(
"@label:spinbox",
"Interval in minutes:" ), intervalBox );
91 d->mIntervalSpin =
new QSpinBox( intervalBox );
92 d->mIntervalSpin->setRange( 1, 900 );
93 d->mIntervalSpin->setEnabled(
false );
95 QVBoxLayout *vbox =
new QVBoxLayout;
96 vbox->addWidget(noAutomaticReload);
97 vbox->addWidget(automaticReloadOnStartup);
98 vbox->addWidget(intervalRadio);
99 vbox->addWidget(intervalBox);
101 groupBox->setLayout(vbox);
104 ResourceCachedReloadConfig::~ResourceCachedReloadConfig()
109 void ResourceCachedReloadConfig::loadSettings(
ResourceCached *resource )
111 d->mGroup->button( resource->
reloadPolicy() )->setChecked(
true );
115 void ResourceCachedReloadConfig::saveSettings(
ResourceCached *resource )
121 void ResourceCachedReloadConfig::slotIntervalToggled(
bool checked )
124 d->mIntervalSpin->setEnabled(
true );
126 d->mIntervalSpin->setEnabled(
false );
130 ResourceCachedSaveConfig::ResourceCachedSaveConfig( QWidget *parent )
133 QBoxLayout *topLayout =
new QVBoxLayout(
this );
135 QGroupBox *groupBox =
new QGroupBox( i18nc(
"@title:group",
"Automatic Save" ),
this );
136 d->mGroup =
new QButtonGroup(
this );
137 topLayout->addWidget( groupBox );
138 QRadioButton *never =
140 i18nc(
"@option:radio never save the cache automatically",
"Never" ), groupBox );
141 QRadioButton *onExit =
143 i18nc(
"@option:radio save the cache on exit",
"On exit" ), groupBox );
145 QRadioButton *intervalRadio =
147 i18nc(
"@option:radio save the cache at regular intervals",
"Regular interval" ), groupBox );
149 d->mGroup =
new QButtonGroup(
this );
150 d->mGroup->addButton( never, 0 );
151 d->mGroup->addButton( onExit, 1 );
152 d->mGroup->addButton( intervalRadio, 2 );
154 connect( intervalRadio, SIGNAL(toggled(
bool)),
155 SLOT(slotIntervalToggled(
bool)) );
157 KHBox *intervalBox =
new KHBox;
158 new QLabel( i18nc(
"@label:spinbox",
"Interval in minutes:" ), intervalBox );
159 d->mIntervalSpin =
new QSpinBox( intervalBox );
160 d->mIntervalSpin->setRange( 1, 900 );
161 d->mIntervalSpin->setEnabled(
false );
163 QRadioButton *delay =
165 i18nc(
"@option:radio save the cache after some delay",
166 "Delayed after changes" ), groupBox );
167 QRadioButton *every =
169 i18nc(
"@option:radio save the cache after every modification",
170 "On every change" ), groupBox );
171 d->mGroup->addButton( delay, 3 );
172 d->mGroup->addButton( every, 4 );
174 QVBoxLayout *vbox =
new QVBoxLayout;
175 vbox->addWidget(never);
176 vbox->addWidget(onExit);
177 vbox->addWidget(intervalRadio);
178 vbox->addWidget(intervalBox);
179 vbox->addWidget(delay);
180 vbox->addWidget(every);
182 groupBox->setLayout(vbox);
186 ResourceCachedSaveConfig::~ResourceCachedSaveConfig()
191 void ResourceCachedSaveConfig::loadSettings(
ResourceCached *resource )
193 d->mGroup->button( resource->
savePolicy() )->setChecked(
true );
197 void ResourceCachedSaveConfig::saveSettings(
ResourceCached *resource )
203 void ResourceCachedSaveConfig::slotIntervalToggled(
bool checked )
206 d->mIntervalSpin->setEnabled(
true );
208 d->mIntervalSpin->setEnabled(
false );
int savePolicy() const
Return save policy.
Configuration widget for save policy.
void setSavePolicy(int policy)
Set save policy.
Configuration widget for reload policy.
void setSaveInterval(int minutes)
Set save interval in minutes which is used when save policy is SaveInterval.
void setReloadInterval(int minutes)
Set reload interval in minutes which is used when reload policy is ReloadInterval.
int saveInterval() const
Return save interval in minutes.
int reloadInterval() const
Return reload interval in minutes.
This class provides a calendar resource using a local CalendarLocal object to cache the calendar data...
int reloadPolicy() const
Return reload policy.
void setReloadPolicy(int policy)
Set reload policy.