• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kaddressbook

kabconfigwidget.cpp

Go to the documentation of this file.
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., 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 <Qt3Support/Q3GroupBox>
00025 #include <QtGui/QBoxLayout>
00026 #include <QtGui/QCheckBox>
00027 #include <QtGui/QComboBox>
00028 #include <QtGui/QGridLayout>
00029 #include <QtGui/QHBoxLayout>
00030 #include <QtGui/QLabel>
00031 #include <QtGui/QLineEdit>
00032 #include <QtGui/QPushButton>
00033 #include <QtGui/QTabWidget>
00034 #include <QtGui/QVBoxLayout>
00035 
00036 #include <k3listview.h>
00037 #include <kconfig.h>
00038 #include <kdebug.h>
00039 #include <kdialog.h>
00040 #include <klocale.h>
00041 #include <kmessagebox.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 )
00050 {
00051   setObjectName( name );
00052   QVBoxLayout *topLayout = new QVBoxLayout( this );
00053   topLayout->setSpacing( KDialog::spacingHint() );
00054   topLayout->setMargin( 0 );
00055 
00056   QTabWidget *tabWidget = new QTabWidget( this );
00057   topLayout->addWidget( tabWidget );
00058 
00059   // General page
00060   QWidget *generalPage = new QWidget( this );
00061   QVBoxLayout *layout = new QVBoxLayout( generalPage );
00062   layout->setSpacing( KDialog::spacingHint() );
00063   layout->setMargin( KDialog::marginHint() );
00064 
00065   Q3GroupBox *groupBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
00066   QBoxLayout *boxLayout = new QVBoxLayout();
00067   groupBox->layout()->addItem( boxLayout );
00068   boxLayout->setAlignment( Qt::AlignTop );
00069 
00070   mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox );
00071   mViewsSingleClickBox->setObjectName( "msingle" );
00072   boxLayout->addWidget( mViewsSingleClickBox );
00073 
00074   mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox );
00075   mNameParsing->setObjectName( "mparse" );
00076   boxLayout->addWidget( mNameParsing );
00077 
00089   mLimitContactDisplay = new QCheckBox( i18n( "Limit unfiltered display to 100 contacts" ), groupBox );
00090   mLimitContactDisplay->setObjectName( "mlimit" );
00091   boxLayout->addWidget( mLimitContactDisplay );
00092 
00093   QBoxLayout *editorLayout = new QHBoxLayout();
00094   boxLayout->addItem( editorLayout );
00095   editorLayout->setSpacing( KDialog::spacingHint() );
00096 
00097   QLabel *label = new QLabel( i18n( "Addressee editor type:" ), groupBox );
00098   editorLayout->addWidget( label );
00099 
00100   mEditorCombo = new QComboBox( groupBox );
00101   mEditorCombo->addItem( i18n( "Full Editor" ) );
00102   mEditorCombo->addItem( i18n( "Simple Editor" ) );
00103   label->setBuddy( mEditorCombo );
00104   editorLayout->addWidget( mEditorCombo );
00105 
00106   editorLayout->addStretch( 1 );
00107 
00108 
00109   layout->addWidget( groupBox );
00110 
00111   groupBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "Script-Hooks" ), generalPage );
00112   QGridLayout *grid = new QGridLayout();
00113   groupBox->layout()->addItem( grid );
00114   grid->setSpacing( KDialog::spacingHint() );
00115   label = new QLabel( i18n( "Phone:" ), groupBox );
00116   grid->addWidget( label, 0, 0 );
00117 
00118   mPhoneHook = new QLineEdit( groupBox );
00119   mPhoneHook->setToolTip( i18n( "<ul><li>%N: Phone Number</li></ul>" ) );
00120   grid->addWidget( mPhoneHook, 0, 1 );
00121 
00122   label = new QLabel( i18n( "Fax:" ), groupBox );
00123   grid->addWidget( label, 1, 0 );
00124 
00125   mFaxHook = new QLineEdit( groupBox );
00126   mFaxHook->setToolTip( i18n( "<ul><li>%N: Fax Number</li></ul>" ) );
00127   grid->addWidget( mFaxHook, 1, 1 );
00128 
00129 
00130   label = new QLabel( i18n( "SMS text:" ), groupBox );
00131   grid->addWidget( label, 2, 0 );
00132 
00133   mSMSHook = new QLineEdit( groupBox );
00134   mSMSHook->setToolTip( i18n( "<ul><li>%N: Phone Number</li><li>%F: File containing the text message(s)</li></ul>" ) );
00135   grid->addWidget( mSMSHook, 2, 1 );
00136 
00137 
00138   grid->setColumnStretch( 1, 1 );
00139 
00140   layout->addWidget( groupBox );
00141 
00142   groupBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "Location Map" ), generalPage );
00143   boxLayout = new QVBoxLayout();
00144   groupBox->layout()->addItem( boxLayout );
00145   boxLayout->setSpacing( KDialog::spacingHint() );
00146   boxLayout->setAlignment( Qt::AlignTop );
00147 
00148   mLocationMapURL = new QComboBox( groupBox );
00149   mLocationMapURL->setEditable( true );
00150   mLocationMapURL->setMinimumContentsLength( 20 );
00151   mLocationMapURL->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength );
00152   mLocationMapURL->setToolTip( i18n( "<ul> <li>%s: Street</li>"
00153                                  "<li>%r: Region</li>"
00154                                  "<li>%l: Location</li>"
00155                                  "<li>%z: Zip Code</li>"
00156                                  "<li>%c: Country ISO Code</li> </ul>" ) );
00157   boxLayout->addWidget( mLocationMapURL );
00158   layout->addWidget( groupBox );
00159 
00160   connect( mNameParsing, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00161   connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00162 //TODO: put back when this option is re-enabled and working
00163 //  connect( mTradeAsFamilyName, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00164   connect( mLimitContactDisplay, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00165   connect( mPhoneHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00166   connect( mSMSHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00167   connect( mFaxHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00168   connect( mLocationMapURL, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00169   connect( mEditorCombo, SIGNAL( activated( int ) ), SLOT( modified() ) );
00170 
00171   tabWidget->addTab( generalPage, i18n( "General" ) );
00172 
00173   // Addressee page
00174   mAddresseeWidget = new AddresseeWidget( this );
00175   tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
00176   connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
00177 
00178   mLocationMapURL->addItems( KABPrefs::instance()->locationMapURLs() );
00179 }
00180 
00181 void KABConfigWidget::restoreSettings()
00182 {
00183   bool blocked = signalsBlocked();
00184   blockSignals( true );
00185 
00186   mNameParsing->setChecked( KABPrefs::instance()->automaticNameParsing() );
00187   mViewsSingleClickBox->setChecked( KABPrefs::instance()->honorSingleClick() );
00188   mPhoneHook->setText( KABPrefs::instance()->phoneHookApplication() );
00189   mSMSHook->setText( KABPrefs::instance()->sMSHookApplication() );
00190   mFaxHook->setText( KABPrefs::instance()->faxHookApplication() );
00191   mAddresseeWidget->restoreSettings();
00192   mEditorCombo->setCurrentIndex( KABPrefs::instance()->editorType() );
00193   mLocationMapURL->setItemText( mLocationMapURL->currentIndex(),
00194       KABPrefs::instance()->locationMapURL().arg( KGlobal::locale()->country() ) );
00195   mLocationMapURL->lineEdit()->setCursorPosition( 0 );
00196 
00197   KConfig _config("kabcrc", KConfig::NoGlobals);
00198   KConfigGroup config(&_config, "General" );
00199 //TODO: put back when this option is re-enabled and working
00200 //mTradeAsFamilyName->setChecked( config.readEntry( "TradeAsFamilyName", true ) );
00201   mLimitContactDisplay->setChecked( config.readEntry( "LimitContactDisplay", true ) );
00202 
00203   blockSignals( blocked );
00204 
00205   emit changed( false );
00206 }
00207 
00208 void KABConfigWidget::saveSettings()
00209 {
00210   KABPrefs::instance()->setAutomaticNameParsing( mNameParsing->isChecked() );
00211   KABPrefs::instance()->setHonorSingleClick( mViewsSingleClickBox->isChecked() );
00212   KABPrefs::instance()->setPhoneHookApplication( mPhoneHook->text() );
00213   KABPrefs::instance()->setSMSHookApplication( mSMSHook->text() );
00214   KABPrefs::instance()->setFaxHookApplication( mFaxHook->text() );
00215   KABPrefs::instance()->setEditorType( mEditorCombo->currentIndex() );
00216   KABPrefs::instance()->setLocationMapURL( mLocationMapURL->currentText() );
00217   mAddresseeWidget->saveSettings();
00218 
00219   KABPrefs::instance()->writeConfig();
00220 
00221   KConfig _config("kabcrc", KConfig::NoGlobals);
00222   KConfigGroup config(&_config, "General" );
00223 //TODO: put back when this option is re-enabled and working
00224 //config.writeEntry( "TradeAsFamilyName", mTradeAsFamilyName->isChecked() );
00225   config.writeEntry( "LimitContactDisplay", mLimitContactDisplay->isChecked() );
00226 
00227   emit changed( false );
00228 }
00229 
00230 void KABConfigWidget::defaults()
00231 {
00232   mNameParsing->setChecked( true );
00233   mViewsSingleClickBox->setChecked( false );
00234   mEditorCombo->setCurrentIndex( 0 );
00235   mLimitContactDisplay->setChecked( true );
00236 
00237   emit changed( true );
00238 }
00239 
00240 void KABConfigWidget::modified()
00241 {
00242   emit changed( true );
00243 }
00244 
00245 #include "kabconfigwidget.moc"

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal