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