#include <kptcalendar.h>
Public Member Functions | |
Calendar () | |
Calendar (QString name, Calendar *parent=0) | |
Calendar (Calendar *calendar) | |
~Calendar () | |
QString | name () const |
void | setName (QString name) |
Calendar * | parent () const |
void | setParent (Calendar *parent) |
Project * | project () const |
void | setProject (Project *project) |
bool | isDeleted () const |
void | setDeleted (bool yes) |
QString | id () const |
bool | setId (QString id) |
void | generateId () |
bool | load (QDomElement &element) |
void | save (QDomElement &element) const |
CalendarDay * | findDay (const QDate &date, bool skipUndefined=false) const |
void | addDay (CalendarDay *day) |
void | deleteDay (CalendarDay *day) |
CalendarDay * | takeDay (CalendarDay *day) |
const QList< CalendarDay * > & | days () const |
int | parentDayState (const QDate &date) const |
IntMap | weekdaysMap () |
void | setWeekday (IntMap::iterator it, int state) |
CalendarWeekdays * | weekdays () |
CalendarDay * | weekday (int day) const |
QString | parentId () const |
void | setParentId (QString id) |
bool | hasParent (Calendar *cal) |
Duration | effort (const QDate &date, const QTime &start, const QTime &end) const |
Duration | effort (const DateTime &start, const DateTime &end) const |
DateTimeInterval | firstInterval (const DateTime &start, const DateTime &end) const |
TimeInterval | firstInterval (const QDate &date, const QTime &start, const QTime &end) const |
bool | hasInterval (const DateTime &start, const DateTime &end) const |
bool | hasInterval (const QDate &date, const QTime &start, const QTime &end) const |
DateTime | firstAvailableAfter (const DateTime &time, const DateTime &limit) |
DateTime | firstAvailableBefore (const DateTime &time, const DateTime &limit) |
Calendar * | findCalendar () const |
Calendar * | findCalendar (const QString &id) const |
bool | removeId () |
bool | removeId (const QString &id) |
void | insertId (const QString &id) |
void | printDebug (QString indent="") |
Protected Member Functions | |
const Calendar & | copy (Calendar &calendar) |
void | init () |
Private Attributes | |
QString | m_name |
Calendar * | m_parent |
Project * | m_project |
bool | m_deleted |
QString | m_id |
QString | m_parentId |
QList< CalendarDay * > | m_days |
CalendarWeekdays * | m_weekdays |
The definition can consist of two parts: Weekdays and Day. Day has highest priority.
A typical calendar hierarchy could include calendars on three levels: 1. Definition of normal weekdays and national holidays/vacation days. 2. Definition of the company's special workdays/-time and vacation days. 3. Definitions for groups of resources/individual resources.
Definition at line 207 of file kptcalendar.h.
KPlato::Calendar::Calendar | ( | ) |
KPlato::Calendar::Calendar | ( | QString | name, | |
Calendar * | parent = 0 | |||
) |
KPlato::Calendar::Calendar | ( | Calendar * | calendar | ) |
KPlato::Calendar::~Calendar | ( | ) |
QString KPlato::Calendar::name | ( | ) | const [inline] |
Definition at line 215 of file kptcalendar.h.
References m_name.
Referenced by KPlato::CalendarListViewItem::buildCommand(), KPlato::CalendarListViewItem::CalendarListViewItem(), KPlato::CalendarModifyNameCmd::CalendarModifyNameCmd(), KPlato::CalendarModifyWeekdayCmd::CalendarModifyWeekdayCmd(), copy(), KPlato::Project::insertCalendarId(), printDebug(), KPlato::ResourceDialog::ResourceDialog(), and setId().
void KPlato::Calendar::setName | ( | QString | name | ) | [inline] |
Definition at line 216 of file kptcalendar.h.
References m_name.
Referenced by KPlato::CalendarModifyNameCmd::execute(), KPlato::StandardWorktime::init(), KPlato::CalendarListDialogImpl::slotItemChanged(), and KPlato::CalendarModifyNameCmd::unexecute().
Calendar* KPlato::Calendar::parent | ( | ) | const [inline] |
Definition at line 218 of file kptcalendar.h.
References m_parent.
Referenced by KPlato::CalendarListViewItem::buildCommand(), KPlato::CalendarModifyParentCmd::CalendarModifyParentCmd(), copy(), and setParent().
void KPlato::Calendar::setParent | ( | Calendar * | parent | ) | [inline] |
Definition at line 219 of file kptcalendar.h.
References m_parent, and parent().
Referenced by KPlato::CalendarListViewItem::buildCommand(), KPlato::CalendarModifyParentCmd::execute(), CalendarTester::testCalendarWithParent(), and KPlato::CalendarModifyParentCmd::unexecute().
Project* KPlato::Calendar::project | ( | ) | const [inline] |
Definition at line 221 of file kptcalendar.h.
References m_project.
Referenced by effort(), firstInterval(), hasInterval(), and setProject().
void KPlato::Calendar::setProject | ( | Project * | project | ) |
Definition at line 537 of file kptcalendar.cc.
References generateId(), m_project, and project().
Referenced by KPlato::CalendarListDialogImpl::slotAddClicked().
bool KPlato::Calendar::isDeleted | ( | ) | const [inline] |
Definition at line 224 of file kptcalendar.h.
References m_deleted.
Referenced by KPlato::Resource::calendar(), copy(), effort(), firstInterval(), hasInterval(), and save().
void KPlato::Calendar::setDeleted | ( | bool | yes | ) |
Definition at line 542 of file kptcalendar.cc.
References m_deleted, m_id, removeId(), and setId().
Referenced by KPlato::CalendarAddCmd::CalendarAddCmd(), KPlato::CalendarDeleteCmd::execute(), KPlato::CalendarAddCmd::execute(), KPlato::CalendarDeleteCmd::unexecute(), and KPlato::CalendarAddCmd::unexecute().
QString KPlato::Calendar::id | ( | ) | const [inline] |
Definition at line 227 of file kptcalendar.h.
References m_id.
Referenced by copy(), KPlato::Resource::save(), and save().
bool KPlato::Calendar::setId | ( | QString | id | ) |
Definition at line 550 of file kptcalendar.cc.
References findCalendar(), insertId(), m_id, name(), and removeId().
Referenced by load(), and setDeleted().
void KPlato::Calendar::generateId | ( | ) |
Definition at line 576 of file kptcalendar.cc.
References findCalendar(), insertId(), m_id, and removeId().
Referenced by setProject().
bool KPlato::Calendar::load | ( | QDomElement & | element | ) |
Definition at line 590 of file kptcalendar.cc.
References addDay(), deleteDay(), findDay(), KPlato::CalendarWeekdays::load(), m_name, m_parentId, m_weekdays, and setId().
Referenced by KPlato::StandardWorktime::load().
void KPlato::Calendar::save | ( | QDomElement & | element | ) | const |
Definition at line 632 of file kptcalendar.cc.
References id(), isDeleted(), m_days, m_deleted, m_id, m_name, m_parent, m_weekdays, KPlato::CalendarDay::save(), and KPlato::CalendarWeekdays::save().
Referenced by KPlato::StandardWorktime::save().
CalendarDay * KPlato::Calendar::findDay | ( | const QDate & | date, | |
bool | skipUndefined = false | |||
) | const |
Find the definition for the day date. If skipUndefined=true the day is NOT returned if it has state None (Undefined).
Definition at line 652 of file kptcalendar.cc.
References KPlato::CalendarDay::date(), m_days, KPlato::Map::None, and KPlato::CalendarDay::state().
Referenced by KPlato::CalendarListViewItem::buildCommand(), KPlato::CalendarModifyDayCmd::CalendarModifyDayCmd(), KPlato::CalendarRemoveDayCmd::CalendarRemoveDayCmd(), effort(), firstInterval(), hasInterval(), load(), KPlato::CalendarEdit::slotApplyClicked(), KPlato::CalendarEdit::slotDateSelected(), CalendarTester::testCalendarWithParent(), and CalendarTester::testSingleDay().
void KPlato::Calendar::addDay | ( | CalendarDay * | day | ) | [inline] |
Definition at line 239 of file kptcalendar.h.
References m_days.
Referenced by KPlato::CalendarModifyDayCmd::execute(), KPlato::CalendarAddDayCmd::execute(), load(), KPlato::CalendarEdit::slotApplyClicked(), CalendarTester::testCalendarWithParent(), CalendarTester::testSingleDay(), KPlato::CalendarModifyDayCmd::unexecute(), and KPlato::CalendarRemoveDayCmd::unexecute().
void KPlato::Calendar::deleteDay | ( | CalendarDay * | day | ) | [inline] |
CalendarDay* KPlato::Calendar::takeDay | ( | CalendarDay * | day | ) | [inline] |
Definition at line 248 of file kptcalendar.h.
References m_days.
Referenced by KPlato::CalendarModifyDayCmd::execute(), KPlato::CalendarRemoveDayCmd::execute(), KPlato::CalendarModifyDayCmd::unexecute(), and KPlato::CalendarAddDayCmd::unexecute().
const QList<CalendarDay*>& KPlato::Calendar::days | ( | ) | const [inline] |
Definition at line 254 of file kptcalendar.h.
References m_days.
Referenced by KPlato::CalendarListViewItem::buildCommand(), copy(), and KPlato::CalendarPanel::setCalendar().
int KPlato::Calendar::parentDayState | ( | const QDate & | date | ) | const |
Returns the state of definition for parents day date in it. Also checks the parents recursively.
IntMap KPlato::Calendar::weekdaysMap | ( | ) | [inline] |
Definition at line 262 of file kptcalendar.h.
References m_weekdays, and KPlato::CalendarWeekdays::map().
Referenced by KPlato::CalendarPanel::setCalendar().
void KPlato::Calendar::setWeekday | ( | IntMap::iterator | it, | |
int | state | |||
) | [inline] |
Definition at line 263 of file kptcalendar.h.
References m_weekdays, and KPlato::CalendarWeekdays::setWeekday().
CalendarWeekdays* KPlato::Calendar::weekdays | ( | ) | [inline] |
Definition at line 264 of file kptcalendar.h.
References m_weekdays.
Referenced by KPlato::CalendarListViewItem::buildCommand(), copy(), KPlato::CalendarModifyWeekdayCmd::execute(), and KPlato::CalendarModifyWeekdayCmd::unexecute().
CalendarDay* KPlato::Calendar::weekday | ( | int | day | ) | const [inline] |
Definition at line 265 of file kptcalendar.h.
References m_weekdays, and KPlato::CalendarWeekdays::weekday().
Referenced by KPlato::StandardWorktime::init(), KPlato::CalendarEdit::slotApplyClicked(), KPlato::CalendarEdit::slotWeekdaySelected(), KPlato::StandardWorktimeDialogImpl::StandardWorktimeDialogImpl(), and CalendarTester::testWeekdays().
QString KPlato::Calendar::parentId | ( | ) | const [inline] |
void KPlato::Calendar::setParentId | ( | QString | id | ) | [inline] |
bool KPlato::Calendar::hasParent | ( | Calendar * | cal | ) |
Definition at line 666 of file kptcalendar.cc.
References hasParent(), and m_parent.
Referenced by hasParent().
Duration KPlato::Calendar::effort | ( | const QDate & | date, | |
const QTime & | start, | |||
const QTime & | end | |||
) | const |
Returns the amount of 'worktime' that can be done on the date date between the times start and end.
Definition at line 675 of file kptcalendar.cc.
References KPlato::Project::defaultCalendar(), effort(), KPlato::CalendarWeekdays::effort(), KPlato::CalendarDay::effort(), findDay(), isDeleted(), m_parent, m_weekdays, KPlato::Map::NonWorking, project(), KPlato::CalendarWeekdays::state(), KPlato::CalendarDay::state(), KPlato::Map::Working, and KPlato::Duration::zeroDuration.
Referenced by KPlato::Resource::effort(), effort(), KPlato::ResourceAppointmentsView::slotUpdate(), CalendarTester::testCalendarWithParent(), and CalendarTester::testSingleDay().
Returns the amount of 'worktime' that can be done in the interval from start to end
Definition at line 714 of file kptcalendar.cc.
References effort().
DateTimeInterval KPlato::Calendar::firstInterval | ( | const DateTime & | start, | |
const DateTime & | end | |||
) | const |
Returns the first 'work interval' for the interval starting at start and ending at end. If no 'work interval' exists, returns an interval with invalid DateTime. You can also use hasInterval() to check if a 'work interval' exists.
Definition at line 759 of file kptcalendar.cc.
Referenced by firstAvailableAfter(), firstAvailableBefore(), firstInterval(), and KPlato::Resource::makeAppointment().
TimeInterval KPlato::Calendar::firstInterval | ( | const QDate & | date, | |
const QTime & | start, | |||
const QTime & | end | |||
) | const |
Returns the first 'work interval' on date for the interval starting at start and ending at end. If no 'work interval' exists, returns an interval with first==second. You can also use hasInterval() to check if a 'work interval' exists.
Definition at line 740 of file kptcalendar.cc.
References KPlato::Project::defaultCalendar(), findDay(), firstInterval(), KPlato::CalendarWeekdays::interval(), KPlato::CalendarDay::interval(), isDeleted(), m_parent, m_weekdays, KPlato::Map::NonWorking, project(), KPlato::CalendarWeekdays::state(), and KPlato::Map::Working.
Returns true if at least a part of a 'work interval' exists for the interval starting at start and ending at end.
Definition at line 812 of file kptcalendar.cc.
Referenced by firstAvailableAfter(), hasInterval(), KPlato::Resource::makeAppointment(), CalendarTester::testCalendarWithParent(), and CalendarTester::testSingleDay().
bool KPlato::Calendar::hasInterval | ( | const QDate & | date, | |
const QTime & | start, | |||
const QTime & | end | |||
) | const |
Returns true if at least a part of a 'work interval' exists for the interval on date, starting at start and ending at end.
Definition at line 793 of file kptcalendar.cc.
References KPlato::Project::defaultCalendar(), findDay(), hasInterval(), KPlato::CalendarWeekdays::hasInterval(), KPlato::CalendarDay::hasInterval(), isDeleted(), m_parent, m_weekdays, KPlato::Map::NonWorking, project(), KPlato::CalendarWeekdays::state(), and KPlato::Map::Working.
Find the first available time after time before limit. Return invalid datetime if not available.
Definition at line 838 of file kptcalendar.cc.
References firstInterval(), and hasInterval().
Referenced by KPlato::Resource::availableAfter(), CalendarTester::testCalendarWithParent(), CalendarTester::testSingleDay(), and CalendarTester::testWeekdays().
Find the first available time backwards from time. Search until limit. Return invalid datetime if not available.
Definition at line 852 of file kptcalendar.cc.
References firstInterval().
Referenced by KPlato::Resource::availableBefore(), CalendarTester::testCalendarWithParent(), CalendarTester::testSingleDay(), and CalendarTester::testWeekdays().
Calendar* KPlato::Calendar::findCalendar | ( | ) | const [inline] |
Definition at line 322 of file kptcalendar.h.
References m_id.
Referenced by generateId(), and setId().
Calendar * KPlato::Calendar::findCalendar | ( | const QString & | id | ) | const |
Definition at line 894 of file kptcalendar.cc.
References KPlato::Project::findCalendar(), and m_project.
bool KPlato::Calendar::removeId | ( | ) | [inline] |
Definition at line 324 of file kptcalendar.h.
References m_id.
Referenced by generateId(), setDeleted(), setId(), and ~Calendar().
bool KPlato::Calendar::removeId | ( | const QString & | id | ) |
Definition at line 898 of file kptcalendar.cc.
References m_project, and KPlato::Project::removeCalendarId().
void KPlato::Calendar::insertId | ( | const QString & | id | ) |
Definition at line 902 of file kptcalendar.cc.
References KPlato::Project::insertCalendarId(), and m_project.
Referenced by generateId(), and setId().
Definition at line 520 of file kptcalendar.cc.
References days(), id(), isDeleted(), m_days, m_deleted, m_id, m_name, m_parent, m_weekdays, name(), parent(), and weekdays().
Referenced by Calendar().
void KPlato::Calendar::init | ( | ) | [protected] |
void KPlato::Calendar::printDebug | ( | QString | indent = "" |
) |
Definition at line 998 of file kptcalendar.cc.
References m_days, m_deleted, m_id, m_name, m_parent, m_weekdays, name(), KPlato::CalendarDay::printDebug(), and KPlato::CalendarWeekdays::printDebug().
QString KPlato::Calendar::m_name [private] |
Definition at line 333 of file kptcalendar.h.
Referenced by copy(), load(), name(), printDebug(), save(), and setName().
Calendar* KPlato::Calendar::m_parent [private] |
Definition at line 334 of file kptcalendar.h.
Referenced by copy(), effort(), firstInterval(), hasInterval(), hasParent(), parent(), printDebug(), save(), and setParent().
Project* KPlato::Calendar::m_project [private] |
Definition at line 335 of file kptcalendar.h.
Referenced by findCalendar(), insertId(), project(), removeId(), and setProject().
bool KPlato::Calendar::m_deleted [private] |
Definition at line 336 of file kptcalendar.h.
Referenced by copy(), isDeleted(), printDebug(), save(), and setDeleted().
QString KPlato::Calendar::m_id [private] |
Definition at line 337 of file kptcalendar.h.
Referenced by copy(), findCalendar(), generateId(), id(), printDebug(), removeId(), save(), setDeleted(), and setId().
QString KPlato::Calendar::m_parentId [private] |
QList<CalendarDay*> KPlato::Calendar::m_days [private] |
Definition at line 340 of file kptcalendar.h.
Referenced by addDay(), copy(), days(), deleteDay(), findDay(), printDebug(), save(), takeDay(), and ~Calendar().
CalendarWeekdays* KPlato::Calendar::m_weekdays [private] |
Definition at line 341 of file kptcalendar.h.
Referenced by copy(), effort(), firstInterval(), hasInterval(), init(), load(), printDebug(), save(), setWeekday(), weekday(), weekdays(), weekdaysMap(), and ~Calendar().