• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kdgantt1

KDGanttViewItem Class Reference

#include <KDGanttViewItem.h>

Inheritance diagram for KDGanttViewItem:

Inheritance graph
[legend]

List of all members.


Detailed Description

This class represents an item in a Gantt chart.

This class is an abstract base class, it cannot be instantiated directly. Instead, you should create items of one of the subclasses. This class provides methods common to all Gantt items.

The initialization of the shapes/colors of the item works as follows:

Shapes: When a new item is created, the shapes are set to the default values for items of the type of this item, defined in the KDGanttView class with void setShapes( KDGanttViewItem::Type type, KDGanttViewItem::Shape start, KDGanttViewItem::Shape middle, KDGanttViewItem::Shape end ); If there is no default value defined for this type, the shapes are set as follows: For TaskViewItems all three shapes are set to Square. For SummaryViewItems all three shapes are set to TriangleDown. For EventViewItems all three shapes are set to Diamond.

Colors: When a new item is created, the colors are set to the default values for items of the type of this item, defined in the KDGanttView class with void setColors( KDGanttViewItem::Type type, const QColor& start, const QColor& middle, const QColor& end ); If there is no default value defined for this type, the colors of the shapes are set to the default color for items of this type, defined in the KDGanttView class with: void setDefaultColor( KDGanttViewItem::Type type, const QColor& ); The initial default color in the KDGanttView class is set to blue for KDGanttViewItem::Event, green for KDGanttViewItem::Task, cyan for KDGanttViewItem::Summary.

Highlight Colors: When a new item is created, the highlight colors are set to the default values for items of the type of this item, defined in the KDGanttView class with: void setHighlightColors( KDGanttViewItem::Type type, const QColor& start, const QColor& middle, const QColor& end ); If there is no default value defined for this type, the highlight colors of the shapes are set to the default color for items of this type, defined in the KDGanttView class with: void setDefaultHighlightColor( KDGanttViewItem::Type type, const QColor& ); The initial default highlight color in the KDGanttView class is set to red for all types.

Start/End time: When a new item is created, the start time and the end time is set automatically. The time, which is currently displayed in the middle of the Gantt View, is set as start/end time. At startup of a newly created Gantt view, this is the current time.

The Priority: The priority is set with setPriority(). The priority determines which items are painted over which other items. The item with the highest priority is painted on top of all others. The priority for an item can be between 1 and 199. A priority less than 100 means that the item is painted below the grid in the Gantt chart. For Task items, the default priority is 50, for all other items it is 150. This feature only makes sense for an item which is a child of another item, for which displaySubitemsAsGroup() property is set to true.

The Display Mode: The display mode is set with setDisplaySubitemsAsGroup(). In the normal view mode (set with setDisplaySubitemsAsGroup( false ); ), an item is displayed in the same manner, when its child items are shown or not. In the other mode (set with setDisplaySubitemsAsGroup( true ); ), called "calendar mode", the item is displayed as follows: If the item has no children, it is displayed as usual. If the item is opened (i.e., its children are displayed), the start/end time of this item is computed automatically according to the earliest start time/latest end time of its children. The item and its children are displayed as usual. If the item is closed (i.e., its children are hidden in the left list view), the item itself is hidden, and its children are displayed on the timeline of this item instead. To control the painting of overlapping children, call setPriority() for the children.

Blocking of user interaction to open item: If you want to block users to open items used as parents of calendar items, call KDGanttView::setCalendarMode( true );

Example 1, Color: If you create an instance of a KDGanttView class and add a SummaryViewItem without setting any color/shape values, you get an item with three shapes of the form TriangleDown in the color magenta. If the item is highlighted, the color will change to the highlight color red.

Example 2, Calender View: To use a Gantt view as a calendar view, call KDGanttView::setCalendarMode( true ); KDGanttView::setDisplaySubitemsAsGroup( true ); Insert root items in the Gantt view. Insert items as children of these root item in the Gantt view. You may use any item type as parent and child; there are no limitations. It is, however, recommended to use KDGanttViewTaskItems Actually, you may add child items to the children themselves. Such a child behaves then like a parent. Now set the start/end time of the children to specify a time interval for these items.

