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(pasteIncidenceSignal()),
00075                      SIGNAL(pasteIncidenceSignal()));
00076   connect(eventPopup,SIGNAL(toggleAlarmSignal(Incidence *)),
00077                      SIGNAL(toggleAlarmSignal(Incidence*)));
00078   connect(eventPopup,SIGNAL(dissociateOccurrenceSignal( Incidence *, const QDate & )),
00079                      SIGNAL(dissociateOccurrenceSignal( Incidence *, const QDate & )));
00080   connect(eventPopup,SIGNAL(dissociateFutureOccurrenceSignal( Incidence *, const QDate & )),
00081                      SIGNAL(dissociateFutureOccurrenceSignal( Incidence *, const QDate & )));
00082 
00083   return eventPopup;
00084 }
00085 
00086 QPopupMenu *KOEventView::newEventPopup()
00087 {
00088   KXMLGUIClient *client = KOCore::self()->xmlguiClient( this );
00089   if ( !client ) {
00090     kdError() << "KOEventView::newEventPopup(): no xmlGuiClient." << endl;
00091     return 0;
00092   }
00093   if ( !client->factory() ) {
00094     kdError() << "KOEventView::newEventPopup(): no factory" << endl;
00095     return 0; // can happen if called too early
00096   }
00097 
00098   return static_cast<QPopupMenu*>
00099       ( client->factory()->container( "rmb_selection_popup", client ) );
00100 }
00101 //---------------------------------------------------------------------------
00102 
00103 void KOEventView::popupShow()
00104 {
00105   emit showIncidenceSignal(mCurrentIncidence);
00106 }
00107 
00108 //---------------------------------------------------------------------------
00109 
00110 void KOEventView::popupEdit()
00111 {
00112   emit editIncidenceSignal(mCurrentIncidence);
00113 }
00114 
00115 //---------------------------------------------------------------------------
00116 
00117 void KOEventView::popupDelete()
00118 {
00119   emit deleteIncidenceSignal(mCurrentIncidence);
00120 }
00121 
00122 //---------------------------------------------------------------------------
00123 
00124 void KOEventView::popupCut()
00125 {
00126   emit cutIncidenceSignal(mCurrentIncidence);
00127 }
00128 
00129 //---------------------------------------------------------------------------
00130 
00131 void KOEventView::popupCopy()
00132 {
00133   emit copyIncidenceSignal(mCurrentIncidence);
00134 }
00135 
00136 //---------------------------------------------------------------------------
00137 
00138 void KOEventView::showNewEventPopup()
00139 {
00140   if ( !readOnly() ) {
00141     QPopupMenu *popup = newEventPopup();
00142     if ( !popup ) {
00143       kdError() << "KOEventView::showNewEventPopup(): popup creation failed"
00144                 << endl;
00145       return;
00146     }
00147 
00148     popup->popup( QCursor::pos() );
00149   }
00150 }
00151 
00152 //---------------------------------------------------------------------------
00153 
00154 void KOEventView::defaultAction( Incidence *incidence )
00155 {
00156   kdDebug(5850) << "KOEventView::defaultAction()" << endl;
00157 
00158   if ( !incidence ) return;
00159 
00160   kdDebug(5850) << "  type: " << incidence->type() << endl;
00161 
00162   if ( incidence->isReadOnly() )
00163     emit showIncidenceSignal(incidence);
00164   else
00165     emit editIncidenceSignal(incidence);
00166 }
00167 
00168 //---------------------------------------------------------------------------
00169 
00170 #include "baseview.moc"
00171 
KDE Home | KDE Accessibility Home | Description of Access Keys