12 #include "kdganttconstraint_p.h"
36 Constraint::Private::Private()
40 Constraint::Private::Private(
const Private &other)
45 , relationType(other.relationType)
63 Constraint::Constraint(
const QModelIndex &idx1,
64 const QModelIndex &idx2,
75 Q_ASSERT_X(idx1 != idx2 || !idx1.isValid(),
"Constraint::Constraint",
"cannot create a constraint with idx1 == idx2");
111 return d->relationType;
132 return d->data.value(role);
142 d->data.insert(role, value);
162 return (d->start == other.
startIndex() || (!d->start.isValid() && !other.
startIndex().isValid()))
163 && (d->end == other.
endIndex() || (!d->end.isValid() && !other.
endIndex().isValid()));
173 return (*d).equals(*(other.d));
182 #ifndef QT_NO_DEBUG_STREAM
191 dbg <<
"KDGantt::Constraint[ start=" << d->start <<
"end=" << d->end <<
"relationType=" << d->relationType <<
"], data=" << d->data;
197 #ifndef KDAB_NO_UNIT_TESTS
199 #include <QStandardItemModel>
201 #include "unittest/test.h"
205 QStandardItemModel dummyModel(100, 100);
206 QModelIndex idx1 = dummyModel.index(7, 17, QModelIndex());
207 QModelIndex idx2 = dummyModel.index(42, 17, QModelIndex());
215 assertTrue(c1 == c2);
217 assertTrue(c1 == c3);
219 assertTrue(c2 == c3);
222 assertFalse(c2 == c4);
225 assertFalse(c4 == c5);
229 dummyModel.removeRow(8);
230 assertFalse(c4 == c5);
A class used to represent a dependency.
QVariant data(int role) const
void setDataMap(const QMap< int, QVariant > &datamap)
Set data on this constraint to the keys/values in datamap.
QDebug debug(QDebug dbg) const
Type
This enum is unused for now.
QModelIndex endIndex() const
Constraint & operator=(const Constraint &other)
Assignment operator.
Type type() const
This is unused for now.
bool operator==(const Constraint &other) const
Compare two Constraint objects.
bool compareIndexes(const Constraint &other) const
RelationType relationType() const
This is unused for now.
QModelIndex startIndex() const
Constraint()
Default constructor, created an invalid constraint.
QMap< int, QVariant > dataMap() const
void setData(int role, const QVariant &value)
Set data on this index for the specified role.
KDAB_SCOPED_UNITTEST_SIMPLE(KDGantt, Constraint, "test")
QDebug operator<<(QDebug dbg, const Constraint &c)
uint qHash(const Constraint &c)