Definition at line 57 of file KDGanttViewItem.h.


Public Types

enum  Connector {
  NoConnector = 0, Start, Middle, End,
  Move, ActualEnd, Lead, TaskLinkStart,
  TaskLinkEnd
}
enum  Shape {
  TriangleDown, TriangleUp, Diamond, Square,
  Circle
}
enum  Type { Event = 0, Task, Summary, UnknownType }

Public Member Functions

void colors (QColor &start, QColor &middle, QColor &end) const
void createNode (QDomDocument &doc, QDomElement &parentElement)
QColor defaultColor () const
QColor defaultHighlightColor () const
bool displaySubitemsAsGroup () const
bool editable () const
bool enabled () const
QDateTime endTime () const
KDGanttViewItem * firstChild () const
QFont font () const
unsigned int getAllSubChildTimeForTimespan (const QDateTime &start, const QDateTime &end)
KDGanttViewItem * getChildByName (const QString &name)
KDGanttViewItem * getChildByUid (const QString &name)
QPtrList< KDGanttViewItem > getChildListForTimespan (const QDateTime &start, const QDateTime &end)
unsigned int getChildTimeForTimespan (const QDateTime &start, const QDateTime &end)
virtual Connector getConnector (QPoint p)
virtual unsigned int getTimeForTimespan (const QDateTime &start, const QDateTime &end)
bool highlight () const
void highlightColors (QColor &start, QColor &middle, QColor &end) const
KDGanttViewItem * itemAbove ()
KDGanttViewItem * itemBelow (bool includeDisabled=true)
bool itemVisible () const
QString listViewText (int column=0) const
virtual bool moveConnector (Connector, QPoint p)
QDateTime myChildEndTime ()
QDateTime myChildStartTime ()
QString name () const
KDGanttViewItem * nextSibling () const
KDGanttViewItem * parent () const
const QPixmap * pixmap (int column=0) const
int priority ()
void setColors (const QColor &start, const QColor &middle, const QColor &end)
void setDefaultColor (const QColor &)
void setDefaultHighlightColor (const QColor &)
void setDisplaySubitemsAsGroup (bool show)
void setEditable (bool editable)
void setEnabled (bool on)
virtual void setEndTime (const QDateTime &end)
void setFloatEndTime (const QDateTime &end)
void setFloatStartTime (const QDateTime &start)
void setFont (const QFont &font)
void setHighlight (bool)
void setHighlightColors (const QColor &start, const QColor &middle, const QColor &end)
void setItemVisible (bool on)
void setListViewText (int column, const QString &text)
void setListViewText (const QString &text, int column=0)
virtual void setOpen (bool o)
void setPixmap (const QPixmap &pixmap)
void setPixmap (int column, const QPixmap &pixmap)
void setPriority (int prio)
void setProgress (int percent)
void setShapes (Shape start, Shape middle, Shape end)
void setShowNoInformation (bool show)
void setShowNoInformationBeforeAndAfter (bool show)
virtual void setStartTime (const QDateTime &start)
void setText (const QString &text)
void setTextColor (const QColor &color)
void setTooltipText (const QString &text)
virtual void setUid (const QString &text)
void setWhatsThisText (const QString &text)
void shapes (Shape &start, Shape &middle, Shape &end) const
bool showNoInformation ()
bool showNoInformationBeforeAndAfter ()
QDateTime startTime () const
bool subitemIsCalendar () const
QString text () const
QColor textColor () const
QString tooltipText () const
Type type () const
virtual QString typeString () const
virtual QString uid () const
void updateItemsOnCanvas (bool forceUpdate=false)
QString whatsThisText () const
virtual ~KDGanttViewItem ()

Static Public Member Functions

static KDGanttViewItem * createFromDomElement (KDGanttViewItem *parent, KDGanttViewItem *previous, QDomElement &element)
static KDGanttViewItem * createFromDomElement (KDGanttViewItem *parent, QDomElement &element)
static KDGanttViewItem * createFromDomElement (KDGanttView *view, KDGanttViewItem *previous, QDomElement &element)
static KDGanttViewItem * createFromDomElement (KDGanttView *view, QDomElement &element)
static KDGanttViewItem * find (const QString &name)

