CDPBaseLineEdit Class

The Line Edit is used for editing text or numeric values. Text input is done by keyboard or touch screen pad. More...

Header: #include <CDPBaseLineEdit>
Inherits: CDPBaseControlVisible, StateChanger, CDPBasePadLauncher, CDPBaseCom,

Public Types

enum GlobalDialog { None, NumPad, KeyPad, PinPad }
enum NumForm { Normal, Scientific, MixedMode }
typedef StylingSvgMap
enum StylingType { NoFile, CSS, SVG }

Properties

Public Functions

CDPBaseLineEdit(QWidget *parent = 0)
virtual ~CDPBaseLineEdit()
QString cdpStyle()
int cdpTimeoutMs()
QString cssFile()
CDPBaseLineEdit::GlobalDialog eventEaterDialog()
int getFocusTimeOut()
StylingType getStylingType()
bool isCssStyling()
bool isSvgStyling()
NumForm numFormat()
QString postfix()
int precision()
bool promptForChanges()
virtual const QStringList &pushRoutables() const
QString routing()
void setCdpStyle(QString routing)
void setCdpTimeoutMs(int ms)
void setCssFile(QString cssFile)
void setFocusTimeOut(int ms)
void setIQtCDPPointer(IQtCDP *pIQtCDP) override
void setNumFormat(NumForm format)
void setPostfix(const QString &qstrPostfix)
void setPrecision(int value)
void setPromptForChanges(bool)
void setRouting(QString routing)
void setStylingType(StylingType type)
void setSvgFile(const QString &svg)
void setTabToConfirm(bool tab)
void setUpdateOnSlotOnly(bool update)
QString svgFile()
bool tabToConfirm()
bool updateOnSlotOnly()
double value(bool *bOk = 0)
bool valueIsWithinRange(double value)

Reimplemented Public Functions

virtual void Connect(std::string strRemoteObjectName) override
virtual QString keyPadDisplayText()
virtual double keyPadMaxValue()
virtual double keyPadMinValue()

Public Slots

virtual QColor fontColor()
virtual void handleVisible(double visible)
virtual void hideWidget()
virtual void sendToCdp()
virtual void setFontColor(QColor color)
virtual void setInCommand(bool cmd)
virtual void setSmoothPixmap(bool smooth)
virtual void setTextAndUpdateCdp(QString str)
virtual void setValue(double value)
virtual void setValue(int value)
virtual bool setValue(QString value, bool bScale)
virtual void setValueAndUpdateCdp(double value)
virtual void setValueAndUpdateCdp(int value)
virtual void setWidgetFont(const QString &font)
virtual void setWidgetStyle(int style)
virtual void setWidgetStyle(double style)
virtual void setWidgetTheme(const QString &theme)
virtual void showWidget()
virtual int widgetStyle()

Signals

virtual void pushRoutablesChanged(const QStringList &pushers)
void signalAcceptedValue(double)
void signalAcceptedValue(QString)

Protected Functions

QString addUrl(QString path)
virtual void focusInEvent(QFocusEvent *)
virtual void focusOutEvent(QFocusEvent *)
QString generatedStyleSheet()
virtual void keyPressEvent(QKeyEvent *)
void loadSvg()
virtual void mouseReleaseEvent(QMouseEvent *)
void processSvgFile(QString svg)
bool promptChangeValue(double *pOldValue = NULL, double *pNewValue = NULL)
bool promptChangeValue(QString *pOldValue = NULL, QString *pNewValue = NULL)
void updateTextColorFromSvg()

Reimplemented Protected Functions

virtual void ConnectionChanged(bool bConnected)

Protected Slots

virtual void acceptedValue(double value)
virtual void acceptedValue(QString value)
void checkTextAndUpdateCdp()
void clearFocusAndUpdateTextFromCdp()
virtual void clearInputFocus()
void initDefaultStyle()
void initDeprecated()
void processCursorPosChanged(int old = 0, int n = 0)
virtual void sendStateChanged(const QString &text)
virtual void sendValueToCdp()
void startFocusTimer()
void updateTextFromCdp()
void validateDisplayString(QString dummy = "")

