KDGantt::Constraint Class Reference

#include <kdganttconstraint.h>

Collaboration diagram for KDGantt::Constraint:

Collaboration graph
[legend]

List of all members.


Detailed Description

A class used to represent a dependency.

Instances of this class represent a dependency between the data items pointed to by a start-QModelIndex and an end-QModelIndex.

Definition at line 38 of file kdganttconstraint.h.


Public Types

enum  ConstraintDataRole {
  ValidConstraintPen = Qt::UserRole,
  InvalidConstraintPen
}
enum  RelationType {
  FinishStart = 0,
  FinishFinish = 1,
  StartStart = 2,
  StartFinish = 3
}
enum  Type {
  TypeSoft = 0,
  TypeHard = 1
}

Public Member Functions

 Constraint (const Constraint &other)
 Constraint (const QModelIndex &idx1, const QModelIndex &idx2, Type type=TypeSoft, RelationType=FinishStart)
QVariant data (int role) const
QDebug debug (QDebug dbg) const
QModelIndex endIndex () const
uint hash () const
bool operator!= (const Constraint &other) const
Constraintoperator= (const Constraint &other)
bool operator== (const Constraint &other) const
RelationType relationType () const
void setData (int role, const QVariant &value)
QModelIndex startIndex () const
Type type () const
 ~Constraint ()

Member Enumeration Documentation

enum KDGantt::Constraint::ConstraintDataRole

Data roles used when specifying the pen to draw constraints with.

See also:
setData
Enumerator:
ValidConstraintPen 
InvalidConstraintPen 

Definition at line 54 of file kdganttconstraint.h.

00055         {
00056             ValidConstraintPen = Qt::UserRole,
00057             InvalidConstraintPen
00058         };

enum KDGantt::Constraint::RelationType

Enumerator:
FinishStart 
FinishFinish 
StartStart 
StartFinish 

Definition at line 46 of file kdganttconstraint.h.

00047         { 
00048             FinishStart = 0,
00049             FinishFinish = 1,
00050             StartStart = 2,
00051             StartFinish = 3
00052         };

enum KDGantt::Constraint::Type

This enum is unused for now.

Enumerator:
TypeSoft 
TypeHard 

Definition at line 41 of file kdganttconstraint.h.

00042         { 
00043             TypeSoft = 0, 
00044             TypeHard = 1
00045         };      


Constructor & Destructor Documentation

Constraint::Constraint ( const QModelIndex &  idx1,
const QModelIndex &  idx2,
Constraint::Type  type = TypeSoft,
Constraint::RelationType  relationType = FinishStart 
)

Constructor. Creates a dependency for idx2 on idx1.

Parameters:
type controls if the constraint is a soft one that is allowed to be broken (ie, go backwards in time) or a hard constraint that will not allow the user to move an item so that the constraint would have to go backwards. The default is TypeSoft.
Actually enforcing hard constraints is the responsibility of the AbstractGrid subclass used in the view.

Parameters:
relationType defines how the tasks depends on each other. relationType can be FinishStart (default), FinishFinish, StartStart or StartFinish.

Definition at line 78 of file kdganttconstraint.cpp.

Referenced by KDAB_SCOPED_UNITTEST_SIMPLE().

00079     : d( new Private )
00080 {
00081     d->start=idx1;
00082     d->end=idx2;
00083     d->type=type;
00084     d->relationType=relationType;
00085     Q_ASSERT_X( idx1 != idx2 || !idx1.isValid(), "Constraint::Constraint", "cannot create a constraint with idx1 == idx2" );
00086 }

Constraint::Constraint ( const Constraint other  ) 

Copy-Constructor.

Definition at line 89 of file kdganttconstraint.cpp.

00090     : d( other.d )
00091 {
00092 }

Constraint::~Constraint (  ) 

Destructor

Definition at line 95 of file kdganttconstraint.cpp.

00096 {
00097 }


Member Function Documentation

QVariant Constraint::data ( int  role  )  const

Returns:
The data associated with this index for the specified role.
Parameters:
role The role to fetch the data for.
See also:
ConstraintDataRole

Definition at line 134 of file kdganttconstraint.cpp.

