Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/graphicsview/qgraphicsitem.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4747#include <QtCore/qvariant.h>
    4848#include <QtCore/qrect.h>
     49#include <QtCore/qscopedpointer.h>
    4950#include <QtGui/qpainterpath.h>
    5051#include <QtGui/qpixmap.h>
     
    6364class QCursor;
    6465class QFocusEvent;
     66class QGraphicsEffect;
    6567class QGraphicsItemGroup;
     68class QGraphicsObject;
    6669class QGraphicsSceneContextMenuEvent;
    6770class QGraphicsSceneDragDropEvent;
     
    7174class QGraphicsSceneWheelEvent;
    7275class QGraphicsScene;
     76class QGraphicsTransform;
    7377class QGraphicsWidget;
    7478class QInputMethodEvent;
     
    9599        ItemIgnoresParentOpacity = 0x40,
    96100        ItemDoesntPropagateOpacityToChildren = 0x80,
    97         ItemStacksBehindParent = 0x100
     101        ItemStacksBehindParent = 0x100,
     102        ItemUsesExtendedStyleOption = 0x200,
     103        ItemHasNoContents = 0x400,
     104        ItemSendsGeometryChanges = 0x800,
     105        ItemAcceptsInputMethod = 0x1000,
     106        ItemNegativeZStacksBehindParent = 0x2000,
     107        ItemIsPanel = 0x4000,
     108        ItemIsFocusScope = 0x8000, // internal
     109        ItemSendsScenePositionChanges = 0x10000
     110        // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
    98111    };
    99112    Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
     
    126139        ItemZValueHasChanged,
    127140        ItemOpacityChange,
    128         ItemOpacityHasChanged
     141        ItemOpacityHasChanged,
     142        ItemScenePositionHasChanged
    129143    };
    130144
     
    135149    };
    136150
     151    enum PanelModality
     152    {
     153        NonModal,
     154        PanelModal,
     155        SceneModal
     156    };
     157
    137158    QGraphicsItem(QGraphicsItem *parent = 0
    138159#ifndef Q_QDOC
    139                   // obsolete argument
     160                  // ### obsolete argument
    140161                  , QGraphicsScene *scene = 0
    141162#endif
     
    147168    QGraphicsItem *parentItem() const;
    148169    QGraphicsItem *topLevelItem() const;
     170    QGraphicsObject *parentObject() const;
    149171    QGraphicsWidget *parentWidget() const;
    150172    QGraphicsWidget *topLevelWidget() const;
    151173    QGraphicsWidget *window() const;
     174    QGraphicsItem *panel() const;
    152175    void setParentItem(QGraphicsItem *parent);
    153176    QList<QGraphicsItem *> children() const; // ### obsolete
     
    155178    bool isWidget() const;
    156179    bool isWindow() const;
     180    bool isPanel() const;
     181
     182    QGraphicsObject *toGraphicsObject();
     183    const QGraphicsObject *toGraphicsObject() const;
    157184
    158185    QGraphicsItemGroup *group() const;
     
    165192    CacheMode cacheMode() const;
    166193    void setCacheMode(CacheMode mode, const QSize &cacheSize = QSize());
     194
     195    PanelModality panelModality() const;
     196    void setPanelModality(PanelModality panelModality);
     197    bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = 0) const;
    167198
    168199#ifndef QT_NO_TOOLTIP
     
    197228    void setOpacity(qreal opacity);
    198229
     230#ifndef QT_NO_GRAPHICSEFFECT
     231    // Effect
     232    QGraphicsEffect *graphicsEffect() const;
     233    void setGraphicsEffect(QGraphicsEffect *effect);
     234#endif //QT_NO_GRAPHICSEFFECT
     235
    199236    Qt::MouseButtons acceptedMouseButtons() const;
    200237    void setAcceptedMouseButtons(Qt::MouseButtons buttons);
    201238
    202     bool acceptsHoverEvents() const; // obsolete
    203     void setAcceptsHoverEvents(bool enabled); // obsolete
     239    bool acceptsHoverEvents() const; // ### obsolete
     240    void setAcceptsHoverEvents(bool enabled); // ### obsolete
    204241    bool acceptHoverEvents() const;
    205242    void setAcceptHoverEvents(bool enabled);
     243    bool acceptTouchEvents() const;
     244    void setAcceptTouchEvents(bool enabled);
     245
     246    bool filtersChildEvents() const;
     247    void setFiltersChildEvents(bool enabled);
    206248
    207249    bool handlesChildEvents() const;
    208250    void setHandlesChildEvents(bool enabled);
     251
     252    bool isActive() const;
     253    void setActive(bool active);
    209254
    210255    bool hasFocus() const;
    211256    void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason);
    212257    void clearFocus();
     258
     259    QGraphicsItem *focusProxy() const;
     260    void setFocusProxy(QGraphicsItem *item);
     261
     262    QGraphicsItem *focusItem() const;
     263    QGraphicsItem *focusScopeItem() const;
    213264
    214265    void grabMouse();
     
    220271    QPointF pos() const;
    221272    inline qreal x() const { return pos().x(); }
     273    void setX(qreal x);
    222274    inline qreal y() const { return pos().y(); }
     275    void setY(qreal y);
    223276    QPointF scenePos() const;
    224277    void setPos(const QPointF &pos);
     
    240293    void setTransform(const QTransform &matrix, bool combine = false);
    241294    void resetTransform();
    242    
    243     void rotate(qreal angle);
    244     void scale(qreal sx, qreal sy);
    245     void shear(qreal sh, qreal sv);
    246     void translate(qreal dx, qreal dy);
     295
     296    void rotate(qreal angle);           // ### obsolete
     297    void scale(qreal sx, qreal sy);     // ### obsolete
     298    void shear(qreal sh, qreal sv);     // ### obsolete
     299    void translate(qreal dx, qreal dy); // ### obsolete
     300
     301    void setRotation(qreal angle);
     302    qreal rotation() const;
     303
     304    void setScale(qreal scale);
     305    qreal scale() const;
     306
     307    QList<QGraphicsTransform *> transformations() const;
     308    void setTransformations(const QList<QGraphicsTransform *> &transformations);
     309
     310    QPointF transformOriginPoint() const;
     311    void setTransformOriginPoint(const QPointF &origin);
     312    inline void setTransformOriginPoint(qreal ax, qreal ay)
     313    { setTransformOriginPoint(QPointF(ax,ay)); }
     314
    247315    virtual void advance(int phase);
    248316
     
    250318    qreal zValue() const;
    251319    void setZValue(qreal z);
     320    void stackBefore(const QGraphicsItem *sibling);
    252321
    253322    // Hit test
     
    337406    void setData(int key, const QVariant &value);
    338407
     408    Qt::InputMethodHints inputMethodHints() const;
     409    void setInputMethodHints(Qt::InputMethodHints hints);
     410
    339411    enum {
    340412        Type = 1,
     
    381453    QGraphicsItem(QGraphicsItemPrivate &dd,
    382454                  QGraphicsItem *parent, QGraphicsScene *scene);
    383     QGraphicsItemPrivate *d_ptr;
     455    QScopedPointer<QGraphicsItemPrivate> d_ptr;
    384456
    385457    void addToIndex();
     
    394466    friend class QGraphicsScenePrivate;
    395467    friend class QGraphicsSceneFindItemBspTreeVisitor;
     468    friend class QGraphicsSceneBspTree;
    396469    friend class QGraphicsView;
    397470    friend class QGraphicsViewPrivate;
     471    friend class QGraphicsObject;
    398472    friend class QGraphicsWidget;
    399473    friend class QGraphicsWidgetPrivate;
    400474    friend class QGraphicsProxyWidgetPrivate;
     475    friend class QGraphicsSceneIndex;
     476    friend class QGraphicsSceneIndexPrivate;
     477    friend class QGraphicsSceneBspTreeIndex;
     478    friend class QGraphicsSceneBspTreeIndexPrivate;
     479    friend class QGraphicsItemEffectSourcePrivate;
     480    friend class QGraphicsTransformPrivate;
     481    friend class QGestureManager;
    401482    friend class ::tst_QGraphicsItem;
    402483    friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *);
     
    405486
    406487Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags)
     488Q_DECLARE_INTERFACE(QGraphicsItem, "com.trolltech.Qt.QGraphicsItem")
    407489
    408490inline void QGraphicsItem::setPos(qreal ax, qreal ay)
     
    451533{ return mapRectFromScene(QRectF(ax, ay, w, h)); }
    452534
     535
     536class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
     537{
     538    Q_OBJECT
     539    Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false)
     540    Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
     541    Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
     542    Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
     543    Q_PROPERTY(QPointF pos READ pos WRITE setPos)
     544    Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
     545    Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
     546    Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged)
     547    Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
     548    Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
     549    Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
     550    Q_INTERFACES(QGraphicsItem)
     551public:
     552    QGraphicsObject(QGraphicsItem *parent = 0);
     553
     554    // ### Qt 5: Disambiguate
     555#ifdef Q_NO_USING_KEYWORD
     556    const QObjectList &children() const { return QObject::children(); }
     557#else
     558    using QObject::children;
     559#endif
     560
     561    void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
     562    void ungrabGesture(Qt::GestureType type);
     563
     564Q_SIGNALS:
     565    void parentChanged();
     566    void opacityChanged();
     567    void visibleChanged();
     568    void enabledChanged();
     569    void xChanged();
     570    void yChanged();
     571    void zChanged();
     572    void rotationChanged();
     573    void scaleChanged();
     574
     575protected:
     576    QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene);
     577private:
     578    friend class QGraphicsItem;
     579    friend class QGraphicsItemPrivate;
     580};
     581
     582
    453583class QAbstractGraphicsShapeItemPrivate;
    454584class Q_GUI_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem
     
    457587    QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0
    458588#ifndef Q_QDOC
    459                                // obsolete argument
     589                               // ### obsolete argument
    460590                               , QGraphicsScene *scene = 0
    461591#endif
     
    487617    QGraphicsPathItem(QGraphicsItem *parent = 0
    488618#ifndef Q_QDOC
    489                       // obsolete argument
     619                      // ### obsolete argument
    490620                      , QGraphicsScene *scene = 0
    491621#endif
     
    493623    QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0
    494624#ifndef Q_QDOC
    495                       // obsolete argument
     625                      // ### obsolete argument
    496626                      , QGraphicsScene *scene = 0
    497627#endif
     
    530660    QGraphicsRectItem(QGraphicsItem *parent = 0
    531661#ifndef Q_QDOC
    532                       // obsolete argument
     662                      // ### obsolete argument
    533663                      , QGraphicsScene *scene = 0
    534664#endif
     
    536666    QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0
    537667#ifndef Q_QDOC
    538                       // obsolete argument
     668                      // ### obsolete argument
    539669                      , QGraphicsScene *scene = 0
    540670#endif
     
    542672    QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0
    543673#ifndef Q_QDOC
    544                       // obsolete argument
     674                      // ### obsolete argument
    545675                      , QGraphicsScene *scene = 0
    546676#endif
     
    583713    QGraphicsEllipseItem(QGraphicsItem *parent = 0
    584714#ifndef Q_QDOC
    585                          // obsolete argument
     715                         // ### obsolete argument
    586716                         , QGraphicsScene *scene = 0
    587717#endif
     
    589719    QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0
    590720#ifndef Q_QDOC
    591                          // obsolete argument
     721                         // ### obsolete argument
    592722                         , QGraphicsScene *scene = 0
    593723#endif
     
    595725    QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0
    596726#ifndef Q_QDOC
    597                          // obsolete argument
     727                         // ### obsolete argument
    598728                         , QGraphicsScene *scene = 0
    599729#endif
     
    642772    QGraphicsPolygonItem(QGraphicsItem *parent = 0
    643773#ifndef Q_QDOC
    644                          // obsolete argument
     774                         // ### obsolete argument
    645775                         , QGraphicsScene *scene = 0
    646776#endif
     
    649779                         QGraphicsItem *parent = 0
    650780#ifndef Q_QDOC
    651                          // obsolete argument
     781                         // ### obsolete argument
    652782                         , QGraphicsScene *scene = 0
    653783#endif
     
    689819    QGraphicsLineItem(QGraphicsItem *parent = 0
    690820#ifndef Q_QDOC
    691                       // obsolete argument
     821                      // ### obsolete argument
    692822                      , QGraphicsScene *scene = 0
    693823#endif
     
    695825    QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0
    696826#ifndef Q_QDOC
    697                       // obsolete argument
     827                      // ### obsolete argument
    698828                      , QGraphicsScene *scene = 0
    699829#endif
     
    701831    QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0
    702832#ifndef Q_QDOC
    703                       // obsolete argument
     833                      // ### obsolete argument
    704834                      , QGraphicsScene *scene = 0
    705835#endif
     
    749879    QGraphicsPixmapItem(QGraphicsItem *parent = 0
    750880#ifndef Q_QDOC
    751                         // obsolete argument
     881                        // ### obsolete argument
    752882                        , QGraphicsScene *scene = 0
    753883#endif
     
    755885    QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0
    756886#ifndef Q_QDOC
    757                         // obsolete argument
     887                        // ### obsolete argument
    758888                        , QGraphicsScene *scene = 0
    759889#endif
     
    802932class QTextDocument;
    803933class QTextCursor;
    804 class Q_GUI_EXPORT QGraphicsTextItem : public QObject, public QGraphicsItem
     934class Q_GUI_EXPORT QGraphicsTextItem : public QGraphicsObject
    805935{
    806936    Q_OBJECT
     
    811941    QGraphicsTextItem(QGraphicsItem *parent = 0
    812942#ifndef Q_QDOC
    813                       // obsolete argument
     943                      // ### obsolete argument
    814944                      , QGraphicsScene *scene = 0
    815945#endif
     
    817947    QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0
    818948#ifndef Q_QDOC
    819                       // obsolete argument
     949                      // ### obsolete argument
    820950                      , QGraphicsScene *scene = 0
    821951#endif
     
    9121042    QGraphicsSimpleTextItem(QGraphicsItem *parent = 0
    9131043#ifndef Q_QDOC
    914                             // obsolete argument
     1044                            // ### obsolete argument
    9151045                            , QGraphicsScene *scene = 0
    9161046#endif
     
    9181048    QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0
    9191049#ifndef Q_QDOC
    920                             // obsolete argument
     1050                            // ### obsolete argument
    9211051                            , QGraphicsScene *scene = 0
    9221052#endif
     
    9581088    QGraphicsItemGroup(QGraphicsItem *parent = 0
    9591089#ifndef Q_QDOC
    960                        // obsolete argument
     1090                       // ### obsolete argument
    9611091                       , QGraphicsScene *scene = 0
    9621092#endif
     
    9951125#ifndef QT_NO_DEBUG_STREAM
    9961126Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem *item);
     1127Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsObject *item);
    9971128Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change);
    9981129Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag);
     
    10141145
    10151146#endif // QGRAPHICSITEM_H
    1016 
Note: See TracChangeset for help on using the changeset viewer.