Beispiel #1
0
//Same again but with the emits..
void ChocoboEditor::RatingChanged(int rating)
{
	choco_rating=rating;
	emit ratingChanged(choco_rating);
}
/*!
    \reimp
 */
void HbRatingSlider::gestureEvent(QGestureEvent *event)
{
    Q_D (HbRatingSlider);
    if(event->gesture(Qt::TapGesture)) {
            HbTapGesture *tap = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture));
            switch(tap->state()) {
            case Qt::GestureStarted:
                {
                qreal xVal = mapFromScene(event->mapToGraphicsScene(tap->position( ))).x();
                int rating = d->calculateProgressValue(xVal);
                if(rating == -1) {
                    return;
                }
                if(d->mReadOnly) {    
                    event->ignore();
                    return;
                }
                QRectF rect = d->mTouchArea->boundingRect();
                if(rect.contains(xVal,0 )) {
                    HbWidgetFeedback::triggered(this, Hb::InstantPressed);
                    d->mMousePressed = true;
                    updatePrimitives();
                    rating = d->calculateProgressValue(xVal);
                    setCurrentRating(rating);
                    event->accept();
                }
                else {
                    event->ignore();
                }
                
                }
                break;
 
            case Qt::GestureFinished: // Reset state 
                {
            qreal xVal = mapFromScene(event->mapToGraphicsScene(tap->position( ))).x();
            QRectF rect = d->mTouchArea->boundingRect();
            int rating=0;
            if(rect.contains(xVal,0 )) {
                if(d->mReadOnly) {
                    event->ignore();
                    return;
                }

                if(!d->mMousePressed){
                    return;
                }

                if(xVal <0) {    
                    setCurrentRating(0);
                    emit ratingDone (d->mCurrentValue);
                    return;
                }

               rating = d->calculateProgressValue(xVal);
        
               if(!toolTip().isNull()) {
                    HbToolTip::showText(toolTip(),this);
                }    
                setCurrentRating(rating);
                HbWidgetFeedback::triggered(this, Hb::InstantReleased);
                if(d->mCurrentValue) {
                    emit ratingDone (d->mCurrentValue);
                }

                event->accept();
                d->mMousePressed = false;
                updatePrimitives();
            }            
            else {

                d->mMousePressed = false;
                updatePrimitives();

                if(xVal <rect.x() )  {

                    setCurrentRating(0);
                    emit ratingDone (d->mCurrentValue);
                }
            
            }
            



            }
            break;
            default: break;
            } 
    }else if(event->gesture(Qt::PanGesture)) {
                HbPanGesture *pan = qobject_cast<HbPanGesture *>(event->gesture(Qt::PanGesture));
                switch(pan->state()) {
                    case Qt::GestureUpdated:
                        {
                        if(!d->mMousePressed) {
                            return;
                        }
                        qreal xVal = mapFromScene(event->mapToGraphicsScene( pan->startPos()+pan->offset())).x();
                            QRectF rect = d->mTouchArea->boundingRect();
                            int rating=0;
                            if(rect.contains(xVal,0 )) {
                                if(d->mReadOnly) {
                                event->ignore();
                                return;
                            }
                            
                            if(xVal <0) {    
                                setCurrentRating(0);
                                return;
                            }

                                rating = d->calculateProgressValue(xVal);
                                
                                if(!toolTip().isNull()) {
                                    HbToolTip::showText(toolTip(),this);
                                }    
                                setCurrentRating(rating);
                                HbWidgetFeedback::continuousTriggered(this, Hb::ContinuousDragged);
                                emit ratingChanged (d->mCurrentValue);
                                event->accept();
                            }
                            else {
                                setCurrentRating(0);
                            }
                        }
                        break;
                    case Qt::GestureFinished: // Reset state 
                    {                          
                         qreal xVal = mapFromScene(event->mapToGraphicsScene( pan->startPos()+pan->offset())).x();
                         QRectF rect = d->mTouchArea->boundingRect();
                         d->mMousePressed = false;
                         updatePrimitives();
                         int rating=0;
                         if(rect.contains(xVal,0 )) {
                            if(d->mReadOnly) {
                               event->ignore();
                               return;
                             }
                         }

                         if(xVal <0) {    
                            setCurrentRating(0);
                            emit ratingDone (d->mCurrentValue);
                            return;
                          }

                          rating = d->calculateProgressValue(xVal);
                          setCurrentRating(rating);
                          HbWidgetFeedback::triggered(this, Hb::InstantReleased);
                          if(d->mCurrentValue) {
                             emit ratingDone (d->mCurrentValue);
                           }                       
                           event->accept();
                        
                      }
                     
					
					default:
                      break;
                }
    }
}
Beispiel #3
0
void Game::setRating(quint16 a_uiRating)
{
    m_uiRating = a_uiRating;
    emit ratingChanged(a_uiRating);
}