korganizer

koeventview.cpp
1 /*
2  This file is part of KOrganizer.
3  Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of TQt, and distribute the resulting executable,
22  without including the source code for TQt in the source distribution.
23 */
24 
25 #include <tqpopupmenu.h>
26 #include <tqcursor.h>
27 
28 #include <tdelocale.h>
29 #include <kdebug.h>
30 #include <kiconloader.h>
31 #include <tdemessagebox.h>
32 #include <kxmlguiclient.h>
33 #include <kxmlguifactory.h>
34 
35 #include <libkcal/calendar.h>
36 
37 
38 #include "kocore.h"
39 #include "koeventview.h"
40 #include "koeventpopupmenu.h"
41 
42 using namespace KOrg;
43 #include "koeventview.moc"
44 
45 //---------------------------------------------------------------------------
46 
47 KOEventView::KOEventView(Calendar *cal,TQWidget *parent,const char *name)
48  : KOrg::BaseView(cal,parent,name)
49 {
50 }
51 
52 //---------------------------------------------------------------------------
53 
55 {
56 }
57 
58 //---------------------------------------------------------------------------
59 
60 KOEventPopupMenu *KOEventView::eventPopup()
61 {
62  KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
63 
64  connect( eventPopup, TQ_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)),
65  TQ_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)) );
66  connect( eventPopup, TQ_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)),
67  TQ_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)) );
68  connect( eventPopup, TQ_SIGNAL(deleteIncidenceSignal(Incidence *)),
69  TQ_SIGNAL(deleteIncidenceSignal(Incidence *)) );
70  connect( eventPopup, TQ_SIGNAL(cutIncidenceSignal(Incidence *)),
71  TQ_SIGNAL(cutIncidenceSignal(Incidence *)) );
72  connect( eventPopup, TQ_SIGNAL(copyIncidenceSignal(Incidence *)),
73  TQ_SIGNAL(copyIncidenceSignal(Incidence *)) );
74  connect( eventPopup, TQ_SIGNAL(pasteIncidenceSignal()),
75  TQ_SIGNAL(pasteIncidenceSignal()) );
76  connect( eventPopup, TQ_SIGNAL(toggleAlarmSignal(Incidence *)),
77  TQ_SIGNAL(toggleAlarmSignal(Incidence*)) );
78  connect( eventPopup, TQ_SIGNAL(dissociateOccurrenceSignal(Incidence *,const TQDate &)),
79  TQ_SIGNAL(dissociateOccurrenceSignal(Incidence *,const TQDate &)) );
80  connect( eventPopup, TQ_SIGNAL(dissociateFutureOccurrenceSignal(Incidence *,const TQDate &)),
81  TQ_SIGNAL(dissociateFutureOccurrenceSignal(Incidence *,const TQDate &)) );
82 
83  return eventPopup;
84 }
85 
87 {
88  KXMLGUIClient *client = KOCore::self()->xmlguiClient( this );
89  if ( !client ) {
90  kdError() << "KOEventView::newEventPopup(): no xmlGuiClient." << endl;
91  return 0;
92  }
93  if ( !client->factory() ) {
94  kdError() << "KOEventView::newEventPopup(): no factory" << endl;
95  return 0; // can happen if called too early
96  }
97 
98  return static_cast<TQPopupMenu*>
99  ( client->factory()->container( "rmb_selection_popup", client ) );
100 }
101 //---------------------------------------------------------------------------
102 
103 void KOEventView::popupShow()
104 {
105  emit showIncidenceSignal(mCurrentIncidence, TQDate() );
106 }
107 
108 //---------------------------------------------------------------------------
109 
110 void KOEventView::popupEdit()
111 {
112  emit editIncidenceSignal( mCurrentIncidence, TQDate() );
113 }
114 
115 //---------------------------------------------------------------------------
116 
117 void KOEventView::popupDelete()
118 {
119  emit deleteIncidenceSignal(mCurrentIncidence);
120 }
121 
122 //---------------------------------------------------------------------------
123 
124 void KOEventView::popupCut()
125 {
126  emit cutIncidenceSignal(mCurrentIncidence);
127 }
128 
129 //---------------------------------------------------------------------------
130 
131 void KOEventView::popupCopy()
132 {
133  emit copyIncidenceSignal(mCurrentIncidence);
134 }
135 
136 //---------------------------------------------------------------------------
137 
138 void KOEventView::showNewEventPopup()
139 {
140  if ( !readOnly() ) {
141  TQPopupMenu *popup = newEventPopup();
142  if ( !popup ) {
143  kdError() << "KOEventView::showNewEventPopup(): popup creation failed"
144  << endl;
145  return;
146  }
147 
148  popup->popup( TQCursor::pos() );
149  }
150 }
151 
152 //---------------------------------------------------------------------------
153 
155 {
156  kdDebug(5850) << "KOEventView::defaultAction()" << endl;
157 
158  if ( !incidence ) return;
159 
160  kdDebug(5850) << " type: " << incidence->type() << endl;
161 
162  if ( incidence->isReadOnly() ) {
163  emit showIncidenceSignal( incidence, TQDate() );
164  } else {
165  emit editIncidenceSignal( incidence, TQDate() );
166  }
167 }
168 
169 //---------------------------------------------------------------------------
170 
171 #include "baseview.moc"
172 
bool isReadOnly() const
KOEventView(Calendar *cal, TQWidget *parent=0, const char *name=0)
Constructs a view.
Definition: koeventview.cpp:47
TQPopupMenu * newEventPopup()
Construct a standard context that allows to create a new event.
Definition: koeventview.cpp:86
virtual ~KOEventView()
Destructor.
Definition: koeventview.cpp:54
KOEventPopupMenu * eventPopup()
Construct a standard context menu for an event.
Definition: koeventview.cpp:60
void defaultAction(Incidence *)
Perform the default action for an incidence, e.g.
This class provides an interface for all views being displayed within the main calendar view.
Definition: baseview.h:60
void copyIncidenceSignal(Incidence *)
instructs the receiver to copy the incidence
void dissociateOccurrenceSignal(Incidence *, const TQDate &)
Dissociate from a recurring incidence the occurrence on the given date to a new incidence.
void toggleAlarmSignal(Incidence *)
instructs the receiver to toggle the alarms of the Incidence.
void editIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to begin editing the incidence specified in some manner.
void dissociateFutureOccurrenceSignal(Incidence *, const TQDate &)
Dissociate from a recurring incidence all occurrences after the given date to a new incidence.
void cutIncidenceSignal(Incidence *)
instructs the receiver to cut the Incidence
void deleteIncidenceSignal(Incidence *)
instructs the receiver to delete the Incidence in some manner; some possibilities include automatical...
void pasteIncidenceSignal()
instructs the receiver to paste the incidence
void showIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to show the incidence in read-only mode.