/*! * \brief Sets up graphical user interface. */ void Blank::setupGUI() { //set up user interface ui->setupUi(this); //initialise interface and settings intrfc = new BlankInterface(this); settings = new BlankSettings(); //point base pointers to child pointers interfaceBase = intrfc; settingsBase = settings; //start listening for incomming messages intrfc->start(); //connect signals/slots qRegisterMetaType<QVector<float> >("QVector<float>"); qRegisterMetaType< QVector<float> >("QVector<QStringList>"); QObject::connect(this, SIGNAL(tabSelected()), this, SLOT(show())); QObject::connect(intrfc, SIGNAL(gpuListReceived(QVector<QStringList>)), this, SLOT(setGpuList(QVector<QStringList>))); QObject::connect(intrfc, SIGNAL(statusReceived(int)), this, SLOT(statusChanged(int))); QObject::connect(intrfc, SIGNAL(parametersReceived(/*YourParameters*/)), settings, SLOT(setParameters(/*YourParameters*/))); QObject::connect(settings->ui->pushButton_ok, SIGNAL(clicked()), settings, SLOT(accept())); QObject::connect(settings, SIGNAL(accepted()), settings, SLOT(save())); QObject::connect(settings->ui->pushButton_cancel, SIGNAL(clicked()), settings, SLOT(reject())); //get the parameters from the module intrfc->sendParametersRequest(); //check if the modeule's tab is currently selected checkFocus(mainWindow->tabWidget->currentIndex()); }
/*! * \brief Processes data received from module. */ void ERAInterface::processPortData() { if(receivedBottle.get(0).asString()=="parameters") { emit parametersReceived(receivedBottle.get(1).asInt()); } else if(receivedBottle.get(0).asString()=="data") { int size = receivedBottle.get(1).asInt(); int n = 1; double *activity, *extInput; activity = (double *)malloc(size * sizeof(double)); extInput = (double *)malloc(size * sizeof(double)); for(int i=0; i<size; i++) { activity[i] = receivedBottle.get(1+n).asDouble(); n ++; extInput[i] = receivedBottle.get(1+n).asDouble(); n ++; } emit dataReceived(size, activity, extInput); } }
void YahooFinanceNetworkRequest::handleReply(QNetworkReply *pReply) { if (!pReply) { qDebug() << "YahooFinanceNetworkRequest::handleReply, null handle, ignored"; return; } if (pReply == mpNetworkReply.data()) { qDebug() << "YahooFinanceNetworkRequest::handleReply, reply belongs to us, parsing data..."; const QVariant http_status_code = pReply->attribute( QNetworkRequest::HttpStatusCodeAttribute); bool is_error = pReply->error() != QNetworkReply::NoError; qDebug() << "YahooFinanceNetworkRequest::handleReply, HTTP status:" << http_status_code.toString() << ", is error:" << is_error; if (!is_error && HTTP_REPLY_CODE_OK == http_status_code.toInt()) { int line_index = 0; while (pReply->canReadLine() && mTickers.count() > line_index) { const QString line(pReply->readLine()); const QString ticker = mTickers.at(line_index); const QStringList data = line.simplified().split(","); if (mParameters.count() == data.count()) { QMap<YahooFinance::StockParameter, QString> data_mappings; for (int value_index = 0; value_index < data.count(); value_index++) { const YahooFinance::StockParameter param = mParameters.at(value_index); const QString value = data.at(value_index); qDebug() << "ticker:" << ticker << ", param:" << param << ", value:" << value; data_mappings.insert(param, value); } emit parametersReceived(mQueryIdentifier, ticker, data_mappings); } else { handleError(); } line_index++; } } else if (HTTP_REPLY_MOVED_PERMANENTLY == http_status_code) { const QVariant redirection_url = pReply->attribute( QNetworkRequest::RedirectionTargetAttribute); qDebug() << "Moved permanently, url:" << redirection_url; mUrl.setUrl(redirection_url.toString()); sendRequest(); } else { handleError(); qDebug() << "YahooFinanceNetworkRequest::handleReply, ERROR"; } mpNetworkReply.reset(); } else { qDebug() << "YahooFinanceNetworkRequest::handleReply, unknown handle, not handled"; pReply->deleteLater(); } }