//------------------------------------------------------------------------- int Handler::Handle( Asev::Event &e ) { if( e.Info() != typeid( Event ) ) return 0; #define GETERROR static_cast<ErrorEvent&>(e).GetError() int result = 0; Event &stream_event = static_cast<Event&>(e); switch( stream_event.m_class ) { case Event::ACCEPTED: Accepted( stream_event.m_stream ); break; case Event::ACCEPTERROR: AcceptError( stream_event.m_stream, GETERROR ); break; case Event::CONNECTED: Connected( stream_event.m_stream ); break; case Event::CONNECTERROR: ConnectError( stream_event.m_stream, GETERROR ); break; case Event::DISCONNECTED: Disconnected( stream_event.m_stream, GETERROR ); break; case Event::RECEIVE: Receive( stream_event.m_stream, static_cast<Event::Receive&>(e).GetMessage() ); break; case Event::SENDFAILED: SendFailed( stream_event.m_stream, GETERROR ); break; } return result; }
void LibraryFilterWidget::SetLibraryModel(LibraryModel* model) { if (model_) { disconnect(model_, 0, this, 0); disconnect(model_, 0, group_by_dialog_.get(), 0); disconnect(group_by_dialog_.get(), 0, model_, 0); disconnect(filter_age_mapper_, 0, model_, 0); } model_ = model; // Connect signals connect(model_, SIGNAL(GroupingChanged(LibraryModel::Grouping)), group_by_dialog_.get(), SLOT(LibraryGroupingChanged(LibraryModel::Grouping))); connect(model_, SIGNAL(GroupingChanged(LibraryModel::Grouping)), SLOT(GroupingChanged(LibraryModel::Grouping))); connect(group_by_dialog_.get(), SIGNAL(Accepted(LibraryModel::Grouping)), model_, SLOT(SetGroupBy(LibraryModel::Grouping))); connect(filter_age_mapper_, SIGNAL(mapped(int)), model_, SLOT(SetFilterAge(int))); // Load settings if (!settings_group_.isEmpty()) { QSettings s; s.beginGroup(settings_group_); model_->SetGroupBy(LibraryModel::Grouping( LibraryModel::GroupBy( s.value("group_by1", int(LibraryModel::GroupBy_Artist)).toInt()), LibraryModel::GroupBy( s.value("group_by2", int(LibraryModel::GroupBy_Album)).toInt()), LibraryModel::GroupBy( s.value("group_by3", int(LibraryModel::GroupBy_None)).toInt()))); } }
PlayerDialog::PlayerDialog(QWidget *parent) : QDialog(parent), ui(new Ui::PlayerDialog) { ui->setupUi(this); connect(ui->buttonBox,SIGNAL(accepted()),this,SLOT(Accepted())); }
SearchBoxWidget::SearchBoxWidget(InternetService* service) : service_(service), ui_(new Ui_SearchBoxWidget), menu_(new QMenu(tr("Display options"), this)) { ui_->setupUi(this); // Icons ui_->options->setIcon(IconLoader::Load("configure", IconLoader::Base)); // Options menu menu_->setIcon(ui_->options->icon()); ui_->options->setMenu(menu_); menu_->addAction(IconLoader::Load("configure", IconLoader::Base), tr("Configure %1...").arg(service_->name()), service_, SLOT(ShowConfig())); ui_->filter->setPlaceholderText( QString("Search on %1").arg(service_->name())); connect(ui_->filter, SIGNAL(textChanged(QString)), SIGNAL(TextChanged(QString))); did_you_mean_ = new DidYouMean(ui_->filter, this); connect(did_you_mean_, SIGNAL(Accepted(QString)), ui_->filter, SLOT(setText(QString))); }
EditDialog::EditDialog(QWidget *parent) : QDialog(parent), ui(new Ui::EditDialog) { ui->setupUi(this); connect(this,SIGNAL(accepted()),this,SLOT(Accepted())); connect(ui->lineEdit,SIGNAL(textChanged(QString)),this,SLOT(textChanged(QString))); }
void NewObstacleDialog::emitAccepted() { emit Accepted(this->ui->nombre->toPlainText().toInt()); }
Future<http::Response> ResourceProviderManagerProcess::api( const http::Request& request, const Option<Principal>& principal) { if (request.method != "POST") { return MethodNotAllowed({"POST"}, request.method); } v1::resource_provider::Call v1Call; // TODO(anand): Content type values are case-insensitive. Option<string> contentType = request.headers.get("Content-Type"); if (contentType.isNone()) { return BadRequest("Expecting 'Content-Type' to be present"); } if (contentType.get() == APPLICATION_PROTOBUF) { if (!v1Call.ParseFromString(request.body)) { return BadRequest("Failed to parse body into Call protobuf"); } } else if (contentType.get() == APPLICATION_JSON) { Try<JSON::Value> value = JSON::parse(request.body); if (value.isError()) { return BadRequest("Failed to parse body into JSON: " + value.error()); } Try<v1::resource_provider::Call> parse = ::protobuf::parse<v1::resource_provider::Call>(value.get()); if (parse.isError()) { return BadRequest("Failed to convert JSON into Call protobuf: " + parse.error()); } v1Call = parse.get(); } else { return UnsupportedMediaType( string("Expecting 'Content-Type' of ") + APPLICATION_JSON + " or " + APPLICATION_PROTOBUF); } Call call = devolve(v1Call); Option<Error> error = validate(call); if (error.isSome()) { return BadRequest( "Failed to validate resource_provider::Call: " + error->message); } ContentType acceptType; if (request.acceptsMediaType(APPLICATION_JSON)) { acceptType = ContentType::JSON; } else if (request.acceptsMediaType(APPLICATION_PROTOBUF)) { acceptType = ContentType::PROTOBUF; } else { return NotAcceptable( string("Expecting 'Accept' to allow ") + "'" + APPLICATION_PROTOBUF + "' or '" + APPLICATION_JSON + "'"); } switch(call.type()) { case Call::UNKNOWN: { return NotImplemented(); } case Call::SUBSCRIBE: { Pipe pipe; OK ok; ok.headers["Content-Type"] = stringify(acceptType); ok.type = http::Response::PIPE; ok.reader = pipe.reader(); HttpConnection http(pipe.writer(), acceptType); subscribe(http, call.subscribe()); return ok; } case Call::UPDATE: { if (!resourceProviders.contains(call.resource_provider_id())) { return BadRequest("Resource provider cannot be found"); } auto resourceProvider = resourceProviders.at(call.resource_provider_id()); update(&resourceProvider, call.update()); return Accepted(); } } UNREACHABLE(); }