51 #include <private/qdeclarativedebugtrace_p.h> 52 #include <private/qdeclarativeinspectorservice_p.h> 67 #include <QtCore/qabstractanimation.h> 68 #include <private/qgraphicsview_p.h> 69 #include <private/qdeclarativeitem_p.h> 70 #include <private/qabstractanimation_p.h> 71 #include <private/qdeclarativeitemchangelistener_p.h> 84 virtual void keyReleaseEvent(
QKeyEvent *);
135 : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0),
component(0),
142 inline QSize rootObjectSize()
const;
172 if (!source.isEmpty()) {
175 q->continueExecute();
187 resizetimer.start(0,q);
304 q->scene()->setStickyFocus(
true);
306 #ifdef QDECLARATIVEVIEW_NOBACKGROUND 385 return d->engine->rootContext();
438 return d->component->errors();
463 if (
d->resizeMode == mode)
466 if (
d->declarativeItemRoot) {
472 }
else if (
d->graphicsWidgetRoot) {
474 d->graphicsWidgetRoot->removeEventFilter(
this);
478 d->resizeMode = mode;
487 if (declarativeItemRoot) {
493 }
else if (graphicsWidgetRoot) {
495 graphicsWidgetRoot->installEventFilter(q);
506 if (declarativeItemRoot) {
508 QSize newSize =
QSize(declarativeItemRoot->width(), declarativeItemRoot->height());
509 if (newSize.
isValid() && newSize != q->size()) {
513 if (!
qFuzzyCompare(q->width(), declarativeItemRoot->width()))
514 declarativeItemRoot->
setWidth(q->width());
515 if (!
qFuzzyCompare(q->height(), declarativeItemRoot->height()))
516 declarativeItemRoot->setHeight(q->height());
518 }
else if (graphicsWidgetRoot) {
520 QSize newSize =
QSize(graphicsWidgetRoot->size().width(), graphicsWidgetRoot->size().height());
521 if (newSize.
isValid() && newSize != q->size()) {
525 QSizeF newSize =
QSize(q->size().width(), q->size().height());
526 if (newSize.
isValid() && newSize != graphicsWidgetRoot->size()) {
527 graphicsWidgetRoot->resize(newSize);
536 QSize rootObjectSize(0,0);
537 int widthCandidate = -1;
538 int heightCandidate = -1;
541 widthCandidate = size.
width();
542 heightCandidate = size.
height();
544 if (widthCandidate > 0) {
545 rootObjectSize.
setWidth(widthCandidate);
547 if (heightCandidate > 0) {
548 rootObjectSize.
setHeight(heightCandidate);
550 return rootObjectSize;
556 return d->resizeMode;
567 if (
d->component->isError()) {
576 QObject *obj =
d->component->create();
578 if(
d->component->isError()) {
597 if (
d->root == obj || !
scene())
599 if (
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem *>(obj)) {
601 d->root = declarativeItem;
602 d->declarativeItemRoot = declarativeItem;
603 }
else if (
QGraphicsObject *graphicsObject = qobject_cast<QGraphicsObject *>(obj)) {
605 d->root = graphicsObject;
606 if (graphicsObject->isWidget()) {
609 qWarning() <<
"QDeclarativeView::resizeMode is not honored for components of type QGraphicsObject";
612 qWarning() <<
"QDeclarativeView only supports loading of root objects that derive from QGraphicsObject";
631 d->initialSize =
d->rootObjectSize();
632 if (
d->initialSize !=
size()) {
652 if (!e || e->
timerId() ==
d->resizetimer.timerId()) {
654 d->resizetimer.stop();
663 if (
d->graphicsWidgetRoot) {
682 QSize rootObjectSize =
d->rootObjectSize();
683 if (rootObjectSize.
isEmpty()) {
686 return rootObjectSize;
696 return d->initialSize;
722 if (
d->declarativeItemRoot) {
724 }
else if (
d->root) {
744 if (frameRateDebug())
745 time =
d->frameTimer.restart();
751 if (frameRateDebug())
752 qDebug() <<
"paintEvent:" <<
d->frameTimer.elapsed() <<
"time since last frame:" << time;
754 #if QT_SHOW_DECLARATIVEVIEW_FPS 760 }
else if (timer.
elapsed() > 5000) {
762 qDebug(
"Average time per frame: %f ms (%i fps)", avgtime,
int(1000 / avgtime));
QDeclarativeContext * rootContext() const
This function returns the root of the context hierarchy.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse release...
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
Status
Emitted after component "startup" has completed.
The QKeyEvent class describes a key event.
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
QDeclarativeView(QWidget *parent=0)
Constructs a QDeclarativeView with the given parent.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
QDeclarativeGuard< QGraphicsWidget > graphicsWidgetRoot
virtual void paintEvent(QPaintEvent *event)
The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface...
virtual ~QDeclarativeView()
Destroys the view.
static void addEvent(EventType)
ResizeMode
This enum specifies how to resize the view.
QDeclarativeGuard< QDeclarativeItem > declarativeItemRoot
void start()
Sets this time to the current time.
virtual void setRootObject(QObject *obj)
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse release...
qreal width() const
Returns the width.
QDeclarativeViewPrivate()
qreal height() const
Returns the height.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
QList< QDeclarativeError > errors() const
Return the list of errors that occurred during the last compile or create operation.
virtual bool eventFilter(QObject *watched, QEvent *e)
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
void addItem(QGraphicsItem *item)
Adds or moves the item and all its childen to this scene.
static QDeclarativeInspectorService * instance()
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse press e...
The QUrl class provides a convenient interface for working with URLs.
void setHeight(int h)
Sets the height to the given height.
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
QDeclarativeScene(QObject *parent=0)
The QObject class is the base class of all Qt objects.
virtual void keyPressEvent(QKeyEvent *event)
This event handler, for event keyEvent, can be reimplemented in a subclass to receive keypress events...
The QElapsedTimer class provides a fast way to calculate elapsed times.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
void setWidth(int w)
Sets the width to the given width.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse press e...
Q_CORE_EXPORT void qDebug(const char *,...)
virtual void timerEvent(QTimerEvent *)
If the QTimerEvent {timer event} e is this view's resize timer, sceneResized() is emitted...
The QTime class provides clock time functions.
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler, for event keyEvent, can be reimplemented in a subclass to receive key release eve...
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual void keyReleaseEvent(QKeyEvent *)
This event handler, for event keyEvent, can be reimplemented in a subclass to receive key release eve...
The QRectF class defines a rectangle in the plane using floating point precision. ...
The QLayoutItem class provides an abstract item that a QLayout manipulates.
The QDeclarativeComponent class encapsulates a QML component definition.
~QDeclarativeViewPrivate()
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse move ev...
The QDeclarativeItem class provides the most basic of all visual items in QML.
void resizeEvent(QResizeEvent *event)
Reimplemented Function
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
void removeView(QDeclarativeView *)
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
QGraphicsObject * rootObject() const
Returns the view's root QGraphicsObject {item}.
The QResizeEvent class contains event parameters for resize events.
void setResizeMode(ResizeMode)
Q_CORE_EXPORT void qWarning(const char *,...)
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
The QDeclarativeError class encapsulates a QML error.
void addView(QDeclarativeView *)
static qreal component(const QPointF &point, unsigned int i)
virtual void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &)
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
void update(qreal x, qreal y, qreal w, qreal h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static void endRange(RangeType)
static void startRange(RangeType)
QDeclarativeGuard< QGraphicsObject > root
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types)
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
bool event(QEvent *event)
Reimplemented Function
#define Q_DECLARE_PUBLIC(Class)
void setSource(const QUrl &)
Sets the source to the url, loads the QML component and instantiates it.
void setSceneRect(const QRectF &rect)
The QTimerEvent class contains parameters that describe a timer event.
The QDeclarativeEngine class provides an environment for instantiating QML components.
ResizeMode resizeMode() const
QDeclarativeEngine * engine() const
Returns a pointer to the QDeclarativeEngine used for instantiating QML Components.
const QSize & size() const
Returns the new size of the widget.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse move ev...
QObject * parent() const
Returns a pointer to the parent object.
void sceneResized(QSize size)
This signal is emitted when the view is resized to size.
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
The QDeclarativeContext class defines a context within a QML engine.
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
QSize initialSize() const
Returns the initial size of the root object.
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
The QBasicTimer class provides timer events for objects.
void paintEvent(QPaintEvent *event)
Reimplemented Function
The QSize class defines the size of a two-dimensional object using integer point precision.
void statusChanged(QDeclarativeView::Status)
This signal is emitted when the component's current status changes.
QDeclarativeView::ResizeMode resizeMode
QSize rootObjectSize() const
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Status
Specifies the loading status of the QDeclarativeView.
The QPaintEvent class contains event parameters for paint events.
QDeclarativeComponent * component
The QGraphicsObject class provides a base class for all graphics items that require signals...
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
QGraphicsScene * scene() const
Returns a pointer to the scene that is currently visualized in the view.
virtual void resizeEvent(QResizeEvent *)
This function handles the QResizeEvent {resize event} e.
QSize sizeHint() const
Preferred size follows the root object geometry.
virtual void keyPressEvent(QKeyEvent *)
This event handler, for event keyEvent, can be reimplemented in a subclass to receive keypress events...
QDeclarativeEngine * engine