kdganttconstraint.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #ifndef KDGANTTCONSTRAINT_H
00024 #define KDGANTTCONSTRAINT_H
00025 
00026 #include <QModelIndex>
00027 #include <QObject>
00028 #include <QSharedDataPointer>
00029 
00030 #include "../kdchart_export.h"
00031 #ifndef QT_NO_DEBUG_STREAM
00032 #include <QDebug>
00033 #endif
00034 
00035 namespace KDGantt {
00036     class KDCHART_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 KDCHART_EXPORT operator<<( QDebug dbg, const KDGantt::Constraint& c );
00092 #endif /* QT_NO_DEBUG_STREAM */
00093 
00094 #endif /* KDGANTTCONSTRAINT_H */
00095