Version: 9.12.0
QDS_ComboBox Class Reference

#include <QDS_ComboBox.h>

Inheritance diagram for QDS_ComboBox:
Inheritance graph

Signals

void activated (int)
 Emitted when the current item in the combo box is changed. More...
 
void activated (const QString &)
 Emitted when the current item in the combo box is changed. More...
 
- Signals inherited from QDS_Datum
void paramChanged ()
 The signal is emitted when the datum value is changed. More...
 
void paramChanged (QString &)
 

Public Member Functions

 QDS_ComboBox (const QString &, QWidget *=0, const int=All, const QString &=QString())
 Constructor. More...
 
virtual ~QDS_ComboBox ()
 Destructor. More...
 
bool editable () const
 Check if combo box allows text editing. More...
 
void setEditable (const bool)
 Enable/disable text editing. More...
 
int count (bool=false) const
 Get number of items in the combo box. More...
 
void values (QList< int > &, bool=false) const
 Get items identifiers. More...
 
virtual int integerValue () const
 Get the current item ID as integer value. More...
 
virtual double doubleValue () const
 Get the current item ID as double value. More...
 
virtual void setIntegerValue (const int)
 Set the current item acording to the specified id. More...
 
virtual void setDoubleValue (const double)
 Set the current item acording to the specified id. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Integer part of val is used as new current ID. More...
 
bool state (const int) const
 Get visibility state of the item specified by id. More...
 
void setState (const bool, const int, const bool=true)
 Set the visibility state of the item specified by id. More...
 
void setState (const bool, const QList< int > &, const bool=true)
 Set the visibility state of items specified by ids. More...
 
void setValues (const QList< int > &, const QStringList &)
 Set the custom user items into the combo box. More...
 
void setValues (const QStringList &)
 Set the custom user items into the combo box. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.User items like standard dictionary list items will be added into the combobox. This function allows user to override items. More...
 
virtual QString getString () const
 Get string from the combo box. More...
 
virtual void reset ()
 Reset the datum. More...
 
int stringToValue (const QString &) const
 Convert string to integer value. More...
 
QString valueToString (const int) const
 Convert integer to string value. More...
 
- Public Member Functions inherited from QDS_Datum
 QDS_Datum (const QString &, QWidget *=0, const int=All, const QString &=QString())
 Constructor. More...
 
virtual ~QDS_Datum ()
 Destructor. More...
 
QString id () const
 Get the datum ID. More...
 
int type () const
 Get the datum value type. More...
 
QString label () const
 Get the datum label text. More...
 
QString units () const
 Get the datum units text. More...
 
QString filter () const
 Get the datum filter string. More...
 
QString format () const
 Get the datum format string. More...
 
QString longDescription () const
 Get the datum long description. More...
 
QString shortDescription () const
 Get the datum short description. More...
 
QString defaultValue () const
 Get the datum default value. More...
 
QString minimumValue () const
 Get the datum minimum value. More...
 
QString maximumValue () const
 Get the datum maximum value. More...
 
QStringList options () const
 Get the datum options names. More...
 
QVariant option (const QString &) const
 Get datum option specified by name as QVariant. More...
 
QString optionString (const QString &) const
 Get datum option specified by name as string. More...
 
double optionDouble (const QString &) const
 Get datum option specified by name as double. More...
 
int optionInteger (const QString &) const
 Get datum option specified by name as integer. More...
 
virtual QVariant value () const
 Get the datum value as QVariant. More...
 
virtual QString stringValue () const
 Get the datum value as string. More...
 
QString text () const
 Get the text data from datum. More...
 
virtual bool isEmpty () const
 Check if the datum is empty. More...
 
virtual void clear ()
 Clear the control. More...
 
virtual void setValue (const QVariant &)
 Set datum value from QVariant object. More...
 
virtual void setStringValue (const QString &)
 Set datum value from string data. More...
 
virtual bool isEnabled (const int=Control) const
 Get 'enabled' state of the specified subwidget. More...
 
virtual void setEnabled (const bool, const int)
 Enable/disable subwidgets specified by element. More...
 
void show (const int=All)
 Show subwidgets specified by element. More...
 
void hide (const int=All)
 Hide subwidgets specified by element. More...
 
virtual void setShown (const bool, const int=All)
 Show/hide subwidgets specified by flags. More...
 