Protected Member Functions

void checkCoord (int *)
void generateAndInsertName (const QString &name)
int getCoordY ()
bool isMoveable () const
bool isResizeable () const
 KDGanttViewItem (Type type, KDGanttViewItem *parent, KDGanttViewItem *after, const QString &lvtext=QString(), const QString &name=QString())
 KDGanttViewItem (Type type, KDGanttView *view, KDGanttViewItem *after, const QString &lvtext=QString(), const QString &name=QString())
 KDGanttViewItem (Type type, KDGanttViewItem *parent, const QString &lvtext=QString(), const QString &name=QString())
 KDGanttViewItem (Type type, KDGanttView *view, const QString &lvtext=QString(), const QString &name=QString())
void moveTextCanvas (int x, int y)
void setMoveable (bool m)
void setResizeable (bool r)
QCanvasText * textcanvas ()
void updateCanvasItems ()
virtual void userReadFromElement (QDomElement &element)
virtual void userWriteToElement (QDomDocument &doc, QDomElement &parentElement)

Protected Attributes

KDCanvasLine * actualEnd
bool blockUpdating
KDCanvasLine * endLine
KDCanvasLine * endLineBack
KDCanvasPolygonItem * endShape
KDCanvasPolygonItem * endShapeBack
KDCanvasPolygonItem * floatEndShape
KDCanvasPolygonItem * floatStartShape
bool isEditable
bool isHighlighted
bool isVisibleInGanttView
int mCurrentConnectorCoordX
int mCurrentConnectorDiffX
int mCurrentCoord_Y
KDCanvasPolygonItem * midShape
KDCanvasPolygonItem * midShapeBack
KDCanvasText * mTextCanvas
QString mUid
QDateTime myEndTime
QDateTime myFloatEndTime
QDateTime myFloatStartTime
KDGanttView * myGanttView
int myItemSize
int myProgress
QDateTime myStartTime
KDCanvasPolygonItem * progressShape
KDCanvasLine * startLine
KDCanvasLine * startLineBack
KDCanvasPolygonItem * startShape
KDCanvasPolygonItem * startShapeBack
QString textCanvasText

Member Enumeration Documentation

enum KDGanttViewItem::Connector

This enum is used to define the types of connectors items can have.

Enumerator:
NoConnector 
Start 
Middle 
End 
Move 
ActualEnd 
Lead 
TaskLinkStart 
TaskLinkEnd 

Definition at line 62 of file KDGanttViewItem.h.

enum KDGanttViewItem::Shape

This enum is used in order to specify the shapes of a Gantt chart item.

Enumerator:
TriangleDown 
TriangleUp 
Diamond 
Square 
Circle 

Definition at line 61 of file KDGanttViewItem.h.

enum KDGanttViewItem::Type

This enum is used in order to return the type of a Gantt chart item.

Enumerator:
Event 
Task 
Summary 
UnknownType 

Definition at line 60 of file KDGanttViewItem.h.


Constructor & Destructor Documentation

KDGanttViewItem::KDGanttViewItem ( Type  type,
KDGanttView *  view,
const QString &  lvtext = QString(),
const QString &  name = QString() 
) [protected]

Constructs an empty Gantt item.

Parameters:
type the type of the item to insert
view the Gantt view to insert this item into
lvtext the text to show in the list view
name the name by which the item can be identified. If no name is specified, a unique name will be generated

Definition at line 172 of file KDGanttViewItem.cpp.

KDGanttViewItem::KDGanttViewItem ( Type  type,
KDGanttViewItem *  parentItem,
const QString &  lvtext = QString(),
const QString &  name = QString() 
) [protected]

Constructs an empty Gantt item.

Parameters:
type the type of the item to insert
parentItem a parent item under which this one goes
lvtext the text to show in the list view
name the name by which the item can be identified. If no name is specified, a unique name will be generated

Definition at line 193 of file KDGanttViewItem.cpp.

