src/hbinput/inputwidgets/hbinputbuttongroup.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
   347         qreal cellWidth = q->boundingRect().width() / mGridSize.width();
   347         qreal cellWidth = q->boundingRect().width() / mGridSize.width();
   348         qreal cellHeight = q->boundingRect().height() / mGridSize.height();
   348         qreal cellHeight = q->boundingRect().height() / mGridSize.height();
   349 
   349 
   350         // Calculate text size
   350         // Calculate text size
   351         QFont font = HbFontSpec(HbFontSpec::Primary).font();
   351         QFont font = HbFontSpec(HbFontSpec::Primary).font();
   352         font.setPixelSize(int(fontSize(HbInputButtonGroup::ButtonTextTypeLabel)));
   352         font.setPixelSize(int(group->fontSize(HbInputButtonGroup::ButtonTextTypeLabel)));
   353         QFontMetricsF fontMetrics(font);
   353         QFontMetricsF fontMetrics(font);
   354         qreal textWidth = fontMetrics.width(item->text(HbInputButton::ButtonTextIndexPrimary));
   354         qreal textWidth = fontMetrics.width(item->text(HbInputButton::ButtonTextIndexPrimary));
   355 
   355 
   356         // Calculate preview size
   356         // Calculate preview size
   357         qreal width = textWidth + HbPreviewMarginInUnits * mUnitValue;
   357         qreal width = textWidth + HbPreviewMarginInUnits * mUnitValue;
   359             width = item->boundingRect().width();
   359             width = item->boundingRect().width();
   360         } else if (width < HbPreviewWidthInUnits * mUnitValue) {
   360         } else if (width < HbPreviewWidthInUnits * mUnitValue) {
   361             width = HbPreviewWidthInUnits * mUnitValue;
   361             width = HbPreviewWidthInUnits * mUnitValue;
   362         }
   362         }
   363         qreal height = HbPreviewHeightInUnits * mUnitValue;
   363         qreal height = HbPreviewHeightInUnits * mUnitValue;
   364         qreal x = q->scenePos().x() + (item->position().x() + 0.5 * item->size().width()) * cellWidth - 0.5 * width;
   364         qreal x = (item->position().x() + 0.5 * item->size().width()) * cellWidth - 0.5 * width;
   365         if (x < 0) {
   365         if (x < 0) {
   366             x = 0;
   366             x = 0;
   367         } else if (x + width > q->boundingRect().width()) {
   367         } else if (x + width > q->boundingRect().width()) {
   368             x = q->boundingRect().width() - width;
   368             x = q->boundingRect().width() - width;
   369         }
   369         }
   370         qreal y = q->scenePos().y() + item->position().y() * cellHeight - height;
   370         qreal y = item->position().y() * cellHeight - height;
   371         group->setGeometry(QRectF(x, y, width, height));
   371         group->setGeometry(QRectF(q->mapToScene(x, y), QSizeF(width, height)));
   372         if (q->parentItem()) {
   372         if (q->parentItem()) {
   373             group->setZValue(q->parentItem()->zValue() + 1);
   373             group->setZValue(q->parentItem()->zValue() + 1);
   374         }
   374         }
   375 
   375 
   376         group->setButtonBorderSize(0);
   376         group->setButtonBorderSize(0);
   398     if (mCharacterSelectionPreviewEnabled && item->type() != HbInputButton::ButtonTypeFunction &&
   398     if (mCharacterSelectionPreviewEnabled && item->type() != HbInputButton::ButtonTypeFunction &&
   399         item->mappedCharacters().count() > 1) {
   399         item->mappedCharacters().count() > 1) {
   400 
   400 
   401         if (item->type() == HbInputButton::ButtonTypeFunction) {
   401         if (item->type() == HbInputButton::ButtonTypeFunction) {
   402             HbWidgetFeedback::triggered(q, Hb::InstantLongPressed, Hb::ModifierInputFunctionButton);
   402             HbWidgetFeedback::triggered(q, Hb::InstantLongPressed, Hb::ModifierInputFunctionButton);
   403         }
   403         } else {
   404         else {
       
   405             HbWidgetFeedback::triggered(q, Hb::InstantLongPressed);
   404             HbWidgetFeedback::triggered(q, Hb::InstantLongPressed);
   406         }
   405         }
   407 
   406 
   408         mProbabilities.clear();
   407         mProbabilities.clear();
   409         q->cancelButtonPress();
   408         q->cancelButtonPress();
   483     int index = mButtonGridPositions.value(QPair<int, int>(column, row), -1);
   482     int index = mButtonGridPositions.value(QPair<int, int>(column, row), -1);
   484 
   483 
   485     if (index >= 0 && index < mButtonData.count()) {
   484     if (index >= 0 && index < mButtonData.count()) {
   486         HbInputButton *item = mButtonData.at(index);
   485         HbInputButton *item = mButtonData.at(index);
   487 
   486 
       
   487         // Check whether we are actually supposed to handle the event.
   488         if ((item->state() != HbInputButton::ButtonStateReleased &&
   488         if ((item->state() != HbInputButton::ButtonStateReleased &&
   489              item->state() != HbInputButton::ButtonStateLatched) ||
   489              item->state() != HbInputButton::ButtonStateLatched) ||
   490             (mCharacterSelectionPreview && mCharacterSelectionPreview->isVisible())) {
   490             (mCharacterSelectionPreview && mCharacterSelectionPreview->isVisible())) {
   491             if (item->state() == HbInputButton::ButtonStateDisabled) {
   491             if (item->state() == HbInputButton::ButtonStateDisabled) {
   492                 startLongPress(index);
   492                 startLongPress(index);
   493             }
   493             }
   494             return;
   494             return;
   495         }
   495         }
       
   496 
       
   497         mActiveButtons.append(index);        
       
   498         item->setLastTriggeredPosition(position);
   496         
   499         
   497         if (item->type() == HbInputButton::ButtonTypeFunction) {
   500         if (item->type() == HbInputButton::ButtonTypeFunction) {
   498             HbWidgetFeedback::triggered(q, Hb::InstantPressed, Hb::ModifierInputFunctionButton);
   501             HbWidgetFeedback::triggered(q, Hb::InstantPressed, Hb::ModifierInputFunctionButton);
   499         }
   502         } else {
   500         else {
       
   501             HbWidgetFeedback::triggered(q, Hb::InstantPressed);        
   503             HbWidgetFeedback::triggered(q, Hb::InstantPressed);        
   502         }
   504         }
   503 
   505 
   504         item->setState(HbInputButton::ButtonStatePressed);
   506         item->setState(HbInputButton::ButtonStatePressed);
   505         updateGraphics(QSizeF(q->boundingRect().width(), q->boundingRect().height()));
   507         updateGraphics(QSizeF(q->boundingRect().width(), q->boundingRect().height()));
   539     int index = mButtonGridPositions.value(QPair<int, int>(column, row), -1);
   541     int index = mButtonGridPositions.value(QPair<int, int>(column, row), -1);
   540 
   542 
   541     if (index >= 0 && index < mButtonData.count()) {
   543     if (index >= 0 && index < mButtonData.count()) {
   542         HbInputButton *item = mButtonData.at(index);
   544         HbInputButton *item = mButtonData.at(index);
   543 
   545 
       
   546         // Check whether we are actually supposed to handle the event.
   544         if ((item->state() != HbInputButton::ButtonStateReleased &&
   547         if ((item->state() != HbInputButton::ButtonStateReleased &&
   545              item->state() != HbInputButton::ButtonStateLatched) ||
   548              item->state() != HbInputButton::ButtonStateLatched) ||
   546             (mCharacterSelectionPreview && mCharacterSelectionPreview->isVisible())) {
   549             (mCharacterSelectionPreview && mCharacterSelectionPreview->isVisible())) {
   547             if (item->state() == HbInputButton::ButtonStateDisabled) {
   550             if (item->state() == HbInputButton::ButtonStateDisabled) {
   548                 startLongPress(index);
   551                 startLongPress(index);
   549             }
   552             }
   550             return;
   553             return;
   551         }
   554         }
   552 
   555 
       
   556         mActiveButtons.append(index);        
       
   557         item->setLastTriggeredPosition(position);
       
   558 
   553         if (item->type() == HbInputButton::ButtonTypeFunction) {
   559         if (item->type() == HbInputButton::ButtonTypeFunction) {
   554             HbWidgetFeedback::triggered(q, Hb::InstantPressed, Hb::ModifierInputFunctionButton);
   560             HbWidgetFeedback::triggered(q, Hb::InstantPressed, Hb::ModifierInputFunctionButton);
   555         }
   561         } else {
   556         else {
       
   557             HbWidgetFeedback::triggered(q, Hb::InstantPressed);        
   562             HbWidgetFeedback::triggered(q, Hb::InstantPressed);        
   558         }
   563         }
   559 
   564 
   560         item->setState(HbInputButton::ButtonStatePressed);
   565         item->setState(HbInputButton::ButtonStatePressed);
   561         updateGraphics(QSizeF(q->boundingRect().width(), q->boundingRect().height()));
   566         updateGraphics(QSizeF(q->boundingRect().width(), q->boundingRect().height()));
   581 
   586 
   582 void HbInputButtonGroupPrivate::moveEvent(const QPointF &oldPosition, const QPointF &newPosition)
   587 void HbInputButtonGroupPrivate::moveEvent(const QPointF &oldPosition, const QPointF &newPosition)
   583 {
   588 {
   584     Q_Q(HbInputButtonGroup);
   589     Q_Q(HbInputButtonGroup);
   585 
   590 
   586     int oldColumn = static_cast<int>(oldPosition.x() / (q->boundingRect().width() / mGridSize.width()));
       
   587     int oldRow = static_cast<int>(oldPosition.y() / (q->boundingRect().height() / mGridSize.height()));
       
   588     int newColumn = static_cast<int>(newPosition.x() / (q->boundingRect().width() / mGridSize.width()));
   591     int newColumn = static_cast<int>(newPosition.x() / (q->boundingRect().width() / mGridSize.width()));
   589     int newRow = static_cast<int>(newPosition.y() / (q->boundingRect().height() / mGridSize.height()));
   592     int newRow = static_cast<int>(newPosition.y() / (q->boundingRect().height() / mGridSize.height()));
   590 
   593 
   591     int oldIndex = mButtonGridPositions.value(QPair<int, int>(oldColumn, oldRow), -1);
       
   592     int newIndex = mButtonGridPositions.value(QPair<int, int>(newColumn, newRow), -1);
   594     int newIndex = mButtonGridPositions.value(QPair<int, int>(newColumn, newRow), -1);
   593 
   595 
   594     // Check if movement happens inside button group
   596     // Check if movement happens inside button group
   595     if (newPosition.x() >= 0 && newPosition.x() < q->boundingRect().width() &&
   597     if (newPosition.x() >= 0 && newPosition.x() < q->boundingRect().width() &&
   596         newPosition.y() >= 0 && newPosition.y() < q->boundingRect().height() &&
   598         newPosition.y() >= 0 && newPosition.y() < q->boundingRect().height() &&
   597         oldPosition.x() >= 0 && oldPosition.x() < q->boundingRect().width() &&
   599         oldPosition.x() >= 0 && oldPosition.x() < q->boundingRect().width() &&
   598         oldPosition.y() >= 0 && oldPosition.y() < q->boundingRect().height()) {
   600         oldPosition.y() >= 0 && oldPosition.y() < q->boundingRect().height()) {        
   599 
   601 
   600         if (oldIndex != newIndex) {
   602         // When user moves a finger on the keyboard, currently active button(s) should consume events
       
   603         // as long as the finger position is within the touch area of the button. Button should be removed
       
   604         // from the mActiveButtons, when finger moves outside the button's touch area.
       
   605 
       
   606         // The button this event belongs to can be determined by checking which button handled the
       
   607         // 'oldPosition' coordinate in previous run of either pressEvent or moveEvent.
       
   608         // If button is no longer active just return.
       
   609         int activeItemIndex = activeButtonIndex(oldPosition);
       
   610         if (activeItemIndex < 0) {
       
   611             return;
       
   612         }
       
   613         HbInputButton* activeItem = mButtonData.at(activeItemIndex);        
       
   614 
       
   615         // In case user has moved finger far enough away from the original button, old active
       
   616         // item needs to be removed and the new one should be added to active list.
       
   617         if (!mActiveButtons.contains(newIndex) && !activeItem->activeTouchArea().contains(newPosition)) {
   601             releaseEvent(oldPosition, false);
   618             releaseEvent(oldPosition, false);
   602             pressEvent(newPosition, false);
   619             pressEvent(newPosition, false);
   603 
   620 
   604             QString text;
   621             QString text;
   605             HbInputButton *oldItem = mButtonData.at(oldIndex);
   622             if (activeItem->type() == HbInputButton::ButtonTypeLabel) {
   606             if (oldItem->type() == HbInputButton::ButtonTypeLabel) {
   623                 text = activeItem->text(HbInputButton::ButtonTextIndexPrimary);
   607                 text = oldItem->text(HbInputButton::ButtonTextIndexPrimary);
   624             }
   608             }
   625             QKeyEvent releaseEvent(QEvent::KeyRelease, activeItem->keyCode(), Qt::NoModifier, text);
   609             QKeyEvent releaseEvent(QEvent::KeyRelease, oldItem->keyCode(), Qt::NoModifier, text);
       
   610 
   626 
   611             HbInputButton *newItem = mButtonData.at(newIndex);
   627             HbInputButton *newItem = mButtonData.at(newIndex);
   612             if (newItem->type() == HbInputButton::ButtonTypeLabel) {
   628             if (newItem->type() == HbInputButton::ButtonTypeLabel) {
   613                 text = newItem->text(HbInputButton::ButtonTextIndexPrimary);
   629                 text = newItem->text(HbInputButton::ButtonTextIndexPrimary);
   614             }
   630             }
   615             QKeyEvent pressEvent(QEvent::KeyPress, newItem->keyCode(), Qt::NoModifier, text);
   631             QKeyEvent pressEvent(QEvent::KeyPress, newItem->keyCode(), Qt::NoModifier, text);
   616 
   632 
   617             q->emitPressedButtonChanged(releaseEvent, pressEvent);
   633             q->emitPressedButtonChanged(releaseEvent, pressEvent);
       
   634         } else {
       
   635             // Even though we do nothing with this button this time, update the status
       
   636             // of the item, so next time this function is invoked, this button is correctly
       
   637             // detected as the owner of the new event.
       
   638             activeItem->setLastTriggeredPosition(newPosition);
   618         }
   639         }
   619     } else {
   640     } else {
   620         // Move event came from outside button group so create new release and press events
   641         // Move event came from outside button group so create new release and press events
   621         // for old and new position. If one of the positions is inside button group
   642         // for old and new position. If one of the positions is inside button group
   622         // a new event will get generated.
   643         // a new key event will get emitted automatically.
   623         releaseEvent(oldPosition, false);
   644         releaseEvent(oldPosition, false);
   624         pressEvent(newPosition);
   645         pressEvent(newPosition);
   625     }
   646     }
   626 }
   647 }
   627 
   648 
   628 void HbInputButtonGroupPrivate::releaseEvent(const QPointF &position, bool emitSignal)
   649 void HbInputButtonGroupPrivate::releaseEvent(const QPointF &position, bool emitSignal)
   629 {
   650 {
   630     Q_Q(HbInputButtonGroup);
   651     Q_Q(HbInputButtonGroup);
   631 
   652 
   632     // Ignore release events outside button group
   653     int activeIndex = activeButtonIndex(position);
   633     if (!(position.x() >= 0 && position.x() < q->boundingRect().width() &&
   654     if (activeIndex >= 0) {
   634           position.y() >= 0 && position.y() < q->boundingRect().height())) {
   655         HbInputButton *item = mButtonData.at(activeIndex);
   635         return;
   656 
   636     }
   657         cancelLongPress(activeIndex);
   637 
   658 
   638     int column = static_cast<int>(position.x() / (q->boundingRect().width() / mGridSize.width()));
   659         // Check if we need to handle this event
   639     int row = static_cast<int>(position.y() / (q->boundingRect().height() / mGridSize.height()));
       
   640 
       
   641     int index = mButtonGridPositions.value(QPair<int, int>(column, row), -1);
       
   642 
       
   643     if (index >= 0 && index < mButtonData.count()) {
       
   644         HbInputButton *item = mButtonData.at(index);
       
   645 
       
   646         cancelLongPress(index);
       
   647 
       
   648         if (item->state() != HbInputButton::ButtonStatePressed) {
   660         if (item->state() != HbInputButton::ButtonStatePressed) {
   649             return;
   661             return;
   650         }
   662         }
   651 
   663 
       
   664         // This item is pressed, so release can happen for this.
       
   665         mActiveButtons.removeAll(activeIndex);
       
   666         item->clearLastTriggeredPosition();
       
   667 
   652         if (item->type() == HbInputButton::ButtonTypeFunction) {
   668         if (item->type() == HbInputButton::ButtonTypeFunction) {
   653             HbWidgetFeedback::triggered(q, Hb::InstantReleased, Hb::ModifierInputFunctionButton);
   669             HbWidgetFeedback::triggered(q, Hb::InstantReleased, Hb::ModifierInputFunctionButton);
   654         }
   670         } else {
   655         else {
       
   656             HbWidgetFeedback::triggered(q, Hb::InstantReleased);
   671             HbWidgetFeedback::triggered(q, Hb::InstantReleased);
   657         }
   672         }
   658 
   673 
   659         item->setState(HbInputButton::ButtonStateReleased);
   674         item->setState(HbInputButton::ButtonStateReleased);
   660         updateGraphics(QSizeF(q->boundingRect().width(), q->boundingRect().height()));
   675         updateGraphics(QSizeF(q->boundingRect().width(), q->boundingRect().height()));
   668         hideButtonPreview(item);
   683         hideButtonPreview(item);
   669 
   684 
   670         if (emitSignal) {
   685         if (emitSignal) {
   671             if (item->type() == HbInputButton::ButtonTypeFunction) {
   686             if (item->type() == HbInputButton::ButtonTypeFunction) {
   672                 HbWidgetFeedback::triggered(q, Hb::InstantClicked, Hb::ModifierInputFunctionButton);
   687                 HbWidgetFeedback::triggered(q, Hb::InstantClicked, Hb::ModifierInputFunctionButton);
   673             }
   688             } else {
   674             else {
       
   675                 HbWidgetFeedback::triggered(q, Hb::InstantClicked);
   689                 HbWidgetFeedback::triggered(q, Hb::InstantClicked);
   676             }
   690             }
   677             int actionIndex = item->keyCode() - HbInputButton::ButtonKeyCodeCustom;
   691             int actionIndex = item->keyCode() - HbInputButton::ButtonKeyCodeCustom;
   678             if (actionIndex >= 0 && actionIndex < mCustomActions.count()) {
   692             if (actionIndex >= 0 && actionIndex < mCustomActions.count()) {
   679                 emit q->aboutToActivateCustomAction(mCustomActions.at(actionIndex));
   693                 emit q->aboutToActivateCustomAction(mCustomActions.at(actionIndex));
   697     Q_Q(HbInputButtonGroup);
   711     Q_Q(HbInputButtonGroup);
   698 
   712 
   699     int index = mLongPressButtons.at(0);
   713     int index = mLongPressButtons.at(0);
   700     mLongPressButtons.removeAt(0);
   714     mLongPressButtons.removeAt(0);
   701     QTimer *timer = mLongPressTimers.at(0);
   715     QTimer *timer = mLongPressTimers.at(0);
   702     mLongPressTimers.removeAt(0);
   716     mLongPressTimers.removeAt(0);    
   703 
   717 
   704     if (index >= 0 && index < mButtonData.count()) {
   718     if (index >= 0 && index < mButtonData.count()) {
   705         HbInputButton *item = mButtonData.at(index);
   719         HbInputButton *item = mButtonData.at(index);
   706 
   720 
   707         // Handle autorepeating buttons
   721         // Handle autorepeating buttons
   712             mLongPressTimers.append(timer);
   726             mLongPressTimers.append(timer);
   713             timer->start(HbAutoRepeatTimeout);
   727             timer->start(HbAutoRepeatTimeout);
   714 
   728 
   715             if (item->type() == HbInputButton::ButtonTypeFunction) {
   729             if (item->type() == HbInputButton::ButtonTypeFunction) {
   716                 HbWidgetFeedback::triggered(q, Hb::InstantKeyRepeated, Hb::ModifierInputFunctionButton);
   730                 HbWidgetFeedback::triggered(q, Hb::InstantKeyRepeated, Hb::ModifierInputFunctionButton);
   717             }
   731             } else {
   718             else {
       
   719                 HbWidgetFeedback::triggered(q, Hb::InstantKeyRepeated);
   732                 HbWidgetFeedback::triggered(q, Hb::InstantKeyRepeated);
   720             }
   733             }
   721 
   734 
   722             QString text;
   735             QString text;
   723             if (item->type() == HbInputButton::ButtonTypeLabel) {
   736             if (item->type() == HbInputButton::ButtonTypeLabel) {
   724                 text = item->text(HbInputButton::ButtonTextIndexPrimary);
   737                 text = item->text(HbInputButton::ButtonTextIndexPrimary);
   725             }
   738             }
   726             int keycode = item->keyCode();
   739             int keycode = item->keyCode();
   727             QKeyEvent releaeEvent(QEvent::KeyRelease, keycode, Qt::NoModifier, text, true);
   740             QKeyEvent releaseEvent(QEvent::KeyRelease, keycode, Qt::NoModifier, text, true);
   728             q->emitButtonReleased(releaeEvent);
   741             q->emitButtonReleased(releaseEvent);
   729             QKeyEvent pressEvent(QEvent::KeyPress, keycode, Qt::NoModifier, text, true);
   742             QKeyEvent pressEvent(QEvent::KeyPress, keycode, Qt::NoModifier, text, true);
   730             q->emitButtonPressed(pressEvent);
   743             q->emitButtonPressed(pressEvent);
   731         } else {
   744         } else {
   732             // Buttons that doesn't support autorepeat can either show character preview
   745             // Buttons that doesn't support autorepeat can either show character preview
   733             // or generate a long press
   746             // or generate a long press
   735                 && item->mappedCharacters().count() > 1) {
   748                 && item->mappedCharacters().count() > 1) {
   736                 showCharacterSelectionPreview(item);
   749                 showCharacterSelectionPreview(item);
   737             } else {
   750             } else {
   738                 if (item->type() == HbInputButton::ButtonTypeFunction) {
   751                 if (item->type() == HbInputButton::ButtonTypeFunction) {
   739                     HbWidgetFeedback::triggered(q, Hb::InstantLongPressed, Hb::ModifierInputFunctionButton);
   752                     HbWidgetFeedback::triggered(q, Hb::InstantLongPressed, Hb::ModifierInputFunctionButton);
   740                 }
   753                 } else {
   741                 else {
       
   742                     HbWidgetFeedback::triggered(q, Hb::InstantLongPressed);
   754                     HbWidgetFeedback::triggered(q, Hb::InstantLongPressed);
   743                 }
   755                 }
   744 
   756 
   745                 QString text;
   757                 QString text;
   746                 if (item->type() == HbInputButton::ButtonTypeLabel) {
   758                 if (item->type() == HbInputButton::ButtonTypeLabel) {
   784 
   796 
   785     // Normalize
   797     // Normalize
   786     for (int i = 0; i < mProbabilities.count(); ++i) {
   798     for (int i = 0; i < mProbabilities.count(); ++i) {
   787         mProbabilities[i].probability /= probabilities;
   799         mProbabilities[i].probability /= probabilities;
   788     }
   800     }
       
   801 }
       
   802 
       
   803 /*!
       
   804 \internal
       
   805 \brief Search active button based on position.
       
   806 
       
   807 Locates active button based on its last interaction point.
       
   808 
       
   809 \param position Location of triggered user action.
       
   810 \return NULL, when no button has reacted to given coordinates.
       
   811 \return Pointer to active button.
       
   812 */
       
   813 int HbInputButtonGroupPrivate::activeButtonIndex(const QPointF &position)
       
   814 {
       
   815     // Here we get the position, where last interaction occurred.
       
   816     // Start searching from the end of the list, because it is likely,
       
   817     // that the triggered position happens on the button that was added last.
       
   818     for (int i = mActiveButtons.count() - 1; i >= 0; --i) {
       
   819         int activeIndex = mActiveButtons[i];
       
   820         if (mButtonData[activeIndex]->wasTriggeredAt(position)) {
       
   821             return activeIndex;
       
   822         }
       
   823     }
       
   824 
       
   825     // Position is not inside any single active button.
       
   826     return -1;
   789 }
   827 }
   790 
   828 
   791 void HbInputButtonGroupPrivate::createPrimarySingleTextLayout(int index, const QHash<int, QString> &textContent, const QSizeF &size)
   829 void HbInputButtonGroupPrivate::createPrimarySingleTextLayout(int index, const QHash<int, QString> &textContent, const QSizeF &size)
   792 {
   830 {
   793     qreal cellWidth = size.width() / mGridSize.width();
   831     qreal cellWidth = size.width() / mGridSize.width();
   947 {
   985 {
   948     qreal textPositionX = 0.0;
   986     qreal textPositionX = 0.0;
   949     qreal textPositionY = 0.0;
   987     qreal textPositionY = 0.0;
   950     
   988     
   951     switch(textType) {
   989     switch(textType) {
   952         case HbInputButtonGroup::ButtonTextTypeSingle:
   990     case HbInputButtonGroup::ButtonTextTypeSingle:
   953         case HbInputButtonGroup::ButtonTextTypeLabel:
   991     case HbInputButtonGroup::ButtonTextTypeLabel:
   954             textPositionX = (button->position().x() + 0.5 * button->size().width()) * cellSize.width() - 0.5 * textSize.width();
   992         textPositionX = (button->position().x() + 0.5 * button->size().width()) * cellSize.width() - 0.5 * textSize.width();
   955             textPositionY = (button->position().y() + 0.5 * button->size().height()) * cellSize.height() - 0.5 * textSize.height();
   993         textPositionY = (button->position().y() + 0.5 * button->size().height()) * cellSize.height() - 0.5 * textSize.height();
   956             break;
   994         break;
   957 
   995 
   958         case HbInputButtonGroup::ButtonTextTypePrimary:
   996     case HbInputButtonGroup::ButtonTextTypePrimary:
   959             textPositionX = button->position().x() * cellSize.width() + HbHorizontalMarginInUnits * mUnitValue + mButtonBorderSize;
   997         textPositionX = button->position().x() * cellSize.width() + HbHorizontalMarginInUnits * mUnitValue + mButtonBorderSize;
   960             textPositionY = (button->position().y() + 0.5 * button->size().height()) * cellSize.height() - 0.5 * textSize.height();
   998         textPositionY = (button->position().y() + 0.5 * button->size().height()) * cellSize.height() - 0.5 * textSize.height();
   961             break;
   999         break;
   962 
  1000 
   963         case HbInputButtonGroup::ButtonTextTypeSecondaryFirstRow:
  1001     case HbInputButtonGroup::ButtonTextTypeSecondaryFirstRow:
   964             textPositionX = (button->position().x() + button->size().width()) * cellSize.width() -
  1002         textPositionX = (button->position().x() + button->size().width()) * cellSize.width() -
   965                             textSize.width() - HbHorizontalMarginInUnits * mUnitValue - mButtonBorderSize;
  1003                         textSize.width() - HbHorizontalMarginInUnits * mUnitValue - mButtonBorderSize;
   966             textPositionY = (button->position().y() + button->size().height()) * cellSize.height() -
  1004         textPositionY = (button->position().y() + button->size().height()) * cellSize.height() -
   967                             textSize.height() - HbVerticalMarginInUnits * mUnitValue - mButtonBorderSize;
  1005                         textSize.height() - HbVerticalMarginInUnits * mUnitValue - mButtonBorderSize;
   968             break;
  1006         break;
   969 
  1007 
   970         case HbInputButtonGroup::ButtonTextTypeSecondarySecondRow:
  1008     case HbInputButtonGroup::ButtonTextTypeSecondarySecondRow:
   971             textPositionX = (button->position().x() + button->size().width()) * cellSize.width() -
  1009         textPositionX = (button->position().x() + button->size().width()) * cellSize.width() -
   972                             textSize.width() - HbHorizontalMarginInUnits * mUnitValue - mButtonBorderSize;
  1010                         textSize.width() - HbHorizontalMarginInUnits * mUnitValue - mButtonBorderSize;
   973             textPositionY = button->position().y() * cellSize.height() + HbVerticalMarginInUnits * mUnitValue + mButtonBorderSize;
  1011         textPositionY = button->position().y() * cellSize.height() + HbVerticalMarginInUnits * mUnitValue + mButtonBorderSize;
   974             break;
  1012         break;
   975 
  1013 
   976         default:
  1014     default:
   977             break;
  1015         break;
   978     }
  1016     }
   979     textLine.setPosition(QPointF(textPositionX, textPositionY));
  1017     textLine.setPosition(QPointF(textPositionX, textPositionY));
   980 }
  1018 }
   981 
  1019 
   982 QString HbInputButtonGroupPrivate::buttonGraphics(HbInputButton::HbInputButtonType type, HbInputButton::HbInputButtonState state)
  1020 QString HbInputButtonGroupPrivate::buttonGraphics(HbInputButton::HbInputButtonType type, HbInputButton::HbInputButtonState state)
  1037     return QString("");
  1075     return QString("");
  1038 }
  1076 }
  1039 
  1077 
  1040 qreal HbInputButtonGroupPrivate::fontSize(HbInputButtonGroup::HbInputButtonTextType textType)
  1078 qreal HbInputButtonGroupPrivate::fontSize(HbInputButtonGroup::HbInputButtonTextType textType)
  1041 {
  1079 {
  1042     switch(textType) {
  1080     return mFontSize[textType];
  1043         case HbInputButtonGroup::ButtonTextTypeSingle:
  1081 }
  1044             return HbTextSizeInUnits * mUnitValue;
  1082 
  1045 
  1083 void HbInputButtonGroupPrivate::setFontSize(HbInputButtonGroup::HbInputButtonTextType textType,qreal size)
  1046         case HbInputButtonGroup::ButtonTextTypePrimary:
  1084 {
  1047             return HbPrimaryTextSizeInUnits * mUnitValue;
  1085     mFontSize[textType] = size;
  1048 
  1086 }
  1049         case HbInputButtonGroup::ButtonTextTypeSecondaryFirstRow:
  1087 
  1050         case HbInputButtonGroup::ButtonTextTypeSecondarySecondRow:
  1088 void HbInputButtonGroupPrivate::resetFontSizes()
  1051             return HbSecondaryTextSizeInUnits * mUnitValue;
  1089 {
  1052 
  1090     mFontSize[HbInputButtonGroup::ButtonTextTypeSingle] = HbTextSizeInUnits * mUnitValue;
  1053         case HbInputButtonGroup::ButtonTextTypeLabel:
  1091     mFontSize[HbInputButtonGroup::ButtonTextTypePrimary] = HbPrimaryTextSizeInUnits * mUnitValue;
  1054             return HbLabelTextSizeInUnits * mUnitValue;
  1092     mFontSize[HbInputButtonGroup::ButtonTextTypeSecondaryFirstRow] = HbSecondaryTextSizeInUnits * mUnitValue;
  1055 
  1093     mFontSize[HbInputButtonGroup::ButtonTextTypeSecondarySecondRow] = HbSecondaryTextSizeInUnits * mUnitValue;
  1056         default:
  1094     mFontSize[HbInputButtonGroup::ButtonTextTypeLabel] = HbLabelTextSizeInUnits * mUnitValue;
  1057             return 0;
       
  1058     }
       
  1059 }
  1095 }
  1060 
  1096 
  1061 void HbInputButtonGroupPrivate::startLongPress(int index)
  1097 void HbInputButtonGroupPrivate::startLongPress(int index)
  1062 {
  1098 {
  1063     Q_Q(HbInputButtonGroup);
  1099     Q_Q(HbInputButtonGroup);
  1099 {
  1135 {
  1100     Q_D(HbInputButtonGroup);
  1136     Q_D(HbInputButtonGroup);
  1101 
  1137 
  1102     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1138     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1103 
  1139 
       
  1140     resetFontSizes();
       
  1141 
  1104     setAcceptedMouseButtons(Qt::LeftButton);
  1142     setAcceptedMouseButtons(Qt::LeftButton);
       
  1143     
       
  1144     setFlag(QGraphicsItem::ItemIsPanel, true);
       
  1145     setActive(false);
  1105 }
  1146 }
  1106 
  1147 
  1107 /*!
  1148 /*!
  1108 Constructor
  1149 Constructor
  1109 */
  1150 */
  1112 {
  1153 {
  1113     Q_D(HbInputButtonGroup);
  1154     Q_D(HbInputButtonGroup);
  1114 
  1155 
  1115     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1156     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1116 
  1157 
       
  1158     resetFontSizes();
       
  1159 
  1117     setAcceptedMouseButtons(Qt::LeftButton);
  1160     setAcceptedMouseButtons(Qt::LeftButton);
  1118 }
  1161 }
  1119 
  1162 
  1120 /*!
  1163 /*!
  1121 Constructor
  1164 Constructor
  1125 {
  1168 {
  1126     Q_D(HbInputButtonGroup);
  1169     Q_D(HbInputButtonGroup);
  1127 
  1170 
  1128     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1171     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1129 
  1172 
       
  1173     resetFontSizes();
       
  1174 
  1130     setAcceptedMouseButtons(Qt::LeftButton);
  1175     setAcceptedMouseButtons(Qt::LeftButton);
  1131 
  1176 
  1132     setGridSize(size);
  1177     setGridSize(size);
  1133 }
  1178 }
  1134 
  1179 
  1139     : HbWidget(dd, parent)
  1184     : HbWidget(dd, parent)
  1140 {
  1185 {
  1141     Q_D(HbInputButtonGroup);
  1186     Q_D(HbInputButtonGroup);
  1142 
  1187 
  1143     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1188     d->mUnitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
       
  1189 
       
  1190     resetFontSizes();
  1144 
  1191 
  1145     setAcceptedMouseButtons(Qt::LeftButton);
  1192     setAcceptedMouseButtons(Qt::LeftButton);
  1146 
  1193 
  1147     setGridSize(size);
  1194     setGridSize(size);
  1148 }
  1195 }
  1200 */
  1247 */
  1201 void HbInputButtonGroup::setButtons(const QList<HbInputButton *> &data)
  1248 void HbInputButtonGroup::setButtons(const QList<HbInputButton *> &data)
  1202 {
  1249 {
  1203     Q_D(HbInputButtonGroup);
  1250     Q_D(HbInputButtonGroup);
  1204 
  1251 
  1205     foreach(HbInputButton *button, d->mButtonData) {
  1252     for (int i = 0; i < d->mButtonData.count(); ++i) {
  1206         if (!data.contains(button)) {
  1253         if (!data.contains(d->mButtonData.at(i))) {
  1207             delete button;
  1254             delete d->mButtonData.at(i);
       
  1255             d->cancelLongPress(i);
  1208         }
  1256         }
  1209     }
  1257     }
  1210     d->mButtonData = data;
  1258     d->mButtonData = data;
  1211 
  1259 
  1212     d->updateButtonGrid(QSizeF(boundingRect().width(), boundingRect().height()));
  1260     d->updateButtonGrid(QSizeF(boundingRect().width(), boundingRect().height()));
  1231     Q_D(HbInputButtonGroup);
  1279     Q_D(HbInputButtonGroup);
  1232 
  1280 
  1233     if (index >= 0 && index < d->mButtonData.count()) {
  1281     if (index >= 0 && index < d->mButtonData.count()) {
  1234         if (data != d->mButtonData.at(index)) {
  1282         if (data != d->mButtonData.at(index)) {
  1235             delete d->mButtonData.at(index);
  1283             delete d->mButtonData.at(index);
       
  1284             d->cancelLongPress(index);
  1236         }
  1285         }
  1237         if (data) {
  1286         if (data) {
  1238             d->mButtonData.replace(index, data);
  1287             d->mButtonData.replace(index, data);
  1239         } else {
  1288         } else {
  1240             d->mButtonData.removeAt(index);
  1289             d->mButtonData.removeAt(index);
  1487     return d->mCharacterSelectionPreviewEnabled;
  1536     return d->mCharacterSelectionPreviewEnabled;
  1488 }
  1537 }
  1489 
  1538 
  1490 
  1539 
  1491 /*!
  1540 /*!
  1492 Sets multi touch enabled or disabled.
  1541 If given parameter is true more that one touch points are accepted
       
  1542 simultaneously.
  1493 
  1543 
  1494 \sa isMultiTouchEnabled
  1544 \sa isMultiTouchEnabled
  1495 */
  1545 */
  1496 void HbInputButtonGroup::setMultiTouchEnabled(bool enabled)
  1546 void HbInputButtonGroup::setMultiTouchEnabled(bool enabled)
  1497 {
  1547 {
  1500     d->mMultiTouchEnabled = enabled;
  1550     d->mMultiTouchEnabled = enabled;
  1501     setAcceptTouchEvents(enabled);
  1551     setAcceptTouchEvents(enabled);
  1502 }
  1552 }
  1503 
  1553 
  1504 /*!
  1554 /*!
  1505 Returns multi touch state.
  1555 Returns true if more than one touch points are accepted simultaneously.
  1506 
  1556 
  1507 \sa setMultiTouchEnabled
  1557 \sa setMultiTouchEnabled
  1508 */
  1558 */
  1509 bool HbInputButtonGroup::isMultiTouchEnabled() const
  1559 bool HbInputButtonGroup::isMultiTouchEnabled() const
  1510 {
  1560 {
  1531 qreal HbInputButtonGroup::fontSize(HbInputButtonTextType textType)
  1581 qreal HbInputButtonGroup::fontSize(HbInputButtonTextType textType)
  1532 {
  1582 {
  1533     Q_D(HbInputButtonGroup);
  1583     Q_D(HbInputButtonGroup);
  1534 
  1584 
  1535     return d->fontSize(textType);
  1585     return d->fontSize(textType);
       
  1586 }
       
  1587 
       
  1588 /*!
       
  1589 Set font size for given text type
       
  1590 */
       
  1591 void HbInputButtonGroup::setFontSize(HbInputButtonTextType textType,qreal size)
       
  1592 {
       
  1593     Q_D(HbInputButtonGroup);
       
  1594 
       
  1595     return d->setFontSize(textType,size);
       
  1596 }
       
  1597 
       
  1598 /*!
       
  1599 Reset font size for all text type
       
  1600 */
       
  1601 void HbInputButtonGroup::resetFontSizes()
       
  1602 {
       
  1603     Q_D(HbInputButtonGroup);
       
  1604 
       
  1605     return d->resetFontSizes();
  1536 }
  1606 }
  1537 
  1607 
  1538 /*!
  1608 /*!
  1539 Returns all possible buttons the user could have intended to press
  1609 Returns all possible buttons the user could have intended to press
  1540 for the last registered touch along with their corresponding probabilities.
  1610 for the last registered touch along with their corresponding probabilities.
  1672 */
  1742 */
  1673 bool HbInputButtonGroup::sceneEvent(QEvent *event)
  1743 bool HbInputButtonGroup::sceneEvent(QEvent *event)
  1674 {
  1744 {
  1675     Q_D(HbInputButtonGroup);
  1745     Q_D(HbInputButtonGroup);
  1676 
  1746 
  1677     if (!d->mEnabled) {
  1747     // In case disabled or there is a preview popup open for any button, ignore events in this group.
       
  1748     if (!d->mEnabled || (d->mCharacterSelectionPreview && d->mCharacterSelectionPreview->isVisible())) {
  1678         event->ignore();
  1749         event->ignore();
  1679         return false;
  1750         return false;
  1680     }
  1751     }
  1681 
  1752 
  1682     switch(event->type()) {
  1753     switch(event->type()) {
  1683         case QEvent::TouchBegin: {
  1754     case QEvent::TouchBegin: {            
  1684             QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
  1755         QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
  1685             foreach(const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
  1756         foreach(const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
  1686                 if (!point.isPrimary() && d->mMultiTouchEnabled) {
  1757             if (!point.isPrimary() && d->mMultiTouchEnabled) {
       
  1758                 d->pressEvent(point.pos());
       
  1759             }
       
  1760         }
       
  1761         break;
       
  1762     }
       
  1763 
       
  1764     case QEvent::TouchUpdate: {
       
  1765         QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
       
  1766         foreach(const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
       
  1767             if (!point.isPrimary() && d->mMultiTouchEnabled) {
       
  1768                 if (point.state() & Qt::TouchPointPressed) {
  1687                     d->pressEvent(point.pos());
  1769                     d->pressEvent(point.pos());
  1688                 }
  1770                 } else if (point.state() & Qt::TouchPointMoved) {
  1689             }
  1771                     d->moveEvent(point.lastPos(), point.pos());
  1690             break;
  1772                 } else if (point.state() & Qt::TouchPointReleased) {
  1691         }
  1773                     d->moveEvent(point.lastPos(), point.pos());
  1692 
       
  1693         case QEvent::TouchUpdate: {
       
  1694             QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
       
  1695             foreach(const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
       
  1696                 if (!point.isPrimary() && d->mMultiTouchEnabled) {
       
  1697                     if (point.state() & Qt::TouchPointPressed) {
       
  1698                         d->pressEvent(point.pos());
       
  1699                     } else if (point.state() & Qt::TouchPointMoved) {
       
  1700                         d->moveEvent(point.lastPos(), point.pos());
       
  1701                     } else if (point.state() & Qt::TouchPointReleased) {
       
  1702                         d->releaseEvent(point.pos());
       
  1703                     }
       
  1704                 }
       
  1705             }
       
  1706             break;
       
  1707         }
       
  1708 
       
  1709         case QEvent::TouchEnd: {
       
  1710             QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
       
  1711             foreach(const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
       
  1712                 if (!point.isPrimary() && d->mMultiTouchEnabled) {
       
  1713                     d->releaseEvent(point.pos());
  1774                     d->releaseEvent(point.pos());
  1714                 }
  1775                 }
  1715             }
  1776             }
  1716             break;
  1777         }
  1717         }
  1778         break;
  1718 
  1779     }
  1719         case QEvent::GraphicsSceneMousePress: {
  1780 
  1720             QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
  1781     case QEvent::TouchEnd: {
  1721             d->pressEvent(mouseEvent->pos());
  1782         QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
  1722             break;
  1783         foreach(const QTouchEvent::TouchPoint &point, touchEvent->touchPoints()) {
  1723         }
  1784             if (!point.isPrimary() && d->mMultiTouchEnabled) {
  1724 
  1785                 d->moveEvent(point.lastPos(), point.pos());
  1725         case QEvent::GraphicsSceneMouseDoubleClick: {
  1786                 d->releaseEvent(point.pos());
  1726             QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
  1787             }
  1727             d->doublePressEvent(mouseEvent->pos());
  1788         }
  1728             break;
  1789         break;
  1729         }
  1790     }
  1730 
  1791 
  1731         case QEvent::GraphicsSceneMouseMove: {
  1792     case QEvent::GraphicsSceneMousePress: {
  1732             QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
  1793         QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
  1733             d->moveEvent(mouseEvent->lastPos(), mouseEvent->pos());
  1794         d->pressEvent(mouseEvent->pos());
  1734             break;
  1795         break;
  1735         }
  1796     }
  1736 
  1797 
  1737         case QEvent::GraphicsSceneMouseRelease: {
  1798     case QEvent::GraphicsSceneMouseDoubleClick: {
  1738             QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
  1799         QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
  1739             d->releaseEvent(mouseEvent->pos());
  1800         d->doublePressEvent(mouseEvent->pos());
  1740             cancelButtonPress();
  1801         break;
  1741             break;
  1802     }
  1742         }
  1803 
  1743 
  1804     case QEvent::GraphicsSceneMouseMove: {
  1744         default:
  1805         QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
  1745             return HbWidget::event(event);
  1806         d->moveEvent(mouseEvent->lastPos(), mouseEvent->pos());
       
  1807         break;
       
  1808     }
       
  1809 
       
  1810     case QEvent::GraphicsSceneMouseRelease: {            
       
  1811         QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
       
  1812         d->moveEvent(mouseEvent->lastPos(), mouseEvent->pos());
       
  1813         d->releaseEvent(mouseEvent->pos());
       
  1814         break;
       
  1815     }
       
  1816 
       
  1817     default:
       
  1818         return HbWidget::event(event);
  1746     }
  1819     }
  1747     return true;
  1820     return true;
  1748 }
  1821 }
  1749 
  1822 
  1750 /*!
  1823 /*!
  1804     HbWidget::changeEvent(event);
  1877     HbWidget::changeEvent(event);
  1805 }
  1878 }
  1806 
  1879 
  1807 /*!
  1880 /*!
  1808 \reimp
  1881 \reimp
  1809 
       
  1810 Enables touch events if multi touch is enabled.
       
  1811 */
  1882 */
  1812 void HbInputButtonGroup::showEvent(QShowEvent *event)
  1883 void HbInputButtonGroup::showEvent(QShowEvent *event)
  1813 {
  1884 {
  1814     Q_D(HbInputButtonGroup);
  1885     Q_D(HbInputButtonGroup);
  1815 
  1886 
  1882 void HbInputButtonGroup::cancelButtonPress()
  1953 void HbInputButtonGroup::cancelButtonPress()
  1883 {
  1954 {
  1884     Q_D(HbInputButtonGroup);
  1955     Q_D(HbInputButtonGroup);
  1885 
  1956 
  1886     ungrabMouse();
  1957     ungrabMouse();
       
  1958 
       
  1959     d->mActiveButtons.clear();
  1887 
  1960 
  1888     // Cancel long press timers
  1961     // Cancel long press timers
  1889     d->mLongPressButtons.clear();
  1962     d->mLongPressButtons.clear();
  1890     foreach (QTimer *timer, d->mLongPressTimers) {
  1963     foreach (QTimer *timer, d->mLongPressTimers) {
  1891         delete timer;
  1964         delete timer;
  1894 
  1967 
  1895     // Release all buttons and close previews
  1968     // Release all buttons and close previews
  1896     foreach (HbInputButton *button, d->mButtonData) {
  1969     foreach (HbInputButton *button, d->mButtonData) {
  1897         if (button->state() == HbInputButton::ButtonStatePressed) {
  1970         if (button->state() == HbInputButton::ButtonStatePressed) {
  1898             button->setState(HbInputButton::ButtonStateReleased);
  1971             button->setState(HbInputButton::ButtonStateReleased);
       
  1972             button->clearLastTriggeredPosition();
  1899         }
  1973         }
  1900         d->hideButtonPreview(button);
  1974         d->hideButtonPreview(button);
  1901     }
  1975     }
  1902     if (d->mCharacterSelectionPreview) {
  1976     if (d->mCharacterSelectionPreview) { 
  1903         d->mCharacterSelectionPreview->hide();
  1977         d->mCharacterSelectionPreview->hide();
  1904     }
  1978     }
  1905 
  1979     
  1906     d->updateGraphics(QSizeF(boundingRect().width(), boundingRect().height()));
  1980     d->updateGraphics(QSizeF(boundingRect().width(), boundingRect().height()));
  1907     d->updateTextLayouts(QSizeF(boundingRect().width(), boundingRect().height()));
  1981     d->updateTextLayouts(QSizeF(boundingRect().width(), boundingRect().height()));
  1908     update();
  1982     update();
  1909 }
  1983 }
  1910 
  1984