25
25
#ifndef KOAGENDAVIEW_H
26
26
#define KOAGENDAVIEW_H
28
#include "agendaview.h"
29
#ifndef KORG_NOPRINTER
30
#include "calprinter.h"
33
#include <KCal/Calendar>
28
#include "../../koeventview.h"
29
#include "../../printing/calprinter.h"
31
#include <KCalCore/Todo>
56
class ResourceCalendar;
62
namespace CalendarDecoration {
66
class IncidenceChangerBase;
70
class EventIndicator : public QFrame
78
explicit EventIndicator( Location loc = Top, QWidget *parent = 0 );
79
virtual ~EventIndicator();
81
void changeColumns( int columns );
83
void enableColumn( int column, bool enable );
86
void paintEvent( QPaintEvent *event );
92
QVector<bool> mEnabled;
35
namespace EventViews {
96
40
KOAgendaView is the agenda-like view that displays events in a single
99
class KOAgendaView : public KOrg::AgendaView, public KCal::Calendar::CalendarObserver
43
class KOAgendaView : public KOEventView
103
explicit KOAgendaView( Calendar *cal, QWidget *parent = 0, bool isSideBySide = false );
47
explicit KOAgendaView( QWidget *parent = 0, bool isSideBySide = false );
104
48
virtual ~KOAgendaView();
106
50
/** Returns maximum number of days supported by the koagendaview */
107
virtual int maxDatesHint();
51
virtual int maxDatesHint() const;
109
53
/** Returns number of currently shown dates. */
110
virtual int currentDateCount();
54
virtual int currentDateCount() const;
112
56
/** returns the currently selected events */
113
virtual Incidence::List selectedIncidences();
57
virtual Akonadi::Item::List selectedIncidences();
115
59
/** returns the currently selected incidence's dates */
116
virtual DateList selectedIncidenceDates();
60
virtual KCalCore::DateList selectedIncidenceDates();
118
62
/** return the default start/end date/time for new events */
119
63
virtual bool eventDurationHint( QDateTime &startDt, QDateTime &endDt, bool &allDay );
121
/** Remove all events from view */
124
#ifndef KORG_NOPRINTER
125
CalPrinter::PrintType printType();
65
CalPrinter::PrintType printType() const;
128
67
/** start-datetime of selection */
129
virtual QDateTime selectionStart() { return mTimeSpanBegin; }
68
virtual QDateTime selectionStart();
131
70
/** end-datetime of selection */
132
virtual QDateTime selectionEnd() { return mTimeSpanEnd; }
71
virtual QDateTime selectionEnd();
134
73
/** returns true if selection is for whole day */
135
bool selectedIsAllDay() { return mTimeSpanInAllDay; }
74
bool selectedIsAllDay();
136
75
/** make selected start/end invalid */
137
76
void deleteSelectedDateTime();
138
77
/** returns if only a single cell is selected, or a range of cells */
139
78
bool selectedIsSingleCell();
141
/** Show only incidences from the given resource. */
142
void setResource( KCal::ResourceCalendar *res, const QString &subResource = QString() );
144
KOAgenda *agenda() const { return mAgenda; }
145
QSplitter *splitter() const { return mSplitterAgenda; }
147
/* reimplemented from KCal::Calendar::CalendarObserver */
148
void calendarIncidenceAdded( Incidence *incidence );
149
void calendarIncidenceChanged( Incidence *incidence );
150
void calendarIncidenceDeleted( Incidence *incidence );
80
/* reimp from BaseView */
81
virtual void setCalendar( CalendarSupport::Calendar *cal );
84
virtual void setTypeAheadReceiver( QObject *o );
86
void setChanges( EventViews::EventView::Changes changes );
89
void setDateRange( const KDateTime &start, const KDateTime &end, const QDate &preferredMonth = QDate() );
153
92
virtual void updateView();
154
93
virtual void updateConfig();
155
virtual void showDates( const QDate &start, const QDate &end );
156
virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
94
virtual void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
95
virtual void showIncidences( const Akonadi::Item::List &incidenceList, const QDate &date );
158
void insertIncidence( Incidence *incidence, const QDate &curDate );
159
void changeIncidenceDisplayAdded( Incidence *incidence );
160
void changeIncidenceDisplay( Incidence *incidence, int mode );
97
void changeIncidenceDisplayAdded( const Akonadi::Item &incidence );
98
void changeIncidenceDisplay( const Akonadi::Item &incidence, int mode );
162
100
void clearSelection();
164
void startDrag( Incidence * );
166
102
void readSettings();
167
103
void readSettings( KConfig * );
168
104
void writeSettings( KConfig * );
170
void setContentsPos( int y );
172
106
/** reschedule the todo to the given x- and y- coordinates.
173
107
Third parameter determines all-day (no time specified) */
174
void slotTodoDropped( Todo *, const QPoint &, bool );
108
void slotTodosDropped( const Todo::List &todos, const QPoint &, bool );
109
void slotTodosDropped( const QList<KUrl> &todos, const QPoint &, bool );
176
111
void enableAgendaUpdate( bool enable );
177
void setIncidenceChanger( IncidenceChangerBase *changer );
112
void setIncidenceChanger( CalendarSupport::IncidenceChanger *changer );
179
114
void zoomInHorizontally( const QDate &date=QDate() );
180
115
void zoomOutHorizontally( const QDate &date=QDate() );
182
117
void zoomInVertically( );
183
118
void zoomOutVertically( );
185
void zoomView( const int delta, const QPoint &pos,
186
const Qt::Orientation orient=Qt::Horizontal );
188
void clearTimeSpanSelection();
190
/** Notifies agenda that there are pending changes */
191
void setUpdateNeeded();
193
// Used by the timelabelszone
194
void updateTimeBarWidth();
195
/** Create labels for the selected dates. */
196
void createDayLabels();
198
void createTimeBarHeaders();
120
void zoomView( const int delta, const QPoint &pos, const Qt::Orientation orient=Qt::Horizontal );
201
123
void zoomViewHorizontally( const QDate &, int count );
203
124
void timeSpanSelectionChanged();
206
/** Fill agenda beginning with date startDate */
207
void fillAgenda( const QDate &startDate );
209
/** Fill agenda using the current set value for the start date */
212
void connectAgenda( KOAgenda *agenda, QMenu *popup, KOAgenda *otherAgenda );
215
Set the masks on the agenda widgets indicating, which days are holidays.
217
void setHolidayMasks();
219
void removeIncidence( Incidence * );
221
Updates the event indicators after a certain incidence was modified or
224
void updateEventIndicators();
227
/** Update event belonging to agenda item */
228
void updateEventDates( KOAgendaItem *item );
229
/** update just the display of the given incidence, called by a single-shot timer */
232
void updateEventIndicatorTop( int newY );
233
void updateEventIndicatorBottom( int newY );
235
/** Updates data for selected timespan */
236
void newTimeSpanSelected( const QPoint &start, const QPoint &end );
237
/** Updates data for selected timespan for all day event*/
238
void newTimeSpanSelectedAllDay( const QPoint &start, const QPoint &end );
242
bool filterByResource( Incidence *incidence );
243
void setupTimeLabel( TimeLabels *timeLabel );
244
int timeLabelsWidth();
245
void displayIncidence( Incidence *incidence );
247
typedef QList<KOrg::CalendarDecoration::Decoration *> DecorationList;
248
bool loadDecorations( const QStringList &decorations, DecorationList &decoList );
249
void placeDecorationsFrame( KHBox *frame, bool decorationsFound, bool isTop );
250
void placeDecorations( DecorationList &decoList, const QDate &date,
251
KHBox *labelBox, bool forWeek );
256
QGridLayout *mGridLayout;
257
QFrame *mTopDayLabels;
258
KHBox *mTopDayLabelsFrame;
259
QBoxLayout *mLayoutTopDayLabels;
260
QFrame *mBottomDayLabels;
261
KHBox *mBottomDayLabelsFrame;
262
QBoxLayout *mLayoutBottomDayLabels;
264
QWidget *mTimeBarHeaderFrame;
265
QGridLayout *mAgendaLayout;
266
QSplitter *mSplitterAgenda;
267
QList<QWidget *> mTimeBarHeaders;
269
KOAgenda *mAllDayAgenda;
272
TimeLabelsZone *mTimeLabelsZone;
274
DateList mSelectedDates; // List of dates to be displayed
277
KOEventPopupMenu *mAgendaPopup;
278
KOEventPopupMenu *mAllDayAgendaPopup;
280
EventIndicator *mEventIndicatorTop;
281
EventIndicator *mEventIndicatorBottom;
286
QVector<bool> mHolidayMask;
288
QDateTime mTimeSpanBegin;
289
QDateTime mTimeSpanEnd;
290
bool mTimeSpanInAllDay;
291
bool mAllowAgendaUpdate;
293
Incidence *mUpdateItem;
295
KCal::ResourceCalendar *mResource;
296
QString mSubResource;
299
bool mPendingChanges;
301
// the current date is inserted into mSelectedDates in the constructor
302
// however whe should only show events when setDates is called, otherwise
303
// we see day view with current date for a few milisecs, then we see something else
304
// because someone called setDates with the real dates that should be displayed.
305
// Other solution would be not initializing mSelectedDates in the ctor, but that requires
306
// lots of changes in koagenda.cpp and koagendaview.cpp
307
bool mAreDatesInitialized;