diff options
author | Dominik Kapusta <dominik.kapusta@teleca.com> | 2010-08-19 15:15:52 +0200 |
---|---|---|
committer | Tomas Junnonen <tomas.junnonen@nokia.com> | 2010-08-20 17:14:28 +0300 |
commit | 5c0eaf65f8df722af92981999f19b6582f665bfd (patch) | |
tree | 4745c4ac04bfdc6d6bc30381ac143b10433c090a | |
parent | 51c67c3f5f483aa5d847a222cb1ef5385c64d892 (diff) |
Changes: Call MApplicationPage::createContent() from doEnterDisplayEvent().
RevBy: Tomas Junnonen
Details: MWidgetPrivate::do{Enter,Exit}DisplayEvent() are made virtual.
MApplicationPagePrivate::prepareForAppearance() functionality moved to
doEnterDisplayEvent().
This removes the requirement to call the base class method when reimplementing
enterDisplayEvent.
-rw-r--r-- | doc/src/news.dox | 1 | ||||
-rw-r--r-- | src/corelib/widgets/core/mwidget.cpp | 6 | ||||
-rw-r--r-- | src/corelib/widgets/core/mwidget_p.h | 4 | ||||
-rw-r--r-- | src/corelib/widgets/mapplicationpage.cpp | 17 | ||||
-rw-r--r-- | src/corelib/widgets/mapplicationpage.h | 21 | ||||
-rw-r--r-- | src/corelib/widgets/mapplicationpage_p.h | 2 |
6 files changed, 18 insertions, 33 deletions
diff --git a/doc/src/news.dox b/doc/src/news.dox index 65db2406..26a78367 100644 --- a/doc/src/news.dox +++ b/doc/src/news.dox @@ -7,7 +7,6 @@ - Updated \subpage rotation document. - You can now simulate the multitouch pinch gesture by holding down the Ctrl key, then pressing and dragging with the left mouse button. - MSceneWindow::appear(QGraphicsScene *scene, MSceneWindow::DeletionPolicy policy); -- MApplicationPage::enterDisplayEvent() calls createContent() internally. When reimplementing this event handler in a subclass you have to call base class event handler to get your content created. \subsection Deprecated - MSceneWindow::appear(MSceneWindow::DeletionPolicy policy). Use appear(QGraphicsScene*) or diff --git a/src/corelib/widgets/core/mwidget.cpp b/src/corelib/widgets/core/mwidget.cpp index 0a4f5c30..9e545597 100644 --- a/src/corelib/widgets/core/mwidget.cpp +++ b/src/corelib/widgets/core/mwidget.cpp @@ -37,7 +37,6 @@ #include <QSwipeGesture> #include <mapplicationwindow.h> -#include <mapplicationpage.h> #include <mpannableviewport.h> #include <maction.h> #include <mcancelevent.h> @@ -226,11 +225,6 @@ void MWidget::onDisplayChangeEvent(MOnDisplayChangeEvent *event) void MWidget::enterDisplayEvent() { - // We are using here a hack which will allow reimplementing the enterDisplayEvent - // method in the application page without recompilation of all client applications. - // This needs to be deleted when API unfreeze will finally happen. - if(MApplicationPage* applicationPage = qobject_cast<MApplicationPage*>(this)) - applicationPage->MApplicationPage::enterDisplayEvent(); } void MWidget::exitDisplayEvent() diff --git a/src/corelib/widgets/core/mwidget_p.h b/src/corelib/widgets/core/mwidget_p.h index b88e1d26..0e43a108 100644 --- a/src/corelib/widgets/core/mwidget_p.h +++ b/src/corelib/widgets/core/mwidget_p.h @@ -29,8 +29,8 @@ public: MWidgetPrivate(); virtual ~MWidgetPrivate(); - void doEnterDisplayEvent(); - void doExitDisplayEvent(); + virtual void doEnterDisplayEvent(); + virtual void doExitDisplayEvent(); void sendOnDisplayChangeEvent(MWidget *widget, const QRectF *visibleSceneRect); void resolveIsOnDisplay(QGraphicsItem *item, const QRectF *visibleSceneRect, diff --git a/src/corelib/widgets/mapplicationpage.cpp b/src/corelib/widgets/mapplicationpage.cpp index b2a38867..d1681fc5 100644 --- a/src/corelib/widgets/mapplicationpage.cpp +++ b/src/corelib/widgets/mapplicationpage.cpp @@ -289,14 +289,21 @@ void MApplicationPage::actionEvent(QActionEvent *e) void MApplicationPage::enterDisplayEvent() { - Q_D(MApplicationPage); + MSceneWindow::enterDisplayEvent(); +} + +void MApplicationPagePrivate::doEnterDisplayEvent() +{ + Q_Q(MApplicationPage); - if (!d->contentCreated) { - d->contentCreated = true; - createContent(); + if (!contentCreated) { + contentCreated = true; + q->createContent(); } - d->updatePannableViewportPosition(); + updatePannableViewportPosition(); + + MWidgetPrivate::doEnterDisplayEvent(); } void MApplicationPagePrivate::setExposedContentRect(const QRectF &exposedContentRect) diff --git a/src/corelib/widgets/mapplicationpage.h b/src/corelib/widgets/mapplicationpage.h index dfe83a90..de914b2d 100644 --- a/src/corelib/widgets/mapplicationpage.h +++ b/src/corelib/widgets/mapplicationpage.h @@ -259,9 +259,7 @@ public: /*! * \brief This function will be called before page becomes visible. Override it in your page class - * and create content for a page. Framework calls this function only once, in enterDisplayEvent(). - * - * \sa enterDisplayEvent() + * and create content for a page. Framework calls this function only once. */ virtual void createContent(); @@ -464,18 +462,8 @@ public Q_SLOTS: protected: //! \reimp virtual void actionEvent(QActionEvent *); - //! \reimp_end - - /*! - * Reimplemented to call createContent() if it hasn't been called yet. - * - * \note When reimplementing this event in your inherited classes, be sure to call - * base class's event handler to set up your page content properly. Otherwise - * createContent() will never be called. - * - * \sa createContent() - */ virtual void enterDisplayEvent(); + //! \reimp_end private: #ifdef UNIT_TEST @@ -486,11 +474,6 @@ private: Q_DISABLE_COPY(MApplicationPage) Q_DECLARE_PRIVATE(MApplicationPage) - - // We are using a hack which will allow reimplementing the enterDisplayEvent - // method in the application page without recompilation of all client applications. - // This needs to be deleted when API unfreeze will finally happen. - friend class MWidget; }; Q_DECLARE_OPERATORS_FOR_FLAGS(MApplicationPage::Components) diff --git a/src/corelib/widgets/mapplicationpage_p.h b/src/corelib/widgets/mapplicationpage_p.h index 4c8b3e56..3d27c719 100644 --- a/src/corelib/widgets/mapplicationpage_p.h +++ b/src/corelib/widgets/mapplicationpage_p.h @@ -45,6 +45,8 @@ public: void init(); + virtual void doEnterDisplayEvent(); + void deleteCurrentCentralWidget(); void placeCentralWidget(QGraphicsWidget *widget); void setWidgetHeight(MWidget *w, qreal height); |