korganizer Library API Documentation

korganizer_part.cpp

00001 /*
00002     This file is part of KOrganizer.
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., 675 Mass Ave, Cambridge, MA 02139, 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 <kinstance.h>
00025 #include <klocale.h>
00026 #include <kaboutdata.h>
00027 #include <kiconloader.h>
00028 #include <kaction.h>
00029 #include <kdebug.h>
00030 
00031 #include "calendarview.h"
00032 
00033 #include "korganizer_part.h"
00034 
00035 extern "C"
00036 {
00042   void *init_libkorganizer()
00043   {
00044     return new KOrganizerFactory;
00045   }
00046 }
00047 
00052 KInstance *KOrganizerFactory::s_instance = 0L;
00053 KAboutData *KOrganizerFactory::s_about = 0L;
00054 
00055 KOrganizerFactory::KOrganizerFactory()
00056 {
00057 }
00058 
00059 KOrganizerFactory::~KOrganizerFactory()
00060 {
00061   delete s_instance;
00062   s_instance = 0;
00063   delete s_about;
00064 }
00065 
00066 KParts::Part *KOrganizerFactory::createPartObject(QWidget *parentWidget, const char *widgetName,
00067                                    QObject *parent, const char *name,
00068                                    const char*,const QStringList& )
00069 {
00070   KParts::Part *obj = new KOrganizerPart(parentWidget, widgetName, parent, name );
00071   return obj;
00072 }
00073 
00074 KInstance *KOrganizerFactory::instance()
00075 {
00076   if ( !s_instance ) {
00077     s_about = new KAboutData("korganizer", I18N_NOOP("KOrganizer"),"1.99");
00078     s_instance = new KInstance(s_about);
00079   }
00080   
00081   kdDebug() << "KOrganizerFactory::instance(): Name: " <<
00082                s_instance->instanceName() << endl;
00083   
00084   return s_instance;
00085 }
00086 
00087 KOrganizerPart::KOrganizerPart(QWidget *parentWidget, const char *widgetName,
00088                                QObject *parent, const char *name) :
00089   KParts::ReadOnlyPart(parent, name)
00090 {
00091   setInstance(KOrganizerFactory::instance());
00092 
00093   // create a canvas to insert our widget
00094   QWidget *canvas = new QWidget(parentWidget, widgetName);
00095   canvas->setFocusPolicy(QWidget::ClickFocus);
00096   setWidget(canvas);
00097 
00098   m_extension = new KOrganizerBrowserExtension(this);
00099 
00100   QVBoxLayout *topLayout = new QVBoxLayout(canvas);
00101 
00102   KGlobal::iconLoader()->addAppDir("korganizer");
00103 
00104   widget = new CalendarView(canvas);
00105   topLayout->addWidget(widget);
00106 
00107   widget->show();
00108 
00109   (void)new KAction(i18n("&List"), "list", 0,
00110                     widget, SLOT(showListView()),
00111                     actionCollection(), "view_list");
00112   (void)new KAction(i18n("&Day"), "1day", 0,
00113                     widget, SLOT(showDayView()),
00114                     actionCollection(), "view_day");
00115   (void)new KAction(i18n("W&ork Week"), "5days", 0,
00116                     widget, SLOT(showWorkWeekView()),
00117                     actionCollection(), "view_workweek");
00118   (void)new KAction(i18n("&Week"), "7days", 0,
00119                     widget, SLOT(showWeekView()),
00120                     actionCollection(), "view_week");
00121   (void)new KAction(i18n("&Next X Days"), "nextXdays", 0,
00122                     widget, SLOT(showNextXView()),
00123                     actionCollection(), "view_nextx");
00124   (void)new KAction(i18n("&Month"), "month", 0,
00125                     widget, SLOT(showMonthView()),
00126                     actionCollection(), "view_month");
00127   (void)new KAction(i18n("&To-Do List"), "todo", 0,
00128                     widget, SLOT(view_todolist()),
00129                     actionCollection(), "view_todo");
00130 
00131   setXMLFile( "korganizer_part.rc" );
00132 }
00133 
00134 KOrganizerPart::~KOrganizerPart()
00135 {
00136   closeURL();
00137 }
00138 
00139 bool KOrganizerPart::openFile()
00140 {
00141   widget->openCalendar(m_file);
00142   widget->show();
00143   return true;
00144 }
00145 
00146 KOrganizerBrowserExtension::KOrganizerBrowserExtension(KOrganizerPart *parent) :
00147   KParts::BrowserExtension(parent, "KOrganizerBrowserExtension")
00148 {
00149 }
00150 
00151 KOrganizerBrowserExtension::~KOrganizerBrowserExtension()
00152 {
00153 }
00154 
00155 using namespace KParts;
00156 #include "korganizer_part.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:41:10 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001