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 <qpopupmenu.h>
00026 #include <qcursor.h>
00027 
00028 #include <klocale.h>
00029 #include <kdebug.h>
00030 #include <kiconloader.h>
00031 #include <kmessagebox.h>
00032 #include <kxmlguiclient.h>
00033 #include <kxmlguifactory.h>
00034 
00035 #include <libkcal/calendar.h>
00036 
00037 
00038 #include "kocore.h"
00039 #include "koeventview.h"
00040 #include "koeventpopupmenu.h"
00041 
00042 using namespace KOrg;
00043 #include "koeventview.moc"
00044 
00045 //---------------------------------------------------------------------------
00046 
00047 KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name)
00048   : KOrg::BaseView(cal,parent,name)
00049 {
00050 }
00051 
00052 //---------------------------------------------------------------------------
00053 
00054 KOEventView::~KOEventView()
00055 {
00056 }
00057 
00058 //---------------------------------------------------------------------------
00059 
00060 KOEventPopupMenu *KOEventView::eventPopup()
00061 {
00062   KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
00063   
00064   connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)),
00065                      SIGNAL(editIncidenceSignal(Incidence *)));
00066   connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)),
00067                      SIGNAL(showIncidenceSignal(Incidence *)));
00068   connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)),
00069                      SIGNAL(deleteIncidenceSignal(Incidence *)));
00070   connect(eventPopup,SIGNAL(cutIncidenceSignal(Incidence *)),
00071                      SIGNAL(cutIncidenceSignal(Incidence *)));
00072   connect(eventPopup,SIGNAL(copyIncidenceSignal(Incidence *)),
00073                      SIGNAL(copyIncidenceSignal(Incidence *)));
00074   connect(eventPopup,SIGNAL(toggleAlarmSignal(Incidence *)),
00075                      SIGNAL(toggleAlarmSignal(Incidence*)));
00076   connect(eventPopup,SIGNAL(dissociateOccurrenceSignal( Incidence *, const QDate & )),
00077                      SIGNAL(dissociateOccurrenceSignal( Incidence *, const QDate & )));
00078   connect(eventPopup,SIGNAL(dissociateFutureOccurrenceSignal( Incidence *, const QDate & )),
00079                      SIGNAL(dissociateFutureOccurrenceSignal( Incidence *, const QDate & )));
00080 
00081   return eventPopup;
00082 }
00083 
00084 QPopupMenu *KOEventView::newEventPopup()
00085 {
00086   KXMLGUIClient *client = KOCore::self()->xmlguiClient( this );
00087   if ( !client ) {
00088     kdError() << "KOEventView::newEventPopup(): no xmlGuiClient." << endl;
00089     return 0;
00090   }
00091   if ( !client->factory() ) {
00092     kdError() << "KOEventView::newEventPopup(): no factory" << endl;
00093     return 0; // can happen if called too early
00094   }
00095 
00096   return static_cast<QPopupMenu*>
00097       ( client->factory()->container( "rmb_selection_popup", client ) );
00098 }
00099 //---------------------------------------------------------------------------
00100 
00101 void KOEventView::popupShow()
00102 {
00103   emit showIncidenceSignal(mCurrentIncidence);
00104 }
00105 
00106 //---------------------------------------------------------------------------
00107 
00108 void KOEventView::popupEdit()
00109 {
00110   emit editIncidenceSignal(mCurrentIncidence);
00111 }
00112 
00113 //---------------------------------------------------------------------------
00114 
00115 void KOEventView::popupDelete()
00116 {
00117   emit deleteIncidenceSignal(mCurrentIncidence);
00118 }
00119 
00120 //---------------------------------------------------------------------------
00121 
00122 void KOEventView::popupCut()
00123 {
00124   emit cutIncidenceSignal(mCurrentIncidence);
00125 }
00126 
00127 //---------------------------------------------------------------------------
00128 
00129 void KOEventView::popupCopy()
00130 {
00131   emit copyIncidenceSignal(mCurrentIncidence);
00132 }
00133 
00134 //---------------------------------------------------------------------------
00135 
00136 void KOEventView::showNewEventPopup()
00137 {
00138   QPopupMenu *popup = newEventPopup();
00139   if ( !popup ) {
00140     kdError() << "KOEventView::showNewEventPopup(): popup creation failed"
00141               << endl;
00142     return;
00143   }
00144 
00145   popup->popup( QCursor::pos() );
00146 }
00147 
00148 //---------------------------------------------------------------------------
00149 
00150 void KOEventView::defaultAction( Incidence *incidence )
00151 {
00152   kdDebug(5850) << "KOEventView::defaultAction()" << endl;
00153 
00154   if ( !incidence ) return;
00155 
00156   kdDebug(5850) << "  type: " << incidence->type() << endl;
00157 
00158   if ( incidence->isReadOnly() )
00159     emit showIncidenceSignal(incidence);
00160   else
00161     emit editIncidenceSignal(incidence);
00162 }
00163 
00164 //---------------------------------------------------------------------------
00165 
00166 #include "baseview.moc"
00167 
KDE Home | KDE Accessibility Home | Description of Access Keys