KD Chart 2
[rev.2.5]
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2012 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.txt 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 <QMap> 00027 #include <QModelIndex> 00028 #include <QObject> 00029 #include <QSharedDataPointer> 00030 #include <QVariant> 00031 00032 #include "kdganttglobal.h" 00033 #ifndef QT_NO_DEBUG_STREAM 00034 #include <QDebug> 00035 #endif 00036 00037 namespace KDGantt { 00038 class KDGANTT_EXPORT Constraint { 00039 class Private; 00040 public: 00041 enum Type 00042 { 00043 TypeSoft = 0, 00044 TypeHard = 1 00045 }; 00046 enum RelationType 00047 { 00048 FinishStart = 0, 00049 FinishFinish = 1, 00050 StartStart = 2, 00051 StartFinish = 3 00052 }; 00053 00054 enum ConstraintDataRole 00055 { 00056 ValidConstraintPen = Qt::UserRole, 00057 InvalidConstraintPen 00058 }; 00059 00060 typedef QMap<int, QVariant> DataMap; 00061 00062 Constraint(); 00063 Constraint( const QModelIndex& idx1, 00064 const QModelIndex& idx2, 00065 Type type=TypeSoft, 00066 RelationType relType=FinishStart, 00067 const DataMap& datamap=DataMap() ); 00068 Constraint( const Constraint& other); 00069 ~Constraint(); 00070 00071 Type type() const; 00072 RelationType relationType() const; 00073 QModelIndex startIndex() const; 00074 QModelIndex endIndex() const; 00075 00076 void setData( int role, const QVariant& value ); 00077 QVariant data( int role ) const; 00078 00079 void setDataMap( const QMap< int, QVariant >& datamap ); 00080 QMap< int, QVariant > dataMap() const; 00081 00082 bool compareIndexes(const Constraint& other) const; 00083 00084 Constraint& operator=( const Constraint& other ); 00085 bool operator==( const Constraint& other ) const; 00086 00087 inline bool operator!=( const Constraint& other ) const { 00088 return !operator==( other ); 00089 } 00090 00091 uint hash() const; 00092 #ifndef QT_NO_DEBUG_STREAM 00093 QDebug debug( QDebug dbg) const; 00094 #endif 00095 00096 private: 00097 QSharedDataPointer<Private> d; 00098 }; 00099 00100 inline uint qHash( const Constraint& c ) {return c.hash();} 00101 } 00102 00103 #ifndef QT_NO_DEBUG_STREAM 00104 QDebug KDCHART_EXPORT operator<<( QDebug dbg, const KDGantt::Constraint& c ); 00105 #endif /* QT_NO_DEBUG_STREAM */ 00106 00107 #endif /* KDGANTTCONSTRAINT_H */ 00108