You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
248 lines
7.8 KiB
248 lines
7.8 KiB
15 years ago
|
/*=========================================================================
|
||
|
| KABCDAV
|
||
|
|--------------------------------------------------------------------------
|
||
|
| (c) 2010 Timothy Pearson
|
||
|
|
|
||
|
| This project is released under the GNU General Public License.
|
||
|
| Please see the file COPYING for more details.
|
||
|
|--------------------------------------------------------------------------
|
||
|
| Automatic Reload / Automatic Save configuration widgets.
|
||
|
| The code is mostly taken from resourcecachedconfig.h/cpp files from
|
||
|
| the kcal library and changed to meet our requirements.
|
||
|
| The original copyright is below.
|
||
|
========================================================================*/
|
||
|
/*
|
||
|
This file is part of the kcal library.
|
||
|
|
||
|
Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "configwidgets.h"
|
||
|
|
||
|
#include <kabcresourcecached.h>
|
||
|
|
||
|
#include <klocale.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
15 years ago
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqcheckbox.h>
|
||
|
#include <tqradiobutton.h>
|
||
|
#include <tqspinbox.h>
|
||
|
#include <tqbuttongroup.h>
|
||
|
#include <tqgroupbox.h>
|
||
|
#include <tqhbox.h>
|
||
15 years ago
|
|
||
|
using namespace KABC;
|
||
|
|
||
|
//@cond PRIVATE
|
||
|
class CardDavConfigPrivate
|
||
|
{
|
||
|
public:
|
||
|
CardDavConfigPrivate()
|
||
|
: mGroup( 0 ),
|
||
|
mIntervalSpin( 0 ) {}
|
||
|
|
||
15 years ago
|
TQButtonGroup *mGroup;
|
||
|
TQSpinBox *mIntervalSpin;
|
||
15 years ago
|
};
|
||
|
|
||
|
class CardDavReloadConfig::Private
|
||
|
: public CardDavConfigPrivate
|
||
|
{
|
||
|
};
|
||
|
|
||
|
class CardDavSaveConfig::Private
|
||
|
: public CardDavConfigPrivate
|
||
|
{
|
||
|
};
|
||
|
//@endcond
|
||
|
|
||
13 years ago
|
CardDavReloadConfig::CardDavReloadConfig( TQWidget *parent )
|
||
|
: TQWidget( parent ), d( new KABC::CardDavReloadConfig::Private() )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQBoxLayout *topLayout = new TQVBoxLayout( this );
|
||
15 years ago
|
|
||
15 years ago
|
//TQGroupBox *groupBox = new TQGroupBox( i18nc( "@title:group", "Automatic Reload" ), this );
|
||
|
TQGroupBox *groupBox = new TQGroupBox( i18n( "Automatic Reload" ), this );
|
||
15 years ago
|
topLayout->addWidget( groupBox );
|
||
|
|
||
15 years ago
|
TQRadioButton *noAutomaticReload =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
//i18nc( "@option:radio never reload the cache", "Never" ), groupBox );
|
||
|
i18n( "Never" ), groupBox );
|
||
15 years ago
|
TQRadioButton *automaticReloadOnStartup =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
//i18nc( "@option:radio reload the cache on startup", "Only on startup" ), groupBox );
|
||
|
i18n( "Only on startup" ), groupBox );
|
||
15 years ago
|
TQRadioButton *intervalRadio =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
// i18nc( "@option:radio reload the cache at regular intervals",
|
||
|
// "Regular interval" ), groupBox );
|
||
|
i18n( "Regular interval" ), groupBox );
|
||
|
|
||
15 years ago
|
d->mGroup = new TQButtonGroup( this );
|
||
15 years ago
|
d->mGroup->hide();
|
||
|
d->mGroup->insert( intervalRadio, 2 );
|
||
|
d->mGroup->insert( automaticReloadOnStartup, 1 );
|
||
|
d->mGroup->insert( noAutomaticReload, 0 );
|
||
|
|
||
15 years ago
|
connect( intervalRadio, TQT_SIGNAL( toggled( bool ) ),
|
||
|
TQT_SLOT( slotIntervalToggled( bool ) ) );
|
||
15 years ago
|
|
||
15 years ago
|
TQHBox *intervalBox = new TQHBox( groupBox );
|
||
|
//new TQLabel( i18nc( "@label:spinbox", "Interval in minutes:" ), intervalBox );
|
||
|
new TQLabel( i18n( "Interval in minutes:" ), intervalBox );
|
||
|
d->mIntervalSpin = new TQSpinBox( intervalBox );
|
||
15 years ago
|
d->mIntervalSpin->setRange( 1, 900 );
|
||
|
d->mIntervalSpin->setEnabled( false );
|
||
|
|
||
14 years ago
|
groupBox->setColumnLayout(1, Qt::Vertical);
|
||
13 years ago
|
TQVBoxLayout *vbox = new TQVBoxLayout(groupBox->layout());
|
||
15 years ago
|
vbox->addWidget(intervalRadio);
|
||
|
vbox->addWidget(intervalBox);
|
||
|
vbox->addWidget(automaticReloadOnStartup);
|
||
|
vbox->addWidget(noAutomaticReload);
|
||
|
vbox->addStretch(1);
|
||
|
}
|
||
|
|
||
|
CardDavReloadConfig::~CardDavReloadConfig()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
void CardDavReloadConfig::loadSettings( ResourceCached *resource )
|
||
|
{
|
||
14 years ago
|
d->mIntervalSpin->setValue( resource->reloadInterval() );
|
||
|
d->mGroup->setButton( resource->reloadPolicy() );
|
||
15 years ago
|
}
|
||
|
|
||
|
void CardDavReloadConfig::saveSettings( ResourceCached *resource )
|
||
|
{
|
||
14 years ago
|
resource->setReloadInterval( d->mIntervalSpin->value() );
|
||
|
resource->setReloadPolicy( d->mGroup->selectedId() );
|
||
15 years ago
|
}
|
||
|
|
||
|
void CardDavReloadConfig::slotIntervalToggled( bool checked )
|
||
|
{
|
||
|
if ( checked ) {
|
||
|
d->mIntervalSpin->setEnabled( true );
|
||
|
} else {
|
||
|
d->mIntervalSpin->setEnabled( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
CardDavSaveConfig::CardDavSaveConfig( TQWidget *parent )
|
||
|
: TQWidget( parent ), d( new KABC::CardDavSaveConfig::Private() )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQBoxLayout *topLayout = new TQVBoxLayout( this );
|
||
15 years ago
|
|
||
15 years ago
|
//TQGroupBox *groupBox = new TQGroupBox( i18nc( "@title:group", "Automatic Save" ), this );
|
||
|
TQGroupBox *groupBox = new TQGroupBox( i18n( "Automatic Save" ), this );
|
||
|
d->mGroup = new TQButtonGroup( this );
|
||
15 years ago
|
d->mGroup->hide();
|
||
|
topLayout->addWidget( groupBox );
|
||
|
|
||
15 years ago
|
TQRadioButton *never =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
//i18nc( "@option:radio never save the cache automatically", "Never" ), groupBox );
|
||
|
i18n( "Never" ), groupBox );
|
||
15 years ago
|
TQRadioButton *onExit =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
//i18nc( "@option:radio save the cache on exit", "Only on exit" ), groupBox );
|
||
|
i18n( "Only on exit" ), groupBox );
|
||
|
|
||
15 years ago
|
TQRadioButton *intervalRadio =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
//i18nc( "@option:radio save the cache at regular intervals", "Regular interval" ), groupBox );
|
||
|
i18n( "Regular interval" ), groupBox );
|
||
|
|
||
15 years ago
|
d->mGroup = new TQButtonGroup( this );
|
||
15 years ago
|
d->mGroup->hide();
|
||
|
d->mGroup->insert( never, 0 );
|
||
|
d->mGroup->insert( onExit, 1 );
|
||
|
d->mGroup->insert( intervalRadio, 2 );
|
||
|
|
||
15 years ago
|
connect( intervalRadio, TQT_SIGNAL( toggled( bool ) ),
|
||
|
TQT_SLOT( slotIntervalToggled( bool ) ) );
|
||
15 years ago
|
|
||
15 years ago
|
TQHBox *intervalBox = new TQHBox( groupBox );
|
||
|
//new TQLabel( i18nc( "@label:spinbox", "Interval in minutes:" ), intervalBox );
|
||
|
new TQLabel( i18n( "Interval in minutes:" ), intervalBox );
|
||
|
d->mIntervalSpin = new TQSpinBox( intervalBox );
|
||
15 years ago
|
d->mIntervalSpin->setRange( 1, 900 );
|
||
|
d->mIntervalSpin->setEnabled( false );
|
||
|
|
||
15 years ago
|
TQRadioButton *delay =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
// i18nc( "@option:radio save the cache after some delay",
|
||
|
// "Delayed after changes" ), groupBox );
|
||
|
i18n( "Delayed after changes" ), groupBox );
|
||
15 years ago
|
TQRadioButton *every =
|
||
|
new TQRadioButton(
|
||
15 years ago
|
// i18nc( "@option:radio save the cache after every modification",
|
||
|
// "Immediately after changes" ), groupBox );
|
||
|
i18n( "Immediately after changes" ), groupBox );
|
||
|
d->mGroup->insert( delay, 3 );
|
||
|
d->mGroup->insert( every, 4 );
|
||
|
|
||
|
// hide unwanted widgets. They may be useful in future, so don't delete them for now.
|
||
|
intervalRadio->hide();
|
||
|
intervalBox->hide();
|
||
|
|
||
14 years ago
|
groupBox->setColumnLayout(1, Qt::Vertical);
|
||
13 years ago
|
TQVBoxLayout *vbox = new TQVBoxLayout(groupBox->layout());
|
||
15 years ago
|
vbox->addWidget(delay);
|
||
|
vbox->addWidget(every);
|
||
|
vbox->addWidget(intervalRadio);
|
||
|
vbox->addWidget(intervalBox);
|
||
|
vbox->addWidget(onExit);
|
||
|
vbox->addWidget(never);
|
||
|
vbox->addStretch(1);
|
||
|
}
|
||
|
|
||
|
CardDavSaveConfig::~CardDavSaveConfig()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
void CardDavSaveConfig::loadSettings( ResourceCached *resource )
|
||
|
{
|
||
14 years ago
|
d->mIntervalSpin->setValue( resource->saveInterval() );
|
||
|
d->mGroup->setButton( resource->savePolicy() );
|
||
15 years ago
|
}
|
||
|
|
||
|
void CardDavSaveConfig::saveSettings( ResourceCached *resource )
|
||
|
{
|
||
14 years ago
|
resource->setSaveInterval( d->mIntervalSpin->value() );
|
||
|
resource->setSavePolicy( d->mGroup->selectedId() );
|
||
15 years ago
|
}
|
||
|
|
||
|
void CardDavSaveConfig::slotIntervalToggled( bool checked )
|
||
|
{
|
||
|
if ( checked ) {
|
||
|
d->mIntervalSpin->setEnabled( true );
|
||
|
} else {
|
||
|
d->mIntervalSpin->setEnabled( false );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
#include "configwidgets.moc"
|
||
|
|
||
15 years ago
|
// EOF ========================================================================
|