CDPBaseComboBox Class

The Combo Box widget is used to display and change values/texts of CDP objects. More...

Header: #include <CDPBaseComboBox>
Inherits: StateChanger, CDPBaseCom, CDPBaseControlVisible,
Inherited By:

CDPBaseTextSelector

Public Types

enum OutOfBoundsAction { defaultValueFirst, defaultValueLast, addValueFirst, addValueLast }
typedef StylingSvgMap
enum StylingType { NoFile, CSS, SVG }

Properties

Public Functions

CDPBaseComboBox(QWidget *parent = 0)
virtual ~CDPBaseComboBox()
int confirmTimeOut()
QString cssFile()
const QFont &font()
virtual QColor fontColor()
OutOfBoundsAction getOutOfBoundsAction()
StylingType getStylingType()
bool getSvgOverwriteGeneratedFiles()
bool getUseIndex()
QString icon()
QColor index0()
QColor index1()
QColor index2()
QColor index3()
bool isCssStyling()
bool isSvgStyling()
bool noSystemBackground()
bool opaquePaintEvent()
QString routing()
void setConfirmTimeOut(int ms)
void setCssFile(QString cssFile)
void setFont(const QFont &font)
virtual void setFontColor(QColor fontColor)
virtual void setIQtCDPPointer(IQtCDP *pIQtCDP)
void setIcon(QString icon)
void setIndex0(QColor fontColor)
void setIndex1(QColor fontColor)
void setIndex2(QColor fontColor)
void setIndex3(QColor fontColor)
void setNoSystemBackground(bool enable)
void setOpaquePaintEvent(bool enable)
int setOutOfBoundsAction(OutOfBoundsAction action)
void setRouting(QString routing)
void setStylingType(StylingType type)
void setSvgFile(const QString &svg)
void setSvgOverwriteGeneratedFiles(bool svgOverwriteGeneratedFiles)
void setUpdateOnSlotOnly(bool update)
void setUseIndex(bool indx)
void setUseIndexColor(bool indexColor)
QString svgFile()
bool updateOnSlotOnly()
bool useIndexColor()
int widgetStyle()

Public Slots

virtual void handleVisible(double visible)
virtual void hideWidget()
virtual const QStringList &pushRoutables() const
virtual void sendToCdp()
void setCurrentIndex(int index)
virtual void setInCommand(bool cmd)
virtual void setSmoothPixmap(bool smooth)
virtual void setValue(double value)
virtual void setValue(int value)
virtual bool setValue(QString value, bool bScale)
virtual void setWidgetFont(const QString &font)
virtual void setWidgetStyle(int style)
virtual void setWidgetTheme(const QString &theme)
virtual void showWidget()

Signals

virtual void pushRoutablesChanged(const QStringList &pushers)

Protected Functions

QString addUrl(QString path)
QString generatedStyleSheet()
void loadSvg()
QSize minimumSizeHint() const override
void prosessOutOfBoundsValue(QString value)
void updateTextColorFromSvg()

Protected Slots

virtual void connectCurrentIndexChanged()
QString getCurrentIcon()
void initDeprecated()
virtual void initDynamicFontColors()
virtual void sendStateChanged(const QString &text)
virtual void sendValueToCdp(int index)
virtual void updateCDP(int value)
void updateFontColor(int index)
void updateTextFromCdp()

Detailed Description

The Combo Box widget is used to display and change values/texts of CDP objects.

The CDPBaseComboBox can be customized using css, svg files or using the stylesheet. Texts are added, removed and rearranged by right-clicking the widget and selecting “Edit Items...” from the context menu. Click on the green plus sign to add text items and note that the order is identical to the signal value for selecting it.

Note: You can select to send/receive index numbers or content by editing the cdpUseIndexNr property.

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

The CDPComboBox can use the standard svg structure of the CDPBaseSpinBox. It can also have its own svg file following the naming conventions listed below.

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.

