korganizer Library API Documentation

configdialog.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 // Dialog for selecting and configuring the Holiday plugin 00021 00022 #include <qlayout.h> 00023 #include <qlabel.h> 00024 #include <qcombobox.h> 00025 00026 #include <klocale.h> 00027 #include <kstandarddirs.h> 00028 #include <ksimpleconfig.h> 00029 #include "holidaySettings.h" 00030 00031 #include "configdialog.h" 00032 #include "configdialog.moc" 00033 00034 ConfigDialog::ConfigDialog(QWidget *parent) 00035 : KDialogBase(Plain,i18n("Configure Holidays"),Ok|Cancel,Ok,parent) 00036 { 00037 QFrame *topFrame = plainPage(); 00038 QVBoxLayout *topLayout = new QVBoxLayout(topFrame,0,spacingHint()); 00039 00040 QLabel *label = new QLabel(i18n("Please select a holiday set:"),topFrame); 00041 topLayout->addWidget(label); 00042 00043 mHolidayCombo = new QComboBox(topFrame); 00044 topLayout->addWidget(mHolidayCombo); 00045 00046 load(); 00047 } 00048 00049 ConfigDialog::~ConfigDialog() 00050 { 00051 } 00052 00053 void ConfigDialog::load() 00054 { 00055 HolidaySettings::self()->readConfig(); 00056 QString currentHoliday( HolidaySettings::holidays() ); 00057 00058 QString currentHolidayName; 00059 00060 QStringList holidayList; 00061 QStringList countryList = KGlobal::dirs()->findAllResources("data", 00062 "korganizer/holiday_*", false, true); 00063 QStringList::ConstIterator it; 00064 for ( it = countryList.begin(); it != countryList.end(); ++it ) { 00065 QString country = (*it).mid((*it).findRev('_') + 1); 00066 QString countryFile = locate("locale","l10n/" + country + "/entry.desktop"); 00067 QString countryName; 00068 if (!countryFile.isEmpty()) { 00069 KSimpleConfig cfg(countryFile); 00070 cfg.setGroup("KCM Locale"); 00071 countryName = cfg.readEntry("Name"); 00072 } 00073 if (countryName.isEmpty()) countryName = country; 00074 00075 mCountryMap[countryName] = country; 00076 holidayList << countryName; 00077 00078 if (country == currentHoliday) currentHolidayName = countryName; 00079 } 00080 holidayList.sort(); 00081 00082 mHolidayCombo->insertStringList(holidayList); 00083 00084 for(int i=0;i<mHolidayCombo->count();++i) { 00085 if(mHolidayCombo->text(i) == currentHolidayName) { 00086 mHolidayCombo->setCurrentItem(i); 00087 break; 00088 } 00089 } 00090 } 00091 00092 void ConfigDialog::save() 00093 { 00094 QString currentHoliday = mCountryMap[mHolidayCombo->currentText()]; 00095 HolidaySettings::setHolidays( currentHoliday ); 00096 HolidaySettings::self()->writeConfig(); 00097 } 00098 00099 void ConfigDialog::slotOk() 00100 { 00101 save(); 00102 00103 accept(); 00104 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:55 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003