homescreenapp/hsdomainmodel/src/hswidgethost.cpp
changeset 51 4785f57bf3d4
parent 46 23b5d6a29cce
child 55 03646e8da489
equal deleted inserted replaced
46:23b5d6a29cce 51:4785f57bf3d4
    68 HsWidgetHost::HsWidgetHost(int databaseId, QGraphicsItem *parent)
    68 HsWidgetHost::HsWidgetHost(int databaseId, QGraphicsItem *parent)
    69     : HbWidget(parent),
    69     : HbWidget(parent),
    70       mWidget(0),
    70       mWidget(0),
    71       mPage(0),
    71       mPage(0),
    72       mState(Unloaded),
    72       mState(Unloaded),
    73       mDatabaseId(databaseId),
    73       mDatabaseId(databaseId)
    74       mTapAndHoldIcon(0)
       
    75 {
    74 {
    76     setFlags(QGraphicsItem::ItemClipsChildrenToShape);
    75     setFlags(QGraphicsItem::ItemClipsChildrenToShape);
    77 
    76 
    78     HsDatabase *db = HsDatabase::instance();
    77     HsDatabase *db = HsDatabase::instance();
    79 
    78 
   145         return false;
   144         return false;
   146     }
   145     }
   147 
   146 
   148     setProperty("isOnline", mIsOnlineProperty);
   147     setProperty("isOnline", mIsOnlineProperty);
   149 	setProperty("rootPath", mRootPathProperty);
   148 	setProperty("rootPath", mRootPathProperty);
   150 
   149     
       
   150     setMethod("isPannable(QGraphicsSceneMouseEvent*)", mIsPannable);
   151     setMethod("onInitialize()", mOnInitializeMethod);
   151     setMethod("onInitialize()", mOnInitializeMethod);
   152     setMethod("onUninitialize()", mOnUninitializeMethod);
   152     setMethod("onUninitialize()", mOnUninitializeMethod);
   153 
   153 
   154     if (hasSignal("setPreferences(const QStringList&)")) {
   154     if (hasSignal("setPreferences(const QStringList&)")) {
   155         connect(mWidget, SIGNAL(setPreferences(QStringList)),
   155         connect(mWidget, SIGNAL(setPreferences(QStringList)),
   360     QString key = orientation == Qt::Vertical ?
   360     QString key = orientation == Qt::Vertical ?
   361         "portrait" : "landscape";
   361         "portrait" : "landscape";
   362 
   362 
   363     return db->deleteWidgetPresentation(mDatabaseId, key);
   363     return db->deleteWidgetPresentation(mDatabaseId, key);
   364 }
   364 }
   365 
   365 /*!
       
   366     Check wheter widget uses pan gestures
       
   367     Return true if successfull.
       
   368 */
       
   369 bool HsWidgetHost::isPannable(QGraphicsSceneMouseEvent *event)
       
   370 {
       
   371     bool ret(false);
       
   372     mIsPannable.invoke(mWidget,Q_RETURN_ARG(bool,ret),Q_ARG(QGraphicsSceneMouseEvent *,event));
       
   373     return ret;
       
   374 }
   366 /*!
   375 /*!
   367     \fn void HsWidgetHost::widgetFinished()
   376     \fn void HsWidgetHost::widgetFinished()
   368     This signal is emitten after the contained widget
   377     This signal is emitted after the contained widget
   369     reported is completion.
   378     reported is completion.
   370 */
   379 */
   371 
   380 
   372 /*!
   381 /*!
   373     \fn void HsWidgetHost::widgetError()
   382     \fn void HsWidgetHost::widgetError()
   374     This signal is emitten after the contained widget
   383     This signal is emitted after the contained widget
   375     reported an error.
   384     reported an error.
   376 */
   385 */
   377 
   386 
   378 /*!
   387 /*!
   379     \fn void HsWidgetHost::widgetResized()
   388     \fn void HsWidgetHost::widgetResized()
   380     This signal is emitten after the contained widget
   389     This signal is emitted after the contained widget
   381     sends a resize event.
   390     sends a resize event.
       
   391 */
       
   392 /*!
       
   393     \fn void HsWidgetHost::mousePressEventIgnored()
       
   394     This signal is emitted if managed widget ignores mouse press event
       
   395 
   382 */
   396 */
   383 
   397 
   384 /*!
   398 /*!
   385     Calls the widget's onInitialize() slot if the
   399     Calls the widget's onInitialize() slot if the
   386     widget defines it.
   400     widget defines it.
   395     mRootPathProperty.write(mWidget, component->rootPath());
   409     mRootPathProperty.write(mWidget, component->rootPath());
   396     setPreferencesToWidget();
   410     setPreferencesToWidget();
   397     setOnline(HsScene::instance()->isOnline());
   411     setOnline(HsScene::instance()->isOnline());
   398     mOnInitializeMethod.invoke(mWidget);
   412     mOnInitializeMethod.invoke(mWidget);
   399 
   413 
   400     mState = Initialized;
   414     if (mState != Finished &&
       
   415         mState != Faulted) {
       
   416         mState = Initialized;
       
   417     }
   401 }
   418 }
   402 
   419 
   403 /*!
   420 /*!
   404     Calls the widget's onShow() slot if the
   421     Calls the widget's onShow() slot if the
   405     widget defines it.
   422     widget defines it.
   512     animationGroup->addAnimation(animation);
   529     animationGroup->addAnimation(animation);
   513     */
   530     */
   514 
   531 
   515     animationGroup->start(QAbstractAnimation::DeleteWhenStopped);
   532     animationGroup->start(QAbstractAnimation::DeleteWhenStopped);
   516 }
   533 }
   517 
   534 /*!
   518 /*!
   535     Overwritten to stop event propogation
   519     Starts the tap-and-hold animation.
   536 */
   520 */
   537 void HsWidgetHost::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) 
   521 void HsWidgetHost::startTapAndHoldAnimation()
   538 { 
   522 {
   539     Q_UNUSED(event) 
   523     mTapAndHoldIcon = new HbIconItem("tapandhold_animation");
   540 }
   524     mTapAndHoldIcon->setZValue(1e6);
   541 /*!
   525     mTapAndHoldIcon->setParentItem(this);
   542     Overwritten to stop event propogation
   526 }
   543 */
   527 
   544 void HsWidgetHost::mouseMoveEvent(QGraphicsSceneMouseEvent *event) 
   528 /*!
   545 { 
   529     Stops the tap-and-hold animation.
   546     Q_UNUSED(event)  
   530 */
   547 }
   531 void HsWidgetHost::stopTapAndHoldAnimation()
   548 /*!
   532 {
   549     Overwritten to stop event propogation
   533     delete mTapAndHoldIcon;
   550 */
   534     mTapAndHoldIcon = 0;
   551 void HsWidgetHost::mousePressEvent(QGraphicsSceneMouseEvent *event) 
   535 }
   552 { 
   536 
   553     Q_UNUSED(event)  
       
   554     
       
   555 }
       
   556 /*!
       
   557     Overwritten to stop event propogation
       
   558 */
       
   559 void HsWidgetHost::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { 
       
   560     Q_UNUSED(event)
       
   561 }    
   537 /*!
   562 /*!
   538     Filters resize events from widgets and resizes inside max/min size boundaries if needed.
   563     Filters resize events from widgets and resizes inside max/min size boundaries if needed.
   539 */
   564 */
   540 bool HsWidgetHost::eventFilter(QObject *obj, QEvent *event)
   565 bool HsWidgetHost::eventFilter(QObject *obj, QEvent *event)
   541 {
   566 {
   658     when it has finished its execution and is ready for
   683     when it has finished its execution and is ready for
   659     removal from the homescreen.
   684     removal from the homescreen.
   660 */
   685 */
   661 void HsWidgetHost::onFinished()
   686 void HsWidgetHost::onFinished()
   662 {
   687 {
       
   688     mState = Finished;
   663     emit widgetFinished(this);
   689     emit widgetFinished(this);
   664 }
   690 }
   665 
   691 
   666 /*!
   692 /*!
   667     This slot reacts to the widgets error() signal, if it was
   693     This slot reacts to the widgets error() signal, if it was