korganizer

koeventpopupmenu.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 <qcursor.h>
00026 
00027 #include <klocale.h>
00028 #include <kdebug.h>
00029 #include <kiconloader.h>
00030 
00031 #include <libkcal/event.h>
00032 
00033 #include "koglobals.h"
00034 
00035 #include "koeventpopupmenu.h"
00036 #include "koeventpopupmenu.moc"
00037 
00038 KOEventPopupMenu::KOEventPopupMenu()
00039 {
00040   mCurrentIncidence = 0;
00041   mCurrentDate = QDate();
00042   mHasAdditionalItems = false;
00043 
00044   insertItem (i18n("&Show"),this,SLOT(popupShow()));
00045   mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
00046   mEditOnlyItems.append(insertSeparator());
00047   mEditOnlyItems.append(insertItem (KOGlobals::self()->smallIcon("editcut"),i18n("&Cut"),
00048                                    this,SLOT(popupCut())));
00049   mEditOnlyItems.append(insertItem (KOGlobals::self()->smallIcon("editcopy"),i18n("&Copy"),
00050                                    this,SLOT(popupCopy())));
00051   mEditOnlyItems.append(insertItem (KOGlobals::self()->smallIcon("editdelete"),i18n("&Delete"),
00052                                    this,SLOT(popupDelete())));
00053   mEditOnlyItems.append( insertSeparator() );
00054   mEditOnlyItems.append( insertItem( QIconSet( KOGlobals::self()->smallIcon("bell") ),
00055                                      i18n("&Toggle Reminder"), this,
00056                                      SLOT( popupAlarm() ) ) );
00057   mRecurrenceItems.append( insertSeparator() );
00058   mRecurrenceItems.append( insertItem( i18n("&Dissociate This Occurrence"),
00059                                        this, SLOT( dissociateOccurrence() ) ) );
00060   mRecurrenceItems.append( insertItem( i18n("&Dissociate Future Occurrences"),
00061                                        this, SLOT( dissociateFutureOccurrence() ) ) );
00062 }
00063 
00064 void KOEventPopupMenu::showIncidencePopup( Incidence *incidence, const QDate &qd )
00065 {
00066   mCurrentIncidence = incidence;
00067   mCurrentDate = qd;
00068 
00069   if (mCurrentIncidence) {
00070     // Enable/Disabled menu items only valid for editable events.
00071     QValueList<int>::Iterator it;
00072     for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
00073       setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
00074     }
00075     for ( it = mRecurrenceItems.begin(); it != mRecurrenceItems.end(); ++it ) {
00076       setItemVisible( *it, mCurrentIncidence->doesRecur() );
00077     }
00078     popup(QCursor::pos());
00079   } else {
00080     kdDebug(5850) << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
00081   }
00082 }
00083 
00084 void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
00085                                     const QObject *receiver, const char *member,
00086                                     bool editOnly)
00087 {
00088   if (!mHasAdditionalItems) {
00089     mHasAdditionalItems = true;
00090     insertSeparator();
00091   }
00092   int id = insertItem(icon,text,receiver,member);
00093   if (editOnly) mEditOnlyItems.append(id);
00094 }
00095 
00096 void KOEventPopupMenu::popupShow()
00097 {
00098   if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
00099 }
00100 
00101 void KOEventPopupMenu::popupEdit()
00102 {
00103   if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
00104 }
00105 
00106 void KOEventPopupMenu::popupDelete()
00107 {
00108   if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
00109 }
00110 
00111 void KOEventPopupMenu::popupCut()
00112 {
00113   if (mCurrentIncidence) emit cutIncidenceSignal(mCurrentIncidence);
00114 }
00115 
00116 void KOEventPopupMenu::popupCopy()
00117 {
00118   if (mCurrentIncidence) emit copyIncidenceSignal(mCurrentIncidence);
00119 }
00120 
00121 
00122 void KOEventPopupMenu::popupAlarm()
00123 {
00124   if (mCurrentIncidence) emit toggleAlarmSignal( mCurrentIncidence );
00125 }
00126 
00127 void KOEventPopupMenu::dissociateOccurrence()
00128 {
00129   if ( mCurrentIncidence )
00130     emit dissociateOccurrenceSignal( mCurrentIncidence, mCurrentDate );
00131 }
00132 
00133 void KOEventPopupMenu::dissociateFutureOccurrence()
00134 {
00135   if ( mCurrentIncidence )
00136     emit dissociateFutureOccurrenceSignal( mCurrentIncidence, mCurrentDate );
00137 }
KDE Home | KDE Accessibility Home | Description of Access Keys