32 #include <calendarsupport/kcalprefs.h>
33 #include <calendarsupport/utils.h>
35 #include <KCalCore/Incidence>
37 #include <KActionCollection>
38 #include <KMimeTypeTrader>
41 :
QMenu( parent ), mCalendar( calendar )
43 mHasAdditionalItems =
false;
45 addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"document-preview") ), i18n(
"&Show" ),
47 mEditOnlyItems.append(
48 addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"document-edit") ), i18n(
"&Edit..." ),
50 mEditOnlyItems.append( addSeparator() );
51 addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"document-print") ), i18n(
"&Print..." ),
52 this, SLOT(
print()) );
53 QAction *preview = addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"document-print-preview") ),
54 i18n(
"Print Previe&w..." ),
56 preview->setEnabled( !KMimeTypeTrader::self()->query(QLatin1String(
"application/pdf"),
57 QLatin1String(
"KParts/ReadOnlyPart") ).isEmpty() );
59 mEditOnlyItems.append( addSeparator() );
60 mEditOnlyItems.append( addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"edit-cut") ),
61 i18nc(
"cut this event",
"C&ut" ),
63 mEditOnlyItems.append( addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"edit-copy") ),
64 i18nc(
"copy this event",
"&Copy" ),
67 mEditOnlyItems.append( addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"edit-paste") ),
70 mEditOnlyItems.append( addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"edit-delete") ),
71 i18nc(
"delete this incidence",
"&Delete" ),
74 mEditOnlyItems.append( addSeparator() );
75 mTodoOnlyItems.append( addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"task-complete") ),
76 i18n(
"Togg&le To-do Completed" ),
78 mToggleReminder = addAction( QIcon(
KOGlobals::self()->smallIcon( QLatin1String(
"appointment-reminder") ) ),
79 i18n(
"&Toggle Reminder" ),
this, SLOT(
toggleAlarm()));
80 mEditOnlyItems.append( mToggleReminder );
82 mRecurrenceItems.append( addSeparator() );
83 mDissociateOccurrences = addAction( i18n(
"&Dissociate From Recurrence..." ),
85 mRecurrenceItems.append( mDissociateOccurrences );
88 addAction(
KOGlobals::self()->smallIcon( QLatin1String(
"mail-forward") ),
89 i18n(
"Send as iCalendar..." ),
95 mCurrentIncidence = item;
98 if ( !CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
99 kDebug() <<
"No event selected";
105 kDebug() <<
"Calendar is 0";
109 const bool hasChangeRights = mCalendar->hasRight( mCurrentIncidence, Akonadi::Collection::CanChangeItem );
111 KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( mCurrentIncidence );
112 Q_ASSERT( incidence );
113 if ( incidence->recurs() ) {
114 const KDateTime thisDateTime( qd, CalendarSupport::KCalPrefs::instance()->timeSpec() );
115 const bool isLastOccurrence =
116 !incidence->recurrence()->getNextDateTime( thisDateTime ).isValid();
117 const bool isFirstOccurrence =
118 !incidence->recurrence()->getPreviousDateTime( thisDateTime ).isValid();
119 mDissociateOccurrences->setEnabled(
120 !( isFirstOccurrence && isLastOccurrence ) && hasChangeRights );
124 QList<QAction *>::Iterator it;
125 for ( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
126 (*it)->setEnabled( hasChangeRights );
128 mToggleReminder->setVisible( ( incidence->type() != KCalCore::Incidence::TypeJournal ) );
129 for ( it = mRecurrenceItems.begin(); it != mRecurrenceItems.end(); ++it ) {
130 (*it)->setVisible( incidence->recurs() );
132 for ( it = mTodoOnlyItems.begin(); it != mTodoOnlyItems.end(); ++it ) {
133 (*it)->setVisible( incidence->type() == KCalCore::Incidence::TypeTodo );
134 (*it)->setEnabled( hasChangeRights );
136 popup( QCursor::pos() );
141 if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
148 if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
161 CalPrinter printer(
this, mCalendar, &helper,
true );
162 connect(
this, SIGNAL(
configChanged()), &printer, SLOT(updateConfig()) );
165 KCalCore::Incidence::List selectedIncidences;
166 Q_ASSERT( mCurrentIncidence.hasPayload<KCalCore::Incidence::Ptr>() );
167 selectedIncidences.append( mCurrentIncidence.payload<KCalCore::Incidence::Ptr>() );
170 mCurrentDate, mCurrentDate, selectedIncidences, preview );
180 if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
187 if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
194 if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
206 if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
213 if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
221 if ( !w || !CalendarSupport::hasIncidence( mCurrentIncidence ) ) {
226 QAction *action = ac->action( QLatin1String(
"schedule_forward") );
230 kError() <<
"What happened to the schedule_forward action?";
236 if ( CalendarSupport::hasTodo( mCurrentIncidence ) ) {
243 mCalendar = calendar;
246 #include "koeventpopupmenu.moc"
static KOrg::MainWindow * findInstance(const KUrl &url)
Is there a instance with this URL?
virtual KActionCollection * getActionCollection() const =0
Return actionCollection of this main window.
interface for korganizer main window
CalPrinter is a class for printing Calendars.
static KOGlobals * self()