4 #include "sharedEnums.h" 21 short _uiElementState;
22 short _elementDataType;
33 short _isColumnHidden;
34 bool _isDefaultPrecision;
36 bool _isColumnEditable;
38 bool _isShowInPortfolio;
39 short _portfolioIndex;
56 const QString &colName,
59 short dataType=API2::DATA_TYPE_UNSIGNED_LONG,
60 short state=API2::UI_STATE_DISABLED,
61 short showTableStatus =API2::TABLE_STATE_HIDE,
62 short isDbColumn = API2::DB_FEILD_HIDE,
63 short isUpdatable = API2::UPDATE_STATE_DISABLE,
64 short portfolioState = API2::SHOW_IN_PORTFOLIO_DISABLE)
65 : _uiWidget(uiWidget),
66 _uiElementState(state),
67 _isShowInTable(showTableStatus),
68 _uiElementType(elementType),
69 _elementDataType(dataType),
70 _uiLabelName(paramNameArg),
72 _isDbField(isDbColumn),
73 _updatable(isUpdatable),
74 _isColumnEditable(false),
75 _isColumnHidden(false),
76 _isDefaultPrecision(true)
78 _isShowInPortfolio = (portfolioState == API2::SHOW_IN_PORTFOLIO_ENABLE) && _isDbField ;
79 _uiLabel =
new QLabel(paramNameArg);
80 _filterType = WidgetType_MAX;
81 _sortingType = SortingType_MAX;
82 _uiElementState = elementType==UI_ELEMENT_NO_UI ? false : _uiElementState;
85 _uiWidget->setEnabled(_uiElementState);
86 _tempValue=getParamUIValue();
98 void setVisible(
bool isVisible)
100 _uiWidget->setVisible(isVisible);
101 _uiLabel->setVisible(isVisible);
105 QVariant getParamValue()
107 if(( _elementDataType==DATA_TYPE_INTEGER || _elementDataType==DATA_TYPE_SHORT)
108 && (_uiElementType!=UI_ELEMENT_DOUBLE_SPIN_BOX))
110 if(_uiElementType == UI_ELEMENT_COMBO_BOX)
111 _tempValue=_tempValue.toInt();
116 QVariant getParamUIValue()
119 if(!_uiWidget)
return _tempValue;
120 switch(_uiElementType)
122 case UI_ELEMENT_LABEL :
124 case UI_ELEMENT_COMBO_BOX:
125 _uiValue =((QComboBox *)getElement())->currentText();
127 case UI_ELEMENT_LINE_EDIT:
128 _uiValue =((QLineEdit *)getElement())->text();
130 case UI_ELEMENT_CHECK_BOX:
131 _uiValue = ((QCheckBox *)_uiWidget)->isChecked();
133 case UI_ELEMENT_PUSH_BUTTON:
135 case UI_ELEMENT_SPIN_BOX:
136 _uiValue =((QSpinBox *)getElement())->value();
138 case UI_ELEMENT_DOUBLE_SPIN_BOX:
139 value =((QDoubleSpinBox *)_uiWidget)->value();
140 _uiValue = QString::number(value,
'f',((QDoubleSpinBox *)_uiWidget)->decimals()).remove(
".").toLongLong();
142 case UI_ELEMENT_RADIO_BUTTON:
144 case UI_ELEMENT_NO_UI:
147 case UI_ELEMENT_SLIDER:
148 return ((QSlider *)_uiWidget)->value();
154 if(( _elementDataType==DATA_TYPE_INTEGER || _elementDataType==DATA_TYPE_SHORT)
155 && (_uiElementType!=UI_ELEMENT_DOUBLE_SPIN_BOX))
157 if(_uiElementType == UI_ELEMENT_COMBO_BOX)
158 _uiValue.setValue(((QComboBox *)_uiWidget)->currentIndex());
164 QString getDoubleText()
166 if(_uiElementType == UI_ELEMENT_DOUBLE_SPIN_BOX)
168 double value =((QDoubleSpinBox *)_uiWidget)->value();
169 return QString::number(value,
'f',((QDoubleSpinBox *)_uiWidget)->decimals());
175 QVariant getValueFromDouble()
177 if(_uiElementType == UI_ELEMENT_DOUBLE_SPIN_BOX)
179 double value = _tempValue.toLongLong()/pow(10.0, ((QDoubleSpinBox *)_uiWidget)->decimals());
180 return QString::number(value,
'f',((QDoubleSpinBox *)_uiWidget)->decimals());
187 void setValue(QVariant value)
193 void setUIValue(QVariant value)
198 switch(_uiElementType)
200 case UI_ELEMENT_LABEL :
202 case UI_ELEMENT_COMBO_BOX:
204 if(!QString(value.typeName()).compare(
"QString") && _elementDataType!=DATA_TYPE_INTEGER)
206 setCurrentIndex(findText(value.toString()));
208 if(!QString(value.typeName()).compare(
"int") || _elementDataType==DATA_TYPE_INTEGER)
210 ((QComboBox *)_uiWidget)->setCurrentIndex(value.toInt());
213 case UI_ELEMENT_LINE_EDIT:
214 ((QLineEdit *)_uiWidget)->setText(_uiValue.toString());
216 case UI_ELEMENT_CHECK_BOX:
217 ((QCheckBox *)_uiWidget)->setChecked(value.toBool());
219 case UI_ELEMENT_PUSH_BUTTON:
221 case UI_ELEMENT_SPIN_BOX:
222 ((QSpinBox *)_uiWidget)->setValue(_uiValue.toInt());
224 case UI_ELEMENT_DOUBLE_SPIN_BOX:
225 ((QDoubleSpinBox *)_uiWidget)->setValue(_uiValue.toDouble());
227 case UI_ELEMENT_RADIO_BUTTON:
229 case UI_ELEMENT_NO_UI:
232 case UI_ELEMENT_SLIDER:
233 ((QSlider *)_uiWidget)->setValue(_uiValue.toInt());
237 if(_elementDataType==DATA_TYPE_DOUBLE){_uiValue=value.toDouble();}
241 void setEnabled(
bool value)
243 if(_uiElementType!=UI_ELEMENT_NO_UI || _uiElementType!=UI_ELEMENT_CHECK_BOX)
246 _uiWidget->setEnabled(value);
250 void addItem(
const QString str)
252 if(_uiElementType!=UI_ELEMENT_COMBO_BOX){
return;}
253 ((QComboBox *)_uiWidget)->addItem(str);
256 void setCurrentIndex(
short index)
258 if(_uiElementType!=UI_ELEMENT_COMBO_BOX){
return;}
259 ((QComboBox *)_uiWidget)->setCurrentIndex(index);
262 short getCurrenIndexComboBox()
264 if(_uiElementType!=UI_ELEMENT_COMBO_BOX){
return 0;}
265 return(((QComboBox *)_uiWidget)->currentIndex());
268 int findText(
const QString &str)
270 return(((QComboBox*)_uiWidget)->findText(str));
276 switch(_uiElementType)
278 case UI_ELEMENT_LABEL :
279 _uiValue.setValue(str);
280 ((QLabel *)getElement())->clear();
282 case UI_ELEMENT_COMBO_BOX:
283 _uiValue.setValue(str);
284 ((QComboBox *)getElement())->clear();
286 case UI_ELEMENT_LINE_EDIT:
287 _uiValue.setValue(str);
288 ((QLineEdit *)getElement())->clear();
290 case UI_ELEMENT_CHECK_BOX:
291 _uiValue.setValue(
false);
292 ((QCheckBox *)_uiWidget)->setChecked(
false);
294 case UI_ELEMENT_PUSH_BUTTON:
296 case UI_ELEMENT_SPIN_BOX:
297 _uiValue.setValue(0);
298 ((QSpinBox *)getElement())->setValue(0);
300 case UI_ELEMENT_DOUBLE_SPIN_BOX:
301 _uiValue.setValue(0.00);
302 ((QDoubleSpinBox *)getElement())->setValue(0.00);
304 case UI_ELEMENT_RADIO_BUTTON:
306 case UI_ELEMENT_NO_UI:
308 case UI_ELEMENT_SLIDER:
309 _uiValue.setValue(0);
310 ((QSlider *)_uiWidget)->setValue(0);
317 bool compareValue(QVariant toCompare)
319 switch(_elementDataType)
321 case DATA_TYPE_SHORT:
322 return(getParamValue().toInt()==toCompare.toInt());
323 case DATA_TYPE_INTEGER:
324 return(getParamValue().toInt()==toCompare.toInt());
325 case DATA_TYPE_FLOAT:
326 return(getParamValue().toFloat()==toCompare.toFloat());
327 case DATA_TYPE_DOUBLE:
328 return(getParamValue().toDouble()==toCompare.toDouble());
329 case DATA_TYPE_STRING:
330 return(getParamValue().toString()==toCompare.toString());
331 case DATA_TYPE_SIGNED_LONG:
332 return(getParamValue().toLongLong()==toCompare.toLongLong());
333 case DATA_TYPE_UNSIGNED_LONG:
334 return(getParamValue().toLongLong()==toCompare.toLongLong());
335 case DATA_TYPE_CHARACTER:
336 return(getParamValue().toChar()==toCompare.toChar());
337 case DATA_TYPE_BOOLEAN:
338 return(getParamValue().toBool()==toCompare.toBool());
343 void setcolumnProperties(QString colName,
int colIndex,
bool show)
346 _columnIndex=colIndex;
349 void setColumnEditable(
bool type){_isColumnEditable = type;}
350 bool isColumnEditable(){
return _isColumnEditable;}
351 bool isDbField(){
return _isDbField;}
352 bool isUpdatable(){
return _updatable;}
353 int getDecimals(){
return ((QDoubleSpinBox *)_uiWidget)->decimals();}
354 QString ItemAt(
int index){
return ((QComboBox *)_uiWidget)->itemText(index);}
355 void setColumnName(QString colName){_columnName=colName;}
356 void setColumnIndex(
int colIndex){_columnIndex=colIndex;}
357 void showLabel(
bool value){ _uiLabel->setVisible(value);}
358 void setFilterType(
short type){_filterType = type;}
359 short getFilterType(){
return _filterType;}
360 void setWidget(QWidget *wid){_uiWidget = wid;}
361 void setDefaultPrecision(
bool isDefaultPrecision){_isDefaultPrecision =isDefaultPrecision;}
362 bool isDefaultPrecision(){
return _isDefaultPrecision;}
363 void setChecked(
bool value){((QCheckBox *)_uiWidget)->setChecked(value);}
364 void removeItem(
int index) {((QComboBox *)_uiWidget)->removeItem(index);}
365 QWidget* getElement() {
return _uiWidget;}
366 QString getWidgetName() {
return _uiLabel->text();}
367 short getElementType(){
return _uiElementType;}
368 short isShowInStrategyTable(){
return _isShowInTable;}
369 short getElementDataType(){
return _elementDataType;}
370 bool isChecked(){
return(((QCheckBox *)_uiWidget)->isChecked());}
371 short getParamState(){
return _uiElementState;}
372 int Count(){
return ((QComboBox *)_uiWidget)->count();}
373 bool isGui(){
return _uiElementType!=UI_ELEMENT_NO_UI;}
374 Qt::CheckState checkedState(){
return ((QCheckBox *)_uiWidget)->checkState();}
375 qlonglong getLongLongValue(){
return getParamValue().toLongLong();}
376 QString currentText(){
return getParamValue().toString();}
377 int currentIndex(){
return(((QComboBox *)_uiWidget)->currentIndex());}
378 int spinBoxValue(){
return getParamValue().toInt();}
379 double dspinBoxValue() {
return getParamValue().toDouble();}
380 QString getParamName(){
return _uiLabelName;}
381 QString getColumnName(){
return _columnName;}
382 int getColumnIndex(){
return _columnIndex;}
383 void setColumnHidden(
bool isHidden){_isColumnHidden =isHidden;}
384 bool isColumnHidden(){
return _isColumnHidden;}
385 void setSortingType(
short type){_sortingType = type;}
386 short getSortingType(){
return _sortingType;}
387 void setPortfolioIndex(
short index){_portfolioIndex = index;}
388 short getPortfolioIndex(){
return _portfolioIndex;}
389 bool isShowInPortfolio() {
return _isShowInPortfolio; }
391 typedef StrategyParameters PARAM;
392 typedef QMap<QString,PARAM *> StrategyParamMap;
393 typedef QMap<QString,QVariant> StgValueMap;
394 typedef QVector<StrategyParamMap *> ParamMapGroup;
396 #endif // SHAREDPARAMS_H Definition: sharedParams.h:13
StrategyParameters(const QString ¶mNameArg, const QString &colName, QWidget *uiWidget, short elementType, short dataType=API2::DATA_TYPE_UNSIGNED_LONG, short state=API2::UI_STATE_DISABLED, short showTableStatus=API2::TABLE_STATE_HIDE, short isDbColumn=API2::DB_FEILD_HIDE, short isUpdatable=API2::UPDATE_STATE_DISABLE, short portfolioState=API2::SHOW_IN_PORTFOLIO_DISABLE)
Constructor structure name - DbName colName widget widgetype datatype string state enable tablestatus...
Definition: sharedParams.h:55