Detailed Description

The Line Edit is used for editing text or numeric values. Text input is done by keyboard or touch screen pad.

The widget can be configured to send and receive text or numeric values to and from CDP objects/properties by configuring the cdpRouting property. All properties related to communication are prefixed with cdp.

There are lots of properties for changing the widget look and feel. For instance, texts can be added after the editable value by configuring the postfix property. To add text in front of the value, we need to group the Line Edit with a Label in front.

To support touch screens, or when no keyboard is present, the properties prefixed with pad can be used to make the widget launch a numeric pad, a text pad or a pad for typing in passwords.

Styling of the Line Edit, text color, font and background, is usually done by the selected theme. To check this, have a look at the stylingType property. When the default type, SVG is selected, the file showing in svgFile is responsible for setting fonts and colors. You can override this using the properties named fontColor and font. The override will be kept even if theme is changed.

To override the background, you will have to create a new SVG file or select a different styling type. Setting the stylingType property to CSS will enable the cssFile property and allow you to specify a CSS file to style the widget. It is also possible to add CSS code directly in the styleSheet property. To make these changes stick we need to set stylingType to NoFile.

There is also a final styling option, palette, that can be used when stylingType is set to NoFile and none of the other styling options are present (does not show in bold).

Some of the most important features of the Line Edit is summarized in the following table:

NameTypeDescription
cdpPromptForChangesboolEnable or disable message box to confirm new value/text to send to routed cdp object/property.
cdpRoutingstringRouting to a CDP object/property that we want to display and edit.
cdpStyleRoutingstringRouting to a CDP object/property that controls what style element in the SVG to show on the LineEdit. This can be used to make the Line Edit show differently based on external events. We could for instance make the background red if an alarm is set.
cdpScalingdoubleDisplay scaling on data to/from routed CDP object/property. Input values to the CDPBaseLineEdit will be multiplied with this value, output values will be divided.
numFormatNumFormSpecify display format; "Normal", "Scientific" or "Mixed".
padTitlestringThe title of the pad when padType is not set to None.
padTypeGlobalDialogThe title of the pad when padType is not set to "None".
postfixstringText to display after actual value/text.
precisionintSets the number of decimals to show when displaying fractured numbers or number of decimal notations before switching to scientific display in “MixedMode

Styling by SVG

Use the svgFile property to style the widget using a svg file. Styling by svg enables switching between different themes in runtime (as long as the files are placed at identical locations within theme directories).

Note: CDPBaseLineEdit generates raster images from svg as described here.

To see where the images are stored, right-click on the widget. Select "Change styleSheet..." and have a look at the paths of the border images.

Main element structure

The CDPBaseLineEdit can use the standard svg structure of the CDPBaseSpinBox. The following svg structure is supported.

svg
└─── Layer1
  ├─── cdpText                     (text)
  ├─── cdpBorderMarginTopLeft      (transparent rect/path)
  ├─── cdpBorderMarginBottomRight  (transparent rect/path)
  └─── cdpBackground              (element group)

The following table explains the named elements in more detail.

PropertyTypeDescription
cdpTexttextThe color and size of the font to be used on the unit text. At the moment we only use the color from this layer.
cdpBorderMarginTopLeftTransparent rect/pathTransparent rectangle that specifies the right border margin by its width and the bottom border margin by its height.
cdpBorderMarginBottomRightTransparent rect/pathTransparent rectangle that specifies the right border margin by its width and the bottom border margin by its height.
cdpBackgroundrect or an element group containing a rectThe cdpBackground should contain the actual background graphics.

Note: Elements that are written with pointy brackets, like < Path >, can be given any name. Avoid cdp prefix as these are special to the parser.

Member Type Documentation

enum CDPBaseLineEdit::GlobalDialog

