1 /* 2 This file is part of KOrganizer. 3 4 SPDX-FileCopyrightText: 1999 Preston Brown <pbrown@kde.org> 5 SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 6 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 7 8 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 9 */ 10 11 #pragma once 12 13 #include "baseview.h" 14 15 namespace Akonadi 16 { 17 class Item; 18 } 19 20 class KOEventPopupMenu; 21 22 class QMenu; 23 24 /** 25 KOEventView is the abstract base class from which all other 26 calendar views for event data are derived. It provides methods for 27 displaying 28 appointments and events on one or more days. The actual number of 29 days that a view actually supports is not defined by this abstract class; 30 that is up to the classes that inherit from it. It also provides 31 methods for updating the display, retrieving the currently selected 32 event (or events), and the like. 33 34 @short Abstract class from which all event views are derived. 35 @author Preston Brown <pbrown@kde.org> 36 @see KOListView, KOAgendaView, KOMonthView 37 */ 38 class KOEventView : public KOrg::BaseView 39 { 40 Q_OBJECT 41 public: 42 enum { 43 // This value is passed to QColor's lighter(int factor) for selected events 44 BRIGHTNESS_FACTOR = 125 45 }; 46 47 /** 48 * Constructs a view. 49 * @param cal is a pointer to the calendar object from which events 50 * will be retrieved for display. 51 * @param parent is the parent QWidget. 52 */ 53 explicit KOEventView(QWidget *parent = nullptr); 54 55 /** 56 * Destructor. Views will do view-specific cleanups here. 57 */ 58 ~KOEventView() override; 59 60 /** 61 * provides a hint back to the caller on the maximum number of dates 62 * that the view supports. A return value of 0 means no maximum. 63 */ 64 virtual int maxDatesHint() const = 0; 65 66 /** 67 * Construct a standard context menu for an event. 68 */ 69 KOEventPopupMenu *eventPopup(); 70 71 /** 72 * Construct a standard context that allows to create a new event. 73 */ 74 QMenu *newEventPopup(); 75 76 /** This view is a view for displaying events. */ isEventView()77 bool isEventView() override 78 { 79 return true; 80 } 81 82 /* 83 * Sets the QObject that will receive key events that were made 84 * while the new event dialog was still being created. 85 * 86 * This is virtual so KOAgendaView can call EventViews::AgendaView::setTypeAheadReceiver(). 87 * because not all views are in kdepim/calendarviews yet 88 * 89 */ 90 virtual void setTypeAheadReceiver(QObject *o); 91 92 /* 93 * Returns true if the view item, that represents a to-do, should use the "completed" 94 * pixmap. 95 * 96 * @param todo The to-do associated with the view item. 97 * @param date The date in which the item appears in the view, for non recuring to-dos 98 * this is the same as the start date, but, for recurring to-dos this is the date of 99 * a particular occurrence. 100 * 101 */ 102 static bool usesCompletedTodoPixmap(const Akonadi::Item &todo, const QDate &date); 103 supportsDateNavigation()104 bool supportsDateNavigation() const override 105 { 106 return true; 107 } 108 109 public Q_SLOTS: 110 void focusChanged(QWidget *, QWidget *); 111 112 /** 113 * Performs the default action for an incidence, e.g. open the event editor, 114 * when double-clicking an event in the agenda view. 115 */ 116 void defaultAction(const Akonadi::Item &incidence); 117 118 Q_SIGNALS: 119 /** 120 * When the view changes the dates that are selected in one way or 121 * another, this signal is emitted. It should be connected back to 122 * the KDateNavigator object so that it changes appropriately, 123 * and any other objects that need to be aware that the list of 124 * selected dates has changed. 125 * @param datelist the new list of selected dates 126 */ 127 void datesSelected(const KCalendarCore::DateList &datelist); 128 129 /** 130 * Emitted when an event is moved using the mouse in an agenda 131 * view (week / month). 132 */ 133 void shiftedEvent(const QDate &olddate, const QDate &ewdate); 134 135 protected Q_SLOTS: 136 void popupShow(); 137 void popupEdit(); 138 void popupDelete(); 139 void popupCut(); 140 void popupCopy(); 141 virtual void showNewEventPopup(); 142 143 protected: 144 Akonadi::Item mCurrentIncidence; // Incidence selected e.g. for a context menu 145 146 private: 147 /* 148 * This is called when the new event dialog is shown. It sends 149 * all events in mTypeAheadEvents to the receiver. 150 */ 151 void finishTypeAhead(); 152 153 private: 154 bool mTypeAhead = false; 155 QObject *mTypeAheadReceiver = nullptr; 156 QList<QEvent *> mTypeAheadEvents; 157 }; 158 159