kaddressbook Library API Documentation

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., 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 <kedittoolbar.h>
00025 #include <kkeydialog.h>
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028 #include <kstatusbar.h>
00029 
00030 #include "kabcore.h"
00031 
00032 #include "kaddressbookmain.h"
00033 
00034 KAddressBookMain::KAddressBookMain( const QString &file )
00035   : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
00036 {
00037   // Set this to be the group leader for all subdialogs - this means
00038   // modal subdialogs will only affect this dialog, not the other windows
00039   setWFlags( getWFlags() | WGroupLeader );
00040 
00041   setCaption( i18n( "Address Book Browser" ) );
00042 
00043   mCore = new KABCore( this, true, this, file );
00044   mCore->restoreSettings();
00045 
00046   initActions();
00047 
00048   setCentralWidget( mCore->widget() );
00049 
00050   statusBar()->show();
00051   statusBar()->insertItem( "", 1 );
00052   mCore->setStatusBar( statusBar() );
00053 
00054   setStandardToolBarMenuEnabled( true );
00055 
00056   createGUI( "kaddressbookui.rc", false );
00057 
00058   resize( 400, 300 ); // initial size
00059   setAutoSaveSettings();
00060 }
00061 
00062 KAddressBookMain::~KAddressBookMain()
00063 {
00064   mCore->saveSettings();
00065 }
00066 
00067 void KAddressBookMain::addEmail( QString addr )
00068 {
00069   mCore->addEmail( addr );
00070 }
00071 
00072 void KAddressBookMain::importVCard( const QString& file )
00073 {
00074   mCore->importVCard( KURL( file ) );
00075 }
00076 
00077 ASYNC KAddressBookMain::showContactEditor( QString uid )
00078 {
00079   mCore->editContact( uid );
00080 }
00081 
00082 void KAddressBookMain::newContact()
00083 {
00084   mCore->newContact();
00085 }
00086 
00087 QString KAddressBookMain::getNameByPhone( QString phone )
00088 {
00089   return mCore->getNameByPhone( phone );
00090 }
00091 
00092 void KAddressBookMain::save()
00093 {
00094   mCore->save();
00095 }
00096 
00097 void KAddressBookMain::exit()
00098 {
00099   close();
00100 }
00101 
00102 bool KAddressBookMain::handleCommandLine()
00103 {
00104   return mCore->handleCommandLine( this );
00105 }
00106 
00107 void KAddressBookMain::saveProperties( KConfig* )
00108 {
00109 }
00110 
00111 void KAddressBookMain::readProperties( KConfig* )
00112 {
00113 }
00114 
00115 void KAddressBookMain::initActions()
00116 {
00117   KStdAction::quit( this, SLOT( close() ), actionCollection() );
00118 
00119   KAction *action;
00120   action = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
00121   action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
00122 
00123   KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
00124 }
00125 
00126 void KAddressBookMain::configureKeyBindings()
00127 {
00128   KKeyDialog::configure( actionCollection(), this );
00129 }
00130 
00131 void KAddressBookMain::configureToolbars()
00132 {
00133   saveMainWindowSettings( KGlobal::config(), "MainWindow" );
00134 
00135   KEditToolbar edit( factory() );
00136   connect( &edit, SIGNAL( newToolbarConfig() ),
00137            this, SLOT( slotNewToolbarConfig() ) );
00138 
00139   edit.exec();
00140 }
00141 
00142 void KAddressBookMain::newToolbarConfig()
00143 {
00144   createGUI();
00145   applyMainWindowSettings( KGlobal::config(), "MainWindow" );
00146 }
00147 
00148 #include "kaddressbookmain.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 2 09:54:31 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003