src/hbwidgets/sliders/hbslider.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    28 #include "hbslidercontrol_p.h"
    28 #include "hbslidercontrol_p.h"
    29 #include "hbslidercontrol_p_p.h"
    29 #include "hbslidercontrol_p_p.h"
    30 #include "hbnamespace_p.h"
    30 #include "hbnamespace_p.h"
    31 #include "hbsliderhandle_p.h"
    31 #include "hbsliderhandle_p.h"
    32 
    32 
    33 #include "hbstyleoptionslider.h"
    33 #include "hbstyleoptionslider_p.h"
    34 #include "hbslidertickmarkslabel_p.h"
    34 #include "hbslidertickmarkslabel_p.h"
    35 #include "hbabstractbutton.h"
    35 #include "hbabstractbutton.h"
    36 #include <hbwidgetfeedback.h>
    36 #include <hbwidgetfeedback.h>
    37 #include <QGraphicsItem>
    37 #include <QGraphicsItem>
    38 #include <QGraphicsSceneEvent>
    38 #include <QGraphicsSceneEvent>
   549 HbSlider::~HbSlider( )
   549 HbSlider::~HbSlider( )
   550 {
   550 {
   551 }
   551 }
   552 
   552 
   553 /*!
   553 /*!
   554     \deprecated HbSlider::elements() const
       
   555         is deprecated. Please use sliderElements() instead
       
   556     Returns the elements of the slider.
       
   557 
       
   558     The slider contains only track element by default.
       
   559 
       
   560     \sa setElements( )
       
   561 */
       
   562 QList<HbSlider::SliderElement> HbSlider::elements( ) const
       
   563 {
       
   564     qDebug("HbSlider::elements() is deprecated. Use sliderElements() instead.");
       
   565     Q_D( const HbSlider );
       
   566     return d->elements;
       
   567 }
       
   568 
       
   569 /*!
       
   570     \deprecated HbSlider::setElements(const QList<HbSlider::SliderElement>&)
       
   571         is deprecated. Please use setSliderElements instead.
       
   572     Sets the elements of the slider.
       
   573 
       
   574     \note Duplicate elements will be ignored.
       
   575 
       
   576     \note element order cant be changed
       
   577 
       
   578     \sa elements( )
       
   579 */
       
   580 void HbSlider::setElements( const QList<SliderElement> &elements )
       
   581 {
       
   582     qDebug("HbSlider::setElements is deprecated. Use setSliderElements instead.");
       
   583     Q_D( HbSlider );
       
   584     bool oldElementRemoved = false;
       
   585     foreach(HbSlider::SliderElement element,d->elements){
       
   586         if(!elements.contains(element)&&d->elementItemMap.contains(element)) {
       
   587             delete d->elementItemMap[element].item;
       
   588             delete d->elementItemMap[element].touchItem;
       
   589             d->elementItemMap.remove(element);
       
   590             oldElementRemoved = true;
       
   591         }
       
   592     }
       
   593     if(oldElementRemoved) {
       
   594         repolish( );
       
   595     }
       
   596     d->elements = elements;
       
   597     // this will delete unwanted element and create new element
       
   598     d->updateElements( );
       
   599     // repolish call is required because new elements might be added
       
   600 }
       
   601 
       
   602 
       
   603 /*!
       
   604     @proto
   554     @proto
   605     Returns the list of slider elements as QVariant 
   555     Returns the list of slider elements as QVariant 
   606     
   556     
   607     \note it is safe to type-cast element to HbSlider::SliderElement.  
   557     \note it is safe to type-cast element to HbSlider::SliderElement.  
   608    
   558    
   779             d->elementWidget( HbSlider::TextElement );  
   729             d->elementWidget( HbSlider::TextElement );  
   780         }
   730         }
   781         // sets text for tooltip also
   731         // sets text for tooltip also
   782         d->sliderControl->setToolTip( text );
   732         d->sliderControl->setToolTip( text );
   783         repolish();
   733         repolish();
   784     }
       
   785 }
       
   786 
       
   787 /*!
       
   788     \deprecated HbSlider::icon(HbSlider::SliderElement) const
       
   789         is deprecated. Please use elementIcons() instead.
       
   790     
       
   791     Returns the icon of the \a element.
       
   792 
       
   793     returns NULL if element does not exist or icon was not set for this element
       
   794 
       
   795     \sa setIcon( )
       
   796 */
       
   797 HbIcon HbSlider::icon( SliderElement element ) const
       
   798 {
       
   799     qDebug("HbSlider::icon() is deprecated. Use elementIcons() instead.");
       
   800     Q_D( const HbSlider );
       
   801     return d->icons.value( element );
       
   802 }
       
   803 
       
   804 /*!
       
   805     \deprecated HbSlider::setIcon(HbSlider::SliderElement, const HbIcon&)
       
   806         is deprecated. Please use setElementIcons() instead.
       
   807     
       
   808     Sets the \a icon if the \a element.
       
   809 
       
   810     Supported elements:
       
   811     \li HbSlider::IncreaseElement
       
   812     \li HbSlider::DecreaseElement
       
   813     \li HbSlider::IconElement
       
   814 
       
   815     \warning Setting icon to a non-existing element has no effect.
       
   816 
       
   817     \sa icon( ) setElements( )
       
   818 */
       
   819 void HbSlider::setIcon( SliderElement element, const HbIcon &icon )
       
   820 {
       
   821     qDebug("HbSlider::setIcon() is deprecated. Use setElementIcons() instead.");
       
   822     Q_D( HbSlider );
       
   823     if ( element != TextElement &&!icon.isNull()) {
       
   824         d->icons[element] = icon;
       
   825         if ( d->elements.contains( element ) ) {
       
   826             // create icon element if it was not existing
       
   827             d->elementWidget( element ); 
       
   828             // update icon primitive
       
   829             
       
   830         } 
       
   831 
       
   832     } else {
       
   833         qWarning( "HbSlider::setIcon: non-supported element or null icon passed" );
       
   834     }
   734     }
   835 }
   735 }
   836 
   736 
   837 /*!
   737 /*!
   838     @beta
   738     @beta