kaddressbook
kaddressbook_part.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 <qlayout.h>
00025
00026 #include <kaction.h>
00027 #include <kapplication.h>
00028 #include <kdebug.h>
00029 #include <kiconloader.h>
00030 #include <kinstance.h>
00031 #include <klocale.h>
00032 #include <kparts/genericfactory.h>
00033 #include <kparts/statusbarextension.h>
00034 #include <kstatusbar.h>
00035
00036 #include "kabcore.h"
00037 #include "kabprefs.h"
00038 #include "kaddressbookiface.h"
00039
00040 #include "kaddressbook_part.h"
00041
00042 typedef KParts::GenericFactory< KAddressbookPart > KAddressbookFactory;
00043 K_EXPORT_COMPONENT_FACTORY( libkaddressbookpart, KAddressbookFactory )
00044
00045 KAddressbookPart::KAddressbookPart( QWidget *parentWidget, const char *widgetName,
00046 QObject *parent, const char *name,
00047 const QStringList & )
00048 : DCOPObject( "KAddressBookIface" ), KParts::ReadOnlyPart( parent, name )
00049 {
00050 setInstance( KAddressbookFactory::instance() );
00051
00052
00053 QWidget *canvas = new QWidget( parentWidget, widgetName );
00054 canvas->setFocusPolicy( QWidget::ClickFocus );
00055 setWidget( canvas );
00056
00057 QVBoxLayout *topLayout = new QVBoxLayout( canvas );
00058
00059 KGlobal::iconLoader()->addAppDir( "kaddressbook" );
00060
00061 mCore = new KABCore( this, true, canvas );
00062 mCore->restoreSettings();
00063 topLayout->addWidget( mCore->widget() );
00064
00065 KParts::StatusBarExtension *statusBar = new KParts::StatusBarExtension( this );
00066 mCore->setStatusBar( statusBar->statusBar() );
00067
00068 setXMLFile( "kaddressbook_part.rc" );
00069 }
00070
00071 KAddressbookPart::~KAddressbookPart()
00072 {
00073 mCore->save();
00074 mCore->saveSettings();
00075
00076 KABPrefs::instance()->writeConfig();
00077 closeURL();
00078 }
00079
00080 KAboutData *KAddressbookPart::createAboutData()
00081 {
00082 return KABCore::createAboutData();
00083 }
00084
00085 void KAddressbookPart::addEmail( QString addr )
00086 {
00087 mCore->addEmail( addr );
00088 }
00089
00090 void KAddressbookPart::importVCard( const KURL& url )
00091 {
00092 mCore->importVCard( url );
00093 }
00094
00095 void KAddressbookPart::importVCardFromData( const QString& vCard )
00096 {
00097 mCore->importVCardFromData( vCard );
00098 }
00099
00100 ASYNC KAddressbookPart::showContactEditor( QString uid )
00101 {
00102 mCore->editContact( uid );
00103 }
00104
00105 void KAddressbookPart::newContact()
00106 {
00107 mCore->newContact();
00108 }
00109
00110
00111 void KAddressbookPart::newDistributionList()
00112 {
00113 mCore->newDistributionList();
00114 }
00115
00116 QString KAddressbookPart::getNameByPhone( QString phone )
00117 {
00118 return mCore->getNameByPhone( phone );
00119 }
00120
00121 void KAddressbookPart::save()
00122 {
00123 mCore->save();
00124 }
00125
00126 void KAddressbookPart::exit()
00127 {
00128 mCore->queryClose();
00129
00130 delete this;
00131 }
00132
00133 bool KAddressbookPart::openURL( const KURL &url )
00134 {
00135 kdDebug(5720) << "KAddressbookPart:openFile()" << endl;
00136
00137 mCore->widget()->show();
00138
00139 if ( !url.isEmpty() )
00140 mCore->importVCard( url );
00141
00142 emit setWindowCaption( url.prettyURL() );
00143
00144 return true;
00145 }
00146
00147 bool KAddressbookPart::openFile()
00148 {
00149 return false;
00150 }
00151
00152 bool KAddressbookPart::handleCommandLine()
00153 {
00154 return mCore->handleCommandLine( this );
00155 }
00156
00157 void KAddressbookPart::guiActivateEvent( KParts::GUIActivateEvent *e )
00158 {
00159 kdDebug(5720) << "KAddressbookPart::guiActivateEvent" << endl;
00160 KParts::ReadOnlyPart::guiActivateEvent( e );
00161
00162 if ( e->activated() )
00163 mCore->reinitXMLGUI();
00164
00165 if ( !e->activated() ) {
00166 mCore->statusBar()->removeItem( 1 );
00167 mCore->statusBar()->removeItem( 2 );
00168 }
00169 }
00170
00171 void KAddressbookPart::loadProfile( const QString& )
00172 {
00173 }
00174
00175 void KAddressbookPart::saveToProfile( const QString& ) const
00176 {
00177 }
00178
00179 #include "kaddressbook_part.moc"
|