当前位置: 首页>>代码示例>>C++>>正文


C++ Todo::setDtDue方法代码示例

本文整理汇总了C++中Todo::setDtDue方法的典型用法代码示例。如果您正苦于以下问题:C++ Todo::setDtDue方法的具体用法?C++ Todo::setDtDue怎么用?C++ Todo::setDtDue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Todo的用法示例。


在下文中一共展示了Todo::setDtDue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testRoles

void TodoTest::testRoles()
{
    const KDateTime today = KDateTime::currentUtcDateTime();
    const KDateTime yesterday = today.addDays(-1);
    Todo todo;
    todo.setDtStart(today.addDays(-1));
    todo.setDtDue(today);
    QCOMPARE(todo.dateTime(Incidence::RoleDisplayStart), today);
    QCOMPARE(todo.dateTime(Incidence::RoleDisplayEnd), today);
    todo.setDtDue(KDateTime());
    QCOMPARE(todo.dateTime(Incidence::RoleDisplayStart), yesterday);
    QCOMPARE(todo.dateTime(Incidence::RoleDisplayEnd), yesterday);
}
开发者ID:KDE,项目名称:kcalcore,代码行数:13,代码来源:testtodo.cpp

示例2: setNewDate

void KOTodoView::setNewDate( QDate date )
{
  if ( !mActiveItem || !mChanger ) return;
  Todo *todo = mActiveItem->todo();
  if ( !todo ) return;

  if ( !todo->isReadOnly() && mChanger->beginChange( todo ) ) {
    Todo *oldTodo = todo->clone();

    QDateTime dt;
    dt.setDate( date );

    if ( !todo->doesFloat() )
      dt.setTime( todo->dtDue().time() );

    if ( date.isNull() )
      todo->setHasDueDate( false );
    else if ( !todo->hasDueDate() )
      todo->setHasDueDate( true );
    todo->setDtDue( dt );

    mActiveItem->construct();
    mChanger->changeIncidence( oldTodo, todo, KOGlobals::COMPLETION_MODIFIED );
    mChanger->endChange( todo );
    delete oldTodo;
  } else {
    kdDebug(5850) << "No active item, active item is read-only, or locking failed" << endl;
  }
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例3: endDate

    Incidence * pasteIncidence( Incidence *inc,
                                const QDate &newDate,
                                const QTime *newTime = 0 )
    {
      if ( inc ) {
        inc = inc->clone();
        inc->recreate();
      }

      if ( inc && newDate.isValid() ) {
        if ( inc->type() == "Event" ) {

          Event *anEvent = static_cast<Event*>( inc );
          // Calculate length of event
          int daysOffset = anEvent->dtStart().date().daysTo(
            anEvent->dtEnd().date() );
          // new end date if event starts at the same time on the new day
          KDateTime endDate( anEvent->dtEnd() );
          endDate.setDate( newDate.addDays( daysOffset ) );

          KDateTime startDate( anEvent->dtStart() );
          startDate.setDate( newDate );
          if ( newTime ) {
            // additional offset for new time of day
            int addSecsOffset( anEvent->dtStart().time().secsTo( *newTime ) );
            endDate=endDate.addSecs( addSecsOffset );
            startDate.setTime( *newTime );
          }
          anEvent->setDtStart( startDate );
          anEvent->setDtEnd( endDate );

        } else if ( inc->type() == "Todo" ) {
          Todo *anTodo = static_cast<Todo*>( inc );
          KDateTime dueDate( anTodo->dtDue() );
          dueDate.setDate( newDate );
          if ( newTime ) {
            dueDate.setTime( *newTime );
          }
          anTodo->setDtDue( dueDate );
        } else if ( inc->type() == "Journal" ) {
          Journal *anJournal = static_cast<Journal*>( inc );
          KDateTime startDate( anJournal->dtStart() );
          startDate.setDate( newDate );
          if ( newTime ) {
            startDate.setTime( *newTime );
          } else {
            startDate.setTime( QTime( 0, 0, 0 ) );
          }
          anJournal->setDtStart( startDate );
        } else {
          kDebug() << "Trying to paste unknown incidence of type" << inc->type();
        }
      }

      return inc;
    }
开发者ID:pvuorela,项目名称:kcalcore,代码行数:56,代码来源:dndfactory.cpp

示例4: testValidity

void TodoTest::testValidity()
{
    QDate dt = QDate::currentDate();
    Todo *todo = new Todo();
    todo->setDtStart(KDateTime(dt));
    todo->setDtDue(KDateTime(dt).addDays(1));
    todo->setSummary(QStringLiteral("To-do1 Summary"));
    todo->setDescription(QStringLiteral("This is a description of the first to-do"));
    todo->setLocation(QStringLiteral("the place"));
    todo->setPercentComplete(5);
    //KDE5: QVERIFY( todo->typeStr() == i18n( "to-do" ) );
    QVERIFY(todo->summary() == QLatin1String("To-do1 Summary"));
    QVERIFY(todo->location() == QLatin1String("the place"));
    QVERIFY(todo->percentComplete() == 5);
}
开发者ID:KDE,项目名称:kcalcore,代码行数:15,代码来源:testtodo.cpp

示例5: copyTodoToDate

void KOTodoView::copyTodoToDate( QDate date )
{
  QDateTime dt( date );

  if ( mActiveItem && mChanger ) {
    Todo *newTodo = mActiveItem->todo()->clone();
    newTodo->recreate();

   newTodo->setHasDueDate( !date.isNull() );
   newTodo->setDtDue( dt );
   newTodo->setPercentComplete( 0 );

   // avoid forking
   if ( newTodo->doesRecur() )
     newTodo->recurrence()->unsetRecurs();

   mChanger->addIncidence( newTodo, this );
 }
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例6: start

/** Dissociate a single occurrence or all future occurrences from a recurring sequence.
    The new incidence is returned, but not automatically inserted into the calendar,
    which is left to the calling application */
Incidence *Calendar::dissociateOccurrence(Incidence *incidence, QDate date,
        bool single)
{
    if(!incidence || !incidence->doesRecur())
        return 0;

    Incidence *newInc = incidence->clone();
    newInc->recreate();
    newInc->setRelatedTo(incidence);
    Recurrence *recur = newInc->recurrence();
    if(single)
    {
        recur->clear();
    }
    else
    {
        // Adjust the recurrence for the future incidences. In particular
        // adjust the "end after n occurrences" rules! "No end date" and "end by ..."
        // don't need to be modified.
        int duration = recur->duration();
        if(duration > 0)
        {
            int doneduration = recur->durationTo(date.addDays(-1));
            if(doneduration >= duration)
            {
                kdDebug(5850) << "The dissociated event already occurred more often "
                              << "than it was supposed to ever occur. ERROR!" << endl;
                recur->clear();
            }
            else
            {
                recur->setDuration(duration - doneduration);
            }
        }
    }
    // Adjust the date of the incidence
    if(incidence->type() == "Event")
    {
        Event *ev = static_cast<Event *>(newInc);
        QDateTime start(ev->dtStart());
        int daysTo = start.date().daysTo(date);
        ev->setDtStart(start.addDays(daysTo));
        ev->setDtEnd(ev->dtEnd().addDays(daysTo));
    }
    else if(incidence->type() == "Todo")
    {
        Todo *td = static_cast<Todo *>(newInc);
        bool haveOffset = false;
        int daysTo = 0;
        if(td->hasDueDate())
        {
            QDateTime due(td->dtDue());
            daysTo = due.date().daysTo(date);
            td->setDtDue(due.addDays(daysTo), true);
            haveOffset = true;
        }
        if(td->hasStartDate())
        {
            QDateTime start(td->dtStart());
            if(!haveOffset)
                daysTo = start.date().daysTo(date);
            td->setDtStart(start.addDays(daysTo));
            haveOffset = true;
        }
    }
    recur = incidence->recurrence();
    if(recur)
    {
        if(single)
        {
            recur->addExDate(date);
        }
        else
        {
            // Make sure the recurrence of the past events ends
            // at the corresponding day
            recur->setEndDate(date.addDays(-1));
        }
    }
    return newInc;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:84,代码来源:calendar.cpp


注:本文中的Todo::setDtDue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。