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 #include "korganizerifaceimpl.h"
00035 #include "stdcalendar.h"
00036 #include "alarmclient.h"
00037 
00038 #include <libkcal/calendarlocal.h>
00039 #include <libkcal/calendarresources.h>
00040 #include <libkcal/resourcecalendar.h>
00041 #include <libkcal/resourcelocal.h>
00042 
00043 #include <kpopupmenu.h>
00044 #include <kinstance.h>
00045 #include <klocale.h>
00046 #include <kaboutdata.h>
00047 #include <kiconloader.h>
00048 #include <kaction.h>
00049 #include <kdebug.h>
00050 #include <kstandarddirs.h>
00051 #include <kconfig.h>
00052 #include <kprocess.h>
00053 #include <ktempfile.h>
00054 #include <kstatusbar.h>
00055 #include <kkeydialog.h>
00056 #include <kparts/genericfactory.h>
00057 
00058 #include <kparts/statusbarextension.h>
00059 
00060 #include <sidebarextension.h>
00061 #include <infoextension.h>
00062 
00063 #include <qapplication.h>
00064 #include <qfile.h>
00065 #include <qtimer.h>
00066 #include <qlayout.h>
00067 
00068 typedef KParts::GenericFactory< KOrganizerPart > KOrganizerFactory;
00069 K_EXPORT_COMPONENT_FACTORY( libkorganizerpart, KOrganizerFactory )
00070 
00071 KOrganizerPart::KOrganizerPart( QWidget *parentWidget, const char *widgetName,
00072                                 QObject *parent, const char *name,
00073                                 const QStringList & ) :
00074   KParts::ReadOnlyPart(parent, name)
00075 {
00076   KGlobal::locale()->insertCatalogue( "libkcal" );
00077   KGlobal::locale()->insertCatalogue( "libkdepim" );
00078   KGlobal::locale()->insertCatalogue( "kdgantt" );
00079 
00080   KOCore::self()->setXMLGUIClient( this );
00081 
00082   QString pname( name );
00083 
00084   // create a canvas to insert our widget
00085   QWidget *canvas = new QWidget( parentWidget, widgetName );
00086   canvas->setFocusPolicy( QWidget::ClickFocus );
00087   setWidget( canvas );
00088   mView = new CalendarView( canvas );
00089 
00090   mActionManager = new ActionManager( this, mView, this, this, true );
00091   (void)new KOrganizerIfaceImpl( mActionManager, this, "IfaceImpl" );
00092 
00093   if ( pname == "kontact" ) {
00094     mActionManager->createCalendarResources();
00095     setHasDocument( false );
00096     KOrg::StdCalendar::self()->load();
00097     mView->updateCategories();
00098   } else {
00099     mActionManager->createCalendarLocal();
00100     setHasDocument( true );
00101   }
00102 
00103   mBrowserExtension = new KOrganizerBrowserExtension( this );
00104   mStatusBarExtension = new KParts::StatusBarExtension( this );
00105 
00106   setInstance( KOrganizerFactory::instance() );
00107 
00108   QVBoxLayout *topLayout = new QVBoxLayout( canvas );
00109   topLayout->addWidget( mView );
00110 
00111   KGlobal::iconLoader()->addAppDir( "korganizer" );
00112 
00113   new KParts::SideBarExtension( mView->leftFrame(), this, "SBE" );
00114 
00115   KParts::InfoExtension *ie = new KParts::InfoExtension( this,
00116                                                          "KOrganizerInfo" );
00117   connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
00118            SLOT( slotChangeInfo( Incidence * ) ) );
00119   connect( this, SIGNAL( textChanged( const QString & ) ),
00120            ie, SIGNAL( textChanged( const QString & ) ) );
00121 
00122   mView->show();
00123 
00124   mActionManager->init();
00125   mActionManager->readSettings();
00126   connect( mActionManager, SIGNAL( actionKeyBindings() ),
00127            SLOT( configureKeyBindings() ) );
00128 
00129   setXMLFile( "korganizer_part.rc" );
00130   mActionManager->loadParts();
00131 }
00132 
00133 KOrganizerPart::~KOrganizerPart()
00134 {
00135   mActionManager->saveCalendar();
00136   mActionManager->writeSettings();
00137 
00138   delete mActionManager;
00139   mActionManager = 0;
00140 
00141   closeURL();
00142 }
00143 
00144 KAboutData *KOrganizerPart::createAboutData()
00145 {
00146   return KOrg::AboutData::self();
00147 }
00148 
00149 void KOrganizerPart::startCompleted( KProcess *process )
00150 {
00151   delete process;
00152 }
00153 
00154 void KOrganizerPart::slotChangeInfo( Incidence *incidence )
00155 {
00156   if ( incidence ) {
00157     emit textChanged( incidence->summary() + " / " +
00158                       incidence->dtStartTimeStr() );
00159   } else {
00160     emit textChanged( QString::null );
00161   }
00162 }
00163 
00164 QWidget *KOrganizerPart::topLevelWidget()
00165 {
00166   return mView->topLevelWidget();
00167 }
00168 
00169 ActionManager *KOrganizerPart::actionManager()
00170 {
00171   return mActionManager;
00172 }
00173 
00174 void KOrganizerPart::showStatusMessage( const QString &message )
00175 {
00176   KStatusBar *statusBar = mStatusBarExtension->statusBar();
00177   if ( statusBar ) statusBar->message( message );
00178 }
00179 
00180 KOrg::CalendarViewBase *KOrganizerPart::view() const
00181 {
00182   return mView;
00183 }
00184 
00185 bool KOrganizerPart::openURL( const KURL &url, bool merge )
00186 {
00187   return mActionManager->openURL( url, merge );
00188 }
00189 
00190 bool KOrganizerPart::saveURL()
00191 {
00192   return mActionManager->saveURL();
00193 }
00194 
00195 bool KOrganizerPart::saveAsURL( const KURL &kurl )
00196 {
00197   return mActionManager->saveAsURL( kurl );
00198 }
00199 
00200 KURL KOrganizerPart::getCurrentURL() const
00201 {
00202   return mActionManager->url();
00203 }
00204 
00205 bool KOrganizerPart::openFile()
00206 {
00207   mView->openCalendar( m_file );
00208   mView->show();
00209   return true;
00210 }
00211 
00212 void KOrganizerPart::configureKeyBindings()
00213 {
00214   KKeyDialog::configure( actionCollection(), true );
00215 }
00216 
00217 
00218 KOrganizerBrowserExtension::KOrganizerBrowserExtension(KOrganizerPart *parent) :
00219   KParts::BrowserExtension(parent, "KOrganizerBrowserExtension")
00220 {
00221 }
00222 
00223 KOrganizerBrowserExtension::~KOrganizerBrowserExtension()
00224 {
00225 }
00226 
00227 using namespace KParts;
00228 
00229 #include "korganizer_part.moc"
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 23 18:22:15 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003