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 QString& file )
00088 {
00089   mCore->importVCard( KURL( file ) );
00090 }
00091 
00092 ASYNC KAddressBookMain::showContactEditor( QString uid )
00093 {
00094   mCore->editContact( uid );
00095 }
00096 
00097 void KAddressBookMain::newContact()
00098 {
00099   mCore->newContact();
00100 }
00101 
00102 QString KAddressBookMain::getNameByPhone( QString phone )
00103 {
00104   return mCore->getNameByPhone( phone );
00105 }
00106 
00107 void KAddressBookMain::save()
00108 {
00109   mCore->save();
00110 }
00111 
00112 void KAddressBookMain::exit()
00113 {
00114   close();
00115 }
00116 
00117 bool KAddressBookMain::handleCommandLine()
00118 {
00119   return mCore->handleCommandLine( this );
00120 }
00121 
00122 void KAddressBookMain::saveProperties( KConfig* )
00123 {
00124 }
00125 
00126 void KAddressBookMain::readProperties( KConfig* )
00127 {
00128 }
00129 
00130 bool KAddressBookMain::queryClose()
00131 {
00132   return mCore->queryClose();
00133 }
00134 
00135 void KAddressBookMain::initActions()
00136 {
00137   KStdAction::quit( this, SLOT( close() ), actionCollection() );
00138 
00139   KAction *action;
00140   action = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
00141   action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
00142 
00143   KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
00144 }
00145 
00146 void KAddressBookMain::configureKeyBindings()
00147 {
00148   KKeyDialog::configure( actionCollection(), this );
00149 }
00150 
00151 void KAddressBookMain::configureToolbars()
00152 {
00153   saveMainWindowSettings( KGlobal::config(), "MainWindow" );
00154 
00155   KEditToolbar edit( factory() );
00156   connect( &edit, SIGNAL( newToolbarConfig() ),
00157            this, SLOT( newToolbarConfig() ) );
00158 
00159   edit.exec();
00160 }
00161 
00162 void KAddressBookMain::newToolbarConfig()
00163 {
00164   createGUI( "kaddressbookui.rc", false );
00165   applyMainWindowSettings( KGlobal::config(), "MainWindow" );
00166 }
00167 
00168 #include "kaddressbookmain.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys