kitchensync Library API Documentation

metadatebook.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2002,2003 Holger Freyther <freyther@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #include <libkcal/event.h>
00023 #include <libkcal/recurrence.h>
00024 
00025 #include "metadatebook.h"
00026 
00027 using namespace OpieHelper;
00028 
00029 MetaDatebook::MetaDatebook()
00030     : MD5Template<KSync::CalendarSyncee, KSync::CalendarSyncEntry>()
00031 {
00032 }
00033 MetaDatebook::~MetaDatebook() {
00034 }
00035 QString MetaDatebook::string( KSync::CalendarSyncEntry* ev) {
00036     QString string;
00037     KCal::Event* event = dynamic_cast<KCal::Event*>( ev->incidence() );
00038     if ( !event )
00039       return "";
00040 
00041     string  = event->categories().join(";");
00042     string += event->summary();
00043     string += event->description();
00044     string += event->location();
00045     string += event->dtStart().toString("dd.MM.yyyy hh:mm:ss");
00046     string += event->dtEnd().toString("dd.MM.yyyy hh:mm:ss");
00047     string += QString::number( event->doesFloat() );
00048 
00049     /* Recurrance */
00050     KCal::Recurrence* rec = event->recurrence();
00051     if ( rec->doesRecur() ) {
00052         switch( rec->doesRecur() ) {
00053         case KCal::Recurrence::rDaily:
00054             string += "Daily";
00055             break;
00056         case KCal::Recurrence::rWeekly:{
00057             string += "Weekly";
00058             string += days( rec->days() );
00059             break;
00060         }
00061         case KCal::Recurrence::rMonthlyPos:
00062             string += "MonthlyDay";
00063             break;
00064         case KCal::Recurrence::rMonthlyDay:
00065             string += "MonthlyDate";
00066             break;
00067         case KCal::Recurrence::rYearlyDay: // see datebook.cpp
00068         case KCal::Recurrence::rYearlyMonth:
00069         case KCal::Recurrence::rYearlyPos:
00070             string += "Yearly";
00071             break;
00072         case KCal::Recurrence::rNone:
00073         default:
00074             break;
00075         }
00076         string += QString::number( rec->frequency() );
00077 
00078         /* test duration */
00079         string += QString::number( rec->duration() );
00080         if ( rec->duration() == 0 ) {
00081             string += rec->endDate().toString("dd.MM.yyyy");
00082         }
00083         string += rec->recurStart().date().toString("dd.MM.yyyy hh:mm:ss");
00084     }
00085     /* Alarms here */
00086 /*    KCal::Alarm* al = event->alarms().first();
00087     if ( al != 0 ) {
00088         int sec = al->offset().asSeconds();
00089         string += QString::number( sec );
00090         string += al->audioFile();
00091     }
00092 */
00093     return string;
00094 }
00095 QString MetaDatebook::days( const QBitArray& ar ) {
00096     QString str;
00097     if ( ar.testBit(0 ) ) str += "Mo";
00098     if ( ar.testBit(1 ) ) str += "Di";
00099     if ( ar.testBit(2 ) ) str += "Mi";
00100     if ( ar.testBit(3 ) ) str += "Do";
00101     if ( ar.testBit(4 ) ) str += "Fr";
00102     if ( ar.testBit(5 ) ) str += "Sa";
00103     if ( ar.testBit(6 ) ) str += "So";
00104 
00105     return str;
00106 }
KDE Logo
This file is part of the documentation for kitchensync Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jan 31 15:53:45 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003