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

KonsoleKalendar

  • sources
  • kde-4.14
  • kdepim
  • console
  • 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 Qt, and distribute the resulting executable, *
24  * without including the source code for Qt in the source distribution. *
25  * *
26  ******************************************************************************/
33 #include "konsolekalendardelete.h"
34 
35 #include <stdlib.h>
36 #include <iostream>
37 
38 #include <kdebug.h>
39 #include <klocale.h>
40 #include <QEventLoop>
41 
42 using namespace KCalCore;
43 using namespace std;
44 
45 KonsoleKalendarDelete::KonsoleKalendarDelete( KonsoleKalendarVariables *vars )
46 {
47  m_variables = vars;
48 }
49 
50 KonsoleKalendarDelete::~KonsoleKalendarDelete()
51 {
52 }
53 
54 bool KonsoleKalendarDelete::deleteEvent()
55 {
56  bool status = false;
57 
58  kDebug() << "konsolekalendardelete.cpp::deleteEvent()";
59 
60  /*
61  * Retrieve event on the basis of the unique string ID
62  */
63  Event::Ptr event = m_variables->getCalendar()->event( m_variables->getUID() );
64  if ( event ) {
65  if ( m_variables->isDryRun() ) {
66  cout << i18n( "Delete Event &lt;Dry Run&gt;:" ).data()
67  << endl;
68  printSpecs( event );
69  } else {
70  kDebug() << "konsolekalendardelete.cpp:deleteEvent() :"
71  << m_variables->getUID().data();
72 
73  if ( m_variables->isVerbose() ) {
74  cout << i18n( "Delete Event &lt;Verbose&gt;:" ).data()
75  << endl;
76  printSpecs( event );
77  }
78 
79  QEventLoop loop;
80  Akonadi::CalendarBase::Ptr calendar = m_variables->getCalendar();
81  QObject::connect(calendar.data(), SIGNAL(deleteFinished(bool,QString)),
82  &loop, SLOT(quit()));
83  calendar->deleteEvent( event );
84  loop.exec();
85  kDebug() << "Finished deleting";
86  status = calendar->incidence(event->uid()) == 0;
87 
88  if (status) {
89  cout << i18n( "Success: \"%1\" deleted", event->summary() ).data() << endl;
90  } else {
91  cout << i18n( "Error deleting: \"%1\"", event->summary() ).data() << endl;
92  }
93  }
94  }
95 
96  kDebug() << "konsolekalendardelete.cpp::deleteEvent() | Done";
97  return status;
98 }
99 
100 void KonsoleKalendarDelete::printSpecs( const Event::Ptr &event )
101 {
102  cout << i18n( " UID: %1", m_variables->getUID() ).data()
103  << endl;
104 
105  cout << i18n( " What: %1", event->summary() ).data()
106  << endl;
107 
108  KDateTime::Spec timeSpec = m_variables->getCalendar()->timeSpec();
109  cout << i18n( " Begin: %1",
110  event->dtStart().toTimeSpec( timeSpec ).dateTime().toString( Qt::TextDate ) ).data()
111  << endl;
112 
113  cout << i18n( " End: %1",
114  event->dtEnd().toTimeSpec( timeSpec ).dateTime().toString( Qt::TextDate ) ).data()
115  << endl;
116 
117  cout << i18n( " Desc: %1",
118  event->description() ).data()
119  << endl;
120 
121  cout << i18n( " Location: %1",
122  event->location() ).data()
123  << endl;
124 }
QEventLoop
KonsoleKalendarVariables
This class provides all the variables for the program.
Definition: konsolekalendarvariables.h:73
KonsoleKalendarDelete::deleteEvent
bool deleteEvent()
Delete the Event.
Definition: konsolekalendardelete.cpp:54
konsolekalendardelete.h
Provides the KonsoleKalendarDelete class definition.
QEventLoop::exec
int exec(QFlags< QEventLoop::ProcessEventsFlag > flags)
KonsoleKalendarDelete::~KonsoleKalendarDelete
~KonsoleKalendarDelete()
Destructor.
Definition: konsolekalendardelete.cpp:50
QString
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KonsoleKalendarDelete::KonsoleKalendarDelete
KonsoleKalendarDelete(KonsoleKalendarVariables *vars)
Constructs a KonsoleKalendarDelete object from command line arguments.
Definition: konsolekalendardelete.cpp:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:26 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
  • pimprint

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