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