cumbia-qtcontrols 1.x
Qt widgets on top of the cumbia C++ library
Public Member Functions | List of all members
CuControlsUtils Class Reference

utility class to find input arguments from objects with text or value properties More...

#include <cucontrolsutils.h>

Public Member Functions

QString findInput (const QString &objectName, const QObject *leaf) const
 
QObject * findObject (const QString &objectName, const QObject *leaf) const
 
CuVariant getArgs (const QString &target, const QObject *leaf) const
 finds the arguments in the source or target. If they are object names it finds the objects with those names and get the input from them, otherwise they are directly converted to CuVariant and returned. More...
 
QList< QObject * > findObjects (const QString &target, const QObject *leaf)
 
bool initObjects (const QString &target, const QObject *leaf, const CuData &data, const char *value_key)
 initialize objects setting range (min, max, if relevant) and the value according to value_key More...
 
QString msg (const CuData &da, const QString &date_time_fmt="yyyy-MM-dd HH:mm:ss.zzz") const
 return a string with a message derived from the da input parameter More...
 

Detailed Description

utility class to find input arguments from objects with text or value properties

This class is used to search input arguments for sources or targets from widgets exposing text or value properties. Text or values are edited within the widget and can be passed as input arguments to readers or writers.

Please refer to the findInput method documentation for more details.

Member Function Documentation

◆ findInput()

QString CuControlsUtils::findInput ( const QString &  objectName,
const QObject *  leaf 
) const

find the input argument from an object and return it in the shape of a string.

Parameters
objectNamethe name of the object to search for
leafthe parent object under which the object providing input is searched for
Returns
a string with the argument.
Note
The object providing input arguments must implement one of the following properties, that are searched and evaluated in this order:
  • data (e.g. QuComboBox: data represented as string, either currentText or currentIndex according to QuComboBox indexMode property)
  • text (e.g. QLabel, QLineEdit, ...)
  • value (e.g. QSpinBox, QDoubleSpinBox, ENumeric)
  • currentIndex (e.g. QComboBox)
Note
The first property found in the list above is used. If you write a custom widget that displays data that may be internally represented by different types (e.g. a combo box that can be used to either change a numerical index or a text), make sure to provide a data property that can be converted to QString regardless of the internal storage type.

Referenced by getArgs().

◆ findObject()

QObject * CuControlsUtils::findObject ( const QString &  objectName,
const QObject *  leaf 
) const

Referenced by findObjects().

◆ findObjects()

QList< QObject * > CuControlsUtils::findObjects ( const QString &  target,
const QObject *  leaf 
)

References findObject().

Referenced by initObjects().

◆ getArgs()

CuVariant CuControlsUtils::getArgs ( const QString &  target,
const QObject *  leaf 
) const

finds the arguments in the source or target. If they are object names it finds the objects with those names and get the input from them, otherwise they are directly converted to CuVariant and returned.

Parameters
targetthe source or target string
leafunder this object getArgs searches for a child (children) with the object name(s) specified in the argument (s).
Returns
a CuVariant with the detected argument(s), or an empty CuVariant.

The child is searched by the findInput method.

References findInput().

Referenced by QuButton::execute(), and QuWriter::execute().

◆ initObjects()

bool CuControlsUtils::initObjects ( const QString &  target,
const QObject *  leaf,
const CuData &  data,
const char *  value_key 
)

initialize objects setting range (min, max, if relevant) and the value according to value_key

Parameters
targetthe name of the target
leafthe parent object under which children are searched by findObjects
datathe CuData holding configuration values (min, max, if present), and a value to display on the object
value_keythe key to look for the value that must be displayed (example: "value" or "w_value")
Returns
true if the operation was successful, false otherwise

References findObjects().

Referenced by QuButton::onUpdate().

◆ msg()

QString CuControlsUtils::msg ( const CuData &  da,
const QString &  date_time_fmt = "yyyy-MM-dd HH:mm:ss.zzz" 
) const

return a string with a message derived from the da input parameter

Parameters
daCuData
date_time_fmta custom timestamp date / time format. Default: "yyyy-MM-dd HH:mm:ss.zzz"
Returns
the message stored in da["msg"] if da["err"] evaluates to true or a new message with the source name, the value of da["mode"] (or da["activity"], if "mode" is empty) and the timestamp. da["timestamp_ms"] or da["timestamp_us"] are used to provide a date /time in the format "yyyy-MM-dd HH:mm:ss.zzz".

References msg().

Referenced by msg().


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