Gui::InputField Class Reference

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::UnitgetUnit () 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::ExpressiongetExpression () const
 
std::string getExpressionString (bool no_throw=true) const
 
const App::ObjectIdentifiergetPath () 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
 
ExpressionLabeliconLabel
 
bool m_autoApply
 
boost::signals2::scoped_connection objectdeleted
 

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.

Author
Jürgen Riegel

Constructor & Destructor Documentation

◆ InputField()

InputField::InputField ( QWidget parent = nullptr)

◆ ~InputField()

InputField::~InputField ( )
virtual

Member Function Documentation

◆ apply() [1/2]

bool InputField::apply ( )
virtual

◆ apply() [2/2]

bool InputField::apply ( const std::string &  propName)
virtual

◆ bind()

◆ contextMenuEvent()

void InputField::contextMenuEvent ( QContextMenuEvent *  event)
protectedvirtual

◆ fixup()

void InputField::fixup ( QString &  input) const

input validation

Referenced by Gui::InputValidator::fixup(), newInput(), and validate().

◆ focusInEvent()

void InputField::focusInEvent ( QFocusEvent *  event)
protectedvirtual

References selectNumber().

◆ focusOutEvent()

void InputField::focusOutEvent ( QFocusEvent *  event)
protectedvirtual

◆ 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()

◆ 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 ( void  ) 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()

void InputField::keyPressEvent ( QKeyEvent *  event)
protectedvirtual

◆ 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

◆ 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

void Gui::InputField::parseError ( const QString &  errorText)
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 InputField::rawValue ( ) const

Get the current quantity without unit.

References Base::Quantity::getValue().

◆ resizeEvent()

void InputField::resizeEvent ( QResizeEvent *  )
protectedvirtual

◆ 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)

◆ setHistorySize()

void InputField::setHistorySize ( int  i)

set the value of the minimum property

◆ setMaximum()

◆ setMinimum()

◆ 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(), Base::QuantityFormat::precision, 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

Referenced by Ui_TaskFemConstraintContact::setupUi().

◆ 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]

◆ setValue() [2/2]

void InputField::setValue ( const double &  value)

References setValue().

◆ showEvent()

void InputField::showEvent ( QShowEvent *  event)
protectedvirtual

References selectNumber().

◆ singleStep()

double Gui::InputField::singleStep ( void  ) const

get the value of the singleStep property

◆ updateIconLabel

void InputField::updateIconLabel ( const QString &  text)
protectedslot

References Gui::ExpressionBinding::iconLabel.

Referenced by InputField().

◆ validate()

QValidator::State InputField::validate ( QString &  input,
int pos 
) const

◆ valueChanged [1/2]

void Gui::InputField::valueChanged ( const Base::Quantity )
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]

void Gui::InputField::valueChanged ( double  )
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()

void InputField::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Property Documentation

◆ format

QString Gui::InputField::format
readwrite

◆ historySize

int InputField::historySize
readwrite

◆ maximum

double InputField::maximum
readwrite

get the value of the maximum property

◆ minimum

double InputField::minimum
readwrite

get the value of the minimum property

◆ precision

◆ prefPath

QByteArray Gui::InputField::prefPath
readwrite

◆ quantity

◆ quantityString

QString Gui::InputField::quantityString
readwrite

◆ rawText

QString InputField::rawText
readwrite

return the quantity in C locale, i.e. decimal separator is a dot.

◆ rawValue

double Gui::InputField::rawValue
readwrite

◆ singleStep

double InputField::singleStep
readwrite

get the value of the singleStep property

◆ unit

QString Gui::InputField::unit
readwrite

Referenced by setUnit().


The documentation for this class was generated from the following files: