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

KonsoleKalendar

  • sources
  • kde-4.12
  • kdepim
  • console
  • konsolekalendar
konsolekalendarchange.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * konsolekalendarchange.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 along *
19  * with this program; if not, write to the Free Software Foundation, Inc., *
20  * 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 Qt, and distribute the resulting executable, *
24  * without including the source code for Qt in the source distribution. *
25  * *
26  *****************************************************************************/
33 #include "konsolekalendarchange.h"
34 
35 #include <kdebug.h>
36 #include <klocale.h>
37 
38 #include <QEventLoop>
39 
40 #include <stdlib.h>
41 #include <iostream>
42 
43 using namespace KCalCore;
44 using namespace std;
45 
46 KonsoleKalendarChange::KonsoleKalendarChange( KonsoleKalendarVariables *vars )
47 {
48  m_variables = vars;
49 }
50 
51 KonsoleKalendarChange::~KonsoleKalendarChange()
52 {
53 }
54 
55 bool KonsoleKalendarChange::changeEvent()
56 {
57  bool status = false;
58 
59  kDebug() << "konsolekalendarchange.cpp::changeEvent()";
60 
61  /*
62  * Retrieve event on the basis of the unique string ID
63  */
64  Event::Ptr event = m_variables->getCalendar()->event( m_variables->getUID() );
65  if ( event ) {
66  if ( m_variables->isDryRun() ) {
67  cout << i18n( "Change Event &lt;Dry Run&gt;:" ).toLocal8Bit().data()
68  << endl;
69  printSpecs( event );
70 
71  cout << i18n( "To Event &lt;Dry Run&gt;:" ).toLocal8Bit().data()
72  << endl;
73  printSpecs();
74  } else {
75  kDebug() << "konsolekalendarchange.cpp:changeEvent() :"
76  << m_variables->getUID().toLocal8Bit().data();
77 
78  if ( m_variables->isVerbose() ) {
79  cout << i18n( "Change Event &lt;Verbose&gt;:" ).toLocal8Bit().data()
80  << endl;
81  printSpecs( event );
82 
83  cout << i18n( "To Event &lt;Dry Run&gt;:" ).toLocal8Bit().data()
84  << endl;
85  printSpecs();
86  }
87 
88  event->startUpdates();
89  Akonadi::CalendarBase::Ptr calendar = m_variables->getCalendar();
90  KDateTime::Spec timeSpec = calendar->timeSpec();
91  if ( m_variables->isStartDateTime() ) {
92  event->setDtStart( KDateTime( m_variables->getStartDateTime(), timeSpec ) );
93  }
94 
95  if ( m_variables->isEndDateTime() ) {
96  event->setDtEnd( KDateTime( m_variables->getEndDateTime(), timeSpec ) );
97  }
98 
99  event->setAllDay( m_variables->getFloating() );
100 
101  if ( m_variables->isSummary() ) {
102  event->setSummary( m_variables->getSummary() );
103  }
104 
105  if ( m_variables->isDescription() ) {
106  event->setDescription( m_variables->getDescription() );
107  }
108 
109  if ( m_variables->isLocation() ) {
110  event->setLocation( m_variables->getLocation() );
111  }
112  event->endUpdates();
113  QEventLoop loop;
114  QObject::connect(calendar.data(), SIGNAL(modifyFinished(bool,QString)),
115  &loop, SLOT(quit()));
116  QElapsedTimer t;
117  t.start();
118  calendar->modifyIncidence(event);
119  loop.exec();
120 
121  status = *event == *calendar->incidence(event->uid());
122 
123  if ( status ) {
124  cout << i18n( "Success: \"%1\" changed", event->summary() ).toLocal8Bit().data()
125  << endl;
126  } else {
127  cout << i18n( "Failure: \"%1\" not changed", event->summary() ).toLocal8Bit().data()
128  << endl;
129  }
130  }
131  }
132 
133  kDebug() << "konsolekalendarchange.cpp::changeEvent() | Done";
134  return status;
135 }
136 
137 void KonsoleKalendarChange::printSpecs( const Event::Ptr &event )
138 {
139  cout << i18n( " UID: %1",
140  event->uid() ).toLocal8Bit().data()
141  << endl;
142 
143  cout << i18n( " What: %1",
144  event->summary() ).toLocal8Bit().data()
145  << endl;
146 
147  KDateTime::Spec timeSpec = m_variables->getCalendar()->timeSpec();
148  cout << i18n( " Begin: %1",
149  event->dtStart().toTimeSpec( timeSpec ).
150  dateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
151  << endl;
152 
153  cout << i18n( " End: %1",
154  event->dtEnd().toTimeSpec( timeSpec ).
155  dateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
156  << endl;
157 
158  cout << i18n( " Desc: %1",
159  event->description() ).toLocal8Bit().data()
160  << endl;
161 
162  cout << i18n( " Location: %1",
163  event->location() ).toLocal8Bit().data()
164  << endl;
165 }
166 
167 void KonsoleKalendarChange::printSpecs()
168 {
169  cout << i18n( " UID: %1",
170  m_variables->getUID() ).toLocal8Bit().data()
171  << endl;
172 
173  cout << i18n( " What: %1",
174  m_variables->getSummary() ).toLocal8Bit().data()
175  << endl;
176 
177  cout << i18n( " Begin: %1",
178  m_variables->getStartDateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
179  << endl;
180 
181  cout << i18n( " End: %1",
182  m_variables->getEndDateTime().toString( Qt::TextDate ) ).toLocal8Bit().data()
183  << endl;
184 
185  cout << i18n( " Desc: %1",
186  m_variables->getDescription() ).toLocal8Bit().data()
187  << endl;
188 
189  cout << i18n( " Location: %1",
190  m_variables->getLocation() ).toLocal8Bit().data()
191  << endl;
192 }
KonsoleKalendarChange::changeEvent
bool changeEvent()
Modify the Event.
Definition: konsolekalendarchange.cpp:55
KonsoleKalendarChange::~KonsoleKalendarChange
~KonsoleKalendarChange()
Destructor.
Definition: konsolekalendarchange.cpp:51
KonsoleKalendarVariables
This class provides all the variables for the program.
Definition: konsolekalendarvariables.h:73
KonsoleKalendarChange::KonsoleKalendarChange
KonsoleKalendarChange(KonsoleKalendarVariables *vars)
Constructs a KonsoleKalendarChange object from command line arguments.
Definition: konsolekalendarchange.cpp:46
konsolekalendarchange.h
Provides the KonsoleKalendarChange class definition.
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:04 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KonsoleKalendar

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal