src/gui/graphicsview/qgraphicsitem.cpp File Reference

#include "qgraphicsitem.h"
#include "qgraphicsscene.h"
#include "qgraphicsscene_p.h"
#include "qgraphicssceneevent.h"
#include "qgraphicsview.h"
#include <QtCore/qbitarray.h>
#include <QtCore/qdebug.h>
#include <QtCore/qpoint.h>
#include <QtCore/qtimer.h>
#include <QtCore/qvariant.h>
#include <QtGui/qapplication.h>
#include <QtGui/qbitmap.h>
#include <QtGui/qpainter.h>
#include <QtGui/qpainterpath.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qevent.h>
#include <private/qgraphicsitem_p.h>
#include <private/qtextcontrol_p.h>
#include <private/qtextengine_p.h>
#include <math.h>
#include "moc_qgraphicsitem.cpp"

Include dependency graph for qgraphicsitem.cpp:

Go to the source code of this file.

Classes

class  QGraphicsItemCustomDataStore
class  QAbstractGraphicsShapeItemPrivate
class  QGraphicsPathItemPrivate
class  QGraphicsRectItemPrivate
class  QGraphicsEllipseItemPrivate
class  QGraphicsPolygonItemPrivate
class  QGraphicsLineItemPrivate
class  QGraphicsPixmapItemPrivate
class  QGraphicsTextItemPrivate
class  QGraphicsSimpleTextItemPrivate
class  QGraphicsItemGroupPrivate

Functions

 Q_GLOBAL_STATIC (QGraphicsItemCustomDataStore, qt_dataStore)
static void qt_graphicsItem_fullUpdate (QGraphicsItem *item)
static QPainterPath qt_graphicsItem_shapeFromPath (const QPainterPath &path, const QPen &pen)
static QRectF setupTextLayout (QTextLayout *layout)
QDebug operator<< (QDebug debug, QGraphicsItem *item)


Function Documentation

QDebug operator<< ( QDebug  debug,
QGraphicsItem item 
)

Definition at line 5821 of file qgraphicsitem.cpp.

05822 {
05823     if (!item) {
05824         debug << "QGraphicsItem(0)";
05825         return debug;
05826     }
05827 
05828     QStringList flags;
05829     if (item->isVisible()) flags << QLatin1String("isVisible");
05830     if (item->isEnabled()) flags << QLatin1String("isEnabled");
05831     if (item->isSelected()) flags << QLatin1String("isSelected");
05832     if (item->hasFocus()) flags << QLatin1String("HasFocus");
05833 
05834     debug << "QGraphicsItem(this =" << ((void*)item)
05835           << ", parent =" << ((void*)item->parentItem())
05836           << ", pos =" << item->pos()
05837           << ", z =" << item->zValue() << ", flags = {"
05838           << flags.join(QLatin1String("|")) << " })";
05839     return debug;
05840 }

Q_GLOBAL_STATIC ( QGraphicsItemCustomDataStore  ,
qt_dataStore   
)

static void qt_graphicsItem_fullUpdate ( QGraphicsItem item  )  [static]

Definition at line 362 of file qgraphicsitem.cpp.

References QGraphicsItem::children(), and QGraphicsItem::update().

Referenced by QGraphicsItem::setMatrix(), QGraphicsItem::setPos(), and QGraphicsItem::setZValue().

00363 {
00364     item->update();
00365     foreach (QGraphicsItem *child, item->children())
00366         qt_graphicsItem_fullUpdate(child);
00367 }

Here is the call graph for this function:

static QPainterPath qt_graphicsItem_shapeFromPath ( const QPainterPath path,
const QPen pen 
) [static]

Definition at line 375 of file qgraphicsitem.cpp.

References QPen::capStyle(), QPainterPathStroker::createStroke(), QPen::joinStyle(), QPen::miterLimit(), p, path, QPainterPathStroker::setCapStyle(), QPainterPathStroker::setJoinStyle(), QPainterPathStroker::setMiterLimit(), QPainterPathStroker::setWidth(), and QPen::widthF().

Referenced by QGraphicsPolygonItem::shape(), QGraphicsPathItem::shape(), QGraphicsLineItem::shape(), QGraphicsEllipseItem::shape(), and QGraphicsRectItem::shape().

00376 {
00377     // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
00378     // if we pass a value of 0.0 to QPainterPathStroker::setWidth()
00379     const qreal penWidthZero = qreal(0.00000001);
00380 
00381     if (path == QPainterPath())
00382         return path;
00383     QPainterPathStroker ps;
00384     ps.setCapStyle(pen.capStyle());
00385     ps.setWidth(pen.widthF() <= 0.0 ? penWidthZero : pen.widthF());
00386     ps.setJoinStyle(pen.joinStyle());
00387     ps.setMiterLimit(pen.miterLimit());
00388     QPainterPath p = ps.createStroke(path);
00389     p.addPath(path);
00390     return p;
00391 }

Here is the call graph for this function:

static QRectF setupTextLayout ( QTextLayout layout  )  [static]

Definition at line 5381 of file qgraphicsitem.cpp.

References i, layout, qMax(), and y.

Referenced by QGraphicsSimpleTextItem::paint(), and QGraphicsSimpleTextItemPrivate::updateBoundingRect().

05382 {
05383     layout->setCacheEnabled(true);
05384     layout->beginLayout();
05385     while (layout->createLine().isValid())
05386         ;
05387     layout->endLayout();
05388     qreal maxWidth = 0;
05389     qreal y = 0;
05390     for (int i = 0; i < layout->lineCount(); ++i) {
05391         QTextLine line = layout->lineAt(i);
05392         maxWidth = qMax(maxWidth, line.naturalTextWidth());
05393         line.setPosition(QPointF(0, y));
05394         y += line.height();
05395     }
05396     return QRectF(0, 0, maxWidth, y);
05397 }

Here is the call graph for this function:


Generated on Thu Mar 15 13:17:37 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1