KPlato::Calendar Class Reference

#include <kptcalendar.h>

List of all members.

Public Member Functions

 Calendar ()
 Calendar (QString name, Calendar *parent=0)
 Calendar (Calendar *calendar)
 ~Calendar ()
QString name () const
void setName (QString name)
Calendarparent () const
void setParent (Calendar *parent)
Projectproject () 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
CalendarDayfindDay (const QDate &date, bool skipUndefined=false) const
void addDay (CalendarDay *day)
void deleteDay (CalendarDay *day)
CalendarDaytakeDay (CalendarDay *day)
const QList< CalendarDay * > & days () const
int parentDayState (const QDate &date) const
IntMap weekdaysMap ()
void setWeekday (IntMap::iterator it, int state)
CalendarWeekdaysweekdays ()
CalendarDayweekday (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)
CalendarfindCalendar () const
CalendarfindCalendar (const QString &id) const
bool removeId ()
bool removeId (const QString &id)
void insertId (const QString &id)
void printDebug (QString indent="")

Protected Member Functions

const Calendarcopy (Calendar &calendar)
void init ()

Private Attributes

QString m_name
Calendarm_parent
Projectm_project
bool m_deleted
QString m_id
QString m_parentId
QList< CalendarDay * > m_days
CalendarWeekdaysm_weekdays


Detailed Description

Calendar defines the working and nonworking days and hours. A day can have the three states None (Undefined), NonWorking, or Working. A calendar can have a parent calendar that defines the days that are undefined in this calendar. If a day is still undefined, it defaults to Nonworking. A Working day has one or more work intervals to define the work hours.

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.


Constructor & Destructor Documentation

KPlato::Calendar::Calendar (  ) 

Definition at line 489 of file kptcalendar.cc.

References init().

KPlato::Calendar::Calendar ( QString  name,
Calendar parent = 0 
)

Definition at line 497 of file kptcalendar.cc.

References init().

KPlato::Calendar::Calendar ( Calendar calendar  ) 

Definition at line 514 of file kptcalendar.cc.

References copy().

KPlato::Calendar::~Calendar (  ) 

Definition at line 507 of file kptcalendar.cc.

References m_days, m_weekdays, and removeId().


Member Function Documentation

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]

Definition at line 240 of file kptcalendar.h.

References m_days.

Referenced by load().

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]

Definition at line 267 of file kptcalendar.h.

References m_parentId.

void KPlato::Calendar::setParentId ( QString  id  )  [inline]

Definition at line 268 of file kptcalendar.h.

References m_parentId.

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().

Duration KPlato::Calendar::effort ( const DateTime start,
const DateTime end 
) const

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.

bool KPlato::Calendar::hasInterval ( const DateTime start,
const DateTime end 
) const

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.

DateTime KPlato::Calendar::firstAvailableAfter ( const DateTime time,
const DateTime limit 
)

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().

DateTime KPlato::Calendar::firstAvailableBefore ( const DateTime time,
const DateTime limit 
)

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().

const Calendar & KPlato::Calendar::copy ( Calendar calendar  )  [protected]

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]

Definition at line 533 of file kptcalendar.cc.

References m_weekdays.

Referenced by Calendar().

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().


Member Data Documentation

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]

Definition at line 338 of file kptcalendar.h.

Referenced by load(), parentId(), and setParentId().

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().


The documentation for this class was generated from the following files:
Generated on Wed Nov 22 23:21:44 2006 for KPlato by  doxygen 1.5.1-p1