This enum type specifies a dialog type:

ConstantValueDescription
CDPBaseLineEdit::None0x00000000Do not use a global dialog.
CDPBaseLineEdit::NumPad0x00000001A numeric key pad.
CDPBaseLineEdit::KeyPad0x00000002A key pad with for numbers and letters.
CDPBaseLineEdit::PinPad0x00000003A num pad for typing passwords.

enum CDPBaseLineEdit::NumForm

This enum type specifies how to format numbers:

ConstantValueDescription
CDPBaseLineEdit::Normal1Format as [-]9.9
CDPBaseLineEdit::Scientific2Format as [-]9.9e[+|-]999
CDPBaseLineEdit::MixedMode3Use "Normal" or "Scientific" format, whichever is the most concise.

typedef CDPBaseLineEdit::StylingSvgMap

enum CDPBaseLineEdit::StylingType

This enum type specifies a styling type:

ConstantValueDescription
CDPBaseLineEdit::NoFile0No custom styling (enables styleSheet property).
CDPBaseLineEdit::CSS1Style by css file (enables cssFile property).
CDPBaseLineEdit::SVG2Style by svg file (enables svgFile property).

Property Documentation

cdpPromptForChanges : bool

This property holds whether to show a message box to accept changes.

Note: The prompt dialog will only show when configured for cdp communication and only in a running application.

Access functions:

bool promptForChanges()
void setPromptForChanges(bool)

See also cdpRouting.

cdpRouting : QString

This property holds the full path to a connected CDP object.

Access functions:

QString routing()
void setRouting(QString routing)

cdpScaling : const double

This property holds a value with which the decimal (if present) value is multiplied/divided.

Input-values to the CDPBaseLineEdit will be multiplied with this value, output-values will be divided. This works with both signals and properties.

cdpStyleRouting : QString

This property holds the routing of the CDP object that is used to change the widget svg style.

Access functions:

QString cdpStyle()
void setCdpStyle(QString routing)

cdpTabToConfirm : bool

This property holds whether to use “Tab” to confirm text input.

Access functions:

bool tabToConfirm()
void setTabToConfirm(bool tab)

cdpTimeoutMs : int

This property holds the time to wait before confirming a newly inserted value.

If there is no signal at the specified route, default value is 0.0 .

Note: This property is ignored if cdpRouting is not set.

Access functions:

int cdpTimeoutMs()
void setCdpTimeoutMs(int ms)

cdpUpdateOnSlotOnly : bool

This property holds whether to only use a slot (sendToCdp()) to send the value to routed cdp object. This makes the widget not send value to cdp on editingFinished or enterPressed.

Access functions:

bool updateOnSlotOnly()
void setUpdateOnSlotOnly(bool update)

cdpVisibleRouting : const QString

This property holds the full path of the signal/parameter that controls the “visible” property.

Note: Values not equal to 1 are considered false.

See also visible.

cssFile : QString

This property holds the css file to use for customization.

http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qlineedit

Access functions:

QString cssFile()
void setCssFile(QString cssFile)

See also svgFile.

focusTimeOutMs : int

This property holds the time after which the lineEdit looses focus after being edited.

This time delay makes sure the widget shows updated values from the routed cdp object.

Access functions:

int getFocusTimeOut()
void setFocusTimeOut(int ms)

fontColor : QColor

This property holds the font color.

Note: If this is set, this overrides the text color from svg file and the entire code received from CSS file.

Note: When combined with max and min, recieving an out-of-range input will reset this color.

Access functions:

virtual QColor fontColor()
virtual void setFontColor(QColor color)

See also svgFile and cssFile.

maximum : const double

This property holds the maximum value to accept from user.

When the user attempts to add a value above this maximum, the line edit text will get colored in red and a focus out event will make the text go back to the previous value.

Note: Receiving cdp values that are out of range will extend the min/max limits so that we always show what is in the control system. Further, the min/max values will also limit the num pad (when enabled). Setting min and max with identical value will disable the functionality.

