void SimpleBackend::processCall () { RK_TRACE (PHP); int next_token = current_template.indexOf ("$$$", template_pos); if (next_token < 0) next_token = template_sep; if (next_token > template_sep) next_token = template_sep; if (next_token < template_sep) { int token_end = current_template.indexOf ("$$$", next_token + 3); RK_ASSERT (token_end >= 0); QString token = current_template.mid (next_token + 3, token_end - (next_token + 3)); template_pos = token_end + 3; emit (requestValue (token)); return; } // all values are fetched. Now generate the return string finishCall (current_template.mid (template_sep + 3)); }
void AttributeHandler::click() { if (isReadOnly()) { requestValue(); item->setText(0, QString::fromStdString(getValue())); } else { QTreeWidget * parent = item->treeWidget(); QRect rect = parent->visualItemRect(item); QPoint pos = parent->mapToGlobal(rect.topLeft()); if (popupMenu == nullptr) { popupMenu = new QMenu(); QAction * actionChange = popupMenu->addAction("Change value"); connect(actionChange, SIGNAL(triggered ( )), this, SLOT(changeValue())); QAction * actionUpdate = popupMenu->addAction("update value"); connect(actionUpdate, SIGNAL(triggered ( )), this, SLOT(updateValue())); } popupMenu->popup(pos); } }
void AttributeHandler::updateValue() { requestValue(); }
void PHPBackend::gotOutput (KProcess *, char* buf, int len) { RK_TRACE (PHP); QString output = buf; QString request; QString data; int i; bool have_data = true;; bool have_request = false; // is there a request in the output stream? if ((i = output.find (eot_string)) >= 0) { have_request = true; // is there also pending data? if (i) { data = output.left (i); } else { have_data = false; } request = output.mid (i + eot_string.length (), len); } else { data = output; } RK_DO (qDebug ("request: %s\ndata: %s", request.latin1 (), data.latin1 ()), PHP, DL_DEBUG); // pending data is always first in a stream, so process it first, too if (have_data) { if (!startup_done) { php_process->detach (); KMessageBox::error (0, i18n ("There has been an error\n(\"%1\")\nwhile starting up the PHP backend. Most likely this is due to either a bug in RKWard or an invalid setting for the location of the PHP support files. Check the settings (Settings->Configure Settings->PHP backend) and try again.").arg (data.stripWhiteSpace ()), i18n ("PHP-Error")); emit (haveError ()); destroy (); return; } _output.append (data); } if (have_request) { if (request == "requesting code") { startup_done = true; busy = false; RK_DO (qDebug ("got type: %d, stack %d", current_type, command_stack.count ()), PHP, DL_DEBUG); if (current_type != Ignore) { if (code_property) { if (_output.isNull ()) _output = ""; // must not be null for the code property! if (current_type == Preprocess) { if (add_headings) code_property->setPreprocess (i18n ("## Prepare\n") + retrieveOutput ()); else code_property->setPreprocess (retrieveOutput ()); resetOutput (); } else if (current_type == Calculate) { if (add_headings) code_property->setCalculate (i18n ("## Compute\n") + retrieveOutput ()); else code_property->setCalculate (retrieveOutput ()); resetOutput (); } else if (current_type == Printout) { if (add_headings) code_property->setPrintout (i18n ("## Print result\n") + retrieveOutput ()); else code_property->setPrintout (retrieveOutput ()); resetOutput (); } else if (current_type == Cleanup) { if (add_headings) code_property->setCleanup (i18n ("## Clean up\n") + retrieveOutput ()); else code_property->setCleanup (retrieveOutput ()); resetOutput (); } else { emit (commandDone (current_flags)); } } else { emit (commandDone (current_flags)); } } tryNextFunction (); if (!busy) { emit (idle ()); return; } } else if (request.startsWith ("requesting data:")) { QString requested_object = request.remove ("requesting data:"); RK_DO (qDebug ("requested data: \"%s\"", requested_object.latin1 ()), PHP, DL_DEBUG); emit (requestValue (requested_object)); busy = true; // writeData (res + eot_string); } else if (request.startsWith ("requesting rcall:")) { QString requested_call = request.remove ("requesting rcall:"); RK_DO (qDebug ("requested rcall: \"%s\"", requested_call.latin1 ()), PHP, DL_DEBUG); emit (requestRCall (requested_call)); busy = true; // _responsible->doRCall (requested_call); } else if (request.startsWith ("requesting rvector:")) { QString requested_call = request.remove ("requesting rvector:"); RK_DO (qDebug ("requested rvector: \"%s\"", requested_call.latin1 ()), PHP, DL_DEBUG); emit (requestRVector (requested_call)); busy = true; // _responsible->getRVector (requested_call); } else if (request.startsWith ("PHP-Error")) { QString error = request.remove ("PHP-Error"); php_process->detach (); KMessageBox::error (0, i18n ("The PHP-backend has reported an error\n(\"%1\")\nand has been shut down. This is most likely due to a bug in the plugin. But of course you may want to try to close and restart the plugin to see whether it works with different settings.").arg (error.stripWhiteSpace ()), i18n ("PHP-Error")); emit (haveError ()); destroy (); return; } return; } }