File indexing completed on 2024-05-19 05:21:40
0001 /* 0002 This file is part of KOrganizer. 0003 0004 SPDX-FileCopyrightText: 1999 Preston Brown <pbrown@kde.org> 0005 SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 0006 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0009 */ 0010 0011 #pragma once 0012 0013 #include "baseview.h" 0014 0015 namespace Akonadi 0016 { 0017 class Item; 0018 } 0019 0020 class KOEventPopupMenu; 0021 0022 class QMenu; 0023 0024 /** 0025 KOEventView is the abstract base class from which all other 0026 calendar views for event data are derived. It provides methods for 0027 displaying 0028 appointments and events on one or more days. The actual number of 0029 days that a view actually supports is not defined by this abstract class; 0030 that is up to the classes that inherit from it. It also provides 0031 methods for updating the display, retrieving the currently selected 0032 event (or events), and the like. 0033 0034 @short Abstract class from which all event views are derived. 0035 @author Preston Brown <pbrown@kde.org> 0036 @see KOListView, KOAgendaView, KOMonthView 0037 */ 0038 class KOEventView : public KOrg::BaseView 0039 { 0040 Q_OBJECT 0041 public: 0042 enum { 0043 // This value is passed to QColor's lighter(int factor) for selected events 0044 BRIGHTNESS_FACTOR = 125 0045 }; 0046 0047 /** 0048 * Constructs a view. 0049 * @param cal is a pointer to the calendar object from which events 0050 * will be retrieved for display. 0051 * @param parent is the parent QWidget. 0052 */ 0053 explicit KOEventView(QWidget *parent = nullptr); 0054 0055 /** 0056 * Destructor. Views will do view-specific cleanups here. 0057 */ 0058 ~KOEventView() override; 0059 0060 /** 0061 * provides a hint back to the caller on the maximum number of dates 0062 * that the view supports. A return value of 0 means no maximum. 0063 */ 0064 virtual int maxDatesHint() const = 0; 0065 0066 /** 0067 * Construct a standard context menu for an event. 0068 */ 0069 KOEventPopupMenu *eventPopup(); 0070 0071 /** 0072 * Construct a standard context that allows to create a new event. 0073 */ 0074 QMenu *newEventPopup(); 0075 0076 /** This view is a view for displaying events. */ 0077 bool isEventView() override 0078 { 0079 return true; 0080 } 0081 0082 /* 0083 * Sets the QObject that will receive key events that were made 0084 * while the new event dialog was still being created. 0085 * 0086 * This is virtual so KOAgendaView can call EventViews::AgendaView::setTypeAheadReceiver(). 0087 * because not all views are in kdepim/calendarviews yet 0088 * 0089 */ 0090 virtual void setTypeAheadReceiver(QObject *o); 0091 0092 /* 0093 * Returns true if the view item, that represents a to-do, should use the "completed" 0094 * pixmap. 0095 * 0096 * @param todo The to-do associated with the view item. 0097 * @param date The date in which the item appears in the view, for non recurring to-dos 0098 * this is the same as the start date, but, for recurring to-dos this is the date of 0099 * a particular occurrence. 0100 * 0101 */ 0102 static bool usesCompletedTodoPixmap(const Akonadi::Item &todo, const QDate &date); 0103 0104 bool supportsDateNavigation() const override 0105 { 0106 return true; 0107 } 0108 0109 public Q_SLOTS: 0110 void focusChanged(QWidget *, QWidget *); 0111 0112 /** 0113 * Performs the default action for an incidence, e.g. open the event editor, 0114 * when double-clicking an event in the agenda view. 0115 */ 0116 void defaultAction(const Akonadi::Item &incidence); 0117 0118 Q_SIGNALS: 0119 /** 0120 * When the view changes the dates that are selected in one way or 0121 * another, this signal is emitted. It should be connected back to 0122 * the KDateNavigator object so that it changes appropriately, 0123 * and any other objects that need to be aware that the list of 0124 * selected dates has changed. 0125 * @param datelist the new list of selected dates 0126 */ 0127 void datesSelected(const KCalendarCore::DateList &datelist); 0128 0129 /** 0130 * Emitted when an event is moved using the mouse in an agenda 0131 * view (week / month). 0132 */ 0133 void shiftedEvent(const QDate &olddate, const QDate &ewdate); 0134 0135 protected Q_SLOTS: 0136 void popupShow(); 0137 void popupEdit(); 0138 void popupDelete(); 0139 void popupCut(); 0140 void popupCopy(); 0141 virtual void showNewEventPopup(); 0142 0143 protected: 0144 Akonadi::Item mCurrentIncidence; // Incidence selected e.g. for a context menu 0145 0146 private: 0147 /* 0148 * This is called when the new event dialog is shown. It sends 0149 * all events in mTypeAheadEvents to the receiver. 0150 */ 0151 void finishTypeAhead(); 0152 0153 private: 0154 bool mTypeAhead = false; 0155 QObject *mTypeAheadReceiver = nullptr; 0156 QList<QEvent *> mTypeAheadEvents; 0157 };