1 /*
2   This file is part of KOrganizer.
3 
4   SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
5 
6   SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 
9 #pragma once
10 
11 #include "koeventview.h"
12 
13 #include <EventViews/ConfigDialogInterface>
14 
15 #include <QDialog>
16 
17 #include <QAbstractItemModel>
18 
19 #include <memory>
20 
21 namespace KOrg
22 {
23 class MultiAgendaViewPrivate;
24 
25 /**
26   Shows one agenda for every resource side-by-side.
27 */
28 class MultiAgendaView : public KOEventView
29 {
30     Q_OBJECT
31 public:
32     explicit MultiAgendaView(QWidget *parent = nullptr);
33     ~MultiAgendaView() override;
34 
35     Q_REQUIRED_RESULT Akonadi::Item::List selectedIncidences() override;
36     Q_REQUIRED_RESULT KCalendarCore::DateList selectedIncidenceDates() override;
37     Q_REQUIRED_RESULT int currentDateCount() const override;
38     Q_REQUIRED_RESULT int maxDatesHint() const override;
39 
40     Q_REQUIRED_RESULT bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay) override;
41     void setCalendar(const Akonadi::ETMCalendar::Ptr &cal) override;
42 
43     /**
44      * reimplemented from KOrg::BaseView
45      */
46     Q_REQUIRED_RESULT bool hasConfigurationDialog() const override;
47 
48     /**
49      * reimplemented from KOrg::BaseView
50      */
51     void showConfigurationDialog(QWidget *parent) override;
52 
53     void setChanges(EventViews::EventView::Changes changes) override;
54 
55     KCheckableProxyModel *takeCustomCollectionSelectionProxyModel();
56     void setCustomCollectionSelectionProxyModel(KCheckableProxyModel *model);
57 
58     void restoreConfig(const KConfigGroup &configGroup) override;
59     void saveConfig(KConfigGroup &configGroup) override;
60 
61     void setDateRange(const QDateTime &start, const QDateTime &end, const QDate &preferredMonth = QDate()) override;
62 
63     Q_REQUIRED_RESULT Akonadi::Collection::Id collectionId() const override;
64 
65 public Q_SLOTS:
66     void showDates(const QDate &start, const QDate &end, const QDate &preferredMonth = QDate()) override;
67     void showIncidences(const Akonadi::Item::List &incidenceList, const QDate &date) override;
68     void updateView() override;
69     void changeIncidenceDisplay(const Akonadi::Item &, Akonadi::IncidenceChanger::ChangeType) override;
70     void updateConfig() override;
71 
72     void setIncidenceChanger(Akonadi::IncidenceChanger *changer) override;
73 
74 private:
75     std::unique_ptr<MultiAgendaViewPrivate> const d;
76 };
77 
78 class MultiAgendaViewConfigDialogPrivate;
79 
80 class MultiAgendaViewConfigDialog : public QDialog, public EventViews::ConfigDialogInterface
81 {
82     Q_OBJECT
83 public:
84     explicit MultiAgendaViewConfigDialog(QAbstractItemModel *baseModel, QWidget *parent = nullptr);
85     ~MultiAgendaViewConfigDialog() override;
86 
87     bool useCustomColumns() const override;
88     void setUseCustomColumns(bool);
89 
90     int numberOfColumns() const override;
91     void setNumberOfColumns(int n);
92 
93     QString columnTitle(int column) const override;
94     void setColumnTitle(int column, const QString &title);
95     KCheckableProxyModel *takeSelectionModel(int column) override;
96     void setSelectionModel(int column, KCheckableProxyModel *model);
97 
98 public Q_SLOTS:
99     /**
100      * reimplemented from QDialog
101      */
102     void accept() override;
103 
104 private Q_SLOTS:
105     void useCustomToggled(bool);
106     void numberOfColumnsChanged(int);
107     void currentChanged(const QModelIndex &index);
108     void titleEdited(const QString &text);
109 
110 private:
111     std::unique_ptr<MultiAgendaViewConfigDialogPrivate> const d;
112 };
113 }
114 
115