本文整理汇总了C++中incidence::Ptr::recurrence方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::recurrence方法的具体用法?C++ Ptr::recurrence怎么用?C++ Ptr::recurrence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类incidence::Ptr
的用法示例。
在下文中一共展示了Ptr::recurrence方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CompatPre32::fixRecurrence( const Incidence::Ptr &incidence )
{
Recurrence *recurrence = incidence->recurrence();
if ( recurrence->recurs() && recurrence->duration() > 0 ) {
recurrence->setDuration( recurrence->duration() + incidence->recurrence()->exDates().count() );
}
// Call base class method now that everything else is done
CompatPre35::fixRecurrence( incidence );
}
示例2: triggerDateForIncidence
/** static */
KDateTime AlarmDialog::triggerDateForIncidence( const Incidence::Ptr &incidence,
const QDateTime &reminderAt,
QString &displayStr )
{
KDateTime result;
if ( incidence->alarms().isEmpty() ) {
return result;
}
Alarm::Ptr alarm = incidence->alarms().first();
if ( incidence->recurs() ) {
result = incidence->recurrence()->getNextDateTime(
KDateTime( reminderAt, KDateTime::Spec::LocalZone( ) ) );
displayStr = KGlobal::locale()->formatDateTime( result.toLocalZone() );
}
if ( !result.isValid() ) {
result = incidence->dateTime( Incidence::RoleAlarm );
displayStr = IncidenceFormatter::dateTimeToString( result, false,
true,
KDateTime::Spec::LocalZone() );
}
return result;
}
示例3: availableOccurrences
int RecurrenceActions::availableOccurrences( const Incidence::Ptr &incidence,
const KDateTime &selectedOccurrence )
{
int result = NoOccurrence;
if ( incidence->recurrence()->recursOn( selectedOccurrence.date(),
selectedOccurrence.timeSpec() ) ) {
result |= SelectedOccurrence;
}
if ( incidence->recurrence()->getPreviousDateTime( selectedOccurrence ).isValid() ) {
result |= PastOccurrences;
}
if ( incidence->recurrence()->getNextDateTime( selectedOccurrence ).isValid() ) {
result |= FutureOccurrences;
}
return result;
}
示例4: start
void CompatPre35::fixRecurrence( const Incidence::Ptr &incidence )
{
Recurrence *recurrence = incidence->recurrence();
if ( recurrence ) {
KDateTime start( incidence->dtStart() );
// kde < 3.5 only had one rrule, so no need to loop over all RRULEs.
RecurrenceRule *r = recurrence->defaultRRule();
if ( r && !r->dateMatchesRules( start ) ) {
recurrence->addExDateTime( start );
}
}
// Call base class method now that everything else is done
Compat::fixRecurrence( incidence );
}
示例5: end
void CompatPre31::fixRecurrence( const Incidence::Ptr &incidence )
{
CompatPre32::fixRecurrence( incidence );
Recurrence *recur = incidence->recurrence();
RecurrenceRule *r = 0;
if ( recur ) {
r = recur->defaultRRule();
}
if ( recur && r ) {
int duration = r->duration();
if ( duration > 0 ) {
// Backwards compatibility for KDE < 3.1.
// rDuration was set to the number of time periods to recur,
// with week start always on a Monday.
// Convert this to the number of occurrences.
r->setDuration( -1 );
QDate end( r->startDt().date() );
bool doNothing = false;
// # of periods:
int tmp = ( duration - 1 ) * r->frequency();
switch ( r->recurrenceType() ) {
case RecurrenceRule::rWeekly:
{
end = end.addDays( tmp * 7 + 7 - end.dayOfWeek() );
break;
}
case RecurrenceRule::rMonthly:
{
int month = end.month() - 1 + tmp;
end.setDate( end.year() + month / 12, month % 12 + 1, 31 );
break;
}
case RecurrenceRule::rYearly:
{
end.setDate( end.year() + tmp, 12, 31 );
break;
}
default:
doNothing = true;
break;
}
if ( !doNothing ) {
duration = r->durationTo(
KDateTime( end, QTime( 0, 0, 0 ), incidence->dtStart().timeSpec() ) );
r->setDuration( duration );
}
}
/* addYearlyNum */
// Dates were stored as day numbers, with a fiddle to take account of
// leap years. Convert the day number to a month.
QList<int> days = r->byYearDays();
if ( !days.isEmpty() ) {
QList<int> months = r->byMonths();
for ( int i = 0; i < months.size(); ++i ) {
int newmonth =
QDate( r->startDt().date().year(), 1, 1 ).addDays( months.at( i ) - 1 ).month();
if ( !months.contains( newmonth ) ) {
months.append( newmonth );
}
}
r->setByMonths( months );
days.clear();
r->setByYearDays( days );
}
}
}
示例6: main
int main( int argc, char **argv )
{
KAboutData aboutData(
"testrecurrencenew", 0,
ki18n( "Load recurrence rules with the new class and print out debug messages" ), "0.1" );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add( "verbose", ki18n( "Verbose output" ) );
options.add( "+input", ki18n( "Name of input file" ) );
options.add( "[+output]", ki18n( "optional name of output file for the recurrence dates" ) );
KCmdLineArgs::addCmdLineOptions( options );
KComponentData componentData( &aboutData );
//QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if ( args->count() < 1 ) {
args->usage( "Wrong number of arguments." );
}
QString input = args->arg( 0 );
kDebug() << "Input file:" << input;
QTextStream *outstream;
outstream = 0;
QString fn( "" );
if ( args->count() > 1 ) {
fn = args->arg( 1 );
kDebug() << "We have a file name given:" << fn;
}
QFile outfile( fn );
if ( !fn.isEmpty() && outfile.open( QIODevice::WriteOnly ) ) {
kDebug() << "Opened output file!!!";
outstream = new QTextStream( &outfile );
}
MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
KDateTime::Spec viewSpec;
FileStorage store( cal, input );
if ( !store.load() ) return 1;
QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
if ( !tz.isEmpty() ) {
viewSpec = KDateTime::Spec( KSystemTimeZones::zone( tz ) );
}
Incidence::List inc = cal->incidences();
for ( Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it ) {
Incidence::Ptr incidence = *it;
kDebug() << "*+*+*+*+*+*+*+*+*+*";
kDebug() << " ->" << incidence->summary() << "<-";
incidence->recurrence()->dump();
KDateTime dt( incidence->recurrence()->endDateTime() );
int i = 0;
if ( outstream ) {
if ( !dt.isValid() ) {
if ( viewSpec.isValid() ) {
dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ), viewSpec );
} else {
dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ) );
}
} else {
dt = dt.addYears( 2 );
}
kDebug() << "-------------------------------------------";
kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
// Output to file for testing purposes
while ( dt.isValid() && i < 500 ) {
++i;
dt = incidence->recurrence()->getPreviousDateTime( dt );
if ( dt.isValid() ) {
(*outstream) << dumpTime( dt, viewSpec ) << endl;
}
}
} else {
if ( !dt.isValid() ) {
dt = KDateTime( QDate( 2005, 7, 31 ), QTime( 23, 59, 59 ), KDateTime::Spec::UTC() );
} else {
dt = dt.addYears( 2 );
}
incidence->recurrence()->dump();
kDebug() << "-------------------------------------------";
kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
// Output to konsole
while ( dt.isValid() && i < 50 ) {
++i;
kDebug() << "-------------------------------------------";
dt = incidence->recurrence()->getPreviousDateTime( dt );
if ( dt.isValid() ) {
kDebug() << " *~*~*~*~ Previous date is:" << dumpTime( dt, viewSpec );
}
}
}
}
//.........这里部分代码省略.........