Access functions:

virtual double keyPadMaxValue()

See also minimum.

minimum : const double

This property holds the minimum value to accept from user.

When the user attempts to add a value below this minimum, the line edit text will get colored in red and a focus out event will make the text go back to the previous value.

Note: Receiving cdp values that are out of range will extend the min/max limits so that we always show what is in the control system. Further, the min/max values will also limit the num pad (when enabled). Setting min and max with identical value will disable the functionality.

Access functions:

virtual double keyPadMinValue()

See also maximum.

numFormat : NumForm

This property holds the format in which numbers are displayed.

Access functions:

NumForm numFormat()
void setNumFormat(NumForm format)

See also precision.

padInfoText1 : const QString

This property holds the information text 1 of the input-pad.

Note: The info text will onlu show when the global num pad class in the main window, CDPBaseMainWindow::numPadName, has been configured with a class that implements the pad info elements. An example of such is the class named CDPBaseNumPadOptInfo.

Note: Recall to set padType to num pad when using this property.

See also padType, padTitle, and padInfoText2.

padInfoText2 : const QString

This property holds the information text 2 of the input-pad.

Note: See padInfoText1 for more details.

See also padType, padTitle, and padInfoText1.

padTitle : const QString

This property holds the title of the input-pad.

See also padType, padInfoText1, and padInfoText2.

padType : const GlobalDialog

This property holds which input pad is used for inserting a value manually.

Access functions:

CDPBaseLineEdit::GlobalDialog eventEaterDialog()

See also padTitle, padInfoText1, and padInfoText2.

postfix : QString

This property holds the string that is appended to the displayed value.

Access functions:

QString postfix()
void setPostfix(const QString &qstrPostfix)

precision : int

This property holds the value of decimal places for numbers.

Sets the number of decimals to show when displaying fractured numbers or number of decimal notations before switching to scientific display in “MixedMode

Access functions:

int precision()
void setPrecision(int value)

See also numFormat.

pushRoutables : const QStringList

Access functions:

virtual const QStringList &pushRoutables() const

Notifier signal:

virtual void pushRoutablesChanged(const QStringList &pushers)

stylingType : StylingType

This property holds a selection of how to customize the widget.

To customize in QtDesigner, set this property to "NoFile".

Access functions:

StylingType getStylingType()
void setStylingType(StylingType type)

See also svgFile, cssFile, and widgetStyle.

svgFile : QString

This property holds the svg file to use for customization.

Access functions:

QString svgFile()
void setSvgFile(const QString &svg)

See also cssFile.

visible : const bool

This property holds whether to show the QWidget or not.

See also cdpVisibleRouting.

widgetStyle : int

This property holds which style from an svg file is used.

Note: This will only have effect if the svg file specified by svgFile provides styles, and stylingType is set to "SVG".

Access functions:

virtual int widgetStyle()
virtual void setWidgetStyle(int style)
virtual void setWidgetStyle(double style)

See also stylingType, svgFile, and cssFile.

Member Function Documentation

CDPBaseLineEdit::CDPBaseLineEdit(QWidget *parent = 0)

Default constructs an instance of CDPBaseLineEdit.

[virtual] CDPBaseLineEdit::~CDPBaseLineEdit()

Destroys the instance of CDPBaseLineEdit. The destructor is virtual.

[override virtual] void CDPBaseLineEdit::Connect(std::string strRemoteObjectName)

[virtual protected] void CDPBaseLineEdit::ConnectionChanged(bool bConnected)

[virtual protected slot] void CDPBaseLineEdit::acceptedValue(double value)

[virtual protected slot] void CDPBaseLineEdit::acceptedValue(QString value)

[protected] QString CDPBaseLineEdit::addUrl(QString path)

[protected slot] void CDPBaseLineEdit::checkTextAndUpdateCdp()

[protected slot] void CDPBaseLineEdit::clearFocusAndUpdateTextFromCdp()

