void OptionsDialog::doProxyIpChecks(QValidatedLineEdit* pUiProxyIp, QLineEdit* pUiProxyPort) { const std::string strAddrProxy = pUiProxyIp->text().toStdString(); CService addrProxy; // Check for a valid IPv4 / IPv6 address if (!(fProxyIpValid = LookupNumeric(strAddrProxy.c_str(), addrProxy))) { disableOkButton(); pUiProxyIp->setValid(false); ui->statusLabel->setStyleSheet("QLabel { color: red; }"); ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); return; } // Check proxy port if (!pUiProxyPort->hasAcceptableInput()){ disableOkButton(); ui->statusLabel->setStyleSheet("QLabel { color: red; }"); ui->statusLabel->setText(tr("The supplied proxy port is invalid.")); return; } proxyType checkProxy = proxyType(addrProxy); if (!checkProxy.IsValid()) { disableOkButton(); ui->statusLabel->setStyleSheet("QLabel { color: red; }"); ui->statusLabel->setText(tr("The supplied proxy settings are invalid.")); return; } enableOkButton(); ui->statusLabel->clear(); }
void OptionsDialog::doProxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPort) { Q_UNUSED(nProxyPort); CService addrProxy; /* Check for a valid IPv4 / IPv6 address */ if (!(fProxyIpsValid = LookupNumeric(pUiProxyIp->text().toStdString().c_str(), addrProxy))) { disableOkButton(); pUiProxyIp->setValid(false); ui->statusLabel->setStyleSheet("QLabel { color: red; }"); ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); } else { enableOkButton(); ui->statusLabel->clear(); } }
void ApplyMeasureNowDialog::displayMeasure() { this->okButton()->setText(APPLY_MEASURE); this->okButton()->show(); this->okButton()->setEnabled(false); m_rightPaneStackedWidget->setCurrentIndex(m_argumentsOkPageIdx); m_bclMeasure.reset(); m_currentMeasureItem.clear(); m_job.reset(); m_model.reset(); m_reloadPath.reset(); openstudio::OSAppBase * app = OSAppBase::instance(); QPointer<LibraryItem> selectedItem = m_localLibraryController->selectedItem(); if (!selectedItem){ return; } UUID id = selectedItem->uuid(); try { // Get the selected measure m_bclMeasure = app->measureManager().getMeasure(id); OS_ASSERT(m_bclMeasure); OS_ASSERT(m_bclMeasure->measureType() == MeasureType::ModelMeasure); if (app->measureManager().checkForUpdates(*m_bclMeasure)){ m_bclMeasure->save(); } // measure analysis::RubyMeasure rubyMeasure(*m_bclMeasure); try{ // DLM: we don't want to use this, if we need to reload cached arguments for measure from member map we can // we could use this t_project.hasStoredArguments(*projectMeasure) boost::optional<model::Model> currentModel = app->currentModel(); OS_ASSERT(currentModel); // clone the current model in case arguments getting changes model m_model = currentModel->clone().cast<model::Model>(); // pass in an empty workspace for the idf since you know it is a model measure Workspace dummyIdf; ruleset::RubyUserScriptInfo info = app->measureManager().infoGetter()->getInfo(*m_bclMeasure, m_model, dummyIdf); std::vector<ruleset::OSArgument> args = info.arguments(); rubyMeasure.setArguments(args); // DLM: don't save the arguments to the project, if we need to preserve user inputs save to member variable map or something //t_project.registerArguments(t_measure, args); } catch (const RubyException & e) { QString errorMessage("Failed to compute arguments for measure: \n\n"); errorMessage += QString::fromStdString(e.what()); errorMessage.prepend(FAILED_ARG_TEXT); m_argumentsFailedTextEdit->setText(errorMessage); m_rightPaneStackedWidget->setCurrentIndex(m_argumentsFailedPageIdx); return; } m_currentMeasureItem = QSharedPointer<measuretab::MeasureItem>(new measuretab::MeasureItem(rubyMeasure, app)); connect(m_currentMeasureItem.data(), &measuretab::MeasureItem::argumentsChanged, this, &ApplyMeasureNowDialog::disableOkButton); bool hasIncompleteArguments = m_currentMeasureItem->hasIncompleteArguments(); disableOkButton(hasIncompleteArguments); m_currentMeasureItem->setName(m_bclMeasure->name().c_str()); m_currentMeasureItem->setDisplayName(m_bclMeasure->displayName().c_str()); m_currentMeasureItem->setDescription(m_bclMeasure->description().c_str()); // DLM: this is ok, call with overload to ignore isItOKToClearResults m_editController->setMeasureItem(m_currentMeasureItem.data(), app); } catch (const std::exception & e) { QString errorMessage("Failed to display measure: \n\n"); errorMessage += QString::fromStdString(e.what()); errorMessage.prepend(FAILED_ARG_TEXT); m_argumentsFailedTextEdit->setText(errorMessage); m_rightPaneStackedWidget->setCurrentIndex(m_argumentsFailedPageIdx); return; } }