korganizer Library API Documentation

korganizer_part.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include "korganizer_part.h"
00026 
00027 #include "calendarview.h"
00028 #include "actionmanager.h"
00029 #include "koglobals.h"
00030 #include "koprefs.h"
00031 #include "resourceview.h"
00032 #include "aboutdata.h"
00033 #include "kocore.h"
00034 
00035 #include "kalarmd/alarmdaemoniface_stub.h"
00036 
00037 #include <libkcal/calendarlocal.h>
00038 #include <libkcal/calendarresources.h>
00039 #include <libkcal/resourcecalendar.h>
00040 #include <libkcal/resourcelocal.h>
00041 
00042 #include <kpopupmenu.h>
00043 #include <kinstance.h>
00044 #include <klocale.h>
00045 #include <kaboutdata.h>
00046 #include <kiconloader.h>
00047 #include <kaction.h>
00048 #include <kdebug.h>
00049 #include <kstandarddirs.h>
00050 #include <kconfig.h>
00051 #include <kprocess.h>
00052 #include <ktempfile.h>
00053 #include <kstatusbar.h>
00054 #include <kkeydialog.h>
00055 #include <kparts/genericfactory.h>
00056 
00057 #include <sidebarextension.h>
00058 #include <infoextension.h>
00059 
00060 #include <qapplication.h>
00061 #include <qfile.h>
00062 #include <qtimer.h>
00063 
00064 typedef KParts::GenericFactory< KOrganizerPart > KOrganizerFactory;
00065 K_EXPORT_COMPONENT_FACTORY( libkorganizerpart, KOrganizerFactory )
00066 
00067 KOrganizerPart::KOrganizerPart( QWidget *parentWidget, const char *widgetName,
00068                                 QObject *parent, const char *name,
00069                                 const QStringList & ) :
00070   KParts::ReadOnlyPart(parent, name)
00071 {
00072   KOCore::self()->setXMLGUIClient( this );
00073 
00074   QString pname( name );
00075 
00076   // create a canvas to insert our widget
00077   QWidget *canvas = new QWidget( parentWidget, widgetName );
00078   canvas->setFocusPolicy( QWidget::ClickFocus );
00079   setWidget( canvas );
00080   mView = new CalendarView( canvas );
00081 
00082   mActionManager = new ActionManager( this, mView, this, this, true );
00083 
00084   if ( pname == "kontact" ) {
00085     mActionManager->createCalendarResources();
00086     setHasDocument( false );
00087   } else {
00088     mActionManager->createCalendarLocal();
00089     setHasDocument( true );
00090   }
00091 
00092   mBrowserExtension = new KOrganizerBrowserExtension( this );
00093   mStatusBarExtension = new KParts::StatusBarExtension( this );
00094 
00095   setInstance( KOrganizerFactory::instance() );
00096 
00097   QVBoxLayout *topLayout = new QVBoxLayout( canvas );
00098   topLayout->addWidget( mView );
00099 
00100   KGlobal::iconLoader()->addAppDir( "korganizer" );
00101 
00102   new KParts::SideBarExtension( mView->leftFrame(), this, "SBE" );
00103 
00104   KParts::InfoExtension *ie = new KParts::InfoExtension( this,
00105                                                          "KOrganizerInfo" );
00106   connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
00107            SLOT( slotChangeInfo( Incidence * ) ) );
00108   connect( this, SIGNAL( textChanged( const QString & ) ),
00109            ie, SIGNAL( textChanged( const QString & ) ) );
00110 
00111   mView->show();
00112 
00113   mActionManager->init();
00114   mActionManager->readSettings();
00115   connect( mActionManager, SIGNAL( actionKeyBindings() ),
00116            SLOT( configureKeyBindings() ) );
00117 
00118   setXMLFile( "korganizer_part.rc" );
00119   mActionManager->loadParts();
00120 }
00121 
00122 KOrganizerPart::~KOrganizerPart()
00123 {
00124   mActionManager->saveCalendar();
00125   mActionManager->writeSettings();
00126 
00127   delete mActionManager;
00128   mActionManager = 0;
00129 
00130   closeURL();
00131 }
00132 
00133 KAboutData *KOrganizerPart::createAboutData()
00134 {
00135   return KOrg::AboutData::self();
00136 }
00137 
00138 void KOrganizerPart::startCompleted( KProcess *process )
00139 {
00140   delete process;
00141 }
00142 
00143 void KOrganizerPart::slotChangeInfo( Incidence *incidence )
00144 {
00145   if ( incidence ) {
00146     emit textChanged( incidence->summary() + " / " +
00147                       incidence->dtStartTimeStr() );
00148   } else {
00149     emit textChanged( QString::null );
00150   }
00151 }
00152 
00153 QWidget *KOrganizerPart::topLevelWidget()
00154 {
00155   return mView->topLevelWidget();
00156 }
00157 
00158 ActionManager *KOrganizerPart::actionManager()
00159 {
00160   return mActionManager;
00161 }
00162 
00163 void KOrganizerPart::showStatusMessage( const QString &message )
00164 {
00165   KStatusBar *statusBar = mStatusBarExtension->statusBar();
00166   if ( statusBar ) statusBar->message( message );
00167 }
00168 
00169 KOrg::CalendarViewBase *KOrganizerPart::view() const
00170 {
00171   return mView;
00172 }
00173 
00174 bool KOrganizerPart::openURL( const KURL &url, bool merge )
00175 {
00176   return mActionManager->openURL( url, merge );
00177 }
00178 
00179 bool KOrganizerPart::saveURL()
00180 {
00181   return mActionManager->saveURL();
00182 }
00183 
00184 bool KOrganizerPart::saveAsURL( const KURL &kurl )
00185 {
00186   return mActionManager->saveAsURL( kurl );
00187 }
00188 
00189 KURL KOrganizerPart::getCurrentURL() const
00190 {
00191   return mActionManager->url();
00192 }
00193 
00194 bool KOrganizerPart::openFile()
00195 {
00196   mView->openCalendar( m_file );
00197   mView->show();
00198   return true;
00199 }
00200 
00201 void KOrganizerPart::configureKeyBindings()
00202 {
00203   KKeyDialog::configure( actionCollection(), true );
00204 }
00205 
00206 
00207 KOrganizerBrowserExtension::KOrganizerBrowserExtension(KOrganizerPart *parent) :
00208   KParts::BrowserExtension(parent, "KOrganizerBrowserExtension")
00209 {
00210 }
00211 
00212 KOrganizerBrowserExtension::~KOrganizerBrowserExtension()
00213 {
00214 }
00215 
00216 using namespace KParts;
00217 
00218 #include "korganizer_part.moc"
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:30 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003