• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

KonsoleKalendar

konsolekalendarchange.cpp

Go to the documentation of this file.
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-2005  Allen Winter <winter@kde.org>                     *
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 along    *
00019  * with this program; if not, write to the Free Software Foundation, Inc.,    *
00020  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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  *****************************************************************************/
00033 #include "konsolekalendarchange.h"
00034 
00035 #include <stdlib.h>
00036 #include <iostream>
00037 
00038 #include <kdebug.h>
00039 #include <klocale.h>
00040 
00041 using namespace KCal;
00042 using namespace std;
00043 
00044 KonsoleKalendarChange::KonsoleKalendarChange( KonsoleKalendarVariables *vars )
00045 {
00046   m_variables = vars;
00047 }
00048 
00049 KonsoleKalendarChange::~KonsoleKalendarChange()
00050 {
00051 }
00052 
00053 bool KonsoleKalendarChange::changeEvent()
00054 {
00055   bool status = false;
00056 
00057   kDebug() << "konsolekalendarchange.cpp::changeEvent()";
00058 
00059   /*
00060    * Retrieve event on the basis of the unique string ID
00061    */
00062   Event *event = m_variables->getCalendar()->event( m_variables->getUID() );
00063   if ( event ) {
00064     if ( m_variables->isDryRun() ) {
00065       cout << i18n( "Change Event &lt;Dry Run&gt;:" ).toLocal8Bit().data()
00066            << endl;
00067       printSpecs( event );
00068 
00069       cout << i18n( "To Event &lt;Dry Run&gt;:" ).toLocal8Bit().data()
00070            << endl;
00071       printSpecs();
00072     } else {
00073       kDebug() << "konsolekalendarchange.cpp:changeEvent() :"
00074                << m_variables->getUID().toLocal8Bit().data();
00075 
00076       if ( m_variables->isVerbose() ) {
00077         cout << i18n( "Change Event &lt;Verbose&gt;:" ).toLocal8Bit().data()
00078              << endl;
00079         printSpecs( event );
00080 
00081         cout << i18n( "To Event &lt;Dry Run&gt;:" ).toLocal8Bit().data()
00082              << endl;
00083         printSpecs();
00084       }
00085 
00086       event->startUpdates();
00087       KDateTime::Spec timeSpec = m_variables->getCalendar()->timeSpec();
00088       if ( m_variables->isStartDateTime() ) {
00089         event->setDtStart( KDateTime( m_variables->getStartDateTime(), timeSpec ) );
00090       }
00091 
00092       if ( m_variables->isEndDateTime() ) {
00093         event->setDtEnd( KDateTime( m_variables->getEndDateTime(), timeSpec ) );
00094       }
00095 
00096       event->setAllDay( m_variables->getFloating() );
00097 
00098       if ( m_variables->isSummary() ) {
00099         event->setSummary( m_variables->getSummary() );
00100       }
00101 
00102       if ( m_variables->isDescription() ) {
00103         event->setDescription( m_variables->getDescription() );
00104       }
00105 
00106       if ( m_variables->isLocation() ) {
00107         event->setLocation( m_variables->getLocation() );
00108       }
00109 
00110       event->endUpdates();
00111       if ( m_variables->getCalendar()->save() ) {
00112         cout << i18n( "Success: \"%1\" changed", event->summary() ).toLocal8Bit().data()
00113              << endl;
00114         status = true;
00115       } else {
00116         cout << i18n( "Failure: \"%1\" not changed", event->summary() ).toLocal8Bit().data()
00117              << endl;
00118       }
00119     }
00120   }
00121 
00122   kDebug() << "konsolekalendarchange.cpp::changeEvent() | Done";
00123   return status;
00124 }
00125 
00126 void KonsoleKalendarChange::printSpecs( Event *event )
00127 {
00128   cout << i18n( "  UID:   %1",
00129      event->uid() ).toLocal8Bit().data()
00130        << endl;
00131 
00132   cout << i18n( "  What:  %1",
00133      event->summary() ).toLocal8Bit().data()
00134        << endl;
00135 
00136   KDateTime::Spec timeSpec = m_variables->getCalendar()->timeSpec();
00137   cout << i18n( "  Begin: %1",
00138      event->dtStart().toTimeSpec( timeSpec ).
00139                 dateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
00140        << endl;
00141 
00142   cout << i18n( "  End:   %1",
00143      event->dtEnd().toTimeSpec( timeSpec ).
00144                 dateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
00145        << endl;
00146 
00147   cout << i18n( "  Desc:  %1",
00148      event->description() ).toLocal8Bit().data()
00149        << endl;
00150 
00151   cout << i18n( "  Location:  %1",
00152      event->location() ).toLocal8Bit().data()
00153        << endl;
00154 }
00155 
00156 void KonsoleKalendarChange::printSpecs()
00157 {
00158   cout << i18n( "  UID:   %1",
00159                 m_variables->getUID() ).toLocal8Bit().data()
00160        << endl;
00161 
00162   cout << i18n( "  What:  %1",
00163                 m_variables->getSummary() ).toLocal8Bit().data()
00164        << endl;
00165 
00166   cout << i18n( "  Begin: %1",
00167                 m_variables->getStartDateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
00168        << endl;
00169 
00170   cout << i18n( "  End:   %1",
00171                 m_variables->getEndDateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
00172        << endl;
00173 
00174   cout << i18n( "  Desc:  %1",
00175                 m_variables->getDescription() ).toLocal8Bit().data()
00176        << endl;
00177 
00178   cout << i18n( "  Location:  %1",
00179                 m_variables->getLocation() ).toLocal8Bit().data()
00180        << endl;
00181 }

KonsoleKalendar

Skip menu "KonsoleKalendar"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal