/*! Pass the text update straight on to the QLineEdit unless the user is editing the text. Note, it would not be common to have a user editing a regularly updating value. However, this scenario should be allowed for. A reasonable reason for a user updated value to update on a gui is if is is written to by another user on another gui. This is the slot used to recieve data updates from a QCaObject based class. */ void QCaLineEdit::setTextIfNoFocus( const QString& value, QCaAlarmInfo& alarmInfo, QCaDateTime&, const unsigned int& ) { /// If not subscribing, then do nothing. /// Note, This will still be called even if not subscribing as there is an initial sing shot read /// to ensure we have valid information about the variable when it is time to do a write. if( !subscribe ) return; /// Save the most recent value. /// If the user is editing the value updates are not applied. If the user cancels the write, the value the widget /// should revert to the latest value. lastValue = value; /// Signal a database value change to any Link widgets emit dbValueChanged( value ); /// Update the text if appropriate /// If the user is editing the object then updates will be inapropriate if( hasFocus() == false ) setText( value ); /// If in alarm, display as an alarm if( alarmInfo.getSeverity() != lastSeverity ) { updateToolTipAlarm( alarmInfo.severityName() ); setStyleSheet( alarmInfo.style() ); lastSeverity = alarmInfo.getSeverity(); } }
/*! Pass the update straight on to the SpinBox unless the user is changing it. Note, it would not be common to have a user editing a regularly updating value. However, this scenario should be allowed for. A reasonable reason for a user modified value to update on a gui is if is is written to by another user on another gui. This is the slot used to recieve data updates from a QCaObject based class. This is the slot used to recieve data updates from a QCaObject based class. */ void QCaSpinBox::setValueIfNoFocus( const long& value, QCaAlarmInfo& alarmInfo, QCaDateTime&, const unsigned int& ) { /// If not subscribing, then do nothing. /// Note, This will still be called even if not subscribing as there may be initial sing shot read /// to ensure we have valid information about the variable when it is time to do a write. if( !subscribe ) return; /// Signal a database value change to any Link widgets emit dbValueChanged( value ); /// Update the spin box only if the user is not interacting with the object. if( !hasFocus() ) { programaticValueChange = true; setValue( value ); programaticValueChange = false; } /// If in alarm, display as an alarm if( alarmInfo.getSeverity() != lastSeverity ) { updateToolTipAlarm( alarmInfo.severityName() ); setStyleSheet( alarmInfo.style() ); lastSeverity = alarmInfo.getSeverity(); } }
// Implement a slot to set the current text of the push button // This is the slot used to recieve data updates from a QCaObject based class. void QEPeriodic::setElement( const double& value, QCaAlarmInfo& alarmInfo, QCaDateTime&, const unsigned int& variableIndex ) { // Signal a database value change to any Link widgets emit dbValueChanged( value ); QString newText; switch( variableIndex ) { // Write push button variables case 0: case 1: if( writeButton ) { if( getElementTextForValue( value, variableIndex, writeButtonData, writeButton->text(), newText ) ) writeButton->setText( newText ); } break; // Readback Label variables case 2: case 3: if( readbackLabel ) { // When checking if an element matched the current text, use the button text in preference to the readback label. // This is required if several elements have the same values. QString currentText; if( writeButton ) { currentText = writeButton->text(); } else { currentText = readbackLabel->text(); } if( getElementTextForValue( value, variableIndex, readbackLabelData, currentText, newText ) ) readbackLabel->setText( newText ); } break; } // Invoke common alarm handling processing. // TODO: Aggregate all channel severities into a single alarm state. processAlarmInfo( alarmInfo ); // if( writeButton ) // writeButton->setStyleSheet( ai.style() ); // // if( readbackLabel ) // readbackLabel->setStyleSheet( ai.style() ); }
/* Pass the update straight on to the SpinBox unless the user is changing it. Note, it would not be common to have a user editing a regularly updating value. However, this scenario should be allowed for. A reasonable reason for a user modified value to update on a gui is if is is written to by another user on another gui. This is the slot used to recieve data updates from a QCaObject based class. This is the slot used to recieve data updates from a QCaObject based class. */ void QESpinBox::setValueIfNoFocus( const double& value, QCaAlarmInfo& alarmInfo, QCaDateTime&, const unsigned int& ) { // Set the limits and step size QEFloating* qca = (QEFloating*)getQcaItem(0); double upper = qca->getControlLimitUpper(); double lower = qca->getControlLimitLower(); if( upper != lower) { setMaximum( qca->getControlLimitUpper() ); setMinimum( qca->getControlLimitLower() ); } setDecimalsFromPrecision( qca ); setSuffixEgu( qca ); // Do nothing more if doing a single shot read (done when not subscribing to get range values) if( ignoreSingleShotRead ) { ignoreSingleShotRead = false; return; } // Signal a database value change to any Link widgets emit dbValueChanged( value ); // Save the last database value lastValue = value; // Update the spin box only if the user is not interacting with the object. if( !hasFocus() ) { // Update the spin box programaticValueChange = true; setValue( value ); programaticValueChange = false; // Note the last value seen by the user lastUserValue = text(); } // Invoke common alarm handling processing. processAlarmInfo( alarmInfo ); }
/* Pass the update straight on to the QSlider unless the user is moving the slider. Note, it would not be common to have a user editing a regularly updating value. However, this scenario should be allowed for. A reasonable reason for a user modified value to update on a gui is if is is written to by another user on another gui. This is the slot used to recieve data updates from a QCaObject based class. */ void QESlider::setValueIfNoFocus( const double& value, QCaAlarmInfo& alarmInfo, QCaDateTime&, const unsigned int& ) { // Do nothing if doing a single shot read (done when not subscribing to get enumeration values) if( ignoreSingleShotRead ) { ignoreSingleShotRead = false; return; } // Signal a database value change to any Link widgets emit dbValueChanged( qlonglong( value ) ); // Update the slider only if the user is not interacting with the object. if( !hasFocus() ) { updateInProgress = true; currentValue = value; int intValue = int( (value - offset) * scale ); setValue( intValue ); updateInProgress = false; } // Invoke common alarm handling processing. processAlarmInfo( alarmInfo ); }
//================================================================= void BoardButton::construct(){ //printf("construct\n");fflush(stdout); HvCrate::label_chnumber_title=new QLabel(mainw); HvCrate::label_chnumber_title->setText("#"); HvCrate::label_chnumber_title->setGeometry(QRect(HvCrate::TABLE_XBASE-30, HvCrate::TABLE_YBASE, 30, 20)); HvCrate::label_chnumber_title->setFrameShape(QFrame::Box); HvCrate::label_chnumber_title->setVisible(true); for(int j=0;j<HvCrate::params_read;j++){ HvCrate::label_hvpar[j] = new QLabel(mainw); HvCrate::label_hvpar[j]->setText( params_labels_caen[j]); HvCrate::label_hvpar[j]->setGeometry(QRect(HvCrate::TABLE_XBASE+j*60, HvCrate::TABLE_YBASE, 60, 20)); HvCrate::label_hvpar[j]->setFrameShape(QFrame::Box); HvCrate::label_hvpar[j]->setVisible(true); } for(int j=0;j<HvCrate::params_switch;j++){ HvCrate::label_hvpar[j+HvCrate::params_read] = new QLabel(mainw); HvCrate::label_hvpar[j+HvCrate::params_read]->setText(params_labels_caen[j+HvCrate::params_read]); HvCrate::label_hvpar[j+HvCrate::params_read]->setGeometry(QRect(HvCrate::TABLE_XBASE+(j+HvCrate::params_read)*60, HvCrate::TABLE_YBASE, 60, 20)); HvCrate::label_hvpar[j+HvCrate::params_read]->setFrameShape(QFrame::Box); HvCrate::label_hvpar[j+HvCrate::params_read]->setVisible(true); } for(int j=0;j<HvCrate::params_set;j++){ HvCrate::label_hvpar[j+HvCrate::params_read+HvCrate::params_switch] = new QLabel(mainw); HvCrate::label_hvpar[j+HvCrate::params_read+HvCrate::params_switch]->setText( params_labels_caen[j+HvCrate::params_read+HvCrate::params_switch]); HvCrate::label_hvpar[j+HvCrate::params_read+HvCrate::params_switch]->setGeometry(QRect(HvCrate::TABLE_XBASE+(j+HvCrate::params_read+HvCrate::params_switch)*60, HvCrate::TABLE_YBASE, 60, 20)); HvCrate::label_hvpar[j+HvCrate::params_read+HvCrate::params_switch]->setFrameShape(QFrame::Box); HvCrate::label_hvpar[j+HvCrate::params_read+HvCrate::params_switch]->setVisible(true); } for(int i=0;i<HvCrate::channels_num;i++){ int i10=i+1; HvCrate::hvch[i].label_chnumber=new QLabel(mainw); HvCrate::hvch[i].label_chnumber->setText(QString::number(i)); HvCrate::hvch[i].label_chnumber->setGeometry(QRect(HvCrate::TABLE_XBASE-30, HvCrate::TABLE_YBASE+i10*20, 30, 20)); HvCrate::hvch[i].label_chnumber->setFrameShape(QFrame::Box); HvCrate::hvch[i].label_chnumber->setVisible(true); for(int j=0;j<HvCrate::params_read;j++){ QString qs=QString( "some_name" ); HvCrate::hvch[i].hvpar_read[j]=new MyQCaLabel(qs,(QWidget *) mainw, j ); connect(HvCrate::hvch[i].hvpar_read[j], SIGNAL(dbValueChanged(QString)), HvCrate::hvch[i].hvpar_read[j], SLOT(s_dbValueChanged(QString)) ); HvCrate::hvch[i].hb_isactivated[j]=0; // HvCrate::hvch[i].hvpar_read[j]->setVisible(false); HvCrate::hvch[i].hvpar_read[j]->setGeometry(QRect(HvCrate::TABLE_XBASE+j*60, HvCrate::TABLE_YBASE+i10*20, 60, 20)); HvCrate::hvch[i].hvpar_read[j]->setFrameShape(QFrame::Box); } for(int j=0;j<HvCrate::params_switch;j++){ HvCrate::hvch[i].hvpar_switch[j]=new MyQCaComboBox( "some_name" , mainw, j ); HvCrate::hvch[i].hvpar_switch[j]->setSubscribe(true); connect(HvCrate::hvch[i].hvpar_switch[j], SIGNAL(dbValueChanged(qlonglong)), HvCrate::hvch[i].hvpar_switch[j], SLOT(s_dbValueChanged(qlonglong)) ); HvCrate::hvch[i].hb_isactivated[j+HvCrate::params_read]=0; if(HvCrate::crate_type==CrateButton::WMPOD && j==0){ HvCrate::hvch[i].hvpar_switch[j]->insertItem(0, "OFF"); HvCrate::hvch[i].hvpar_switch[j]->insertItem(1, "ON"); } // HvCrate::hvch[i].hvpar_switch[j]->setVisible(false); HvCrate::hvch[i].hvpar_switch[j]->setGeometry(QRect(HvCrate::TABLE_XBASE+(j+HvCrate::params_read)*60, HvCrate::TABLE_YBASE+i10*20, 80, 20)); } for(int j=0;j<HvCrate::params_set;j++){ HvCrate::hvch[i].hvpar_set[j]=new QCaLineEdit( "some_name" , mainw ); HvCrate::hvch[i].hb_isactivated[j+HvCrate::params_read+HvCrate::params_switch]=0; // HvCrate::hvch[i].hvpar_set[j]->setVisible(false); HvCrate::hvch[i].hvpar_set[j]->setGeometry(QRect(HvCrate::TABLE_XBASE+(j+HvCrate::params_read+HvCrate::params_switch)*60, HvCrate::TABLE_YBASE+i10*20, 60, 20)); } } //i HvCrate::constructed=1; }