konsolekalendar Library API Documentation

konsolekalendardelete.cpp

00001 /***************************************************************************
00002         konsolekalendardelete.cpp  -  description
00003            -------------------
00004     begin                : Sun May 25 2003
00005     copyright            : (C) 2003 by Tuukka Pasanen
00006     copyright            : (C) 2003 by Allen Winter
00007     email                : illuusio@mailcity.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #include <stdlib.h>
00020 #include <iostream>
00021 
00022 #include <kdebug.h>
00023 #include <klocale.h>
00024 
00025 #include "konsolekalendardelete.h"
00026 
00027 using namespace KCal;
00028 using namespace std;
00029 
00030 KonsoleKalendarDelete::KonsoleKalendarDelete( KonsoleKalendarVariables *variables )
00031 {
00032   m_variables = variables;
00033 }
00034 
00035 KonsoleKalendarDelete::~KonsoleKalendarDelete()
00036 {
00037 }
00038 
00039 bool KonsoleKalendarDelete::deleteEvent()
00040 {
00041   bool status = false;
00042 
00043   /* Retrieve event on the basis of the unique string ID */
00044   Event *event = m_variables->getCalendar()->event( m_variables->getUID() );
00045 
00046   if( event ) {
00047     if( m_variables->isDryRun() ) {
00048       cout << i18n("Delete Event <Dry Run>:").local8Bit() << endl;
00049       printSpecs( event );
00050     } else {
00051       kdDebug() << "konsolekalendardelete.cpp:deleteEvent() : " << m_variables->getUID().local8Bit() << endl;
00052 
00053       if( m_variables->isVerbose() ) {
00054 // TODO: put back after string freeze
00055 //  cout << i18n("Delete Event <Verbose>:").local8Bit() << endl;
00056     printSpecs( event );
00057       }
00058 
00059       m_variables->getCalendar()->deleteEvent( event );
00060       
00061       if( !m_variables->isCalendarResources() ){
00062         m_variables->getCalendar()->save( m_variables->getCalendarFile() );
00063       } else {
00064         m_variables->getCalendar()->save();     
00065       }
00066     }
00067     status = true;
00068   }
00069  
00070   return( status );
00071 }
00072 
00073 void KonsoleKalendarDelete::printSpecs( Event *event )
00074 {
00075   cout << i18n("  UID:   ").local8Bit() << m_variables->getUID().local8Bit() << endl;
00076   cout << i18n("  What:  ").local8Bit() << event->summary().local8Bit() << endl;;
00077   cout << i18n("  Begin: ").local8Bit() << event->dtStart().toString(Qt::TextDate).local8Bit() << endl;
00078   cout << i18n("  End:   ").local8Bit() << event->dtEnd().toString(Qt::TextDate).local8Bit() << endl;
00079   cout << i18n("  Desc:  ").local8Bit() << event->description().local8Bit() << endl;;
00080 }
KDE Logo
This file is part of the documentation for konsolekalendar Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:15 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003