<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> <head> <title>libkcal: recurrencerule.cpp Source File (libkcal)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org" r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org" r (n 0 s 0 v 0 l 0))' /> <meta name="trademark" content="KDE e.V." /> <meta name="description" content="K Desktop Environment Homepage, KDE.org" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="robots" content="all" /> <link rel="shortcut icon" href="../../favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" /> <style type="text/css"> <!-- hr { display: none; } #content h2 { margin-left: 0px; } table.mdTable { background-color: #f8f8f8; border: .2em solid #d7d7d7; } td.mdRow { padding: 8px 20px; } td.md { font-weight: bold; } td.mdname1 { font-weight: bold; color: #602020; } td.mdname { font-weight: bold; color: #602020; } --> </style> </head> <body> <div id="nav_header_top" align="right"> <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a> <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a> <span class="doNotDisplay">::</span> <img id="nav_header_logo_right" alt="" align="right" src="../../pimlogo.png" border="0" /> <div id="nav_header_title" align="left">KDE PIM API Reference</div> </div> <div id="nav_header_bottom" align="right"> <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span> <div id="nav_header_bottom_left" style="text-align: left;"> / <a href="../../">API Reference</a> / <a href=".">libkcal</a> </div> </div> <table id="main" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" class="menuheader" height="0"></td> <td id="contentcolumn" valign="top" rowspan="2" > <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;"> <h2><a name="content"></a>libkcal</h2> <!-- Generated by Doxygen 1.5.5 --> <h1>recurrencerule.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> This file is part of libkcal.</span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> Copyright (c) 2005 Reinhold Kainhofer <reinhold@kainhofe.com></span> <a name="l00005"></a>00005 <span class="comment"></span> <a name="l00006"></a>00006 <span class="comment"></span> <a name="l00007"></a>00007 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00008"></a>00008 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00009"></a>00009 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00010"></a>00010 <span class="comment"> version 2 of the License, or (at your option) any later version.</span> <a name="l00011"></a>00011 <span class="comment"></span> <a name="l00012"></a>00012 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00013"></a>00013 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00014"></a>00014 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00015"></a>00015 <span class="comment"> Library General Public License for more details.</span> <a name="l00016"></a>00016 <span class="comment"></span> <a name="l00017"></a>00017 <span class="comment"> You should have received a copy of the GNU Library General Public License</span> <a name="l00018"></a>00018 <span class="comment"> along with this library; see the file COPYING.LIB. If not, write to</span> <a name="l00019"></a>00019 <span class="comment"> the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span> <a name="l00020"></a>00020 <span class="comment"> Boston, MA 02110-1301, USA.</span> <a name="l00021"></a>00021 <span class="comment">*/</span> <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="preprocessor">#include "recurrencerule.h"</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#include <kdebug.h></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <kglobal.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <qdatetime.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <qstringlist.h></span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="preprocessor">#include <limits.h></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <math.h></span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="keyword">using namespace </span>KCal; <a name="l00034"></a>00034 <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="comment">// FIXME: If Qt is ever changed so that QDateTime:::addSecs takes into account</span> <a name="l00037"></a>00037 <span class="comment">// DST shifts, we need to use our own addSecs method, too, since we</span> <a name="l00038"></a>00038 <span class="comment">// need to caalculate things in UTC!</span> <a name="l00058"></a>00058 <span class="comment"></span><span class="keywordtype">long</span> <span class="keywordtype">long</span> ownSecsTo( <span class="keyword">const</span> QDateTime &dt1, <span class="keyword">const</span> QDateTime &dt2 ) <a name="l00059"></a>00059 { <a name="l00060"></a>00060 <span class="keywordtype">long</span> <span class="keywordtype">long</span> res = <span class="keyword">static_cast<</span><span class="keywordtype">long</span> <span class="keywordtype">long</span><span class="keyword">></span>( dt1.date().daysTo( dt2.date() ) ) * 24*3600; <a name="l00061"></a>00061 res += dt1.time().secsTo( dt2.time() ); <a name="l00062"></a>00062 <span class="keywordflow">return</span> res; <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <a name="l00065"></a>00065 <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="comment">/**************************************************************************</span> <a name="l00068"></a>00068 <span class="comment"> * DateHelper *</span> <a name="l00069"></a>00069 <span class="comment"> **************************************************************************/</span> <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="keyword">class </span>DateHelper { <a name="l00073"></a>00073 <span class="keyword">public</span>: <a name="l00074"></a>00074 <span class="preprocessor">#ifndef NDEBUG</span> <a name="l00075"></a>00075 <span class="preprocessor"></span> <span class="keyword">static</span> QString dayName( <span class="keywordtype">short</span> day ); <a name="l00076"></a>00076 <span class="preprocessor">#endif</span> <a name="l00077"></a>00077 <span class="preprocessor"></span> <span class="keyword">static</span> QDate getNthWeek( <span class="keywordtype">int</span> year, <span class="keywordtype">int</span> weeknumber, <span class="keywordtype">short</span> weekstart = 1 ); <a name="l00078"></a>00078 <span class="keyword">static</span> <span class="keywordtype">int</span> weekNumbersInYear( <span class="keywordtype">int</span> year, <span class="keywordtype">short</span> weekstart = 1 ); <a name="l00079"></a>00079 <span class="keyword">static</span> <span class="keywordtype">int</span> getWeekNumber( <span class="keyword">const</span> QDate &date, <span class="keywordtype">short</span> weekstart, <span class="keywordtype">int</span> *year = 0 ); <a name="l00080"></a>00080 <span class="keyword">static</span> <span class="keywordtype">int</span> getWeekNumberNeg( <span class="keyword">const</span> QDate &date, <span class="keywordtype">short</span> weekstart, <span class="keywordtype">int</span> *year = 0 ); <a name="l00081"></a>00081 }; <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a name="l00084"></a>00084 <span class="preprocessor">#ifndef NDEBUG</span> <a name="l00085"></a>00085 <span class="preprocessor"></span>QString DateHelper::dayName( <span class="keywordtype">short</span> day ) <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <span class="keywordflow">switch</span> ( day ) { <a name="l00088"></a>00088 <span class="keywordflow">case</span> 1: <span class="keywordflow">return</span> <span class="stringliteral">"MO"</span>; <span class="keywordflow">break</span>; <a name="l00089"></a>00089 <span class="keywordflow">case</span> 2: <span class="keywordflow">return</span> <span class="stringliteral">"TU"</span>; <span class="keywordflow">break</span>; <a name="l00090"></a>00090 <span class="keywordflow">case</span> 3: <span class="keywordflow">return</span> <span class="stringliteral">"WE"</span>; <span class="keywordflow">break</span>; <a name="l00091"></a>00091 <span class="keywordflow">case</span> 4: <span class="keywordflow">return</span> <span class="stringliteral">"TH"</span>; <span class="keywordflow">break</span>; <a name="l00092"></a>00092 <span class="keywordflow">case</span> 5: <span class="keywordflow">return</span> <span class="stringliteral">"FR"</span>; <span class="keywordflow">break</span>; <a name="l00093"></a>00093 <span class="keywordflow">case</span> 6: <span class="keywordflow">return</span> <span class="stringliteral">"SA"</span>; <span class="keywordflow">break</span>; <a name="l00094"></a>00094 <span class="keywordflow">case</span> 7: <span class="keywordflow">return</span> <span class="stringliteral">"SU"</span>; <span class="keywordflow">break</span>; <a name="l00095"></a>00095 <span class="keywordflow">default</span>: <span class="keywordflow">return</span> <span class="stringliteral">"??"</span>; <a name="l00096"></a>00096 } <a name="l00097"></a>00097 } <a name="l00098"></a>00098 <span class="preprocessor">#endif</span> <a name="l00099"></a>00099 <span class="preprocessor"></span> <a name="l00100"></a>00100 <a name="l00101"></a>00101 QDate DateHelper::getNthWeek( <span class="keywordtype">int</span> year, <span class="keywordtype">int</span> weeknumber, <span class="keywordtype">short</span> weekstart ) <a name="l00102"></a>00102 { <a name="l00103"></a>00103 <span class="keywordflow">if</span> ( weeknumber == 0 ) <span class="keywordflow">return</span> QDate(); <a name="l00104"></a>00104 <span class="comment">// Adjust this to the first day of week #1 of the year and add 7*weekno days.</span> <a name="l00105"></a>00105 QDate dt( year, 1, 4 ); <span class="comment">// Week #1 is the week that contains Jan 4</span> <a name="l00106"></a>00106 <span class="keywordtype">int</span> adjust = -(7 + dt.dayOfWeek() - weekstart) % 7; <a name="l00107"></a>00107 <span class="keywordflow">if</span> ( weeknumber > 0 ) { <a name="l00108"></a>00108 dt = dt.addDays( 7 * (weeknumber-1) + adjust ); <a name="l00109"></a>00109 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( weeknumber < 0 ) { <a name="l00110"></a>00110 dt = dt.addYears( 1 ); <a name="l00111"></a>00111 dt = dt.addDays( 7 * weeknumber + adjust ); <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <span class="keywordflow">return</span> dt; <a name="l00114"></a>00114 } <a name="l00115"></a>00115 <a name="l00116"></a>00116 <a name="l00117"></a>00117 <span class="keywordtype">int</span> DateHelper::getWeekNumber( <span class="keyword">const</span> QDate &date, <span class="keywordtype">short</span> weekstart, <span class="keywordtype">int</span> *year ) <a name="l00118"></a>00118 { <a name="l00119"></a>00119 <span class="comment">// kdDebug(5800) << "Getting week number for " << date << " with weekstart="<<weekstart<<endl;</span> <a name="l00120"></a>00120 <span class="keywordflow">if</span> ( year ) *year = date.year(); <a name="l00121"></a>00121 QDate dt( date.year(), 1, 4 ); <span class="comment">// <= definitely in week #1</span> <a name="l00122"></a>00122 dt = dt.addDays( -(7 + dt.dayOfWeek() - weekstart) % 7 ); <span class="comment">// begin of week #1</span> <a name="l00123"></a>00123 QDate dtn( date.year()+1, 1, 4 ); <span class="comment">// <= definitely first week of next year</span> <a name="l00124"></a>00124 dtn = dtn.addDays( -(7 + dtn.dayOfWeek() - weekstart) % 7 ); <a name="l00125"></a>00125 <a name="l00126"></a>00126 <span class="keywordtype">int</span> daysto = dt.daysTo( date ); <a name="l00127"></a>00127 <span class="keywordtype">int</span> dayston = dtn.daysTo( date ); <a name="l00128"></a>00128 <span class="keywordflow">if</span> ( daysto < 0 ) { <a name="l00129"></a>00129 <span class="keywordflow">if</span> ( year ) *year = date.year()-1; <a name="l00130"></a>00130 dt = QDate( date.year()-1, 1, 4 ); <a name="l00131"></a>00131 dt = dt.addDays( -(7 + dt.dayOfWeek() - weekstart) % 7 ); <span class="comment">// begin of week #1</span> <a name="l00132"></a>00132 daysto = dt.daysTo( date ); <a name="l00133"></a>00133 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( dayston >= 0 ) { <a name="l00134"></a>00134 <span class="comment">// in first week of next year;</span> <a name="l00135"></a>00135 <span class="keywordflow">if</span> ( year ) *year = date.year() + 1; <a name="l00136"></a>00136 dt = dtn; <a name="l00137"></a>00137 daysto = dayston; <a name="l00138"></a>00138 } <a name="l00139"></a>00139 <span class="keywordflow">return</span> daysto / 7 + 1; <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="keywordtype">int</span> DateHelper::weekNumbersInYear( <span class="keywordtype">int</span> year, <span class="keywordtype">short</span> weekstart ) <a name="l00143"></a>00143 { <a name="l00144"></a>00144 QDate dt( year, 1, weekstart ); <a name="l00145"></a>00145 QDate dt1( year + 1, 1, weekstart ); <a name="l00146"></a>00146 <span class="keywordflow">return</span> dt.daysTo( dt1 ) / 7; <a name="l00147"></a>00147 } <a name="l00148"></a>00148 <a name="l00149"></a>00149 <span class="comment">// Week number from the end of the year</span> <a name="l00150"></a>00150 <span class="keywordtype">int</span> DateHelper::getWeekNumberNeg( <span class="keyword">const</span> QDate &date, <span class="keywordtype">short</span> weekstart, <span class="keywordtype">int</span> *year ) <a name="l00151"></a>00151 { <a name="l00152"></a>00152 <span class="keywordtype">int</span> weekpos = getWeekNumber( date, weekstart, year ); <a name="l00153"></a>00153 <span class="keywordflow">return</span> weekNumbersInYear( *year, weekstart ) - weekpos - 1; <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a>00156 <a name="l00157"></a>00157 <a name="l00158"></a>00158 <a name="l00159"></a>00159 <a name="l00160"></a>00160 <span class="comment">/**************************************************************************</span> <a name="l00161"></a>00161 <span class="comment"> * RecurrenceRule::Constraint *</span> <a name="l00162"></a>00162 <span class="comment"> **************************************************************************/</span> <a name="l00163"></a>00163 <a name="l00164"></a>00164 <a name="l00165"></a>00165 RecurrenceRule::Constraint::Constraint( <span class="keywordtype">int</span> wkst ) <a name="l00166"></a>00166 { <a name="l00167"></a>00167 weekstart = wkst; <a name="l00168"></a>00168 <a class="code" href="classKCal_1_1Recurrence.html#c7ac3073c65bf590a97c87ed53301655" title="Removes all recurrence and exception rules and dates.">clear</a>(); <a name="l00169"></a>00169 } <a name="l00170"></a>00170 <a name="l00171"></a>00171 RecurrenceRule::Constraint::Constraint( <span class="keyword">const</span> QDateTime &preDate, PeriodType type, <span class="keywordtype">int</span> wkst ) <a name="l00172"></a>00172 { <a name="l00173"></a>00173 weekstart = wkst; <a name="l00174"></a>00174 readDateTime( preDate, type ); <a name="l00175"></a>00175 } <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="keywordtype">void</span> RecurrenceRule::Constraint::clear() <a name="l00178"></a>00178 { <a name="l00179"></a>00179 year = 0; <a name="l00180"></a>00180 month = 0; <a name="l00181"></a>00181 day = 0; <a name="l00182"></a>00182 hour = -1; <a name="l00183"></a>00183 minute = -1; <a name="l00184"></a>00184 second = -1; <a name="l00185"></a>00185 weekday = 0; <a name="l00186"></a>00186 weekdaynr = 0; <a name="l00187"></a>00187 weeknumber = 0; <a name="l00188"></a>00188 yearday = 0; <a name="l00189"></a>00189 } <a name="l00190"></a>00190 <a name="l00191"></a>00191 <span class="keywordtype">bool</span> RecurrenceRule::Constraint::matches( <span class="keyword">const</span> QDate &dt, <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">RecurrenceRule::PeriodType</a> type )<span class="keyword"> const</span> <a name="l00192"></a>00192 <span class="keyword"></span>{ <a name="l00193"></a>00193 <span class="comment">// If the event recurs in week 53 or 1, the day might not belong to the same</span> <a name="l00194"></a>00194 <span class="comment">// year as the week it is in. E.g. Jan 1, 2005 is in week 53 of year 2004.</span> <a name="l00195"></a>00195 <span class="comment">// So we can't simply check the year in that case!</span> <a name="l00196"></a>00196 <span class="keywordflow">if</span> ( weeknumber == 0 ) { <a name="l00197"></a>00197 <span class="keywordflow">if</span> ( year > 0 && year != dt.year() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00198"></a>00198 } <span class="keywordflow">else</span> { <a name="l00199"></a>00199 <span class="keywordtype">int</span> y; <a name="l00200"></a>00200 <span class="keywordflow">if</span> ( weeknumber > 0 && <a name="l00201"></a>00201 weeknumber != DateHelper::getWeekNumber( dt, weekstart, &y ) ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00202"></a>00202 <span class="keywordflow">if</span> ( weeknumber < 0 && <a name="l00203"></a>00203 weeknumber != DateHelper::getWeekNumberNeg( dt, weekstart, &y ) ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00204"></a>00204 <span class="keywordflow">if</span> ( year > 0 && year != y ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00205"></a>00205 } <a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="keywordflow">if</span> ( month > 0 && month != dt.month() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00208"></a>00208 <span class="keywordflow">if</span> ( day > 0 && day != dt.day() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00209"></a>00209 <span class="keywordflow">if</span> ( day < 0 && dt.day() != (dt.daysInMonth() + day + 1 ) ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00210"></a>00210 <span class="keywordflow">if</span> ( weekday > 0 ) { <a name="l00211"></a>00211 <span class="keywordflow">if</span> ( weekday != dt.dayOfWeek() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00212"></a>00212 <span class="keywordflow">if</span> ( weekdaynr != 0 ) { <a name="l00213"></a>00213 <span class="comment">// If it's a yearly recurrence and a month is given, the position is</span> <a name="l00214"></a>00214 <span class="comment">// still in the month, not in the year.</span> <a name="l00215"></a>00215 <span class="keywordtype">bool</span> inMonth = (type == rMonthly) || ( type == rYearly && month > 0 ); <a name="l00216"></a>00216 <span class="comment">// Monthly</span> <a name="l00217"></a>00217 <span class="keywordflow">if</span> ( weekdaynr > 0 && inMonth && <a name="l00218"></a>00218 weekdaynr != (dt.day() - 1)/7 + 1 ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00219"></a>00219 <span class="keywordflow">if</span> ( weekdaynr < 0 && inMonth && <a name="l00220"></a>00220 weekdaynr != -((dt.daysInMonth() - dt.day() )/7 + 1 ) ) <a name="l00221"></a>00221 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00222"></a>00222 <span class="comment">// Yearly</span> <a name="l00223"></a>00223 <span class="keywordflow">if</span> ( weekdaynr > 0 && !inMonth && <a name="l00224"></a>00224 weekdaynr != (dt.dayOfYear() - 1)/7 + 1 ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00225"></a>00225 <span class="keywordflow">if</span> ( weekdaynr < 0 && !inMonth && <a name="l00226"></a>00226 weekdaynr != -((dt.daysInYear() - dt.dayOfYear() )/7 + 1 ) ) <a name="l00227"></a>00227 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00228"></a>00228 } <a name="l00229"></a>00229 } <a name="l00230"></a>00230 <span class="keywordflow">if</span> ( yearday > 0 && yearday != dt.dayOfYear() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00231"></a>00231 <span class="keywordflow">if</span> ( yearday < 0 && yearday != dt.daysInYear() - dt.dayOfYear() + 1 ) <a name="l00232"></a>00232 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00233"></a>00233 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00234"></a>00234 } <a name="l00235"></a>00235 <a name="l00236"></a>00236 <span class="keywordtype">bool</span> RecurrenceRule::Constraint::matches( <span class="keyword">const</span> QDateTime &dt, <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">RecurrenceRule::PeriodType</a> type )<span class="keyword"> const</span> <a name="l00237"></a>00237 <span class="keyword"></span>{ <a name="l00238"></a>00238 <span class="keywordflow">if</span> ( !matches( dt.date(), type ) ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00239"></a>00239 <span class="keywordflow">if</span> ( hour >= 0 && hour != dt.time().hour() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00240"></a>00240 <span class="keywordflow">if</span> ( minute >= 0 && minute != dt.time().minute() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00241"></a>00241 <span class="keywordflow">if</span> ( second >= 0 && second != dt.time().second() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00242"></a>00242 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00243"></a>00243 } <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="keywordtype">bool</span> RecurrenceRule::Constraint::isConsistent( PeriodType <span class="comment">/*period*/</span>)<span class="keyword"> const</span> <a name="l00246"></a>00246 <span class="keyword"></span>{ <a name="l00247"></a>00247 <span class="comment">// TODO: Check for consistency, e.g. byyearday=3 and bymonth=10</span> <a name="l00248"></a>00248 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00249"></a>00249 } <a name="l00250"></a>00250 <a name="l00251"></a>00251 QDateTime RecurrenceRule::Constraint::intervalDateTime( <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">RecurrenceRule::PeriodType</a> type )<span class="keyword"> const</span> <a name="l00252"></a>00252 <span class="keyword"></span>{ <a name="l00253"></a>00253 QDateTime dt; <a name="l00254"></a>00254 dt.setTime( QTime( 0, 0, 0 ) ); <a name="l00255"></a>00255 dt.setDate( QDate( year, (month>0)?month:1, (day>0)?day:1 ) ); <a name="l00256"></a>00256 <span class="keywordflow">if</span> ( day < 0 ) <a name="l00257"></a>00257 dt = dt.addDays( dt.date().daysInMonth() + day ); <a name="l00258"></a>00258 <span class="keywordflow">switch</span> ( type ) { <a name="l00259"></a>00259 <span class="keywordflow">case</span> rSecondly: <a name="l00260"></a>00260 dt.setTime( QTime( hour, minute, second ) ); <span class="keywordflow">break</span>; <a name="l00261"></a>00261 <span class="keywordflow">case</span> rMinutely: <a name="l00262"></a>00262 dt.setTime( QTime( hour, minute, 1 ) ); <span class="keywordflow">break</span>; <a name="l00263"></a>00263 <span class="keywordflow">case</span> rHourly: <a name="l00264"></a>00264 dt.setTime( QTime( hour, 1, 1 ) ); <span class="keywordflow">break</span>; <a name="l00265"></a>00265 <span class="keywordflow">case</span> rDaily: <a name="l00266"></a>00266 <span class="keywordflow">break</span>; <a name="l00267"></a>00267 <span class="keywordflow">case</span> rWeekly: <a name="l00268"></a>00268 dt = DateHelper::getNthWeek( year, weeknumber, weekstart ); <span class="keywordflow">break</span>; <a name="l00269"></a>00269 <span class="keywordflow">case</span> rMonthly: <a name="l00270"></a>00270 dt.setDate( QDate( year, month, 1 ) ); <span class="keywordflow">break</span>; <a name="l00271"></a>00271 <span class="keywordflow">case</span> rYearly: <a name="l00272"></a>00272 dt.setDate( QDate( year, 1, 1 ) ); <span class="keywordflow">break</span>; <a name="l00273"></a>00273 <span class="keywordflow">default</span>: <a name="l00274"></a>00274 <span class="keywordflow">break</span>; <a name="l00275"></a>00275 } <a name="l00276"></a>00276 <span class="keywordflow">return</span> dt; <a name="l00277"></a>00277 } <a name="l00278"></a>00278 <a name="l00279"></a>00279 <a name="l00280"></a>00280 <span class="comment">// Y M D | H Mn S | WD #WD | WN | YD</span> <a name="l00281"></a>00281 <span class="comment">// required:</span> <a name="l00282"></a>00282 <span class="comment">// x | x x x | | |</span> <a name="l00283"></a>00283 <span class="comment">// 0) Trivial: Exact date given, maybe other restrictions</span> <a name="l00284"></a>00284 <span class="comment">// x x x | x x x | | |</span> <a name="l00285"></a>00285 <span class="comment">// 1) Easy case: no weekly restrictions -> at most a loop through possible dates</span> <a name="l00286"></a>00286 <span class="comment">// x + + | x x x | - - | - | -</span> <a name="l00287"></a>00287 <span class="comment">// 2) Year day is given -> date known</span> <a name="l00288"></a>00288 <span class="comment">// x | x x x | | | +</span> <a name="l00289"></a>00289 <span class="comment">// 3) week number is given -> loop through all days of that week. Further</span> <a name="l00290"></a>00290 <span class="comment">// restrictions will be applied in the end, when we check all dates for</span> <a name="l00291"></a>00291 <span class="comment">// consistency with the constraints</span> <a name="l00292"></a>00292 <span class="comment">// x | x x x | | + | (-)</span> <a name="l00293"></a>00293 <span class="comment">// 4) week day is specified -></span> <a name="l00294"></a>00294 <span class="comment">// x | x x x | x ? | (-)| (-)</span> <a name="l00295"></a>00295 <span class="comment">// 5) All possiblecases have already been treated, so this must be an error!</span> <a name="l00296"></a>00296 <a name="l00297"></a>00297 DateTimeList RecurrenceRule::Constraint::dateTimes( <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">RecurrenceRule::PeriodType</a> type )<span class="keyword"> const</span> <a name="l00298"></a>00298 <span class="keyword"></span>{ <a name="l00299"></a>00299 <span class="comment">// kdDebug(5800) << " RecurrenceRule::Constraint::dateTimes: " << endl;</span> <a name="l00300"></a>00300 DateTimeList result; <a name="l00301"></a>00301 <span class="keywordtype">bool</span> done = <span class="keyword">false</span>; <a name="l00302"></a>00302 <span class="comment">// TODO_Recurrence: Handle floating</span> <a name="l00303"></a>00303 QTime tm( hour, minute, second ); <a name="l00304"></a>00304 <span class="keywordflow">if</span> ( !isConsistent( type ) ) <span class="keywordflow">return</span> result; <a name="l00305"></a>00305 <a name="l00306"></a>00306 <span class="keywordflow">if</span> ( !done && day > 0 && month > 0 ) { <a name="l00307"></a>00307 QDateTime dt( QDate( year, month, day ), tm ); <a name="l00308"></a>00308 <span class="keywordflow">if</span> ( dt.isValid() ) result.append( dt ); <a name="l00309"></a>00309 done = <span class="keyword">true</span>; <a name="l00310"></a>00310 } <a name="l00311"></a>00311 <span class="keywordflow">if</span> ( !done && day < 0 && month > 0 ) { <a name="l00312"></a>00312 QDateTime dt( QDate( year, month, 1 ), tm ); <a name="l00313"></a>00313 dt = dt.addDays( dt.date().daysInMonth() + day ); <a name="l00314"></a>00314 <span class="keywordflow">if</span> ( dt.isValid() ) result.append( dt ); <a name="l00315"></a>00315 done = <span class="keyword">true</span>; <a name="l00316"></a>00316 } <a name="l00317"></a>00317 <a name="l00318"></a>00318 <a name="l00319"></a>00319 <span class="keywordflow">if</span> ( !done && weekday == 0 && weeknumber == 0 && yearday == 0 ) { <a name="l00320"></a>00320 <span class="comment">// Easy case: date is given, not restrictions by week or yearday</span> <a name="l00321"></a>00321 uint mstart = (month>0) ? month : 1; <a name="l00322"></a>00322 uint mend = (month <= 0) ? 12 : month; <a name="l00323"></a>00323 <span class="keywordflow">for</span> ( uint m = mstart; m <= mend; ++m ) { <a name="l00324"></a>00324 uint dstart, dend; <a name="l00325"></a>00325 <span class="keywordflow">if</span> ( day > 0 ) { <a name="l00326"></a>00326 dstart = dend = day; <a name="l00327"></a>00327 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( day < 0 ) { <a name="l00328"></a>00328 QDate date( year, month, 1 ); <a name="l00329"></a>00329 dstart = dend = date.daysInMonth() + day + 1; <a name="l00330"></a>00330 } <span class="keywordflow">else</span> { <a name="l00331"></a>00331 QDate date( year, month, 1 ); <a name="l00332"></a>00332 dstart = 1; <a name="l00333"></a>00333 dend = date.daysInMonth(); <a name="l00334"></a>00334 } <a name="l00335"></a>00335 <span class="keywordflow">for</span> ( uint d = dstart; d <= dend; ++d ) { <a name="l00336"></a>00336 QDateTime dt( QDate( year, m, d ), tm ); <a name="l00337"></a>00337 <span class="keywordflow">if</span> ( dt.isValid() ) result.append( dt ); <a name="l00338"></a>00338 } <a name="l00339"></a>00339 } <a name="l00340"></a>00340 done = <span class="keyword">true</span>; <a name="l00341"></a>00341 } <a name="l00342"></a>00342 <a name="l00343"></a>00343 <span class="comment">// Else: At least one of the week / yearday restrictions was given...</span> <a name="l00344"></a>00344 <span class="comment">// If we have a yearday (and of course a year), we know the exact date</span> <a name="l00345"></a>00345 <span class="keywordflow">if</span> ( !done && yearday != 0 ) { <a name="l00346"></a>00346 <span class="comment">// yearday < 0 means from end of year, so we'll need Jan 1 of the next year</span> <a name="l00347"></a>00347 QDate d( year + ((yearday>0)?0:1), 1, 1 ); <a name="l00348"></a>00348 d = d.addDays( yearday - ((yearday>0)?1:0) ); <a name="l00349"></a>00349 result.append( QDateTime( d, tm ) ); <a name="l00350"></a>00350 done = <span class="keyword">true</span>; <a name="l00351"></a>00351 } <a name="l00352"></a>00352 <a name="l00353"></a>00353 <span class="comment">// Else: If we have a weeknumber, we have at most 7 possible dates, loop through them</span> <a name="l00354"></a>00354 <span class="keywordflow">if</span> ( !done && weeknumber != 0 ) { <a name="l00355"></a>00355 QDate wst( DateHelper::getNthWeek( year, weeknumber, weekstart ) ); <a name="l00356"></a>00356 <span class="keywordflow">if</span> ( weekday != 0 ) { <a name="l00357"></a>00357 wst = wst.addDays( (7 + weekday - weekstart ) % 7 ); <a name="l00358"></a>00358 result.append( QDateTime( wst, tm ) ); <a name="l00359"></a>00359 } <span class="keywordflow">else</span> { <a name="l00360"></a>00360 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < 7; ++i ) { <a name="l00361"></a>00361 result.append( QDateTime( wst, tm ) ); <a name="l00362"></a>00362 wst = wst.addDays( 1 ); <a name="l00363"></a>00363 } <a name="l00364"></a>00364 } <a name="l00365"></a>00365 done = <span class="keyword">true</span>; <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <a name="l00368"></a>00368 <span class="comment">// weekday is given</span> <a name="l00369"></a>00369 <span class="keywordflow">if</span> ( !done && weekday != 0 ) { <a name="l00370"></a>00370 QDate dt( year, 1, 1 ); <a name="l00371"></a>00371 <span class="comment">// If type == yearly and month is given, pos is still in month not year!</span> <a name="l00372"></a>00372 <span class="comment">// TODO_Recurrence: Correct handling of n-th BYDAY...</span> <a name="l00373"></a>00373 <span class="keywordtype">int</span> maxloop = 53; <a name="l00374"></a>00374 <span class="keywordtype">bool</span> inMonth = ( type == rMonthly) || ( type == rYearly && month > 0 ); <a name="l00375"></a>00375 <span class="keywordflow">if</span> ( inMonth && month > 0 ) { <a name="l00376"></a>00376 dt = QDate( year, month, 1 ); <a name="l00377"></a>00377 maxloop = 5; <a name="l00378"></a>00378 } <a name="l00379"></a>00379 <span class="keywordflow">if</span> ( weekdaynr < 0 ) { <a name="l00380"></a>00380 <span class="comment">// From end of period (month, year) => relative to begin of next period</span> <a name="l00381"></a>00381 <span class="keywordflow">if</span> ( inMonth ) <a name="l00382"></a>00382 dt = dt.addMonths( 1 ); <a name="l00383"></a>00383 <span class="keywordflow">else</span> <a name="l00384"></a>00384 dt = dt.addYears( 1 ); <a name="l00385"></a>00385 } <a name="l00386"></a>00386 <span class="keywordtype">int</span> adj = ( 7 + weekday - dt.dayOfWeek() ) % 7; <a name="l00387"></a>00387 dt = dt.addDays( adj ); <span class="comment">// correct first weekday of the period</span> <a name="l00388"></a>00388 <a name="l00389"></a>00389 <span class="keywordflow">if</span> ( weekdaynr > 0 ) { <a name="l00390"></a>00390 dt = dt.addDays( ( weekdaynr - 1 ) * 7 ); <a name="l00391"></a>00391 result.append( QDateTime( dt, tm ) ); <a name="l00392"></a>00392 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( weekdaynr < 0 ) { <a name="l00393"></a>00393 dt = dt.addDays( weekdaynr * 7 ); <a name="l00394"></a>00394 result.append( QDateTime( dt, tm ) ); <a name="l00395"></a>00395 } <span class="keywordflow">else</span> { <a name="l00396"></a>00396 <span class="comment">// loop through all possible weeks, non-matching will be filtered later</span> <a name="l00397"></a>00397 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < maxloop; ++i ) { <a name="l00398"></a>00398 result.append( QDateTime( dt, tm ) ); <a name="l00399"></a>00399 dt = dt.addDays( 7 ); <a name="l00400"></a>00400 } <a name="l00401"></a>00401 } <a name="l00402"></a>00402 } <span class="comment">// weekday != 0</span> <a name="l00403"></a>00403 <a name="l00404"></a>00404 <a name="l00405"></a>00405 <span class="comment">// Only use those times that really match all other constraints, too</span> <a name="l00406"></a>00406 DateTimeList valid; <a name="l00407"></a>00407 DateTimeList::Iterator it; <a name="l00408"></a>00408 <span class="keywordflow">for</span> ( it = result.begin(); it != result.end(); ++it ) { <a name="l00409"></a>00409 <span class="keywordflow">if</span> ( matches( *it, type ) ) valid.append( *it ); <a name="l00410"></a>00410 } <a name="l00411"></a>00411 <span class="comment">// Don't sort it here, would be unnecessary work. The results from all</span> <a name="l00412"></a>00412 <span class="comment">// constraints will be merged to one big list of the interval. Sort that one!</span> <a name="l00413"></a>00413 <span class="keywordflow">return</span> valid; <a name="l00414"></a>00414 } <a name="l00415"></a>00415 <a name="l00416"></a>00416 <a name="l00417"></a>00417 <span class="keywordtype">bool</span> RecurrenceRule::Constraint::increase( <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">RecurrenceRule::PeriodType</a> type, <span class="keywordtype">int</span> freq ) <a name="l00418"></a>00418 { <a name="l00419"></a>00419 <span class="comment">// convert the first day of the interval to QDateTime</span> <a name="l00420"></a>00420 <span class="comment">// Sub-daily types need to be converted to UTC to correctly handle DST shifts</span> <a name="l00421"></a>00421 QDateTime dt( intervalDateTime( type ) ); <a name="l00422"></a>00422 <a name="l00423"></a>00423 <span class="comment">// Now add the intervals</span> <a name="l00424"></a>00424 <span class="keywordflow">switch</span> ( type ) { <a name="l00425"></a>00425 <span class="keywordflow">case</span> rSecondly: <a name="l00426"></a>00426 dt = dt.addSecs( freq ); <span class="keywordflow">break</span>; <a name="l00427"></a>00427 <span class="keywordflow">case</span> rMinutely: <a name="l00428"></a>00428 dt = dt.addSecs( 60*freq ); <span class="keywordflow">break</span>; <a name="l00429"></a>00429 <span class="keywordflow">case</span> rHourly: <a name="l00430"></a>00430 dt = dt.addSecs( 3600 * freq ); <span class="keywordflow">break</span>; <a name="l00431"></a>00431 <span class="keywordflow">case</span> rDaily: <a name="l00432"></a>00432 dt = dt.addDays( freq ); <span class="keywordflow">break</span>; <a name="l00433"></a>00433 <span class="keywordflow">case</span> rWeekly: <a name="l00434"></a>00434 dt = dt.addDays( 7*freq ); <span class="keywordflow">break</span>; <a name="l00435"></a>00435 <span class="keywordflow">case</span> rMonthly: <a name="l00436"></a>00436 dt = dt.addMonths( freq ); <span class="keywordflow">break</span>; <a name="l00437"></a>00437 <span class="keywordflow">case</span> rYearly: <a name="l00438"></a>00438 dt = dt.addYears( freq ); <span class="keywordflow">break</span>; <a name="l00439"></a>00439 <span class="keywordflow">default</span>: <a name="l00440"></a>00440 <span class="keywordflow">break</span>; <a name="l00441"></a>00441 } <a name="l00442"></a>00442 <span class="comment">// Convert back from QDateTime to the Constraint class</span> <a name="l00443"></a>00443 readDateTime( dt, type ); <a name="l00444"></a>00444 <a name="l00445"></a>00445 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00446"></a>00446 } <a name="l00447"></a>00447 <a name="l00448"></a>00448 <span class="keywordtype">bool</span> RecurrenceRule::Constraint::readDateTime( <span class="keyword">const</span> QDateTime &preDate, PeriodType type ) <a name="l00449"></a>00449 { <a name="l00450"></a>00450 <a class="code" href="classKCal_1_1Recurrence.html#c7ac3073c65bf590a97c87ed53301655" title="Removes all recurrence and exception rules and dates.">clear</a>(); <a name="l00451"></a>00451 <span class="keywordflow">switch</span> ( type ) { <a name="l00452"></a>00452 <span class="comment">// Really fall through! Only weekly needs to be treated differentely!</span> <a name="l00453"></a>00453 <span class="keywordflow">case</span> rSecondly: <a name="l00454"></a>00454 second = preDate.time().second(); <a name="l00455"></a>00455 <span class="keywordflow">case</span> rMinutely: <a name="l00456"></a>00456 minute = preDate.time().minute(); <a name="l00457"></a>00457 <span class="keywordflow">case</span> rHourly: <a name="l00458"></a>00458 hour = preDate.time().hour(); <a name="l00459"></a>00459 <span class="keywordflow">case</span> rDaily: <a name="l00460"></a>00460 day = preDate.date().day(); <a name="l00461"></a>00461 <span class="keywordflow">case</span> rMonthly: <a name="l00462"></a>00462 month = preDate.date().month(); <a name="l00463"></a>00463 <span class="keywordflow">case</span> rYearly: <a name="l00464"></a>00464 year = preDate.date().year(); <a name="l00465"></a>00465 <span class="keywordflow">break</span>; <a name="l00466"></a>00466 <a name="l00467"></a>00467 <span class="keywordflow">case</span> rWeekly: <a name="l00468"></a>00468 <span class="comment">// Determine start day of the current week, calculate the week number from that</span> <a name="l00469"></a>00469 weeknumber = DateHelper::getWeekNumber( preDate.date(), weekstart, &year ); <a name="l00470"></a>00470 <span class="keywordflow">break</span>; <a name="l00471"></a>00471 <span class="keywordflow">default</span>: <a name="l00472"></a>00472 <span class="keywordflow">break</span>; <a name="l00473"></a>00473 } <a name="l00474"></a>00474 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00475"></a>00475 } <a name="l00476"></a>00476 <a name="l00477"></a>00477 <a name="l00478"></a>00478 RecurrenceRule::RecurrenceRule( ) <a name="l00479"></a>00479 : mPeriod( rNone ), mFrequency( 0 ), mIsReadOnly( false ), <a name="l00480"></a>00480 mFloating( false ), <a name="l00481"></a>00481 mWeekStart(1) <a name="l00482"></a>00482 { <a name="l00483"></a>00483 } <a name="l00484"></a>00484 <a name="l00485"></a>00485 RecurrenceRule::RecurrenceRule( <span class="keyword">const</span> <a class="code" href="classKCal_1_1RecurrenceRule.html" title="This class represents a recurrence rule for a calendar incidence.">RecurrenceRule</a> &r ) <a name="l00486"></a>00486 { <a name="l00487"></a>00487 mRRule = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#39931af2502c39e92b8afb0ca7bc4e93">mRRule</a>; <a name="l00488"></a>00488 mPeriod = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#1dcd8e1fbd8468282a6260048d4b56d2">mPeriod</a>; <a name="l00489"></a>00489 mDateStart = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#738678e1c53cdc828da0e52102cb1a92">mDateStart</a>; <a name="l00490"></a>00490 mDuration = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#0e417492ba7949118eac7ef2f8db9fd7" title="how often it recurs (including dtstart): -1 means infinitely, 0 means an explicit...">mDuration</a>; <a name="l00491"></a>00491 mDateEnd = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#e0a6c990cafe63f1312660865d3a9595">mDateEnd</a>; <a name="l00492"></a>00492 mFrequency = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#1df20c58b36d7dcf852687d6ceb0b3f4">mFrequency</a>; <a name="l00493"></a>00493 <a name="l00494"></a>00494 mIsReadOnly = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#d823491837d8fb0739c135f5e89af6b0">mIsReadOnly</a>; <a name="l00495"></a>00495 mFloating = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#9f20604192b3d736ceea2b827d91157c">mFloating</a>; <a name="l00496"></a>00496 <a name="l00497"></a>00497 mBySeconds = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#8c1b7b8c43928175999e8369df4a1f1a">mBySeconds</a>; <a name="l00498"></a>00498 mByMinutes = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#60bdc1ec24b53b14c1fb935ed4204514">mByMinutes</a>; <a name="l00499"></a>00499 mByHours = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#9794ade641402469559e0b588804fa45">mByHours</a>; <a name="l00500"></a>00500 mByDays = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#40f4236159232bf8a961ec09f488eab1">mByDays</a>; <a name="l00501"></a>00501 mByMonthDays = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#f9ffd938f3f6c03624e68f99ebbb2ef8">mByMonthDays</a>; <a name="l00502"></a>00502 mByYearDays = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#c444adda662a97ae97ff3342a6bd17f1">mByYearDays</a>; <a name="l00503"></a>00503 mByWeekNumbers = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#6f9f34fd08a1f4be76eab5caf56e6876">mByWeekNumbers</a>; <a name="l00504"></a>00504 mByMonths = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#3f8e61bee6d74e1f86a5820d09561286">mByMonths</a>; <a name="l00505"></a>00505 mBySetPos = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#d454ead64a65f31a92582aeb3463bb10">mBySetPos</a>; <a name="l00506"></a>00506 mWeekStart = r.<a class="code" href="classKCal_1_1RecurrenceRule.html#dd261b0c5d1039c244ed0cb4a44604f6">mWeekStart</a>; <a name="l00507"></a>00507 <a name="l00508"></a>00508 setDirty(); <a name="l00509"></a>00509 } <a name="l00510"></a>00510 <a name="l00511"></a>00511 RecurrenceRule::~RecurrenceRule() <a name="l00512"></a>00512 { <a name="l00513"></a>00513 } <a name="l00514"></a>00514 <a name="l00515"></a>00515 <span class="keywordtype">bool</span> RecurrenceRule::operator==( <span class="keyword">const</span> <a class="code" href="classKCal_1_1RecurrenceRule.html" title="This class represents a recurrence rule for a calendar incidence.">RecurrenceRule</a>& r )<span class="keyword"> const</span> <a name="l00516"></a>00516 <span class="keyword"></span>{ <a name="l00517"></a>00517 <span class="keywordflow">if</span> ( mPeriod != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#1dcd8e1fbd8468282a6260048d4b56d2">mPeriod</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00518"></a>00518 <span class="keywordflow">if</span> ( mDateStart != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#738678e1c53cdc828da0e52102cb1a92">mDateStart</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00519"></a>00519 <span class="keywordflow">if</span> ( mDuration != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#0e417492ba7949118eac7ef2f8db9fd7" title="how often it recurs (including dtstart): -1 means infinitely, 0 means an explicit...">mDuration</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00520"></a>00520 <span class="keywordflow">if</span> ( mDateEnd != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#e0a6c990cafe63f1312660865d3a9595">mDateEnd</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00521"></a>00521 <span class="keywordflow">if</span> ( mFrequency != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#1df20c58b36d7dcf852687d6ceb0b3f4">mFrequency</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00522"></a>00522 <a name="l00523"></a>00523 <span class="keywordflow">if</span> ( mIsReadOnly != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#d823491837d8fb0739c135f5e89af6b0">mIsReadOnly</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00524"></a>00524 <span class="keywordflow">if</span> ( mFloating != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#9f20604192b3d736ceea2b827d91157c">mFloating</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00525"></a>00525 <a name="l00526"></a>00526 <span class="keywordflow">if</span> ( mBySeconds != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#8c1b7b8c43928175999e8369df4a1f1a">mBySeconds</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00527"></a>00527 <span class="keywordflow">if</span> ( mByMinutes != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#60bdc1ec24b53b14c1fb935ed4204514">mByMinutes</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00528"></a>00528 <span class="keywordflow">if</span> ( mByHours != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#9794ade641402469559e0b588804fa45">mByHours</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00529"></a>00529 <span class="keywordflow">if</span> ( mByDays != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#40f4236159232bf8a961ec09f488eab1">mByDays</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00530"></a>00530 <span class="keywordflow">if</span> ( mByMonthDays != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#f9ffd938f3f6c03624e68f99ebbb2ef8">mByMonthDays</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00531"></a>00531 <span class="keywordflow">if</span> ( mByYearDays != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#c444adda662a97ae97ff3342a6bd17f1">mByYearDays</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00532"></a>00532 <span class="keywordflow">if</span> ( mByWeekNumbers != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#6f9f34fd08a1f4be76eab5caf56e6876">mByWeekNumbers</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00533"></a>00533 <span class="keywordflow">if</span> ( mByMonths != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#3f8e61bee6d74e1f86a5820d09561286">mByMonths</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00534"></a>00534 <span class="keywordflow">if</span> ( mBySetPos != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#d454ead64a65f31a92582aeb3463bb10">mBySetPos</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00535"></a>00535 <span class="keywordflow">if</span> ( mWeekStart != r.<a class="code" href="classKCal_1_1RecurrenceRule.html#dd261b0c5d1039c244ed0cb4a44604f6">mWeekStart</a> ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00536"></a>00536 <a name="l00537"></a>00537 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00538"></a>00538 } <a name="l00539"></a>00539 <a name="l00540"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#c3721035ea2edf7d73a03797bd278933">00540</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#c3721035ea2edf7d73a03797bd278933" title="Installs an observer.">RecurrenceRule::addObserver</a>( Observer *observer ) <a name="l00541"></a>00541 { <a name="l00542"></a>00542 <span class="keywordflow">if</span> ( !mObservers.contains( observer ) ) <a name="l00543"></a>00543 mObservers.append( observer ); <a name="l00544"></a>00544 } <a name="l00545"></a>00545 <a name="l00546"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#5f9a2e30e0f554e171223c325feda437">00546</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#5f9a2e30e0f554e171223c325feda437" title="Removes an observer that was added with addObserver.">RecurrenceRule::removeObserver</a>( Observer *observer ) <a name="l00547"></a>00547 { <a name="l00548"></a>00548 <span class="keywordflow">if</span> ( mObservers.contains( observer ) ) <a name="l00549"></a>00549 mObservers.remove( observer ); <a name="l00550"></a>00550 } <a name="l00551"></a>00551 <a name="l00552"></a>00552 <a name="l00553"></a>00553 <a name="l00554"></a>00554 <span class="keywordtype">void</span> RecurrenceRule::setRecurrenceType( <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">PeriodType</a> period ) <a name="l00555"></a>00555 { <a name="l00556"></a>00556 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00557"></a>00557 mPeriod = period; <a name="l00558"></a>00558 setDirty(); <a name="l00559"></a>00559 } <a name="l00560"></a>00560 <a name="l00561"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954">00561</a> QDateTime <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">RecurrenceRule::endDt</a>( <span class="keywordtype">bool</span> *result )<span class="keyword"> const</span> <a name="l00562"></a>00562 <span class="keyword"></span>{ <a name="l00563"></a>00563 <span class="keywordflow">if</span> ( result ) *result = <span class="keyword">false</span>; <a name="l00564"></a>00564 <span class="keywordflow">if</span> ( mPeriod == rNone ) <span class="keywordflow">return</span> QDateTime(); <a name="l00565"></a>00565 <span class="keywordflow">if</span> ( mDuration < 0 ) <span class="keywordflow">return</span> QDateTime(); <a name="l00566"></a>00566 <span class="keywordflow">if</span> ( mDuration == 0 ) { <a name="l00567"></a>00567 <span class="keywordflow">if</span> ( result ) *result = <span class="keyword">true</span>; <a name="l00568"></a>00568 <span class="keywordflow">return</span> mDateEnd; <a name="l00569"></a>00569 } <a name="l00570"></a>00570 <span class="comment">// N occurrences. Check if we have a full cache. If so, return the cached end date.</span> <a name="l00571"></a>00571 <span class="keywordflow">if</span> ( ! mCached ) { <a name="l00572"></a>00572 <span class="comment">// If not enough occurrences can be found (i.e. inconsistent constraints)</span> <a name="l00573"></a>00573 <span class="keywordflow">if</span> ( !buildCache() ) <span class="keywordflow">return</span> QDateTime(); <a name="l00574"></a>00574 } <a name="l00575"></a>00575 <span class="keywordflow">if</span> ( result ) *result = <span class="keyword">true</span>; <a name="l00576"></a>00576 <span class="keywordflow">return</span> mCachedDateEnd; <a name="l00577"></a>00577 } <a name="l00578"></a>00578 <a name="l00579"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#58f6bda7ee1d675168972a4a0bcb7633">00579</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#58f6bda7ee1d675168972a4a0bcb7633" title="Sets the date and time of the last recurrence.">RecurrenceRule::setEndDt</a>( <span class="keyword">const</span> QDateTime &dateTime ) <a name="l00580"></a>00580 { <a name="l00581"></a>00581 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00582"></a>00582 mDateEnd = dateTime; <a name="l00583"></a>00583 mDuration = 0; <span class="comment">// set to 0 because there is an end date/time</span> <a name="l00584"></a>00584 setDirty(); <a name="l00585"></a>00585 } <a name="l00586"></a>00586 <a name="l00587"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#2c16ccbb4c87ebe799b3fe4c9125bb39">00587</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#2c16ccbb4c87ebe799b3fe4c9125bb39" title="Sets the total number of times the event is to occur, including both the first and...">RecurrenceRule::setDuration</a>(<span class="keywordtype">int</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#6e56f222c2940c4577e73dba47d300d3" title="Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the...">duration</a>) <a name="l00588"></a>00588 { <a name="l00589"></a>00589 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00590"></a>00590 mDuration = duration; <a name="l00591"></a>00591 setDirty(); <a name="l00592"></a>00592 } <a name="l00593"></a>00593 <a name="l00594"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#90de024f9b895cf09bbff6975e28fc47">00594</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#90de024f9b895cf09bbff6975e28fc47" title="Sets whether the dtstart is a floating time (i.e.">RecurrenceRule::setFloats</a>( <span class="keywordtype">bool</span> floats ) <a name="l00595"></a>00595 { <a name="l00596"></a>00596 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00597"></a>00597 mFloating = floats; <a name="l00598"></a>00598 setDirty(); <a name="l00599"></a>00599 } <a name="l00600"></a>00600 <a name="l00601"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#1e03da0b72efac7303214beb06805dc7">00601</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#1e03da0b72efac7303214beb06805dc7" title="Turns off recurrence for the event.">RecurrenceRule::clear</a>() <a name="l00602"></a>00602 { <a name="l00603"></a>00603 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00604"></a>00604 mPeriod = rNone; <a name="l00605"></a>00605 mBySeconds.clear(); <a name="l00606"></a>00606 mByMinutes.clear(); <a name="l00607"></a>00607 mByHours.clear(); <a name="l00608"></a>00608 mByDays.clear(); <a name="l00609"></a>00609 mByMonthDays.clear(); <a name="l00610"></a>00610 mByYearDays.clear(); <a name="l00611"></a>00611 mByWeekNumbers.clear(); <a name="l00612"></a>00612 mByMonths.clear(); <a name="l00613"></a>00613 mBySetPos.clear(); <a name="l00614"></a>00614 mWeekStart = 1; <a name="l00615"></a>00615 <a name="l00616"></a>00616 setDirty(); <a name="l00617"></a>00617 } <a name="l00618"></a>00618 <a name="l00619"></a>00619 <span class="keywordtype">void</span> RecurrenceRule::setDirty() <a name="l00620"></a>00620 { <a name="l00621"></a>00621 mConstraints.clear(); <a name="l00622"></a>00622 buildConstraints(); <a name="l00623"></a>00623 mDirty = <span class="keyword">true</span>; <a name="l00624"></a>00624 mCached = <span class="keyword">false</span>; <a name="l00625"></a>00625 mCachedDates.clear(); <a name="l00626"></a>00626 <span class="keywordflow">for</span> ( QValueList<Observer*>::ConstIterator it = mObservers.begin(); <a name="l00627"></a>00627 it != mObservers.end(); ++it ) { <a name="l00628"></a>00628 <span class="keywordflow">if</span> ( (*it) ) (*it)->recurrenceChanged( <span class="keyword">this</span> ); <a name="l00629"></a>00629 } <a name="l00630"></a>00630 } <a name="l00631"></a>00631 <a name="l00632"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#ac94a23ae67e5dc6fa4c65e7a3178a0a">00632</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#ac94a23ae67e5dc6fa4c65e7a3178a0a" title="Set start of recurrence, as a date and time.">RecurrenceRule::setStartDt</a>( <span class="keyword">const</span> QDateTime &start ) <a name="l00633"></a>00633 { <a name="l00634"></a>00634 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00635"></a>00635 mDateStart = start; <a name="l00636"></a>00636 setDirty(); <a name="l00637"></a>00637 } <a name="l00638"></a>00638 <a name="l00639"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#5594fded1c7023d124674d21897a94d4">00639</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#5594fded1c7023d124674d21897a94d4" title="Sets the frequency of recurrence, in terms of the recurrence time period type.">RecurrenceRule::setFrequency</a>(<span class="keywordtype">int</span> freq) <a name="l00640"></a>00640 { <a name="l00641"></a>00641 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() || freq <= 0 ) <span class="keywordflow">return</span>; <a name="l00642"></a>00642 mFrequency = freq; <a name="l00643"></a>00643 setDirty(); <a name="l00644"></a>00644 } <a name="l00645"></a>00645 <a name="l00646"></a>00646 <span class="keywordtype">void</span> RecurrenceRule::setBySeconds( <span class="keyword">const</span> QValueList<int> bySeconds ) <a name="l00647"></a>00647 { <a name="l00648"></a>00648 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00649"></a>00649 mBySeconds = bySeconds; <a name="l00650"></a>00650 setDirty(); <a name="l00651"></a>00651 } <a name="l00652"></a>00652 <a name="l00653"></a>00653 <span class="keywordtype">void</span> RecurrenceRule::setByMinutes( <span class="keyword">const</span> QValueList<int> byMinutes ) <a name="l00654"></a>00654 { <a name="l00655"></a>00655 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00656"></a>00656 mByMinutes = byMinutes; <a name="l00657"></a>00657 setDirty(); <a name="l00658"></a>00658 } <a name="l00659"></a>00659 <a name="l00660"></a>00660 <span class="keywordtype">void</span> RecurrenceRule::setByHours( <span class="keyword">const</span> QValueList<int> byHours ) <a name="l00661"></a>00661 { <a name="l00662"></a>00662 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00663"></a>00663 mByHours = byHours; <a name="l00664"></a>00664 setDirty(); <a name="l00665"></a>00665 } <a name="l00666"></a>00666 <a name="l00667"></a>00667 <a name="l00668"></a>00668 <span class="keywordtype">void</span> RecurrenceRule::setByDays( <span class="keyword">const</span> QValueList<WDayPos> byDays ) <a name="l00669"></a>00669 { <a name="l00670"></a>00670 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00671"></a>00671 mByDays = byDays; <a name="l00672"></a>00672 setDirty(); <a name="l00673"></a>00673 } <a name="l00674"></a>00674 <a name="l00675"></a>00675 <span class="keywordtype">void</span> RecurrenceRule::setByMonthDays( <span class="keyword">const</span> QValueList<int> byMonthDays ) <a name="l00676"></a>00676 { <a name="l00677"></a>00677 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00678"></a>00678 mByMonthDays = byMonthDays; <a name="l00679"></a>00679 setDirty(); <a name="l00680"></a>00680 } <a name="l00681"></a>00681 <a name="l00682"></a>00682 <span class="keywordtype">void</span> RecurrenceRule::setByYearDays( <span class="keyword">const</span> QValueList<int> byYearDays ) <a name="l00683"></a>00683 { <a name="l00684"></a>00684 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00685"></a>00685 mByYearDays = byYearDays; <a name="l00686"></a>00686 setDirty(); <a name="l00687"></a>00687 } <a name="l00688"></a>00688 <a name="l00689"></a>00689 <span class="keywordtype">void</span> RecurrenceRule::setByWeekNumbers( <span class="keyword">const</span> QValueList<int> byWeekNumbers ) <a name="l00690"></a>00690 { <a name="l00691"></a>00691 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00692"></a>00692 mByWeekNumbers = byWeekNumbers; <a name="l00693"></a>00693 setDirty(); <a name="l00694"></a>00694 } <a name="l00695"></a>00695 <a name="l00696"></a>00696 <span class="keywordtype">void</span> RecurrenceRule::setByMonths( <span class="keyword">const</span> QValueList<int> byMonths ) <a name="l00697"></a>00697 { <a name="l00698"></a>00698 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00699"></a>00699 mByMonths = byMonths; <a name="l00700"></a>00700 setDirty(); <a name="l00701"></a>00701 } <a name="l00702"></a>00702 <a name="l00703"></a>00703 <span class="keywordtype">void</span> RecurrenceRule::setBySetPos( <span class="keyword">const</span> QValueList<int> bySetPos ) <a name="l00704"></a>00704 { <a name="l00705"></a>00705 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00706"></a>00706 mBySetPos = bySetPos; <a name="l00707"></a>00707 setDirty(); <a name="l00708"></a>00708 } <a name="l00709"></a>00709 <a name="l00710"></a>00710 <span class="keywordtype">void</span> RecurrenceRule::setWeekStart( <span class="keywordtype">short</span> weekStart ) <a name="l00711"></a>00711 { <a name="l00712"></a>00712 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() ) <span class="keywordflow">return</span>; <a name="l00713"></a>00713 mWeekStart = weekStart; <a name="l00714"></a>00714 setDirty(); <a name="l00715"></a>00715 } <a name="l00716"></a>00716 <a name="l00717"></a>00717 <a name="l00718"></a>00718 <a name="l00719"></a>00719 <span class="comment">// Taken from recurrence.cpp</span> <a name="l00720"></a>00720 <span class="comment">// int RecurrenceRule::maxIterations() const</span> <a name="l00721"></a>00721 <span class="comment">// {</span> <a name="l00722"></a>00722 <span class="comment">// /* Find the maximum number of iterations which may be needed to reach the</span> <a name="l00723"></a>00723 <span class="comment">// * next actual occurrence of a monthly or yearly recurrence.</span> <a name="l00724"></a>00724 <span class="comment">// * More than one iteration may be needed if, for example, it's the 29th February,</span> <a name="l00725"></a>00725 <span class="comment">// * the 31st day of the month or the 5th Monday, and the month being checked is</span> <a name="l00726"></a>00726 <span class="comment">// * February or a 30-day month.</span> <a name="l00727"></a>00727 <span class="comment">// * The following recurrences may never occur:</span> <a name="l00728"></a>00728 <span class="comment">// * - For rMonthlyDay: if the frequency is a whole number of years.</span> <a name="l00729"></a>00729 <span class="comment">// * - For rMonthlyPos: if the frequency is an even whole number of years.</span> <a name="l00730"></a>00730 <span class="comment">// * - For rYearlyDay, rYearlyMonth: if the frequeny is a multiple of 4 years.</span> <a name="l00731"></a>00731 <span class="comment">// * - For rYearlyPos: if the frequency is an even number of years.</span> <a name="l00732"></a>00732 <span class="comment">// * The maximum number of iterations needed, assuming that it does actually occur,</span> <a name="l00733"></a>00733 <span class="comment">// * was found empirically.</span> <a name="l00734"></a>00734 <span class="comment">// */</span> <a name="l00735"></a>00735 <span class="comment">// switch (recurs) {</span> <a name="l00736"></a>00736 <span class="comment">// case rMonthlyDay:</span> <a name="l00737"></a>00737 <span class="comment">// return (rFreq % 12) ? 6 : 8;</span> <a name="l00738"></a>00738 <span class="comment">//</span> <a name="l00739"></a>00739 <span class="comment">// case rMonthlyPos:</span> <a name="l00740"></a>00740 <span class="comment">// if (rFreq % 12 == 0) {</span> <a name="l00741"></a>00741 <span class="comment">// // Some of these frequencies may never occur</span> <a name="l00742"></a>00742 <span class="comment">// return (rFreq % 84 == 0) ? 364 // frequency = multiple of 7 years</span> <a name="l00743"></a>00743 <span class="comment">// : (rFreq % 48 == 0) ? 7 // frequency = multiple of 4 years</span> <a name="l00744"></a>00744 <span class="comment">// : (rFreq % 24 == 0) ? 14 : 28; // frequency = multiple of 2 or 1 year</span> <a name="l00745"></a>00745 <span class="comment">// }</span> <a name="l00746"></a>00746 <span class="comment">// // All other frequencies will occur sometime</span> <a name="l00747"></a>00747 <span class="comment">// if (rFreq > 120)</span> <a name="l00748"></a>00748 <span class="comment">// return 364; // frequencies of > 10 years will hit the date limit first</span> <a name="l00749"></a>00749 <span class="comment">// switch (rFreq) {</span> <a name="l00750"></a>00750 <span class="comment">// case 23: return 50;</span> <a name="l00751"></a>00751 <span class="comment">// case 46: return 38;</span> <a name="l00752"></a>00752 <span class="comment">// case 56: return 138;</span> <a name="l00753"></a>00753 <span class="comment">// case 66: return 36;</span> <a name="l00754"></a>00754 <span class="comment">// case 89: return 54;</span> <a name="l00755"></a>00755 <span class="comment">// case 112: return 253;</span> <a name="l00756"></a>00756 <span class="comment">// default: return 25; // most frequencies will need < 25 iterations</span> <a name="l00757"></a>00757 <span class="comment">// }</span> <a name="l00758"></a>00758 <span class="comment">//</span> <a name="l00759"></a>00759 <span class="comment">// case rYearlyMonth:</span> <a name="l00760"></a>00760 <span class="comment">// case rYearlyDay:</span> <a name="l00761"></a>00761 <span class="comment">// return 8; // only 29th Feb or day 366 will need more than one iteration</span> <a name="l00762"></a>00762 <span class="comment">//</span> <a name="l00763"></a>00763 <span class="comment">// case rYearlyPos:</span> <a name="l00764"></a>00764 <span class="comment">// if (rFreq % 7 == 0)</span> <a name="l00765"></a>00765 <span class="comment">// return 364; // frequencies of a multiple of 7 years will hit the date limit first</span> <a name="l00766"></a>00766 <span class="comment">// if (rFreq % 2 == 0) {</span> <a name="l00767"></a>00767 <span class="comment">// // Some of these frequencies may never occur</span> <a name="l00768"></a>00768 <span class="comment">// return (rFreq % 4 == 0) ? 7 : 14; // frequency = even number of years</span> <a name="l00769"></a>00769 <span class="comment">// }</span> <a name="l00770"></a>00770 <span class="comment">// return 28;</span> <a name="l00771"></a>00771 <span class="comment">// }</span> <a name="l00772"></a>00772 <span class="comment">// return 1;</span> <a name="l00773"></a>00773 <span class="comment">// }</span> <a name="l00774"></a>00774 <a name="l00775"></a>00775 <span class="keywordtype">void</span> RecurrenceRule::buildConstraints() <a name="l00776"></a>00776 { <a name="l00777"></a>00777 mConstraints.clear(); <a name="l00778"></a>00778 Constraint con; <a name="l00779"></a>00779 <span class="keywordflow">if</span> ( mWeekStart > 0 ) con.weekstart = mWeekStart; <a name="l00780"></a>00780 mConstraints.append( con ); <a name="l00781"></a>00781 <a name="l00782"></a>00782 Constraint::List tmp; <a name="l00783"></a>00783 Constraint::List::const_iterator it; <a name="l00784"></a>00784 QValueList<int>::const_iterator intit; <a name="l00785"></a>00785 <a name="l00786"></a>00786 <span class="preprocessor"> #define intConstraint( list, element ) \</span> <a name="l00787"></a>00787 <span class="preprocessor"> if ( !list.isEmpty() ) { \</span> <a name="l00788"></a>00788 <span class="preprocessor"> for ( it = mConstraints.constBegin(); it != mConstraints.constEnd(); ++it ) { \</span> <a name="l00789"></a>00789 <span class="preprocessor"> for ( intit = list.constBegin(); intit != list.constEnd(); ++intit ) { \</span> <a name="l00790"></a>00790 <span class="preprocessor"> con = (*it); \</span> <a name="l00791"></a>00791 <span class="preprocessor"> con.element = (*intit); \</span> <a name="l00792"></a>00792 <span class="preprocessor"> tmp.append( con ); \</span> <a name="l00793"></a>00793 <span class="preprocessor"> } \</span> <a name="l00794"></a>00794 <span class="preprocessor"> } \</span> <a name="l00795"></a>00795 <span class="preprocessor"> mConstraints = tmp; \</span> <a name="l00796"></a>00796 <span class="preprocessor"> tmp.clear(); \</span> <a name="l00797"></a>00797 <span class="preprocessor"> }</span> <a name="l00798"></a>00798 <span class="preprocessor"></span> <a name="l00799"></a>00799 intConstraint( mBySeconds, second ); <a name="l00800"></a>00800 intConstraint( mByMinutes, minute ); <a name="l00801"></a>00801 intConstraint( mByHours, hour ); <a name="l00802"></a>00802 intConstraint( mByMonthDays, day ); <a name="l00803"></a>00803 intConstraint( mByMonths, month ); <a name="l00804"></a>00804 intConstraint( mByYearDays, yearday ); <a name="l00805"></a>00805 intConstraint( mByWeekNumbers, weeknumber ); <a name="l00806"></a>00806 <span class="preprocessor"> #undef intConstraint</span> <a name="l00807"></a>00807 <span class="preprocessor"></span> <a name="l00808"></a>00808 <span class="keywordflow">if</span> ( !mByDays.isEmpty() ) { <a name="l00809"></a>00809 <span class="keywordflow">for</span> ( it = mConstraints.constBegin(); it != mConstraints.constEnd(); ++it ) { <a name="l00810"></a>00810 QValueList<WDayPos>::const_iterator dayit; <a name="l00811"></a>00811 <span class="keywordflow">for</span> ( dayit = mByDays.constBegin(); dayit != mByDays.constEnd(); ++dayit ) { <a name="l00812"></a>00812 con = (*it); <a name="l00813"></a>00813 con.weekday = (*dayit).day(); <a name="l00814"></a>00814 con.weekdaynr = (*dayit).pos(); <a name="l00815"></a>00815 tmp.append( con ); <a name="l00816"></a>00816 } <a name="l00817"></a>00817 } <a name="l00818"></a>00818 mConstraints = tmp; <a name="l00819"></a>00819 tmp.clear(); <a name="l00820"></a>00820 } <a name="l00821"></a>00821 <a name="l00822"></a>00822 <span class="preprocessor"> #define fixConstraint( element, value ) \</span> <a name="l00823"></a>00823 <span class="preprocessor"> { \</span> <a name="l00824"></a>00824 <span class="preprocessor"> tmp.clear(); \</span> <a name="l00825"></a>00825 <span class="preprocessor"> for ( it = mConstraints.constBegin(); it != mConstraints.constEnd(); ++it ) { \</span> <a name="l00826"></a>00826 <span class="preprocessor"> con = (*it); con.element = value; tmp.append( con ); \</span> <a name="l00827"></a>00827 <span class="preprocessor"> } \</span> <a name="l00828"></a>00828 <span class="preprocessor"> mConstraints = tmp; \</span> <a name="l00829"></a>00829 <span class="preprocessor"> }</span> <a name="l00830"></a>00830 <span class="preprocessor"></span> <span class="comment">// Now determine missing values from DTSTART. This can speed up things,</span> <a name="l00831"></a>00831 <span class="comment">// because we have more restrictions and save some loops.</span> <a name="l00832"></a>00832 <a name="l00833"></a>00833 <span class="comment">// TODO: Does RFC 2445 intend to restrict the weekday in all cases of weekly?</span> <a name="l00834"></a>00834 <span class="keywordflow">if</span> ( mPeriod == rWeekly && mByDays.isEmpty() ) { <a name="l00835"></a>00835 fixConstraint( weekday, mDateStart.date().dayOfWeek() ); <a name="l00836"></a>00836 } <a name="l00837"></a>00837 <a name="l00838"></a>00838 <span class="comment">// Really fall through in the cases, because all smaller time intervals are</span> <a name="l00839"></a>00839 <span class="comment">// constrained from dtstart</span> <a name="l00840"></a>00840 <span class="keywordflow">switch</span> ( mPeriod ) { <a name="l00841"></a>00841 <span class="keywordflow">case</span> rYearly: <a name="l00842"></a>00842 <span class="keywordflow">if</span> ( mByDays.isEmpty() && mByWeekNumbers.isEmpty() && mByYearDays.isEmpty() && mByMonths.isEmpty() ) { <a name="l00843"></a>00843 fixConstraint( month, mDateStart.date().month() ); <a name="l00844"></a>00844 } <a name="l00845"></a>00845 <span class="keywordflow">case</span> rMonthly: <a name="l00846"></a>00846 <span class="keywordflow">if</span> ( mByDays.isEmpty() && mByWeekNumbers.isEmpty() && mByYearDays.isEmpty() && mByMonthDays.isEmpty() ) { <a name="l00847"></a>00847 fixConstraint( day, mDateStart.date().day() ); <a name="l00848"></a>00848 } <a name="l00849"></a>00849 <a name="l00850"></a>00850 <span class="keywordflow">case</span> rWeekly: <a name="l00851"></a>00851 <span class="keywordflow">case</span> rDaily: <a name="l00852"></a>00852 <span class="keywordflow">if</span> ( mByHours.isEmpty() ) { <a name="l00853"></a>00853 fixConstraint( hour, mDateStart.time().hour() ); <a name="l00854"></a>00854 } <a name="l00855"></a>00855 <span class="keywordflow">case</span> rHourly: <a name="l00856"></a>00856 <span class="keywordflow">if</span> ( mByMinutes.isEmpty() ) { <a name="l00857"></a>00857 fixConstraint( minute, mDateStart.time().minute() ); <a name="l00858"></a>00858 } <a name="l00859"></a>00859 <span class="keywordflow">case</span> rMinutely: <a name="l00860"></a>00860 <span class="keywordflow">if</span> ( mBySeconds.isEmpty() ) { <a name="l00861"></a>00861 fixConstraint( second, mDateStart.time().second() ); <a name="l00862"></a>00862 } <a name="l00863"></a>00863 <span class="keywordflow">case</span> rSecondly: <a name="l00864"></a>00864 <span class="keywordflow">default</span>: <a name="l00865"></a>00865 <span class="keywordflow">break</span>; <a name="l00866"></a>00866 } <a name="l00867"></a>00867 <span class="preprocessor"> #undef fixConstraint</span> <a name="l00868"></a>00868 <span class="preprocessor"></span> <a name="l00869"></a>00869 Constraint::List::Iterator conit = mConstraints.begin(); <a name="l00870"></a>00870 <span class="keywordflow">while</span> ( conit != mConstraints.end() ) { <a name="l00871"></a>00871 <span class="keywordflow">if</span> ( (*conit).isConsistent( mPeriod ) ) { <a name="l00872"></a>00872 ++conit; <a name="l00873"></a>00873 } <span class="keywordflow">else</span> { <a name="l00874"></a>00874 conit = mConstraints.remove( conit ); <a name="l00875"></a>00875 } <a name="l00876"></a>00876 } <a name="l00877"></a>00877 } <a name="l00878"></a>00878 <a name="l00879"></a>00879 <span class="keywordtype">bool</span> RecurrenceRule::buildCache()<span class="keyword"> const</span> <a name="l00880"></a>00880 <span class="keyword"></span>{ <a name="l00881"></a>00881 kdDebug(5800) << <span class="stringliteral">" RecurrenceRule::buildCache: "</span> << endl; <a name="l00882"></a>00882 <span class="comment">// Build the list of all occurrences of this event (we need that to determine</span> <a name="l00883"></a>00883 <span class="comment">// the end date!)</span> <a name="l00884"></a>00884 Constraint interval( getNextValidDateInterval( <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>(), recurrenceType() ) ); <a name="l00885"></a>00885 QDateTime next; <a name="l00886"></a>00886 <a name="l00887"></a>00887 DateTimeList dts = datesForInterval( interval, recurrenceType() ); <a name="l00888"></a>00888 DateTimeList::Iterator it = dts.begin(); <a name="l00889"></a>00889 <span class="comment">// Only use dates after the event has started (start date is only included</span> <a name="l00890"></a>00890 <span class="comment">// if it matches)</span> <a name="l00891"></a>00891 <span class="keywordflow">while</span> ( it != dts.end() ) { <a name="l00892"></a>00892 <span class="keywordflow">if</span> ( (*it) < <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) it = dts.remove( it ); <a name="l00893"></a>00893 <span class="keywordflow">else</span> ++it; <a name="l00894"></a>00894 } <a name="l00895"></a>00895 <span class="comment">// dts.prepend( startDt() ); // the start date is always the first occurrence</span> <a name="l00896"></a>00896 <a name="l00897"></a>00897 <a name="l00898"></a>00898 <span class="keywordtype">int</span> loopnr = 0; <a name="l00899"></a>00899 <span class="keywordtype">int</span> dtnr = dts.count(); <a name="l00900"></a>00900 <span class="comment">// some validity checks to avoid infinite loops (i.e. if we have</span> <a name="l00901"></a>00901 <span class="comment">// done this loop already 10000 times and found no occurrence, bail out )</span> <a name="l00902"></a>00902 <span class="keywordflow">while</span> ( loopnr < 10000 && dtnr < mDuration ) { <a name="l00903"></a>00903 interval.increase( recurrenceType(), <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ); <a name="l00904"></a>00904 <span class="comment">// The returned date list is already sorted!</span> <a name="l00905"></a>00905 dts += datesForInterval( interval, recurrenceType() ); <a name="l00906"></a>00906 dtnr = dts.count(); <a name="l00907"></a>00907 ++loopnr; <a name="l00908"></a>00908 } <a name="l00909"></a>00909 <span class="keywordflow">if</span> ( <span class="keywordtype">int</span>(dts.count()) > mDuration ) { <a name="l00910"></a>00910 <span class="comment">// we have picked up more occurrences than necessary, remove them</span> <a name="l00911"></a>00911 it = dts.at( mDuration ); <a name="l00912"></a>00912 <span class="keywordflow">while</span> ( it != dts.end() ) it = dts.remove( it ); <a name="l00913"></a>00913 } <a name="l00914"></a>00914 mCached = <span class="keyword">true</span>; <a name="l00915"></a>00915 mCachedDates = dts; <a name="l00916"></a>00916 <a name="l00917"></a>00917 kdDebug(5800) << <span class="stringliteral">" Finished Building Cache, cache has "</span> << dts.count() << <span class="stringliteral">" entries:"</span> << endl; <a name="l00918"></a>00918 <span class="comment">// it = dts.begin();</span> <a name="l00919"></a>00919 <span class="comment">// while ( it != dts.end() ) {</span> <a name="l00920"></a>00920 <span class="comment">// kdDebug(5800) << " -=> " << (*it) << endl;</span> <a name="l00921"></a>00921 <span class="comment">// ++it;</span> <a name="l00922"></a>00922 <span class="comment">// }</span> <a name="l00923"></a>00923 <span class="keywordflow">if</span> ( <span class="keywordtype">int</span>(dts.count()) == mDuration ) { <a name="l00924"></a>00924 mCachedDateEnd = dts.last(); <a name="l00925"></a>00925 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00926"></a>00926 } <span class="keywordflow">else</span> { <a name="l00927"></a>00927 mCachedDateEnd = QDateTime(); <a name="l00928"></a>00928 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00929"></a>00929 } <a name="l00930"></a>00930 } <a name="l00931"></a>00931 <a name="l00932"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#d0b5449b7e33b49ef1bfdb6762b802aa">00932</a> <span class="keywordtype">bool</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#d0b5449b7e33b49ef1bfdb6762b802aa" title="Returns true if the date matches the rules.">RecurrenceRule::dateMatchesRules</a>( <span class="keyword">const</span> QDateTime &qdt )<span class="keyword"> const</span> <a name="l00933"></a>00933 <span class="keyword"></span>{ <a name="l00934"></a>00934 <span class="keywordtype">bool</span> match = <span class="keyword">false</span>; <a name="l00935"></a>00935 <span class="keywordflow">for</span> ( Constraint::List::ConstIterator it = mConstraints.begin(); <a name="l00936"></a>00936 it!=mConstraints.end(); ++it ) { <a name="l00937"></a>00937 match = match || ( (*it).matches( qdt, recurrenceType() ) ); <a name="l00938"></a>00938 } <a name="l00939"></a>00939 <span class="keywordflow">return</span> match; <a name="l00940"></a>00940 } <a name="l00941"></a>00941 <a name="l00942"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#2f6bc75e245c5277b783054a4498126e">00942</a> <span class="keywordtype">bool</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#2f6bc75e245c5277b783054a4498126e" title="Returns true if the date specified is one on which the event will recur.">RecurrenceRule::recursOn</a>( <span class="keyword">const</span> QDate &qd )<span class="keyword"> const</span> <a name="l00943"></a>00943 <span class="keyword"></span>{ <a name="l00944"></a>00944 <span class="comment">// kdDebug(5800) << " RecurrenceRule::recursOn: " << qd << endl;</span> <a name="l00945"></a>00945 <span class="keywordflow">if</span> ( qd < <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>().date() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00946"></a>00946 <span class="comment">// Start date is only included if it really matches</span> <a name="l00947"></a>00947 <span class="comment">// if ( qd == startDt().date() ) return true;</span> <a name="l00948"></a>00948 <span class="keywordflow">if</span> ( mDuration >= 0 && qd > <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>().date() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00949"></a>00949 <a name="l00950"></a>00950 <span class="comment">// The date must be in an appropriate interval (getNextValidDateInterval),</span> <a name="l00951"></a>00951 <span class="comment">// Plus it must match at least one of the constraints</span> <a name="l00952"></a>00952 <span class="keywordtype">bool</span> match = <span class="keyword">false</span>; <a name="l00953"></a>00953 <span class="keywordflow">for</span> ( Constraint::List::ConstIterator it = mConstraints.begin(); <a name="l00954"></a>00954 it!=mConstraints.end(); ++it ) { <a name="l00955"></a>00955 match = match || ( (*it).matches( qd, recurrenceType() ) ); <a name="l00956"></a>00956 } <a name="l00957"></a>00957 <span class="keywordflow">if</span> ( !match ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00958"></a>00958 QDateTime tmp( qd, QTime( 0, 0, 0 ) ); <a name="l00959"></a>00959 Constraint interval( getNextValidDateInterval( tmp, recurrenceType() ) ); <a name="l00960"></a>00960 <span class="comment">// Constraint::matches is quite efficient, so first check if it can occur at</span> <a name="l00961"></a>00961 <span class="comment">// all before we calculate all actual dates.</span> <a name="l00962"></a>00962 <span class="keywordflow">if</span> ( !interval.matches( qd, recurrenceType() ) ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00963"></a>00963 <span class="comment">// We really need to obtain the list of dates in this interval, since</span> <a name="l00964"></a>00964 <span class="comment">// otherwise BYSETPOS will not work (i.e. the date will match the interval,</span> <a name="l00965"></a>00965 <span class="comment">// but BYSETPOS selects only one of these matching dates!</span> <a name="l00966"></a>00966 DateTimeList times = datesForInterval( interval, recurrenceType() ); <a name="l00967"></a>00967 DateTimeList::ConstIterator it = times.begin(); <a name="l00968"></a>00968 <span class="keywordflow">while</span> ( ( it != times.end() ) && ( (*it).date() < qd ) ) <a name="l00969"></a>00969 ++it; <a name="l00970"></a>00970 <span class="keywordflow">if</span> ( it != times.end() ) { <a name="l00971"></a>00971 <span class="comment">// If we are beyond the end...</span> <a name="l00972"></a>00972 <span class="keywordflow">if</span> ( mDuration >= 0 && (*it) > <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() ) <a name="l00973"></a>00973 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00974"></a>00974 <span class="keywordflow">if</span> ( (*it).date() == qd ) <a name="l00975"></a>00975 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00976"></a>00976 } <a name="l00977"></a>00977 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00978"></a>00978 } <a name="l00979"></a>00979 <a name="l00980"></a>00980 <a name="l00981"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#3e813ef9380182f941306af68c396d23">00981</a> <span class="keywordtype">bool</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#3e813ef9380182f941306af68c396d23" title="Returns true if the date/time specified is one at which the event will recur.">RecurrenceRule::recursAt</a>( <span class="keyword">const</span> QDateTime &qd )<span class="keyword"> const</span> <a name="l00982"></a>00982 <span class="keyword"></span>{ <a name="l00983"></a>00983 <span class="comment">// kdDebug(5800) << " RecurrenceRule::recursAt: " << qd << endl;</span> <a name="l00984"></a>00984 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#1c1410f7aba825460d38844fc55a8e86" title="Returns whether the start date has no time associated.">doesFloat</a>() ) <span class="keywordflow">return</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#2f6bc75e245c5277b783054a4498126e" title="Returns true if the date specified is one on which the event will recur.">recursOn</a>( qd.date() ); <a name="l00985"></a>00985 <span class="keywordflow">if</span> ( qd < <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00986"></a>00986 <span class="comment">// Start date is only included if it really matches</span> <a name="l00987"></a>00987 <span class="comment">// if ( qd == startDt() ) return true;</span> <a name="l00988"></a>00988 <span class="keywordflow">if</span> ( mDuration >= 0 && qd > <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00989"></a>00989 <a name="l00990"></a>00990 <span class="comment">// The date must be in an appropriate interval (getNextValidDateInterval),</span> <a name="l00991"></a>00991 <span class="comment">// Plus it must match at least one of the constraints</span> <a name="l00992"></a>00992 <span class="keywordtype">bool</span> match = <a class="code" href="classKCal_1_1RecurrenceRule.html#d0b5449b7e33b49ef1bfdb6762b802aa" title="Returns true if the date matches the rules.">dateMatchesRules</a>( qd ); <a name="l00993"></a>00993 <span class="keywordflow">if</span> ( !match ) <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00994"></a>00994 <span class="comment">// if it recurs every interval, speed things up...</span> <a name="l00995"></a>00995 <span class="comment">// if ( mFrequency == 1 && mBySetPos.isEmpty() && mByDays.isEmpty() ) return true;</span> <a name="l00996"></a>00996 Constraint interval( getNextValidDateInterval( qd, recurrenceType() ) ); <a name="l00997"></a>00997 <span class="comment">// TODO_Recurrence: Does this work with BySetPos???</span> <a name="l00998"></a>00998 <span class="keywordflow">if</span> ( interval.matches( qd, recurrenceType() ) ) <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00999"></a>00999 <a name="l01000"></a>01000 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01001"></a>01001 } <a name="l01002"></a>01002 <a name="l01003"></a>01003 <a name="l01004"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#b306f7f3589d20b02b9469b60f240df4">01004</a> TimeList <a class="code" href="classKCal_1_1RecurrenceRule.html#b306f7f3589d20b02b9469b60f240df4" title="Returns a list of the times on the specified date at which the recurrence will occur...">RecurrenceRule::recurTimesOn</a>( <span class="keyword">const</span> QDate &date )<span class="keyword"> const</span> <a name="l01005"></a>01005 <span class="keyword"></span>{ <a name="l01006"></a>01006 <span class="comment">// kdDebug(5800) << " RecurrenceRule::recurTimesOn: " << date << endl;</span> <a name="l01007"></a>01007 TimeList lst; <a name="l01008"></a>01008 <span class="keywordflow">if</span> ( !<a class="code" href="classKCal_1_1RecurrenceRule.html#2f6bc75e245c5277b783054a4498126e" title="Returns true if the date specified is one on which the event will recur.">recursOn</a>( date ) ) <span class="keywordflow">return</span> lst; <a name="l01009"></a>01009 <a name="l01010"></a>01010 <span class="keywordflow">if</span> ( <a class="code" href="classKCal_1_1RecurrenceRule.html#1c1410f7aba825460d38844fc55a8e86" title="Returns whether the start date has no time associated.">doesFloat</a>() ) <span class="keywordflow">return</span> lst; <a name="l01011"></a>01011 <a name="l01012"></a>01012 QDateTime dt( date, QTime( 0, 0, 0 ) ); <a name="l01013"></a>01013 <span class="keywordtype">bool</span> valid = dt.isValid() && ( dt.date() == date ); <a name="l01014"></a>01014 <span class="keywordflow">while</span> ( valid ) { <a name="l01015"></a>01015 <span class="comment">// TODO: Add a flag so that the date is never increased!</span> <a name="l01016"></a>01016 dt = <a class="code" href="classKCal_1_1RecurrenceRule.html#c25cddd7a185e3d92f94ae2176b91f0e" title="Returns the date and time of the next recurrence, after the specified date/time.">getNextDate</a>( dt ); <a name="l01017"></a>01017 valid = dt.isValid() && ( dt.date() == date ); <a name="l01018"></a>01018 <span class="keywordflow">if</span> ( valid ) lst.append( dt.time() ); <a name="l01019"></a>01019 } <a name="l01020"></a>01020 <span class="keywordflow">return</span> lst; <a name="l01021"></a>01021 } <a name="l01022"></a>01022 <a name="l01024"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#981e2375fa191c7be6bebb6be0361f91">01024</a> <span class="keywordtype">int</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#981e2375fa191c7be6bebb6be0361f91" title="Returns the number of recurrences up to and including the date specified.">RecurrenceRule::durationTo</a>( <span class="keyword">const</span> QDateTime &dt )<span class="keyword"> const</span> <a name="l01025"></a>01025 <span class="keyword"></span>{ <a name="l01026"></a>01026 <span class="comment">// kdDebug(5800) << " RecurrenceRule::durationTo: " << dt << endl;</span> <a name="l01027"></a>01027 <span class="comment">// Easy cases: either before start, or after all recurrences and we know</span> <a name="l01028"></a>01028 <span class="comment">// their number</span> <a name="l01029"></a>01029 <span class="keywordflow">if</span> ( dt < <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) <span class="keywordflow">return</span> 0; <a name="l01030"></a>01030 <span class="comment">// Start date is only included if it really matches</span> <a name="l01031"></a>01031 <span class="comment">// if ( dt == startDt() ) return 1;</span> <a name="l01032"></a>01032 <span class="keywordflow">if</span> ( mDuration > 0 && dt >= <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() ) <span class="keywordflow">return</span> mDuration; <a name="l01033"></a>01033 <a name="l01034"></a>01034 QDateTime next( <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ); <a name="l01035"></a>01035 <span class="keywordtype">int</span> found = 0; <a name="l01036"></a>01036 <span class="keywordflow">while</span> ( next.isValid() && next <= dt ) { <a name="l01037"></a>01037 ++found; <a name="l01038"></a>01038 next = <a class="code" href="classKCal_1_1RecurrenceRule.html#c25cddd7a185e3d92f94ae2176b91f0e" title="Returns the date and time of the next recurrence, after the specified date/time.">getNextDate</a>( next ); <a name="l01039"></a>01039 } <a name="l01040"></a>01040 <span class="keywordflow">return</span> found; <a name="l01041"></a>01041 } <a name="l01042"></a>01042 <a name="l01043"></a>01043 <a name="l01044"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#85539f959146988ad378993ad5876438">01044</a> QDateTime <a class="code" href="classKCal_1_1RecurrenceRule.html#85539f959146988ad378993ad5876438" title="Returns the date and time of the last previous recurrence, before the specified date/time...">RecurrenceRule::getPreviousDate</a>( <span class="keyword">const</span> QDateTime& afterDate )<span class="keyword"> const</span> <a name="l01045"></a>01045 <span class="keyword"></span>{ <a name="l01046"></a>01046 <span class="comment">// kdDebug(5800) << " RecurrenceRule::getPreviousDate: " << afterDate << endl;</span> <a name="l01047"></a>01047 <span class="comment">// Beyond end of recurrence</span> <a name="l01048"></a>01048 <span class="keywordflow">if</span> ( afterDate < <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) <a name="l01049"></a>01049 <span class="keywordflow">return</span> QDateTime(); <a name="l01050"></a>01050 <a name="l01051"></a>01051 <span class="comment">// If we have a cache (duration given), use that</span> <a name="l01052"></a>01052 QDateTime prev; <a name="l01053"></a>01053 <span class="keywordflow">if</span> ( mDuration > 0 ) { <a name="l01054"></a>01054 <span class="keywordflow">if</span> ( !mCached ) buildCache(); <a name="l01055"></a>01055 DateTimeList::ConstIterator it = mCachedDates.begin(); <a name="l01056"></a>01056 <span class="keywordflow">while</span> ( it != mCachedDates.end() && (*it) < afterDate ) { <a name="l01057"></a>01057 prev = *it; <a name="l01058"></a>01058 ++it; <a name="l01059"></a>01059 } <a name="l01060"></a>01060 <span class="keywordflow">if</span> ( prev.isValid() && prev < afterDate ) <span class="keywordflow">return</span> prev; <a name="l01061"></a>01061 <span class="keywordflow">else</span> <span class="keywordflow">return</span> QDateTime(); <a name="l01062"></a>01062 } <a name="l01063"></a>01063 <a name="l01064"></a>01064 <span class="comment">// kdDebug(5800) << " getNext date after " << preDate << endl;</span> <a name="l01065"></a>01065 prev = afterDate; <a name="l01066"></a>01066 <span class="keywordflow">if</span> ( mDuration >= 0 && <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>().isValid() && afterDate > <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() ) <a name="l01067"></a>01067 prev = <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>().addSecs( 1 ); <a name="l01068"></a>01068 <a name="l01069"></a>01069 Constraint interval( getPreviousValidDateInterval( prev, recurrenceType() ) ); <a name="l01070"></a>01070 <span class="comment">// kdDebug(5800) << "Previous Valid Date Interval for date " << prev << ": " << endl;</span> <a name="l01071"></a>01071 <span class="comment">// interval.dump();</span> <a name="l01072"></a>01072 DateTimeList dts = datesForInterval( interval, recurrenceType() ); <a name="l01073"></a>01073 DateTimeList::Iterator dtit = dts.end(); <a name="l01074"></a>01074 <span class="keywordflow">if</span> ( dtit != dts.begin() ) { <a name="l01075"></a>01075 <span class="keywordflow">do</span> { <a name="l01076"></a>01076 --dtit; <a name="l01077"></a>01077 } <span class="keywordflow">while</span> ( dtit != dts.begin() && (*dtit) >= prev ); <a name="l01078"></a>01078 <span class="keywordflow">if</span> ( (*dtit) < prev ) { <a name="l01079"></a>01079 <span class="keywordflow">if</span> ( (*dtit) >= <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) <span class="keywordflow">return</span> (*dtit); <a name="l01080"></a>01080 <span class="keywordflow">else</span> <span class="keywordflow">return</span> QDateTime(); <a name="l01081"></a>01081 } <a name="l01082"></a>01082 } <a name="l01083"></a>01083 <a name="l01084"></a>01084 <span class="comment">// Previous interval. As soon as we find an occurrence, we're done.</span> <a name="l01085"></a>01085 <span class="keywordflow">while</span> ( interval.intervalDateTime( recurrenceType() ) > <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) { <a name="l01086"></a>01086 interval.increase( recurrenceType(), -<a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ); <a name="l01087"></a>01087 <span class="comment">// kdDebug(5800) << "Decreased interval: " << endl;</span> <a name="l01088"></a>01088 <span class="comment">// interval.dump();</span> <a name="l01089"></a>01089 <span class="comment">// The returned date list is sorted</span> <a name="l01090"></a>01090 DateTimeList dts = datesForInterval( interval, recurrenceType() ); <a name="l01091"></a>01091 <span class="comment">// The list is sorted, so take the last one.</span> <a name="l01092"></a>01092 <span class="keywordflow">if</span> ( dts.count() > 0 ) { <a name="l01093"></a>01093 prev = dts.last(); <a name="l01094"></a>01094 <span class="keywordflow">if</span> ( prev.isValid() && prev >= <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) <span class="keywordflow">return</span> prev; <a name="l01095"></a>01095 <span class="keywordflow">else</span> <span class="keywordflow">return</span> QDateTime(); <a name="l01096"></a>01096 } <a name="l01097"></a>01097 } <a name="l01098"></a>01098 <span class="keywordflow">return</span> QDateTime(); <a name="l01099"></a>01099 } <a name="l01100"></a>01100 <a name="l01101"></a>01101 <a name="l01102"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#c25cddd7a185e3d92f94ae2176b91f0e">01102</a> QDateTime <a class="code" href="classKCal_1_1RecurrenceRule.html#c25cddd7a185e3d92f94ae2176b91f0e" title="Returns the date and time of the next recurrence, after the specified date/time.">RecurrenceRule::getNextDate</a>( <span class="keyword">const</span> QDateTime &preDate )<span class="keyword"> const</span> <a name="l01103"></a>01103 <span class="keyword"></span>{ <a name="l01104"></a>01104 <span class="comment">// kdDebug(5800) << " RecurrenceRule::getNextDate: " << preDate << endl;</span> <a name="l01105"></a>01105 <span class="comment">// Beyond end of recurrence</span> <a name="l01106"></a>01106 <span class="keywordflow">if</span> ( mDuration >= 0 && <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>().isValid() && preDate >= <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() ) <a name="l01107"></a>01107 <span class="keywordflow">return</span> QDateTime(); <a name="l01108"></a>01108 <a name="l01109"></a>01109 <span class="comment">// Start date is only included if it really matches</span> <a name="l01110"></a>01110 QDateTime adjustedPreDate; <a name="l01111"></a>01111 <span class="keywordflow">if</span> ( preDate < <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() ) <a name="l01112"></a>01112 adjustedPreDate = <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>().addSecs( -1 ); <a name="l01113"></a>01113 <span class="keywordflow">else</span> <a name="l01114"></a>01114 adjustedPreDate = preDate; <a name="l01115"></a>01115 <a name="l01116"></a>01116 <span class="keywordflow">if</span> ( mDuration > 0 ) { <a name="l01117"></a>01117 <span class="keywordflow">if</span> ( !mCached ) buildCache(); <a name="l01118"></a>01118 DateTimeList::ConstIterator it = mCachedDates.begin(); <a name="l01119"></a>01119 <span class="keywordflow">while</span> ( it != mCachedDates.end() && (*it) <= adjustedPreDate ) ++it; <a name="l01120"></a>01120 <span class="keywordflow">if</span> ( it != mCachedDates.end() ) { <a name="l01121"></a>01121 <span class="comment">// kdDebug(5800) << " getNext date after " << adjustedPreDate << ", cached date: " << *it << endl;</span> <a name="l01122"></a>01122 <span class="keywordflow">return</span> (*it); <a name="l01123"></a>01123 } <a name="l01124"></a>01124 } <a name="l01125"></a>01125 <a name="l01126"></a>01126 <span class="comment">// kdDebug(5800) << " getNext date after " << adjustedPreDate << endl;</span> <a name="l01127"></a>01127 Constraint interval( getNextValidDateInterval( adjustedPreDate, recurrenceType() ) ); <a name="l01128"></a>01128 DateTimeList dts = datesForInterval( interval, recurrenceType() ); <a name="l01129"></a>01129 DateTimeList::Iterator dtit = dts.begin(); <a name="l01130"></a>01130 <span class="keywordflow">while</span> ( dtit != dts.end() && (*dtit) <= adjustedPreDate ) ++dtit; <a name="l01131"></a>01131 <span class="keywordflow">if</span> ( dtit != dts.end() ) { <a name="l01132"></a>01132 <span class="keywordflow">if</span> ( mDuration >= 0 && (*dtit) > <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() ) <span class="keywordflow">return</span> QDateTime(); <a name="l01133"></a>01133 <span class="keywordflow">else</span> <span class="keywordflow">return</span> (*dtit); <a name="l01134"></a>01134 } <a name="l01135"></a>01135 <a name="l01136"></a>01136 <span class="comment">// Increase the interval. The first occurrence that we find is the result (if</span> <a name="l01137"></a>01137 <span class="comment">// if's before the end date).</span> <a name="l01138"></a>01138 <span class="comment">// TODO: some validity checks to avoid infinite loops for contradictory constraints</span> <a name="l01139"></a>01139 <span class="keywordtype">int</span> loopnr = 0; <a name="l01140"></a>01140 <span class="keywordflow">while</span> ( loopnr < 10000 ) { <a name="l01141"></a>01141 interval.increase( recurrenceType(), <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ); <a name="l01142"></a>01142 DateTimeList dts = datesForInterval( interval, recurrenceType() ); <a name="l01143"></a>01143 <span class="keywordflow">if</span> ( dts.count() > 0 ) { <a name="l01144"></a>01144 QDateTime ret( dts.first() ); <a name="l01145"></a>01145 <span class="keywordflow">if</span> ( mDuration >= 0 && ret > <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() ) <span class="keywordflow">return</span> QDateTime(); <a name="l01146"></a>01146 <span class="keywordflow">else</span> <span class="keywordflow">return</span> ret; <a name="l01147"></a>01147 } <a name="l01148"></a>01148 ++loopnr; <a name="l01149"></a>01149 } <a name="l01150"></a>01150 <span class="keywordflow">return</span> QDateTime(); <a name="l01151"></a>01151 } <a name="l01152"></a>01152 <a name="l01153"></a>01153 RecurrenceRule::Constraint RecurrenceRule::getPreviousValidDateInterval( <span class="keyword">const</span> QDateTime &preDate, <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">PeriodType</a> type )<span class="keyword"> const</span> <a name="l01154"></a>01154 <span class="keyword"></span>{ <a name="l01155"></a>01155 <span class="comment">// kdDebug(5800) << " (o) getPreviousValidDateInterval after " << preDate << ", type=" << type << endl;</span> <a name="l01156"></a>01156 <span class="keywordtype">long</span> periods = 0; <a name="l01157"></a>01157 QDateTime nextValid = <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>(); <a name="l01158"></a>01158 QDateTime start = <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>(); <a name="l01159"></a>01159 <span class="keywordtype">int</span> modifier = 1; <a name="l01160"></a>01160 QDateTime toDate( preDate ); <a name="l01161"></a>01161 <span class="comment">// for super-daily recurrences, don't care about the time part</span> <a name="l01162"></a>01162 <a name="l01163"></a>01163 <span class="comment">// Find the #intervals since the dtstart and round to the next multiple of</span> <a name="l01164"></a>01164 <span class="comment">// the frequency</span> <a name="l01165"></a>01165 <span class="comment">// FIXME: All sub-daily periods need to convert to UTC, do the calculations</span> <a name="l01166"></a>01166 <span class="comment">// in UTC, then convert back to the local time zone. Otherwise,</span> <a name="l01167"></a>01167 <span class="comment">// recurrences across DST changes will be determined wrongly</span> <a name="l01168"></a>01168 <span class="keywordflow">switch</span> ( type ) { <a name="l01169"></a>01169 <span class="comment">// Really fall through for sub-daily, since the calculations only differ</span> <a name="l01170"></a>01170 <span class="comment">// by the factor 60 and 60*60! Same for weekly and daily (factor 7)</span> <a name="l01171"></a>01171 <span class="keywordflow">case</span> rHourly: modifier *= 60; <a name="l01172"></a>01172 <span class="keywordflow">case</span> rMinutely: modifier *= 60; <a name="l01173"></a>01173 <span class="keywordflow">case</span> rSecondly: <a name="l01174"></a>01174 periods = ownSecsTo( start, toDate ) / modifier; <a name="l01175"></a>01175 <span class="comment">// round it down to the next lower multiple of frequency():</span> <a name="l01176"></a>01176 periods = ( periods / <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) * <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>(); <a name="l01177"></a>01177 nextValid = start.addSecs( modifier * periods ); <a name="l01178"></a>01178 <span class="keywordflow">break</span>; <a name="l01179"></a>01179 <a name="l01180"></a>01180 <span class="keywordflow">case</span> rWeekly: <a name="l01181"></a>01181 toDate = toDate.addDays( -(7 + toDate.date().dayOfWeek() - mWeekStart) % 7 ); <a name="l01182"></a>01182 start = start.addDays( -(7 + start.date().dayOfWeek() - mWeekStart) % 7 ); <a name="l01183"></a>01183 modifier *= 7; <a name="l01184"></a>01184 <span class="keywordflow">case</span> rDaily: <a name="l01185"></a>01185 periods = start.daysTo( toDate ) / modifier; <a name="l01186"></a>01186 <span class="comment">// round it down to the next lower multiple of frequency():</span> <a name="l01187"></a>01187 periods = ( periods / <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) * <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>(); <a name="l01188"></a>01188 nextValid = start.addDays( modifier * periods ); <a name="l01189"></a>01189 <span class="keywordflow">break</span>; <a name="l01190"></a>01190 <a name="l01191"></a>01191 <span class="keywordflow">case</span> rMonthly: { <a name="l01192"></a>01192 periods = 12*( toDate.date().year() - start.date().year() ) + <a name="l01193"></a>01193 ( toDate.date().month() - start.date().month() ); <a name="l01194"></a>01194 <span class="comment">// round it down to the next lower multiple of frequency():</span> <a name="l01195"></a>01195 periods = ( periods / <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) * <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>(); <a name="l01196"></a>01196 <span class="comment">// set the day to the first day of the month, so we don't have problems</span> <a name="l01197"></a>01197 <span class="comment">// with non-existent days like Feb 30 or April 31</span> <a name="l01198"></a>01198 start.setDate( QDate( start.date().year(), start.date().month(), 1 ) ); <a name="l01199"></a>01199 nextValid.setDate( start.date().addMonths( periods ) ); <a name="l01200"></a>01200 <span class="keywordflow">break</span>; } <a name="l01201"></a>01201 <span class="keywordflow">case</span> rYearly: <a name="l01202"></a>01202 periods = ( toDate.date().year() - start.date().year() ); <a name="l01203"></a>01203 <span class="comment">// round it down to the next lower multiple of frequency():</span> <a name="l01204"></a>01204 periods = ( periods / <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) * <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>(); <a name="l01205"></a>01205 nextValid.setDate( start.date().addYears( periods ) ); <a name="l01206"></a>01206 <span class="keywordflow">break</span>; <a name="l01207"></a>01207 <span class="keywordflow">default</span>: <a name="l01208"></a>01208 <span class="keywordflow">break</span>; <a name="l01209"></a>01209 } <a name="l01210"></a>01210 <span class="comment">// kdDebug(5800) << " ~~~> date in previous interval is: : " << nextValid << endl;</span> <a name="l01211"></a>01211 <a name="l01212"></a>01212 <span class="keywordflow">return</span> Constraint( nextValid, type, mWeekStart ); <a name="l01213"></a>01213 } <a name="l01214"></a>01214 <a name="l01215"></a>01215 RecurrenceRule::Constraint RecurrenceRule::getNextValidDateInterval( <span class="keyword">const</span> QDateTime &preDate, <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">PeriodType</a> type )<span class="keyword"> const</span> <a name="l01216"></a>01216 <span class="keyword"></span>{ <a name="l01217"></a>01217 <span class="comment">// TODO: Simplify this!</span> <a name="l01218"></a>01218 kdDebug(5800) << <span class="stringliteral">" (o) getNextValidDateInterval after "</span> << preDate << <span class="stringliteral">", type="</span> << type << endl; <a name="l01219"></a>01219 <span class="keywordtype">long</span> periods = 0; <a name="l01220"></a>01220 QDateTime start = <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>(); <a name="l01221"></a>01221 QDateTime nextValid( start ); <a name="l01222"></a>01222 <span class="keywordtype">int</span> modifier = 1; <a name="l01223"></a>01223 QDateTime toDate( preDate ); <a name="l01224"></a>01224 <span class="comment">// for super-daily recurrences, don't care about the time part</span> <a name="l01225"></a>01225 <a name="l01226"></a>01226 <span class="comment">// Find the #intervals since the dtstart and round to the next multiple of</span> <a name="l01227"></a>01227 <span class="comment">// the frequency</span> <a name="l01228"></a>01228 <span class="comment">// FIXME: All sub-daily periods need to convert to UTC, do the calculations</span> <a name="l01229"></a>01229 <span class="comment">// in UTC, then convert back to the local time zone. Otherwise,</span> <a name="l01230"></a>01230 <span class="comment">// recurrences across DST changes will be determined wrongly</span> <a name="l01231"></a>01231 <span class="keywordflow">switch</span> ( type ) { <a name="l01232"></a>01232 <span class="comment">// Really fall through for sub-daily, since the calculations only differ</span> <a name="l01233"></a>01233 <span class="comment">// by the factor 60 and 60*60! Same for weekly and daily (factor 7)</span> <a name="l01234"></a>01234 <span class="keywordflow">case</span> rHourly: modifier *= 60; <a name="l01235"></a>01235 <span class="keywordflow">case</span> rMinutely: modifier *= 60; <a name="l01236"></a>01236 <span class="keywordflow">case</span> rSecondly: <a name="l01237"></a>01237 periods = ownSecsTo( start, toDate ) / modifier; <a name="l01238"></a>01238 periods = QMAX( 0, periods); <a name="l01239"></a>01239 <span class="keywordflow">if</span> ( periods > 0 ) <a name="l01240"></a>01240 periods += ( <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() - 1 - ( (periods - 1) % <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) ); <a name="l01241"></a>01241 nextValid = start.addSecs( modifier * periods ); <a name="l01242"></a>01242 <span class="keywordflow">break</span>; <a name="l01243"></a>01243 <a name="l01244"></a>01244 <span class="keywordflow">case</span> rWeekly: <a name="l01245"></a>01245 <span class="comment">// correct both start date and current date to start of week</span> <a name="l01246"></a>01246 toDate = toDate.addDays( -(7 + toDate.date().dayOfWeek() - mWeekStart) % 7 ); <a name="l01247"></a>01247 start = start.addDays( -(7 + start.date().dayOfWeek() - mWeekStart) % 7 ); <a name="l01248"></a>01248 modifier *= 7; <a name="l01249"></a>01249 <span class="keywordflow">case</span> rDaily: <a name="l01250"></a>01250 periods = start.daysTo( toDate ) / modifier; <a name="l01251"></a>01251 periods = QMAX( 0, periods); <a name="l01252"></a>01252 <span class="keywordflow">if</span> ( periods > 0 ) <a name="l01253"></a>01253 periods += (<a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() - 1 - ( (periods - 1) % <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) ); <a name="l01254"></a>01254 nextValid = start.addDays( modifier * periods ); <a name="l01255"></a>01255 <span class="keywordflow">break</span>; <a name="l01256"></a>01256 <a name="l01257"></a>01257 <span class="keywordflow">case</span> rMonthly: { <a name="l01258"></a>01258 periods = 12*( toDate.date().year() - start.date().year() ) + <a name="l01259"></a>01259 ( toDate.date().month() - start.date().month() ); <a name="l01260"></a>01260 periods = QMAX( 0, periods); <a name="l01261"></a>01261 <span class="keywordflow">if</span> ( periods > 0 ) <a name="l01262"></a>01262 periods += (<a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() - 1 - ( (periods - 1) % <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) ); <a name="l01263"></a>01263 <span class="comment">// set the day to the first day of the month, so we don't have problems</span> <a name="l01264"></a>01264 <span class="comment">// with non-existent days like Feb 30 or April 31</span> <a name="l01265"></a>01265 start.setDate( QDate( start.date().year(), start.date().month(), 1 ) ); <a name="l01266"></a>01266 nextValid.setDate( start.date().addMonths( periods ) ); <a name="l01267"></a>01267 <span class="keywordflow">break</span>; } <a name="l01268"></a>01268 <span class="keywordflow">case</span> rYearly: <a name="l01269"></a>01269 periods = ( toDate.date().year() - start.date().year() ); <a name="l01270"></a>01270 periods = QMAX( 0, periods); <a name="l01271"></a>01271 <span class="keywordflow">if</span> ( periods > 0 ) <a name="l01272"></a>01272 periods += ( <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() - 1 - ( (periods - 1) % <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() ) ); <a name="l01273"></a>01273 nextValid.setDate( start.date().addYears( periods ) ); <a name="l01274"></a>01274 <span class="keywordflow">break</span>; <a name="l01275"></a>01275 <span class="keywordflow">default</span>: <a name="l01276"></a>01276 <span class="keywordflow">break</span>; <a name="l01277"></a>01277 } <a name="l01278"></a>01278 <span class="comment">// kdDebug(5800) << " ~~~> date in next interval is: : " << nextValid << endl;</span> <a name="l01279"></a>01279 <a name="l01280"></a>01280 <span class="keywordflow">return</span> Constraint( nextValid, type, mWeekStart ); <a name="l01281"></a>01281 } <a name="l01282"></a>01282 <a name="l01283"></a>01283 <span class="keywordtype">bool</span> RecurrenceRule::mergeIntervalConstraint( Constraint *merged, <a name="l01284"></a>01284 <span class="keyword">const</span> Constraint &conit, <span class="keyword">const</span> Constraint &interval )<span class="keyword"> const</span> <a name="l01285"></a>01285 <span class="keyword"></span>{ <a name="l01286"></a>01286 Constraint result( interval ); <a name="l01287"></a>01287 <a name="l01288"></a>01288 <span class="preprocessor">#define mergeConstraint( name, cmparison ) \</span> <a name="l01289"></a>01289 <span class="preprocessor"> if ( conit.name cmparison ) { \</span> <a name="l01290"></a>01290 <span class="preprocessor"> if ( !(result.name cmparison) || result.name == conit.name ) { \</span> <a name="l01291"></a>01291 <span class="preprocessor"> result.name = conit.name; \</span> <a name="l01292"></a>01292 <span class="preprocessor"> } else return false;\</span> <a name="l01293"></a>01293 <span class="preprocessor"> }</span> <a name="l01294"></a>01294 <span class="preprocessor"></span> <a name="l01295"></a>01295 mergeConstraint( year, > 0 ); <a name="l01296"></a>01296 mergeConstraint( month, > 0 ); <a name="l01297"></a>01297 mergeConstraint( day, != 0 ); <a name="l01298"></a>01298 mergeConstraint( hour, >= 0 ); <a name="l01299"></a>01299 mergeConstraint( minute, >= 0 ); <a name="l01300"></a>01300 mergeConstraint( second, >= 0 ); <a name="l01301"></a>01301 <a name="l01302"></a>01302 mergeConstraint( weekday, != 0 ); <a name="l01303"></a>01303 mergeConstraint( weekdaynr, != 0 ); <a name="l01304"></a>01304 mergeConstraint( weeknumber, != 0 ); <a name="l01305"></a>01305 mergeConstraint( yearday, != 0 ); <a name="l01306"></a>01306 <a name="l01307"></a>01307 <span class="preprocessor"> #undef mergeConstraint</span> <a name="l01308"></a>01308 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( merged ) *merged = result; <a name="l01309"></a>01309 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01310"></a>01310 } <a name="l01311"></a>01311 <a name="l01312"></a>01312 <a name="l01313"></a>01313 DateTimeList RecurrenceRule::datesForInterval( <span class="keyword">const</span> Constraint &interval, <a class="code" href="classKCal_1_1RecurrenceRule.html#d67adb9f784863d1ecdba2392a2f6bbf" title="enum for describing the frequency how an event recurs, if at all.">PeriodType</a> type )<span class="keyword"> const</span> <a name="l01314"></a>01314 <span class="keyword"></span>{ <a name="l01315"></a>01315 <span class="comment">/* -) Loop through constraints,</span> <a name="l01316"></a>01316 <span class="comment"> -) merge interval with each constraint</span> <a name="l01317"></a>01317 <span class="comment"> -) if merged constraint is not consistent => ignore that constraint</span> <a name="l01318"></a>01318 <span class="comment"> -) if complete => add that one date to the date list</span> <a name="l01319"></a>01319 <span class="comment"> -) Loop through all missing fields => For each add the resulting</span> <a name="l01320"></a>01320 <span class="comment"> */</span> <a name="l01321"></a>01321 <span class="comment">// kdDebug(5800) << " RecurrenceRule::datesForInterval: " << endl;</span> <a name="l01322"></a>01322 <span class="comment">// interval.dump();</span> <a name="l01323"></a>01323 DateTimeList lst; <a name="l01324"></a>01324 Constraint::List::ConstIterator conit = mConstraints.begin(); <a name="l01325"></a>01325 <span class="keywordflow">for</span> ( ; conit != mConstraints.end(); ++conit ) { <a name="l01326"></a>01326 Constraint merged; <a name="l01327"></a>01327 <span class="keywordtype">bool</span> mergeok = mergeIntervalConstraint( &merged, *conit, interval ); <a name="l01328"></a>01328 <span class="comment">// If the information is incomplete, we can't use this constraint</span> <a name="l01329"></a>01329 <span class="keywordflow">if</span> ( merged.year <= 0 || merged.hour < 0 || merged.minute < 0 || merged.second < 0 ) <a name="l01330"></a>01330 mergeok = <span class="keyword">false</span>; <a name="l01331"></a>01331 <span class="keywordflow">if</span> ( mergeok ) { <a name="l01332"></a>01332 <span class="comment">// kdDebug(5800) << " -) merged constraint: " << endl;</span> <a name="l01333"></a>01333 <span class="comment">// merged.dump();</span> <a name="l01334"></a>01334 <span class="comment">// We have a valid constraint, so get all datetimes that match it andd</span> <a name="l01335"></a>01335 <span class="comment">// append it to all date/times of this interval</span> <a name="l01336"></a>01336 DateTimeList lstnew = merged.dateTimes( type ); <a name="l01337"></a>01337 lst += lstnew; <a name="l01338"></a>01338 } <a name="l01339"></a>01339 } <a name="l01340"></a>01340 <span class="comment">// Sort it so we can apply the BySetPos. Also some logic relies on this being sorted</span> <a name="l01341"></a>01341 qSortUnique( lst ); <a name="l01342"></a>01342 <a name="l01343"></a>01343 <a name="l01344"></a>01344 <span class="comment">/*if ( lst.isEmpty() ) {</span> <a name="l01345"></a>01345 <span class="comment"> kdDebug(5800) << " No Dates in Interval " << endl;</span> <a name="l01346"></a>01346 <span class="comment">} else {</span> <a name="l01347"></a>01347 <span class="comment"> kdDebug(5800) << " Dates: " << endl;</span> <a name="l01348"></a>01348 <span class="comment"> for ( DateTimeList::Iterator it = lst.begin(); it != lst.end(); ++it ) {</span> <a name="l01349"></a>01349 <span class="comment"> kdDebug(5800)<< " -) " << (*it).toString() << endl;</span> <a name="l01350"></a>01350 <span class="comment"> }</span> <a name="l01351"></a>01351 <span class="comment"> kdDebug(5800) << " ---------------------" << endl;</span> <a name="l01352"></a>01352 <span class="comment">}*/</span> <a name="l01353"></a>01353 <span class="keywordflow">if</span> ( !mBySetPos.isEmpty() ) { <a name="l01354"></a>01354 DateTimeList tmplst = lst; <a name="l01355"></a>01355 lst.clear(); <a name="l01356"></a>01356 QValueList<int>::ConstIterator it; <a name="l01357"></a>01357 <span class="keywordflow">for</span> ( it = mBySetPos.begin(); it != mBySetPos.end(); ++it ) { <a name="l01358"></a>01358 <span class="keywordtype">int</span> pos = *it; <a name="l01359"></a>01359 <span class="keywordflow">if</span> ( pos > 0 ) --pos; <a name="l01360"></a>01360 <span class="keywordflow">if</span> ( pos < 0 ) pos += tmplst.count(); <a name="l01361"></a>01361 <span class="keywordflow">if</span> ( pos >= 0 && uint(pos) < tmplst.count() ) { <a name="l01362"></a>01362 lst.append( tmplst[pos] ); <a name="l01363"></a>01363 } <a name="l01364"></a>01364 } <a name="l01365"></a>01365 qSortUnique( lst ); <a name="l01366"></a>01366 } <a name="l01367"></a>01367 <a name="l01368"></a>01368 <span class="keywordflow">return</span> lst; <a name="l01369"></a>01369 } <a name="l01370"></a>01370 <a name="l01371"></a>01371 <a name="l01372"></a><a class="code" href="classKCal_1_1RecurrenceRule.html#bdccbc70c31c09700a49c03cbc7b608c">01372</a> <span class="keywordtype">void</span> <a class="code" href="classKCal_1_1RecurrenceRule.html#bdccbc70c31c09700a49c03cbc7b608c" title="Debug output.">RecurrenceRule::dump</a>()<span class="keyword"> const</span> <a name="l01373"></a>01373 <span class="keyword"></span>{ <a name="l01374"></a>01374 <span class="preprocessor">#ifndef NDEBUG</span> <a name="l01375"></a>01375 <span class="preprocessor"></span> kdDebug(5800) << <span class="stringliteral">"RecurrenceRule::dump():"</span> << endl; <a name="l01376"></a>01376 <span class="keywordflow">if</span> ( !mRRule.isEmpty() ) <a name="l01377"></a>01377 kdDebug(5800) << <span class="stringliteral">" RRULE="</span> << mRRule << endl; <a name="l01378"></a>01378 kdDebug(5800) << <span class="stringliteral">" Read-Only: "</span> << <a class="code" href="classKCal_1_1RecurrenceRule.html#d5f19086670b73c0ef6b2b98a40633ac" title="Returns true if the recurrence is read-only, or false if it can be changed.">isReadOnly</a>() << <a name="l01379"></a>01379 <span class="stringliteral">", dirty: "</span> << mDirty << endl; <a name="l01380"></a>01380 <a name="l01381"></a>01381 kdDebug(5800) << <span class="stringliteral">" Period type: "</span> << recurrenceType() << <span class="stringliteral">", frequency: "</span> << <a class="code" href="classKCal_1_1RecurrenceRule.html#fbc5baf7391035f00297190d63f29e0b" title="Returns frequency of recurrence, in terms of the recurrence time period type.">frequency</a>() << endl; <a name="l01382"></a>01382 kdDebug(5800) << <span class="stringliteral">" #occurrences: "</span> << <a class="code" href="classKCal_1_1RecurrenceRule.html#6e56f222c2940c4577e73dba47d300d3" title="Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the...">duration</a>() << endl; <a name="l01383"></a>01383 kdDebug(5800) << <span class="stringliteral">" start date: "</span> << <a class="code" href="classKCal_1_1RecurrenceRule.html#6ed2cdc26c2a0f0d3996dd75b7e2d5f9" title="Return the start of the recurrence.">startDt</a>() <<<span class="stringliteral">", end date: "</span> << <a class="code" href="classKCal_1_1RecurrenceRule.html#6949836f246e298e23e9140dbb406954" title="Returns the date and time of the last recurrence.">endDt</a>() << endl; <a name="l01384"></a>01384 <a name="l01385"></a>01385 <a name="l01386"></a>01386 <span class="preprocessor">#define dumpByIntList(list,label) \</span> <a name="l01387"></a>01387 <span class="preprocessor"> if ( !list.isEmpty() ) {\</span> <a name="l01388"></a>01388 <span class="preprocessor"> QStringList lst;\</span> <a name="l01389"></a>01389 <span class="preprocessor"> for ( QValueList<int>::ConstIterator it = list.begin();\</span> <a name="l01390"></a>01390 <span class="preprocessor"> it != list.end(); ++it ) {\</span> <a name="l01391"></a>01391 <span class="preprocessor"> lst.append( QString::number( *it ) );\</span> <a name="l01392"></a>01392 <span class="preprocessor"> }\</span> <a name="l01393"></a>01393 <span class="preprocessor"> kdDebug(5800) << " " << label << lst.join(", ") << endl;\</span> <a name="l01394"></a>01394 <span class="preprocessor"> }</span> <a name="l01395"></a>01395 <span class="preprocessor"></span> dumpByIntList( mBySeconds, <span class="stringliteral">"BySeconds: "</span> ); <a name="l01396"></a>01396 dumpByIntList( mByMinutes, <span class="stringliteral">"ByMinutes: "</span> ); <a name="l01397"></a>01397 dumpByIntList( mByHours, <span class="stringliteral">"ByHours: "</span> ); <a name="l01398"></a>01398 <span class="keywordflow">if</span> ( !mByDays.isEmpty() ) { <a name="l01399"></a>01399 QStringList lst; <a name="l01400"></a>01400 <span class="keywordflow">for</span> ( QValueList<WDayPos>::ConstIterator it = mByDays.begin(); <a name="l01401"></a>01401 it != mByDays.end(); ++it ) { <a name="l01402"></a>01402 lst.append( ( ((*it).pos()!=0) ? QString::number( (*it).pos() ) : <span class="stringliteral">""</span> ) + <a name="l01403"></a>01403 DateHelper::dayName( (*it).day() ) ); <a name="l01404"></a>01404 } <a name="l01405"></a>01405 kdDebug(5800) << <span class="stringliteral">" ByDays: "</span> << lst.join(<span class="stringliteral">", "</span>) << endl; <a name="l01406"></a>01406 } <a name="l01407"></a>01407 dumpByIntList( mByMonthDays, <span class="stringliteral">"ByMonthDays:"</span> ); <a name="l01408"></a>01408 dumpByIntList( mByYearDays, <span class="stringliteral">"ByYearDays: "</span> ); <a name="l01409"></a>01409 dumpByIntList( mByWeekNumbers,<span class="stringliteral">"ByWeekNr: "</span> ); <a name="l01410"></a>01410 dumpByIntList( mByMonths, <span class="stringliteral">"ByMonths: "</span> ); <a name="l01411"></a>01411 dumpByIntList( mBySetPos, <span class="stringliteral">"BySetPos: "</span> ); <a name="l01412"></a>01412 <span class="preprocessor"> #undef dumpByIntList</span> <a name="l01413"></a>01413 <span class="preprocessor"></span> <a name="l01414"></a>01414 kdDebug(5800) << <span class="stringliteral">" Week start: "</span> << DateHelper::dayName( mWeekStart ) << endl; <a name="l01415"></a>01415 <a name="l01416"></a>01416 kdDebug(5800) << <span class="stringliteral">" Constraints:"</span> << endl; <a name="l01417"></a>01417 <span class="comment">// dump constraints</span> <a name="l01418"></a>01418 <span class="keywordflow">for</span> ( Constraint::List::ConstIterator it = mConstraints.begin(); <a name="l01419"></a>01419 it!=mConstraints.end(); ++it ) { <a name="l01420"></a>01420 (*it).dump(); <a name="l01421"></a>01421 } <a name="l01422"></a>01422 <span class="preprocessor">#endif</span> <a name="l01423"></a>01423 <span class="preprocessor"></span>} <a name="l01424"></a>01424 <a name="l01425"></a>01425 <span class="keywordtype">void</span> RecurrenceRule::Constraint::dump()<span class="keyword"> const</span> <a name="l01426"></a>01426 <span class="keyword"></span>{ <a name="l01427"></a>01427 kdDebug(5800) << <span class="stringliteral">" ~> Y="</span><<year<<<span class="stringliteral">", M="</span><<month<<<span class="stringliteral">", D="</span><<day<<<span class="stringliteral">", H="</span><<hour<<<span class="stringliteral">", m="</span><<minute<<<span class="stringliteral">", S="</span><<second<<<span class="stringliteral">", wd="</span><<weekday<<<span class="stringliteral">",#wd="</span><<weekdaynr<<<span class="stringliteral">", #w="</span><<weeknumber<<<span class="stringliteral">", yd="</span><<yearday<<endl; <a name="l01428"></a>01428 } </pre></div></div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>libkcal</h2> <div class="nav_list"> <ul><li><a href="index.html">Main Page</a></li><li><a href="namespaces.html">Namespace List</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="namespacemembers.html">Namespace Members</a></li><li><a href="functions.html">Class Members</a></li></ul> <!-- <h2>Class Picker</h2> <div style="text-align: center;"> <form name="guideform"> <select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option value="annotated.html">-- Choose --</option> <option value="classKCal_1_1Alarm.html">kcal::alarm</option>, <option value="classKCal_1_1Attachment.html">kcal::attachment</option>, <option value="classKCal_1_1Attendee.html">kcal::attendee</option>, <option value="classKCal_1_1Calendar.html">kcal::calendar</option>, <option value="classKCal_1_1Calendar_1_1Observer.html">kcal::calendar::observer</option>, <option value="classKCal_1_1CalendarLocal.html">kcal::calendarlocal</option>, <option value="classKCal_1_1CalendarNull.html">kcal::calendarnull</option>, <option value="classKCal_1_1CalendarResources.html">kcal::calendarresources</option>, <option value="classKCal_1_1CalFilter.html">kcal::calfilter</option>, <option value="classKCal_1_1CalFormat.html">kcal::calformat</option>, <option value="classKCal_1_1CalStorage.html">kcal::calstorage</option>, <option value="classKCal_1_1Compat.html">kcal::compat</option>, <option value="classKCal_1_1CompatFactory.html">kcal::compatfactory</option>, <option value="classKCal_1_1CustomProperties.html">kcal::customproperties</option>, <option value="classKCal_1_1DndFactory.html">kcal::dndfactory</option>, <option value="classKCal_1_1Duration.html">kcal::duration</option>, <option value="classKCal_1_1ErrorFormat.html">kcal::errorformat</option>, <option value="classKCal_1_1Event.html">kcal::event</option>, <option value="classKCal_1_1Exception.html">kcal::exception</option>, <option value="classKCal_1_1FileStorage.html">kcal::filestorage</option>, <option value="classKCal_1_1FreeBusy.html">kcal::freebusy</option>, <option value="classKCal_1_1HtmlExport.html">kcal::htmlexport</option>, <option value="classKCal_1_1ICalDrag.html">kcal::icaldrag</option>, <option value="classKCal_1_1ICalFormat.html">kcal::icalformat</option>, <option value="classKCal_1_1Incidence.html">kcal::incidence</option>, <option value="classKCal_1_1Incidence_1_1AddVisitor.html">kcal::incidence::addvisitor</option>, <option value="classKCal_1_1Incidence_1_1DeleteVisitor.html">kcal::incidence::deletevisitor</option>, <option value="classKCal_1_1IncidenceBase.html">kcal::incidencebase</option>, <option value="classKCal_1_1IncidenceBase_1_1Visitor.html">kcal::incidencebase::visitor</option>, <option value="classKCal_1_1IncidenceFormatter.html">kcal::incidenceformatter</option>, <option value="classKCal_1_1Journal.html">kcal::journal</option>, <option value="classKCal_1_1ListBase.html">kcal::listbase</option>, <option value="classKCal_1_1Period.html">kcal::period</option>, <option value="classKCal_1_1Person.html">kcal::person</option>, <option value="classKCal_1_1QtopiaFormat.html">kcal::qtopiaformat</option>, <option value="classKCal_1_1Recurrence.html">kcal::recurrence</option>, <option value="classKCal_1_1RecurrenceRule.html">kcal::recurrencerule</option>, <option value="classKCal_1_1RecurrenceRule_1_1WDayPos.html">kcal::recurrencerule::wdaypos</option>, <option value="classKCal_1_1ResourceCached.html">kcal::resourcecached</option>, <option value="classKCal_1_1ResourceCachedReloadConfig.html">kcal::resourcecachedreloadconfig</option>, <option value="classKCal_1_1ResourceCachedSaveConfig.html">kcal::resourcecachedsaveconfig</option>, <option value="classKCal_1_1ResourceCalendar.html">kcal::resourcecalendar</option>, <option value="classKCal_1_1ResourceLocal.html">kcal::resourcelocal</option>, <option value="classKCal_1_1ResourceLocalConfig.html">kcal::resourcelocalconfig</option>, <option value="classKCal_1_1ScheduleMessage.html">kcal::schedulemessage</option>, <option value="classKCal_1_1Scheduler.html">kcal::scheduler</option>, <option value="classKCal_1_1Todo.html">kcal::todo</option>, <option value="classKCal_1_1VCalDrag.html">kcal::vcaldrag</option>, <option value="classKCal_1_1VCalFormat.html">kcal::vcalformat</option>, </select> </form> </div> --> </div></div> <div class="menu_box"><h2>API Dox</h2> <div class="nav_list"> <ul> <li><a href="../../akregator/html/index.html">akregator</a></li><li> <a href="../../akregator/src/html/index.html">src</a></li><li> <a href="../../akregator/src/librss/html/index.html">librss</a></li><li><a href="../../certmanager/html/index.html">certmanager</a></li><li> <a href="../../certmanager/lib/html/index.html">lib</a></li><li><a href="../../kaddressbook/html/index.html">kaddressbook</a></li><li><a href="../../kalarm/html/index.html">kalarm</a></li><li> <a href="../../kalarm/lib/html/index.html">lib</a></li><li><a href="../../kandy/html/index.html">kandy</a></li><li><a href="../../karm/html/index.html">karm</a></li><li><a href="../../kdgantt/html/index.html">kdgantt</a></li><li><a href="../../kgantt/html/index.html">kgantt</a></li><li><a href="../../kioslaves/html/index.html">kioslaves</a></li><li> <a href="../../kioslaves/imap4/html/index.html">imap4</a></li><li> <a href="../../kioslaves/mbox/html/index.html">mbox</a></li><li><a href="../../kitchensync/html/index.html">kitchensync</a></li><li><a href="../../kmail/html/index.html">kmail</a></li><li><a href="../../knotes/html/index.html">knotes</a></li><li><a href="../../konsolekalendar/html/index.html">konsolekalendar</a></li><li><a href="../../kontact/html/index.html">kontact</a></li><li><a href="../../korganizer/html/index.html">korganizer</a></li><li><a href="../../kpilot/html/index.html">kpilot</a></li><li> <a href="../../kpilot/kpilot/html/index.html">kpilot</a></li><li> <a href="../../kpilot/lib/html/index.html">lib</a></li><li><a href="../../libemailfunctions/html/index.html">libemailfunctions</a></li><li><a href="../../libkcal/html/index.html">libkcal</a></li><li><a href="../../libkdepim/html/index.html">libkdepim</a></li><li><a href="../../libkholidays/html/index.html">libkholidays</a></li><li><a href="../../libkmime/html/index.html">libkmime</a></li><li><a href="../../libkpgp/html/index.html">libkpgp</a></li><li><a href="../../libkpimidentities/html/index.html">libkpimidentities</a></li> </ul></div></div> </td> </tr> </table> <span class="doNotDisplay"> <a href="http://www.kde.org/" accesskey="8">KDE Home</a> | <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> | <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a> </span> <div style="height: 8px"></div> <div id="footer"> <div id="footer_left"> Maintained by <a href="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>