konsolekalendaradd.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
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 }
This file is part of the documentation for konsolekalendar Library Version 3.3.2.