kaddressbook
kaddressbookmain.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00041
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 );
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"
|