QWidgetwidget (const int) const
 Get subwidget specified by element. More...
 
void setFocus ()
 Set the input focus to the control widget. More...
 
virtual bool isValid (const bool=true, const QString &=QString(), const QString &=QString()) const
 Check if input data is valid. More...
 
virtual QValidatorvalidator (const bool=false) const
 Create validator according to the datum type of value. More...
 
void addTo (QVBoxLayout *)
 Add widgets to the vertical box layout. More...
 
void addTo (QHBoxLayout *)
 Add widgets to the horizontal box layout. More...
 
void addTo (QGridLayout *, const int, const int, const bool=false)
 Add widgets to the grid layout. More...
 
virtual void setAlignment (const int, const int=Label)
 Set the aligment for QDS::Label and/or QDS::Units subwidgets. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Event filter. More...
 
 operator QWidget * () const
 Overloaded operator used to retrieve main subwidget named QDS::Control. More...
 
bool isCustomTr () const
 Return state of custom translation. More...
 
void enableCustomTr (const bool)
 Change state of custom translation. More...
 

Protected Slots

virtual void onActivated (int)
 Called when combo box item is activated. More...
 
virtual void onTextChanged (const QString &)
 Called when text in the combo box (editable) is modified by the user. More...
 
- Protected Slots inherited from QDS_Datum
virtual void onParamChanged ()
 Called when datum value is changed. More...
 

Protected Member Functions

QtxComboBoxcomboBox () const
 Get combo box widget. More...
 
virtual QWidgetcreateControl (QWidget *)
 Create internal combo box as control widget. More...
 
virtual void setString (const QString &)
 Set the string value to the combo box widget. More...
 
virtual void unitSystemChanged (const QString &)
 Process notification about active units system changing. More...
 
- Protected Member Functions inherited from QDS_Datum
QLabellabelWidget () const
 Get QDS::Label widget. More...
 
QLabelunitsWidget () const
 Get QDS::Units widget. More...
 
QWidgetcontrolWidget () const
 Get QDS::Control widget. More...
 
 Handle (DDS_DicItem) dicItem() const
 
void setDicItem (const Handle(DDS_DicItem)&)
 
int flags () const
 Get datum flags. More...
 
void invalidateCache ()
 Reset the numeric value cache. More...
 
virtual QLabelcreateLabel (QWidget *)
 Create QDS::Label widget. More...
 
virtual QLabelcreateUnits (QWidget *)
 Create QDS::Units widget. More...
 
virtual bool validate (const QString &) const
 Validate the specified string. More...
 
QString prefix () const
 Get prefix string from format. More...
 
QString suffix () const
 Get suffix string from format. More...
 
virtual QString minValue () const
 Get minimum value. More...
 
virtual QString maxValue () const
 Get maximum value. More...
 
void initDatum () const
 Perform initialization if it needed. More...
 

Private Types

typedef QMap< int, QPixmap > IdIconsMap
 
typedef QMap< int, QString > IdValueMap
 
typedef QMap< int, bool > IdStateMap
 
typedef QMap< int, int > IdIndexMap
 

Private Member Functions

int getId (const int) const
 Get item identifier according to the specified index. More...
 
int getId (const QString &) const
 Get item identifier. More...
 
int getIndex (const int) const
 Get index of the combo box item according to its identifier. More...
 
int getIndex (const QString &) const
 Get index of the combo box item. More...
 
void updateComboBox ()
 Update combo box. More...
 

Private Attributes

IdValueMap myValue
 
IdStateMap myState
 
IdIndexMap myIndex
 
IdIconsMap myIcons
 
QIntList myDataIds
 
QIntList myUserIds
 
QStringList myUserNames
 

Additional Inherited Members

- Public Types inherited from QDS
enum  DatumFlags {
  None = 0x00 , Label = 0x01 , Control = 0x02 , Units = 0x04 ,
  NotFormat = 0x08 , NotAccel = 0x10 , NotConvert = 0x20 , UnitsWithLabel = 0x40 ,
  All = Label | Control | Units
}
 Enum describes bit flags of the Qt datum view and behaviour. More...
 
- Public Slots inherited from QDS_Datum
void setEnabled (bool)
 Enable/disable main control subwidget (QDS::Control). More...
 
