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

korganizer

  • sources
  • kde-4.12
  • kdepim
  • korganizer
koeventview.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "koeventview.h"
27 #include "kocore.h"
28 #include "koeventpopupmenu.h"
29 
30 #include <Akonadi/Calendar/ETMCalendar>
31 #include <calendarsupport/kcalprefs.h>
32 #include <calendarsupport/utils.h>
33 
34 #include <libkdepim/widgets/pimmessagebox.h>
35 
36 #include <KXMLGUIFactory>
37 
38 #include <QApplication>
39 #include <QMenu>
40 
41 //---------------------------------------------------------------------------
42 
43 KOEventView::KOEventView( QWidget *parent )
44  : KOrg::BaseView( parent )
45 {
46  mReturnPressed = false;
47  mTypeAhead = false;
48  mTypeAheadReceiver = 0;
49 
50  //AKONADI_PORT review: the FocusLineEdit in the editor emits focusReceivedSignal(),
51  //which triggered finishTypeAhead. But the global focus widget in QApplication is
52  //changed later, thus subsequent keyevents still went to this view, triggering
53  //another editor, for each keypress
54  //Thus listen to the global focusChanged() signal (seen with Qt 4.6-stable-patched 20091112)
55  // -Frank
56  connect( qobject_cast<QApplication*>( QApplication::instance() ),
57  SIGNAL(focusChanged(QWidget*,QWidget*)),
58  this, SLOT(focusChanged(QWidget*,QWidget*)) );
59 }
60 
61 //---------------------------------------------------------------------------
62 
63 KOEventView::~KOEventView()
64 {
65 }
66 
67 //---------------------------------------------------------------------------
68 
69 KOEventPopupMenu *KOEventView::eventPopup()
70 {
71  KOEventPopupMenu *eventPopup = new KOEventPopupMenu( calendar().data(), this );
72 
73  connect( eventPopup, SIGNAL(editIncidenceSignal(Akonadi::Item)),
74  SIGNAL(editIncidenceSignal(Akonadi::Item)));
75  connect( eventPopup, SIGNAL(showIncidenceSignal(Akonadi::Item)),
76  SIGNAL(showIncidenceSignal(Akonadi::Item)));
77  connect( eventPopup, SIGNAL(deleteIncidenceSignal(Akonadi::Item)),
78  SIGNAL(deleteIncidenceSignal(Akonadi::Item)));
79  connect( eventPopup, SIGNAL(cutIncidenceSignal(Akonadi::Item)),
80  SIGNAL(cutIncidenceSignal(Akonadi::Item)));
81  connect( eventPopup, SIGNAL(copyIncidenceSignal(Akonadi::Item)),
82  SIGNAL(copyIncidenceSignal(Akonadi::Item)));
83  connect( eventPopup, SIGNAL(pasteIncidenceSignal()),
84  SIGNAL(pasteIncidenceSignal()));
85  connect( eventPopup, SIGNAL(toggleAlarmSignal(Akonadi::Item)),
86  SIGNAL(toggleAlarmSignal(Akonadi::Item)));
87  connect( eventPopup, SIGNAL(toggleTodoCompletedSignal(Akonadi::Item)),
88  SIGNAL(toggleTodoCompletedSignal(Akonadi::Item)));
89  connect( eventPopup, SIGNAL(copyIncidenceToResourceSignal(Akonadi::Item,QString)),
90  SIGNAL(copyIncidenceToResourceSignal(Akonadi::Item,QString)));
91  connect( eventPopup, SIGNAL(moveIncidenceToResourceSignal(Akonadi::Item,QString)),
92  SIGNAL(moveIncidenceToResourceSignal(Akonadi::Item,QString)));
93  connect( eventPopup, SIGNAL(dissociateOccurrencesSignal(Akonadi::Item,QDate)),
94  SIGNAL(dissociateOccurrencesSignal(Akonadi::Item,QDate)) );
95 
96  return eventPopup;
97 }
98 
99 QMenu *KOEventView::newEventPopup()
100 {
101  KXMLGUIClient *client = KOCore::self()->xmlguiClient( this );
102  if ( !client ) {
103  kError() << "no xmlGuiClient.";
104  return 0;
105  }
106  if ( !client->factory() ) {
107  kError() << "no factory";
108  return 0; // can happen if called too early
109  }
110 
111  return static_cast<QMenu*>
112  ( client->factory()->container( QLatin1String("rmb_selection_popup"), client ) );
113 }
114 //---------------------------------------------------------------------------
115 
116 void KOEventView::popupShow()
117 {
118  emit showIncidenceSignal(mCurrentIncidence);
119 }
120 
121 //---------------------------------------------------------------------------
122 
123 void KOEventView::popupEdit()
124 {
125  emit editIncidenceSignal(mCurrentIncidence);
126 }
127 
128 //---------------------------------------------------------------------------
129 
130 void KOEventView::popupDelete()
131 {
132  emit deleteIncidenceSignal(mCurrentIncidence);
133 }
134 
135 //---------------------------------------------------------------------------
136 
137 void KOEventView::popupCut()
138 {
139  emit cutIncidenceSignal(mCurrentIncidence);
140 }
141 
142 //---------------------------------------------------------------------------
143 
144 void KOEventView::popupCopy()
145 {
146  emit copyIncidenceSignal(mCurrentIncidence);
147 }
148 
149 //---------------------------------------------------------------------------
150 
151 void KOEventView::showNewEventPopup()
152 {
153  QMenu *popup = newEventPopup();
154  if ( !popup ) {
155  kError() << "popup creation failed";
156  return;
157  }
158 
159  popup->popup( QCursor::pos() );
160 }
161 
162 //---------------------------------------------------------------------------
163 
164 void KOEventView::defaultAction( const Akonadi::Item &aitem )
165 {
166  kDebug();
167  const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( aitem );
168  if ( !incidence ) {
169  kDebug() << "Ouch, null incidence";
170  return;
171  }
172 
173  if ( !calendar()->hasRight( aitem, Akonadi::Collection::CanChangeItem ) ) {
174  emit showIncidenceSignal( aitem );
175  } else {
176  emit editIncidenceSignal( aitem );
177  }
178 }
179 
180 //---------------------------------------------------------------------------
181 int KOEventView::showMoveRecurDialog( const Akonadi::Item &aitem, const QDate &date )
182 {
183  const KCalCore::Incidence::Ptr inc = CalendarSupport::incidence( aitem );
184  int answer = KMessageBox::Ok;
185  KGuiItem itemFuture( i18n( "Also &Future Items" ) );
186 
187  KDateTime dateTime( date, CalendarSupport::KCalPrefs::instance()->timeSpec() );
188  bool isFirst = !inc->recurrence()->getPreviousDateTime( dateTime ).isValid();
189  bool isLast = !inc->recurrence()->getNextDateTime( dateTime ).isValid();
190 
191  QString message;
192 
193  if ( !isFirst && !isLast ) {
194  itemFuture.setEnabled( true );
195  message = i18n( "The item you are trying to change is a recurring item. "
196  "Should the changes be applied only to this single occurrence, "
197  "also to future items, or to all items in the recurrence?" );
198  } else {
199  itemFuture.setEnabled( false );
200  message = i18n( "The item you are trying to change is a recurring item. "
201  "Should the changes be applied only to this single occurrence "
202  "or to all items in the recurrence?" );
203  }
204 
205  if ( !( isFirst && isLast ) ) {
206  answer = PIMMessageBox::fourBtnMsgBox(
207  this,
208  QMessageBox::Question,
209  message,
210  i18n( "Changing Recurring Item" ),
211  KGuiItem( i18n( "Only &This Item" ) ),
212  itemFuture,
213  KGuiItem( i18n( "&All Occurrences" ) ) );
214  }
215 
216  return answer;
217 }
218 
219 void KOEventView::setTypeAheadReceiver( QObject *o )
220 {
221  mTypeAheadReceiver = o;
222 }
223 
224 void KOEventView::focusChanged( QWidget *, QWidget *now )
225 {
226  if ( mTypeAhead && now && now == mTypeAheadReceiver ) {
227  finishTypeAhead();
228  }
229 }
230 
231 void KOEventView::finishTypeAhead()
232 {
233  if ( mTypeAheadReceiver ) {
234  foreach ( QEvent *e, mTypeAheadEvents ) {
235  QApplication::sendEvent( mTypeAheadReceiver, e );
236  }
237  }
238  qDeleteAll( mTypeAheadEvents );
239  mTypeAheadEvents.clear();
240  mTypeAhead = false;
241 }
242 
243 bool KOEventView::usesCompletedTodoPixmap( const Akonadi::Item &aitem, const QDate &date )
244 {
245  const KCalCore::Todo::Ptr todo = CalendarSupport::todo( aitem );
246  if ( !todo ) {
247  return false;
248  }
249 
250  if ( todo->isCompleted() ) {
251  return true;
252  } else if ( todo->recurs() ) {
253  QTime time;
254  if ( todo->allDay() ) {
255  time = QTime( 0, 0 );
256  } else {
257  time = todo->dtDue().toTimeSpec( CalendarSupport::KCalPrefs::instance()->timeSpec() ).time();
258  }
259 
260  KDateTime itemDateTime( date, time, CalendarSupport::KCalPrefs::instance()->timeSpec() );
261 
262  return itemDateTime < todo->dtDue( false );
263 
264  } else {
265  return false;
266  }
267 }
268 
269 #include "koeventview.moc"
270 
KOEventView::focusChanged
void focusChanged(QWidget *, QWidget *)
Definition: koeventview.cpp:224
KOEventView::popupEdit
void popupEdit()
Definition: koeventview.cpp:123
KOEventView::setTypeAheadReceiver
virtual void setTypeAheadReceiver(QObject *o)
Definition: koeventview.cpp:219
KOEventView::popupDelete
void popupDelete()
Definition: koeventview.cpp:130
KOCore::xmlguiClient
KXMLGUIClient * xmlguiClient(QWidget *) const
Definition: kocore.cpp:226
QWidget
KOrg::BaseView::toggleAlarmSignal
void toggleAlarmSignal(const Akonadi::Item &)
instructs the receiver to toggle the alarms of the Incidence.
KOEventView::showMoveRecurDialog
int showMoveRecurDialog(const Akonadi::Item &inc, const QDate &date)
Definition: koeventview.cpp:181
QObject
KOEventView::popupShow
void popupShow()
Definition: koeventview.cpp:116
KOrg::BaseView::dissociateOccurrencesSignal
void dissociateOccurrencesSignal(const Akonadi::Item &, const QDate &)
Dissociate from a recurring incidence the occurrence on the given date to a new incidence or dissocia...
KOrg::BaseView::editIncidenceSignal
void editIncidenceSignal(const Akonadi::Item &)
instructs the receiver to begin editing the incidence specified in some manner.
koeventpopupmenu.h
koeventview.h
KOrg::BaseView::showIncidenceSignal
void showIncidenceSignal(const Akonadi::Item &)
instructs the receiver to show the incidence in read-only mode.
KOrg::BaseView::copyIncidenceSignal
void copyIncidenceSignal(const Akonadi::Item &)
instructs the receiver to copy the incidence
KOrg::BaseView::cutIncidenceSignal
void cutIncidenceSignal(const Akonadi::Item &)
instructs the receiver to cut the Incidence
KOEventView::usesCompletedTodoPixmap
static bool usesCompletedTodoPixmap(const Akonadi::Item &todo, const QDate &date)
Definition: koeventview.cpp:243
KOEventView::mCurrentIncidence
Akonadi::Item mCurrentIncidence
Definition: koeventview.h:156
KOEventView::newEventPopup
QMenu * newEventPopup()
Construct a standard context that allows to create a new event.
Definition: koeventview.cpp:99
KOrg::BaseView::toggleTodoCompletedSignal
void toggleTodoCompletedSignal(const Akonadi::Item &)
instructs the receiver to toggle the completion state of the Incidence (which must be a Todo type)...
KOEventView::eventPopup
KOEventPopupMenu * eventPopup()
Construct a standard context menu for an event.
Definition: koeventview.cpp:69
KOrg::BaseView::deleteIncidenceSignal
void deleteIncidenceSignal(const Akonadi::Item &)
instructs the receiver to delete the Incidence in some manner; some possibilities include automatical...
KOrg::BaseView::moveIncidenceToResourceSignal
void moveIncidenceToResourceSignal(const Akonadi::Item &, const QString &)
Move the incidence to the specified resource.
KOrg::BaseView::calendar
virtual Akonadi::ETMCalendar::Ptr calendar()
Return calendar object of this view.
Definition: baseview.cpp:80
KOEventPopupMenu
Context menu for event views with standard event actions.
Definition: koeventpopupmenu.h:38
QMenu
KOEventView::popupCut
void popupCut()
Definition: koeventview.cpp:137
KOrg::BaseView::copyIncidenceToResourceSignal
void copyIncidenceToResourceSignal(const Akonadi::Item &, const QString &)
Copy the incidence to the specified resource.
KOEventView::~KOEventView
virtual ~KOEventView()
Destructor.
Definition: koeventview.cpp:63
KOEventView::popupCopy
void popupCopy()
Definition: koeventview.cpp:144
KOEventView::defaultAction
void defaultAction(const Akonadi::Item &incidence)
Performs the default action for an incidence, e.g.
Definition: koeventview.cpp:164
kocore.h
KOCore::self
static KOCore * self()
Definition: kocore.cpp:37
KOrg::BaseView::pasteIncidenceSignal
void pasteIncidenceSignal()
instructs the receiver to paste the incidence
KOEventView::showNewEventPopup
virtual void showNewEventPopup()
Definition: koeventview.cpp:151
KOEventView::KOEventView
KOEventView(QWidget *parent=0)
Constructs a view.
Definition: koeventview.cpp:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

korganizer

Skip menu "korganizer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • 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