The InputField class The input field widget handles all around user input of Quantities. More...
#include <InputField.h>
Public Member Functions | |
void | fixup (QString &input) const |
input validation More... | |
QString | getFormat (void) const |
get the value of the format property: "f" (fixed), "e" (scientific), "g" (general) More... | |
int | getPrecision (void) const |
get the value of the precision property More... | |
Base::Quantity | getQuantity (void) const |
get the current value More... | |
QString | getQuantityString (void) const |
get stored, valid quantity as a string (user string - avoid storing) More... | |
const Base::Unit & | getUnit () const |
QString | getUnitText (void) |
get the unit as a string (can be used in the *.ui file) More... | |
bool | hasValidInput () |
gives the current state of the user input, gives true if it is a valid input with correct quantity (shown by the green pixmap), returns false if the input is a unparsable string or has a wrong unit (shown by the red pixmap in the gui) More... | |
int | historySize (void) const |
get the value of the minimum property More... | |
InputField (QWidget *parent=0) | |
double | maximum (void) const |
get the value of the maximum property More... | |
double | minimum (void) const |
get the value of the minimum property More... | |
QString | rawText (void) const |
return the quantity in C locale, i.e. decimal separator is a dot. More... | |
double | rawValue () const |
Get the current quantity without unit. More... | |
void | selectNumber (void) |
set the number portion selected (use after setValue()) More... | |
void | setFormat (const QString &) |
set the value of the format property (can be used in the *.ui file) More... | |
void | setHistorySize (int) |
set the value of the minimum property More... | |
void | setMaximum (double) |
set the value of the maximum property More... | |
void | setMinimum (double) |
set the value of the minimum property More... | |
void | setPrecision (const int) |
set the value of the precision property (can be used in the *.ui file) More... | |
void | setQuantityString (const QString &text) |
set, validate and display quantity from a string. Must match existing units. More... | |
void | setRawText (const QString &text) |
expects the string in C locale and internally converts it into the OS-specific locale More... | |
void | setSingleStep (double) |
set the value of the singleStep property More... | |
void | setToLastUsedValue (void) |
set the input field to the last used value (works only if the setParamGrpPath() was called) More... | |
void | setUnit (const Base::Unit &) |
sets the Unit this field is working with. More... | |
void | setUnitText (const QString &) |
set the unit by a string (can be used in the *.ui file) More... | |
void | setValue (const Base::Quantity &) |
set the field with a quantity More... | |
void | setValue (const double &) |
double | singleStep (void) const |
get the value of the singleStep property More... | |
QValidator::State | validate (QString &input, int &pos) const |
input validation More... | |
virtual | ~InputField () |
Public Member Functions inherited from Gui::ExpressionLineEdit | |
bool | completerActive () const |
ExpressionLineEdit (QWidget *parent=0, bool noProperty=false) | |
void | hideCompleter () |
void | setDocumentObject (const App::DocumentObject *currentDocObj) |
void | setNoProperty (bool enabled=true) |
Public Member Functions inherited from Gui::ExpressionBinding | |
bool | autoApply () const |
virtual void | bind (const App::Property &prop) |
ExpressionBinding () | |
QPixmap | getIcon (const char *name, const QSize &size) const |
bool | hasExpression () const |
bool | isBound () const |
void | setAutoApply (bool value) |
~ExpressionBinding () | |
Properties | |
QString | format |
int | historySize |
double | maximum |
get the value of the maximum property More... | |
double | minimum |
get the value of the minimum property More... | |
int | precision |
QByteArray | prefPath |
Base::Quantity | quantity |
QString | quantityString |
QString | rawText |
return the quantity in C locale, i.e. decimal separator is a dot. More... | |
double | rawValue |
double | singleStep |
get the value of the singleStep property More... | |
QString | unit |
history and default management | |
QByteArray | paramGrpPath () const |
the param group path where the widget writes and reads the default values More... | |
void | setParamGrpPath (const QByteArray &name) |
set the param group path where the widget writes and reads the default values More... | |
void | pushToHistory (const QString &valueq=QString()) |
push a new value to the history, if no string given the actual text of the input field is used. More... | |
std::vector< QString > | getHistory (void) |
get the history of the field, newest first More... | |
void | pushToSavedValues (const QString &valueq=QString()) |
push a new value to the history, if no string given the actual text of the input field is used. More... | |
std::vector< QString > | getSavedValues (void) |
get the history of the field, newest first More... | |
void | bind (const App::ObjectIdentifier &_path) |
bool | apply (const std::string &propName) |
bool | apply () |
void | valueChanged (const Base::Quantity &) |
gets emitted if the user has entered a VALID input Valid means the user inputted string obeys all restrictions like: minimum, maximum and/or the right Unit (if specified). More... | |
void | valueChanged (double) |
gets emitted if the user has entered a VALID input Valid means the user inputted string obeys all restrictions like: minimum, maximum and/or the right Unit (if specified). More... | |
void | parseError (const QString &errorText) |
signal for an invalid user input (signals a lot while typing!) More... | |
void | newInput (const QString &text) |
void | updateIconLabel (const QString &text) |
virtual void | showEvent (QShowEvent *event) |
virtual void | focusInEvent (QFocusEvent *event) |
virtual void | focusOutEvent (QFocusEvent *event) |
virtual void | keyPressEvent (QKeyEvent *event) |
virtual void | wheelEvent (QWheelEvent *event) |
virtual void | contextMenuEvent (QContextMenuEvent *event) |
virtual void | resizeEvent (QResizeEvent *) |
Additional Inherited Members | |
Public Slots inherited from Gui::ExpressionLineEdit | |
void | slotCompleteText (const QString &completionPrefix) |
void | slotTextChanged (const QString &text) |
Signals inherited from Gui::ExpressionLineEdit | |
void | textChanged2 (QString text, int pos) |
Protected Member Functions inherited from Gui::ExpressionLineEdit | |
void | keyPressEvent (QKeyEvent *event) |
Protected Member Functions inherited from Gui::ExpressionBinding | |
void | expressionChange (const App::ObjectIdentifier &id) |
std::string | getEscapedExpressionString () const |
boost::shared_ptr< App::Expression > | getExpression () const |
std::string | getExpressionString (bool no_throw=true) const |
const App::ObjectIdentifier & | getPath () const |
virtual void | onChange () |
virtual void | setExpression (boost::shared_ptr< App::Expression > expr) |
Protected Attributes inherited from Gui::ExpressionBinding | |
boost::signals2::scoped_connection | connection |
QPalette | defaultPalette |
int | iconHeight |
QLabel * | iconLabel |
bool | m_autoApply |
Detailed Description
The InputField class The input field widget handles all around user input of Quantities.
That includes parsing and checking input. Providing a context menu for common operations and managing default and history values. Although it's derived from a QLineEdit widget, it supports most of the properties and signals of a spin box.
Constructor & Destructor Documentation
◆ InputField()
InputField::InputField | ( | QWidget * | parent = 0 | ) |
References Gui::ExpressionBinding::iconLabel, newInput(), and updateIconLabel().
◆ ~InputField()
|
virtual |
Member Function Documentation
◆ apply() [1/2]
|
virtual |
Reimplemented from Gui::ExpressionBinding.
References Gui::ExpressionBinding::apply().
◆ apply() [2/2]
|
virtual |
Reimplemented from Gui::ExpressionBinding.
References Gui::ExpressionBinding::apply(), Gui::Command::Doc, and getQuantity().
◆ bind()
|
virtual |
◆ contextMenuEvent()
|
protectedvirtual |
References getHistory(), getSavedValues(), and pushToSavedValues().
◆ fixup()
void InputField::fixup | ( | QString & | input | ) | const |
input validation
Referenced by Gui::InputValidator::fixup(), newInput(), and validate().
◆ focusInEvent()
|
protectedvirtual |
References selectNumber().
◆ focusOutEvent()
|
protectedvirtual |
References Base::Quantity::getUserString().
◆ getFormat()
QString InputField::getFormat | ( | void | ) | const |
get the value of the format property: "f" (fixed), "e" (scientific), "g" (general)
References Base::Quantity::getFormat(), and Base::QuantityFormat::toFormat().
◆ getHistory()
std::vector< QString > InputField::getHistory | ( | void | ) |
get the history of the field, newest first
Referenced by contextMenuEvent(), pushToHistory(), and setToLastUsedValue().
◆ getPrecision()
int InputField::getPrecision | ( | void | ) | const |
get the value of the precision property
References Base::Quantity::getFormat(), and Base::QuantityFormat::precision.
◆ getQuantity()
Base::Quantity Gui::InputField::getQuantity | ( | void | ) | const |
get the current value
Referenced by apply().
◆ getQuantityString()
QString InputField::getQuantityString | ( | void | ) | const |
get stored, valid quantity as a string (user string - avoid storing)
get stored, valid quantity as a string
References Base::Quantity::getUserString().
◆ getSavedValues()
std::vector< QString > InputField::getSavedValues | ( | void | ) |
get the history of the field, newest first
Referenced by contextMenuEvent().
◆ getUnit()
const Base::Unit & InputField::getUnit | ( | ) | const |
◆ getUnitText()
QString InputField::getUnitText | ( | void | ) |
get the unit as a string (can be used in the *.ui file)
References Base::Quantity::getUserString().
◆ hasValidInput()
bool Gui::InputField::hasValidInput | ( | ) |
gives the current state of the user input, gives true if it is a valid input with correct quantity (shown by the green pixmap), returns false if the input is a unparsable string or has a wrong unit (shown by the red pixmap in the gui)
◆ historySize()
int Gui::InputField::historySize | ( | void | ) | const |
get the value of the minimum property
◆ keyPressEvent()
|
protectedvirtual |
References Base::Quantity::getUserString().
◆ maximum()
double Gui::InputField::maximum | ( | void | ) | const |
get the value of the maximum property
◆ minimum()
double Gui::InputField::minimum | ( | void | ) | const |
get the value of the minimum property
◆ newInput
|
protectedslot |
References fixup(), Gui::ExpressionBinding::getExpression(), Base::Quantity::getFormat(), Gui::ExpressionBinding::getPath(), Gui::ExpressionBinding::iconLabel, Gui::ExpressionBinding::isBound(), Base::Unit::isEmpty(), parseError(), Gui::ExpressionBinding::setExpression(), and valueChanged().
Referenced by bind(), InputField(), setQuantityString(), and setRawText().
◆ paramGrpPath()
QByteArray InputField::paramGrpPath | ( | ) | const |
the param group path where the widget writes and reads the default values
Returns the widget's preferences path.
◆ parseError
|
signal |
signal for an invalid user input (signals a lot while typing!)
Referenced by newInput().
◆ pushToHistory()
void InputField::pushToHistory | ( | const QString & | valueq = QString() | ) |
push a new value to the history, if no string given the actual text of the input field is used.
References getHistory().
◆ pushToSavedValues()
void InputField::pushToSavedValues | ( | const QString & | valueq = QString() | ) |
push a new value to the history, if no string given the actual text of the input field is used.
Referenced by contextMenuEvent().
◆ rawText()
QString Gui::InputField::rawText | ( | void | ) | const |
return the quantity in C locale, i.e. decimal separator is a dot.
◆ rawValue()
double Gui::InputField::rawValue | ( | ) | const |
Get the current quantity without unit.
◆ resizeEvent()
|
protectedvirtual |
References Gui::ExpressionBinding::iconLabel.
◆ selectNumber()
void InputField::selectNumber | ( | void | ) |
set the number portion selected (use after setValue())
References Base::QuantityFormat::Fixed, Base::QuantityFormat::format, and Base::Quantity::getFormat().
Referenced by focusInEvent(), showEvent(), and wheelEvent().
◆ setFormat()
void InputField::setFormat | ( | const QString & | format | ) |
set the value of the format property (can be used in the *.ui file)
References Base::QuantityFormat::format, Base::Quantity::getFormat(), Base::Quantity::setFormat(), and Base::QuantityFormat::toFormat().
Referenced by PathScripts.PostUtils.GCodeHighlighter::highlightBlock(), and PathScripts.PathInspect.GCodeHighlighter::highlightBlock().
◆ setHistorySize()
void InputField::setHistorySize | ( | int | i | ) |
set the value of the minimum property
◆ setMaximum()
void InputField::setMaximum | ( | double | m | ) |
set the value of the maximum property
References Base::Quantity::getValue(), and Base::Quantity::setValue().
◆ setMinimum()
void InputField::setMinimum | ( | double | m | ) |
set the value of the minimum property
References Base::Quantity::getValue(), and Base::Quantity::setValue().
◆ setParamGrpPath()
void InputField::setParamGrpPath | ( | const QByteArray & | name | ) |
set the param group path where the widget writes and reads the default values
Sets the preference path to path.
References App::GetApplication(), and App::Application::GetParameterGroupByPath().
◆ setPrecision()
void InputField::setPrecision | ( | const int | precision | ) |
set the value of the precision property (can be used in the *.ui file)
References Base::Quantity::getFormat(), precision, Base::QuantityFormat::precision, and Base::Quantity::setFormat().
◆ setQuantityString()
void InputField::setQuantityString | ( | const QString & | text | ) |
set, validate and display quantity from a string. Must match existing units.
References newInput().
◆ setRawText()
void InputField::setRawText | ( | const QString & | text | ) |
expects the string in C locale and internally converts it into the OS-specific locale
References Base::Quantity::getUserString(), newInput(), and Base::Quantity::parse().
◆ setSingleStep()
void InputField::setSingleStep | ( | double | s | ) |
set the value of the singleStep property
◆ setToLastUsedValue()
void InputField::setToLastUsedValue | ( | void | ) |
set the input field to the last used value (works only if the setParamGrpPath() was called)
References getHistory().
◆ setUnit()
void InputField::setUnit | ( | const Base::Unit & | unit | ) |
sets the Unit this field is working with.
After setting the Unit the field will only accept user input with this unit type. Or if the user input a value without unit, this one will be added to the resulting Quantity.
References Base::Quantity::setUnit(), and unit.
Referenced by setUnitText().
◆ setUnitText()
void InputField::setUnitText | ( | const QString & | str | ) |
set the unit by a string (can be used in the *.ui file)
References Base::Quantity::getUnit(), Base::Quantity::parse(), and setUnit().
◆ setValue() [1/2]
void InputField::setValue | ( | const Base::Quantity & | quant | ) |
set the field with a quantity
sets the field with a quantity
References Base::Quantity::getUnit(), Base::Quantity::getValue(), and Base::Quantity::setValue().
Referenced by setValue().
◆ setValue() [2/2]
void InputField::setValue | ( | const double & | value | ) |
References setValue().
◆ showEvent()
|
protectedvirtual |
References selectNumber().
◆ singleStep()
double Gui::InputField::singleStep | ( | void | ) | const |
get the value of the singleStep property
◆ updateIconLabel
|
protectedslot |
References Gui::ExpressionBinding::iconLabel.
Referenced by InputField().
◆ validate()
QValidator::State InputField::validate | ( | QString & | input, |
int & | pos | ||
) | const |
◆ valueChanged [1/2]
|
signal |
gets emitted if the user has entered a VALID input Valid means the user inputted string obeys all restrictions like: minimum, maximum and/or the right Unit (if specified).
If you want the unfiltered/non-validated input use textChanged(const QString&) instead:
Referenced by newInput().
◆ valueChanged [2/2]
|
signal |
gets emitted if the user has entered a VALID input Valid means the user inputted string obeys all restrictions like: minimum, maximum and/or the right Unit (if specified).
If you want the unfiltered/non-validated input use textChanged(const QString&) instead:
◆ wheelEvent()
|
protectedvirtual |
References Base::Quantity::getUserString(), and selectNumber().
Property Documentation
◆ format
|
readwrite |
◆ historySize
|
readwrite |
◆ maximum
|
readwrite |
get the value of the maximum property
◆ minimum
|
readwrite |
get the value of the minimum property
◆ precision
|
readwrite |
◆ prefPath
|
readwrite |
◆ quantity
|
readwrite |
◆ quantityString
|
readwrite |
◆ rawText
|
readwrite |
return the quantity in C locale, i.e. decimal separator is a dot.
◆ rawValue
|
readwrite |
◆ singleStep
|
readwrite |
get the value of the singleStep property
◆ unit
|
readwrite |
Referenced by setUnit().
The documentation for this class was generated from the following files:
- src/Gui/InputField.h
- src/Gui/InputField.cpp