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=nullptr) | |
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=nullptr, bool noProperty=false, char checkPrefix=0, bool checkInList=true) | |
void | hideCompleter () |
void | setDocumentObject (const App::DocumentObject *currentDocObj, bool checkInList=true) |
void | setExactMatch (bool enabled=true) |
void | setNoProperty (bool enabled=true) |
void | setPrefix (char prefix) |
Public Member Functions inherited from Gui::ExpressionBinding | |
virtual bool | apply () |
virtual bool | apply (const std::string &propName) |
bool | autoApply () const |
virtual void | bind (const App::ObjectIdentifier &_path) |
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) |
void | unbind () |
virtual | ~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 | contextMenuEvent (QContextMenuEvent *event) |
void | keyPressEvent (QKeyEvent *event) |
Protected Member Functions inherited from Gui::ExpressionBinding | |
void | expressionChange (const App::ObjectIdentifier &id) |
std::string | getEscapedExpressionString () const |
std::shared_ptr< App::Expression > | getExpression () const |
std::string | getExpressionString (bool no_throw=true) const |
const App::ObjectIdentifier & | getPath () const |
void | makeLabel (QLineEdit *parent) |
void | objectDeleted (const App::DocumentObject &) |
virtual void | onChange () |
virtual void | setExpression (std::shared_ptr< App::Expression > expr) |
Protected Attributes inherited from Gui::ExpressionBinding | |
QPalette | defaultPalette |
boost::signals2::scoped_connection | expressionchanged |
int | iconHeight |
ExpressionLabel * | iconLabel |
bool | m_autoApply |
boost::signals2::scoped_connection | objectdeleted |
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.
InputField::InputField | ( | QWidget * | parent = nullptr | ) |
|
virtual |
|
virtual |
Reimplemented from Gui::ExpressionBinding.
References Gui::ExpressionBinding::apply().
|
virtual |
Reimplemented from Gui::ExpressionBinding.
References Gui::ExpressionBinding::apply(), Gui::Command::Doc, and getQuantity().
|
virtual |
|
protectedvirtual |
References getHistory(), getSavedValues(), and pushToSavedValues().
void InputField::fixup | ( | QString & | input | ) | const |
input validation
Referenced by Gui::InputValidator::fixup(), newInput(), and validate().
|
protectedvirtual |
References selectNumber().
|
protectedvirtual |
References Base::Quantity::getUserString().
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().
std::vector< QString > InputField::getHistory | ( | void | ) |
get the history of the field, newest first
Referenced by contextMenuEvent(), pushToHistory(), and setToLastUsedValue().
int InputField::getPrecision | ( | void | ) | const |
get the value of the precision property
References Base::Quantity::getFormat(), and Base::QuantityFormat::precision.
Base::Quantity Gui::InputField::getQuantity | ( | void | ) | const |
get the current value
Referenced by apply(), FemGui::TaskFemConstraintTemperature::get_cflux(), FemGui::TaskFemConstraintSpring::get_normalStiffness(), FemGui::TaskFemConstraintPressure::get_Pressure(), FemGui::TaskFemConstraintSpring::get_tangentialStiffness(), FemGui::TaskFemConstraintInitialTemperature::get_temperature(), FemGui::TaskFemConstraintTemperature::get_temperature(), FemGui::TaskFemConstraintHeatflux::getAmbientTemp(), and FemGui::TaskFemConstraintHeatflux::getFilmCoef().
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().
std::vector< QString > InputField::getSavedValues | ( | void | ) |
get the history of the field, newest first
Referenced by contextMenuEvent().
const Base::Unit & InputField::getUnit | ( | void | ) | const |
QString InputField::getUnitText | ( | void | ) |
get the unit as a string (can be used in the *.ui file)
References Base::Quantity::getUserString().
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)
int Gui::InputField::historySize | ( | void | ) | const |
get the value of the minimum property
|
protectedvirtual |
References Base::Quantity::getUserString().
double Gui::InputField::maximum | ( | void | ) | const |
get the value of the maximum property
double Gui::InputField::minimum | ( | void | ) | const |
get the value of the minimum property
|
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().
QByteArray InputField::paramGrpPath | ( | ) | const |
the param group path where the widget writes and reads the default values
Returns the widget's preferences path.
|
signal |
signal for an invalid user input (signals a lot while typing!)
Referenced by newInput().
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().
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().
QString Gui::InputField::rawText | ( | void | ) | const |
return the quantity in C locale, i.e. decimal separator is a dot.
double InputField::rawValue | ( | ) | const |
Get the current quantity without unit.
References Base::Quantity::getValue().
|
protectedvirtual |
References Gui::ExpressionBinding::iconLabel.
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().
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.PathInspect.GCodeHighlighter::highlightBlock(), and PathScripts.PostUtils.GCodeHighlighter::highlightBlock().
void InputField::setHistorySize | ( | int | i | ) |
set the value of the minimum property
void InputField::setMaximum | ( | double | m | ) |
set the value of the maximum property
References Base::Quantity::getValue(), and Base::Quantity::setValue().
Referenced by Ui_TaskFemConstraintContact::setupUi(), FemGui::TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(), FemGui::TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature(), FemGui::TaskFemConstraintPressure::TaskFemConstraintPressure(), FemGui::TaskFemConstraintSpring::TaskFemConstraintSpring(), and FemGui::TaskFemConstraintTemperature::TaskFemConstraintTemperature().
void InputField::setMinimum | ( | double | m | ) |
set the value of the minimum property
References Base::Quantity::getValue(), and Base::Quantity::setValue().
Referenced by FemGui::TaskFemConstraintContact::TaskFemConstraintContact(), FemGui::TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(), FemGui::TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature(), FemGui::TaskFemConstraintPressure::TaskFemConstraintPressure(), FemGui::TaskFemConstraintSpring::TaskFemConstraintSpring(), and FemGui::TaskFemConstraintTemperature::TaskFemConstraintTemperature().
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().
void InputField::setPrecision | ( | const int | precision | ) |
set the value of the precision property (can be used in the *.ui file)
References Base::Quantity::getFormat(), Base::QuantityFormat::precision, precision, and Base::Quantity::setFormat().
void InputField::setQuantityString | ( | const QString & | text | ) |
set, validate and display quantity from a string. Must match existing units.
References newInput().
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().
void InputField::setSingleStep | ( | double | s | ) |
set the value of the singleStep property
Referenced by Ui_TaskFemConstraintContact::setupUi().
void InputField::setToLastUsedValue | ( | void | ) |
set the input field to the last used value (works only if the setParamGrpPath() was called)
References getHistory().
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().
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().
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(), FemGui::TaskFemConstraintContact::TaskFemConstraintContact(), FemGui::TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(), FemGui::TaskFemConstraintInitialTemperature::TaskFemConstraintInitialTemperature(), FemGui::TaskFemConstraintPressure::TaskFemConstraintPressure(), FemGui::TaskFemConstraintSpring::TaskFemConstraintSpring(), and FemGui::TaskFemConstraintTemperature::TaskFemConstraintTemperature().
void InputField::setValue | ( | const double & | value | ) |
References setValue().
|
protectedvirtual |
References selectNumber().
double Gui::InputField::singleStep | ( | void | ) | const |
get the value of the singleStep property
|
protectedslot |
References Gui::ExpressionBinding::iconLabel.
Referenced by InputField().
QValidator::State InputField::validate | ( | QString & | input, |
int & | pos | ||
) | const |
input validation
References fixup().
Referenced by AddonManager.CommandAddonManager::startup(), and Gui::InputValidator::validate().
|
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().
|
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:
|
protectedvirtual |
References Base::Quantity::getUserString(), and selectNumber().
|
readwrite |
|
readwrite |
|
readwrite |
get the value of the maximum property
|
readwrite |
get the value of the minimum property
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
return the quantity in C locale, i.e. decimal separator is a dot.
|
readwrite |
Referenced by FemGui::TaskFemConstraintContact::get_Slope().
|
readwrite |
get the value of the singleStep property
|
readwrite |
Referenced by setUnit().