1 /*
2   This file is part of the KOrganizer interfaces.
3 
4   SPDX-FileCopyrightText: 1999, 2001, 2003 Cornelius Schumacher <schumacher@kde.org>
5   SPDX-FileCopyrightText: 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 
7   SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #include "baseview.h"
11 
12 #include <KRandom>
13 
14 using namespace KOrg;
15 
16 class KOrg::BaseViewPrivate
17 {
18     BaseView *const q;
19 
20 public:
BaseViewPrivate(BaseView * qq)21     explicit BaseViewPrivate(BaseView *qq)
22         : q(qq)
23         , mChanges(EventViews::EventView::IncidencesAdded | EventViews::EventView::DatesChanged)
24         , calendar(nullptr)
25     {
26         QByteArray cname = q->metaObject()->className();
27         cname.replace(':', '_');
28         identifier = cname + '_' + KRandom::randomString(8).toLatin1();
29     }
30 
~BaseViewPrivate()31     ~BaseViewPrivate()
32     {
33     }
34 
35     EventViews::EventView::Changes mChanges;
36     Akonadi::ETMCalendar::Ptr calendar;
37     QByteArray identifier;
38     QDateTime startDateTime;
39     QDateTime endDateTime;
40     QDateTime actualStartDateTime;
41     QDateTime actualEndDateTime;
42 };
43 
BaseView(QWidget * parent)44 BaseView::BaseView(QWidget *parent)
45     : QWidget(parent)
46     , d(new BaseViewPrivate(this))
47 {
48 }
49 
50 BaseView::~BaseView() = default;
51 
setCalendar(const Akonadi::ETMCalendar::Ptr & calendar)52 void BaseView::setCalendar(const Akonadi::ETMCalendar::Ptr &calendar)
53 {
54     d->calendar = calendar;
55 }
56 
printType() const57 CalendarSupport::CalPrinterBase::PrintType BaseView::printType() const
58 {
59     return CalendarSupport::CalPrinterBase::Month;
60 }
61 
calendar()62 Akonadi::ETMCalendar::Ptr BaseView::calendar()
63 {
64     return d->calendar;
65 }
66 
selectionStart()67 QDateTime BaseView::selectionStart()
68 {
69     return QDateTime();
70 }
71 
selectionEnd()72 QDateTime BaseView::selectionEnd()
73 {
74     return QDateTime();
75 }
76 
isEventView()77 bool BaseView::isEventView()
78 {
79     return false;
80 }
81 
dayPassed(const QDate &)82 void BaseView::dayPassed(const QDate &)
83 {
84     updateView();
85 }
86 
setIncidenceChanger(Akonadi::IncidenceChanger * changer)87 void BaseView::setIncidenceChanger(Akonadi::IncidenceChanger *changer)
88 {
89     mChanger = changer;
90 }
91 
flushView()92 void BaseView::flushView()
93 {
94 }
95 
viewAt(const QPoint &)96 BaseView *BaseView::viewAt(const QPoint &)
97 {
98     return this;
99 }
100 
updateConfig()101 void BaseView::updateConfig()
102 {
103 }
104 
hasConfigurationDialog() const105 bool BaseView::hasConfigurationDialog() const
106 {
107     return false;
108 }
109 
setDateRange(const QDateTime & start,const QDateTime & end,const QDate & preferredMonth)110 void BaseView::setDateRange(const QDateTime &start, const QDateTime &end, const QDate &preferredMonth)
111 {
112     d->startDateTime = start;
113     d->endDateTime = end;
114     showDates(start.date(), end.date(), preferredMonth);
115     const QPair<QDateTime, QDateTime> adjusted = actualDateRange(start, end, preferredMonth);
116     d->actualStartDateTime = adjusted.first;
117     d->actualEndDateTime = adjusted.second;
118 }
119 
startDateTime() const120 QDateTime BaseView::startDateTime() const
121 {
122     return d->startDateTime;
123 }
124 
endDateTime() const125 QDateTime BaseView::endDateTime() const
126 {
127     return d->endDateTime;
128 }
129 
actualStartDateTime() const130 QDateTime BaseView::actualStartDateTime() const
131 {
132     return d->actualStartDateTime;
133 }
134 
actualEndDateTime() const135 QDateTime BaseView::actualEndDateTime() const
136 {
137     return d->actualEndDateTime;
138 }
139 
showConfigurationDialog(QWidget *)140 void BaseView::showConfigurationDialog(QWidget *)
141 {
142 }
143 
identifier() const144 QByteArray BaseView::identifier() const
145 {
146     return d->identifier;
147 }
148 
setIdentifier(const QByteArray & identifier)149 void BaseView::setIdentifier(const QByteArray &identifier)
150 {
151     d->identifier = identifier;
152 }
153 
restoreConfig(const KConfigGroup & configGroup)154 void BaseView::restoreConfig(const KConfigGroup &configGroup)
155 {
156     doRestoreConfig(configGroup);
157 }
158 
saveConfig(KConfigGroup & configGroup)159 void BaseView::saveConfig(KConfigGroup &configGroup)
160 {
161     doSaveConfig(configGroup);
162 }
163 
doRestoreConfig(const KConfigGroup &)164 void BaseView::doRestoreConfig(const KConfigGroup &)
165 {
166 }
167 
doSaveConfig(KConfigGroup &)168 void BaseView::doSaveConfig(KConfigGroup &)
169 {
170 }
171 
clearSelection()172 void BaseView::clearSelection()
173 {
174 }
175 
eventDurationHint(QDateTime & startDt,QDateTime & endDt,bool & allDay)176 bool BaseView::eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay)
177 {
178     Q_UNUSED(startDt)
179     Q_UNUSED(endDt)
180     Q_UNUSED(allDay)
181     return false;
182 }
183 
getHighlightMode(bool & highlightEvents,bool & highlightTodos,bool & highlightJournals)184 void BaseView::getHighlightMode(bool &highlightEvents, bool &highlightTodos, bool &highlightJournals)
185 {
186     highlightEvents = true;
187     highlightTodos = false;
188     highlightJournals = false;
189 }
190 
usesFullWindow()191 bool BaseView::usesFullWindow()
192 {
193     return false;
194 }
195 
supportsZoom()196 bool BaseView::supportsZoom()
197 {
198     return false;
199 }
200 
supportsDateRangeSelection()201 bool BaseView::supportsDateRangeSelection()
202 {
203     return true;
204 }
205 
calendarReset()206 void BaseView::calendarReset()
207 {
208 }
209 
actualDateRange(const QDateTime & start,const QDateTime & end,const QDate & preferredMonth) const210 QPair<QDateTime, QDateTime> BaseView::actualDateRange(const QDateTime &start, const QDateTime &end, const QDate &preferredMonth) const
211 {
212     Q_UNUSED(preferredMonth)
213     return qMakePair(start, end);
214 }
215 
setChanges(EventViews::EventView::Changes changes)216 void BaseView::setChanges(EventViews::EventView::Changes changes)
217 {
218     d->mChanges = changes;
219 }
220 
changes() const221 EventViews::EventView::Changes BaseView::changes() const
222 {
223     return d->mChanges;
224 }
225