• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kdgantt

kdganttconstraintgraphicsitem.cpp

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 used under the terms of the GNU General Public
00007  ** License versions 2.0 or 3.0 as published by the Free Software
00008  ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
00009  ** included in the packaging of this file.  Alternatively you may (at
00010  ** your option) use any later version of the GNU General Public
00011  ** License if such license has been publicly approved by
00012  ** Klarälvdalens Datakonsult AB (or its successors, if any).
00013  ** 
00014  ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
00015  ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
00016  ** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
00017  ** not expressly granted herein.
00018  ** 
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  **********************************************************************/
00023 #include "kdganttconstraintgraphicsitem.h"
00024 #include "kdganttconstraintmodel.h"
00025 #include "kdganttgraphicsscene.h"
00026 #include "kdganttitemdelegate.h"
00027 #include "kdganttsummaryhandlingproxymodel.h"
00028 
00029 #include <QPainter>
00030 #include <QDebug>
00031 
00032 using namespace KDGantt;
00033 
00038 ConstraintGraphicsItem::ConstraintGraphicsItem( const Constraint& c, QGraphicsItem* parent, GraphicsScene* scene )
00039     : QGraphicsItem( parent, scene ),  m_constraint( c )
00040 {
00041     qDebug() << "ConstraintGraphicsItem::ConstraintGraphicsItem()";
00042     setPos( QPointF( 0., 0. ) );
00043     setAcceptsHoverEvents( false );
00044     setAcceptedMouseButtons( Qt::NoButton );
00045     setZValue( 10. );
00046 }
00047 
00048 ConstraintGraphicsItem::~ConstraintGraphicsItem()
00049 {
00050 }
00051 
00052 int ConstraintGraphicsItem::type() const
00053 {
00054     return Type;
00055 }
00056 
00057 GraphicsScene* ConstraintGraphicsItem::scene() const
00058 {
00059     return qobject_cast<GraphicsScene*>( QGraphicsItem::scene() );
00060 }
00061 
00062 Constraint ConstraintGraphicsItem::proxyConstraint() const
00063 {
00064     return Constraint( scene()->summaryHandlingModel()->mapFromSource( m_constraint.startIndex() ),
00065                        scene()->summaryHandlingModel()->mapFromSource( m_constraint.endIndex() ),
00066                        m_constraint.type() );
00067 }
00068 
00069 QRectF ConstraintGraphicsItem::boundingRect() const
00070 {
00071     return scene()->itemDelegate()->constraintBoundingRect( m_start, m_end, m_constraint );
00072 }
00073 
00074 void ConstraintGraphicsItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option,
00075                                     QWidget* widget )
00076 {
00077     Q_UNUSED( widget );
00078 
00079     scene()->itemDelegate()->paintConstraintItem( painter, *option, m_start, m_end, m_constraint );
00080 }
00081 
00082 QString ConstraintGraphicsItem::ganttToolTip() const
00083 {
00084     return m_constraint.data( Qt::ToolTipRole ).toString();
00085 }
00086 
00087 void ConstraintGraphicsItem::setStart( const QPointF& start )
00088 {
00089     prepareGeometryChange();
00090     m_start = start;
00091     update();
00092 }
00093 
00094 void ConstraintGraphicsItem::setEnd( const QPointF& end )
00095 {
00096     prepareGeometryChange();
00097     m_end = end;
00098     update();
00099 }
00100 
00101 void ConstraintGraphicsItem::updateItem( const QPointF& start,const QPointF& end )
00102 {
00103     qDebug() << "ConstraintGraphicsItem::updateItem("<<start<<end<<")";
00104     setStart( start );
00105     setEnd( end );
00106 }
00107 

kdgantt

Skip menu "kdgantt"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal