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


C++ List::begin方法代码示例

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


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

示例1: deleteIncidences

void EventArchiver::deleteIncidences(Calendar *calendar, const QDate &limitDate, QWidget *widget, const Incidence::List &incidences, bool withGUI)
{
    QStringList incidenceStrs;
    Incidence::List::ConstIterator it;
    for(it = incidences.begin(); it != incidences.end(); ++it)
    {
        incidenceStrs.append((*it)->summary());
    }

    if(withGUI)
    {
        int result = KMessageBox::warningContinueCancelList(
                         widget, i18n("Delete all items before %1 without saving?\n"
                                      "The following items will be deleted:")
                         .arg(KGlobal::locale()->formatDate(limitDate)), incidenceStrs,
                         i18n("Delete Old Items"), KStdGuiItem::del());
        if(result != KMessageBox::Continue)
            return;
    }
    for(it = incidences.begin(); it != incidences.end(); ++it)
    {
        calendar->deleteIncidence(*it);
    }
    emit eventsDeleted();
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:25,代码来源:eventarchiver.cpp

示例2: doSave

bool ResourceGroupware::doSave( bool )
{
  kDebug() <<"KCal::ResourceGroupware::doSave()";

  saveToCache();

  if ( !hasChanges() ) {
    kDebug() <<"No changes";
    return true;
  }
  
  if ( !confirmSave() ) return false;

#if 0
  Incidence::List::ConstIterator it;

  Incidence::List added = addedIncidences();
  for( it = added.begin(); it != added.end(); ++it ) {
    if ( mServer->addIncidence( *it, this ) ) {
      clearChange( *it );
      saveToCache();
    }
  }
  Incidence::List changed = changedIncidences();
  for( it = changed.begin(); it != changed.end(); ++it ) {
    if ( mServer->changeIncidence( *it ) ) clearChange( *it );
  }
  Incidence::List deleted = deletedIncidences();
  for( it = deleted.begin(); it != deleted.end(); ++it ) {
    if ( mServer->deleteIncidence( *it ) ) clearChange( *it );
  }
#endif

  return true;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:35,代码来源:kcal_resourcegroupware.cpp

示例3: doSave

bool ResourceGroupwareBase::doSave( bool syncCache )
{
  kDebug(5800);

  Q_UNUSED( syncCache );
  saveToCache();

  if ( !hasChanges() ) {
    kDebug(5800) << "No changes";
    return true;
  }
  // TODO: Implement confirming of single changes i.e. it should be possible
  //       to upload only certain changes and discard the rest. This is
  //       particularly important for resources like the blogging resource,
  //       where uploading would mean a republication of the blog, not only
  //       a modifications.
  if ( !confirmSave() ) return false;

  mUploadJob = createUploadJob( adaptor() );
  connect( mUploadJob, SIGNAL( result( KPIM::GroupwareJob * ) ),
    SLOT( slotUploadJobResult( KPIM::GroupwareJob * ) ) );

  Incidence::List inc;
  Incidence::List::Iterator it;
  KPIM::GroupwareUploadItem::List addedItems, changedItems, deletedItems;

  inc = addedIncidences();
  for( it = inc.begin(); it != inc.end(); ++it ) {
    addedItems.append( adaptor()->newUploadItem( *it,
                                           KPIM::GroupwareUploadItem::Added ) );
  }
  // TODO: Check if the item has changed on the server...
  // In particular, check if the version we based our change on is still current
  // on the server
  inc = changedIncidences();
  for( it = inc.begin(); it != inc.end(); ++it ) {
    changedItems.append( adaptor()->newUploadItem( *it,
                                         KPIM::GroupwareUploadItem::Changed ) );
  }
  inc = deletedIncidences();
  for( it = inc.begin(); it != inc.end(); ++it ) {
    deletedItems.append( adaptor()->newUploadItem( *it,
                                         KPIM::GroupwareUploadItem::Deleted ) );
  }

  mUploadJob->setAddedItems( addedItems );
  mUploadJob->setChangedItems( changedItems );
  mUploadJob->setDeletedItems( deletedItems );

  // FIXME: Calling clearChanges() here is not the ideal way since the
  // upload might fail, but there is no other place to call it...
  clearChanges();
  return true;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:54,代码来源:kcal_resourcegroupwarebase.cpp

示例4: addIncidences

void KOListView::addIncidences(const Incidence::List &incidenceList)
{
    Incidence::List::ConstIterator it;
    for(it = incidenceList.begin(); it != incidenceList.end(); ++it)
    {
        addIncidence(*it);
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:8,代码来源:kolistview.cpp

示例5: incidencesFromSchedulingID

Incidence::List Calendar::incidencesFromSchedulingID(const QString &UID)
{
    Incidence::List result;
    Incidence::List incidences = rawIncidences();
    Incidence::List::iterator it = incidences.begin();
    for(; it != incidences.end(); ++it)
        if((*it)->schedulingID() == UID)
            result.append(*it);
    return result;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:10,代码来源:calendar.cpp

示例6: rawIncidences

Incidence *Calendar::incidenceFromSchedulingID(const QString &UID)
{
    Incidence::List incidences = rawIncidences();
    Incidence::List::iterator it = incidences.begin();
    for(; it != incidences.end(); ++it)
        if((*it)->schedulingID() == UID)
            // Touchdown, and the crowd goes wild
            return *it;
    // Not found
    return 0;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:11,代码来源:calendar.cpp

示例7: doSave

bool ResourceLocalDir::doSave()
{
    Incidence::List list;
    bool success = true;

    list = addedIncidences();
    list += changedIncidences();

    for(Incidence::List::iterator it = list.begin(); it != list.end(); ++it)
        if(!doSave(*it))
            success = false;

    return success;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:14,代码来源:resourcelocaldir.cpp

示例8: loadChangesCache

void ResourceCached::loadChangesCache(QMap<Incidence *, bool> &map, const QString &type)
{
    CalendarLocal calendar(QString::fromLatin1("UTC"));

    if(KStandardDirs::exists(changesCacheFile(type)))
        calendar.load(changesCacheFile(type));
    else
        return;

    const Incidence::List list = calendar.incidences();
    Incidence::List::ConstIterator it;
    for(it = list.begin(); it != list.end(); ++it)
        map.insert((*it)->clone(), true);

    calendar.close();
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:16,代码来源:resourcecached.cpp

示例9: slotJobResult

void ResourceGroupware::slotJobResult( KJob *job )
{
  kDebug() <<"ResourceGroupware::slotJobResult():";

  if ( job->error() ) {
    mIsShowingError = true;
    loadError( job->errorString() );
    mIsShowingError = false;
  } else {
    disableChangeNotification();

    clearCache();

     // FIXME: This does not take into account the time zone!
    CalendarLocal calendar;
    ICalFormat ical;
    if ( !ical.fromString( &calendar, mJobData ) ) {
      loadError( i18n("Error parsing calendar data.") );
    } else {
      Incidence::List incidences = calendar.incidences();
      Incidence::List::ConstIterator it;
      for( it = incidences.begin(); it != incidences.end(); ++it ) {
//        kDebug() <<"INCIDENCE:" << (*it)->summary();
        Incidence *i = (*it)->clone();
        QString remote = (*it)->customProperty( "GWRESOURCE", "UID" );
        QString local = idMapper().localId( remote );
        if ( local.isEmpty() ) {
          idMapper().setRemoteId( i->uid(), remote );
        } else {
          i->setUid( local );
        }
        addIncidence( i );
      }
    }
    saveToCache();
    enableChangeNotification();

    clearChanges();

    emit resourceChanged( this );
    emit resourceLoaded( this );
  }

  mDownloadJob = 0;
  if ( mProgress ) mProgress->setComplete();
  mProgress = 0;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:47,代码来源:kcal_resourcegroupware.cpp

示例10: main

int main( int argc, char **argv )
{
  KAboutData aboutData(
    "testrecurson", 0,
    ki18n( "Tests all dates from 2002 to 2010 to test if the event recurs on each individual date. "
           "This is meant to test the Recurrence::recursOn method for errors." ), "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 ) );

  FileStorage store( cal, input );
  if ( !store.load() ) return 1;
  QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
  if ( !tz.isEmpty() ) {
    cal->setViewTimeZoneId( tz );
  }

  Incidence::List inc = cal->incidences();

  for ( Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it ) {
    Incidence::Ptr incidence = *it;

//     kDebug() << " ->" << incidence->summary() << "<-";

//     incidence->recurrence()->dump();

    QDate dt( 1996, 7, 1 );
    if ( outstream ) {
      // Output to file for testing purposes
      int nr = 0;
      while ( dt.year() <= 2020 && nr<=500 ) {
        if ( incidence->recursOn( dt, cal->viewTimeSpec() ) ) {
          (*outstream) << dt.toString( Qt::ISODate ) << endl;
          nr++;
        }
        dt = dt.addDays( 1 );
      }
    } else {
      dt = QDate( 2005, 1, 1 );
      while ( dt.year() < 2007 ) {
        if ( incidence->recursOn( dt, cal->viewTimeSpec() ) ) {
          kDebug() << dt.toString( Qt::ISODate );
        }
        dt = dt.addDays( 1 );
      }
    }
  }

  delete outstream;
  outfile.close();
  return 0;
}
开发者ID:dudochkin-victor,项目名称:kcalcore,代码行数:83,代码来源:testrecurson.cpp

示例11: acceptCancel

CallId Scheduler::acceptCancel( const IncidenceBase::Ptr &incidence,
                                ScheduleMessage::Status status,
                                const QString &attendee )
{
  Incidence::Ptr inc = incidence.staticCast<Incidence>();
  if ( !inc ) {
    return -1;
  }

  const CallId callId = ++d->mLatestCallId;
  ResultCode resultCode = ResultCodeSuccess;
  QString errorMessage;

  if ( inc->type() == IncidenceBase::TypeFreeBusy ) {
    // reply to this request is handled in korganizer's incomingdialog
    emitOperationFinished( callId, resultCode, errorMessage );
    return callId;
  }

  const Incidence::List existingIncidences = d->mCalendar->incidencesFromSchedulingID( inc->uid() );
  kDebug() << "Scheduler::acceptCancel="
           << Stringify::scheduleMessageStatus( status ) //krazy2:exclude=kdebug
           << ": found " << existingIncidences.count()
           << " incidences with schedulingID " << inc->schedulingID();

  Incidence::List::ConstIterator incit = existingIncidences.begin();
  for ( ; incit != existingIncidences.end() ; ++incit ) {
    Incidence::Ptr i = *incit;
    kDebug() << "Considering this found event ("
             << ( i->isReadOnly() ? "readonly" : "readwrite" )
             << ") :" << d->mFormat->toString( i );

    // If it's readonly, we can't possible remove it.
    if ( i->isReadOnly() ) {
      continue;
    }

    // Code for new invitations:
    // We cannot check the value of "status" to be RequestNew because
    // "status" comes from a similar check inside libical, where the event
    // is compared to other events in the calendar. But if we have another
    // version of the event around (e.g. shared folder for a group), the
    // status could be RequestNew, Obsolete or Updated.
    kDebug() << "looking in " << i->uid() << "'s attendees";

    // This is supposed to be a new request, not an update - however we want
    // to update the existing one to handle the "clicking more than once
    // on the invitation" case. So check the attendee status of the attendee.
    bool isMine = true;
    const Attendee::List attendees = i->attendees();
    Attendee::List::ConstIterator ait;
    for ( ait = attendees.begin(); ait != attendees.end(); ++ait ) {
      if ( (*ait)->email() == attendee &&
           (*ait)->status() == Attendee::NeedsAction ) {
        // This incidence wasn't created by me - it's probably in a shared
        // folder and meant for someone else, ignore it.
        kDebug() << "ignoring " << i->uid()
                 << " since I'm still NeedsAction there";
        isMine = false;
        break;
      }
    }

    if ( isMine ) {
      //TODO_SERGIO: use ItemDeleteJob and make this async.
      kDebug() << "removing existing incidence " << i->uid();

      Akonadi::Item item = d->mCalendar->itemForIncidenceUid( i->uid() );
      bool emitResult = true;
      if ( item.isValid() ) {
        const int changeId = d->mChanger->deleteIncidence( item );

        if ( changeId >= 0 ) {
          d->mCallIdByChangeId.insert( changeId, callId );
          d->mDeletedIncidenceByChangeId.insert( changeId, i );
          emitResult = false; // will be emitted in the job result's slot.
        } else {
          resultCode = ResultCodeErrorDeletingIncidence;
          errorMessage = QLatin1String( "Error while trying to delete the incidence" );
        }
      } else {
        resultCode = ResultCodeIncidenceNotFound;
        errorMessage = QLatin1String( "Couldn't find incidence in calendar" );
      }

      if ( emitResult ) {
        deleteTransaction( incidence->uid() );
        errorMessage = QLatin1String( "Error deleting incidence" );
        emitOperationFinished( callId, resultCode, errorMessage );
      }

      return callId;
    }
  }

  // in case we didn't find the to-be-removed incidence
  if ( existingIncidences.count() > 0 && inc->revision() > 0 ) {
    KMessageBox::error(
      0,
      i18nc( "@info",
//.........这里部分代码省略.........
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:101,代码来源:scheduler.cpp

示例12: acceptRequest

CallId Scheduler::acceptRequest( const IncidenceBase::Ptr &incidence,
                                 ScheduleMessage::Status status,
                                 const QString &email )
{
  Incidence::Ptr inc = incidence.staticCast<Incidence>() ;
  if ( !inc ) {
    kWarning() << "Accept what?";
    return -1;
  }

  const CallId callId = ++d->mLatestCallId;
  ResultCode resultCode = ResultCodeSuccess;
  QString errorMessage;

  if ( inc->type() == IncidenceBase::TypeFreeBusy ) {
    emitOperationFinished( callId, ResultCodeSuccess, QString() );
    // reply to this request is handled in korganizer's incomingdialog
    return callId;
  }

  const Incidence::List existingIncidences = d->mCalendar->incidencesFromSchedulingID( inc->uid() );
  kDebug() << "status=" << Stringify::scheduleMessageStatus( status ) //krazy:exclude=kdebug
           << ": found " << existingIncidences.count()
           << " incidences with schedulingID " << inc->schedulingID()
           << "; uid was = " << inc->uid();

  if ( existingIncidences.isEmpty() ) {
    // Perfectly normal if the incidence doesn't exist. This is probably
    // a new invitation.
    kDebug() << "incidence not found; calendar = " << d->mCalendar.data()
             << "; incidence count = " << d->mCalendar->incidences().count();
  }
  Incidence::List::ConstIterator incit = existingIncidences.begin();
  for ( ; incit != existingIncidences.end() ; ++incit ) {
    Incidence::Ptr existingIncidence = *incit;
    kDebug() << "Considering this found event ("
             << ( existingIncidence->isReadOnly() ? "readonly" : "readwrite" )
             << ") :" << d->mFormat->toString( existingIncidence );
    // If it's readonly, we can't possible update it.
    if ( existingIncidence->isReadOnly() ) {
      continue;
    }
    if ( existingIncidence->revision() <= inc->revision() ) {
      // The new incidence might be an update for the found one
      bool isUpdate = true;
      // Code for new invitations:
      // If you think we could check the value of "status" to be RequestNew:  we can't.
      // It comes from a similar check inside libical, where the event is compared to
      // other events in the calendar. But if we have another version of the event around
      // (e.g. shared folder for a group), the status could be RequestNew, Obsolete or Updated.
      kDebug() << "looking in " << existingIncidence->uid() << "'s attendees";
      // This is supposed to be a new request, not an update - however we want to update
      // the existing one to handle the "clicking more than once on the invitation" case.
      // So check the attendee status of the attendee.
      const Attendee::List attendees = existingIncidence->attendees();
      Attendee::List::ConstIterator ait;
      for ( ait = attendees.begin(); ait != attendees.end(); ++ait ) {
        if( (*ait)->email() == email && (*ait)->status() == Attendee::NeedsAction ) {
          // This incidence wasn't created by me - it's probably in a shared folder
          // and meant for someone else, ignore it.
          kDebug() << "ignoring "
                   << existingIncidence->uid() << " since I'm still NeedsAction there";
          isUpdate = false;
          break;
        }
      }
      if ( isUpdate ) {
        if ( existingIncidence->revision() == inc->revision() &&
             existingIncidence->lastModified() > inc->lastModified() ) {
          // This isn't an update - the found incidence was modified more recently
          deleteTransaction( existingIncidence->uid() );
          errorMessage = QLatin1String( "This isn't an update - "
                                        "the found incidence was modified more recently" );
          kDebug() << errorMessage;
          emitOperationFinished( callId, ResultCodeNotUpdate, errorMessage );

          return callId;
        }
        kDebug() << "replacing existing incidence " << existingIncidence->uid();

        bool emitResult = true;
        const QString oldUid = existingIncidence->uid();
        if ( existingIncidence->type() != inc->type() ) {
          errorMessage = QLatin1String( "Cannot assign two different incidence types" );
          resultCode = ResultCodeDifferentIncidenceTypes;
        } else {
          IncidenceBase *existingIncidenceBase = existingIncidence.data();
          IncidenceBase *incBase = inc.data();
          *existingIncidenceBase = *incBase;
          existingIncidence->setSchedulingID( inc->uid(), oldUid );

          Akonadi::Item item = d->mCalendar->itemForIncidenceUid( oldUid );
          item.setPayload<Incidence::Ptr>( existingIncidence );
          if ( item.isValid() ) {
            const int changeId = d->mChanger->modifyIncidence( item );

            if ( changeId >= 0 ) {
              d->mCallIdByChangeId.insert( changeId, callId );
              emitResult = false; // will be emitted in the job result's slot.
            } else {
//.........这里部分代码省略.........
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:101,代码来源:scheduler.cpp

示例13: search

void SearchDialog::search(const QRegExp &re)
{
    QDate startDt = mStartDate->date();
    QDate endDt = mEndDate->date();

    Event::List events;
    if(mEventsCheck->isChecked())
    {
        events = mCalendar->events(startDt, endDt, mInclusiveCheck->isChecked());
    }
    Todo::List todos;
    if(mTodosCheck->isChecked())
    {
        if(mIncludeUndatedTodos->isChecked())
        {
            Todo::List alltodos = mCalendar->todos();
            Todo::List::iterator it;
            Todo *todo;
            for(it = alltodos.begin(); it != alltodos.end(); ++it)
            {
                todo = *it;
                if((!todo->hasStartDate() && !todo->hasDueDate()) ||    // undated
                        (todo->hasStartDate() && (todo->dtStart() >= startDt) && (todo->dtStart() <= endDt)) ||   // start dt in range
                        (todo->hasDueDate() && (todo->dtDue().date() >= startDt) && (todo->dtDue() <= endDt)) ||   // due dt in range
                        (todo->hasCompletedDate() && (todo->completed().date() >= startDt) && (todo->completed() <= endDt)))    // completed dt in range
                {
                    todos.append(todo);
                }
            }
        }
        else
        {
            QDate dt = startDt;
            while(dt <= endDt)
            {
                todos += mCalendar->todos(dt);
                dt = dt.addDays(1);
            }
        }
    }

    Journal::List journals;
    if(mJournalsCheck->isChecked())
    {
        QDate dt = startDt;
        while(dt <= endDt)
        {
            journals += mCalendar->journals(dt);
            dt = dt.addDays(1);
        }
    }

    Incidence::List allIncidences = Calendar::mergeIncidenceList(events, todos, journals);

    mMatchedEvents.clear();
    Incidence::List::ConstIterator it;
    for(it = allIncidences.begin(); it != allIncidences.end(); ++it)
    {
        Incidence *ev = *it;
        if(mSummaryCheck->isChecked())
        {
#if QT_VERSION >= 300
            if(re.search(ev->summary()) != -1)
            {
#else
            if(re.match(ev->summary()) != -1)
            {
#endif
                mMatchedEvents.append(ev);
                continue;
            }
        }
        if(mDescriptionCheck->isChecked())
        {
#if QT_VERSION >= 300
            if(re.search(ev->description()) != -1)
            {
#else
            if(re.match(ev->description()) != -1)
            {
#endif
                mMatchedEvents.append(ev);
                continue;
            }
        }
        if(mCategoryCheck->isChecked())
        {
#if QT_VERSION >= 300
            if(re.search(ev->categoriesStr()) != -1)
            {
#else
            if(re.match(ev->categoriesStr()) != -1)
            {
#endif
                mMatchedEvents.append(ev);
                continue;
            }
        }
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:100,代码来源:searchdialog.cpp

示例14: removeRelations

// If a task with subtasks is deleted, move it's subtasks to the orphans list
void Calendar::removeRelations(Incidence *incidence)
{
    if(!incidence)
    {
        kdDebug(5800) << "Warning: Calendar::removeRelations( 0 )!\n";
        return;
    }

    // kdDebug(5850) << "Calendar::removeRelations for incidence " << forincidence << " with UID " << forincidence->uid() << ", summary: " << forincidence->summary() << endl;
    QString uid = incidence->uid();

    Incidence::List relations = incidence->relations();
    Incidence::List::ConstIterator it;
    for(it = relations.begin(); it != relations.end(); ++it)
    {
        Incidence *i = *it;
        if(!mOrphanUids.find(i->uid()))
        {
            mOrphans.insert(uid, i);
            mOrphanUids.insert(i->uid(), i);
            i->setRelatedTo(0);
            i->setRelatedToUid(uid);
        }
    }

    // If this incidence is related to something else, tell that about it
    if(incidence->relatedTo())
        incidence->relatedTo()->removeRelation(incidence);

    // Remove this one from the orphans list
    if(mOrphanUids.remove(uid))
    {
        // This incidence is located in the orphans list - it should be removed
        // Since the mOrphans dict might contain the same key (with different
        // child incidence pointers!) multiple times, take care that we remove
        // the correct one. So we need to remove all items with the given
        // parent UID, and readd those that are not for this item. Also, there
        // might be other entries with differnet UID that point to this
        // incidence (this might happen when the relatedTo of the item is
        // changed before its parent is inserted. This might happen with
        // groupware servers....). Remove them, too
        QStringList relatedToUids;
        // First get the list of all keys in the mOrphans list that point to the removed item
        relatedToUids << incidence->relatedToUid();
        for(QDictIterator<Incidence> it(mOrphans); it.current(); ++it)
        {
            if(it.current()->uid() == uid)
            {
                relatedToUids << it.currentKey();
            }
        }

        // now go through all uids that have one entry that point to the incidence
        for(QStringList::Iterator uidit = relatedToUids.begin();
                uidit != relatedToUids.end(); ++uidit)
        {
            Incidence::List tempList;
            // Remove all to get access to the remaining entries
            while(Incidence *i = mOrphans[ *uidit ])
            {
                mOrphans.remove(*uidit);
                if(i != incidence) tempList.append(i);
            }
            // Readd those that point to a different orphan incidence
            for(Incidence::List::Iterator incit = tempList.begin();
                    incit != tempList.end(); ++incit)
            {
                mOrphans.insert(*uidit, *incit);
            }
        }
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:73,代码来源:calendar.cpp

示例15: main

int main(int argc, char **argv)
{
    KAboutData aboutData("testrecurrencenew", "Load recurrence rules with the new class and print out debug messages", "0.1");
    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app(false, false);

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    if(args->count() < 1)
    {
        args->usage("Wrong number of arguments.");
    }

    // use zoneinfo data from source dir
    set_zone_directory(KDETOPSRCDIR "/libkcal/libical/zoneinfo");

    QString input = QFile::decodeName(args->arg(0));
    kdDebug(5800) << "Input file: " << input << endl;

    QTextStream *outstream;
    outstream = 0;
    QString fn("");
    if(args->count() > 1)
    {
        fn = args->arg(1);
        kdDebug() << "We have a file name given: " << fn << endl;
    }
    QFile outfile(fn);
    if(!fn.isEmpty() && outfile.open(IO_WriteOnly))
    {
        kdDebug() << "Opened output file!!!" << endl;
        outstream = new QTextStream(&outfile);
    }

    CalendarLocal cal(QString::fromLatin1("UTC"));

    if(!cal.load(input)) return 1;
    QString tz = cal.nonKDECustomProperty("X-LibKCal-Testsuite-OutTZ");
    if(!tz.isEmpty())
    {
        cal.setTimeZoneIdViewOnly(tz);
    }

    Incidence::List inc = cal.incidences();

    for(Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it)
    {
        Incidence *incidence = *it;
        kdDebug(5800) << "*+*+*+*+*+*+*+*+*+*" << endl;
        kdDebug(5800) << " -> " << incidence->summary() << " <- " << endl;

        incidence->recurrence()->dump();

        QDateTime dt(incidence->recurrence()->endDateTime());
        int i = 0;
        if(outstream)
        {
            if(!dt.isValid()) dt = QDateTime(QDate(2011, 1, 1), QTime(0, 0, 1));
            else dt = dt.addYears(2);
            kdDebug(5800) << "-------------------------------------------" << endl;
            kdDebug(5800) << " *~*~*~*~ Starting with date: " << dt << endl;
            // Output to file for testing purposes
            while(dt.isValid() && i < 500)
            {
                dt = dt.addSecs(-1);
                ++i;
                dt = incidence->recurrence()->getPreviousDateTime(dt);
                (*outstream) << dt.toString(Qt::ISODate) << endl;
            }
        }
        else
        {
            if(!dt.isValid()) dt = QDateTime(QDate(2005, 7, 31), QTime(23, 59, 59));
            else dt = dt.addYears(2);
            incidence->recurrence()->dump();
            kdDebug(5800) << "-------------------------------------------" << endl;
            kdDebug(5800) << " *~*~*~*~ Starting with date: " << dt << endl;
            // Output to konsole
            while(dt.isValid() && i < 50)
            {
                dt = dt.addSecs(-1);
                ++i;
                kdDebug(5800) << "-------------------------------------------" << endl;
                dt = incidence->recurrence()->getPreviousDateTime(dt);
                kdDebug(5800) << " *~*~*~*~ Previous date is: " << dt << endl;
            }
        }
    }

    delete outstream;
    outfile.close();
    return 0;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:95,代码来源:testrecurprevious.cpp


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