KD Chart 2 [rev.2.4]
|
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 "kdchart_export.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 to work around a compiler error on OS X (gcc 4.2.1) 00061 //in 'const QMap<int,QVariant>& dataMap=QMap<int,QVariant>()' 00062 //in the second Constraint ctor 00063 typedef QMap<int,QVariant> DataMap; 00064 00065 Constraint(); 00066 Constraint( const QModelIndex& idx1, 00067 const QModelIndex& idx2, 00068 Type type=TypeSoft, 00069 RelationType=FinishStart, 00070 const DataMap& dataMap=DataMap() ); 00071 Constraint( const Constraint& other); 00072 ~Constraint(); 00073 00074 Type type() const; 00075 RelationType relationType() const; 00076 QModelIndex startIndex() const; 00077 QModelIndex endIndex() const; 00078 00079 void setData( int role, const QVariant& value ); 00080 QVariant data( int role ) const; 00081 00082 void setDataMap( const QMap< int, QVariant >& datamap ); 00083 QMap< int, QVariant > dataMap() const; 00084 00085 bool compareIndexes(const Constraint& other) const; 00086 00087 Constraint& operator=( const Constraint& other ); 00088 bool operator==( const Constraint& other ) const; 00089 00090 inline bool operator!=( const Constraint& other ) const { 00091 return !operator==( other ); 00092 } 00093 00094 uint hash() const; 00095 #ifndef QT_NO_DEBUG_STREAM 00096 QDebug debug( QDebug dbg) const; 00097 #endif 00098 00099 private: 00100 QSharedDataPointer<Private> d; 00101 }; 00102 00103 inline uint qHash( const Constraint& c ) {return c.hash();} 00104 } 00105 00106 #ifndef QT_NO_DEBUG_STREAM 00107 QDebug KDGANTT_EXPORT operator<<( QDebug dbg, const KDGantt::Constraint& c ); 00108 #endif /* QT_NO_DEBUG_STREAM */ 00109 00110 #endif /* KDGANTTCONSTRAINT_H */ 00111