Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

DynamicSlider Class Reference

#include <dynamicSlider.h>

Inheritance diagram for DynamicSlider:

[legend]
Collaboration diagram for DynamicSlider:
[legend]
List of all members.

Detailed Description

A more dynamic slider that provides moving tooltips that show the slider value.

Definition at line 21 of file dynamicSlider.h.

Signals

void mouseHasMoved ()

Public Member Functions

 DynamicSlider (Orientation orientation, QWidget *parent, const char *name=0)
 ~DynamicSlider ()
void setZeroString (QString val)
 when set, a zero string is shown instead of the current value/prefix/suffix when the slider value is 0

void setPrefix (QString val)
 set the prefix that is displayed before the current slider value

void setPrefixes (QString prefix1, QString prefix2)
 set two prefix values, one for when the value is positive and one for when the value is negative.

void setSuffix (QString val)
 set the suffix that is displayed after the current slider value

void setSuffixes (QString suffix1, QString suffix2)
 set two suffix values, one for when the value is positive and one for when the value is negative.

QPoint getMousePos ()

Protected Member Functions

void mouseMoveEvent (QMouseEvent *e)
virtual QString mapValToString ()
 subclass DynamicSlider and reimplement this method to change the behavior used to display slider values


Private Slots

void updateTooltipLabel ()

Private Attributes

QString zeroString
QString prefix1
QString prefix2
QString suffix1
QString suffix2
SliderToolTiptooltip
QPoint cachedMousePos


Constructor & Destructor Documentation

DynamicSlider::DynamicSlider Orientation  orientation,
QWidget parent,
const char *  name = 0
 

Definition at line 17 of file dynamicSlider.cpp.

References DynamicSlider(), tooltip, and updateTooltipLabel().

Referenced by DynamicSlider().

00018 : QSlider(orientation, parent, name) 00019 { 00020 //determine the parent screen the tooltip will be displayed in and create tooltip 00021 int scr = QApplication::desktop()->screenNumber( this ); 00022 tooltip = new SliderToolTip( QApplication::desktop()->screen( scr ), this); 00023 updateTooltipLabel(); 00024 00025 //make sure tooltip label is updated when the slider value changes 00026 connect( this, SIGNAL( valueChanged(int) ), 00027 this, SLOT( updateTooltipLabel() ) ); 00028 }

DynamicSlider::~DynamicSlider  ) 
 

Definition at line 30 of file dynamicSlider.cpp.

References tooltip.

00031 { 00032 delete tooltip; 00033 tooltip = NULL; 00034 }


Member Function Documentation

QPoint DynamicSlider::getMousePos  ) 
 

Definition at line 119 of file dynamicSlider.cpp.

References cachedMousePos.

Referenced by SliderToolTip::update().

00119 { return cachedMousePos; }

QString DynamicSlider::mapValToString  )  [protected, virtual]
 

subclass DynamicSlider and reimplement this method to change the behavior used to display slider values

Reimplemented in BlurSharpenSlider.

Definition at line 70 of file dynamicSlider.cpp.

Referenced by updateTooltipLabel().

00071 { 00072 //the default behavior is to simply use the slider value directly 00073 if( orientation() == Qt::Vertical ) 00074 return QString("%1").arg( -value() ); 00075 else 00076 return QString("%1").arg(value()); 00077 }

void DynamicSlider::mouseHasMoved  )  [signal]
 

Referenced by mouseMoveEvent().

void DynamicSlider::mouseMoveEvent QMouseEvent *  e  )  [protected]
 

Definition at line 111 of file dynamicSlider.cpp.

References cachedMousePos, mouseHasMoved(), and mouseMoveEvent().

Referenced by mouseMoveEvent().

00112 { 00113 //cache the mouse position since the tooltip will need this information when updating itself 00114 cachedMousePos = e->pos(); 00115 QSlider::mouseMoveEvent(e); 00116 emit mouseHasMoved(); 00117 }

void DynamicSlider::setPrefix QString  val  ) 
 

set the prefix that is displayed before the current slider value

Definition at line 42 of file dynamicSlider.cpp.

References prefix1, prefix2, setPrefix(), and updateTooltipLabel().

Referenced by setPrefix().

00043 { 00044 prefix1 = val; 00045 prefix2 = QString( NULL ); 00046 updateTooltipLabel(); 00047 }

void DynamicSlider::setPrefixes QString  prefix1,
QString  prefix2
 

set two prefix values, one for when the value is positive and one for when the value is negative.

