本文整理汇总了C++中incidence::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
}
}
}
}
示例2: testPasteTodo
void DndFactoryTest::testPasteTodo()
{
MemoryCalendar::Ptr calendar( new MemoryCalendar( QString() ) );
DndFactory factory( calendar );
Todo::Ptr todo( new Todo() );
todo->setSummary( QLatin1String( "Summary 1" ) );
todo->setDtDue( KDateTime( QDate( 2010, 8, 9 ) ) );
Incidence::List incidencesToPaste;
incidencesToPaste.append( todo );
QVERIFY( factory.copyIncidences( incidencesToPaste ) );
const KDateTime newDateTime( QDate( 2011, 1, 1 ), QTime( 10, 10 ) );
Incidence::List pastedIncidences = factory.pasteIncidences( newDateTime );
QVERIFY( pastedIncidences.size() == 1 );
Incidence::Ptr incidence = pastedIncidences.first();
QVERIFY( incidence->type() == Incidence::TypeTodo );
// check if a new uid was generated.
QVERIFY( incidence->uid() != todo->uid() );
Todo::Ptr pastedTodo = incidence.staticCast<Todo>();
QVERIFY( pastedTodo->dtDue() == newDateTime );
QVERIFY( pastedTodo->summary() == todo->summary() );
}
示例3: 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;
}
示例4: incidenceStatus
QString Stringify::incidenceStatus( const Incidence::Ptr &incidence )
{
if ( incidence->status() == Incidence::StatusX ) {
return incidence->customStatus();
} else {
return incidenceStatus( incidence->status() );
}
}
示例5:
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 );
}
示例6: formatCategories
void HtmlExport::formatCategories(QTextStream *ts,
const Incidence::Ptr &incidence)
{
if (!incidence->categoriesStr().isEmpty()) {
*ts << " " << cleanChars(incidence->categoriesStr()) << endl;
} else {
*ts << " " << endl;
}
}
示例7: openIncidenceEditorThroughKOrganizer
bool AlarmDialog::openIncidenceEditorThroughKOrganizer( const Incidence::Ptr &incidence )
{
if ( !QDBusConnection::sessionBus().interface()->isServiceRegistered( "org.kde.korganizer" ) ) {
if ( KToolInvocation::startServiceByDesktopName( "korganizer", QString() ) ) {
KMessageBox::error(
this,
i18nc( "@info",
"Could not start KOrganizer so editing is not possible." ) );
return false;
}
}
org::kde::korganizer::Korganizer korganizer(
"org.kde.korganizer", "/Korganizer", QDBusConnection::sessionBus() );
kDebug() << "editing incidence " << incidence->summary();
if ( !korganizer.editIncidence( incidence->uid() ) ) {
KMessageBox::error(
this,
i18nc( "@info",
"An internal KOrganizer error occurred attempting to modify \"%1\"",
cleanSummary( incidence->summary() ) ) );
}
// get desktop # where korganizer (or kontact) runs
QString object =
QDBusConnection::sessionBus().interface()->isServiceRegistered( "org.kde.kontact" ) ?
"kontact/MainWindow_1" : "korganizer/MainWindow_1";
QDBusInterface korganizerObj( "org.kde.korganizer", '/' + object );
#ifdef Q_WS_X11
QDBusReply<int> reply = korganizerObj.call( "winId" );
if ( reply.isValid() ) {
int window = reply;
int desktop = KWindowSystem::windowInfo( window, NET::WMDesktop ).desktop();
if ( KWindowSystem::currentDesktop() == desktop ) {
KWindowSystem::minimizeWindow( winId(), false );
} else {
KWindowSystem::setCurrentDesktop( desktop );
}
KWindowSystem::activateWindow( KWindowSystem::transientFor( window ) );
}
#elif defined(Q_WS_WIN)
// WId is a typedef to a void* on windows
QDBusReply<qlonglong> reply = korganizerObj.call( "winId" );
if ( reply.isValid() ) {
qlonglong window = reply;
KWindowSystem::minimizeWindow( winId(), false );
KWindowSystem::allowExternalProcessWindowActivation();
KWindowSystem::activateWindow( reinterpret_cast<WId>(window) );
}
#else
// TODO (mac)
#endif
return true;
}
示例8: createInitialIncidences
void CalendarBaseTest::createInitialIncidences()
{
mExpectedSlotResult = true;
for (int i=0; i<5; ++i) {
Event::Ptr event = Event::Ptr(new Event());
event->setUid(QStringLiteral("event") + QString::number(i));
event->setSummary(QStringLiteral("summary") + QString::number(i));
event->setDtStart(KDateTime::currentDateTime(KDateTime::UTC));
mUids.append(event->uid());
QVERIFY(mCalendar->addEvent(event));
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
}
mOneEventUid = mUids.last();
for (int i=0; i<5; ++i) {
Todo::Ptr todo = Todo::Ptr(new Todo());
todo->setUid(QStringLiteral("todo") + QString::number(i));
todo->setDtStart(KDateTime::currentDateTime(KDateTime::UTC));
todo->setSummary(QStringLiteral("summary") + QString::number(i));
mUids.append(todo->uid());
QVERIFY(mCalendar->addTodo(todo));
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
}
mOneTodoUid = mUids.last();
for (int i=0; i<5; ++i) {
Journal::Ptr journal = Journal::Ptr(new Journal());
journal->setUid(QStringLiteral("journal") + QString::number(i));
journal->setSummary(QStringLiteral("summary") + QString::number(i));
journal->setDtStart(KDateTime::currentDateTime(KDateTime::UTC));
mUids.append(journal->uid());
QVERIFY(mCalendar->addJournal(journal));
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
}
mOneJournalUid = mUids.last();
for (int i=0; i<5; ++i) {
Incidence::Ptr incidence = Incidence::Ptr(new Event());
incidence->setUid(QStringLiteral("incidence") + QString::number(i));
incidence->setSummary(QStringLiteral("summary") + QString::number(i));
incidence->setDtStart(KDateTime::currentDateTime(KDateTime::UTC));
mUids.append(incidence->uid());
QVERIFY(mCalendar->addIncidence(incidence));
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
}
mOneIncidenceUid = mUids.last();
}
示例9: addIncidence
void AlarmDialog::addIncidence( const Akonadi::Item &incidenceitem,
const QDateTime &reminderAt,
const QString &displayText )
{
Incidence::Ptr incidence = CalendarSupport::incidence( incidenceitem );
ReminderListItem *item = searchByItem( incidenceitem );
if ( !item ) {
item = new ReminderListItem( incidenceitem, mIncidenceTree );
}
item->mNotified = false;
item->mHappening = KDateTime();
item->mRemindAt = reminderAt;
item->mTrigger = KDateTime::currentLocalDateTime();
item->mDisplayText = displayText;
item->setText( 0, cleanSummary( incidence->summary() ) );
Event::Ptr event;
Todo::Ptr todo;
QString displayStr;
const KDateTime dateTime = triggerDateForIncidence( incidence, reminderAt,
displayStr );
if ( incidence->type() == Incidence::TypeEvent ) {
item->setIcon( 0, SmallIcon( "view-calendar-day" ) );
} else if ( incidence->type() == Incidence::TypeTodo ) {
item->setIcon( 0, SmallIcon( "view-calendar-tasks" ) );
}
item->mHappening = dateTime;
item->setText( 1, displayStr );
item->setText( 2, IncidenceFormatter::dateTimeToString(
item->mTrigger, false, true, KDateTime::Spec::LocalZone() ) );
QString tip =
IncidenceFormatter::toolTipStr(
CalendarSupport::displayName( mCalendar, incidenceitem.parentCollection() ),
incidence,
item->mRemindAt.date(), true,
KDateTime::Spec::LocalZone() );
if ( !item->mDisplayText.isEmpty() ) {
tip += "<br>" + item->mDisplayText;
}
item->setToolTip( 0, tip );
item->setToolTip( 1, tip );
item->setToolTip( 2, tip );
item->setData( 0, QTreeWidgetItem::UserType, false );
mIncidenceTree->setCurrentItem( item );
showDetails();
slotSave();
}
示例10: openIncidenceEditorNG
bool AlarmDialog::openIncidenceEditorNG( const Akonadi::Item &item )
{
if ( !IncidenceEditorNG::GroupwareIntegration::isActive() ) {
//TODO: Why do we need this to have a simple editor?
IncidenceEditorNG::GroupwareIntegration::activate( mCalendar );
}
Incidence::Ptr incidence = CalendarSupport::incidence( item );
IncidenceEditorNG::IncidenceDialog *dialog =
IncidenceEditorNG::IncidenceDialogFactory::create(
false, /*doesn't need initial saving*/
incidence->type(), this );
dialog->load( item );
return true;
}
示例11: calendar
void DndFactoryTest::testPasteAllDayEvent2()
{
MemoryCalendar::Ptr calendar( new MemoryCalendar( QString() ) );
DndFactory factory( calendar );
Event::Ptr allDayEvent( new Event() );
allDayEvent->setSummary( QLatin1String( "Summary 2" ) );
allDayEvent->setDtStart( KDateTime( QDate( 2010, 8, 8 ) ) );
allDayEvent->setDtEnd( KDateTime( QDate( 2010, 8, 9 ) ) );
const QString originalUid = allDayEvent->uid();
Incidence::List incidencesToPaste;
incidencesToPaste.append( allDayEvent );
QVERIFY( factory.copyIncidences( incidencesToPaste ) );
const KDateTime newDateTime( QDate( 2011, 1, 1 ) );
const uint originalLength = allDayEvent->dtStart().secsTo( allDayEvent->dtEnd() );
// paste at the new time
Incidence::List pastedIncidences = factory.pasteIncidences( newDateTime );
// we only copied one incidence
QVERIFY( pastedIncidences.size() == 1 );
Incidence::Ptr incidence = pastedIncidences.first();
QVERIFY( incidence->type() == Incidence::TypeEvent );
// check if a new uid was generated.
QVERIFY( incidence->uid() != originalUid );
// the new dateTime didn't have time component
QVERIFY( incidence->allDay() );
Event::Ptr pastedEvent = incidence.staticCast<Event>();
const uint newLength = pastedEvent->dtStart().secsTo( pastedEvent->dtEnd() );
kDebug() << "originalLength was " << originalLength << "; and newLength is "
<< newLength << "; old dtStart was " << allDayEvent->dtStart()
<< " and old dtEnd was " << allDayEvent->dtEnd() << endl
<< "; new dtStart is " << pastedEvent->dtStart()
<< " and new dtEnd is " << pastedEvent->dtEnd();
QVERIFY( originalLength == newLength );
QVERIFY( pastedEvent->dtStart() == newDateTime );
QVERIFY( pastedEvent->summary() == allDayEvent->summary() );
}
示例12: 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 );
}
示例13: fixEmptySummary
void Compat::fixEmptySummary( const Incidence::Ptr &incidence )
{
// some stupid vCal exporters ignore the standard and use Description
// instead of Summary for the default field. Correct for this: Copy the
// first line of the description to the summary (if summary is just one
// line, move it)
if ( incidence->summary().isEmpty() && !( incidence->description().isEmpty() ) ) {
QString oldDescription = incidence->description().trimmed();
QString newSummary( oldDescription );
newSummary.remove( QRegExp( "\n.*" ) );
incidence->setSummary( newSummary );
if ( oldDescription == newSummary ) {
incidence->setDescription( "" );
}
}
}
示例14: 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;
}
示例15: edit
void AlarmDialog::edit()
{
ReminderList selection = selectedItems();
if ( selection.count() != 1 ) {
return;
}
Incidence::Ptr incidence = CalendarSupport::incidence( selection.first()->mIncidence );
if ( !mCalendar->hasChangeRights( selection.first()->mIncidence ) ) {
KMessageBox::sorry(
this,
i18nc( "@info",
"\"%1\" is a read-only item so modifications are not possible.",
cleanSummary( incidence->summary() ) ) );
return;
}
#if !defined(KDEPIM_MOBILE_UI)
openIncidenceEditorNG( selection.first()->mIncidence );
#else
openIncidenceEditorThroughKOrganizer( incidence );
#endif
}