00001
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
extern "C"
00044 {
00045
void *init_libkorg_hebrew()
00046 {
00047
return (
new HebrewFactory);
00048 }
00049 }
00050
00051
QString Hebrew::shortText(
const QDate & date)
00052 {
00053
00054 KConfig config(locateLocal(
"config",
"korganizerrc"));
00055
00056 config.setGroup(
"Calendar/Hebrew Calendar Plugin");
00057 IsraelP =
00058 config.readBoolEntry(
"Israel",
00059 (KGlobal::locale()->country() ==
".il"));
00060 Holiday::ParshaP = config.readBoolEntry(
"Parsha",
true);
00061 Holiday::CholP = config.readBoolEntry(
"Chol_HaMoed",
true);
00062 Holiday::OmerP = config.readBoolEntry(
"Omer",
true);
00063
QString *label_text =
new QString();
00064
00065
int day = date.day();
00066
int month = date.month();
00067
int year = date.year();
00068
00069
00070
struct DateResult result;
00071
00072 Converter::SecularToHebrewConversion(year, month, day,
00073 &result);
00074
int hebrew_day = result.day;
00075
int hebrew_month = result.month;
00076
int hebrew_year = result.year;
00077
int hebrew_day_of_week = result.day_of_week;
00078
bool hebrew_leap_year_p = result.hebrew_leap_year_p;
00079
int hebrew_kvia = result.kvia;
00080
int hebrew_day_number = result.hebrew_day_number;
00081
00082
QStringList holidays =
00083 Holiday::FindHoliday(hebrew_month, hebrew_day,
00084 hebrew_day_of_week + 1, hebrew_kvia,
00085 hebrew_leap_year_p, IsraelP,
00086 hebrew_day_number, hebrew_year);
00087
00088 KCalendarSystem *cal = KCalendarSystemFactory::create(
"hebrew");
00089 *label_text = QString(
"%1 %2").arg(cal->dayString(date,
false))
00090 .arg(cal->monthName(date));
00091
00092
if (holidays.count())
00093 {
00094
int count = holidays.count();
00095
00096
for (
int h = 0; h <= count; h++)
00097 {
00098 *label_text +=
"\n" + holidays[h];
00099 }
00100 }
00101
00102
return *label_text;
00103 }
00104
00105
QString Hebrew::info()
00106 {
00107
return
00108 i18n(
"This plugin provides the date in the Jewish calendar.");
00109 }
00110
00111
void Hebrew::configure(
QWidget * parent)
00112 {
00113
ConfigDialog *dlg =
new ConfigDialog(parent);
00114
00115 dlg->exec();
00116 }