Definition at line 49 of file dynamicSlider.cpp.

References prefix1, prefix2, setPrefixes(), and updateTooltipLabel().

Referenced by HistogramEditor::HistogramEditor(), and setPrefixes().

00050 { 00051 prefix1 = v1; 00052 prefix2 = v2; 00053 updateTooltipLabel(); 00054 }

void DynamicSlider::setSuffix QString  val  ) 
 

set the suffix that is displayed after the current slider value

Definition at line 56 of file dynamicSlider.cpp.

References setSuffix(), suffix1, suffix2, and updateTooltipLabel().

Referenced by setSuffix().

00057 { 00058 suffix1 = val; 00059 suffix2 = QString( NULL ); 00060 updateTooltipLabel(); 00061 }

void DynamicSlider::setSuffixes QString  suffix1,
QString  suffix2
 

set two suffix values, one for when the value is positive and one for when the value is negative.

Definition at line 63 of file dynamicSlider.cpp.

References setSuffixes(), suffix1, suffix2, and updateTooltipLabel().

Referenced by setSuffixes().

00064 { 00065 suffix1 = v1; 00066 suffix2 = v2; 00067 updateTooltipLabel(); 00068 }

void DynamicSlider::setZeroString QString  val  ) 
 

when set, a zero string is shown instead of the current value/prefix/suffix when the slider value is 0

Definition at line 36 of file dynamicSlider.cpp.

References setZeroString(), updateTooltipLabel(), and zeroString.

Referenced by HistogramEditor::HistogramEditor(), and setZeroString().

00037 { 00038 zeroString = val; 00039 updateTooltipLabel(); 00040 }

void DynamicSlider::updateTooltipLabel  )  [private, slot]
 

Definition at line 79 of file dynamicSlider.cpp.

References mapValToString(), prefix1, prefix2, suffix1, suffix2, tooltip, and zeroString.

Referenced by DynamicSlider(), setPrefix(), setPrefixes(), setSuffix(), setSuffixes(), and setZeroString().

00080 { 00081 //determine string that will be used for tooltip 00082 QString tipString; 00083 00084 //if the value is zero and a zero string has been provided used that 00085 if( value() == 0 && !zeroString.isNull() ) 00086 { 00087 tipString = zeroString; 00088 } 00089 //otherwise construct a tip string using provided prefixes, suffixes, and the current slider value 00090 else 00091 { 00092 //determine prefix and suffix that will be used to construct tooltip string 00093 QString p, s; 00094 if( value() > 0 || prefix2.isNull() ) p = prefix1; 00095 else p = prefix2; 00096 00097 if( value() > 0 || suffix2.isNull() ) s = suffix1; 00098 else s = suffix2; 00099 00100 //construct tipstring 00101 tipString = QString("%1%2%3").arg(p).arg(mapValToString()).arg(s); 00102 00103 } 00104 00105 //update tooltip 00106 tooltip->setText( tipString ); 00107 tooltip->adjustSize(); 00108 if( tooltip->isShown() ) qApp->processEvents(); 00109 }


Member Data Documentation

QPoint DynamicSlider::cachedMousePos [private]
 

Definition at line 61 of file dynamicSlider.h.

Referenced by getMousePos(), and mouseMoveEvent().

QString DynamicSlider::prefix1 [private]
 

Definition at line 57 of file dynamicSlider.h.

Referenced by setPrefix(), setPrefixes(), and updateTooltipLabel().

QString DynamicSlider::prefix2 [private]
 

Definition at line 57 of file dynamicSlider.h.

Referenced by setPrefix(), setPrefixes(), and updateTooltipLabel().

QString DynamicSlider::suffix1 [private]
 

Definition at line 58 of file dynamicSlider.h.

Referenced by setSuffix(), setSuffixes(), and updateTooltipLabel().

QString DynamicSlider::suffix2 [private]
 

Definition at line 58 of file dynamicSlider.h.

Referenced by setSuffix(), setSuffixes(), and updateTooltipLabel().

SliderToolTip* DynamicSlider::tooltip [private]
 

Definition at line 60 of file dynamicSlider.h.

Referenced by DynamicSlider(), updateTooltipLabel(), and ~DynamicSlider().

QString DynamicSlider::zeroString [private]
 

Definition at line 55 of file dynamicSlider.h.

Referenced by setZeroString(), and updateTooltipLabel().


The documentation for this class was generated from the following files:
Generated on Sun Mar 4 19:43:05 2007 for AlbumShaper by doxygen 1.3.7