void QSpinBoxReal32::updateDisplay(void) { getLineEdit()->setUpdatesEnabled(false ); QString value(_spinHelper.getValueByStr().c_str()); value.setNum (value.toFloat() ); getLineEdit()->setText (value ); getLineEdit()->setEnabled (isEnabled() && !getReadOnly() ); getLineEdit()->setUpdatesEnabled(true ); getLineEdit()->repaint (false ); bool bUpEnabled = (isEnabled () == true ) && (getReadOnly() == false ) && ((_spinHelper.getValue() < _spinHelper.getUpperBound()) || (_spinHelper.getWrapAround() == true ) ); bool bDownEnabled = (isEnabled () == true ) && (getReadOnly() == false ) && ((_spinHelper.getValue() > _spinHelper.getLowerBound()) || (_spinHelper.getWrapAround() == true ) ); _pSpinWidget->setUpEnabled (bUpEnabled ); _pSpinWidget->setDownEnabled(bDownEnabled); repaint(false); }
OSG_USING_NAMESPACE QSpinBoxReal32::QSpinBoxReal32(QWidget *pParent, const char *name) : Inherited (pParent, name), _bTextChanged(false ), _spinHelper ( ), _pSpinWidget (NULL ) { _pSpinWidget = new QSpinWidget(this, "QSpinBoxReal32::_pSpinWidget"); connect(_pSpinWidget, SIGNAL(stepUpPressed (void)), this, SLOT (stepUp (void)) ); connect(_pSpinWidget, SIGNAL(stepDownPressed(void)), this, SLOT (stepDown (void)) ); _pSpinWidget ->setEditWidget (getLineEdit()); getLineEdit()->installEventFilter(this ); connect(getLineEdit(), SIGNAL(textChanged (const QString &)), this, SLOT (slotTextChanged (void )) ); connect(getLineEdit(), SIGNAL(returnPressed (void )), this, SLOT (slotReturnPressed(void )) ); updateDisplay(); }
void QSpinBoxReal32::slotTextChanged(void) { _bTextChanged = true; _spinHelper.setValueByStr(getLineEdit()->text().latin1()); emit valueChanged(); }
void QSpinBoxReal32::slotReturnPressed(void) { if(_bTextChanged == true) { _bTextChanged = false; _spinHelper.setValueByStr(getLineEdit()->text().latin1()); } updateDisplay(); }
void GUI::search() { auto textEdit = getLineEdit("input"); auto qSearchString = textEdit->text(); if(qSearchString.size() == 0) { return; } std::string searchString = QUtil::instance().convertQStringtoStdString(qSearchString); auto result = KeyWordSearch::getInstance().search(searchString); Display(result); outputButtons->setVisible(true); }
void GUI::checkBoxSelected() { auto itr = checkBoxes.begin(); auto itrEnd = checkBoxes.end(); std::vector<std::string> checkedBoxes; while(itr != itrEnd) { if(itr->second->isChecked()) { checkedBoxes.push_back(QUtil::instance().convertQStringtoStdString(itr->second->text())); } ++itr; } auto textEdit = getLineEdit("input"); auto qSearchString = textEdit->text(); if (qSearchString.size() == 0) { return; } std::string searchString = QUtil::instance().convertQStringtoStdString(qSearchString); auto prev = KeyWordSearch::getInstance().search(searchString); //std::map<std::string, std::vector<std::string>>result; std::vector<std::string>result; std::vector < std::string > out; out.insert(out.end(), prev.begin(), prev.end()); auto size = checkedBoxes.size(); for (int i = 0; i < size; ++i) { auto temp = KeyWordSearch::getInstance().getFeatureNames(checkedBoxes[i]); out.insert(out.end(), temp.begin(), temp.end()); //result[checkedBoxes[i]]; } std::vector<std::string >output; KeyWordSearch::getInstance().recommendation(out, output); // auto itr = result.find(checkedBoxes[i]); // if (itr != result.end()) // { // itr->second.insert(itr->second.end(), output.begin(), output.end()); // } // else // result[checkedBoxes[i]] = output; //} recommendation(output); }
bool QSpinBoxReal32::eventFilter(QObject *pObj, QEvent *pEvent) { bool retValue = false; if(pObj != getLineEdit()) return Inherited::eventFilter(pObj, pEvent); if(pEvent->type() == QEvent::KeyPress) { QKeyEvent *pKeyEvent = static_cast<QKeyEvent *>(pEvent); switch(pKeyEvent->key()) { case Qt::Key_Tab: case Qt::Key_BackTab: { if(_bTextChanged == true) { this->slotReturnPressed(); } qApp->sendEvent(this, pEvent); retValue = true; break; } case Qt::Key_Up: { if(_bTextChanged == true) { this->slotReturnPressed(); } this->stepUp(); retValue = true; break; } case Qt::Key_Down: { if(_bTextChanged == true) { this->slotReturnPressed(); } this->stepDown(); retValue = true; break; } case Qt::Key_PageUp: { if(_bTextChanged == true) { this->slotReturnPressed(); } this->stepPageUp(); retValue = true; break; } case Qt::Key_PageDown: { if(_bTextChanged == true) { this->slotReturnPressed(); } this->stepPageDown(); retValue = true; break; } case Qt::Key_Return: case Qt::Key_Enter: { this->slotReturnPressed(); break; } }; } else if((pEvent->type() == QEvent::FocusOut) || (pEvent->type() == QEvent::Hide ) ) { if(_bTextChanged == true) { this->slotReturnPressed(); } } return retValue; }