svg
└─── Layer1
  ├─── cdpText                     (text)
  ├─── cdpMenuColor                (text)
  ├─── cdpBorderMarginTopLeft      (transparent rect/path)
  ├─── cdpBorderMarginBottomRight  (transparent rect/path)
  ├─── cdpBackground               (element group)
  ├─── cdpButtonDown               (element group)
  ├─── cdpButtonDownPressed        (element group)
  ├─── cdpButtonDownDisabled       (element group)
  └─── cdpIconDown                 (element group)
       ├─── < Path >               (transparent rect/path)
       └─── < Group >              (background graphics)

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 onely use the color from this layer.
cdpMenuColortextText color is used on menu background when present.
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.
cdpButtonDownrect or an element group containing a rectThe cdpButtonDown should contain the actual button graphics.
cdpButtonDownPressedrect or an element group containing a rectThe cdpButtonDownPressed should contain the graphics to show when the button is pressed.
cdpButtonDownDisabledrect or an element group containing a rectThe cdpButtonDownDisabled should contain the actual button graphics.
cdpIconDownrect or an element group containing a rectThe cdpButtonDown should contain the actual button graphics. To ensure that the svg parser gets the correct background size (and aspect ratio), we have to place a transparent rect along with the graphics within a group element.

Note: CDPBaseComboBox 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.

Member Type Documentation

enum CDPBaseComboBox::OutOfBoundsAction

This enum type specifies value out of bounds actions:

ConstantValueDescription
CDPBaseComboBox::defaultValueFirst0Show the first item in the list.
CDPBaseComboBox::defaultValueLast1Show the last item in the list.
CDPBaseComboBox::addValueFirst2Add the value at first of the list.
CDPBaseComboBox::addValueLast3Add the value at end of the list

typedef CDPBaseComboBox::StylingSvgMap

enum CDPBaseComboBox::StylingType

This enum type specifies what styling type to use:

ConstantValueDescription
CDPBaseComboBox::NoFile0No styling file.
CDPBaseComboBox::CSS1Style by css file.
CDPBaseComboBox::SVG2Style by SVG file.

Property Documentation

cdpRouting : QString

This property holds the routing to the cdp object we want connect to.

Access functions:

QString routing()
void setRouting(QString routing)

cdpTimeoutMs : int

This property holds the time to wait before confirming the combobox selection.

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 confirmTimeOut()
void setConfirmTimeOut(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)

cdpUseIndexNr : bool

This property holds whether to use the index value of an item in the list to send to the cdp signal instead of the actual value noted in the list.

Note: This has to be unchecked when the combobox is used to send text to a cdpProperty.

Access functions:

bool getUseIndex()
void setUseIndex(bool indx)

See also index0, index1, index2, and index3.

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-qspinbox

Access functions:

QString cssFile()
void setCssFile(QString cssFile)

See also svgFile.

currentIndex : int

This property holds the value of the current index.

Access functions:

void setCurrentIndex(int index)

font : QFont

This property holds the font to be used in widget.

Access functions:

const QFont &font()
void setFont(const QFont &font)

fontColor : QColor

This property holds the font color.

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

Access functions:

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

See also svgFile and cssFile.

icon : QString

This property holds the icon to show on the “Down” button.

If stylingType is set to SVG, this option overrides the icon parsed from the svg file.

Access functions:

QString icon()
void setIcon(QString icon)

See also stylingType and svgFile.

index0 : QColor

This property holds the color to show if index 0 is selected.

Access functions:

QColor index0()
void setIndex0(QColor fontColor)

See also index1, index2, index3, and useIndexColor.

index1 : QColor

This property holds the color to show if index 1 is selected.

Access functions:

QColor index1()
void setIndex1(QColor fontColor)

See also index0, index2, index3, and useIndexColor.

index2 : QColor

This property holds the color to show if index 2 is selected.

Access functions:

QColor index2()
void setIndex2(QColor fontColor)

See also index0, index1, index3, and useIndexColor.

index3 : QColor

This property holds the color to show if index 3 is selected.

Access functions:

QColor index3()
void setIndex3(QColor fontColor)

See also index0, index1, index2, and useIndexColor.

noSystemBackground : bool

This property holds whether the widget has a background.

Newly exposed areas are never filled with the background.

Access functions:

bool noSystemBackground()
void setNoSystemBackground(bool enable)

