kaddressbook

kaddressbookmain.cpp

00001 /*
00002     This file is part of KAddressbook.
00003     Copyright (c) 1999 Don Sanders <dsanders@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 <kedittoolbar.h>
00025 #include <kkeydialog.h>
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028 #include <kstatusbar.h>
00029 
00030 #include <libkdepim/statusbarprogresswidget.h>
00031 #include <libkdepim/progressdialog.h>
00032 
00033 #include "kabcore.h"
00034 
00035 #include "kaddressbookmain.h"
00036 
00037 KAddressBookMain::KAddressBookMain( const QString &file )
00038   : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
00039 {
00040   // Set this to be the group leader for all subdialogs - this means
00041   // modal subdialogs will only affect this dialog, not the other windows
00042   setWFlags( getWFlags() | WGroupLeader );
00043 
00044   setCaption( i18n( "Address Book Browser" ) );
00045 
00046   mCore = new KABCore( this, true, this, file );
00047   mCore->restoreSettings();
00048 
00049   initActions();
00050 
00051   setCentralWidget( mCore->widget() );
00052 
00053   statusBar()->show();
00054   statusBar()->insertItem( "", 1 );
00055 
00056   KPIM::ProgressDialog *progressDialog = new KPIM::ProgressDialog( statusBar(),
00057     this );
00058   progressDialog->hide();
00059 
00060   KPIM::StatusbarProgressWidget *progressWidget;
00061   progressWidget = new KPIM::StatusbarProgressWidget( progressDialog,
00062     statusBar() );
00063   progressWidget->show();
00064 
00065   statusBar()->addWidget( progressWidget, 0, true );
00066 
00067   mCore->setStatusBar( statusBar() );
00068 
00069   setStandardToolBarMenuEnabled( true );
00070 
00071   createGUI( "kaddressbookui.rc", false );
00072 
00073   resize( 400, 300 ); // initial size
00074   setAutoSaveSettings();
00075 }
00076 
00077 KAddressBookMain::~KAddressBookMain()
00078 {
00079   mCore->saveSettings();
00080 }
00081 
00082 void KAddressBookMain::addEmail( QString addr )
00083 {
00084   mCore->addEmail( addr );
00085 }
00086 
00087 void KAddressBookMain::importVCard( const KURL& url )
00088 {
00089   mCore->importVCard( url );
00090 }
00091 
00092 void KAddressBookMain::importVCardFromData( const QString& vCard )
00093 {
00094   mCore->importVCardFromData( vCard );
00095 }
00096 
00097 ASYNC KAddressBookMain::showContactEditor( QString uid )
00098 {
00099   mCore->editContact( uid );
00100 }
00101 
00102 void KAddressBookMain::newContact()
00103 {
00104   mCore->newContact();
00105 }
00106 
00107 QString KAddressBookMain::getNameByPhone( QString phone )
00108 {
00109   return mCore->getNameByPhone( phone );
00110 }
00111 
00112 void KAddressBookMain::save()
00113 {
00114   mCore->save();
00115 }
00116 
00117 void KAddressBookMain::exit()
00118 {
00119   close();
00120 }
00121 
00122 bool KAddressBookMain::handleCommandLine()
00123 {
00124   return mCore->handleCommandLine( this );
00125 }
00126 
00127 void KAddressBookMain::saveProperties( KConfig* )
00128 {
00129 }
00130 
00131 void KAddressBookMain::readProperties( KConfig* )
00132 {
00133 }
00134 
00135 bool KAddressBookMain::queryClose()
00136 {
00137   return mCore->queryClose();
00138 }
00139 
00140 void KAddressBookMain::initActions()
00141 {
00142   KStdAction::quit( this, SLOT( close() ), actionCollection() );
00143 
00144   KAction *action;
00145   action = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
00146   action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
00147 
00148   KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
00149 }
00150 
00151 void KAddressBookMain::configureKeyBindings()
00152 {
00153   KKeyDialog::configure( actionCollection(), this );
00154 }
00155 
00156 void KAddressBookMain::configureToolbars()
00157 {
00158   saveMainWindowSettings( KGlobal::config(), "MainWindow" );
00159 
00160   KEditToolbar edit( factory() );
00161   connect( &edit, SIGNAL( newToolbarConfig() ),
00162            this, SLOT( newToolbarConfig() ) );
00163 
00164   edit.exec();
00165 }
00166 
00167 void KAddressBookMain::newToolbarConfig()
00168 {
00169   createGUI( "kaddressbookui.rc", false );
00170   applyMainWindowSettings( KGlobal::config(), "MainWindow" );
00171 }
00172 
00173 #include "kaddressbookmain.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys