29 #include "incidence.h"
33 Compat *CompatFactory::createCompat(
const TQString &productId )
40 int korg = productId.find(
"KOrganizer" );
41 int outl9 = productId.find(
"Outlook 9.0" );
46 int versionStart = productId.find(
" ", korg );
47 if ( versionStart >= 0 ) {
48 int versionStop = productId.find( TQRegExp(
"[ /]" ), versionStart + 1 );
49 if ( versionStop >= 0 ) {
50 TQString version = productId.mid( versionStart + 1,
51 versionStop - versionStart - 1 );
54 int versionNum = version.section(
".", 0, 0 ).toInt() * 10000 +
55 version.section(
".", 1, 1 ).toInt() * 100 +
56 version.section(
".", 2, 2 ).toInt();
57 int releaseStop = productId.find(
"/", versionStop );
59 if ( releaseStop > versionStop ) {
60 release = productId.mid( versionStop+1, releaseStop-versionStop-1 );
66 if ( versionNum < 30100 ) {
67 compat =
new CompatPre31;
68 }
else if ( versionNum < 30200 ) {
69 compat =
new CompatPre32;
70 }
else if ( versionNum == 30200 && release ==
"pre" ) {
71 kdDebug(5800) <<
"Generating compat for KOrganizer 3.2 pre " << endl;
72 compat =
new Compat32PrereleaseVersions;
73 }
else if ( versionNum < 30400 ) {
74 compat =
new CompatPre34;
75 }
else if ( versionNum < 30500 ) {
76 compat =
new CompatPre35;
80 }
else if ( outl9 >= 0 ) {
81 kdDebug(5800) <<
"Generating compat for Outlook < 2000 (Outlook 9.0)" << endl;
82 compat =
new CompatOutlook9;
85 if ( !compat ) compat =
new Compat;
90 void Compat::fixEmptySummary(
Incidence *incidence )
96 if (incidence->
summary().isEmpty() &&
98 TQString oldDescription = incidence->
description().stripWhiteSpace();
99 TQString newSummary( oldDescription );
100 newSummary.remove( TQRegExp(
"\n.*") );
102 if ( oldDescription == newSummary )
107 void Compat::fixRecurrence(
Incidence * )
118 void CompatPre35::fixRecurrence(
Incidence *incidence )
122 TQDateTime start( incidence->
dtStart() );
126 recurrence->addExDateTime( start );
131 Compat::fixRecurrence( incidence );
134 int CompatPre34::fixPriority(
int prio )
136 if ( 0<prio && prio<6 ) {
146 void CompatPre32::fixRecurrence(
Incidence *incidence )
153 CompatPre35::fixRecurrence( incidence );
167 void CompatPre31::fixFloatingEnd( TQDate &endDate )
169 endDate = endDate.addDays( 1 );
172 void CompatPre31::fixRecurrence(
Incidence *incidence )
174 CompatPre32::fixRecurrence( incidence );
178 if ( recur ) r = recur->defaultRRule();
181 if ( duration > 0 ) {
187 TQDate end( r->
startDt().date() );
188 bool doNothing =
false;
190 int tmp = ( duration - 1 ) * r->
frequency();
191 switch ( r->recurrenceType() ) {
192 case RecurrenceRule::rWeekly: {
193 end = end.addDays( tmp * 7 + 7 - end.dayOfWeek() );
195 case RecurrenceRule::rMonthly: {
196 int month = end.month() - 1 + tmp;
197 end.setYMD( end.year() + month / 12, month % 12 + 1, 31 );
199 case RecurrenceRule::rYearly: {
200 end.setYMD( end.year() + tmp, 12, 31);
207 duration = r->
durationTo( TQDateTime( end, TQTime( 0, 0, 0 ) ) );
215 TQValueList<int> days = r->byYearDays();
216 if ( !days.isEmpty() ) {
217 TQValueList<int> months = r->byMonths();
218 for ( TQValueListConstIterator<int> it = days.begin(); it != days.end(); ++it ) {
219 int newmonth = TQDate( r->
startDt().date().year(), 1, 1).addDays( (*it) - 1 ).month();
220 if ( !months.contains( newmonth ) )
221 months.append( newmonth );
223 r->setByMonths( months );
225 r->setByYearDays( days );
235 void CompatOutlook9::fixAlarms(
Incidence *incidence )
237 if ( !incidence )
return;
239 Alarm::List::Iterator it;
240 for ( it = alarms.begin(); it != alarms.end(); ++it ) {
This class represents an alarm notification.
bool hasStartOffset() const
Return whether the alarm is defined in terms of an offset relative to the start of the event.
Duration startOffset() const
Return offset of alarm in time relative to the start of the event.
void setStartOffset(const Duration &)
Set offset of alarm in time relative to the start of the event.
This class provides compatibility to older (broken) versions of KOrganizer.
This class represents a duration.
int asSeconds() const
Returns the length of the duration in seconds.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
This class provides the base class common to all calendar components.
const Alarm::List & alarms() const
All alarms that are associated with this incidence.
void setSummary(const TQString &summary)
Set short summary.
TQString description() const
Return long description.
void setDescription(const TQString &description)
Set the long description.
TQString summary() const
Return short summary.
Recurrence * recurrence() const
Return the recurrence rule associated with this incidence.
This class represents a recurrence rule for a calendar incidence.
void setDuration(int duration)
Sets the total number of times the event is to occur, including both the first and last.
int durationTo(const TQDateTime &) const
Returns the number of recurrences up to and including the date/time specified.
TQDateTime startDt() const
Return the start of the recurrence.
uint frequency() const
Returns frequency of recurrence, in terms of the recurrence time period type.
int duration() const
Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of re...
bool dateMatchesRules(const TQDateTime &qdt) const
Returns true if the date matches the rules.
This class represents a recurrence rule for a calendar incidence.
bool doesRecur() const
Returns whether the event recurs at all.
int duration() const
Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of re...
void setDuration(int duration)
Sets the total number of times the event is to occur, including both the first and last.
Namespace KCal is for global classes, objects and/or functions in libkcal.