kdgantt

kdganttconstraint.h

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB.  All rights reserved.
00003  **
00004  ** This file is part of the KD Gantt library.
00005  **
00006  ** This file may be used under the terms of the GNU General Public
00007  ** License versions 2.0 or 3.0 as published by the Free Software
00008  ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
00009  ** included in the packaging of this file.  Alternatively you may (at
00010  ** your option) use any later version of the GNU General Public
00011  ** License if such license has been publicly approved by
00012  ** Klarälvdalens Datakonsult AB (or its successors, if any).
00013  ** 
00014  ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
00015  ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
00016  ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
00017  ** not expressly granted herein.
00018  ** 
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  **********************************************************************/
00023 #ifndef KDGANTTCONSTRAINT_H
00024 #define KDGANTTCONSTRAINT_H
00025 
00026 #include <QModelIndex>
00027 #include <QObject>
00028 #include <QSharedDataPointer>
00029 
00030 #include "kdgantt_export.h"
00031 #ifndef QT_NO_DEBUG_STREAM
00032 #include <QDebug>
00033 #endif
00034 
00035 namespace KDGantt {
00036     class KDGANTT_EXPORT Constraint {
00037         class Private;
00038     public:
00039         enum Type
00040         { 
00041             TypeSoft = 0, 
00042             TypeHard = 1
00043         };  
00044         enum RelationType
00045         { 
00046             FinishStart = 0,
00047             FinishFinish = 1,
00048             StartStart = 2,
00049             StartFinish = 3
00050         };
00051 
00052         enum ConstraintDataRole
00053         {
00054             ValidConstraintPen = Qt::UserRole,
00055             InvalidConstraintPen
00056         };
00057 
00058         Constraint( const QModelIndex& idx1,  const QModelIndex& idx2, Type type=TypeSoft, RelationType=FinishStart );
00059         Constraint( const Constraint& other);
00060         ~Constraint();
00061 
00062         Type type() const;
00063         RelationType relationType() const;
00064         QModelIndex startIndex() const;
00065         QModelIndex endIndex() const;
00066 
00067         void setData( int role, const QVariant& value );
00068         QVariant data( int role ) const;
00069 
00070         Constraint& operator=( const Constraint& other );
00071 
00072         bool operator==( const Constraint& other ) const;
00073 
00074         inline bool operator!=( const Constraint& other ) const {
00075             return !operator==( other );
00076         }
00077 
00078         uint hash() const;
00079 #ifndef QT_NO_DEBUG_STREAM
00080         QDebug debug( QDebug dbg) const;
00081 #endif
00082 
00083     private:
00084         QSharedDataPointer<Private> d;
00085     };
00086 
00087     inline uint qHash( const Constraint& c ) {return c.hash();}
00088 }
00089 
00090 #ifndef QT_NO_DEBUG_STREAM
00091 QDebug operator<<( QDebug dbg, const KDGantt::Constraint& c );
00092 #endif /* QT_NO_DEBUG_STREAM */
00093 
00094 #endif /* KDGANTTCONSTRAINT_H */
00095