- Static Public Member Functions inherited from QDS_Datum
static QString unitsToText (const QString &)
 Convert units into text presentation. More...
 
static QString textToUnits (const QString &)
 Convert text presentation into internal units format. More...
 
static QString format (const QString &, const QString &, const bool=false)
 Format the specified string as dictionary item value. More...
 
static QString format (const int, const QString &, const bool=false)
 Format the specified integer as dictionary item value. More...
 
static QString format (const double, const QString &, const bool=false)
 Format the specified double as dictionary item value. More...
 
static QString units (const QString &)
 Get displayable units string for specified data dictionary item. More...
 
- Static Public Member Functions inherited from QDS
static bool load (const QString &)
 Load datum definitions from XML file dictPath to the dictionary. More...
 
static QString unitSystemLabel (const QString &, const QString &=QString())
 Get the label of unit system sys. More...
 
static QString activeUnitSystem (const QString &=QString())
 Get the name of active unit system from the specified component comp. More...
 
static void setActiveUnitSystem (const QString &, const QString &=QString())
 Set the active unit system. More...
 
static QString toQString (const TCollection_AsciiString &)
 Convert the OpenCascade ASCII string to Qt string. More...
 
static QString toQString (const TCollection_ExtendedString &)
 Convert the OpenCascade Unicode string to Qt string. More...
 
static QString toQString (const Handle(TCollection_HAsciiString)&)
 Convert the OpenCascade ASCII string to Qt string. More...
 
static QString toQString (const Handle(TCollection_HExtendedString)&)
 Convert the OpenCascade Unicode string to Qt string. More...
 
static TCollection_AsciiString toAsciiString (const QString &)
 Convert the Qt string to OpenCascade ASCII string. More...
 
static TCollection_AsciiString toAsciiString (const TCollection_ExtendedString &)
 Convert the OpenCascade Unicode string to OpenCascade ASCII string. More...
 
static TCollection_AsciiString toAsciiString (const Handle(TCollection_HExtendedString)&)
 Convert the OpenCascade Unicode string to OpenCascade ASCII string. More...
 
static TCollection_ExtendedString toExtString (const QString &)
 Convert the Qt string to OpenCascade Unicode string. More...
 
static TCollection_ExtendedString toExtString (const TCollection_AsciiString &)
 Convert the OpenCascade ASCII string to OpenCascade Unicode string. More...
 
- Static Protected Member Functions inherited from QDS_Datum
static QString format (const QString &, const int, const int)
 Format the given value according to the data dictionary item type. More...
 
static QString format (const QString &, const int, const double)
 Format the given value according to the data dictionary item type. More...
 
static QString format (const QString &, const int, const QString &)
 Format the given value according to the data dictionary item type. More...
 
static QString sprintf (const QString &, const int)
 Wrapper around the standard sprintf() function. More...
 
static QString sprintf (const QString &, const double)
 Wrapper around the standard sprintf() function. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Process some non standard flags from format string. More...
 
static QString sprintf (const QString &, const QString &)
 Wrapper around the standard sprintf() function. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Process some non standard flags from format string. More...
 
- Static Protected Member Functions inherited from QDS
static void insertDatum (QDS_Datum *)
 Register given datum datum in the global list. More...
 
static void removeDatum (QDS_Datum *)
 Remove given datum datum from the global list. More...
 

Member Typedef Documentation

◆ IdIconsMap

typedef QMap<int, QPixmap> QDS_ComboBox::IdIconsMap
private

◆ IdIndexMap

typedef QMap<int, int> QDS_ComboBox::IdIndexMap
private

◆ IdStateMap

typedef QMap<int, bool> QDS_ComboBox::IdStateMap
private

◆ IdValueMap

typedef QMap<int, QString> QDS_ComboBox::IdValueMap
private

Constructor & Destructor Documentation

◆ QDS_ComboBox()

QDS_ComboBox::QDS_ComboBox ( const QString &  id,
QWidget parent = 0,
const int  flags = All,
const QString &  comp = QString() 
)

Constructor.

Create combobox datum object with datum identifier id and parent widget parent.

Parameter flags defines behaviour of datum and set of created subwidgets. Default value of this parameter is QDS::All.

Parameter comp specifies the component name which will be used when searching the dictionary item.

Parameters
iddatum identifier
parentparent widget
flagsdatum flags
compcomponent

