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 KOCore::self()->setXMLGUIClient( this ); 00077 00078 QString pname( name ); 00079 00080 // create a canvas to insert our widget 00081 QWidget *canvas = new QWidget( parentWidget, widgetName ); 00082 canvas->setFocusPolicy( QWidget::ClickFocus ); 00083 setWidget( canvas ); 00084 mView = new CalendarView( canvas ); 00085 00086 mActionManager = new ActionManager( this, mView, this, this, true ); 00087 (void)new KOrganizerIfaceImpl( mActionManager, this, "IfaceImpl" ); 00088 00089 if ( pname == "kontact" ) { 00090 mActionManager->createCalendarResources(); 00091 setHasDocument( false ); 00092 KOrg::StdCalendar::self()->load(); 00093 mView->updateCategories(); 00094 } else { 00095 mActionManager->createCalendarLocal(); 00096 setHasDocument( true ); 00097 } 00098 00099 mBrowserExtension = new KOrganizerBrowserExtension( this ); 00100 mStatusBarExtension = new KParts::StatusBarExtension( this ); 00101 00102 setInstance( KOrganizerFactory::instance() ); 00103 00104 QVBoxLayout *topLayout = new QVBoxLayout( canvas ); 00105 topLayout->addWidget( mView ); 00106 00107 KGlobal::iconLoader()->addAppDir( "korganizer" ); 00108 00109 new KParts::SideBarExtension( mView->leftFrame(), this, "SBE" ); 00110 00111 KParts::InfoExtension *ie = new KParts::InfoExtension( this, 00112 "KOrganizerInfo" ); 00113 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 00114 SLOT( slotChangeInfo( Incidence * ) ) ); 00115 connect( this, SIGNAL( textChanged( const QString & ) ), 00116 ie, SIGNAL( textChanged( const QString & ) ) ); 00117 00118 mView->show(); 00119 00120 mActionManager->init(); 00121 mActionManager->readSettings(); 00122 connect( mActionManager, SIGNAL( actionKeyBindings() ), 00123 SLOT( configureKeyBindings() ) ); 00124 00125 setXMLFile( "korganizer_part.rc" ); 00126 mActionManager->loadParts(); 00127 // If korganizer is run as part inside kontact, the alarmdaemon 00128 // is not started by KOrganizerApp, so we have to start it here. 00129 KOGlobals::self()->alarmClient()->startDaemon(); 00130 } 00131 00132 KOrganizerPart::~KOrganizerPart() 00133 { 00134 mActionManager->saveCalendar(); 00135 mActionManager->writeSettings(); 00136 00137 delete mActionManager; 00138 mActionManager = 0; 00139 00140 closeURL(); 00141 } 00142 00143 KAboutData *KOrganizerPart::createAboutData() 00144 { 00145 return KOrg::AboutData::self(); 00146 } 00147 00148 void KOrganizerPart::startCompleted( KProcess *process ) 00149 { 00150 delete process; 00151 } 00152 00153 void KOrganizerPart::slotChangeInfo( Incidence *incidence ) 00154 { 00155 if ( incidence ) { 00156 emit textChanged( incidence->summary() + " / " + 00157 incidence->dtStartTimeStr() ); 00158 } else { 00159 emit textChanged( QString::null ); 00160 } 00161 } 00162 00163 QWidget *KOrganizerPart::topLevelWidget() 00164 { 00165 return mView->topLevelWidget(); 00166 } 00167 00168 ActionManager *KOrganizerPart::actionManager() 00169 { 00170 return mActionManager; 00171 } 00172 00173 void KOrganizerPart::showStatusMessage( const QString &message ) 00174 { 00175 KStatusBar *statusBar = mStatusBarExtension->statusBar(); 00176 if ( statusBar ) statusBar->message( message ); 00177 } 00178 00179 KOrg::CalendarViewBase *KOrganizerPart::view() const 00180 { 00181 return mView; 00182 } 00183 00184 bool KOrganizerPart::openURL( const KURL &url, bool merge ) 00185 { 00186 return mActionManager->openURL( url, merge ); 00187 } 00188 00189 bool KOrganizerPart::saveURL() 00190 { 00191 return mActionManager->saveURL(); 00192 } 00193 00194 bool KOrganizerPart::saveAsURL( const KURL &kurl ) 00195 { 00196 return mActionManager->saveAsURL( kurl ); 00197 } 00198 00199 KURL KOrganizerPart::getCurrentURL() const 00200 { 00201 return mActionManager->url(); 00202 } 00203 00204 bool KOrganizerPart::openFile() 00205 { 00206 mView->openCalendar( m_file ); 00207 mView->show(); 00208 return true; 00209 } 00210 00211 void KOrganizerPart::configureKeyBindings() 00212 { 00213 KKeyDialog::configure( actionCollection(), true ); 00214 } 00215 00216 00217 KOrganizerBrowserExtension::KOrganizerBrowserExtension(KOrganizerPart *parent) : 00218 KParts::BrowserExtension(parent, "KOrganizerBrowserExtension") 00219 { 00220 } 00221 00222 KOrganizerBrowserExtension::~KOrganizerBrowserExtension() 00223 { 00224 } 00225 00226 using namespace KParts; 00227 00228 #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 Oct 1 15:19:32 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003