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::newDistributionList()
00103 {
00104   mCore->newDistributionList();
00105 }
00106 
00107 void KAddressBookMain::newContact()
00108 {
00109   mCore->newContact();
00110 }
00111 
00112 QString KAddressBookMain::getNameByPhone( QString phone )
00113 {
00114   return mCore->getNameByPhone( phone );
00115 }
00116 
00117 void KAddressBookMain::save()
00118 {
00119   mCore->save();
00120 }
00121 
00122 void KAddressBookMain::exit()
00123 {
00124   close();
00125 }
00126 
00127 bool KAddressBookMain::handleCommandLine()
00128 {
00129   return mCore->handleCommandLine( this );
00130 }
00131 
00132 void KAddressBookMain::saveProperties( KConfig* )
00133 {
00134 }
00135 
00136 void KAddressBookMain::readProperties( KConfig* )
00137 {
00138 }
00139 
00140 bool KAddressBookMain::queryClose()
00141 {
00142   return mCore->queryClose();
00143 }
00144 
00145 void KAddressBookMain::initActions()
00146 {
00147   KStdAction::quit( this, SLOT( close() ), actionCollection() );
00148 
00149   KAction *action;
00150   action = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
00151   action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
00152 
00153   KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
00154 }
00155 
00156 void KAddressBookMain::configureKeyBindings()
00157 {
00158   KKeyDialog::configure( actionCollection(), this );
00159 }
00160 
00161 void KAddressBookMain::loadProfile( const QString& )
00162 {
00163 }
00164 
00165 void KAddressBookMain::saveToProfile( const QString& ) const
00166 {
00167 }
00168 
00169 void KAddressBookMain::configureToolbars()
00170 {
00171   saveMainWindowSettings( KGlobal::config(), "MainWindow" );
00172 
00173   KEditToolbar edit( factory() );
00174   connect( &edit, SIGNAL( newToolbarConfig() ),
00175            this, SLOT( newToolbarConfig() ) );
00176 
00177   edit.exec();
00178 }
00179 
00180 void KAddressBookMain::newToolbarConfig()
00181 {
00182   createGUI( "kaddressbookui.rc", false );
00183   applyMainWindowSettings( KGlobal::config(), "MainWindow" );
00184 }
00185 
00186 #include "kaddressbookmain.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys