summaryrefslogtreecommitdiffstats
path: root/korganizer/plugins/hebrew/hebrew.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /korganizer/plugins/hebrew/hebrew.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'korganizer/plugins/hebrew/hebrew.cpp')
-rw-r--r--korganizer/plugins/hebrew/hebrew.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/korganizer/plugins/hebrew/hebrew.cpp b/korganizer/plugins/hebrew/hebrew.cpp
new file mode 100644
index 000000000..4c557d00d
--- /dev/null
+++ b/korganizer/plugins/hebrew/hebrew.cpp
@@ -0,0 +1,112 @@
+/*
+ This file is part of KOrganizer.
+ Copyright (c) 2003 Jonathan Singer <jsinger@leeta.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <kglobal.h>
+#include <kconfig.h>
+#include <kstandarddirs.h>
+#include <ksimpleconfig.h>
+#include <kcalendarsystem.h>
+#include <kcalendarsystemfactory.h>
+#include "hebrew.h"
+#include "configdialog.h"
+#include "parsha.h"
+#include "converter.h"
+#include "holiday.h"
+
+bool Hebrew::IsraelP;
+
+class HebrewFactory:public CalendarDecorationFactory
+{
+public:
+ CalendarDecoration * create()
+ {
+ return new Hebrew;
+ }
+};
+
+K_EXPORT_COMPONENT_FACTORY( libkorg_hebrew, HebrewFactory )
+
+
+QString Hebrew::shortText(const QDate & date)
+{
+
+ KConfig config("korganizerrc", true, false); // Open read-only, no kdeglobals
+
+ config.setGroup("Calendar/Hebrew Calendar Plugin");
+ IsraelP =
+ config.readBoolEntry("Israel",
+ (KGlobal::locale()->country() == ".il"));
+ Holiday::ParshaP = config.readBoolEntry("Parsha", true);
+ Holiday::CholP = config.readBoolEntry("Chol_HaMoed", true);
+ Holiday::OmerP = config.readBoolEntry("Omer", true);
+ QString *label_text = new QString();
+
+ int day = date.day();
+ int month = date.month();
+ int year = date.year();
+
+ // core calculations!!
+ struct DateResult result;
+
+ Converter::SecularToHebrewConversion(year, month, day, /*0, */
+ &result);
+ int hebrew_day = result.day;
+ int hebrew_month = result.month;
+ int hebrew_year = result.year;
+ int hebrew_day_of_week = result.day_of_week;
+ bool hebrew_leap_year_p = result.hebrew_leap_year_p;
+ int hebrew_kvia = result.kvia;
+ int hebrew_day_number = result.hebrew_day_number;
+
+ QStringList holidays =
+ Holiday::FindHoliday(hebrew_month, hebrew_day,
+ hebrew_day_of_week + 1, hebrew_kvia,
+ hebrew_leap_year_p, IsraelP,
+ hebrew_day_number, hebrew_year);
+
+ KCalendarSystem *cal = KCalendarSystemFactory::create("hebrew");
+ *label_text = QString("%1 %2").arg(cal->dayString(date, false))
+ .arg(cal->monthName(date));
+
+ if (holidays.count())
+ {
+ int count = holidays.count();
+
+ for (int h = 0; h <= count; ++h)
+ {
+ *label_text += "\n" + holidays[h];
+ }
+ }
+
+ return *label_text;
+}
+
+QString Hebrew::info()
+{
+ return
+ i18n("This plugin provides the date in the Jewish calendar.");
+}
+
+void Hebrew::configure(QWidget * parent)
+{
+ ConfigDialog *dlg = new ConfigDialog(parent); //parent?
+
+ dlg->exec();
+ delete dlg;
+}