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 
00039 #include "kaddressbook_part.h"
00040 
00041 typedef KParts::GenericFactory< KAddressbookPart > KAddressbookFactory;
00042 K_EXPORT_COMPONENT_FACTORY( libkaddressbookpart, KAddressbookFactory )
00043 
00044 KAddressbookPart::KAddressbookPart( QWidget *parentWidget, const char *widgetName,
00045                                     QObject *parent, const char *name,
00046                                     const QStringList & )
00047   : DCOPObject( "KAddressBookIface" ), KParts::ReadOnlyPart( parent, name )
00048 {
00049   kdDebug(5720) << "KAddressbookPart()" << endl;
00050   kdDebug(5720) << "  InstanceName: " << kapp->instanceName() << endl;
00051 
00052   setInstance( KAddressbookFactory::instance() );
00053 
00054   kdDebug(5720) << "KAddressbookPart()..." << endl;
00055   kdDebug(5720) << "  InstanceName: " << kapp->instanceName() << endl;
00056 
00057   // create a canvas to insert our widget
00058   QWidget *canvas = new QWidget( parentWidget, widgetName );
00059   canvas->setFocusPolicy( QWidget::ClickFocus );
00060   setWidget( canvas );
00061 
00062   mExtension = new KAddressbookBrowserExtension( this );
00063 
00064   QVBoxLayout *topLayout = new QVBoxLayout( canvas );
00065 
00066   KGlobal::iconLoader()->addAppDir( "kaddressbook" );
00067 
00068   mCore = new KABCore( this, true, canvas );
00069   mCore->restoreSettings();
00070   topLayout->addWidget( mCore->widget() );
00071 
00072   KParts::StatusBarExtension *statusBar = new KParts::StatusBarExtension( this );
00073   mCore->setStatusBar( statusBar->statusBar() );
00074 
00075   setXMLFile( "kaddressbook_part.rc" );
00076 }
00077 
00078 KAddressbookPart::~KAddressbookPart()
00079 {
00080   mCore->save();
00081   closeURL();
00082 }
00083 
00084 KAboutData *KAddressbookPart::createAboutData()
00085 {
00086   return KABCore::createAboutData();
00087 }
00088 
00089 void KAddressbookPart::addEmail( QString addr )
00090 {
00091   mCore->addEmail( addr );
00092 }
00093 
00094 void KAddressbookPart::importVCard( const QString& vCardURL )
00095 {
00096   mCore->importVCard( vCardURL );
00097 }
00098 
00099 ASYNC KAddressbookPart::showContactEditor( QString uid )
00100 {
00101   mCore->editContact( uid );
00102 }
00103 
00104 void KAddressbookPart::newContact()
00105 {
00106   mCore->newContact();
00107 }
00108 
00109 QString KAddressbookPart::getNameByPhone( QString phone )
00110 {
00111   return mCore->getNameByPhone( phone );
00112 }
00113 
00114 void KAddressbookPart::save()
00115 {
00116   mCore->save();
00117 }
00118 
00119 void KAddressbookPart::exit()
00120 {
00121   delete this;
00122 }
00123 
00124 bool KAddressbookPart::openURL( const KURL &url )
00125 {
00126   kdDebug(5720) << "KAddressbookPart:openFile()" << endl;
00127 
00128   mCore->widget()->show();
00129 
00130   if ( !url.isEmpty() )
00131     mCore->importVCard( url );
00132 
00133   emit setWindowCaption( url.prettyURL() );
00134 
00135   return true;
00136 }
00137 
00138 bool KAddressbookPart::openFile()
00139 {
00140   return false;
00141 }
00142 
00143 bool KAddressbookPart::handleCommandLine()
00144 {
00145   return mCore->handleCommandLine( this );
00146 }
00147 
00148 void KAddressbookPart::guiActivateEvent( KParts::GUIActivateEvent *e )
00149 {
00150   kdDebug(5720) << "KAddressbookPart::guiActivateEvent" << endl;
00151   KParts::ReadOnlyPart::guiActivateEvent( e );
00152 }
00153 
00154 KAddressbookBrowserExtension::KAddressbookBrowserExtension( KAddressbookPart *parent )
00155   : KParts::BrowserExtension( parent, "KAddressbookBrowserExtension" )
00156 {
00157 }
00158 
00159 KAddressbookBrowserExtension::~KAddressbookBrowserExtension()
00160 {
00161 }
00162 
00163 using namespace KParts;
00164 
00165 #include "kaddressbook_part.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Dec 21 14:24:11 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003