[virtual protected slot] void CDPBaseLineEdit::clearInputFocus()

[virtual protected] void CDPBaseLineEdit::focusInEvent(QFocusEvent *)

[virtual protected] void CDPBaseLineEdit::focusOutEvent(QFocusEvent *)

[protected] QString CDPBaseLineEdit::generatedStyleSheet()

[virtual slot] void CDPBaseLineEdit::handleVisible(double visible)

[virtual slot] void CDPBaseLineEdit::hideWidget()

[protected slot] void CDPBaseLineEdit::initDefaultStyle()

[protected slot] void CDPBaseLineEdit::initDeprecated()

bool CDPBaseLineEdit::isCssStyling()

bool CDPBaseLineEdit::isSvgStyling()

[virtual] QString CDPBaseLineEdit::keyPadDisplayText()

[virtual protected] void CDPBaseLineEdit::keyPressEvent(QKeyEvent *)

[protected] void CDPBaseLineEdit::loadSvg()

[virtual protected] void CDPBaseLineEdit::mouseReleaseEvent(QMouseEvent *)

[protected slot] void CDPBaseLineEdit::processCursorPosChanged(int old = 0, int n = 0)

[protected] void CDPBaseLineEdit::processSvgFile(QString svg)

[protected] bool CDPBaseLineEdit::promptChangeValue(double *pOldValue = NULL, double *pNewValue = NULL)

[protected] bool CDPBaseLineEdit::promptChangeValue(QString *pOldValue = NULL, QString *pNewValue = NULL)

[virtual protected slot] void CDPBaseLineEdit::sendStateChanged(const QString &text)

[virtual slot] void CDPBaseLineEdit::sendToCdp()

[virtual protected slot] void CDPBaseLineEdit::sendValueToCdp()

void CDPBaseLineEdit::setIQtCDPPointer(IQtCDP *pIQtCDP)

[virtual slot] void CDPBaseLineEdit::setInCommand(bool cmd)

[virtual slot] void CDPBaseLineEdit::setSmoothPixmap(bool smooth)

[virtual slot] void CDPBaseLineEdit::setTextAndUpdateCdp(QString str)

[virtual slot] void CDPBaseLineEdit::setValue(double value)

See also value().

[virtual slot] void CDPBaseLineEdit::setValue(int value)

[virtual slot] bool CDPBaseLineEdit::setValue(QString value, bool bScale)

[virtual slot] void CDPBaseLineEdit::setValueAndUpdateCdp(double value)

[virtual slot] void CDPBaseLineEdit::setValueAndUpdateCdp(int value)

[virtual slot] void CDPBaseLineEdit::setWidgetFont(const QString &font)

[virtual slot] void CDPBaseLineEdit::setWidgetTheme(const QString &theme)

[virtual slot] void CDPBaseLineEdit::showWidget()

[signal] void CDPBaseLineEdit::signalAcceptedValue(double)

Note: Signal signalAcceptedValue is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

connect(cDPBaseLineEdit, static_cast<void(CDPBaseLineEdit::*)(double)>(&CDPBaseLineEdit::signalAcceptedValue),
    [=](double ){ /* ... */ });

[signal] void CDPBaseLineEdit::signalAcceptedValue(QString)

Note: Signal signalAcceptedValue is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

connect(cDPBaseLineEdit, static_cast<void(CDPBaseLineEdit::*)(QString)>(&CDPBaseLineEdit::signalAcceptedValue),
    [=](QString ){ /* ... */ });

[protected slot] void CDPBaseLineEdit::startFocusTimer()

[protected] void CDPBaseLineEdit::updateTextColorFromSvg()

[protected slot] void CDPBaseLineEdit::updateTextFromCdp()

[protected slot] void CDPBaseLineEdit::validateDisplayString(QString dummy = "")

double CDPBaseLineEdit::value(bool *bOk = 0)

See also setValue().

bool CDPBaseLineEdit::valueIsWithinRange(double value)