◆ ~QDS_ComboBox()

QDS_ComboBox::~QDS_ComboBox ( )
virtual

Destructor.

Member Function Documentation

◆ activated [1/2]

void QDS_ComboBox::activated ( const QString &  txt)
signal

Emitted when the current item in the combo box is changed.

Parameters
txtcurrent item text

◆ activated [2/2]

void QDS_ComboBox::activated ( int  id)
signal

Emitted when the current item in the combo box is changed.

Parameters
idcurrent item ID

◆ comboBox()

QtxComboBox * QDS_ComboBox::comboBox ( ) const
protected

Get combo box widget.

Returns
internal combo box widget

References QDS_Datum::controlWidget().

◆ count()

int QDS_ComboBox::count ( bool  total = false) const

Get number of items in the combo box.

Parameters
totalif false, only visible items are taken into account, otherwise get total number of items
Returns
number of items

References comboBox(), and myValue.

◆ createControl()

QWidget * QDS_ComboBox::createControl ( QWidget parent)
protectedvirtual

Create internal combo box as control widget.

Parameters
parentparent widget
Returns
created combo box widget

Implements QDS_Datum.

References activated(), onActivated(), and onTextChanged().

◆ doubleValue()

double QDS_ComboBox::doubleValue ( ) const
virtual

Get the current item ID as double value.

Returns
current item ID converted to double

Reimplemented from QDS_Datum.

References comboBox(), getId(), getString(), and QDS_Datum::initDatum().

◆ editable()

bool QDS_ComboBox::editable ( ) const

Check if combo box allows text editing.

Returns
true if combo box is editable

References comboBox().

◆ getId() [1/2]

int QDS_ComboBox::getId ( const int  idx) const
private

Get item identifier according to the specified index.

Parameters
idxitem index
Returns
item ID or -1 if index is out of range

References QDS_Datum::id(), and myIndex.

◆ getId() [2/2]

int QDS_ComboBox::getId ( const QString &  str) const
private

Get item identifier.

Parameters
strcombo box item
Returns
item ID or -1 if not found

References QDS_Datum::id(), myValue, and state().

◆ getIndex() [1/2]

int QDS_ComboBox::getIndex ( const int  id) const
private

Get index of the combo box item according to its identifier.

Parameters
iditem ID
Returns
item index or -1 if not found

References QDS_Datum::id(), and myIndex.

◆ getIndex() [2/2]

int QDS_ComboBox::getIndex ( const QString &  str) const
private

Get index of the combo box item.

Parameters
strcombo box item
Returns
item index or -1 if not found

References comboBox().

◆ getString()

QString QDS_ComboBox::getString ( ) const
virtual

Get string from the combo box.

Returns
string value

Implements QDS_Datum.

References comboBox(), and QtxComboBox::isCleared().

◆ integerValue()

int QDS_ComboBox::integerValue ( ) const
virtual

Get the current item ID as integer value.

Returns
current item ID converted to integer

Reimplemented from QDS_Datum.

References comboBox(), getId(), and getString().

◆ onActivated

void QDS_ComboBox::onActivated ( int  idx)
protectedvirtualslot

Called when combo box item is activated.

Parameters
idxindex of teh item being activated

References activated(), comboBox(), getId(), getString(), QDS_Datum::onParamChanged(), and QDS_Datum::paramChanged().

◆ onTextChanged

void QDS_ComboBox::onTextChanged ( const QString &  )
protectedvirtualslot

Called when text in the combo box (editable) is modified by the user.

Parameters
txtcurrent text in the combo box editor (not used)

References getString(), QDS_Datum::onParamChanged(), and QDS_Datum::paramChanged().

◆ reset()

void QDS_ComboBox::reset ( )
virtual

Reset the datum.

Set the active item as item with default ID. If default ID is not defined then the first item is used.

Reimplemented from QDS_Datum.

References QDS_Datum::defaultValue(), getId(), setIntegerValue(), and setString().

◆ setDoubleValue()

void QDS_ComboBox::setDoubleValue ( const double  val)
virtual

Set the current item acording to the specified id. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Integer part of val is used as new current ID.

Parameters
valitem ID

Reimplemented from QDS_Datum.

References QDS_Datum::initDatum(), myValue, and setString().

◆ setEditable()

void QDS_ComboBox::setEditable ( const bool  on)

