korganizer

koeventview.cpp

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
00004     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include "koprefs.h"
00026 #include "kocore.h"
00027 #include "koeventview.h"
00028 #include "koeventpopupmenu.h"
00029 
00030 #include <libkcal/calendar.h>
00031 
00032 #include <klocale.h>
00033 #include <kdebug.h>
00034 #include <kiconloader.h>
00035 #include <kmessagebox.h>
00036 #include <kxmlguiclient.h>
00037 #include <kxmlguifactory.h>
00038 
00039 #include <qpopupmenu.h>
00040 #include <qcursor.h>
00041 
00042 
00043 using namespace KOrg;
00044 #include "koeventview.moc"
00045 
00046 //---------------------------------------------------------------------------
00047 
00048 KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name)
00049   : KOrg::BaseView(cal,parent,name)
00050 {
00051 }
00052 
00053 //---------------------------------------------------------------------------
00054 
00055 KOEventView::~KOEventView()
00056 {
00057 }
00058 
00059 //---------------------------------------------------------------------------
00060 
00061 KOEventPopupMenu *KOEventView::eventPopup()
00062 {
00063   KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
00064 
00065   connect( eventPopup, SIGNAL(editIncidenceSignal(Incidence *,const QDate &)),
00066            SIGNAL(editIncidenceSignal(Incidence *,const QDate &)) );
00067   connect( eventPopup, SIGNAL(showIncidenceSignal(Incidence *,const QDate &)),
00068            SIGNAL(showIncidenceSignal(Incidence *,const QDate &)) );
00069   connect( eventPopup, SIGNAL(deleteIncidenceSignal(Incidence *)),
00070            SIGNAL(deleteIncidenceSignal(Incidence *)) );
00071   connect( eventPopup, SIGNAL(cutIncidenceSignal(Incidence *)),
00072            SIGNAL(cutIncidenceSignal(Incidence *)) );
00073   connect( eventPopup, SIGNAL(copyIncidenceSignal(Incidence *)),
00074            SIGNAL(copyIncidenceSignal(Incidence *)) );
00075   connect( eventPopup, SIGNAL(pasteIncidenceSignal()),
00076            SIGNAL(pasteIncidenceSignal()) );
00077   connect( eventPopup, SIGNAL(toggleAlarmSignal(Incidence *)),
00078            SIGNAL(toggleAlarmSignal(Incidence*)) );
00079   connect( eventPopup, SIGNAL(dissociateOccurrenceSignal(Incidence *,const QDate &)),
00080            SIGNAL(dissociateOccurrenceSignal(Incidence *,const QDate &)) );
00081   connect( eventPopup, SIGNAL(dissociateFutureOccurrenceSignal(Incidence *,const QDate &)),
00082            SIGNAL(dissociateFutureOccurrenceSignal(Incidence *,const QDate &)) );
00083 
00084   return eventPopup;
00085 }
00086 
00087 QPopupMenu *KOEventView::newEventPopup()
00088 {
00089   KXMLGUIClient *client = KOCore::self()->xmlguiClient( this );
00090   if ( !client ) {
00091     kdError() << "KOEventView::newEventPopup(): no xmlGuiClient." << endl;
00092     return 0;
00093   }
00094   if ( !client->factory() ) {
00095     kdError() << "KOEventView::newEventPopup(): no factory" << endl;
00096     return 0; // can happen if called too early
00097   }
00098 
00099   return static_cast<QPopupMenu*>
00100       ( client->factory()->container( "rmb_selection_popup", client ) );
00101 }
00102 //---------------------------------------------------------------------------
00103 
00104 void KOEventView::popupShow()
00105 {
00106   emit showIncidenceSignal(mCurrentIncidence,  QDate() );
00107 }
00108 
00109 //---------------------------------------------------------------------------
00110 
00111 void KOEventView::popupEdit()
00112 {
00113   emit editIncidenceSignal( mCurrentIncidence, QDate() );
00114 }
00115 
00116 //---------------------------------------------------------------------------
00117 
00118 void KOEventView::popupDelete()
00119 {
00120   emit deleteIncidenceSignal(mCurrentIncidence);
00121 }
00122 
00123 //---------------------------------------------------------------------------
00124 
00125 void KOEventView::popupCut()
00126 {
00127   emit cutIncidenceSignal(mCurrentIncidence);
00128 }
00129 
00130 //---------------------------------------------------------------------------
00131 
00132 void KOEventView::popupCopy()
00133 {
00134   emit copyIncidenceSignal(mCurrentIncidence);
00135 }
00136 
00137 //---------------------------------------------------------------------------
00138 
00139 void KOEventView::showNewEventPopup()
00140 {
00141   if ( !readOnly() ) {
00142     QPopupMenu *popup = newEventPopup();
00143     if ( !popup ) {
00144       kdError() << "KOEventView::showNewEventPopup(): popup creation failed"
00145                 << endl;
00146       return;
00147     }
00148 
00149     popup->popup( QCursor::pos() );
00150   }
00151 }
00152 
00153 //---------------------------------------------------------------------------
00154 
00155 void KOEventView::defaultAction( Incidence *incidence )
00156 {
00157   kdDebug(5850) << "KOEventView::defaultAction()" << endl;
00158 
00159   if ( !incidence ) return;
00160 
00161   kdDebug(5850) << "  type: " << incidence->type() << endl;
00162 
00163   if ( incidence->isReadOnly() ) {
00164     emit showIncidenceSignal( incidence, QDate() );
00165   } else {
00166     emit editIncidenceSignal( incidence, QDate() );
00167   }
00168 }
00169 
00170 //---------------------------------------------------------------------------
00171 /* static */
00172 bool KOEventView::makesWholeDayBusy( Incidence *incidence )
00173 {
00174   // Must be enabled in config
00175   // Must be event
00176   // Must be all day
00177   // Must be marked busy (TRANSP: OPAQUE)
00178   // You must be attendee or organizer
00179   if ( !KOPrefs::instance()->mColorBusyDaysEnabled ) {
00180     return false;
00181   }
00182 
00183   if ( incidence->type() != "Event" || !incidence->doesFloat() ) {
00184     return false;
00185   }
00186 
00187   Event *ev = static_cast<Event*>( incidence );
00188 
00189   if ( ev->transparency() != Event::Opaque ) {
00190     return false;
00191   }
00192 
00193   // Last check: must be organizer or attendee:
00194   if ( KOPrefs::instance()->thatIsMe( ev->organizer().email() ) ) {
00195     return true;
00196   }
00197 
00198   KCal::Attendee::List attendees = ev->attendees();
00199   KCal::Attendee::List::ConstIterator it;
00200   for ( it = attendees.constBegin(); it != attendees.constEnd(); ++it ) {
00201     if ( KOPrefs::instance()->thatIsMe( (*it)->email() ) ) {
00202       return true;
00203     }
00204   }
00205 
00206   return false;
00207 }
00208 //---------------------------------------------------------------------------
00209 
00210 
00211 #include "baseview.moc"
00212 
KDE Home | KDE Accessibility Home | Description of Access Keys