KGantt

kganttconstraintmodel.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 KGANTTCONSTRAINTMODEL_H
10#define KGANTTCONSTRAINTMODEL_H
11
12#include <QModelIndex>
13#include <QDebug>
14
15#include "kganttglobal.h"
16#include "kganttconstraint.h"
17
18namespace KGantt {
19
20
21 /*!\class KGantt::ConstraintModel
22 *\ingroup KGantt
23 * The ConstraintModel keeps track of the
24 * interdependencies between gantt items in
25 * a View.
26 *
27 */
28 class KGANTT_EXPORT ConstraintModel : public QObject {
29 Q_OBJECT
30 KGANTT_DECLARE_PRIVATE_DERIVED_PARENT( ConstraintModel, QObject* )
31 public:
32
33
34 /*! Constructor. Creates an empty ConstraintModel with parent \a parent
35 */
36 explicit ConstraintModel( QObject* parent = nullptr );
37
38
39 /*! Destroys this ConstraintModel */
40 ~ConstraintModel() override;
41
42 /*! Adds the constraint \a c to this ConstraintModel
43 * If the Constraint \a c is already in this ConstraintModel,
44 * nothing happens.
45 *
46 * Subclassing ConstraintModel and overriding addConstraint() and removeConstraint() can provide
47 * re-entrancy issues in the ConstraintModel<->ConstraintProxy interaction. Therefore it is recommended
48 * to better subclass GraphicsView and override addConstraint() there.
49 */
50 virtual void addConstraint( const Constraint& c );
51
52 /*! Removes the Constraint \a c from this
53 * ConstraintModel. If \a c was found and removed,
54 * the signal constraintRemoved(const Constraint&) is emitted.
55 *
56 * \returns If \a c was found and removed, it returns true,
57 * otherwise it returns false.
58 */
59 virtual bool removeConstraint( const Constraint& c );
60
61 /*! Removes all Constraints from this model
62 * The signal constraintRemoved(const Constraint&) is emitted
63 * for every Constraint that is removed.
64 */
65 void clear();
66
67 /*! Not used */
68 void cleanup();
69
70 /*! \returns A list of all Constraints in this
71 * ConstraintModel.
72 */
73 QList<Constraint> constraints() const;
74
75 /*! Returns true if a Constraint with start \a s and end \a e
76 * exists, otherwise false.
77 */
78 bool hasConstraint( const Constraint& c ) const;
79 inline bool hasConstraint( const QModelIndex& s,
80 const QModelIndex& e ) const;
81
82
83 /*! \returns A list of all Constraints in this ConstraintModel
84 * that have an endpoint at \a idx.
85 */
86 QList<Constraint> constraintsForIndex( const QModelIndex& ) const;
87
88 Q_SIGNALS:
89 void constraintAdded(const KGantt::Constraint&);
90 void constraintRemoved(const KGantt::Constraint&);
91
92 private:
93 Private* _d;
94 };
95
96 inline const ConstraintModel::Private* ConstraintModel::d_func() const { return _d; }
97 inline ConstraintModel::Private* ConstraintModel::d_func() { return _d; }
98 inline bool ConstraintModel::hasConstraint( const QModelIndex& s, const QModelIndex& e ) const {
99 return hasConstraint( Constraint( s, e ) );
100 }
101}
102
103#ifndef QT_NO_DEBUG_STREAM
104
105QDebug KGANTT_EXPORT operator<<( QDebug dbg, const KGantt::ConstraintModel& model );
107{
108 return operator<<(dbg,*model);
109}
110
111#endif /* QT_NO_DEBUG_STREAM */
112
113#endif /* KGANTTCONSTRAINTMODEL_H */
114
bool hasConstraint(const Constraint &c) const
A class used to represent a dependency.
Contains KGantt macros.
Global namespace.
QDebug operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.