See also opaquePaintEvent.

opaquePaintEvent : bool

This property holds whether the widget is transparent.

Set true to optimize painting when having no transparency in widget graphics This property should be set true on all widgets that does not require transparency. It will prevent Qt from painting widgets behind current widget and thus increase performance.

Access functions:

bool opaquePaintEvent()
void setOpaquePaintEvent(bool enable)

See also visible and noSystemBackground.

outOfBoundsAction : OutOfBoundsAction

This property holds what to do if receiving a signal or property from a CDPObject that is not in the list.

Options are:

  • Show the first item in the list
  • Show the last item in the list
  • Add the value at first of the list ( Careful if cdpUseIndexNr is set. )
  • Add the value at end of the list ( Careful if cdpUseIndexNr is set. )

Access functions:

OutOfBoundsAction getOutOfBoundsAction()
int setOutOfBoundsAction(OutOfBoundsAction action)

See also cdpUseIndexNr.

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.

Options are:

  • "NoFile" - Don't use a file for customization
  • "CSS" - Use a css file specified by cssFile property for customization
  • "SVG" - Use a svg file specified by svgFile property for customization

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

Access functions:

StylingType getStylingType()
void setStylingType(StylingType type)

See also svgFile and cssFile.

svgFile : QString

This property holds the path to the svg file that styles the widget.

The path can be either to a resource or a file on disk.

Note: Resources can be overridden by files on disk with identical names.

Access functions:

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

See also cssFile.

svgOverwriteGeneratedFiles : bool

This property holds whether every time loadSvg() is called, the widget creates new png images from the svg file or not.

Access functions:

bool getSvgOverwriteGeneratedFiles()
void setSvgOverwriteGeneratedFiles(bool svgOverwriteGeneratedFiles)

See also svgFile.

useIndexColor : bool

This property holds whether to make the text change color depending on what index is shown.

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

Note: If index exceeds index3, the color of index0 is shown.

Access functions:

bool useIndexColor()
void setUseIndexColor(bool indexColor)

See also svgFile and cssFile.

visible : const bool

This property holds whether to show the QWidget or not.

See also cdpVisibleRouting.

Member Function Documentation

CDPBaseComboBox::CDPBaseComboBox(QWidget *parent = 0)

Default constructs an instance of CDPBaseComboBox.

[virtual] CDPBaseComboBox::~CDPBaseComboBox()

Destroys the instance of CDPBaseComboBox. The destructor is virtual.

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

[virtual protected slot] void CDPBaseComboBox::connectCurrentIndexChanged()

[protected] QString CDPBaseComboBox::generatedStyleSheet()

[protected slot] QString CDPBaseComboBox::getCurrentIcon()

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

[virtual slot] void CDPBaseComboBox::hideWidget()

[protected slot] void CDPBaseComboBox::initDeprecated()

[virtual protected slot] void CDPBaseComboBox::initDynamicFontColors()

bool CDPBaseComboBox::isCssStyling()

bool CDPBaseComboBox::isSvgStyling()

[protected] void CDPBaseComboBox::loadSvg()

[protected] QSize CDPBaseComboBox::minimumSizeHint() const

[protected] void CDPBaseComboBox::prosessOutOfBoundsValue(QString value)

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

[virtual slot] void CDPBaseComboBox::sendToCdp()

[virtual protected slot] void CDPBaseComboBox::sendValueToCdp(int index)

[virtual] void CDPBaseComboBox::setIQtCDPPointer(IQtCDP *pIQtCDP)

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

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

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

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

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

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

[virtual slot] void CDPBaseComboBox::setWidgetStyle(int style)

See also widgetStyle().

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

[virtual slot] void CDPBaseComboBox::showWidget()

[virtual protected slot] void CDPBaseComboBox::updateCDP(int value)

[protected slot] void CDPBaseComboBox::updateFontColor(int index)

[protected] void CDPBaseComboBox::updateTextColorFromSvg()

[protected slot] void CDPBaseComboBox::updateTextFromCdp()

int CDPBaseComboBox::widgetStyle()

See also setWidgetStyle().