kaddressbook Library API Documentation

kaddressbook_part.cpp

00001 /* 00002 This file is part of KAddressbook. 00003 Copyright (c) 2000 Cornelius Schumacher <schumacher@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 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 "kaddressbookiface.h" 00038 #include "libkdepim/infoextension.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 kdDebug(5720) << "KAddressbookPart()" << endl; 00051 kdDebug(5720) << " InstanceName: " << kapp->instanceName() << endl; 00052 00053 setInstance( KAddressbookFactory::instance() ); 00054 00055 kdDebug(5720) << "KAddressbookPart()..." << endl; 00056 kdDebug(5720) << " InstanceName: " << kapp->instanceName() << endl; 00057 00058 // create a canvas to insert our widget 00059 QWidget *canvas = new QWidget( parentWidget, widgetName ); 00060 canvas->setFocusPolicy( QWidget::ClickFocus ); 00061 setWidget( canvas ); 00062 00063 mExtension = new KAddressbookBrowserExtension( this ); 00064 00065 QVBoxLayout *topLayout = new QVBoxLayout( canvas ); 00066 00067 KGlobal::iconLoader()->addAppDir( "kaddressbook" ); 00068 00069 mCore = new KABCore( this, true, canvas ); 00070 mCore->restoreSettings(); 00071 topLayout->addWidget( mCore->widget() ); 00072 00073 KParts::StatusBarExtension *statusBar = new KParts::StatusBarExtension( this ); 00074 mCore->setStatusBar( statusBar->statusBar() ); 00075 00076 KParts::InfoExtension *info = new KParts::InfoExtension( this, "KABPart" ); 00077 connect( mCore, SIGNAL( contactSelected( const QString& ) ), 00078 info, SIGNAL( textChanged( const QString& ) ) ); 00079 connect( mCore, SIGNAL( contactSelected( const QPixmap& ) ), 00080 info, SIGNAL( iconChanged( const QPixmap& ) ) ); 00081 00082 setXMLFile( "kaddressbook_part.rc" ); 00083 } 00084 00085 KAddressbookPart::~KAddressbookPart() 00086 { 00087 mCore->save(); 00088 closeURL(); 00089 } 00090 00091 KAboutData *KAddressbookPart::createAboutData() 00092 { 00093 return KABCore::createAboutData(); 00094 } 00095 00096 void KAddressbookPart::addEmail( QString addr ) 00097 { 00098 mCore->addEmail( addr ); 00099 } 00100 00101 void KAddressbookPart::importVCard( const QString& vCardURL ) 00102 { 00103 mCore->importVCard( vCardURL ); 00104 } 00105 00106 ASYNC KAddressbookPart::showContactEditor( QString uid ) 00107 { 00108 mCore->editContact( uid ); 00109 } 00110 00111 void KAddressbookPart::newContact() 00112 { 00113 mCore->newContact(); 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 delete this; 00129 } 00130 00131 bool KAddressbookPart::openURL( const KURL &url ) 00132 { 00133 kdDebug(5720) << "KAddressbookPart:openFile()" << endl; 00134 00135 mCore->widget()->show(); 00136 00137 if ( !url.isEmpty() ) 00138 mCore->importVCard( url ); 00139 00140 emit setWindowCaption( url.prettyURL() ); 00141 00142 return true; 00143 } 00144 00145 bool KAddressbookPart::openFile() 00146 { 00147 return false; 00148 } 00149 00150 bool KAddressbookPart::handleCommandLine() 00151 { 00152 return mCore->handleCommandLine( this ); 00153 } 00154 00155 void KAddressbookPart::guiActivateEvent( KParts::GUIActivateEvent *e ) 00156 { 00157 kdDebug(5720) << "KAddressbookPart::guiActivateEvent" << endl; 00158 KParts::ReadOnlyPart::guiActivateEvent( e ); 00159 } 00160 00161 KAddressbookBrowserExtension::KAddressbookBrowserExtension( KAddressbookPart *parent ) 00162 : KParts::BrowserExtension( parent, "KAddressbookBrowserExtension" ) 00163 { 00164 } 00165 00166 KAddressbookBrowserExtension::~KAddressbookBrowserExtension() 00167 { 00168 } 00169 00170 using namespace KParts; 00171 00172 #include "kaddressbook_part.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:08 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003