26 #include <tdeaction.h>
27 #include <tdeapplication.h>
29 #include <kiconloader.h>
30 #include <kinstance.h>
31 #include <tdelocale.h>
32 #include <tdeparts/genericfactory.h>
33 #include <tdeparts/statusbarextension.h>
34 #include <kstatusbar.h>
38 #include "kaddressbookiface.h"
40 #include "kaddressbook_part.h"
42 typedef KParts::GenericFactory< KAddressbookPart > KAddressbookFactory;
43 K_EXPORT_COMPONENT_FACTORY( libkaddressbookpart, KAddressbookFactory )
45 KAddressbookPart::KAddressbookPart( TQWidget *parentWidget,
const char *widgetName,
46 TQObject *parent,
const char *name,
47 const TQStringList & )
48 : DCOPObject(
"KAddressBookIface" ), KParts::ReadOnlyPart( parent, name )
50 setInstance( KAddressbookFactory::instance() );
53 TQWidget *canvas =
new TQWidget( parentWidget, widgetName );
54 canvas->setFocusPolicy( TQWidget::ClickFocus );
57 TQVBoxLayout *topLayout =
new TQVBoxLayout( canvas );
59 TDEGlobal::iconLoader()->addAppDir(
"kaddressbook" );
61 mCore =
new KABCore(
this,
true, canvas );
62 mCore->restoreSettings();
63 topLayout->addWidget( mCore->widget() );
65 KParts::StatusBarExtension *statusBar =
new KParts::StatusBarExtension(
this );
66 mCore->setStatusBar( statusBar->statusBar() );
68 setXMLFile(
"kaddressbook_part.rc" );
71 KAddressbookPart::~KAddressbookPart()
74 mCore->saveSettings();
76 KABPrefs::instance()->writeConfig();
80 TDEAboutData *KAddressbookPart::createAboutData()
82 return KABCore::createAboutData();
85 void KAddressbookPart::addEmail( TQString addr )
87 mCore->addEmail( addr );
90 void KAddressbookPart::importVCard(
const KURL& url )
92 mCore->importVCard( url );
95 void KAddressbookPart::importVCardFromData(
const TQString& vCard )
97 mCore->importVCardFromData( vCard );
100 ASYNC KAddressbookPart::showContactEditor( TQString uid )
102 mCore->editContact( uid );
105 void KAddressbookPart::newContact()
111 void KAddressbookPart::newDistributionList()
113 mCore->newDistributionList();
116 TQString KAddressbookPart::getNameByPhone( TQString phone )
118 return mCore->getNameByPhone( phone );
121 void KAddressbookPart::save()
126 void KAddressbookPart::exit()
133 bool KAddressbookPart::openURL(
const KURL &url )
135 kdDebug(5720) <<
"KAddressbookPart:openFile()" << endl;
137 mCore->widget()->show();
139 if ( !url.isEmpty() )
140 mCore->importVCard( url );
142 emit setWindowCaption( url.prettyURL() );
147 bool KAddressbookPart::openFile()
152 bool KAddressbookPart::handleCommandLine()
154 return mCore->handleCommandLine(
this );
157 void KAddressbookPart::syncAllResources()
163 void KAddressbookPart::guiActivateEvent( KParts::GUIActivateEvent *e )
165 kdDebug(5720) <<
"KAddressbookPart::guiActivateEvent" << endl;
166 KParts::ReadOnlyPart::guiActivateEvent( e );
168 if ( e->activated() )
169 mCore->reinitXMLGUI();
171 if ( !e->activated() ) {
172 mCore->statusBar()->removeItem( 1 );
173 mCore->statusBar()->removeItem( 2 );
177 void KAddressbookPart::loadProfile(
const TQString& )
181 void KAddressbookPart::saveToProfile(
const TQString& )
const
185 #include "kaddressbook_part.moc"