KDGanttViewItem::KDGanttViewItem ( Type  type,
KDGanttView *  view,
KDGanttViewItem *  after,
const QString &  lvtext = QString(),
const QString &  name = QString() 
) [protected]

Constructs an empty Gantt item.

Parameters:
type the type of the item to insert
view the Gantt view to insert this item into
after another item at the same level behind which this one should go
lvtext the text to show in the list view
name the name by which the item can be identified. If no name is specified, a unique name will be generated

Definition at line 214 of file KDGanttViewItem.cpp.

KDGanttViewItem::KDGanttViewItem ( Type  type,
KDGanttViewItem *  parentItem,
KDGanttViewItem *  after,
const QString &  lvtext = QString(),
const QString &  name = QString() 
) [protected]

Constructs an empty Gantt item.

Parameters:
type the type of the item to insert
parentItem a parent item under which this one goes
after another item at the same level behind which this one should go
lvtext the text to show in the list view
name the name by which the item can be identified. If no name is specified, a unique name will be generated

Definition at line 236 of file KDGanttViewItem.cpp.

KDGanttViewItem::~KDGanttViewItem (  )  [virtual]

Destroys the object and frees any allocated resources.

Definition at line 250 of file KDGanttViewItem.cpp.


Member Function Documentation

void KDGanttViewItem::checkCoord ( int *  co  )  [protected]

Definition at line 2726 of file KDGanttViewItem.cpp.

void KDGanttViewItem::colors ( QColor &  start,
QColor &  middle,
QColor &  end 
) const

Returns the colors used for this item

Parameters:
start returns the start color
middle returns the middle color
end returns the end color
See also:
setColors(), setShapes(), shapes(), setDefaultColor(), defaultColor()

Definition at line 1194 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::createFromDomElement ( KDGanttViewItem *  parent,
KDGanttViewItem *  previous,
QDomElement &  element 
) [static]

Creates a KDGanttViewItem according to the specification in a DOM element.

Parameters:
parent the parent item under which the item will be inserted
previous to item behind this one should appear
element the DOM element from which to read the specification
Returns:
the newly created item

Definition at line 2001 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::createFromDomElement ( KDGanttViewItem *  parent,
QDomElement &  element 
) [static]

Creates a KDGanttViewItem according to the specification in a DOM element.

Parameters:
parent the parent item under which the item will be inserted
element the DOM element from which to read the specification
Returns:
the newly created item

Definition at line 1979 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::createFromDomElement ( KDGanttView *  view,
KDGanttViewItem *  previous,
QDomElement &  element 
) [static]

Creates a KDGanttViewItem according to the specification in a DOM element.

Parameters:
view the view in which the item will be inserted
previous to item behind this one should appear
element the DOM element from which to read the specification
Returns:
the newly created item

Definition at line 1954 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::createFromDomElement ( KDGanttView *  view,
QDomElement &  element 
) [static]

Creates a KDGanttViewItem according to the specification in a DOM element.

Parameters:
view the view in which the item will be inserted
element the DOM element from which to read the specification
Returns:
the newly created item

Definition at line 1932 of file KDGanttViewItem.cpp.

void KDGanttViewItem::createNode ( QDomDocument &  doc,
QDomElement &  parentElement 
)

Creates a DOM node that describes this item.

Parameters:
doc the DOM document to which the node belongs
parentElement the element into which to insert this node

Definition at line 1858 of file KDGanttViewItem.cpp.

QColor KDGanttViewItem::defaultColor (  )  const

Returns the default color that is used for the item if no specific start, middle, or end colors are set.

Returns:
color the default color used
See also:
setDefaultColor(), setColors(), colors()

Definition at line 1392 of file KDGanttViewItem.cpp.

QColor KDGanttViewItem::defaultHighlightColor (  )  const

Returns the default highlighting color that is used for the item if no specific start, middle, or end colors are set.

Returns:
color the default highlighting color used
See also:
setDefaultHighlightColor(), setHighlightColors(), highlightColors()

Definition at line 1436 of file KDGanttViewItem.cpp.

bool KDGanttViewItem::displaySubitemsAsGroup (  )  const

Returns whether this item displays hidden subitems. Initial set to false.

