A combo box to select a unit for measures. More...
#include <klfunitinput.h>
Classes | |
struct | Unit |
Public Slots | |
void | setUnits (const QString &unitstrlist) |
void | setUnits (const QList< Unit > &unitlist) |
void | setCurrentUnit (const QString &unitName) |
void | setCurrentUnitAbbrev (const QString &unitAbbrev) |
void | setCurrentUnitIndex (int k) |
Signals | |
void | unitChanged (const QString &unitName) |
void | unitChanged (double unitFactor) |
void | unitChanged (double unitFactor, const QString &suffix) |
Public Member Functions | |
KLFUnitChooser (QWidget *parent=NULL) | |
virtual | ~KLFUnitChooser () |
Unit | currentUnit () const |
QString | currentUnitName () const |
QString | currentUnitAbbrev () const |
double | currentUnitFactor () const |
QStringList | unitNames () const |
QList< Unit > | unitList () const |
QString | unitStringDescription () const |
Protected Member Functions | |
virtual void | changeEvent (QEvent *event) |
Properties | |
QString | currentUnit |
double | currentUnitFactor |
QString | klfUnits |
A combo box to select a unit for measures.
Typical usage:
Definition at line 43 of file klfunitinput.h.
KLFUnitChooser::KLFUnitChooser | ( | QWidget * | parent = NULL | ) |
Definition at line 36 of file klfunitinput.cpp.
KLFUnitChooser::~KLFUnitChooser | ( | ) | [virtual] |
Definition at line 41 of file klfunitinput.cpp.
void KLFUnitChooser::changeEvent | ( | QEvent * | event | ) | [protected, virtual] |
Definition at line 122 of file klfunitinput.cpp.
References QString::isEmpty(), setCurrentUnit(), and QEvent::type().
Unit KLFUnitChooser::currentUnit | ( | ) | const [inline] |
Definition at line 60 of file klfunitinput.h.
QString KLFUnitChooser::currentUnitAbbrev | ( | ) | const [inline] |
Definition at line 62 of file klfunitinput.h.
double KLFUnitChooser::currentUnitFactor | ( | ) | const [inline] |
Definition at line 63 of file klfunitinput.h.
QString KLFUnitChooser::currentUnitName | ( | ) | const [inline] |
Definition at line 61 of file klfunitinput.h.
void KLFUnitChooser::setCurrentUnit | ( | const QString & | unitName | ) | [slot] |
Definition at line 86 of file klfunitinput.cpp.
References KLF_FUNC_NAME, and setCurrentUnitIndex().
Referenced by changeEvent().
void KLFUnitChooser::setCurrentUnitAbbrev | ( | const QString & | unitAbbrev | ) | [slot] |
Definition at line 97 of file klfunitinput.cpp.
References KLF_FUNC_NAME, and setCurrentUnitIndex().
void KLFUnitChooser::setCurrentUnitIndex | ( | int | k | ) | [slot] |
Definition at line 110 of file klfunitinput.cpp.
References unitChanged().
Referenced by setCurrentUnit(), and setCurrentUnitAbbrev().
void KLFUnitChooser::setUnits | ( | const QString & | unitstrlist | ) | [slot] |
Set the possible units user can choose from. Units are specified as a string of semicolon-separated items, each item in the list corresponding to one unit, specified as a string like "Inch=in=25.4"
or "Centimeter=cm=10"
or "Millimeter=mm=1"
, that is a string with three sections separated by an '='
sign giving unit name, unit abbreviation, and the factor of that unit to a reference unit. See KLFUnitSpinBox for discussion about units.
Example:
setUnits("Postscript Point=pt=1;Millimeter=mm=2.835;Centimeter=cm=28.35;1/8 th inch=1/8 in=9;Inch=in=72")
Definition at line 45 of file klfunitinput.cpp.
References KLFUnitChooser::Unit::abbrev, KLFUnitChooser::Unit::factor, KLF_FUNC_NAME, KLFUnitChooser::Unit::name, QList::size(), and QString::split().
void KLFUnitChooser::setUnits | ( | const QList< Unit > & | unitlist | ) | [slot] |
Set the possible units user can choose from.
Definition at line 65 of file klfunitinput.cpp.
References KLFUnitChooser::Unit::name, and QList::size().
void KLFUnitChooser::unitChanged | ( | const QString & | unitName | ) | [signal] |
Referenced by setCurrentUnitIndex().
void KLFUnitChooser::unitChanged | ( | double | unitFactor | ) | [signal] |
void KLFUnitChooser::unitChanged | ( | double | unitFactor, |
const QString & | suffix | ||
) | [signal] |
QList<Unit> KLFUnitChooser::unitList | ( | ) | const [inline] |
Definition at line 67 of file klfunitinput.h.
QStringList KLFUnitChooser::unitNames | ( | ) | const [inline] |
Definition at line 65 of file klfunitinput.h.
References KLFUnitChooser::Unit::name.
QString KLFUnitChooser::unitStringDescription | ( | ) | const |
Definition at line 77 of file klfunitinput.cpp.
References QString::arg(), QStringList::join(), and QList::size().
QString KLFUnitChooser::currentUnit [read, write] |
Definition at line 47 of file klfunitinput.h.
double KLFUnitChooser::currentUnitFactor [read] |
Definition at line 48 of file klfunitinput.h.
QString KLFUnitChooser::klfUnits [read, write] |
Definition at line 49 of file klfunitinput.h.