libkcal

resourcecachedconfig.cpp

Go to the documentation of this file.
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 <qbuttongroup.h>
00023 #include <qlayout.h>
00024 #include <qradiobutton.h>
00025 #include <qspinbox.h>
00026 #include <qhbox.h>
00027 #include <qlabel.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( QWidget *parent,
00039                                                         const char *name )
00040   : QWidget( parent, name )
00041 {
00042   QBoxLayout *topLayout = new QVBoxLayout( this );
00043 
00044   mGroup = new QButtonGroup( 1, Horizontal, i18n("Automatic Reload"), this );
00045   topLayout->addWidget( mGroup );
00046   new QRadioButton( i18n("Never"), mGroup );
00047   new QRadioButton( i18n("On startup"), mGroup );
00048 
00049   QRadioButton *intervalRadio = new QRadioButton( i18n("Regular interval"),
00050                                                   mGroup );
00051   connect( intervalRadio, SIGNAL( stateChanged( int ) ),
00052            SLOT( slotIntervalStateChanged( int ) ) );
00053   QHBox *intervalBox = new QHBox( mGroup );
00054   new QLabel( i18n("Interval in minutes"), intervalBox );
00055   mIntervalSpin = new QSpinBox( 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 == QButton::On ) mIntervalSpin->setEnabled( true );
00074   else mIntervalSpin->setEnabled( false );
00075 }
00076 
00077 
00078 ResourceCachedSaveConfig::ResourceCachedSaveConfig( QWidget *parent,
00079                                                         const char *name )
00080   : QWidget( parent, name )
00081 {
00082   QBoxLayout *topLayout = new QVBoxLayout( this );
00083 
00084   mGroup = new QButtonGroup( 1, Horizontal, i18n("Automatic Save"), this );
00085   topLayout->addWidget( mGroup );
00086   new QRadioButton( i18n("Never"), mGroup );
00087   new QRadioButton( i18n("On exit"), mGroup );
00088 
00089   QRadioButton *intervalRadio = new QRadioButton( i18n("Regular interval"),
00090                                                   mGroup );
00091   connect( intervalRadio, SIGNAL( stateChanged( int ) ),
00092            SLOT( slotIntervalStateChanged( int ) ) );
00093   QHBox *intervalBox = new QHBox( mGroup );
00094   new QLabel( i18n("Interval in minutes"), intervalBox );
00095   mIntervalSpin = new QSpinBox( 1,900, 1,intervalBox );
00096   mIntervalSpin->setEnabled( false );
00097 
00098   new QRadioButton( i18n("Delayed after changes"), mGroup );
00099   new QRadioButton( 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 == QButton::On ) mIntervalSpin->setEnabled( true );
00117   else mIntervalSpin->setEnabled( false );
00118 }
00119 
00120 #include "resourcecachedconfig.moc"