本文整理汇总了C++中incidence::Ptr::alarms方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::alarms方法的具体用法?C++ Ptr::alarms怎么用?C++ Ptr::alarms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类incidence::Ptr
的用法示例。
在下文中一共展示了Ptr::alarms方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: slotCalendarChanged
void AlarmDialog::slotCalendarChanged()
{
Akonadi::Item::List incidences = mCalendar->incidences();
for ( Akonadi::Item::List::ConstIterator it = incidences.constBegin();
it != incidences.constEnd(); ++it ) {
ReminderListItem *item = searchByItem( *it );
if ( item ) {
Incidence::Ptr incidence = CalendarSupport::incidence( *it );
QString displayStr;
// Yes, alarms can be empty, if someone edited the incidence and removed all alarms
if ( !incidence->alarms().isEmpty() ) {
const KDateTime dateTime = triggerDateForIncidence( incidence,
item->mRemindAt,
displayStr );
const QString summary = cleanSummary( incidence->summary() );
if ( displayStr != item->text( 1 ) || summary != item->text( 0 ) ) {
item->setText( 1, displayStr );
item->setText( 0, summary );
}
}
}
}
}
示例3: Duration
void CompatOutlook9::fixAlarms( const Incidence::Ptr &incidence )
{
if ( !incidence ) {
return;
}
Alarm::List alarms = incidence->alarms();
Alarm::List::Iterator it;
for ( it = alarms.begin(); it != alarms.end(); ++it ) {
Alarm::Ptr al = *it;
if ( al && al->hasStartOffset() ) {
Duration offsetDuration = al->startOffset();
int offs = offsetDuration.asSeconds();
if ( offs > 0 ) {
offsetDuration = Duration( -offs );
}
al->setStartOffset( offsetDuration );
}
}
}
示例4: eventNotification
void AlarmDialog::eventNotification()
{
bool beeped = false;
bool found = false;
ReminderList list;
QTreeWidgetItemIterator it( mIncidenceTree );
while ( *it ) {
ReminderListItem *item = static_cast<ReminderListItem *>( *it );
++it;
if ( item->isDisabled() || item->mNotified ) {
//skip suspended reminders or reminders that have been notified
continue;
}
found = true;
item->mNotified = true;
Incidence::Ptr incidence = CalendarSupport::incidence( item->mIncidence );
Alarm::List alarms = incidence->alarms();
Alarm::List::ConstIterator ait;
for ( ait = alarms.constBegin(); ait != alarms.constEnd(); ++ait ) {
Alarm::Ptr alarm = *ait;
// FIXME: Check whether this should be done for all multiple alarms
if ( alarm->type() == Alarm::Procedure ) {
// FIXME: Add a message box asking whether the procedure should really be executed
kDebug() << "Starting program: '" << alarm->programFile() << "'";
QString program = alarm->programFile();
// if the program name contains spaces escape it
if ( program.contains( ' ' ) &&
!( program.startsWith( '\"' ) && program.endsWith( '\"' ) ) ) {
program = '\"' + program + '\"';
}
QProcess::startDetached( program + ' ' + alarm->programArguments() );
} else if ( alarm->type() == Alarm::Audio ) {
beeped = true;
Phonon::MediaObject *player =
Phonon::createPlayer( Phonon::NotificationCategory, alarm->audioFile() );
player->setParent( this );
connect( player, SIGNAL(finished()), player, SLOT(deleteLater()) );
player->play();
} else if ( alarm->type() == Alarm::Email ) {
QString from = CalendarSupport::KCalPrefs::instance()->email();
Identity id = KOCore::self()->identityManager()->identityForAddress( from );
QString to;
if ( alarm->mailAddresses().isEmpty() ) {
to = from;
} else {
const Person::List addresses = alarm->mailAddresses();
QStringList add;
for ( Person::List::ConstIterator it = addresses.constBegin();
it != addresses.constEnd(); ++it ) {
add << (*it)->fullName();
}
to = add.join( ", " );
}
QString subject;
Akonadi::Item parentItem = mCalendar->itemForIncidenceUid( alarm->parentUid() );
Incidence::Ptr parent = CalendarSupport::incidence( parentItem );
if ( alarm->mailSubject().isEmpty() ) {
if ( parent->summary().isEmpty() ) {
subject = i18nc( "@title", "Reminder" );
} else {
subject = i18nc( "@title", "Reminder: %1", cleanSummary( parent->summary() ) );
}
} else {
subject = i18nc( "@title", "Reminder: %1", alarm->mailSubject() );
}
QString body =
IncidenceFormatter::mailBodyStr(
parent.staticCast<IncidenceBase>(), KSystemTimeZones::local() );
if ( !alarm->mailText().isEmpty() ) {
body += '\n' + alarm->mailText();
}
//TODO: support attachments
CalendarSupport::MailClient mailer;
mailer.send( id, from, to, QString(), subject, body, true, false, QString(),
MailTransport::TransportManager::self()->defaultTransportName() );
}
}
}
if ( !beeped && found ) {
KNotification::beep();
}
}