void ITunesFeature::onRightClick(const QPoint& globalPos) { BaseExternalLibraryFeature::onRightClick(globalPos); QMenu menu; QAction useDefault(tr("Use Default Library"), &menu); QAction chooseNew(tr("Choose Library..."), &menu); menu.addAction(&useDefault); menu.addAction(&chooseNew); QAction *chosen(menu.exec(globalPos)); if (chosen == &useDefault) { SettingsDAO settings(m_database); settings.setValue(ITDB_PATH_KEY, QString()); activate(true); // clears tables before parsing } else if (chosen == &chooseNew) { SettingsDAO settings(m_database); QString dbfile = QFileDialog::getOpenFileName( NULL, tr("Select your iTunes library"), QDir::homePath(), "*.xml"); QFileInfo dbFileInfo(dbfile); if (dbfile.isEmpty() || !dbFileInfo.exists()) { return; } // The user has picked a new directory via a file dialog. This means the // system sandboxer (if we are sandboxed) has granted us permission to // this folder. Create a security bookmark while we have permission so // that we can access the folder on future runs. We need to canonicalize // the path so we first wrap the directory string with a QDir. Sandbox::createSecurityToken(dbFileInfo); settings.setValue(ITDB_PATH_KEY, dbfile); activate(true); // clears tables before parsing } }
void SetWidget::dropEvent(QDropEvent* event) { ui->addLabel->setVisible(false); event->accept(); emit chosen(); }
bool QCompletionEdit::qt_emit( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->signalOffset() ) { case 0: chosen((const QString&)static_QUType_QString.get(_o+1)); break; default: return QLineEdit::qt_emit(_id,_o); } return TRUE; }
// Checks if ALPN was negotiated correctly and returns false if it wasn't. // After this returns successfully, alpn_ will be set to the negotiated // protocol. bool TransportLayerDtls::CheckAlpn() { if (alpn_allowed_.empty()) { return true; } SSLNextProtoState alpnState; char chosenAlpn[MAX_ALPN_LENGTH]; unsigned int chosenAlpnLen; SECStatus rv = SSL_GetNextProto(ssl_fd_, &alpnState, reinterpret_cast<unsigned char*>(chosenAlpn), &chosenAlpnLen, sizeof(chosenAlpn)); if (rv != SECSuccess) { MOZ_MTLOG(ML_ERROR, LAYER_INFO << "ALPN error"); return false; } switch (alpnState) { case SSL_NEXT_PROTO_SELECTED: case SSL_NEXT_PROTO_NEGOTIATED: break; // OK case SSL_NEXT_PROTO_NO_SUPPORT: MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "ALPN not negotiated, " << (alpn_default_.empty() ? "failing" : "selecting default")); alpn_ = alpn_default_; return !alpn_.empty(); case SSL_NEXT_PROTO_NO_OVERLAP: // This only happens if there is a custom NPN/ALPN callback installed and // that callback doesn't properly handle ALPN. MOZ_MTLOG(ML_ERROR, LAYER_INFO << "error in ALPN selection callback"); return false; case SSL_NEXT_PROTO_EARLY_VALUE: MOZ_CRASH("Unexpected 0-RTT ALPN value"); return false; } // Warning: NSS won't null terminate the ALPN string for us. std::string chosen(chosenAlpn, chosenAlpnLen); MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "Selected ALPN string: " << chosen); if (alpn_allowed_.find(chosen) == alpn_allowed_.end()) { // Maybe our peer chose a protocol we didn't offer (when we are client), or // something is seriously wrong. std::ostringstream ss; for (auto i = alpn_allowed_.begin(); i != alpn_allowed_.end(); ++i) { ss << (i == alpn_allowed_.begin() ? " '" : ", '") << *i << "'"; } MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Bad ALPN string: '" << chosen << "'; permitted:" << ss.str()); return false; } alpn_ = chosen; return true; }
expr_ref_vector mk_array_instantiation::instantiate_pred(app*old_pred) { unsigned nb_old_args=old_pred->get_num_args(); //Stores, for each old position, the list of a new possible arguments vector<expr_ref_vector> arg_correspondance; for(unsigned i=0;i<nb_old_args;i++) { expr_ref arg(old_pred->get_arg(i), m); if(m_a.is_array(get_sort(arg))) { vector<expr_ref_vector> arg_possibilities(m_ctx.get_params().xform_instantiate_arrays_nb_quantifier(), retrieve_all_selects(arg)); arg_correspondance.append(arg_possibilities); if(!m_ctx.get_params().xform_instantiate_arrays_enforce()) { expr_ref_vector tmp(m); tmp.push_back(arg); arg_correspondance.push_back(tmp); } } else { expr_ref_vector tmp(m); tmp.push_back(arg); arg_correspondance.push_back(tmp); } } //Now, we need to deal with every combination expr_ref_vector res(m); svector<unsigned> chosen(arg_correspondance.size(), 0u); while(1) { expr_ref_vector new_args(m); for(unsigned i=0;i<chosen.size();i++) { new_args.push_back(arg_correspondance[i][chosen[i]].get()); } res.push_back(create_pred(old_pred, new_args)); unsigned pos=-1; do { pos++; if(pos==chosen.size()) { return res; } }while(chosen[pos]+1>=arg_correspondance[pos].size()); chosen[pos]++; } }
bool RrtDual::solve() { this->begin[0] = this->addVertex(this->tree[0], ::boost::make_shared< ::rl::math::Vector >(*this->start)); this->begin[1] = this->addVertex(this->tree[1], ::boost::make_shared< ::rl::math::Vector >(*this->goal)); ::rl::math::Vector chosen(this->model->getDof()); timer.start(); timer.stop(); while (timer.elapsed() < this->duration) { this->choose(chosen); Neighbor nearest = this->nearest(this->tree[0], chosen); Vertex extended = this->extend(this->tree[0], nearest, chosen); if (NULL != extended) { Neighbor nearest2 = this->nearest(this->tree[1], chosen); Vertex extended2 = this->extend(this->tree[1], nearest2, chosen); if (NULL != extended2) { if (this->areEqual(*this->tree[0][extended].q, *this->tree[1][extended2].q)) { this->end[0] = extended; this->end[1] = extended2; return true; } } } timer.stop(); } return false; }
void ITunesFeature::onRightClick(const QPoint& globalPos) { BaseExternalLibraryFeature::onRightClick(globalPos); QMenu menu; QAction useDefault(tr("Use Default Library"), &menu); QAction chooseNew(tr("Choose Library..."), &menu); menu.addAction(&useDefault); menu.addAction(&chooseNew); QAction *chosen(menu.exec(globalPos)); if (chosen == &useDefault) { SettingsDAO settings(m_database); settings.setValue(ITDB_PATH_KEY, QString()); activate(true); // clears tables before parsing } else if (chosen == &chooseNew) { SettingsDAO settings(m_database); QString dbfile = QFileDialog::getOpenFileName( NULL, tr("Select your iTunes library"), QDir::homePath(), "*.xml"); if (dbfile.isEmpty() || !QFile::exists(dbfile)) { return; } settings.setValue(ITDB_PATH_KEY, dbfile); activate(true); // clears tables before parsing } }
QString text() const { return chosen(); }
bool QCompletionEdit::eventFilter( QObject *o, QEvent *e ) { if ( o == popup || o == listbox || o == listbox->viewport() ) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent*)e; if ( ke->key() == Key_Enter || ke->key() == Key_Return || ke->key() == Key_Tab ) { if ( ke->key() == Key_Tab && listbox->count() > 1 && listbox->currentItem() < (int)listbox->count() - 1 ) { listbox->setCurrentItem( listbox->currentItem() + 1 ); return TRUE; } popup->close(); setFocus(); blockSignals( TRUE ); setText( listbox->currentText() ); blockSignals( FALSE ); emit chosen( text() ); return TRUE; } else if ( ke->key() == Key_Left || ke->key() == Key_Right || ke->key() == Key_Up || ke->key() == Key_Down || ke->key() == Key_Home || ke->key() == Key_End || ke->key() == Key_Prior || ke->key() == Key_Next ) { return FALSE; } else if ( ke->key() == Key_Escape ) { popup->close(); setFocus(); } else if ( ke->key() != Key_Shift && ke->key() != Key_Control && ke->key() != Key_Alt ) { updateListBox(); if ( listbox->count() == 0 || text().length() == 0 ) { popup->close(); setFocus(); } QApplication::sendEvent( this, e ); return TRUE; } } else if ( e->type() == QEvent::MouseButtonDblClick ) { popup->close(); setFocus(); blockSignals( TRUE ); setText( listbox->currentText() ); blockSignals( FALSE ); emit chosen( text() ); return TRUE; } } else if ( o == this ) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent*)e; if ( ke->key() == Key_Up || ke->key() == Key_Down || ke->key() == Key_Prior || ke->key() == Key_Next || ke->key() == Key_Return || ke->key() == Key_Enter || ke->key() == Key_Tab || ke->key() == Key_Escape ) { QApplication::sendEvent( listbox, e ); return TRUE; } } } return QLineEdit::eventFilter( o, e ); }