<commit_before>/*
    This file is part of libkcal.

    Copyright (c) 2004 <NAME> <<EMAIL>>

    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., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <qbuttongroup.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qhbox.h>
#include <qlabel.h>

#include <klocale.h>
#include <kdebug.h>

#include "resourcecached.h"

#include "resourcecachedconfig.h"

using namespace KCal;

ResourceCachedReloadConfig::ResourceCachedReloadConfig( QWidget *parent,
                                                        const char *name )
  : QWidget( parent, name )
{
  QBoxLayout *topLayout = new QVBoxLayout( this );

  mGroup = new QButtonGroup( 1, Horizontal, i18n("Automatic Reload"), this );
  topLayout->addWidget( mGroup );
  new QRadioButton( i18n("Never"), mGroup );
  new QRadioButton( i18n("On startup"), mGroup );

  QRadioButton *intervalRadio = new QRadioButton( i18n("Regular Interval"),
                                                  mGroup );
  connect( intervalRadio, SIGNAL( stateChanged( int ) ),
           SLOT( slotIntervalStateChanged( int ) ) );
  QHBox *intervalBox = new QHBox( mGroup );
  new QLabel( i18n("Interval in minutes"), intervalBox );
  mIntervalSpin = new QSpinBox( intervalBox );
  mIntervalSpin->setEnabled( false );
}

void ResourceCachedReloadConfig::loadSettings( ResourceCached *resource )
{
  mGroup->setButton( resource->reloadPolicy() );
}

void ResourceCachedReloadConfig::saveSettings( ResourceCached *resource )
{
  resource->setReloadPolicy( mGroup->selectedId() );
}

void ResourceCachedReloadConfig::slotIntervalStateChanged( int state )
{
  if ( state == QButton::On ) mIntervalSpin->setEnabled( true );
  else mIntervalSpin->setEnabled( false );
}


ResourceCachedSaveConfig::ResourceCachedSaveConfig( QWidget *parent,
                                                        const char *name )
  : QWidget( parent, name )
{
  QBoxLayout *topLayout = new QVBoxLayout( this );

  mGroup = new QButtonGroup( 1, Horizontal, i18n("Automatic Save"), this );
  topLayout->addWidget( mGroup );
  new QRadioButton( i18n("Never"), mGroup );
  new QRadioButton( i18n("On exit"), mGroup );

  QRadioButton *intervalRadio = new QRadioButton( i18n("Regular Interval"),
                                                  mGroup );
  connect( intervalRadio, SIGNAL( stateChanged( int ) ),
           SLOT( slotIntervalStateChanged( int ) ) );
  QHBox *intervalBox = new QHBox( mGroup );
  new QLabel( i18n("Interval in minutes"), intervalBox );
  mIntervalSpin = new QSpinBox( intervalBox );
  mIntervalSpin->setEnabled( false );

  new QRadioButton( i18n("Delayed after changes"), mGroup );
  new QRadioButton( i18n("On every change"), mGroup );
}

void ResourceCachedSaveConfig::loadSettings( ResourceCached *resource )
{
  mGroup->setButton( resource->savePolicy() );
}

void ResourceCachedSaveConfig::saveSettings( ResourceCached *resource )
{
  resource->setSavePolicy( mGroup->selectedId() );
}

void ResourceCachedSaveConfig::slotIntervalStateChanged( int state )
{
  if ( state == QButton::On ) mIntervalSpin->setEnabled( true );
  else mIntervalSpin->setEnabled( false );
}

#include "resourcecachedconfig.moc"<commit_msg>Load and save interval settings.<commit_after>/*
    This file is part of libkcal.

    Copyright (c) 2004 <NAME> <<EMAIL>>

    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., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <qbuttongroup.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qhbox.h>
#include <qlabel.h>

#include <klocale.h>
#include <kdebug.h>

#include "resourcecached.h"

#include "resourcecachedconfig.h"

using namespace KCal;

ResourceCachedReloadConfig::ResourceCachedReloadConfig( QWidget *parent,
                                                        const char *name )
  : QWidget( parent, name )
{
  QBoxLayout *topLayout = new QVBoxLayout( this );

  mGroup = new QButtonGroup( 1, Horizontal, i18n("Automatic Reload"), this );
  topLayout->addWidget( mGroup );
  new QRadioButton( i18n("Never"), mGroup );
  new QRadioButton( i18n("On startup"), mGroup );

  QRadioButton *intervalRadio = new QRadioButton( i18n("Regular Interval"),
                                                  mGroup );
  connect( intervalRadio, SIGNAL( stateChanged( int ) ),
           SLOT( slotIntervalStateChanged( int ) ) );
  QHBox *intervalBox = new QHBox( mGroup );
  new QLabel( i18n("Interval in minutes"), intervalBox );
  mIntervalSpin = new QSpinBox( intervalBox );
  mIntervalSpin->setEnabled( false );
}

void ResourceCachedReloadConfig::loadSettings( ResourceCached *resource )
{
  mGroup->setButton( resource->reloadPolicy() );
  mIntervalSpin->setValue( resource->reloadInterval() );
}

void ResourceCachedReloadConfig::saveSettings( ResourceCached *resource )
{
  resource->setReloadPolicy( mGroup->selectedId() );
  resource->setReloadInterval( mIntervalSpin->value() );
}

void ResourceCachedReloadConfig::slotIntervalStateChanged( int state )
{
  if ( state == QButton::On ) mIntervalSpin->setEnabled( true );
  else mIntervalSpin->setEnabled( false );
}


ResourceCachedSaveConfig::ResourceCachedSaveConfig( QWidget *parent,
                                                        const char *name )
  : QWidget( parent, name )
{
  QBoxLayout *topLayout = new QVBoxLayout( this );

  mGroup = new QButtonGroup( 1, Horizontal, i18n("Automatic Save"), this );
  topLayout->addWidget( mGroup );
  new QRadioButton( i18n("Never"), mGroup );
  new QRadioButton( i18n("On exit"), mGroup );

  QRadioButton *intervalRadio = new QRadioButton( i18n("Regular Interval"),
                                                  mGroup );
  connect( intervalRadio, SIGNAL( stateChanged( int ) ),
           SLOT( slotIntervalStateChanged( int ) ) );
  QHBox *intervalBox = new QHBox( mGroup );
  new QLabel( i18n("Interval in minutes"), intervalBox );
  mIntervalSpin = new QSpinBox( intervalBox );
  mIntervalSpin->setEnabled( false );

  new QRadioButton( i18n("Delayed after changes"), mGroup );
  new QRadioButton( i18n("On every change"), mGroup );
}

void ResourceCachedSaveConfig::loadSettings( ResourceCached *resource )
{
  mGroup->setButton( resource->savePolicy() );
  mIntervalSpin->setValue( resource->saveInterval() );
}

void ResourceCachedSaveConfig::saveSettings( ResourceCached *resource )
{
  resource->setSavePolicy( mGroup->selectedId() );
  resource->setSaveInterval( mIntervalSpin->value() );
}

void ResourceCachedSaveConfig::slotIntervalStateChanged( int state )
{
  if ( state == QButton::On ) mIntervalSpin->setEnabled( true );
  else mIntervalSpin->setEnabled( false );
}

#include "resourcecachedconfig.moc"
{'fraction_non_alphanumeric': 0.1032521330530481, 'fraction_numerical': 0.011128972424879436, 'mean_word_length': 3.6323024054982818, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5086823', 'n_tokens_mistral': 2392, 'n_tokens_neox': 2283, 'n_words': 705}