00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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"