konsolekalendar Library API Documentation

konsolekalendaradd.cpp

00001 /******************************************************************************* 00002 * konsolekalendaradd.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 <qdatetime.h> 00032 #include <qobject.h> 00033 00034 #include <kdebug.h> 00035 #include <klocale.h> 00036 00037 #include <libkcal/calendarlocal.h> 00038 #include <libkcal/calendar.h> 00039 #include <libkcal/event.h> 00040 00041 #include "konsolekalendaradd.h" 00042 00043 using namespace KCal; 00044 using namespace std; 00045 00046 KonsoleKalendarAdd::KonsoleKalendarAdd( KonsoleKalendarVariables *vars ) 00047 { 00048 m_variables = vars; 00049 } 00050 00051 KonsoleKalendarAdd::~KonsoleKalendarAdd() 00052 { 00053 } 00054 00059 bool KonsoleKalendarAdd::addEvent() 00060 { 00061 bool status = true; 00062 00063 kdDebug() << "konsolekalendaradd.cpp::addEvent()" << endl; 00064 00065 if ( m_variables->isDryRun() ) { 00066 cout << i18n("Insert Event <Dry Run>:").local8Bit() 00067 << endl; 00068 printSpecs(); 00069 } else { 00070 if ( m_variables->isVerbose() ) { 00071 cout << i18n("Insert Event <Verbose>:").local8Bit() 00072 << endl; 00073 printSpecs(); 00074 } 00075 00076 Event *event = new Event(); 00077 00078 event->setDtStart( m_variables->getStartDateTime() ); 00079 event->setDtEnd( m_variables->getEndDateTime() ); 00080 event->setSummary( m_variables->getSummary() ); 00081 event->setFloats( m_variables->getFloating() ); 00082 event->setDescription( m_variables->getDescription() ); 00083 event->setLocation( m_variables->getLocation() ); 00084 00085 if ( m_variables->getCalendar()->addEvent( event ) ) { 00086 cout << i18n("Success: \"%1\" inserted"). 00087 arg( m_variables->getSummary() ).local8Bit() 00088 << endl; 00089 00090 if ( ! m_variables->isCalendarResources() ) { 00091 status = 00092 m_variables->getCalendar()->save( m_variables->getCalendarFile() ); 00093 } else { 00094 m_variables->getCalendar()->save(); 00095 } 00096 00097 } else { 00098 cout << i18n("Failure: \"%1\" not inserted"). 00099 arg( m_variables->getSummary() ).local8Bit() 00100 << endl; 00101 status = false; 00102 } 00103 } 00104 00105 kdDebug() << "konsolekalendaradd.cpp::addEvent() | Done " << endl; 00106 return status; 00107 } 00108 00109 bool KonsoleKalendarAdd::addImportedCalendar() 00110 { 00111 00112 // TODO: reimplement this please.. 00113 00114 /*if ( ! m_variables->getCalendar()->load( m_variables->getImportFile() ) ) { 00115 kdDebug() 00116 << "konsolekalendaradd.cpp::importCalendar() | " 00117 << "Can't import file: " 00118 << m_variables->getImportFile() 00119 << endl; 00120 return false; 00121 } else { 00122 kdDebug() 00123 << "konsolekalendaradd.cpp::importCalendar() | " 00124 << "Successfully imported file: " 00125 << m_variables->getImportFile() 00126 << endl; 00127 } 00128 00129 if ( ! m_variables->isCalendarResources() ) { 00130 m_variables->getCalendar()->save( m_variables->getCalendarFile() ); 00131 } else { 00132 m_variables->getCalendar()->save(); 00133 }*/ 00134 00135 return true; 00136 } 00137 00138 void KonsoleKalendarAdd::printSpecs() 00139 { 00140 cout << i18n(" What: %1"). 00141 arg( m_variables->getSummary() ).local8Bit() 00142 << endl; 00143 00144 cout << i18n(" Begin: %1"). 00145 arg( m_variables->getStartDateTime().toString(Qt::TextDate) ).local8Bit() 00146 << endl; 00147 00148 cout << i18n(" End: %1"). 00149 arg( m_variables->getEndDateTime().toString(Qt::TextDate) ).local8Bit() 00150 << endl; 00151 00152 if ( m_variables->getFloating() == true ) { 00153 cout << i18n(" No Time Associated with Event").local8Bit() 00154 << endl; 00155 } 00156 00157 cout << i18n(" Desc: %1"). 00158 arg( m_variables->getDescription() ).local8Bit() 00159 << endl; 00160 00161 cout << i18n(" Location: %1"). 00162 arg( m_variables->getLocation() ).local8Bit() 00163 << endl; 00164 }
KDE Logo
This file is part of the documentation for konsolekalendar Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:59 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003