kitchensync

kcalkonnectorconfig.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2004 Tobias Koenig <tokoe@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 <kconfig.h>
00023 #include <klocale.h>
00024 #include <kresources/manager.h>
00025 #include <libkcal/resourcecalendar.h>
00026 
00027 #include <qlabel.h>
00028 #include <qlayout.h>
00029 
00030 #include "kcalkonnector.h"
00031 
00032 #include "kcalkonnectorconfig.h"
00033 
00034 using namespace KSync;
00035 
00036 KCalKonnectorConfig::KCalKonnectorConfig( QWidget *parent )
00037   : KRES::ConfigWidget( parent, 0 )
00038 {
00039   initGUI();
00040 
00041   KRES::Manager<KCal::ResourceCalendar> manager( "calendar" );
00042   manager.readConfig();
00043   KRES::Manager<KCal::ResourceCalendar>::ActiveIterator it;
00044   for ( it = manager.activeBegin(); it != manager.activeEnd(); ++it ) {
00045     mResourceIdentifiers.append( (*it)->identifier() );
00046     mResourceBox->insertItem( (*it)->resourceName() );
00047   }
00048 }
00049 
00050 KCalKonnectorConfig::~KCalKonnectorConfig()
00051 {
00052 }
00053 
00054 void KCalKonnectorConfig::loadSettings( KRES::Resource *resource )
00055 {
00056   KCalKonnector *konnector = dynamic_cast<KCalKonnector *>( resource );
00057   if ( konnector ) {
00058     int pos = mResourceIdentifiers.findIndex( konnector->currentResource() );
00059     mResourceBox->setCurrentItem( pos );
00060   }
00061 }
00062 
00063 void KCalKonnectorConfig::saveSettings( KRES::Resource *resource )
00064 {
00065   KCalKonnector *konnector = dynamic_cast<KCalKonnector *>( resource );
00066   if ( konnector ) {
00067     int pos = mResourceBox->currentItem();
00068     konnector->setCurrentResource( mResourceIdentifiers[ pos ] );
00069   }
00070 }
00071 
00072 void KCalKonnectorConfig::initGUI()
00073 {
00074   QBoxLayout *layout = new QVBoxLayout( this );
00075 
00076   QLabel *label = new QLabel( i18n( "Select the calendar you want to sync with:" ), this );
00077   layout->addWidget( label );
00078 
00079   mResourceBox = new QComboBox( this );
00080   layout->addWidget( mResourceBox );
00081 }
00082 
00083 #include "kcalkonnectorconfig.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys