2 Copyright (c) 2010 Bertjan Broeksema <broeksema@kde.org>
3 Copyright (C) 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #ifndef INCIDENCEEDITOR_INCIDENCEDATETIME_H
22 #define INCIDENCEEDITOR_INCIDENCEDATETIME_H
24 #include "incidenceeditor-ng.h"
26 #include <KCalCore/Event>
27 #include <KCalCore/Journal>
28 #include <KCalCore/Todo>
31 class EventOrTodoDesktop
;
38 namespace IncidenceEditorNG
{
40 class INCIDENCEEDITORS_NG_EXPORT IncidenceDateTime
: public IncidenceEditor
44 IncidenceDateTime( Ui::EventOrTodoDesktop
*ui
);
47 virtual void load( const KCalCore::Incidence::Ptr
&incidence
);
48 virtual void save( const KCalCore::Incidence::Ptr
&incidence
);
49 virtual bool isDirty() const;
52 * Sets the active date for the editing session. This defaults to the current
53 * date. It should be set <em>before</em> loading a non-empty (i.e. existing
56 void setActiveDate( const QDate
&activeDate
);
58 QDate
startDate() const; /// Returns the current start date.
59 QTime
startTime() const; /// Returns the current start time.
60 QDate
endDate() const; /// Returns the current end date.
61 QTime
endTime() const; /// Returns the current endtime.
63 /// Created from the values in the widgets
64 KDateTime
currentStartDateTime() const;
65 KDateTime
currentEndDateTime() const;
67 void setStartTime( const QTime
&newTime
);
68 void setStartDate( const QDate
&newDate
);
70 bool startDateTimeEnabled() const;
71 bool endDateTimeEnabled() const;
77 void startDateTimeToggled( bool enabled
);
78 void startDateChanged( const QDate
&newDate
);
79 void startTimeChanged( const QTime
&newTime
);
80 void endDateTimeToggled( bool enabled
);
81 void endDateChanged( const QDate
&newDate
);
82 void endTimeChanged( const QTime
&newTime
);
84 private slots
: /// General
85 void setTimeZonesVisibility( bool visible
);
86 void toggleTimeZoneVisibility();
87 void updateStartTime( const QTime
&newTime
);
88 void updateStartDate( const QDate
&newDate
);
89 void updateStartSpec();
91 private slots
: /// Todo specific
92 void enableStartEdit( bool enable
);
93 void enableEndEdit( bool enable
);
94 void enableTimeEdits();
95 bool isDirty( const KCalCore::Todo::Ptr
&todo
) const;
97 private slots
: /// Event specific
98 bool isDirty( const KCalCore::Event::Ptr
&event
) const;
99 bool isDirty( const KCalCore::Journal::Ptr
&journal
) const;
102 void load( const KCalCore::Event::Ptr
&event
);
103 void load( const KCalCore::Todo::Ptr
&todo
);
104 void load( const KCalCore::Journal::Ptr
&journal
);
105 void save( const KCalCore::Event::Ptr
&event
);
106 void save( const KCalCore::Todo::Ptr
&todo
);
107 void save( const KCalCore::Journal::Ptr
&journal
);
108 void setDateTimes( const KDateTime
&start
, const KDateTime
&end
);
109 void setTimes( const KDateTime
&start
, const KDateTime
&end
);
112 KCalCore::ICalTimeZones
*mTimeZones
;
113 Ui::EventOrTodoDesktop
*mUi
;
117 * These might differ from mLoadedIncidence->(dtStart|dtDue) as these take
118 * in account recurrence if needed. The values are calculated once on load().
119 * and don't change afterwards.
121 KDateTime mInitialStartDT
;
122 KDateTime mInitialEndDT
;
125 * We need to store the current start date/time to be able to update the end
126 * time appropriate when the start time changes.
128 KDateTime mCurrentStartDateTime
;
130 /// Remembers state when switching between takes whole day and timed event/to-do.
131 bool mTimezoneCombosWhereVisibile
;