calendarview.h 24.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
  This file is part of KOrganizer.

  Copyright (c) 2000,2001,2003,2004 Cornelius Schumacher <schumacher@kde.org>
  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
  Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along
  with this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

  As a special exception, permission is given to link this program
  with any edition of Qt, and distribute the resulting executable,
  without including the source code for Qt in the source distribution.
*/
26
27
28

#ifndef KORG_CALENDARVIEW_H
#define KORG_CALENDARVIEW_H
29

Laurent Montel's avatar
Laurent Montel committed
30
#include "korganizerprivate_export.h"
Laurent Montel's avatar
Laurent Montel committed
31
#include "helper/searchcollectionhelper.h"
32

33
34
#include "interfaces/korganizer/calendarviewbase.h"

35
36
#include <KCalCore/Incidence>
#include <KCalCore/Visitor>
37
#include <KCalCore/ScheduleMessage>
38

39
#include <Akonadi/Calendar/ITIPHandler>
40

Laurent Montel's avatar
Laurent Montel committed
41
#include <CalendarSupport/MessageWidget>
42

43
44
45
46
47
48
49
class DateChecker;
class DateNavigator;
class DateNavigatorContainer;
class KODialogManager;
class KOTodoView;
class KOViewManager;
class NavigatorBar;
50
class KOCheckableProxyModel;
51
class AkonadiCollectionView;
Laurent Montel's avatar
Laurent Montel committed
52
53
54
namespace KOrg
{
class HTMLExportSettings;
55
56
}

Laurent Montel's avatar
Laurent Montel committed
57
58
59
60
namespace CalendarSupport
{
class CalPrinter;
class IncidenceViewer;
61
62
}

Laurent Montel's avatar
Laurent Montel committed
63
64
65
namespace IncidenceEditorNG
{
class IncidenceDialog;
66
}
67

Laurent Montel's avatar
Laurent Montel committed
68
69
70
71
72
73
namespace Akonadi
{
class History;
class IncidenceChanger;
class CalendarClipboard;
class TodoPurger;
74
75
}

76
77
78
class QSplitter;
class QStackedWidget;

79
80
using namespace KOrg;

81
82
class CalendarViewExtension : public QWidget
{
Laurent Montel's avatar
Laurent Montel committed
83
    Q_OBJECT
Laurent Montel's avatar
Laurent Montel committed
84
85
public:
    explicit CalendarViewExtension(QWidget *parent) : QWidget(parent) {}
86
87
88

    class Factory
    {
Laurent Montel's avatar
Laurent Montel committed
89
    public:
90
        virtual ~Factory() {}
Laurent Montel's avatar
Laurent Montel committed
91
        virtual CalendarViewExtension *create(QWidget *parent) = 0;
92
93
94
95
96
97
98
99
100
101
102
103
104
    };
};

/**
  This is the main calendar widget. It provides the different views on the
  calendar data as well as the date navigator. It also handles synchronization
  of the different views and controls the different dialogs like preferences,
  event editor, search dialog etc.

  @short main calendar view widget
  @author Cornelius Schumacher
*/
class KORGANIZERPRIVATE_EXPORT CalendarView : public KOrg::CalendarViewBase,
Laurent Montel's avatar
Laurent Montel committed
105
    public Akonadi::ETMCalendar::CalendarObserver
