konsolekalendar

konsolekalendardelete.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 * konsolekalendardelete.cpp *
3 * *
4 * KonsoleKalendar is a command line interface to KDE calendars *
5 * Copyright (C) 2002-2004 Tuukka Pasanen <illuusio@mailcity.com> *
6 * Copyright (C) 2003-2005 Allen Winter <winter@kde.org> *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
21 * *
22 * As a special exception, permission is given to link this program *
23 * with any edition of TQt, and distribute the resulting executable, *
24 * without including the source code for TQt in the source distribution. *
25 * *
26 ******************************************************************************/
33#include <stdlib.h>
34#include <iostream>
35
36#include <kdebug.h>
37#include <tdelocale.h>
38
40
41using namespace KCal;
42using namespace std;
43
48
52
54{
55 bool status = false;
56
57 kdDebug() << "konsolekalendardelete.cpp::deleteEvent()" << endl;
58
59 /*
60 * Retrieve event on the basis of the unique string ID
61 */
62 Event *event = m_variables->getCalendar()->event( m_variables->getUID() );
63 if ( event ) {
64 if ( m_variables->isDryRun() ) {
65 cout << i18n( "Delete Event <Dry Run>:" ).local8Bit().data()
66 << endl;
67 printSpecs( event );
68 } else {
69 kdDebug() << "konsolekalendardelete.cpp:deleteEvent() : "
70 << m_variables->getUID().local8Bit()
71 << endl;
72
73 if ( m_variables->isVerbose() ) {
74 cout << i18n( "Delete Event <Verbose>:" ).local8Bit().data()
75 << endl;
76 printSpecs( event );
77 }
78
79 m_variables->getCalendar()->deleteEvent( event );
80 cout << i18n( "Success: \"%1\" deleted" )
81 .arg( event->summary() ).local8Bit().data()
82 << endl;
83
84 m_variables->getCalendar()->save();
85 status = true;
86 }
87 }
88
89 kdDebug() << "konsolekalendardelete.cpp::deleteEvent() | Done " << endl;
90 return status;
91}
92
93void KonsoleKalendarDelete::printSpecs( Event *event )
94{
95 cout << i18n( " UID: %1" ).
96 arg( m_variables->getUID() ).local8Bit().data()
97 << endl;
98
99 cout << i18n( " What: %1" ).
100 arg( event->summary() ).local8Bit().data()
101 << endl;
102
103 cout << i18n( " Begin: %1" ).
104 arg( event->dtStart().toString( TQt::TextDate ) ).local8Bit().data()
105 << endl;
106
107 cout << i18n( " End: %1" ).
108 arg( event->dtEnd().toString( TQt::TextDate ) ).local8Bit().data()
109 << endl;
110
111 cout << i18n( " Desc: %1" ).
112 arg( event->description() ).local8Bit().data()
113 << endl;
114
115 cout << i18n( " Location: %1" ).
116 arg( event->location() ).local8Bit().data()
117 << endl;
118}
bool deleteEvent()
Delete the Event.
KonsoleKalendarDelete(KonsoleKalendarVariables *vars)
Constructs a KonsoleKalendarDelete object from command line arguments.
This class provides all the variables for the program.
TQString getUID()
Get UID, the unique tag for VCard entry.
Provides the KonsoleKalendarDelete class definition.