File indexing completed on 2025-01-05 04:54:32
0001 /* 0002 This file is part of KOrganizer. 0003 0004 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> 0005 SPDX-FileContributor: Sergio Martins <sergio.martins@kdab.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0008 */ 0009 0010 #include "monthview.h" 0011 #include "koeventpopupmenu.h" 0012 #include "prefs/koprefs.h" 0013 0014 #include <EventViews/MonthView> 0015 0016 #include <QVBoxLayout> 0017 0018 using namespace KOrg; 0019 0020 MonthView::MonthView(QWidget *parent) 0021 : KOEventView(parent) 0022 { 0023 auto layout = new QVBoxLayout(this); 0024 layout->setContentsMargins({}); 0025 mMonthView = new EventViews::MonthView(EventViews::MonthView::Visible, this); 0026 mMonthView->setPreferences(KOPrefs::instance()->eventViewsPreferences()); 0027 layout->addWidget(mMonthView); 0028 mPopup = eventPopup(); 0029 0030 connect(mMonthView, &EventViews::MonthView::showIncidencePopupSignal, mPopup, &KOEventPopupMenu::showIncidencePopup); 0031 0032 connect(mMonthView, &EventViews::MonthView::showNewEventPopupSignal, this, &MonthView::showNewEventPopup); 0033 0034 connect(mMonthView, &EventViews::EventView::datesSelected, this, &KOEventView::datesSelected); 0035 0036 connect(mMonthView, &EventViews::EventView::shiftedEvent, this, &KOEventView::shiftedEvent); 0037 0038 connect(mMonthView, &EventViews::EventView::incidenceSelected, this, &BaseView::incidenceSelected); 0039 0040 connect(mMonthView, &EventViews::EventView::showIncidenceSignal, this, &BaseView::showIncidenceSignal); 0041 0042 connect(mMonthView, &EventViews::EventView::editIncidenceSignal, this, &BaseView::editIncidenceSignal); 0043 0044 connect(mMonthView, &EventViews::EventView::deleteIncidenceSignal, this, &BaseView::deleteIncidenceSignal); 0045 0046 connect(mMonthView, &EventViews::EventView::cutIncidenceSignal, this, &BaseView::cutIncidenceSignal); 0047 0048 connect(mMonthView, &EventViews::EventView::copyIncidenceSignal, this, &BaseView::copyIncidenceSignal); 0049 0050 connect(mMonthView, &EventViews::EventView::pasteIncidenceSignal, this, &BaseView::pasteIncidenceSignal); 0051 0052 connect(mMonthView, &EventViews::EventView::toggleAlarmSignal, this, &BaseView::toggleAlarmSignal); 0053 0054 connect(mMonthView, &EventViews::EventView::toggleTodoCompletedSignal, this, &BaseView::toggleTodoCompletedSignal); 0055 0056 connect(mMonthView, &EventViews::EventView::copyIncidenceToResourceSignal, this, &BaseView::copyIncidenceToResourceSignal); 0057 0058 connect(mMonthView, &EventViews::EventView::moveIncidenceToResourceSignal, this, &BaseView::moveIncidenceToResourceSignal); 0059 0060 connect(mMonthView, &EventViews::EventView::dissociateOccurrencesSignal, this, &BaseView::dissociateOccurrencesSignal); 0061 0062 connect(mMonthView, qOverload<>(&EventViews::MonthView::newEventSignal), this, qOverload<>(&KOrg::MonthView::newEventSignal)); 0063 0064 connect(mMonthView, qOverload<const QDate &>(&EventViews::MonthView::newEventSignal), this, qOverload<const QDate &>(&KOrg::MonthView::newEventSignal)); 0065 0066 connect(mMonthView, 0067 qOverload<const QDateTime &>(&EventViews::MonthView::newEventSignal), 0068 this, 0069 qOverload<const QDateTime &>(&KOrg::MonthView::newEventSignal)); 0070 0071 connect(mMonthView, 0072 qOverload<const QDateTime &, const QDateTime &>(&EventViews::MonthView::newEventSignal), 0073 this, 0074 qOverload<const QDateTime &, const QDateTime &>(&KOrg::MonthView::newEventSignal)); 0075 0076 connect(mMonthView, &EventViews::EventView::newTodoSignal, this, &BaseView::newTodoSignal); 0077 0078 connect(mMonthView, &EventViews::EventView::newSubTodoSignal, this, &BaseView::newSubTodoSignal); 0079 0080 connect(mMonthView, &EventViews::EventView::newJournalSignal, this, &BaseView::newJournalSignal); 0081 0082 connect(mMonthView, &EventViews::MonthView::fullViewChanged, this, &MonthView::fullViewChanged); 0083 } 0084 0085 MonthView::~MonthView() = default; 0086 0087 CalendarSupport::CalPrinterBase::PrintType MonthView::printType() const 0088 { 0089 return CalendarSupport::CalPrinterBase::Month; 0090 } 0091 0092 int MonthView::currentDateCount() const 0093 { 0094 return mMonthView->currentDateCount(); 0095 } 0096 0097 int MonthView::currentMonth() const 0098 { 0099 return mMonthView->currentMonth(); 0100 } 0101 0102 KCalendarCore::DateList MonthView::selectedIncidenceDates() 0103 { 0104 return mMonthView->selectedIncidenceDates(); 0105 } 0106 0107 QDateTime MonthView::selectionStart() 0108 { 0109 return mMonthView->selectionStart(); 0110 } 0111 0112 QDateTime MonthView::selectionEnd() 0113 { 0114 return mMonthView->selectionEnd(); 0115 } 0116 0117 bool MonthView::eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay) 0118 { 0119 return mMonthView->eventDurationHint(startDt, endDt, allDay); 0120 } 0121 0122 QDate MonthView::averageDate() const 0123 { 0124 return mMonthView->averageDate(); 0125 } 0126 0127 bool MonthView::usesFullWindow() 0128 { 0129 return mMonthView->usesFullWindow(); 0130 } 0131 0132 bool MonthView::supportsDateRangeSelection() 0133 { 0134 return mMonthView->supportsDateRangeSelection(); 0135 } 0136 0137 void MonthView::updateView() 0138 { 0139 mMonthView->updateView(); 0140 } 0141 0142 void MonthView::showIncidences(const Akonadi::Item::List &incidenceList, const QDate &date) 0143 { 0144 mMonthView->showIncidences(incidenceList, date); 0145 } 0146 0147 void MonthView::changeIncidenceDisplay(const Akonadi::Item &item, Akonadi::IncidenceChanger::ChangeType changeType) 0148 { 0149 mMonthView->changeIncidenceDisplay(item, changeType); 0150 } 0151 0152 void MonthView::updateConfig() 0153 { 0154 mMonthView->updateConfig(); 0155 } 0156 0157 int MonthView::maxDatesHint() const 0158 { 0159 return 6 * 7; 0160 } 0161 0162 Akonadi::Item::List MonthView::selectedIncidences() 0163 { 0164 return mMonthView->selectedIncidences(); 0165 } 0166 0167 void MonthView::setTypeAheadReceiver(QObject *o) 0168 { 0169 mMonthView->setTypeAheadReceiver(o); 0170 } 0171 0172 void MonthView::setDateRange(const QDateTime &start, const QDateTime &end, const QDate &preferredMonth) 0173 { 0174 mMonthView->setDateRange(start, end, preferredMonth); 0175 } 0176 0177 void MonthView::setModel(QAbstractItemModel *model) 0178 { 0179 KOEventView::setModel(model); 0180 mMonthView->setModel(model); 0181 } 0182 0183 void MonthView::setIncidenceChanger(Akonadi::IncidenceChanger *changer) 0184 { 0185 mMonthView->setIncidenceChanger(changer); 0186 } 0187 0188 void MonthView::showDates(const QDate &start, const QDate &end, const QDate &preferredMonth) 0189 { 0190 Q_UNUSED(start) 0191 Q_UNUSED(end) 0192 Q_UNUSED(preferredMonth) 0193 } 0194 0195 void MonthView::calendarAdded(const Akonadi::CollectionCalendar::Ptr &calendar) 0196 { 0197 mMonthView->addCalendar(calendar); 0198 } 0199 0200 void MonthView::calendarRemoved(const Akonadi::CollectionCalendar::Ptr &calendar) 0201 { 0202 mMonthView->removeCalendar(calendar); 0203 } 0204 #include "moc_monthview.cpp"