kaddressbook
kaddressbookmain.cpp
Go to the documentation of this file.00001
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 <kshortcutsdialog.h>
00026 #include <kglobal.h>
00027 #include <klocale.h>
00028 #include <kmessagebox.h>
00029 #include <kstatusbar.h>
00030 #include <kstandardaction.h>
00031 #include <kactioncollection.h>
00032
00033 #include <libkdepim/statusbarprogresswidget.h>
00034 #include <libkdepim/progressdialog.h>
00035
00036 #include "kaddressbookadaptor.h"
00037
00038 #include "kabcore.h"
00039
00040 #include "kaddressbookmain.h"
00041
00042 KAddressBookMain::KAddressBookMain( const QString &file )
00043 : KXmlGuiWindow( 0 )
00044 {
00045
00046
00047 setAttribute( Qt::WA_GroupLeader );
00048
00049 setCaption( i18n( "Address Book Browser" ) );
00050
00051 mCore = new KABCore( this, true, this, file );
00052 mCore->restoreSettings();
00053
00054 initActions();
00055
00056 setCentralWidget( mCore->widget() );
00057
00058 statusBar()->show();
00059 statusBar()->insertItem( "", 1 );
00060
00061 KPIM::ProgressDialog *progressDialog = new KPIM::ProgressDialog( statusBar(),
00062 this );
00063 progressDialog->hide();
00064
00065 KPIM::StatusbarProgressWidget *progressWidget;
00066 progressWidget = new KPIM::StatusbarProgressWidget( progressDialog,
00067 statusBar() );
00068 progressWidget->show();
00069
00070 statusBar()->addPermanentWidget( progressWidget, 0 );
00071
00072 mCore->setStatusBar( statusBar() );
00073
00074 setStandardToolBarMenuEnabled( true );
00075
00076 createGUI( "kaddressbookui.rc" );
00077
00078 resize( 400, 300 );
00079 setAutoSaveSettings();
00080
00081 new CoreAdaptor( this );
00082 QDBusConnection::sessionBus().registerObject("/KAddressBook", this, QDBusConnection::ExportAdaptors);
00083 }
00084
00085 KAddressBookMain::~KAddressBookMain()
00086 {
00087 mCore->saveSettings();
00088 }
00089
00090 void KAddressBookMain::addEmail( QString addr )
00091 {
00092 mCore->addEmail( addr );
00093 }
00094
00095 void KAddressBookMain::importVCard( const KUrl& url )
00096 {
00097 mCore->importVCard( url );
00098 }
00099
00100 void KAddressBookMain::importVCardFromData( const QString& vCard )
00101 {
00102 mCore->importVCardFromData( vCard );
00103 }
00104
00105 void KAddressBookMain::showContactEditor( QString uid )
00106 {
00107 mCore->editContact( uid );
00108 }
00109
00110 void KAddressBookMain::newDistributionList()
00111 {
00112 mCore->newDistributionList();
00113 }
00114
00115 void KAddressBookMain::newContact()
00116 {
00117 mCore->newContact();
00118 }
00119
00120 QString KAddressBookMain::getNameByPhone( QString phone )
00121 {
00122 return mCore->getNameByPhone( phone );
00123 }
00124
00125 void KAddressBookMain::save()
00126 {
00127 mCore->save();
00128 }
00129
00130 void KAddressBookMain::exit()
00131 {
00132 close();
00133 }
00134
00135 bool KAddressBookMain::handleCommandLine()
00136 {
00137 return mCore->handleCommandLine();
00138 }
00139
00140 void KAddressBookMain::saveProperties( KConfigGroup& )
00141 {
00142 }
00143
00144 void KAddressBookMain::readProperties( const KConfigGroup& )
00145 {
00146 }
00147
00148 bool KAddressBookMain::queryClose()
00149 {
00150 return mCore->queryClose();
00151 }
00152
00153 void KAddressBookMain::initActions()
00154 {
00155 KStandardAction::quit( this, SLOT( close() ), actionCollection() );
00156
00157 KAction *action;
00158 action = KStandardAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
00159 action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
00160
00161 KStandardAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
00162 }
00163
00164 void KAddressBookMain::configureKeyBindings()
00165 {
00166 KShortcutsDialog::configure( actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, this );
00167 }
00168
00169 void KAddressBookMain::configureToolbars()
00170 {
00171 saveMainWindowSettings( KGlobal::config()->group( "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" );
00183 applyMainWindowSettings( KGlobal::config()->group( "MainWindow" ) );
00184 }
00185
00186 #include "kaddressbookmain.moc"