Incidenceeditor

incidencedatetime.h
1/*
2 SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org>
3 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "incidenceeditor-ng.h"
11
12#include <KCalendarCore/Event>
13#include <KCalendarCore/Journal>
14#include <KCalendarCore/Todo>
15
16#include <QDate>
17
18namespace Ui
19{
20class EventOrTodoDesktop;
21}
22
23namespace IncidenceEditorNG
24{
25class IncidenceDateTime : public IncidenceEditor
26{
28public:
29 using IncidenceEditorNG::IncidenceEditor::load; // So we don't trigger -Woverloaded-virtual
30 using IncidenceEditorNG::IncidenceEditor::save; // So we don't trigger -Woverloaded-virtual
31 explicit IncidenceDateTime(Ui::EventOrTodoDesktop *ui);
32 ~IncidenceDateTime() override;
33
34 void load(const KCalendarCore::Incidence::Ptr &incidence) override;
35 void save(const KCalendarCore::Incidence::Ptr &incidence) override;
36 [[nodiscard]] bool isDirty() const override;
37
38 /**
39 * Sets the active date for the editing session. This defaults to the current
40 * date. It should be set <em>before</em> loading a non-empty (i.e. existing
41 * incidence).
42 */
43 void setActiveDate(const QDate &activeDate);
44
45 [[nodiscard]] QDate startDate() const; /// Returns the current start date.
46 [[nodiscard]] QTime startTime() const; /// Returns the current start time.
47 [[nodiscard]] QDate endDate() const; /// Returns the current end date.
48 [[nodiscard]] QTime endTime() const; /// Returns the current endtime.
49
50 /// Created from the values in the widgets
51 [[nodiscard]] QDateTime currentStartDateTime() const;
52 [[nodiscard]] QDateTime currentEndDateTime() const;
53
54 void setStartTime(const QTime &newTime);
55 void setStartDate(const QDate &newDate);
56
57 [[nodiscard]] bool startDateTimeEnabled() const;
58 [[nodiscard]] bool endDateTimeEnabled() const;
59
60 void focusInvalidField() override;
61
62 [[nodiscard]] bool isValid() const override;
63 void printDebugInfo() const override;
64
66 // used to indicate that the widgets were activated
67 void startDateFocus(QObject *obj);
68 void endDateFocus(QObject *obj);
69 void startTimeFocus(QObject *obj);
70 void endTimeFocus(QObject *obj);
71
72 // general
73 void startDateTimeToggled(bool enabled);
74 void startDateChanged(const QDate &newDate);
75 void startTimeChanged(const QTime &newTime);
76 void endDateTimeToggled(bool enabled);
77 void endDateChanged(const QDate &newDate);
78 void endTimeChanged(const QTime &newTime);
79
80private: /// General
81 void setTimeZonesVisibility(bool visible);
82 void toggleTimeZoneVisibility();
83 void updateStartTime(const QTime &newTime);
84 void updateStartDate(const QDate &newDate);
85 void updateStartSpec();
86 void updateEndSpec();
87 void updateStartToolTips();
88 void updateEndToolTips();
89
90 void enableStartEdit(bool enable);
91 void enableEndEdit(bool enable);
92 void enableTimeEdits();
93
94 bool isDirty(const KCalendarCore::Todo::Ptr &todo) const;
95 bool isDirty(const KCalendarCore::Event::Ptr &event) const;
96 bool isDirty(const KCalendarCore::Journal::Ptr &journal) const;
97
98protected:
99 bool eventFilter(QObject *obj, QEvent *event) override;
100
101private:
102 void load(const KCalendarCore::Event::Ptr &event, bool isTemplate = false, bool templateOverridesTimes = false);
103 void load(const KCalendarCore::Todo::Ptr &todo, bool isTemplate = false, bool templateOverridesTimes = false);
104 void load(const KCalendarCore::Journal::Ptr &journal, bool isTemplate = false, bool templateOverridesTimes = false);
105 void save(const KCalendarCore::Event::Ptr &event);
106 void save(const KCalendarCore::Todo::Ptr &todo);
107 void save(const KCalendarCore::Journal::Ptr &journal);
108 void setDateTimes(const QDateTime &start, const QDateTime &end);
109 void setTimes(const QDateTime &start, const QDateTime &end);
110 void setTimeZoneLabelEnabled(bool enable);
111 bool timeZonesAreLocal(const QDateTime &start, const QDateTime &end);
112
113private:
114 Ui::EventOrTodoDesktop *mUi = nullptr;
115
116 QDate mActiveDate;
117 /**
118 * These might differ from mLoadedIncidence->(dtStart|dtDue) as these take
119 * in account recurrence if needed. The values are calculated once on load().
120 * and don't change afterwards.
121 */
122 QDateTime mInitialStartDT;
123 QDateTime mInitialEndDT;
124
125 /**
126 * We need to store the current start date/time to be able to update the end
127 * time appropriate when the start time changes.
128 */
129 QDateTime mCurrentStartDateTime;
130
131 /// Remembers state when switching between takes whole day and timed event/to-do.
132 bool mTimezoneCombosWereVisibile;
133};
134}
virtual void load(const KCalendarCore::Incidence::Ptr &incidence)=0
Load the values of.
QSharedPointer< IncidenceT > incidence() const
Convenience method to get a pointer for a specific const Incidence Type.
virtual void save(const KCalendarCore::Incidence::Ptr &incidence)=0
Store the current values of the editor into.
Q_SCRIPTABLE Q_NOREPLY void start()
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
virtual bool event(QEvent *e)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.