koeventpopupmenu.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <qcursor.h>
00025
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 #include <kiconloader.h>
00029
00030 #include <libkcal/event.h>
00031
00032 #include "koglobals.h"
00033
00034 #include "koeventpopupmenu.h"
00035 #include "koeventpopupmenu.moc"
00036
00037 KOEventPopupMenu::KOEventPopupMenu()
00038 {
00039 mCurrentIncidence = 0;
00040 mCurrentDate = QDate();
00041 mHasAdditionalItems = false;
00042
00043 insertItem (i18n("&Show"),this,SLOT(popupShow()));
00044 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
00045 mEditOnlyItems.append(insertItem (KOGlobals::self()->smallIcon("editdelete"),i18n("&Delete"),
00046 this,SLOT(popupDelete())));
00047 mEditOnlyItems.append( insertSeparator() );
00048 mEditOnlyItems.append( insertItem( QIconSet( KOGlobals::self()->smallIcon("bell") ),
00049 i18n("Toggle Alarm"), this,
00050 SLOT( popupAlarm() ) ) );
00051 }
00052
00053 void KOEventPopupMenu::showIncidencePopup( Incidence *incidence, const QDate &qd )
00054 {
00055 mCurrentIncidence = incidence;
00056 mCurrentDate = qd;
00057
00058 if (mCurrentIncidence) {
00059
00060 QValueList<int>::Iterator it;
00061 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
00062 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
00063 }
00064 popup(QCursor::pos());
00065 } else {
00066 kdDebug(5850) << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
00067 }
00068 }
00069
00070 void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
00071 const QObject *receiver, const char *member,
00072 bool editOnly)
00073 {
00074 if (!mHasAdditionalItems) {
00075 mHasAdditionalItems = true;
00076 insertSeparator();
00077 }
00078 int id = insertItem(icon,text,receiver,member);
00079 if (editOnly) mEditOnlyItems.append(id);
00080 }
00081
00082 void KOEventPopupMenu::popupShow()
00083 {
00084 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
00085 }
00086
00087 void KOEventPopupMenu::popupEdit()
00088 {
00089 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
00090 }
00091
00092 void KOEventPopupMenu::popupDelete()
00093 {
00094 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
00095 }
00096
00097 void KOEventPopupMenu::popupAlarm()
00098 {
00099 if (mCurrentIncidence) emit toggleAlarmSignal( mCurrentIncidence );
00100 }
This file is part of the documentation for korganizer Library Version 3.3.2.