resourcecachedconfig.cpp
00001 /* 00002 This file is part of libkcal. 00003 00004 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include <tqbuttongroup.h> 00023 #include <tqlayout.h> 00024 #include <tqradiobutton.h> 00025 #include <tqspinbox.h> 00026 #include <tqhbox.h> 00027 #include <tqlabel.h> 00028 00029 #include <klocale.h> 00030 #include <kdebug.h> 00031 00032 #include "resourcecached.h" 00033 00034 #include "resourcecachedconfig.h" 00035 00036 using namespace KCal; 00037 00038 ResourceCachedReloadConfig::ResourceCachedReloadConfig( TQWidget *parent, 00039 const char *name ) 00040 : TQWidget( parent, name ) 00041 { 00042 TQBoxLayout *topLayout = new TQVBoxLayout( this ); 00043 00044 mGroup = new TQButtonGroup( 1, Qt::Horizontal, i18n("Automatic Reload"), this ); 00045 topLayout->addWidget( mGroup ); 00046 new TQRadioButton( i18n("Never"), mGroup ); 00047 new TQRadioButton( i18n("On startup"), mGroup ); 00048 00049 TQRadioButton *intervalRadio = new TQRadioButton( i18n("Regular interval"), 00050 mGroup ); 00051 connect( intervalRadio, TQT_SIGNAL( stateChanged( int ) ), 00052 TQT_SLOT( slotIntervalStateChanged( int ) ) ); 00053 TQHBox *intervalBox = new TQHBox( mGroup ); 00054 new TQLabel( i18n("Interval in minutes"), intervalBox ); 00055 mIntervalSpin = new TQSpinBox( 1,900, 1,intervalBox ); 00056 mIntervalSpin->setEnabled( false ); 00057 } 00058 00059 void ResourceCachedReloadConfig::loadSettings( ResourceCached *resource ) 00060 { 00061 mGroup->setButton( resource->reloadPolicy() ); 00062 mIntervalSpin->setValue( resource->reloadInterval() ); 00063 } 00064 00065 void ResourceCachedReloadConfig::saveSettings( ResourceCached *resource ) 00066 { 00067 resource->setReloadPolicy( mGroup->selectedId() ); 00068 resource->setReloadInterval( mIntervalSpin->value() ); 00069 } 00070 00071 void ResourceCachedReloadConfig::slotIntervalStateChanged( int state ) 00072 { 00073 if ( state == TQButton::On ) mIntervalSpin->setEnabled( true ); 00074 else mIntervalSpin->setEnabled( false ); 00075 } 00076 00077 00078 ResourceCachedSaveConfig::ResourceCachedSaveConfig( TQWidget *parent, 00079 const char *name ) 00080 : TQWidget( parent, name ) 00081 { 00082 TQBoxLayout *topLayout = new TQVBoxLayout( this ); 00083 00084 mGroup = new TQButtonGroup( 1, Qt::Horizontal, i18n("Automatic Save"), this ); 00085 topLayout->addWidget( mGroup ); 00086 new TQRadioButton( i18n("Never"), mGroup ); 00087 new TQRadioButton( i18n("On exit"), mGroup ); 00088 00089 TQRadioButton *intervalRadio = new TQRadioButton( i18n("Regular interval"), 00090 mGroup ); 00091 connect( intervalRadio, TQT_SIGNAL( stateChanged( int ) ), 00092 TQT_SLOT( slotIntervalStateChanged( int ) ) ); 00093 TQHBox *intervalBox = new TQHBox( mGroup ); 00094 new TQLabel( i18n("Interval in minutes"), intervalBox ); 00095 mIntervalSpin = new TQSpinBox( 1,900, 1,intervalBox ); 00096 mIntervalSpin->setEnabled( false ); 00097 00098 new TQRadioButton( i18n("Delayed after changes"), mGroup ); 00099 new TQRadioButton( i18n("On every change"), mGroup ); 00100 } 00101 00102 void ResourceCachedSaveConfig::loadSettings( ResourceCached *resource ) 00103 { 00104 mGroup->setButton( resource->savePolicy() ); 00105 mIntervalSpin->setValue( resource->saveInterval() ); 00106 } 00107 00108 void ResourceCachedSaveConfig::saveSettings( ResourceCached *resource ) 00109 { 00110 resource->setSavePolicy( mGroup->selectedId() ); 00111 resource->setSaveInterval( mIntervalSpin->value() ); 00112 } 00113 00114 void ResourceCachedSaveConfig::slotIntervalStateChanged( int state ) 00115 { 00116 if ( state == TQButton::On ) mIntervalSpin->setEnabled( true ); 00117 else mIntervalSpin->setEnabled( false ); 00118 } 00119 00120 #include "resourcecachedconfig.moc"