korganizer
hebrew.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <kglobal.h>
00021 #include <kconfig.h>
00022 #include <kstandarddirs.h>
00023 #include <ksimpleconfig.h>
00024 #include <kcalendarsystem.h>
00025 #include <kcalendarsystemfactory.h>
00026 #include "hebrew.h"
00027 #include "configdialog.h"
00028 #include "parsha.h"
00029 #include "converter.h"
00030 #include "holiday.h"
00031
00032 bool Hebrew::IsraelP;
00033
00034 class HebrewFactory:public CalendarDecorationFactory
00035 {
00036 public:
00037 CalendarDecoration * create()
00038 {
00039 return new Hebrew;
00040 }
00041 };
00042
00043 K_EXPORT_COMPONENT_FACTORY( libkorg_hebrew, HebrewFactory )
00044
00045
00046 QString Hebrew::shortText(const QDate & date)
00047 {
00048
00049 KConfig config("korganizerrc", true, false);
00050
00051 config.setGroup("Calendar/Hebrew Calendar Plugin");
00052 IsraelP =
00053 config.readBoolEntry("Israel",
00054 (KGlobal::locale()->country() == ".il"));
00055 Holiday::ParshaP = config.readBoolEntry("Parsha", true);
00056 Holiday::CholP = config.readBoolEntry("Chol_HaMoed", true);
00057 Holiday::OmerP = config.readBoolEntry("Omer", true);
00058 QString *label_text = new QString();
00059
00060 int day = date.day();
00061 int month = date.month();
00062 int year = date.year();
00063
00064
00065 struct DateResult result;
00066
00067 Converter::SecularToHebrewConversion(year, month, day,
00068 &result);
00069 int hebrew_day = result.day;
00070 int hebrew_month = result.month;
00071 int hebrew_year = result.year;
00072 int hebrew_day_of_week = result.day_of_week;
00073 bool hebrew_leap_year_p = result.hebrew_leap_year_p;
00074 int hebrew_kvia = result.kvia;
00075 int hebrew_day_number = result.hebrew_day_number;
00076
00077 QStringList holidays =
00078 Holiday::FindHoliday(hebrew_month, hebrew_day,
00079 hebrew_day_of_week + 1, hebrew_kvia,
00080 hebrew_leap_year_p, IsraelP,
00081 hebrew_day_number, hebrew_year);
00082
00083 KCalendarSystem *cal = KCalendarSystemFactory::create("hebrew");
00084 *label_text = QString("%1 %2").arg(cal->dayString(date, false))
00085 .arg(cal->monthName(date));
00086
00087 if (holidays.count())
00088 {
00089 int count = holidays.count();
00090
00091 for (int h = 0; h <= count; ++h)
00092 {
00093 *label_text += "\n" + holidays[h];
00094 }
00095 }
00096
00097 return *label_text;
00098 }
00099
00100 QString Hebrew::info()
00101 {
00102 return
00103 i18n("This plugin provides the date in the Jewish calendar.");
00104 }
00105
00106 void Hebrew::configure(QWidget * parent)
00107 {
00108 ConfigDialog *dlg = new ConfigDialog(parent);
00109
00110 dlg->exec();
00111 }
|