libkcal

resourcecachedconfig.cpp
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include <tqbuttongroup.h>
23#include <tqlayout.h>
24#include <tqradiobutton.h>
25#include <tqspinbox.h>
26#include <tqhbox.h>
27#include <tqlabel.h>
28
29#include <tdelocale.h>
30#include <kdebug.h>
31
32#include "resourcecached.h"
33
34#include "resourcecachedconfig.h"
35
36using namespace KCal;
37
38ResourceCachedReloadConfig::ResourceCachedReloadConfig( TQWidget *parent,
39 const char *name )
40 : TQWidget( parent, name )
41{
42 TQBoxLayout *topLayout = new TQVBoxLayout( this );
43
44 mGroup = new TQButtonGroup( 1, TQt::Horizontal, i18n("Automatic Reload"), this );
45 topLayout->addWidget( mGroup );
46 new TQRadioButton( i18n("Never"), mGroup );
47 new TQRadioButton( i18n("On startup"), mGroup );
48
49 TQRadioButton *intervalRadio = new TQRadioButton( i18n("Regular interval"),
50 mGroup );
51 connect( intervalRadio, TQ_SIGNAL( stateChanged( int ) ),
52 TQ_SLOT( slotIntervalStateChanged( int ) ) );
53 TQHBox *intervalBox = new TQHBox( mGroup );
54 new TQLabel( i18n("Interval in minutes"), intervalBox );
55 mIntervalSpin = new TQSpinBox( 1,900, 1,intervalBox );
56 mIntervalSpin->setEnabled( false );
57}
58
59void ResourceCachedReloadConfig::loadSettings( ResourceCached *resource )
60{
61 mGroup->setButton( resource->reloadPolicy() );
62 mIntervalSpin->setValue( resource->reloadInterval() );
63}
64
65void ResourceCachedReloadConfig::saveSettings( ResourceCached *resource )
66{
67 resource->setReloadPolicy( mGroup->selectedId() );
68 resource->setReloadInterval( mIntervalSpin->value() );
69}
70
71void ResourceCachedReloadConfig::slotIntervalStateChanged( int state )
72{
73 if ( state == TQButton::On ) mIntervalSpin->setEnabled( true );
74 else mIntervalSpin->setEnabled( false );
75}
76
77
78ResourceCachedSaveConfig::ResourceCachedSaveConfig( TQWidget *parent,
79 const char *name )
80 : TQWidget( parent, name )
81{
82 TQBoxLayout *topLayout = new TQVBoxLayout( this );
83
84 mGroup = new TQButtonGroup( 1, TQt::Horizontal, i18n("Automatic Save"), this );
85 topLayout->addWidget( mGroup );
86 new TQRadioButton( i18n("Never"), mGroup );
87 new TQRadioButton( i18n("On exit"), mGroup );
88
89 TQRadioButton *intervalRadio = new TQRadioButton( i18n("Regular interval"),
90 mGroup );
91 connect( intervalRadio, TQ_SIGNAL( stateChanged( int ) ),
92 TQ_SLOT( slotIntervalStateChanged( int ) ) );
93 TQHBox *intervalBox = new TQHBox( mGroup );
94 new TQLabel( i18n("Interval in minutes"), intervalBox );
95 mIntervalSpin = new TQSpinBox( 1,900, 1,intervalBox );
96 mIntervalSpin->setEnabled( false );
97
98 new TQRadioButton( i18n("Delayed after changes"), mGroup );
99 new TQRadioButton( i18n("On every change"), mGroup );
100}
101
102void ResourceCachedSaveConfig::loadSettings( ResourceCached *resource )
103{
104 mGroup->setButton( resource->savePolicy() );
105 mIntervalSpin->setValue( resource->saveInterval() );
106}
107
108void ResourceCachedSaveConfig::saveSettings( ResourceCached *resource )
109{
110 resource->setSavePolicy( mGroup->selectedId() );
111 resource->setSaveInterval( mIntervalSpin->value() );
112}
113
114void ResourceCachedSaveConfig::slotIntervalStateChanged( int state )
115{
116 if ( state == TQButton::On ) mIntervalSpin->setEnabled( true );
117 else mIntervalSpin->setEnabled( false );
118}
119
120#include "resourcecachedconfig.moc"
This class provides a calendar resource using a local CalendarLocal object to cache the calendar data...
void setSavePolicy(int policy)
Set save policy.
int reloadInterval() const
Return reload interval in minutes.
int reloadPolicy() const
Return reload policy.
void setSaveInterval(int minutes)
Set save interval in minutes which is used when save policy is SaveInterval.
int savePolicy() const
Return save policy.
void setReloadInterval(int minutes)
Set reload interval in minutes which is used when reload policy is ReloadInterval.
void setReloadPolicy(int policy)
Set reload policy.
int saveInterval() const
Return save interval in minutes.
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38