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 TQt, and distribute the resulting executable,
00021     without including the source code for TQt in the source distribution.
00022 */
00023 
00024 #include <kedittoolbar.h>
00025 #include <kkeydialog.h>
00026 #include <tdelocale.h>
00027 #include <tdemessagebox.h>
00028 #include <kstatusbar.h>
00029 
00030 #include <libtdepim/statusbarprogresswidget.h>
00031 #include <libtdepim/progressdialog.h>
00032 
00033 #include "kabcore.h"
00034 
00035 #include "kaddressbookmain.h"
00036 
00037 KAddressBookMain::KAddressBookMain( const TQString &file )
00038   : DCOPObject( "KAddressBookIface" ), TDEMainWindow( 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( TQString 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 TQString& vCard )
00093 {
00094   mCore->importVCardFromData( vCard );
00095 }
00096 
00097 ASYNC KAddressBookMain::showContactEditor( TQString 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 TQString KAddressBookMain::getNameByPhone( TQString 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::syncAllResources()
00133 {
00134   mCore->save();
00135   mCore->load();
00136 }
00137 
00138 void KAddressBookMain::saveProperties( TDEConfig* )
00139 {
00140 }
00141 
00142 void KAddressBookMain::readProperties( TDEConfig* )
00143 {
00144 }
00145 
00146 bool KAddressBookMain::queryClose()
00147 {
00148   return mCore->queryClose();
00149 }
00150 
00151 void KAddressBookMain::initActions()
00152 {
00153   KStdAction::quit( TQT_TQOBJECT(this), TQT_SLOT( close() ), actionCollection() );
00154 
00155   TDEAction *action;
00156   action = KStdAction::keyBindings( TQT_TQOBJECT(this), TQT_SLOT( configureKeyBindings() ), actionCollection() );
00157   action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
00158 
00159   KStdAction::configureToolbars( TQT_TQOBJECT(this), TQT_SLOT( configureToolbars() ), actionCollection() );
00160 }
00161 
00162 void KAddressBookMain::configureKeyBindings()
00163 {
00164   KKeyDialog::configure( actionCollection(), this );
00165 }
00166 
00167 void KAddressBookMain::loadProfile( const TQString& )
00168 {
00169 }
00170 
00171 void KAddressBookMain::saveToProfile( const TQString& ) const
00172 {
00173 }
00174 
00175 void KAddressBookMain::configureToolbars()
00176 {
00177   saveMainWindowSettings( TDEGlobal::config(), "MainWindow" );
00178 
00179   KEditToolbar edit( factory() );
00180   connect( &edit, TQT_SIGNAL( newToolbarConfig() ),
00181            this, TQT_SLOT( newToolbarConfig() ) );
00182 
00183   edit.exec();
00184 }
00185 
00186 void KAddressBookMain::newToolbarConfig()
00187 {
00188   createGUI( "kaddressbookui.rc", false );
00189   applyMainWindowSettings( TDEGlobal::config(), "MainWindow" );
00190 }
00191 
00192 #include "kaddressbookmain.moc"