File indexing completed on 2024-05-19 05:21:40

0001 /*
0002   This file is part of KOrganizer.
0003 
0004   SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
0005   SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
0006 
0007   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0008 */
0009 
0010 #pragma once
0011 
0012 #include <QDate>
0013 #include <QMenu>
0014 
0015 #include <Akonadi/CollectionCalendar>
0016 #include <Akonadi/Item>
0017 
0018 /**
0019  * Context menu with standard Incidence actions.
0020  */
0021 class KOEventPopupMenu : public QMenu
0022 {
0023     Q_OBJECT
0024 public:
0025     /**
0026      * The different types of preset menus available.
0027      */
0028     enum MenuStyle {
0029         NormalView = 0, /**< typical menu shown in most views. this is the default menu style */
0030         MiniList = 1, /**< mini-menu with just the basic items, typical in lists */
0031     };
0032     Q_ENUM(MenuStyle)
0033 
0034     /**
0035      * Create an Incidence menu instance with the NormalView style.
0036      */
0037     explicit KOEventPopupMenu(QWidget *parent = nullptr);
0038 
0039     /**
0040      * Create an Incidence menu instance with a specified style.
0041      */
0042     KOEventPopupMenu(MenuStyle menuStyle, QWidget *parent = nullptr);
0043 
0044 public Q_SLOTS:
0045     /**
0046      * Display a pop-up menu that operates on the incidence contained in the
0047      * given item, and its occurrence displayed on the given date.
0048      */
0049     void showIncidencePopup(const Akonadi::CollectionCalendar::Ptr &calendar, const Akonadi::Item &, const QDate &);
0050 
0051     void createEvent(const Akonadi::Item &item);
0052     void createNote(const Akonadi::Item &item);
0053 
0054 protected Q_SLOTS:
0055     void popupShow();
0056     void popupEdit();
0057     void popupPaste();
0058     void slotPrint();
0059     void printPreview();
0060     void popupDelete();
0061     void popupCut();
0062     void popupCopy();
0063     void toggleAlarm();
0064     void toggleTodoCompleted();
0065     void dissociateOccurrences();
0066     void forward();
0067     void createTodo();
0068     void createEvent();
0069     void createNote();
0070 
0071     void slotCreateNote(const Akonadi::Item &noteItem, const Akonadi::Collection &collection);
0072     void slotCreateNewNoteJobFinished(KJob *);
0073 
0074 Q_SIGNALS:
0075     void configChanged();
0076     void editIncidenceSignal(const Akonadi::Item &);
0077     void showIncidenceSignal(const Akonadi::Item &);
0078     void deleteIncidenceSignal(const Akonadi::Item &);
0079     void cutIncidenceSignal(const Akonadi::Item &);
0080     void copyIncidenceSignal(const Akonadi::Item &);
0081     void pasteIncidenceSignal();
0082     void toggleAlarmSignal(const Akonadi::Item &);
0083     void toggleOccurrenceCompletedSignal(const Akonadi::Item &, const QDate &);
0084     void copyIncidenceToResourceSignal(const Akonadi::Item &, const Akonadi::Collection &);
0085     void moveIncidenceToResourceSignal(const Akonadi::Item &, const Akonadi::Collection &);
0086     void dissociateOccurrencesSignal(const Akonadi::Item &, const QDate &);
0087 
0088 private:
0089     void init(MenuStyle menuStyle);
0090     void appendEditOnlyItems();
0091     void appendEventOnlyItems();
0092     void appendTodoOnlyItems();
0093     void appendReminderOnlyItems();
0094     void appendRecurrenceOnlyItems();
0095     void appendShareOnlyItems();
0096 
0097     void print(bool previous);
0098 
0099     Akonadi::CollectionCalendar::Ptr mCurrentCalendar;
0100     Akonadi::Item mCurrentIncidence;
0101     QDate mCurrentDate;
0102 
0103     bool mHasAdditionalItems = false;
0104     QList<QAction *> mEditOnlyItems;
0105     QList<QAction *> mEventOnlyItems;
0106     QList<QAction *> mTodoOnlyItems;
0107     QList<QAction *> mReminderOnlyItems;
0108     QList<QAction *> mRecurrenceOnlyItems;
0109     QList<QAction *> mShareOnlyItems;
0110     QAction *mToggleReminder = nullptr;
0111     QAction *mDissociateOccurrences = nullptr;
0112 };