示例#1
0
KCal::Journal *APIBlog::journalFromPosting(KBlog::BlogPosting *blog)
{
    if(!blog) return 0;
    KCal::Journal *j = new KCal::Journal();
    QDateTime dt = blog->dateTime();
    QDateTime creationDt = blog->creationDateTime();
    QDateTime modificationDt = blog->modificationDateTime();
    kdDebug() << "dt            =" << dt.toString(Qt::ISODate) << endl;
    kdDebug() << "creationDt    =" << creationDt.toString(Qt::ISODate) << endl;
    kdDebug() << "modificationDt=" << modificationDt.toString(Qt::ISODate) << endl;
    if(dt.isValid() && !dt.isNull())
    {
        j->setDtStart(dt);
    }
    else if(creationDt.isValid() && !creationDt.isNull())
    {
        j->setDtStart(creationDt);
    }
    else if(modificationDt.isValid() && !modificationDt.isNull())
    {
        j->setDtStart(modificationDt);
    }

    j->setCreated(blog->creationDateTime());
    j->setLastModified(blog->modificationDateTime());
    j->setFloats(false);
    kdDebug() << "Date for blog " << blog->title() << " is "
              << blog->dateTime().toString() << endl;
    j->setSummary(blog->title());
    j->setDescription(blog->content());
    j->setCategories(QStringList(blog->category()));
    j->setOrganizer(blog->userID());
    j->setCustomProperty("KCalBloggerRes", "UserID", blog->userID());
    j->setCustomProperty("KCalBloggerRes", "BlogID", blog->blogID());
    j->setCustomProperty("KCalBloggerRes", "PostID", blog->postID());

    // TODO: Set the read-only flag in the resource!
    //   j->setReadOnly( readOnly() );

    return j;
}
KCal::Journal* IncidenceConverter::convertFromNote( ngwt__Note* note)
{
  kDebug();
  if ( !note )
    return 0;

  KCal::Journal *journal = new KCal::Journal();

  if ( !convertFromCalendarItem( note, journal ) ) {
    kDebug() << "Couldn't convert Note to Journal!";
    delete journal;
    return 0;
  }

  if ( note->startDate ) {
    kDebug() << "Journal start date is: " << note->startDate->c_str();
    journal->setDtStart( stringToKDateTime( note->startDate, mTimeSpec ) );
  }

  return journal;
}