Returns:
true if this item displays hidden subitems, false otherwise
See also:
setDisplaySubitemsAsGroup()

Definition at line 685 of file KDGanttViewItem.cpp.

bool KDGanttViewItem::editable (  )  const

Returns whether this item is editable.

Returns:
true if this item is editable, false otherwise
See also:
setEditable(), KDGanttView::setEditable(), KDGanttView::editable()

Definition at line 646 of file KDGanttViewItem.cpp.

bool KDGanttViewItem::enabled (  )  const

Returns whether this item is enabled.

Returns:
true if this item is enabled, false otherwise
See also:
setEnabled()

Definition at line 588 of file KDGanttViewItem.cpp.

QDateTime KDGanttViewItem::endTime (  )  const

Returns the end time of this item.

Returns:
the end time of this item
See also:
setEndTime(), setStartTime(), startTime()

Definition at line 789 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::find ( const QString &  name  )  [static]

Returns the item with the specified name.

Parameters:
name the name to search for
Returns:
the item with the specified name; 0 if no item with that name exists
See also:
name() uid()

Definition at line 365 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::firstChild (  )  const

Returns the first child of this item.

Returns:
the first child of this item, 0 if this item has no children

Definition at line 1447 of file KDGanttViewItem.cpp.

QFont KDGanttViewItem::font (  )  const

Returns the font used for the text in this item.

Returns:
the font used for the text in this item
See also:
setFont()

Definition at line 882 of file KDGanttViewItem.cpp.

void KDGanttViewItem::generateAndInsertName ( const QString &  name  )  [protected]

Generates a unique name if necessary and inserts it into the item dictionary.

Definition at line 291 of file KDGanttViewItem.cpp.

unsigned int KDGanttViewItem::getAllSubChildTimeForTimespan ( const QDateTime &  start,
const QDateTime &  end 
)

Computes for a set of items recursively the amount of time each item do have in the specified timespan. (Specified by the items start datetime and end datetime). The set of items in this method is the list of all children of this item. I.e. all subchildren ( children of children ) are in this list. The item itself is in the list as well. It calls for each item getTimeForTimespan() and returns the sum of the computed times. Please read getTimeForTimespan() for an example.

Parameters:
start the start QDateTime of the interval. If an invalid QDateTime is passed it is an open interval, i.e. all items before the end datetime will be computed end the end QDateTime of the interval. If an invalid QDateTime is passed it is an open interval, i.e. all items after the start datetime will be computed. if start and end are invalid all items will be computed.
Returns:
the sum of times of computed items in seconds
See also:
getTimeForTimespan() getChildTimeForTimespan() getChildListForTimespan()

Definition at line 492 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::getChildByName ( const QString &  name  ) 

If the name of this item is name (i.e., listViewText() == name), the pointer to this item is returned. Otherwise, it looks for an item with name name in the set of children and subchildren of this item.

Parameters:
name the name of the item
Returns:
the pointer to the item with name name

Definition at line 2461 of file KDGanttViewItem.cpp.

KDGanttViewItem * KDGanttViewItem::getChildByUid ( const QString &  uid  ) 

If the uid of this item is uid (i.e. a user defined unique id), the pointer to this item is returned. Otherwise, it looks for an item with uid uid in the set of children and subchildren of this item. The uid of an item is not set automatically, it has to be set by the programmer.

Parameters:
uid the uid of the item
Returns:
the pointer to the item with uid uid
See also:
setUid() uid() KDGanttView::getItemByUid()

Definition at line 2486 of file KDGanttViewItem.cpp.

QPtrList< KDGanttViewItem > KDGanttViewItem::getChildListForTimespan ( const QDateTime &  start,
const QDateTime &  end 
)

Computes a list of direct subitems of this item which do have some duration during the timespan. It call for every direct subitem getTimeForTimespan() and appends it to the list if this call does not return 0. Please read getTimeForTimespan() for an example when a call of getTimeForTimespan() does not return 0.

