26 #include <KCalendarSystem>
28 class DatenumsFactory :
public DecorationFactory
37 : mDisplayedInfo( DayOfYear | DaysRemaining )
39 KConfig _config( QLatin1String(
"korganizerrc"), KConfig::NoGlobals );
40 KConfigGroup config( &_config,
"Calendar/Datenums Plugin" );
41 mDisplayedInfo = (DayNumbers)config.readEntry(
42 "DayNumbers",
int( DayOfYear | DaysRemaining ) );
53 return i18n(
"This plugin shows information on a day's position in the year." );
61 int dayOfYear = calsys->dayOfYear( date );
62 int remainingDays = calsys->daysInYear( date ) - dayOfYear;
65 switch ( mDisplayedInfo ) {
67 e =
new StoredElement( QLatin1String(
"main element"), QString::number( dayOfYear ) );
70 e =
new StoredElement( QLatin1String(
"main element"), QString::number( remainingDays ),
71 i18np(
"1 day before the end of the year",
72 "%1 days before the end of the year",
77 e =
new StoredElement( QLatin1String(
"main element"), QString::number( dayOfYear ),
78 i18nc(
"dayOfYear / daysTillEndOfYear",
"%1 / %2",
79 dayOfYear, remainingDays ),
80 i18np(
"1 day since the beginning of the year,\n",
81 "%1 days since the beginning of the year,\n",
83 i18np(
"1 day until the end of the year",
84 "%1 days until the end of the year",
101 const int weekOfYear = calsys->week( date, yearOfTheWeek );
103 QString weekOfYearShort;
104 QString weekOfYearLong;
105 QString weekOfYearExtensive;
106 QString remainingWeeksShort;
107 QString remainingWeeksLong;
108 QString remainingWeeksExtensive;
109 QString weekOfYearAndRemainingWeeksShort;
112 remainingWeeks = calsys->weeksInYear( date.year() ) - weekOfYear;
114 weekOfYearShort = QString::number( weekOfYear );
115 weekOfYearLong = i18nc(
"Week weekOfYear",
"Week %1", weekOfYear );
116 weekOfYearExtensive = i18np(
"1 week since the beginning of the year",
117 "%1 weeks since the beginning of the year",
120 if ( yearOfTheWeek ) {
122 weekOfYearShort = i18nc(
"weekOfYear (year)",
123 "%1 (%2)", weekOfYear, *yearOfTheWeek );
124 weekOfYearLong = i18nc(
"Week weekOfYear (year)",
125 "Week %1 (%2)", weekOfYear, *yearOfTheWeek );
127 if ( *yearOfTheWeek == date.year() + 1 ) {
131 weekOfYearExtensive = i18np(
"1 week since the beginning of the year",
132 "%1 weeks since the beginning of the year",
137 remainingWeeks = calsys->weeksInYear( date.year() );
139 weekOfYearExtensive = i18np(
"1 week since the beginning of the year",
140 "%1 weeks since the beginning of the year",
145 remainingWeeksShort = QString::number( remainingWeeks );
146 remainingWeeksShort = i18np(
"1 week remaining",
147 "%1 weeks remaining",
149 remainingWeeksExtensive = i18np(
"1 week until the end of the year",
150 "%1 weeks until the end of the year",
152 weekOfYearAndRemainingWeeksShort = i18nc(
"weekOfYear / weeksTillEndOfYear",
153 "%1 / %2", weekOfYear,
157 switch ( mDisplayedInfo ) {
159 e =
new StoredElement( QLatin1String(
"main element"), weekOfYearShort, weekOfYearLong,
160 weekOfYearExtensive );
163 e =
new StoredElement( QLatin1String(
"main element"), remainingWeeksShort,
164 remainingWeeksLong, remainingWeeksExtensive );
168 e =
new StoredElement( QLatin1String(
"main element"), weekOfYearShort,
169 weekOfYearAndRemainingWeeksShort,
170 i18nc(
"n weeks since the beginning of the year\n"
171 "n weeks until the end of the year",
172 "%1\n%2", weekOfYearExtensive,
173 remainingWeeksExtensive ) );
Element::List createDayElements(const QDate &)
Element::List createWeekElements(const QDate &)
const KCalendarSystem * calendarSystem() const
static KOGlobals * self()
K_EXPORT_PLUGIN(KOrganizerFactory(createAboutData())) KOrganizerPart
void configure(QWidget *parent)