• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

korganizer

koeventpopupmenu.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of KOrganizer.
00003 
00004   Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00005   Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007   This program is free software; you can redistribute it and/or modify
00008   it under the terms of the GNU General Public License as published by
00009   the Free Software Foundation; either version 2 of the License, or
00010   (at your option) any later version.
00011 
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015   GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License along
00018   with this program; if not, write to the Free Software Foundation, Inc.,
00019   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021   As a special exception, permission is given to link this program
00022   with any edition of Qt, and distribute the resulting executable,
00023   without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #include "koeventpopupmenu.h"
00027 #include "koglobals.h"
00028 #include "kocorehelper.h"
00029 #include "korganizer/baseview.h"
00030 #include "actionmanager.h"
00031 #ifndef KORG_NOPRINTER
00032 #include "calprinter.h"
00033 #endif
00034 
00035 #include <kcal/event.h>
00036 
00037 #include <kactioncollection.h>
00038 #include <klocale.h>
00039 #include <kdebug.h>
00040 #include <kiconloader.h>
00041 #include <kurl.h>
00042 
00043 #include <QCursor>
00044 
00045 #include "koeventpopupmenu.moc"
00046 
00047 KOEventPopupMenu::KOEventPopupMenu()
00048 {
00049   mCurrentIncidence = 0;
00050   mCurrentDate = QDate();
00051   mHasAdditionalItems = false;
00052 
00053   addAction( i18n( "&Show" ), this, SLOT( popupShow() ) );
00054   mEditOnlyItems.append( addAction( i18n( "&Edit..." ), this, SLOT( popupEdit() ) ) );
00055 #ifndef KORG_NOPRINTER
00056   addAction( KOGlobals::self()->smallIcon( "document-print" ), i18n( "&Print..." ),
00057              this, SLOT( print() ) );
00058 #endif
00059   //------------------------------------------------------------------------
00060   mEditOnlyItems.append( addSeparator() );
00061   mEditOnlyItems.append( addAction( KOGlobals::self()->smallIcon( "edit-cut" ),
00062                                     i18nc( "cut this event", "C&ut" ),
00063                                     this, SLOT(popupCut()) ) );
00064   mEditOnlyItems.append( addAction( KOGlobals::self()->smallIcon( "edit-copy" ),
00065                                     i18nc( "copy this event", "&Copy" ),
00066                                     this, SLOT(popupCopy()) ) );
00067   // paste is always possible
00068   mEditOnlyItems.append( addAction( KOGlobals::self()->smallIcon("edit-paste"), i18n("&Paste"),
00069                                     this, SLOT(popupPaste()) ) );
00070   mEditOnlyItems.append( addAction( KOGlobals::self()->smallIcon( "edit-delete" ),
00071                                     i18nc( "delete this incidence", "&Delete" ),
00072                                     this, SLOT(popupDelete()) ) );
00073   //------------------------------------------------------------------------
00074   mEditOnlyItems.append( addSeparator() );
00075   mEditOnlyItems.append( addAction( QIcon( KOGlobals::self()->smallIcon( "appointment-reminder" ) ),
00076                                     i18n( "&Toggle Reminder" ), this, SLOT(popupAlarm())) );
00077   //------------------------------------------------------------------------
00078   mRecurrenceItems.append( addSeparator() );
00079   mRecurrenceItems.append( addAction( i18n( "&Dissociate This Occurrence" ),
00080                                       this, SLOT(dissociateOccurrence()) ) );
00081   mRecurrenceItems.append( addAction( i18n( "Dissociate &Future Occurrences" ),
00082                                       this, SLOT(dissociateFutureOccurrence()) ) );
00083 
00084   addSeparator();
00085   insertItem( KOGlobals::self()->smallIcon( "mail-forward" ), i18n( "Send as iCalendar..." ),
00086               this, SLOT(forward()) );
00087 }
00088 
00089 void KOEventPopupMenu::showIncidencePopup( Incidence *incidence, const QDate &qd )
00090 {
00091   mCurrentIncidence = incidence;
00092   mCurrentDate = qd;
00093 
00094   if ( mCurrentIncidence ) {
00095     // Enable/Disabled menu items only valid for editable events.
00096     QList<QAction *>::Iterator it;
00097     for ( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
00098       (*it)->setEnabled( !mCurrentIncidence->isReadOnly() );
00099     }
00100     for ( it = mRecurrenceItems.begin(); it != mRecurrenceItems.end(); ++it ) {
00101       (*it)->setVisible( mCurrentIncidence->recurs() );
00102     }
00103     popup( QCursor::pos() );
00104   } else {
00105     kDebug() << "No event selected";
00106   }
00107 }
00108 
00109 void KOEventPopupMenu::popupShow()
00110 {
00111   if ( mCurrentIncidence ) {
00112     emit showIncidenceSignal( mCurrentIncidence );
00113   }
00114 }
00115 
00116 void KOEventPopupMenu::popupEdit()
00117 {
00118   if ( mCurrentIncidence ) {
00119     emit editIncidenceSignal( mCurrentIncidence );
00120   }
00121 }
00122 
00123 void KOEventPopupMenu::print()
00124 {
00125 #ifndef KORG_NOPRINTER
00126   Calendar *cal = 0;
00127   KOCoreHelper helper;
00128   CalPrinter printer( this, cal, &helper );
00129   connect( this, SIGNAL(configChanged()), &printer, SLOT(updateConfig()) );
00130 
00131   Incidence::List selectedIncidences;
00132   selectedIncidences.append( mCurrentIncidence );
00133 
00134   printer.print( KOrg::CalPrinterBase::Incidence,
00135                  mCurrentDate, mCurrentDate, selectedIncidences );
00136 #endif
00137 }
00138 
00139 void KOEventPopupMenu::popupDelete()
00140 {
00141   if ( mCurrentIncidence ) {
00142     emit deleteIncidenceSignal( mCurrentIncidence );
00143   }
00144 }
00145 
00146 void KOEventPopupMenu::popupCut()
00147 {
00148   if ( mCurrentIncidence ) {
00149     emit cutIncidenceSignal(mCurrentIncidence);
00150   }
00151 }
00152 
00153 void KOEventPopupMenu::popupCopy()
00154 {
00155   if ( mCurrentIncidence ) {
00156     emit copyIncidenceSignal( mCurrentIncidence );
00157   }
00158 }
00159 
00160 void KOEventPopupMenu::popupPaste()
00161 {
00162   emit pasteIncidenceSignal();
00163 }
00164 
00165 void KOEventPopupMenu::popupAlarm()
00166 {
00167   if ( mCurrentIncidence ) {
00168     emit toggleAlarmSignal( mCurrentIncidence );
00169   }
00170 }
00171 
00172 void KOEventPopupMenu::dissociateOccurrence()
00173 {
00174   if ( mCurrentIncidence ) {
00175     emit dissociateOccurrenceSignal( mCurrentIncidence, mCurrentDate );
00176   }
00177 }
00178 
00179 void KOEventPopupMenu::dissociateFutureOccurrence()
00180 {
00181   if ( mCurrentIncidence ) {
00182     emit dissociateFutureOccurrenceSignal( mCurrentIncidence, mCurrentDate );
00183   }
00184 }
00185 
00186 void KOEventPopupMenu::forward()
00187 {
00188   KOrg::MainWindow *w = ActionManager::findInstance( KUrl() );
00189   if ( !w || !mCurrentIncidence ) {
00190     return;
00191   }
00192 
00193   KActionCollection *ac = w->getActionCollection();
00194   QAction *action = ac->action( "schedule_forward" );
00195   if ( action ) {
00196     action->trigger();
00197   } else {
00198     kError() << "What happened to the schedule_forward action?";
00199   }
00200 }
00201 

korganizer

Skip menu "korganizer"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal