#include <kdganttconstraint.h>
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 |
Constraint & | operator= (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 () |
Data roles used when specifying the pen to draw constraints with.
Definition at line 54 of file kdganttconstraint.h.
00055 { 00056 ValidConstraintPen = Qt::UserRole, 00057 InvalidConstraintPen 00058 };
Definition at line 46 of file kdganttconstraint.h.
00047 { 00048 FinishStart = 0, 00049 FinishFinish = 1, 00050 StartStart = 2, 00051 StartFinish = 3 00052 };
Constraint::Constraint | ( | const QModelIndex & | idx1, | |
const QModelIndex & | idx2, | |||
Constraint::Type | type = TypeSoft , |
|||
Constraint::RelationType | relationType = FinishStart | |||
) |
Constructor. Creates a dependency for idx2 on idx1.
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. |
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 | ( | ) |
QVariant Constraint::data | ( | int | role | ) | const |
role | The role to fetch the data for. |
Definition at line 134 of file kdganttconstraint.cpp.
Referenced by KDGantt::ConstraintGraphicsItem::ganttToolTip().
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 |
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().
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.
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().
void Constraint::setData | ( | int | role, | |
const QVariant & | value | |||
) |
Set data on this index for the specified role.
role | The role to set the data for. | |
value | The data to set on the index. |
Definition at line 144 of file kdganttconstraint.cpp.
QModelIndex Constraint::startIndex | ( | ) | const |
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().
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().