00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "parsha.h"
00012 #include <klocale.h>
00013
00014 QStringList Parsha::parshiot_names;
00015
00016 Parsha::Parsha()
00017 {
00018
00019 }
00020
00021 Parsha::~Parsha()
00022 {
00023 }
00024
00025 QString
00026 Parsha::FindParshaName(int daynumber, int kvia, bool leap_p,
00027 bool israel_p)
00028 {
00029
00030 parshiot_names <<
00031 i18n
00032 ("These are weekly readings and do not have translations. They may have different spellings in your language; otherwise, just translate the sound to your characters",
00033 "Bereshit") << i18n("Noach") << i18n("Lech L'cha") <<
00034 i18n("Vayera") << i18n("Chaye Sarah") << i18n("Toldot") <<
00035 i18n("Vayetze") << i18n("Vayishlach") << i18n("Vayeshev") <<
00036 i18n("Miketz") << i18n("Vayigash") << i18n("Vayechi") <<
00037 i18n("Shemot") << i18n("Vaera") << i18n("Bo") << i18n("Beshalach")
00038 << i18n("Yitro") << i18n("Mishpatim") << i18n("Terumah") <<
00039 i18n("Tetzaveh") << i18n("Ki Tisa") << i18n("Vayakhel") <<
00040 i18n("Pekudei") << i18n("Vayikra") << i18n("Tzav") <<
00041 i18n("Shemini") << i18n("Tazria") << i18n("Metzora") <<
00042 i18n("Acharei Mot") << i18n("Kedoshim") << i18n("Emor") <<
00043 i18n("Behar") << i18n("Bechukotai") << i18n("Bemidbar") <<
00044 i18n("Naso") << i18n("Behaalotcha") << i18n("Shelach") <<
00045 i18n("Korach") << i18n("Chukat") << i18n("Balak") <<
00046 i18n("Pinchas") << i18n("Matot") << i18n("Masei") <<
00047 i18n("Devarim") << i18n("Vaetchanan") << i18n("Ekev") <<
00048 i18n("Reeh") << i18n("Shoftim") << i18n("Ki Tetze") <<
00049 i18n("Ki Tavo") << i18n("Nitzavim") << i18n("Vayelech") <<
00050 i18n("Haazinu");
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #define XX 255
00066 static unsigned const char Sat_short[] =
00067 { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
00068 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25,
00069 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44,
00070 45, 46, 47, 48, 49, 50,
00071 };
00072
00073 static unsigned const char Sat_long[] =
00074 { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
00075 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25,
00076 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44,
00077 45, 46, 47, 48, 49, 150,
00078 };
00079
00080 static unsigned const char Mon_short[] =
00081 { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00082 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, 126,
00083 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44, 45,
00084 46, 47, 48, 49, 150,
00085 };
00086
00087 static unsigned const char Mon_long[] =
00088 { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00089 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, 126,
00090 128, 30, 131, 33, XX, 34, 35, 36, 37, 138, 40, 141, 43, 44, 45,
00091 46, 47, 48, 49, 150,
00092 };
00093
00094 #define Mon_long_Israel Mon_short
00095
00096 #define Tue_normal Mon_long
00097 #define Tue_normal_Israel Mon_short
00098
00099 static unsigned const char Thu_normal[] =
00100 { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00101 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, XX, 25,
00102 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44,
00103 45, 46, 47, 48, 49, 50,
00104 };
00105 static unsigned const char Thu_normal_Israel[] =
00106 { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00107 12, 13, 14, 15, 16, 17, 18, 19, 20, 121, 23, 24, XX, 25, 126,
00108 128, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44,
00109 45, 46, 47, 48, 49, 50,
00110 };
00111
00112 static unsigned const char Thu_long[] =
00113 { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00114 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, XX, 25,
00115 126, 128, 30, 131, 33, 34, 35, 36, 37, 38, 39, 40, 141, 43, 44,
00116 45, 46, 47, 48, 49, 50,
00117 };
00118
00119 static unsigned const char Sat_short_leap[] =
00120 { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
00121 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
00122 26, 27, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
00123 40, 141, 43, 44, 45, 46, 47, 48, 49, 150,
00124 };
00125
00126 static unsigned const char Sat_long_leap[] =
00127 { XX, 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
00128 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
00129 26, 27, XX, 28, 29, 30, 31, 32, 33, XX, 34, 35, 36, 37, 138,
00130 40, 141, 43, 44, 45, 46, 47, 48, 49, 150,
00131 };
00132
00133 #define Sat_long_leap_Israel Sat_short_leap
00134
00135 static unsigned const char Mon_short_leap[] =
00136 { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00137 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
00138 27, XX, 28, 29, 30, 31, 32, 33, XX, 34, 35, 36, 37, 138, 40,
00139 141, 43, 44, 45, 46, 47, 48, 49, 150,
00140 };
00141 static unsigned const char Mon_short_leap_Israel[] =
00142 { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00143 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
00144 27, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
00145 141, 43, 44, 45, 46, 47, 48, 49, 150,
00146 };
00147
00148 static unsigned const char Mon_long_leap[] =
00149 { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00150 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
00151 27, XX, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
00152 40, 141, 43, 44, 45, 46, 47, 48, 49, 50,
00153 };
00154 static unsigned const char Mon_long_leap_Israel[] =
00155 { 51, 52, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00156 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
00157 27, XX, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
00158 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
00159 };
00160
00161 #define Tue_normal_leap Mon_long_leap
00162 #define Tue_normal_leap_Israel Mon_long_leap_Israel
00163
00164 static unsigned const char Thu_short_leap[] =
00165 { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00166 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
00167 27, 28, XX, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
00168 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
00169 };
00170
00171 static unsigned const char Thu_long_leap[] =
00172 { 52, XX, XX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
00173 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
00174 27, 28, XX, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
00175 41, 42, 43, 44, 45, 46, 47, 48, 49, 150,
00176 };
00177
00178
00179
00180
00181
00182 int week = daynumber / 7;
00183 unsigned const char *array = NULL;
00184 int index;
00185
00186
00187
00188
00189 if (!leap_p)
00190 {
00191 switch (daynumber % 7)
00192 {
00193 case 1:
00194 if (kvia == 0)
00195 array = Sat_short;
00196 else if (kvia == 2)
00197 array = Sat_long;
00198 break;
00199 case 6:
00200 if (kvia == 0)
00201 array = Mon_short;
00202 else if (kvia == 2)
00203 array = israel_p ? Mon_long_Israel : Mon_long;
00204 break;
00205 case 5:
00206 if (kvia == 1)
00207 array = israel_p ? Tue_normal_Israel : Tue_normal;
00208 break;
00209 case 3:
00210 if (kvia == 1)
00211 array = israel_p ? Thu_normal_Israel : Thu_normal;
00212 else if (kvia == 2)
00213 array = Thu_long;
00214 break;
00215 }
00216 }
00217 else
00218 switch (daynumber % 7)
00219 {
00220 case 1:
00221 if (kvia == 0)
00222 array = Sat_short_leap;
00223 else if (kvia == 2)
00224 array = israel_p ? Sat_long_leap_Israel : Sat_long_leap;
00225 break;
00226 case 6:
00227 if (kvia == 0)
00228 array = israel_p ? Mon_short_leap_Israel : Mon_short_leap;
00229 else if (kvia == 2)
00230 array = israel_p ? Mon_long_leap_Israel : Mon_long_leap;
00231 break;
00232 case 5:
00233 if (kvia == 1)
00234 array =
00235 israel_p ? Tue_normal_leap_Israel : Tue_normal_leap;
00236 break;
00237 case 3:
00238 if (kvia == 0)
00239 array = Thu_short_leap;
00240 else if (kvia == 2)
00241 array = Thu_long_leap;
00242 break;
00243
00244 }
00245
00246 QString buffer;
00247
00248 if (array == NULL)
00249
00250 {
00251 buffer = "??Parsha??";
00252 return buffer;
00253 }
00254 index = array[week];
00255 if (index == XX)
00256 {
00257 buffer = "";
00258 return buffer;
00259 }
00260 else if (index < 100)
00261 {
00262 buffer = parshiot_names[index];
00263 return buffer;
00264 }
00265 else
00266 {
00267 buffer =
00268 parshiot_names[index - 100] + "-" + parshiot_names[index -
00269 99];
00270 return buffer;
00271
00272 }
00273 }