KCal::Journal* ResourceKolab::addNote( const QString& data, const QString& subresource,
                             quint32 sernum, const QString &mimetype )
{
  KCal::Journal* journal = 0;
    // FIXME: This does not take into account the time zone!
  KCal::ICalFormat formatter;
  if ( mimetype == attachmentMimeType )
    journal = Note::xmlToJournal( data );
  else
    journal = static_cast<KCal::Journal*>( formatter.fromString( data ) );

  Q_ASSERT( journal );
  if( journal && !mUidMap.contains( journal->uid() ) ) {
    if ( addNote( journal, subresource, sernum ) )
      return journal;
    else
      delete journal;
  }
  else if ( journal && mUidMap.contains( journal->uid() ) )
  {
    //For debugging
    kDebug( 5500 ) << "mUidMap already contains" << journal->uid();
  }
  return 0;
}
Example #2
0
void KNoteTip::setNote(KNotesIconViewItem *item)
{
    if(mNoteIVI == item)
        return;

    mNoteIVI = item;

    if(!mNoteIVI)
    {
        killTimers();
        if(isVisible())
        {
            setFilter(false);
            hide();
        }
    }
    else
    {
        KCal::Journal *journal = item->journal();
        if(journal->customProperty("KNotes", "RichText") == "true")
            mPreview->setTextFormat(Qt::RichText);
        else
            mPreview->setTextFormat(Qt::PlainText);

        QColor fg(journal->customProperty("KNotes", "FgColor"));
        QColor bg(journal->customProperty("KNotes", "BgColor"));
        setColor(fg, bg);

        mPreview->setText(journal->description());
        mPreview->zoomTo(8);
        mPreview->sync();

        int w = 400;
        int h = mPreview->heightForWidth(w);
        while(w > 60 && h == mPreview->heightForWidth(w - 20))
            w -= 20;

        QRect desk = KGlobalSettings::desktopGeometry(mNoteIVI->rect().center());
        resize(w, QMIN(h, desk.height() / 2 - 20));

        hide();
        killTimers();
        setFilter(true);
        startTimer(600);    // delay showing the tooltip for 0.7 sec
    }
}
void ResourceKolab::incidenceUpdated( KCal::IncidenceBase* i )
{
  QString subResource;
  quint32 sernum;
  if ( mUidMap.contains( i->uid() ) ) {
    subResource = mUidMap[ i->uid() ].resource();
    sernum = mUidMap[ i->uid() ].serialNumber();
  } else { // can this happen?
    subResource = findWritableResource( mSubResources );
    if ( subResource.isEmpty() ) // canceled
      return;
    sernum = 0;
  }

  KCal::Journal* journal = static_cast<KCal::Journal*>( i );
  QString xml = Note::journalToXML( journal );
  if( !xml.isEmpty() && kmailUpdate( subResource, sernum, xml, attachmentMimeType, journal->uid() ) )
    mUidMap[ i->uid() ] = StorageReference( subResource, sernum );
}
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;
}
Example #5
0
QString KNotesApp::newNote( const QString& name, const QString& text )
{
    // create the new note
    KCal::Journal *journal = new KCal::Journal();

    // new notes have the current date/time as title if none was given
    if ( !name.isEmpty() )
        journal->setSummary( name );
    else
        journal->setSummary( KGlobal::locale()->formatDateTime( QDateTime::currentDateTime() ) );

    // the body of the note
    journal->setDescription( text );

    m_manager->addNewNote( journal );

    showNote( journal->uid() );

    return journal->uid();
}
Example #6
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;
}