Referenced by KDGantt::ConstraintGraphicsItem::ganttToolTip().

00135 {
00136     return d->data.value( role );
00137 }

QDebug Constraint::debug ( QDebug  dbg  )  const

Definition at line 171 of file kdganttconstraint.cpp.

Referenced by operator<<().

00172 {
00173     dbg << "KDGantt::Constraint[ start=" << d->start << "end=" << d->end << "relationType=" << d->relationType << "]";
00174     return dbg;
00175 }

QModelIndex Constraint::endIndex (  )  const

Returns:
The constrained index

Definition at line 125 of file kdganttconstraint.cpp.

Referenced by KDGantt::ConstraintModel::addConstraint(), KDGantt::ConstraintModel::cleanup(), KDGantt::ConstraintModel::constraintsForIndex(), KDGantt::GraphicsScene::insertItem(), KDGantt::AbstractGrid::isSatisfiedConstraint(), KDGantt::DateTimeGrid::mapFromChart(), KDGantt::ConstraintGraphicsItem::proxyConstraint(), and KDGantt::ConstraintModel::removeConstraint().

00126 {
00127     return d->end;
00128 }

uint Constraint::hash (  )  const

Definition at line 159 of file kdganttconstraint.cpp.

References KDGantt::qHash().

Referenced by KDGantt::qHash().

00160 {
00161     return ::qHash( d->start ) ^ ::qHash( d->end ) ^ ::qHash( static_cast<uint>( d->type ) );
00162 }

bool KDGantt::Constraint::operator!= ( const Constraint other  )  const

Definition at line 76 of file kdganttconstraint.h.

References KDGantt::operator==().

00076                                                                 {
00077             return !operator==( other );
00078         }

Constraint & Constraint::operator= ( const Constraint other  ) 

Assignment operator.

Definition at line 100 of file kdganttconstraint.cpp.

References d.

00101 {
00102     d = other.d;
00103     return *this;
00104 }

bool Constraint::operator== ( const Constraint other  )  const

Compare two Constraint objects. Two Constraints are equal if the have the same start and end indexes

Definition at line 152 of file kdganttconstraint.cpp.

References d.

00153 {
00154     if ( d == other.d ) return true;
00155     return ( *d ).equals( *( other.d ) );
00156 }

Constraint::RelationType Constraint::relationType (  )  const

This is unused for now.

Definition at line 113 of file kdganttconstraint.cpp.

Referenced by KDGantt::ItemDelegate::constraintBoundingRect(), and KDGantt::ItemDelegate::paintConstraintItem().

00114 {
00115     return d->relationType;
00116 }

void Constraint::setData ( int  role,
const QVariant &  value 
)

Set data on this index for the specified role.

Parameters:
role The role to set the data for.
value The data to set on the index.
See also:
ConstraintDataRole

Definition at line 144 of file kdganttconstraint.cpp.

00145 {
00146     d->data.insert( role, value );
00147 }

QModelIndex Constraint::startIndex (  )  const

Returns:
The dependency index

Definition at line 119 of file kdganttconstraint.cpp.

Referenced by KDGantt::ConstraintModel::addConstraint(), KDGantt::ConstraintModel::cleanup(), KDGantt::ConstraintModel::constraintsForIndex(), KDGantt::GraphicsScene::insertItem(), KDGantt::AbstractGrid::isSatisfiedConstraint(), KDGantt::DateTimeGrid::mapFromChart(), KDGantt::ConstraintGraphicsItem::proxyConstraint(), and KDGantt::ConstraintModel::removeConstraint().

00120 {
00121     return d->start;
00122 }

Constraint::Type Constraint::type (  )  const

This is unused for now.

Definition at line 107 of file kdganttconstraint.cpp.

Referenced by KDAB_SCOPED_UNITTEST_SIMPLE(), KDGantt::DateTimeGrid::mapFromChart(), and KDGantt::ConstraintGraphicsItem::proxyConstraint().

00108 {
00109     return d->type;
00110 }


The documentation for this class was generated from the following files:
Generated on Thu Mar 4 23:26:59 2010 for KD Chart 2 by  doxygen 1.5.4