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 <klocale.h>
29 #include <kdebug.h>
30 #include <kiconloader.h>
31 #include <kmessagebox.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, TQT_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)),
65  TQT_SIGNAL(editIncidenceSignal(Incidence *,const TQDate &)) );
66  connect( eventPopup, TQT_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)),
67  TQT_SIGNAL(showIncidenceSignal(Incidence *,const TQDate &)) );
68  connect( eventPopup, TQT_SIGNAL(deleteIncidenceSignal(Incidence *)),
69  TQT_SIGNAL(deleteIncidenceSignal(Incidence *)) );
70  connect( eventPopup, TQT_SIGNAL(cutIncidenceSignal(Incidence *)),
71  TQT_SIGNAL(cutIncidenceSignal(Incidence *)) );
72  connect( eventPopup, TQT_SIGNAL(copyIncidenceSignal(Incidence *)),
73  TQT_SIGNAL(copyIncidenceSignal(Incidence *)) );
74  connect( eventPopup, TQT_SIGNAL(pasteIncidenceSignal()),
75  TQT_SIGNAL(pasteIncidenceSignal()) );
76  connect( eventPopup, TQT_SIGNAL(toggleAlarmSignal(Incidence *)),
77  TQT_SIGNAL(toggleAlarmSignal(Incidence*)) );
78  connect( eventPopup, TQT_SIGNAL(dissociateOccurrenceSignal(Incidence *,const TQDate &)),
79  TQT_SIGNAL(dissociateOccurrenceSignal(Incidence *,const TQDate &)) );
80  connect( eventPopup, TQT_SIGNAL(dissociateFutureOccurrenceSignal(Incidence *,const TQDate &)),
81  TQT_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