Parameters:
start the start QDateTime of the interval. If an invalid QDateTime is passed it is an open interval, i.e. all items before the end datetime will be computed end the end QDateTime of the interval. If an invalid QDateTime is passed it is an open interval, i.e. all items after the start datetime will be computed. if start and end are invalid all items will be computed.
Returns:
a list of direct subitems of this item which do have some duration during the timespan
See also:
getTimeForTimespan() getChildTimeForTimespan() getAllSubChildTimeForTimespan()

Definition at line 429 of file KDGanttViewItem.cpp.

unsigned int KDGanttViewItem::getChildTimeForTimespan ( const QDateTime &  start,
const QDateTime &  end 
)

Computes for a set of items the amount of time each item do have in the specified timespan. (Specified by the items start datetime and end datetime). The set of items in this method is the list of direct children of this item. No subchildren ( children of children ) are in this list. The item itself is not in the list. It calls for each item getTimeForTimespan() and returns the sum of the computed times. Please read getTimeForTimespan() for an example.

Parameters:
start the start QDateTime of the interval. If an invalid QDateTime is passed it is an open interval, i.e. all items before the end datetime will be computed end the end QDateTime of the interval. If an invalid QDateTime is passed it is an open interval, i.e. all items after the start datetime will be computed. if start and end are invalid all items will be computed.
Returns:
the sum of times of computed items in seconds
See also:
getTimeForTimespan() getAllSubChildTimeForTimespan() getChildListForTimespan()

Definition at line 522 of file KDGanttViewItem.cpp.

KDGanttViewItem::Connector KDGanttViewItem::getConnector ( QPoint  p  )  [virtual]

Returns the region of the item for the position p. A region is a connector and it is used for changing item in the gantt view. This virtual method is reimplemented in the subclasses.

Parameters:
p point to check for a connector
Returns:
This virtual method does nothing and returns NoConnector
See also:
moveConnector()

Reimplemented in KDGanttViewEventItem, KDGanttViewSummaryItem, and KDGanttViewTaskItem.

Definition at line 342 of file KDGanttViewItem.cpp.

int KDGanttViewItem::getCoordY (  )  [protected]

Returns the y coordinate of this item.

Returns:
the y coordinate of this item

Definition at line 2277 of file KDGanttViewItem.cpp.

unsigned int KDGanttViewItem::getTimeForTimespan ( const QDateTime &  start,
const QDateTime &  end 
) [virtual]

The virtual method computes for this item the amount of time this item do have in the specified timespan. (Specified by the items start datetime and end datetime). The default implementation of this method returns 0. This method is reimplemented in the subclass KDGanttViewTaskItem only. Example: Let eTask be a task item with start date time 24. March 2005 - 17:00 and end date time 24. March 2005 - 19:30 i.e. it has a duration of 2:30 hours , which are 9000 seconds.

eTask->getTimeForTimespan( QDateTime(),QDateTime() ) returns the complete duration of 9000, because an open interval was specified eTask->getTimeForTimespan( QDateTime(),QDateTime( 24. March 2005 - 18:00 ) ) returns 3600. eTask->getTimeForTimespan( QDateTime( 24. March 2005 - 17:30 ),QDateTime( 24. March 2005 - 18:00 ) ) returns 1800. eTask->getTimeForTimespan( QDateTime( 24. March 2005 - 17:30 ),QDateTime( 28. April 2005 - 18:00 ) ) returns 7200 ( 2 hours ). eTask->getTimeForTimespan( QDateTime( 1. March 2005 - 0:30 ),QDateTime( 28. April 2005 - 18:00 ) ) returns 9000 ( complete duration ). eTask->getTimeForTimespan( QDateTime( 1. Jan 2004 - 12:30 ),QDateTime( 1. April 2004 - 1:00 ) ) returns 0.

Parameters:
start the start QDateTime of the interval. If an invalid QDateTime is passed it is an open interval. end the end QDateTime of the interval. If an invalid QDateTime is passed it is an open interval. if start and end are invalid the duration (start time to end time in seconds) is returned.
Returns:
the time of this item in the interval in seconds
See also:
getChildTimeForTimespan() getAllSubChildTimeForTimespan() getChildListForTimespan()

Reimplemented in KDGanttViewTaskItem.

Definition at line 470 of