korganizer
koeventpopupmenu.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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 }
|