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 KDGANTTITEMDELEGATE_H 00024 #define KDGANTTITEMDELEGATE_H 00025 00026 #include <QItemDelegate> 00027 #include <QBrush> 00028 #include <QPen> 00029 #include <QDebug> 00030 00031 #include "kdganttglobal.h" 00032 00033 namespace KDGantt { 00034 class StyleOptionGanttItem; 00035 class Constraint; 00036 00037 class KDGANTT_EXPORT ItemDelegate : public QItemDelegate { 00038 Q_OBJECT 00039 KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( ItemDelegate ) 00040 public: 00041 enum InteractionState { State_None = 0, 00042 State_Move, 00043 State_ExtendLeft, 00044 State_ExtendRight, 00045 State_DragConstraint 00046 }; 00047 00048 explicit ItemDelegate( QObject* parent = 0 ); 00049 virtual ~ItemDelegate(); 00050 00051 void setDefaultBrush( ItemType type, const QBrush& brush ); 00052 QBrush defaultBrush( ItemType type ) const; 00053 00054 void setDefaultPen( ItemType type, const QPen& pen ); 00055 QPen defaultPen( ItemType type ) const; 00056 00057 virtual Span itemBoundingSpan(const StyleOptionGanttItem& opt, const QModelIndex& idx) const; 00058 virtual QRectF constraintBoundingRect( const QPointF& start, const QPointF& end, const Constraint &constraint ) const; 00059 virtual InteractionState interactionStateFor( const QPointF& pos, 00060 const StyleOptionGanttItem& opt, 00061 const QModelIndex& idx ) const; 00062 00063 virtual void paintGanttItem( QPainter* p, const StyleOptionGanttItem& opt, const QModelIndex& idx ); 00064 virtual void paintConstraintItem( QPainter* p, const QStyleOptionGraphicsItem& opt, 00065 const QPointF& start, const QPointF& end, const Constraint &constraint ); 00066 00067 virtual QString toolTip( const QModelIndex &idx ) const; 00068 00069 protected: 00070 void paintFinishStartConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt, 00071 const QPointF& start, const QPointF& end, const Constraint &constraint ); 00072 QPolygonF finishStartLine( const QPointF& start, const QPointF& end ) const; 00073 QPolygonF finishStartArrow( const QPointF& start, const QPointF& end ) const; 00074 00075 void paintFinishFinishConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt, 00076 const QPointF& start, const QPointF& end, const Constraint &constraint ); 00077 QPolygonF finishFinishLine( const QPointF& start, const QPointF& end ) const; 00078 QPolygonF finishFinishArrow( const QPointF& start, const QPointF& end ) const; 00079 00080 void paintStartStartConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt, 00081 const QPointF& start, const QPointF& end, const Constraint &constraint ); 00082 QPolygonF startStartLine( const QPointF& start, const QPointF& end ) const; 00083 QPolygonF startStartArrow( const QPointF& start, const QPointF& end ) const; 00084 00085 void paintStartFinishConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt, 00086 const QPointF& start, const QPointF& end, const Constraint &constraint ); 00087 QPolygonF startFinishLine( const QPointF& start, const QPointF& end ) const; 00088 QPolygonF startFinishArrow( const QPointF& start, const QPointF& end ) const; 00089 00090 00091 }; 00092 } 00093 00094 #ifndef QT_NO_DEBUG_STREAM 00095 QDebug operator<<( QDebug dbg, KDGantt::ItemDelegate::InteractionState ); 00096 #endif 00097 00098 #endif /* KDGANTTITEMDELEGATE_H */ 00099