KGantt

kganttconstraint.h
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KGantt library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KGANTTCONSTRAINT_H
10#define KGANTTCONSTRAINT_H
11
12#include <QMap>
13#include <QModelIndex>
14#include <QObject>
15#include <QSharedDataPointer>
16#include <QVariant>
17
18#include "kganttglobal.h"
19#ifndef QT_NO_DEBUG_STREAM
20#include <QDebug>
21#endif
22
23namespace KGantt {
24
25
26 /*!\class KGantt::Constraint
27 *\ingroup KGantt
28 * \brief A class used to represent a dependency.
29 *
30 * Instances of this class represent a dependency between the
31 * data items pointed to by a start-QModelIndex and an
32 * end-QModelIndex.
33 */
34 class KGANTT_EXPORT Constraint {
35 class Private;
36 public:
37 /*!\enum KGantt::Constraint::Type
38 * This enum is unused for now.
39 */
40 enum Type
41 {
42 TypeSoft = 0,
43 TypeHard = 1
44 };
45 enum RelationType
46 {
47 FinishStart = 0,
48 FinishFinish = 1,
49 StartStart = 2,
50 StartFinish = 3
51 };
52
53 /*!\enum KGantt::Constraint::ConstraintDataRole
54 * Data roles used when specifying the pen to draw constraints with.
55 * \sa setData
56 */
57 enum ConstraintDataRole
58 {
59 ValidConstraintPen = Qt::UserRole,
60 InvalidConstraintPen
61 };
62
64
65 /*! Default constructor, created an invalid constraint. */
66 Constraint();
67
68 /*! Constructor. Creates a dependency for \a idx2 on \a idx1.
69 * \param type controls if the constraint is a soft one that
70 * is allowed to be broken (ie, go backwards in time) or a hard
71 * constraint that will not allow the user to move an item so
72 * that the constraint would have to go backwards. The default is
73 * TypeSoft.
74 *
75 * Actually enforcing hard constraints is the responsibility of
76 * the AbstractGrid subclass used in the view.
77 *
78 * \param relationType defines how the tasks depends on each other.
79 * relationType can be FinishStart (default), FinishFinish, StartStart or StartFinish.
80 */
81 Constraint( const QModelIndex& idx1,
82 const QModelIndex& idx2,
83 Type type=TypeSoft,
84 RelationType relType=FinishStart,
85 const DataMap& datamap=DataMap() );
86
87 /*! Copy-Constructor. */
88 Constraint( const Constraint& other);
89
90
91 /*! Destructor */
93
94 /*! This is unused for now. */
95 Type type() const;
96
97 /*! This is unused for now. */
98 RelationType relationType() const;
99
100 /*! \returns The dependency index */
101 QModelIndex startIndex() const;
102
103 /*! \returns The constrained index */
104 QModelIndex endIndex() const;
105
106 /*! Set data on this index for the specified role.
107 * \param role The role to set the data for.
108 * \param value The data to set on the index.
109 * \sa ConstraintDataRole
110 */
111 void setData( int role, const QVariant& value );
112
113 /*! \returns The data associated with this index for the specified role.
114 * \param role The role to fetch the data for.
115 * \sa ConstraintDataRole
116 */
117 QVariant data( int role ) const;
118
119 /*! Set data on this constraint to the keys/values in \a datamap.
120 * Clears any existing data from the constraint.
121 */
122 void setDataMap( const QMap< int, QVariant >& datamap );
123
124 /*! \returns all the data set on this constraint. \see setDataMap
125 */
126 QMap< int, QVariant > dataMap() const;
127
128 bool compareIndexes(const Constraint& other) const;
129
130 /*! Assignment operator. */
131 Constraint& operator=( const Constraint& other );
132
133 /*! Compare two Constraint objects. Two Constraints are equal
134 * if the have the same start and end indexes
135 */
136 bool operator==( const Constraint& other ) const;
137
138 inline bool operator!=( const Constraint& other ) const {
139 return !operator==( other );
140 }
141
142 /*!\internal*/
143 uint hash() const;
144#ifndef QT_NO_DEBUG_STREAM
145 QDebug debug( QDebug dbg) const;
146#endif
147
148 private:
150 };
151
152 inline uint qHash( const Constraint& c ) {return c.hash();}
153}
154
155#ifndef QT_NO_DEBUG_STREAM
156QDebug KGANTT_EXPORT operator<<( QDebug dbg, const KGantt::Constraint& c );
157#endif /* QT_NO_DEBUG_STREAM */
158
159#endif /* KGANTTCONSTRAINT_H */
160
A class used to represent a dependency.
Contains KGantt macros.
Global namespace.
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:54:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.