konsolekalendar Library API Documentation

konsolekalendarchange.cpp

00001 /*******************************************************************************
00002  * konsolekalendarchange.cpp                                                   *
00003  *                                                                             *
00004  * KonsoleKalendar is a command line interface to KDE calendars                *
00005  * Copyright (C) 2002-2004  Tuukka Pasanen <illuusio@mailcity.com>             *
00006  * Copyright (C) 2003-2004  Allen Winter <awinterz@users.sourceforge.net>      *
00007  *                                                                             *
00008  * This program is free software; you can redistribute it and/or modify        *
00009  * it under the terms of the GNU General Public License as published by        *
00010  * the Free Software Foundation; either version 2 of the License, or           *
00011  * (at your option) any later version.                                         *
00012  *                                                                             *
00013  * This program is distributed in the hope that it will be useful,             *
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                *
00016  * GNU General Public License for more details.                                *
00017  *                                                                             *
00018  * You should have received a copy of the GNU General Public License           *
00019  * along with this program; if not, write to the Free Software                 *
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. *
00021  *                                                                             *
00022  * As a special exception, permission is given to link this program            *
00023  * with any edition of Qt, and distribute the resulting executable,            *
00024  * without including the source code for Qt in the source distribution.        *
00025  *                                                                             *
00026  ******************************************************************************/
00027 
00028 #include <stdlib.h>
00029 #include <iostream>
00030 
00031 #include <kdebug.h>
00032 #include <klocale.h>
00033 
00034 #include "konsolekalendarchange.h"
00035 
00036 using namespace KCal;
00037 using namespace std;
00038 
00039 KonsoleKalendarChange::KonsoleKalendarChange( KonsoleKalendarVariables *vars )
00040 {
00041   m_variables = vars;
00042 }
00043 
00044 KonsoleKalendarChange::~KonsoleKalendarChange()
00045 {
00046 }
00047 
00048 bool KonsoleKalendarChange::changeEvent()
00049 {
00050   bool status = false;
00051 
00052   kdDebug() << "konsolekalendarchange.cpp::changeEvent()" << endl;
00053 
00054   /* Retrieve event on the basis of the unique string ID */
00055   Event *event = m_variables->getCalendar()->event( m_variables->getUID() );
00056   if ( event ) {
00057     if ( m_variables->isDryRun() ) {
00058       cout << i18n("Change Event <Dry Run>:").local8Bit()
00059            << endl;
00060       printSpecs( event );
00061 
00062       cout << i18n("To Event <Dry Run>:").local8Bit()
00063            << endl;
00064       printSpecs();
00065     } else {
00066       kdDebug() << "konsolekalendarchange.cpp:changeEvent() : "
00067                 << m_variables->getUID().local8Bit()
00068                 << endl;
00069 
00070       if ( m_variables->isVerbose() ) {
00071         cout << i18n("Change Event <Verbose>:").local8Bit()
00072              << endl;
00073         printSpecs( event );
00074 
00075         cout << i18n("To Event <Dry Run>:").local8Bit()
00076              << endl;
00077         printSpecs();
00078       }
00079 
00080       if ( m_variables->isStartDateTime() ) {
00081         event->setDtStart( m_variables->getStartDateTime() );
00082       }
00083 
00084       if ( m_variables->isEndDateTime() ) {
00085         event->setDtEnd( m_variables->getEndDateTime() );
00086       }
00087 
00088       event->setFloats( m_variables->getFloating() );
00089 
00090       if ( m_variables->isSummary() ) {
00091         event->setSummary( m_variables->getSummary() );
00092       }
00093 
00094       if ( m_variables->isDescription() ) {
00095         event->setDescription( m_variables->getDescription() );
00096       }
00097 
00098       if ( m_variables->isLocation() ) {
00099         event->setLocation( m_variables->getLocation() );
00100       }
00101 
00102       if ( m_variables->getCalendar()->addEvent( event ) ) {
00103         cout << i18n("Success: \"%1\" changed")
00104           .arg( event->summary() ).local8Bit()
00105              << endl;
00106 
00107         if ( !m_variables->isCalendarResources() ) {
00108           status =
00109             m_variables->getCalendar()->save( m_variables->getCalendarFile() );
00110         } else {
00111           m_variables->getCalendar()->save();
00112           status = true;
00113         }
00114       } else {
00115         cout << i18n("Failure: \"%1\" not changed")
00116           .arg( event->summary() ).local8Bit()
00117              << endl;
00118       }
00119     }
00120   }
00121 
00122   kdDebug() << "konsolekalendarchange.cpp::changeEvent() | Done " << endl;
00123   return status;
00124 }
00125 
00126 void KonsoleKalendarChange::printSpecs( Event *event )
00127 {
00128   cout << i18n("  UID:   %1").
00129     arg( event->uid() ).local8Bit()
00130        << endl;
00131 
00132   cout << i18n("  What:  %1").
00133     arg( event->summary() ).local8Bit()
00134        << endl;
00135 
00136   cout << i18n("  Begin: %1").
00137     arg( event->dtStart().toString(Qt::TextDate) ).local8Bit()
00138        << endl;
00139 
00140   cout << i18n("  End:   %1").
00141     arg( event->dtEnd().toString(Qt::TextDate) ).local8Bit()
00142        << endl;
00143 
00144   cout << i18n("  Desc:  %1").
00145     arg( event->description() ).local8Bit()
00146        << endl;
00147 
00148   cout << i18n("  Location:  %1").
00149     arg( event->location() ).local8Bit()
00150        << endl;
00151 }
00152 
00153 void KonsoleKalendarChange::printSpecs( )
00154 {
00155   cout << i18n("  UID:   %1").
00156     arg( m_variables->getUID() ).local8Bit()
00157        << endl;
00158 
00159   cout << i18n("  What:  %1").
00160     arg( m_variables->getSummary() ).local8Bit()
00161        << endl;
00162 
00163   cout << i18n("  Begin: %1").
00164     arg( m_variables->getStartDateTime().toString(Qt::TextDate) ).local8Bit()
00165        << endl;
00166 
00167   cout << i18n("  End:   %1").
00168     arg( m_variables->getEndDateTime().toString(Qt::TextDate) ).local8Bit()
00169        << endl;
00170 
00171   cout << i18n("  Desc:  %1").
00172     arg( m_variables->getDescription() ).local8Bit()
00173        << endl;
00174 
00175   cout << i18n("  Location:  %1").
00176     arg( m_variables->getLocation() ).local8Bit()
00177        << endl;
00178 }
KDE Logo
This file is part of the documentation for konsolekalendar Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jan 31 15:56:19 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003