106
{
Laurent Montel's avatar
Laurent Montel committed
107
108
    Q_OBJECT
public:
109
110
111
112
    /**
      Constructs a new calendar view widget.
      @param parent   parent window
    */
Laurent Montel's avatar
Laurent Montel committed
113
    explicit CalendarView(QWidget *parent = Q_NULLPTR);
114
115
    virtual ~CalendarView();

116
    class CalendarViewVisitor : public KCalCore::Visitor
117
    {
Laurent Montel's avatar
Laurent Montel committed
118
    public:
Laurent Montel's avatar
Laurent Montel committed
119
        CalendarViewVisitor() : mView(Q_NULLPTR)
Allen Winter's avatar
Allen Winter committed
120
121
122
        {
        }

Laurent Montel's avatar
Laurent Montel committed
123
        bool act(KCalCore::IncidenceBase::Ptr &incidence, CalendarView *view)
124
        {
Laurent Montel's avatar
Laurent Montel committed
125
126
            mView = view;
            return incidence->accept(*this, incidence);
127
        }
Allen Winter's avatar
Allen Winter committed
128

Laurent Montel's avatar
Laurent Montel committed
129
    protected:
130
131
132
        CalendarView *mView;
    };

Laurent Montel's avatar
Laurent Montel committed
133
    void setCalendar(const Akonadi::ETMCalendar::Ptr &);
Laurent Montel's avatar
Laurent Montel committed
134
    Akonadi::ETMCalendar::Ptr calendar() const Q_DECL_OVERRIDE;
135

136
137
    void showMessage(const QString &message, KMessageWidget::MessageType);

138
    Akonadi::History *history() const;
Laurent Montel's avatar
Laurent Montel committed
139
    void setCheckableProxyModel(KOCheckableProxyModel *);
140

Laurent Montel's avatar
Laurent Montel committed
141
142
143
144
145
146
147
148
    KOViewManager *viewManager() const
    {
        return mViewManager;
    }
    KODialogManager *dialogManager() const
    {
        return mDialogManager;
    }
149

Laurent Montel's avatar
Laurent Montel committed
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
    QStackedWidget *viewStack() const
    {
        return mRightFrame;
    }
    QWidget *leftFrame() const
    {
        return mLeftFrame;
    }
    NavigatorBar *navigatorBar() const
    {
        return mNavigatorBar;
    }
    DateNavigator *dateNavigator() const
    {
        return mDateNavigator;
    }
166
167
    // TODO_NG
    //IncidenceEditors::IncidenceEditor *editorDialog( const Akonadi::Item &item ) const;
Laurent Montel's avatar
Laurent Montel committed
168
    Akonadi::IncidenceChanger *incidenceChanger() const Q_DECL_OVERRIDE
Laurent Montel's avatar
Laurent Montel committed
169
170
171
    {
        return mChanger;
    }
172

Allen Winter's avatar
Allen Winter committed
173
    /**
174
175
176
177
178
179
     * Informs the date navigator which incidence types should be used
     * to embolden days, this function is mainly called when the view changes
     * or when the config changes.
     */
    void updateHighlightModes();

Laurent Montel's avatar
Laurent Montel committed
180
181
    QDate startDate() Q_DECL_OVERRIDE;
    QDate endDate() Q_DECL_OVERRIDE;
182
183

    KOrg::BaseView *currentView() const;
Laurent Montel's avatar
Laurent Montel committed
184
185
    void addView(KOrg::BaseView *) Q_DECL_OVERRIDE;
    void showView(KOrg::BaseView *) Q_DECL_OVERRIDE;
186
187

    /**
Allen Winter's avatar
Allen Winter committed
188
189
190
     * Adds a calendar view extension widget. CalendarView takes ownership of the
     * objects created by the factory.
     */
Laurent Montel's avatar
Laurent Montel committed
191
    void addExtension(CalendarViewExtension::Factory *);
192

Allen Winter's avatar
Allen Winter committed
193
194
195
196
    /**
     * Returns the item selected in the current view (or an invalid one if none selected)
     * @reimp
     */
Laurent Montel's avatar
Laurent Montel committed
197
    Akonadi::Item currentSelection() Q_DECL_OVERRIDE;
198

Allen Winter's avatar
Allen Winter committed
199
200
201
202
    /**
     * Returns a pointer to the incidence selected in the current view. If there
     * is no selection, return the selected todo from the todo list on the left.
     */
203
204
    Akonadi::Item selectedIncidence();

Allen Winter's avatar
Allen Winter committed
205
206
207
    /**
     * Returns true if there's a filter applied.
     */
208
209
    bool isFiltered() const;

Allen Winter's avatar
Allen Winter committed
210
211
212
    /**
     * Returns the name of the current filter.
     */
213
214
    QString currentFilterName() const;

Laurent Montel's avatar
Laurent Montel committed
215
Q_SIGNALS:
216
    /** when change is made to options dialog, the topwidget will catch this
Laurent Montel's avatar
Laurent Montel committed
217
     *  and Q_EMIT this signal which notifies all widgets which have registered
218
219
220
221
     *  for notification to update their settings. */
    void configChanged();

    /** Emitted right before we die */
Laurent Montel's avatar
Laurent Montel committed
222
    void closed(QWidget *);
223
224

    /** Emitted when state of modified flag changes */
Laurent Montel's avatar
Laurent Montel committed
225
    void modifiedChanged(bool);
226
227

    /** Emitted when state of read-only flag changes */
Laurent Montel's avatar
Laurent Montel committed
228
    void readOnlyChanged(bool);
229
230

    /** Emitted when the unit of navigation changes */
Laurent Montel's avatar
Laurent Montel committed
231
232
    void changeNavStringPrev(const QString &);
    void changeNavStringNext(const QString &);
233
234

    /** Emitted when state of events selection has changed and user is organizer*/
Laurent Montel's avatar
Laurent Montel committed
235
    void organizerEventsSelected(bool);
236
    /** Emitted when state of events selection has changed and user is attendee*/
Laurent Montel's avatar
Laurent Montel committed
237
    void groupEventsSelected(bool);
238
239
240
241
    /**
      Emitted when an incidence gets selected. If the selection is cleared the
      signal is emitted with 0 as argument.
    */
Laurent Montel's avatar
Laurent Montel committed
242
    void incidenceSelected(const Akonadi::Item &incidence, const QDate &date);
243
244
    /** Emitted, when a todoitem is selected or deselected.
        the connected slots enables/disables the corresponding menu items */
Laurent Montel's avatar
Laurent Montel committed
245
246
    void todoSelected(bool);
    void subtodoSelected(bool);
247
248
249

    /** Emitted, when a day changed (i.e. korganizer was running at midnight).
        The argument is the new date */
Laurent Montel's avatar
Laurent Montel committed
250
    void dayPassed(const QDate &);
251
252
253
254
255

    /**
      Emitted, when clipboard content changes. Parameter indicates if paste
      is possible or not.
    */
Laurent Montel's avatar
Laurent Montel committed
256
    void pasteEnabled(bool);
257
    /** Send status message, which can e.g. be displayed in the status bar. */
Laurent Montel's avatar
Laurent Montel committed
258
    void statusMessage(const QString &);
259

Laurent Montel's avatar
Laurent Montel committed
260
    void calendarViewExpanded(bool);
261
262
263
264

    /** Emitted when auto-archiving options were modified */
    void autoArchivingSettingsModified();

Laurent Montel's avatar
Laurent Montel committed
265
    void newIncidenceChanger(Akonadi::IncidenceChanger *) Q_DECL_OVERRIDE;
Laurent Montel's avatar
Laurent Montel committed
266
    void exportHTML(KOrg::HTMLExportSettings *);
267

Laurent Montel's avatar
Laurent Montel committed
268
    void filtersUpdated(const QStringList &, int);
269
270
    void filterChanged();

Laurent Montel's avatar
Laurent Montel committed
271
public Q_SLOTS:
272
273
274
    /** options dialog made a changed to the configuration. we catch this
     *  and notify all widgets which need to update their configuration. */
    void updateConfig();
Laurent Montel's avatar
Laurent Montel committed
275
    void updateConfig(const QByteArray &);
276

277
    void handleIncidenceCreated(const Akonadi::Item &item);
278
279
280
281
282
283

    /**
      Save calendar data to file. Return true if calendar could be
      successfully saved.
        @param filename The file name to save the calendar to
    */
Laurent Montel's avatar
Laurent Montel committed
284
    bool saveCalendar(const QString &filename);
285
286
287
288

    /** Archive old events of calendar */
    void archiveCalendar();

Laurent Montel's avatar
Laurent Montel committed
289
    void newEvent(const QDate &);
290

291
292
293
294
    /**
       create new event without having a date hint. Takes current date as
       default hint.
    */
295
    void newEvent();
296

297
298
299
300
    /**
       create an editeventwin with supplied date/time, and if bool is true,
       make the event take all day.
    */
Laurent Montel's avatar
Laurent Montel committed
301
    void newEvent(const QDateTime &startDt);
302

Laurent Montel's avatar
Laurent Montel committed
303
    void newEvent(const QDateTime &startDt, const QDateTime &EndDt, bool allDay = false);
304
305
306
307
308

    /**
      Create new Event from given summary, description, attachment list and
      attendees list
    */
Laurent Montel's avatar
Laurent Montel committed
309
310
311
312
313
314
    void newEvent(const QString &summary,
                  const QString &description = QString(),
                  const QStringList &attachment = QStringList(),
                  const QStringList &attendees = QStringList(),
                  const QStringList &attachmentMimetypes = QStringList(),
                  bool inlineAttachment = false);
315
316
317
318
    void newFloatingEvent();

    /** Create a read-only viewer dialog for the supplied incidence.
        It calls the correct showXXX method */
Laurent Montel's avatar
Laurent Montel committed
319
320
    void showIncidence(const Akonadi::Item &item);
    bool showIncidence(Akonadi::Item::Id id);
321
322
323
324
325
326
327
    void showIncidence();

    /**
      Show an incidence in context. This means showing the todo, agenda or
      journal view (as appropriate) and scrolling it to show the incidence.
      @param incidence The incidence to show.
    */
Laurent Montel's avatar
Laurent Montel committed
328
329
    void showIncidenceContext(const Akonadi::Item &incidence);
    bool showIncidenceContext(Akonadi::Item::Id id);
330
331

    /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
Laurent Montel's avatar
Laurent Montel committed
332
    bool editIncidence(const Akonadi::Item &item, bool isCounter = false) Q_DECL_OVERRIDE;
Laurent Montel's avatar
Laurent Montel committed
333
    bool editIncidence(Akonadi::Item::Id id);
334
335
336
337
338
339
340
341
342
    void editIncidence();

    /**
      Delete the supplied incidence. It calls the correct deleteXXX method
      @param force If true, all recurrences and sub-todos (if applicable) will be
                   deleted without prompting for confirmation.
      @param force If true, all recurrences and sub-todos (if applicable) will be
                   deleted without prompting for confirmation.
    */
Laurent Montel's avatar
Laurent Montel committed
343
344
    bool deleteIncidence(const Akonadi::Item &item, bool force = false);
    bool deleteIncidence(Akonadi::Item::Id id, bool force = false);
345
346
    void deleteIncidence();

Laurent Montel's avatar
Laurent Montel committed
347
348
349
350
351
352
353
    /**
     Add an incidence to the active calendar.
     @param ical A calendar in iCalendar format containing the incidence. The
                 calendar must consist of a VCALENDAR component which contains
                 the incidence (VEVENT, VTODO, VJOURNAL or VFREEBUSY) and
                 optionally a VTIMEZONE component. If there is more than one
                 incidence, only the first is added to KOrganizer's calendar.
354
    */
Laurent Montel's avatar
Laurent Montel committed
355
356
    bool addIncidence(const QString &ical);
    bool addIncidence(const KCalCore::Incidence::Ptr &incidence);
357
358
359
360

    /**
      Cuts the selected incidence using the edit_cut() method
    */
Laurent Montel's avatar
Laurent Montel committed
361
    void cutIncidence(const Akonadi::Item &);
362
363
364
365

    /**
      Copies the selected incidence using the edit_copy() method
    */
Laurent Montel's avatar
Laurent Montel committed
366
    void copyIncidence(const Akonadi::Item &);
367
368
369
370
371
372
373

    /**
      Pastes the current incidence using the edit_paste() method
    */
    void pasteIncidence();

    /** Delete the supplied todo and all sub-todos */
Laurent Montel's avatar
Laurent Montel committed
374
    void deleteSubTodosIncidence(const Akonadi::Item &todo);
375
376
377
378
379
380

    /**
      Delete the todo incidence, and its sub-to-dos.
      @param todo The todo to delete.
      @param force If true, all sub-todos will be deleted without prompting for confirmation.
    */
Laurent Montel's avatar
Laurent Montel committed
381
    void deleteTodoIncidence(const Akonadi::Item &todo, bool force = false);
382
383
384
385
386

    /** create new todo */
    void newTodo();

    /** create new todo, due on date */
Laurent Montel's avatar
Laurent Montel committed
387
    void newTodo(const QDate &date);
388
389

    /** create new todo **/
Laurent Montel's avatar
Laurent Montel committed
390
    void newTodo(const Akonadi::Collection &collection);
391
392
393
394
395

    /** create new todo with a parent todo */
    void newSubTodo();

    /** create new todo with a parent todo */
Laurent Montel's avatar
Laurent Montel committed
396
    void newSubTodo(const Akonadi::Item &todo);
397
398

    /** create new todo with parent todo */
Laurent Montel's avatar
Laurent Montel committed
399
    void newSubTodo(const Akonadi::Collection &collection);
400

Laurent Montel's avatar
Laurent Montel committed
401
402
403
404
405
    void newTodo(const QString &summary, const QString &description = QString(),
                 const QStringList &attachments = QStringList(),
                 const QStringList &attendees = QStringList(),
                 const QStringList &attachmentMimetypes = QStringList(),
                 bool inlineAttachment = false);
406
407

    void newJournal();
Laurent Montel's avatar
Laurent Montel committed
408
409
410
    void newJournal(const QDate &date);
    void newJournal(const QString &text, const QDate &date = QDate());
    void newJournal(const Akonadi::Collection &collection);
411
412
413

    void configureCurrentView();

Laurent Montel's avatar
Laurent Montel committed
414
415
416
417
418
    void toggleAlarm(const Akonadi::Item &incidence);
    void toggleTodoCompleted(const Akonadi::Item &incidence);
    void copyIncidenceToResource(const Akonadi::Item &incidence, const Akonadi::Collection &col);
    void moveIncidenceToResource(const Akonadi::Item &incidence, const Akonadi::Collection &col);
    void dissociateOccurrences(const Akonadi::Item &incidence, const QDate &date);
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437

    /**
      Check if clipboard contains vCalendar event. The signal pasteEnabled() is
      emitted as result.
    */
    void checkClipboard();

    /**
      Using the KConfig associated with the kapp variable, read in the
      settings from the config file.

      You have to call setCalendar before calling readSettings.
    */
    void readSettings();

    /** write current state to config file. */
    void writeSettings();

    /** read settings for calendar filters */
Laurent Montel's avatar
Laurent Montel committed
438
    void readFilterSettings(KConfig *config);
439
440

    /** write settings for calendar filters */
Laurent Montel's avatar
Laurent Montel committed
441
    void writeFilterSettings(KConfig *config);
442
443
444

    /** passes on the message that an event has changed to the currently
     * activated view so that it can make appropriate display changes. */
Laurent Montel's avatar
Laurent Montel committed
445
446
    void changeIncidenceDisplay(const Akonadi::Item &incidence,
                                Akonadi::IncidenceChanger::ChangeType);
447

Laurent Montel's avatar
Laurent Montel committed
448
449
450
451
    void slotCreateFinished(int changeId,
                            const Akonadi::Item &item,
                            Akonadi::IncidenceChanger::ResultCode resultCode,
                            const QString &errorString);
452

Laurent Montel's avatar
Laurent Montel committed
453
454
455
456
    void slotModifyFinished(int changeId,
                            const Akonadi::Item &item,
                            Akonadi::IncidenceChanger::ResultCode resultCode,
                            const QString &errorString);
457

Laurent Montel's avatar
Laurent Montel committed
458
459
460
461
    void slotDeleteFinished(int changeId,
                            const QVector<Akonadi::Item::Id> &itemIdList,
                            Akonadi::IncidenceChanger::ResultCode resultCode,
                            const QString &errorString);
462

Laurent Montel's avatar
Laurent Montel committed
463
    void startMultiModify(const QString &text);
464
465
    void endMultiModify();

Laurent Montel's avatar
Laurent Montel committed
466
467
    void updateView(const QDate &start, const QDate &end,
                    const QDate &preferredMonth, const bool updateTodos = true);
Laurent Montel's avatar
Laurent Montel committed
468
    void updateView() Q_DECL_OVERRIDE;
469
470
471
472
473
474
475
476
477
478
479
480

    void updateUnmanagedViews();

    /** cut the current appointment to the clipboard */
    void edit_cut();

    /** copy the current appointment(s) to the clipboard */
    void edit_copy();

    /** paste the current vobject(s) in the clipboard buffer into calendar */
    void edit_paste();

481
482
    void onCutFinished();

483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
    /** edit viewing and configuration options. */
    void edit_options();

    /**
      Functions for printing, previewing a print, and setting up printing
      parameters.
    */
    void print();
    void printPreview();

    /** Export as HTML file */
    void exportWeb();

    /** Export as iCalendar file */
    void exportICalendar();

    /** Export as vCalendar file */
    void exportVCalendar();

    /** pop up a dialog to show an existing appointment. */
    void appointment_show();
    /**
     * pop up an Appointment Dialog to edit an existing appointment. Get
     * information on the appointment from the list of unique IDs that is
     * currently in the View, called currIds.
     */
    void appointment_edit();

    /**
     * pop up dialog confirming deletion of currently selected event in the
     * View.
     */
    void appointment_delete();

    /** Frees a subtodo from it's relation, update the view */
    void todo_unsub();

    /* Frees an incidence's children from it's relation, without the view update
       Works with any incidence type, although currently we only pass to-dos
    */
Laurent Montel's avatar
Laurent Montel committed
523
    bool incidence_unsub(const Akonadi::Item &item);
524
525

    /** Make all sub-to-dos of the selected todo independent, update the view */
Laurent Montel's avatar
Laurent Montel committed
526
    bool makeSubTodosIndependent();
527
528
529
530

    /** Make all children of incidence independent, not update the view
        Works with any incidence type, although currently we only pass to-dos
    */
Laurent Montel's avatar
Laurent Montel committed
531
    bool makeChildrenIndependent(const Akonadi::Item &item);
532
533
534
535
536
537
538
539
540
541

    /** Take ownership of selected event. */
    void takeOverEvent();

    /** query if the calendar is read-only. */
    bool isReadOnly() const;

    /** set state of calendar to read-only
        @param readOnly whether the calendar view should be set read-only or not
    */
Laurent Montel's avatar
Laurent Montel committed
542
    void setReadOnly(bool readOnly = true);
543

Laurent Montel's avatar
Laurent Montel committed
544
    void eventUpdated(const Akonadi::Item &incidence);
545
546

    /* iTIP scheduling actions */
Laurent Montel's avatar
Laurent Montel committed
547
548
549
550
551
552
553
554
555
556
    void schedule_publish(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_request(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_refresh(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_cancel(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_add(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_reply(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_counter(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_declinecounter(const Akonadi::Item &incidence = Akonadi::Item());
    void schedule_forward(const Akonadi::Item &incidence = Akonadi::Item());
    void mailFreeBusy(int daysToPublish = 30);
557
558
559
560
561
562
563
564
565
566
    void uploadFreeBusy();

    void openAddressbook();

    void editFilters();

    void updateFilter();

    void showIntro();

Laurent Montel's avatar
Laurent Montel committed
567
568
569
    void showDateNavigator(bool);
    void showTodoView(bool);
    void showEventViewer(bool);
570
571

    /** Move the current view date to the specified date */
Laurent Montel's avatar
Laurent Montel committed
572
    void goDate(const QDate &date);
573
574

    /** Show the given date without changing date selection length. */
Laurent Montel's avatar
Laurent Montel committed
575
    void showDate(const QDate &date);
576
577
578
579
580
581
582
583
584
585

    /** Move the current view date to today */
    void goToday();

    /** Move to the next date(s) in the current view */
    void goNext();

    /** Move to the previous date(s) in the current view */
    void goPrevious();

Laurent Montel's avatar
Laurent Montel committed
586
    void showLeftFrame(bool show = true);
587

Laurent Montel's avatar
Laurent Montel committed
588
    void dialogClosing(const Akonadi::Item &incidence);
589

Laurent Montel's avatar
Laurent Montel committed
590
591
    void processMainViewSelection(const Akonadi::Item &incidence, const QDate &date);
    void processTodoListSelection(const Akonadi::Item &incidence, const QDate &date);
592

Laurent Montel's avatar
Laurent Montel committed
593
    void processIncidenceSelection(const Akonadi::Item &incidence, const QDate &date);
594
595
596

    void purgeCompleted();

Laurent Montel's avatar
Laurent Montel committed
597
598
    void slotAutoArchivingSettingsModified()
    {
Laurent Montel's avatar
Laurent Montel committed
599
        Q_EMIT autoArchivingSettingsModified();
Laurent Montel's avatar
Laurent Montel committed
600
    }
601

Laurent Montel's avatar
Laurent Montel committed
602
603
604
605
606
    void showErrorMessage(const QString &);
    void schedule(KCalCore::iTIPMethod, const Akonadi::Item &incidence);
    void addIncidenceOn(const Akonadi::Item &incidence, const QDate &);
    void moveIncidenceTo(const Akonadi::Item &incidence, const QDate &);
    void filterActivated(int filterNum);
607
608
609
610

    void resourcesChanged();

    /**
Allen Winter's avatar
Allen Winter committed
611
612
613
614
615
616
617
     * The user clicked on a week number in the date navigator
     *
     * Select a week or a work week depending on the user's config option.
     *
     * @param preferredMonth Holds the month that should be selected when
     * the week crosses months.  It's a QDate instead of uint so it can be
     * easily fed to KCalendarSystem's functions.
618
    */
Laurent Montel's avatar
Laurent Montel committed
619
    void selectWeek(const QDate &week, const QDate &preferredMonth);
620

621
622
623
624
625
626
    /**
     * Use as much of the full window as possible for the view.
     *
     * @param fullView if true, expand the view as much as possible within the
     * main view (hiding the sidebar for example); else put back the normal view.
     */
Laurent Montel's avatar
Laurent Montel committed
627
    void changeFullView(bool fullView);
628

Laurent Montel's avatar
Laurent Montel committed
629
protected Q_SLOTS:
Allen Winter's avatar
Allen Winter committed
630
631
632
633
634
    /**
     * Select a view or adapt the current view to display the specified dates.
     * @p preferredMonth is useful when the datelist crosses months, if valid,
     * any month-like component should honour this
     */
Laurent Montel's avatar
Laurent Montel committed
635
    void showDates(const KCalCore::DateList &, const QDate &preferredMonth = QDate());
636

Laurent Montel's avatar
Laurent Montel committed
637
public:
638
639
640
    int msgCalModified();

    /**
Allen Winter's avatar
Allen Winter committed
641
642
     * Adapts navigation units according to the current view's navigation step size.
     */
643
644
645
    void adaptNavigationUnits();

    /**
Allen Winter's avatar
Allen Winter committed
646
647
648
649
650
     * Returns the date of the selected incidence.
     *
     * If the selected incidence is recurring, it will return the date
     * of the selected occurrence.
     */
651
652
653
654
655
656
657
658
659
660
661
662
    QDate activeIncidenceDate();

    /**
      Returns the best guess at the current active date in the view.
      This has nothing to do with selected incidences, use activeIncidenceDate()
      for that, for example, agenda supports time selection and incidence selection
      and they can have diferent dates.

      @param fallbackToToday If guessing doesn't work, some views will prefer
      today to be returned instead of the first select date in the day matrix,
      Journal view for example.
    */
Laurent Montel's avatar
Laurent Montel committed
663
    QDate activeDate(bool fallbackToToday = false);
664

Laurent Montel's avatar
Laurent Montel committed
665
666
protected:
    int msgItemDelete(const Akonadi::Item &incidence);
667
668

    Akonadi::Item selectedTodo();
669
    IncidenceEditorNG::IncidenceDialog *incidenceDialog(const Akonadi::Item &);
670

Laurent Montel's avatar
Laurent Montel committed
671
672
    void warningChangeFailed(const Akonadi::Item &);
    void checkForFilteredChange(const Akonadi::Item &incidence);
673
674
675
676
677

    /**
      Adjust the given date/times by valid defaults (selection or configured
      defaults, if invalid values are given) and allow the view to adjust the type.
    */
Laurent Montel's avatar
Laurent Montel committed
678
679
    void dateTimesForNewEvent(QDateTime &startDt, QDateTime &endDt, bool &allDay);
    IncidenceEditorNG::IncidenceDialog *newEventEditor(const KCalCore::Event::Ptr &event);
680

Laurent Montel's avatar
Laurent Montel committed
681
    bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
682

Laurent Montel's avatar
Laurent Montel committed
683
684
685
private Q_SLOTS:
    void onCheckableProxyAboutToToggle(bool newState);
    void onCheckableProxyToggled(bool newState);
686
    void onTodosPurged(bool success, int numDeleted, int numIgnored);
687

Laurent Montel's avatar
Laurent Montel committed
688
private:
689
    void init();
690
691
    Akonadi::Collection selectedCollection() const;
    Akonadi::Collection::List checkedCollections() const;
692
693
694

    void createPrinter();

Laurent Montel's avatar
Laurent Montel committed
695
    void dissociateOccurrence(const Akonadi::Item &incidence, const QDate &, bool futureOccurrences);
696

697
    /**
Allen Winter's avatar
Allen Winter committed
698
699
700
701
702
703
     * Returns the default collection.
     * The view's collection takes precedence, only then the config one is used.
     * If mimeType is set, the collection to return will have to support that mime type.
     * If no valid collection is found, an invalid one is returned.
     */
    Akonadi::Collection defaultCollection(
Laurent Montel's avatar
Laurent Montel committed
704
        const QLatin1String &mimeType = QLatin1String("")) const;
705
706

    /**
Allen Winter's avatar
Allen Winter committed
707
708
709
710
     * Creates a new incidence editor and chooses a decent default for the collection
     * in the collection combo.
     */
    IncidenceEditorNG::IncidenceDialog *createIncidenceEditor(
Laurent Montel's avatar
Laurent Montel committed
711
        const Akonadi::Item &item, const Akonadi::Collection &collection = Akonadi::Collection());
712

713
    CalendarSupport::CalPrinter *mCalPrinter;
714
    Akonadi::TodoPurger *mTodoPurger;
715
716
717
718
719

    QSplitter *mPanner;
    QSplitter *mLeftSplitter;
    QWidget *mLeftFrame;
    QStackedWidget *mRightFrame;
720
    CalendarSupport::MessageWidget *mMessageWidget;
721
722
723
724
725
726
727

    // This navigator bar is used when in full window month view
    // It has nothing to do with the date navigator
    NavigatorBar *mNavigatorBar;

    DateNavigatorContainer *mDateNavigatorContainer;

Laurent Montel's avatar
Laurent Montel committed
728
    QList<CalendarViewExtension *> mExtensions;
729

730
    Akonadi::ETMCalendar::Ptr mCalendar;
731
732
733
734

    DateNavigator *mDateNavigator;
    DateChecker *mDateChecker;

Laurent Montel's avatar
Laurent Montel committed
735
    QWidget *mEventViewerBox;
736
737
738
739
740
    CalendarSupport::IncidenceViewer *mEventViewer;
    KOViewManager *mViewManager;
    KODialogManager *mDialogManager;

    // Calendar filters
Laurent Montel's avatar
Laurent Montel committed
741
    QList<KCalCore::CalFilter *> mFilters;
742
    KCalCore::CalFilter *mCurrentFilter;
743
744
745
746
747
748
749
750

    // various housekeeping variables.
    bool  mReadOnly; // flag indicating if calendar is read-only

    Akonadi::Item mSelectedIncidence;
    QDate mSaveDate;

    KOTodoView *mTodoList;
751
    Akonadi::IncidenceChanger *mChanger;
752
    Akonadi::ITIPHandler *mITIPHandler;
753
754
755
    QList<int> mMainSplitterSizes; // temp store for main splitter sizes while left frame is hidden
    bool mSplitterSizesValid;
    bool mCreatingEnabled;
756

757
    Akonadi::CalendarClipboard *mCalendarClipboard;
758
    KOCheckableProxyModel *mCheckableProxyModel;
759
    AkonadiCollectionView *mETMCollectionView;
760

761
    SearchCollectionHelper mSearchCollectionHelper;
762
763
764
};

#endif