00001
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 <korganizer/baseview.h>
00036 #include "koeventpopupmenu.h"
00037 #include "koeventpopupmenu.moc"
00038 #include "kocorehelper.h"
00039 #ifndef KORG_NOPRINTER
00040 #include "calprinter.h"
00041 #endif
00042
00043 KOEventPopupMenu::KOEventPopupMenu()
00044 {
00045 mCurrentIncidence = 0;
00046 mCurrentDate = QDate();
00047 mHasAdditionalItems = false;
00048
00049 insertItem( i18n("&Show"), this, SLOT( popupShow() ) );
00050 mEditOnlyItems.append(
00051 insertItem(i18n("&Edit..."), this, SLOT( popupEdit() ) ) );
00052 #ifndef KORG_NOPRINTER
00053 insertItem( KOGlobals::self()->smallIcon("printer1"), i18n("&Print..."),
00054 this, SLOT( print() ) );
00055 #endif
00056
00057 mEditOnlyItems.append( insertSeparator() );
00058 mEditOnlyItems.append(
00059 insertItem( KOGlobals::self()->smallIcon("editcut"), i18n("&Cut"),
00060 this, SLOT( popupCut() ) ) );
00061 mEditOnlyItems.append(
00062 insertItem( KOGlobals::self()->smallIcon("editcopy"), i18n("&Copy"),
00063 this, SLOT( popupCopy() ) ) );
00064 mEditOnlyItems.append(
00065 insertItem( KOGlobals::self()->smallIcon("editdelete"), i18n("&Delete"),
00066 this, SLOT( popupDelete() ) ) );
00067
00068 mEditOnlyItems.append( insertSeparator() );
00069 mEditOnlyItems.append(
00070 insertItem( KOGlobals::self()->smallIcon("bell"), i18n("&Toggle Reminder"),
00071 this, SLOT( popupAlarm() ) ) );
00072
00073 mRecurrenceItems.append( insertSeparator() );
00074 mRecurrenceItems.append(
00075 insertItem( i18n("&Dissociate This Occurrence"),
00076 this, SLOT( dissociateOccurrence() ) ) );
00077 mRecurrenceItems.append(
00078 insertItem( i18n("&Dissociate Future Occurrences"),
00079 this, SLOT( dissociateFutureOccurrence() ) ) );
00080 }
00081
00082 void KOEventPopupMenu::showIncidencePopup( Incidence *incidence, const QDate &qd )
00083 {
00084 mCurrentIncidence = incidence;
00085 mCurrentDate = qd;
00086
00087 if (mCurrentIncidence) {
00088
00089 QValueList<int>::Iterator it;
00090 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
00091 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
00092 }
00093 for ( it = mRecurrenceItems.begin(); it != mRecurrenceItems.end(); ++it ) {
00094 setItemVisible( *it, mCurrentIncidence->doesRecur() );
00095 }
00096 popup(QCursor::pos());
00097 } else {
00098 kdDebug(5850) << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
00099 }
00100 }
00101
00102 void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
00103 const QObject *receiver, const char *member,
00104 bool editOnly)
00105 {
00106 if (!mHasAdditionalItems) {
00107 mHasAdditionalItems = true;
00108 insertSeparator();
00109 }
00110 int id = insertItem(icon,text,receiver,member);
00111 if (editOnly) mEditOnlyItems.append(id);
00112 }
00113
00114 void KOEventPopupMenu::popupShow()
00115 {
00116 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
00117 }
00118
00119 void KOEventPopupMenu::popupEdit()
00120 {
00121 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
00122 }
00123
00124 void KOEventPopupMenu::print()
00125 {
00126 #ifndef KORG_NOPRINTER
00127 Calendar *cal;
00128 KOCoreHelper helper;
00129 CalPrinter printer( this, cal, &helper );
00130 connect( this, SIGNAL(configChanged()), &printer, SLOT(updateConfig()) );
00131
00132 Incidence::List selectedIncidences;
00133 selectedIncidences.append( mCurrentIncidence );
00134
00135 printer.print( KOrg::CalPrinterBase::Incidence,
00136 mCurrentDate, mCurrentDate, selectedIncidences );
00137 #endif
00138 }
00139
00140 void KOEventPopupMenu::popupDelete()
00141 {
00142 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
00143 }
00144
00145 void KOEventPopupMenu::popupCut()
00146 {
00147 if (mCurrentIncidence) emit cutIncidenceSignal(mCurrentIncidence);
00148 }
00149
00150 void KOEventPopupMenu::popupCopy()
00151 {
00152 if (mCurrentIncidence) emit copyIncidenceSignal(mCurrentIncidence);
00153 }
00154
00155
00156 void KOEventPopupMenu::popupAlarm()
00157 {
00158 if (mCurrentIncidence) emit toggleAlarmSignal( mCurrentIncidence );
00159 }
00160
00161 void KOEventPopupMenu::dissociateOccurrence()
00162 {
00163 if ( mCurrentIncidence )
00164 emit dissociateOccurrenceSignal( mCurrentIncidence, mCurrentDate );
00165 }
00166
00167 void KOEventPopupMenu::dissociateFutureOccurrence()
00168 {
00169 if ( mCurrentIncidence )
00170 emit dissociateFutureOccurrenceSignal( mCurrentIncidence, mCurrentDate );
00171 }