kaddressbook Library API Documentation

kabconfigwidget.cpp

00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (c) 2003 Tobias Koenig <tokoe@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 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 <qcheckbox.h> 00025 #include <qframe.h> 00026 #include <qgroupbox.h> 00027 #include <qlabel.h> 00028 #include <qlayout.h> 00029 #include <qlineedit.h> 00030 #include <qpushbutton.h> 00031 #include <qtabwidget.h> 00032 #include <qtooltip.h> 00033 #include <qcombobox.h> 00034 00035 #include <kconfig.h> 00036 #include <kdebug.h> 00037 #include <kdialog.h> 00038 #include <klistview.h> 00039 #include <klocale.h> 00040 #include <kmessagebox.h> 00041 #include <ktrader.h> 00042 00043 #include "addresseewidget.h" 00044 #include "kabprefs.h" 00045 00046 #include "kabconfigwidget.h" 00047 00048 KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) 00049 : QWidget( parent, name ) 00050 { 00051 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 00052 KDialog::spacingHint() ); 00053 00054 QTabWidget *tabWidget = new QTabWidget( this ); 00055 topLayout->addWidget( tabWidget ); 00056 00057 // General page 00058 QWidget *generalPage = new QWidget( this ); 00059 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHint(), 00060 KDialog::spacingHint() ); 00061 00062 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); 00063 QBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); 00064 boxLayout->setAlignment( Qt::AlignTop ); 00065 00066 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); 00067 boxLayout->addWidget( mViewsSingleClickBox ); 00068 00069 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); 00070 boxLayout->addWidget( mNameParsing ); 00071 00072 mTradeAsFamilyName = new QCheckBox( i18n( "Trade single name component as family name" ), groupBox, "mtrade" ); 00073 boxLayout->addWidget( mTradeAsFamilyName ); 00078 mTradeAsFamilyName->hide(); 00079 00080 mLimitContactDisplay = new QCheckBox( i18n( "Limit unfiltered display to 100 contacts" ), groupBox, "mlimit" ); 00081 boxLayout->addWidget( mLimitContactDisplay ); 00082 00083 QBoxLayout *editorLayout = new QHBoxLayout( boxLayout, KDialog::spacingHint() ); 00084 00085 QLabel *label = new QLabel( i18n( "Addressee editor type:" ), groupBox ); 00086 editorLayout->addWidget( label ); 00087 00088 mEditorCombo = new QComboBox( groupBox ); 00089 mEditorCombo->insertItem( i18n( "Full Editor" ) ); 00090 mEditorCombo->insertItem( i18n( "Simple Editor" ) ); 00091 label->setBuddy( mEditorCombo ); 00092 editorLayout->addWidget( mEditorCombo ); 00093 00094 editorLayout->addStretch( 1 ); 00095 00096 00097 layout->addWidget( groupBox ); 00098 00099 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Script-Hooks" ), generalPage ); 00100 QGridLayout *grid = new QGridLayout( groupBox->layout(), 2, 2, 00101 KDialog::spacingHint() ); 00102 label = new QLabel( i18n( "Phone:" ), groupBox ); 00103 grid->addWidget( label, 0, 0 ); 00104 00105 mPhoneHook = new QLineEdit( groupBox ); 00106 QToolTip::add( mPhoneHook, i18n( "<ul><li>%N: Phone Number</li></ul>" ) ); 00107 grid->addWidget( mPhoneHook, 0, 1 ); 00108 00109 label = new QLabel( i18n( "Fax:" ), groupBox ); 00110 grid->addWidget( label, 1, 0 ); 00111 00112 mFaxHook = new QLineEdit( groupBox ); 00113 QToolTip::add( mFaxHook, i18n( "<ul><li>%N: Fax Number</li></ul>" ) ); 00114 grid->addWidget( mFaxHook, 1, 1 ); 00115 grid->setColStretch( 1, 1 ); 00116 00117 layout->addWidget( groupBox ); 00118 00119 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Location Map" ), generalPage ); 00120 boxLayout = new QVBoxLayout( groupBox->layout(), KDialog::spacingHint() ); 00121 boxLayout->setAlignment( Qt::AlignTop ); 00122 00123 mLocationMapURL = new QComboBox( true, groupBox ); 00124 mLocationMapURL->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) ); 00125 QToolTip::add( mLocationMapURL, i18n( "<ul> <li>%s: Street</li>" 00126 "<li>%r: Region</li>" 00127 "<li>%l: Location</li>" 00128 "<li>%z: Zip Code</li>" 00129 "<li>%c: Country ISO Code</li> </ul>" ) ); 00130 mLocationMapURL->insertStringList( KABPrefs::instance()->mLocationMapURLs ); 00131 boxLayout->addWidget( mLocationMapURL ); 00132 layout->addWidget( groupBox ); 00133 00134 connect( mNameParsing, SIGNAL( toggled( bool ) ), SLOT( modified() ) ); 00135 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) ); 00136 connect( mTradeAsFamilyName, SIGNAL( toggled( bool ) ), SLOT( modified() ) ); 00137 connect( mLimitContactDisplay, SIGNAL( toggled( bool ) ), SLOT( modified() ) ); 00138 connect( mPhoneHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 00139 connect( mFaxHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 00140 connect( mLocationMapURL, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 00141 connect( mEditorCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); 00142 00143 tabWidget->addTab( generalPage, i18n( "General" ) ); 00144 00145 // Addressee page 00146 mAddresseeWidget = new AddresseeWidget( this ); 00147 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 00148 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 00149 } 00150 00151 void KABConfigWidget::restoreSettings() 00152 { 00153 bool blocked = signalsBlocked(); 00154 blockSignals( true ); 00155 00156 mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing ); 00157 mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick ); 00158 mPhoneHook->setText( KABPrefs::instance()->mPhoneHookApplication ); 00159 mFaxHook->setText( KABPrefs::instance()->mFaxHookApplication ); 00160 mAddresseeWidget->restoreSettings(); 00161 mEditorCombo->setCurrentItem( KABPrefs::instance()->mEditorType ); 00162 mLocationMapURL->setCurrentText( KABPrefs::instance()->mLocationMapURL.arg( KGlobal::locale()->country() ) ); 00163 mLocationMapURL->lineEdit()->setCursorPosition( 0 ); 00164 00165 KConfig config( "kabcrc", false, false ); 00166 config.setGroup( "General" ); 00167 mTradeAsFamilyName->setChecked( config.readBoolEntry( "TradeAsFamilyName", true ) ); 00168 mLimitContactDisplay->setChecked( config.readBoolEntry( "LimitContactDisplay", true ) ); 00169 00170 blockSignals( blocked ); 00171 00172 emit changed( false ); 00173 } 00174 00175 void KABConfigWidget::saveSettings() 00176 { 00177 KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked(); 00178 KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 00179 KABPrefs::instance()->mPhoneHookApplication = mPhoneHook->text(); 00180 KABPrefs::instance()->mFaxHookApplication = mFaxHook->text(); 00181 KABPrefs::instance()->mEditorType = mEditorCombo->currentItem(); 00182 KABPrefs::instance()->mLocationMapURL = mLocationMapURL->currentText(); 00183 mAddresseeWidget->saveSettings(); 00184 00185 KABPrefs::instance()->writeConfig(); 00186 00187 KConfig config( "kabcrc", false, false ); 00188 config.setGroup( "General" ); 00189 config.writeEntry( "TradeAsFamilyName", mTradeAsFamilyName->isChecked() ); 00190 config.writeEntry( "LimitContactDisplay", mLimitContactDisplay->isChecked() ); 00191 00192 emit changed( false ); 00193 } 00194 00195 void KABConfigWidget::defaults() 00196 { 00197 mNameParsing->setChecked( true ); 00198 mViewsSingleClickBox->setChecked( false ); 00199 mEditorCombo->setCurrentItem( 0 ); 00200 mLimitContactDisplay->setChecked( true ); 00201 00202 emit changed( true ); 00203 } 00204 00205 void KABConfigWidget::modified() 00206 { 00207 emit changed( true ); 00208 } 00209 00210 #include "kabconfigwidget.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:36 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003