kaddressbook

kabprefs.cpp

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include <kconfig.h>
00025 #include <klocale.h>
00026 #include <kstaticdeleter.h>
00027 
00028 #include "kabprefs.h"
00029 
00030 KABPrefs *KABPrefs::mInstance = 0;
00031 static KStaticDeleter<KABPrefs> staticDeleter;
00032 
00033 KABPrefs::KABPrefs()
00034   : KABPrefsBase()
00035 {
00036   KConfigSkeleton::setCurrentGroup( "General" );
00037 
00038   QStringList defaultMap;
00039   defaultMap << "http://world.maporama.com/idl/maporama/drawaddress.aspx?MD_scale=0.0002&MD_size=500x380&GC_country=%c&GC_address=%s&GC_zip=%z&GC_state=%r&GC_city=%l";
00040   defaultMap << "http://link2.map24.com/?lid=9cc343ae&maptype=CGI&lang=%1&street0=%s&zip0=%z&city0=%l&country0=%c";
00041   defaultMap << "http://www.mapquest.com/maps/map.adp?country=%c&address=%s&state=%r&zipcode=%z&city=%l";
00042   addItemString( "LocationMapURL", mLocationMapURL, defaultMap[ 0 ] );
00043   addItemStringList( "LocationMapURLs", mLocationMapURLs, defaultMap );
00044 }
00045 
00046 KABPrefs::~KABPrefs()
00047 {
00048 }
00049 
00050 KABPrefs *KABPrefs::instance()
00051 {
00052   if ( !mInstance ) {
00053     staticDeleter.setObject( mInstance, new KABPrefs() );
00054     mInstance->readConfig();
00055   }
00056 
00057   return mInstance;
00058 }
00059 
00060 void KABPrefs::setCategoryDefaults()
00061 {
00062   mCustomCategories.clear();
00063   mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
00064                     << i18n( "Customer" ) << i18n( "Friend" );
00065 }
00066 
00067 void KABPrefs::usrReadConfig()
00068 {
00069   config()->setGroup( "General" );
00070   mCustomCategories = config()->readListEntry( "Custom Categories" );
00071   if ( mCustomCategories.isEmpty() )
00072     setCategoryDefaults();
00073 
00074   KPimPrefs::usrReadConfig();
00075 }
00076 
00077 
00078 void KABPrefs::usrWriteConfig()
00079 {
00080   config()->setGroup( "General" );
00081   config()->writeEntry( "Custom Categories", mCustomCategories );
00082 
00083   KPimPrefs::usrWriteConfig();
00084 }
KDE Home | KDE Accessibility Home | Description of Access Keys