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 TQt, and distribute the resulting executable, 00021 without including the source code for TQt in the source distribution. 00022 */ 00023 00024 #include <tdeconfig.h> 00025 #include <tdelocale.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 TDEConfigSkeleton::setCurrentGroup( "General" ); 00037 00038 TQStringList defaultMap; 00039 defaultMap << "http://maps.google.com/maps?f=q&hl=%1&q=%n,%l,%s"; 00040 addItemString( "LocationMapURL", mLocationMapURL, defaultMap[ 0 ] ); 00041 addItemStringList( "LocationMapURLs", mLocationMapURLs, defaultMap ); 00042 } 00043 00044 KABPrefs::~KABPrefs() 00045 { 00046 } 00047 00048 KABPrefs *KABPrefs::instance() 00049 { 00050 if ( !mInstance ) { 00051 staticDeleter.setObject( mInstance, new KABPrefs() ); 00052 mInstance->readConfig(); 00053 } 00054 00055 return mInstance; 00056 } 00057 00058 void KABPrefs::setCategoryDefaults() 00059 { 00060 mCustomCategories.clear(); 00061 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 00062 << i18n( "Customer" ) << i18n( "Friend" ); 00063 } 00064 00065 void KABPrefs::usrReadConfig() 00066 { 00067 config()->setGroup( "General" ); 00068 mCustomCategories = config()->readListEntry( "Custom Categories" ); 00069 if ( mCustomCategories.isEmpty() ) 00070 setCategoryDefaults(); 00071 00072 KPimPrefs::usrReadConfig(); 00073 } 00074 00075 00076 void KABPrefs::usrWriteConfig() 00077 { 00078 config()->setGroup( "General" ); 00079 config()->writeEntry( "Custom Categories", mCustomCategories ); 00080 00081 KPimPrefs::usrWriteConfig(); 00082 }