src/hbcore/gui/hbpopupmanager.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   274     Deliver mouseEvent to all HbPopupBackGround object for non-modal popups until event blocking
   274     Deliver mouseEvent to all HbPopupBackGround object for non-modal popups until event blocking
   275     item is found.
   275     item is found.
   276 */
   276 */
   277 void HbPopupManagerPrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
   277 void HbPopupManagerPrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
   278 {
   278 {
   279     foreach (QGraphicsItem *item, scene->items(mouseEvent->scenePos())) {
   279     //This function can be removed since popup background is handling the events
       
   280     Q_UNUSED(mouseEvent);
       
   281     /*foreach (QGraphicsItem *item, scene->items(mouseEvent->scenePos())) {
   280         if (eventBlockItem(item)) {
   282         if (eventBlockItem(item)) {
   281             break;
   283             break;
   282         }
   284         }
   283         if (item->type() == HbPrivate::ItemType_PopupBackGround) {
   285         if (item->type() == HbPrivate::ItemType_PopupBackGround) {
   284             static_cast<GraphicsItem *>(item)->sceneEvent(mouseEvent);
   286             static_cast<GraphicsItem *>(item)->sceneEvent(mouseEvent);
   285             // Finish loop if popup of background is modal
   287             // Finish loop if popup of background is modal
   286             if (static_cast<HbPopupBackGround *>(item)->isModal()) {
   288             if (static_cast<HbPopupBackGround *>(item)->isModal()) {
   287                 break;
   289                 break;
   288             }
   290             }
   289         }
   291         }
   290     }
   292     }*/
   291 }
   293 }
   292 
   294 
   293 /*
   295 /*
   294   Returns true if item is an event blocking item.
   296   Returns true if item is an event blocking item.
   295 */
   297 */
   342     popupCountRegisters[priority] = popupCountRegister;
   344     popupCountRegisters[priority] = popupCountRegister;
   343 }
   345 }
   344 
   346 
   345 void HbPopupManagerPrivate::eventHook(QEvent *event)
   347 void HbPopupManagerPrivate::eventHook(QEvent *event)
   346 {
   348 {
   347     if (event && event->type() == QEvent::GraphicsSceneMouseRelease && popupList.count() && scene) {
   349     Q_UNUSED(event);
       
   350     //This function can be removed since popup background is handling the events
       
   351    /* if (event && event->type() == QEvent::GraphicsSceneMouseRelease && popupList.count() && scene) {
   348         mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
   352         mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
   349     }
   353     }*/
   350 }
   354 }
   351 
   355 
   352 void HbPopupManagerPrivate::showPopup(HbPopup *popup)
   356 void HbPopupManagerPrivate::showPopup(HbPopup *popup)
   353 {
   357 {
   354     if (popup) {
   358     if (popup) {
   416 {
   420 {
   417     //delete the layoutproxy and remove the popup from parentItems list
   421     //delete the layoutproxy and remove the popup from parentItems list
   418     //only if its in its destruction
   422     //only if its in its destruction
   419     bool popupInDestruction = (HbPopupPrivate::d_ptr(popup))->inDestruction;
   423     bool popupInDestruction = (HbPopupPrivate::d_ptr(popup))->inDestruction;
   420     if ( parentItems.contains( popup ) && (popupInDestruction)) {
   424     if ( parentItems.contains( popup ) && (popupInDestruction)) {
   421         //HbPopupLayoutManager *parentItem = parentItems[popup];        
   425         HbPopupLayoutManager *parentItem = parentItems[popup];
   422         parentItems.remove( popup );
   426         parentItems.remove( popup );
   423         //delete parentItem;
   427         delete parentItem;
   424     }
   428     }
   425 
   429 
   426     // Only execute if close if popup was in popupList before
   430     // Only execute if close if popup was in popupList before
   427     if (popupList.removeOne(popup)) {
   431     if (popupList.removeOne(popup)) {
   428         // Update popup count registers
   432         // Update popup count registers
   443         }
   447         }
   444 
   448 
   445         bool wasActivePopup = true;
   449         bool wasActivePopup = true;
   446         // If the previous popup was an inactive panel, then it would not have
   450         // If the previous popup was an inactive panel, then it would not have
   447         // gained focused. So no need to set the focus to the next topmost popup.
   451         // gained focused. So no need to set the focus to the next topmost popup.
   448         if (popup->isPanel() && !popup->isActive()) {
   452         if (popup->isPanel() && !HbPopupPrivate::d_ptr(popup)->mActivePopup) {
   449             wasActivePopup = false;
   453             wasActivePopup = false;
   450         }
   454         }
   451         if (topLevelFocusablePopup && wasActivePopup ) {
   455         if (topLevelFocusablePopup && wasActivePopup ) {
   452             topLevelFocusablePopup->setFocus();
   456             topLevelFocusablePopup->setFocus();
       
   457             if (HbPopupPrivate::d_ptr(topLevelFocusablePopup)->mActivePopup)
       
   458                 topLevelFocusablePopup->setActive(true);
   453         }
   459         }
   454         //TODO: this is not very efficient way of deciding if has already been deleted or not
   460         //TODO: this is not very efficient way of deciding if has already been deleted or not
   455         else if (initialFocusedItem && scene &&
   461         else if (initialFocusedItem && scene &&
   456                  scene->items().contains(initialFocusedItem)) {
   462                  scene->items().contains(initialFocusedItem)) {
   457 
   463 
   556 // no need to delete d because it is child of this object
   562 // no need to delete d because it is child of this object
   557 }
   563 }
   558 
   564 
   559 void HbPopupManager::eventHook(QEvent *event)
   565 void HbPopupManager::eventHook(QEvent *event)
   560 {
   566 {
   561     d->eventHook(event);
   567     //This function can be removed
       
   568     Q_UNUSED(event);
       
   569     //d->eventHook(event);
   562 }
   570 }
   563 
   571 
   564 void HbPopupManager::showPopup(HbPopup *popup)
   572 void HbPopupManager::showPopup(HbPopup *popup)
   565 {
   573 {
   566     d->showPopup(popup);
   574     d->showPopup(popup);