Enable/disable text editing.

Parameters
onif true, combo box is made editable

References comboBox(), and QDS_Datum::validator().

◆ setIntegerValue()

void QDS_ComboBox::setIntegerValue ( const int  id)
virtual

Set the current item acording to the specified id.

Parameters
iditem ID

Reimplemented from QDS_Datum.

References QDS_Datum::initDatum(), myValue, and setString().

◆ setState() [1/2]

void QDS_ComboBox::setState ( const bool  on,
const int  id,
const bool  append = true 
)

Set the visibility state of the item specified by id.

If id is -1 then specified state will be set to all items.

If append is set to true, keep current status for other items, otherwise status of other items is cleared.

Parameters
onnew visibility state
iditem ID
appendif true, keep original status for other items

References myState.

◆ setState() [2/2]

void QDS_ComboBox::setState ( const bool  on,
const QList< int > &  ids,
const bool  append = true 
)

Set the visibility state of items specified by ids.

If append is set to true, keep current status for other items, otherwise status of other items is cleared.

Parameters
onnew visibility state
idsitems IDs list
appendif true, keep original status for other items

References QDS_Datum::initDatum(), myState, and updateComboBox().

◆ setString()

void QDS_ComboBox::setString ( const QString &  txt)
protectedvirtual

Set the string value to the combo box widget.

Parameters
txtstring value

Implements QDS_Datum.

References activated(), comboBox(), getString(), integerValue(), QtxComboBox::isCleared(), QDS_Datum::onParamChanged(), QDS_Datum::paramChanged(), and QtxComboBox::setCleared().

◆ setValues() [1/2]

void QDS_ComboBox::setValues ( const QList< int > &  ids,
const QStringList &  names 
)

Set the custom user items into the combo box.

User items like standard dictionary list items will be added into the combobox. This function allows user to override items.

Parameters
idsitems IDs
namesitems names

References QDS_Datum::initDatum(), myUserIds, and myUserNames.

◆ setValues() [2/2]

void QDS_ComboBox::setValues ( const QStringList &  names)

Set the custom user items into the combo box. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.User items like standard dictionary list items will be added into the combobox. This function allows user to override items.

Uses (0, 1, 2 ... ) as items IDs.

Parameters
namesitems names

References QDS_Datum::initDatum(), and setValues().

◆ state()

bool QDS_ComboBox::state ( const int  id) const

Get visibility state of the item specified by id.

Parameters
iditem ID
Returns
item visibility state

References QDS_Datum::id(), and myState.

◆ stringToValue()

int QDS_ComboBox::stringToValue ( const QString &  str) const

Convert string to integer value.

Parameters
stritem
Returns
item ID or -1 if not found

References getId().

◆ unitSystemChanged()

void QDS_ComboBox::unitSystemChanged ( const QString &  system)
protectedvirtual

Process notification about active units system changing.

Update combobox contents.

Parameters
systemnew active units system

Reimplemented from QDS_Datum.

References QDS_Datum::Handle(), QDS_Datum::id(), myDataIds, myIcons, myState, myUserIds, myUserNames, myValue, QDS::toQString(), QDS_Datum::unitSystemChanged(), and updateComboBox().

◆ updateComboBox()

void QDS_ComboBox::updateComboBox ( )
private

◆ values()

void QDS_ComboBox::values ( QList< int > &  ids,
bool  total = false 
) const

Get items identifiers.

Parameters
idsreturned list of items IDs
totalif false, only visible items are taken into account, otherwise get total number of items

References myDataIds, and myState.

◆ valueToString()

QString QDS_ComboBox::valueToString ( const int  val) const

Convert integer to string value.

Parameters
valitem ID
Returns
item value or empty string if val is invalid

References myValue.

Member Data Documentation

◆ myDataIds

QIntList QDS_ComboBox::myDataIds
private

◆ myIcons

IdIconsMap QDS_ComboBox::myIcons
private

◆ myIndex

IdIndexMap QDS_ComboBox::myIndex
private

◆ myState

IdStateMap QDS_ComboBox::myState
private

◆ myUserIds

QIntList QDS_ComboBox::myUserIds
private

◆ myUserNames

QStringList QDS_ComboBox::myUserNames
private

◆ myValue

IdValueMap QDS_ComboBox::myValue
private

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