kdganttitemdelegate.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 distributed and/or modified under the terms of the
00007  ** GNU General Public License version 2 as published by the Free Software
00008  ** Foundation and appearing in the file LICENSE.GPL included in the
00009  ** packaging of this file.
00010  **
00011  ** Licensees holding valid commercial KD Gantt licenses may use this file in
00012  ** accordance with the KD Gantt Commercial License Agreement provided with
00013  ** the Software.
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  ** See http://www.kdab.net/kdgantt for
00019  **   information about KD Gantt Commercial License Agreements.
00020  **
00021  ** Contact info@kdab.net if any conditions of this
00022  ** licensing are not clear to you.
00023  **
00024  **********************************************************************/
00025 #ifndef KDGANTTITEMDELEGATE_H
00026 #define KDGANTTITEMDELEGATE_H
00027 
00028 #include <QItemDelegate>
00029 #include <QBrush>
00030 #include <QPen>
00031 #include <QDebug>
00032 
00033 #include "../kdchart_export.h"
00034 #include "kdganttglobal.h"
00035 
00036 namespace KDGantt {
00037     class StyleOptionGanttItem;
00038     class Constraint;
00039 
00040     class KDCHART_EXPORT ItemDelegate : public QItemDelegate {
00041         Q_OBJECT
00042         KDGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( ItemDelegate )
00043     public:
00044         enum InteractionState { State_None = 0,
00045                                 State_Move,
00046                                 State_ExtendLeft,
00047                                 State_ExtendRight,
00048                                 State_DragConstraint
00049         };
00050 
00051         explicit ItemDelegate( QObject* parent = 0 );
00052         virtual ~ItemDelegate();
00053 
00054         void setDefaultBrush( ItemType type, const QBrush& brush );
00055         QBrush defaultBrush( ItemType type ) const;
00056 
00057         void setDefaultPen( ItemType type, const QPen& pen );
00058         QPen defaultPen( ItemType type ) const;
00059 
00060         virtual Span itemBoundingSpan(const StyleOptionGanttItem& opt, const QModelIndex& idx) const;
00061         virtual QRectF constraintBoundingRect( const QPointF& start, const QPointF& end, const Constraint &constraint ) const;
00062         virtual InteractionState interactionStateFor( const QPointF& pos,
00063                                                       const StyleOptionGanttItem& opt,
00064                                                       const QModelIndex& idx ) const;
00065 
00066         virtual void paintGanttItem( QPainter* p, const StyleOptionGanttItem& opt, const QModelIndex& idx );
00067         virtual void paintConstraintItem( QPainter* p, const QStyleOptionGraphicsItem& opt,
00068                                           const QPointF& start, const QPointF& end, const Constraint &constraint );
00069         
00070     protected:
00071         void paintFinishStartConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
00072                 const QPointF& start, const QPointF& end, const Constraint &constraint );
00073         QPolygonF finishStartLine( const QPointF& start, const QPointF& end ) const;
00074         QPolygonF finishStartArrow( const QPointF& start, const QPointF& end ) const;
00075 
00076         void paintFinishFinishConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
00077                 const QPointF& start, const QPointF& end, const Constraint &constraint );
00078         QPolygonF finishFinishLine( const QPointF& start, const QPointF& end ) const;
00079         QPolygonF finishFinishArrow( const QPointF& start, const QPointF& end ) const;
00080         
00081         void paintStartStartConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
00082                 const QPointF& start, const QPointF& end, const Constraint &constraint );
00083         QPolygonF startStartLine( const QPointF& start, const QPointF& end ) const;
00084         QPolygonF startStartArrow( const QPointF& start, const QPointF& end ) const;
00085         
00086         void paintStartFinishConstraint( QPainter* p, const QStyleOptionGraphicsItem& opt,
00087                 const QPointF& start, const QPointF& end, const Constraint &constraint );
00088         QPolygonF startFinishLine( const QPointF& start, const QPointF& end ) const;
00089         QPolygonF startFinishArrow( const QPointF& start, const QPointF& end ) const;
00090 
00091         
00092     };
00093 }
00094 
00095 #ifndef QT_NO_DEBUG_STREAM
00096 QDebug operator<<( QDebug dbg, KDGantt::ItemDelegate::InteractionState );
00097 #endif
00098 
00099 #endif /* KDGANTTITEMDELEGATE_H */
00100 

Generated on Thu Mar 4 23:19:13 2010 for KD Chart 2 by  doxygen 1.5.4