void YTSingleVideoSource::loadVideos(int max, int startIndex) { aborted = false; this->startIndex = startIndex; this->max = max; QUrl url; if (startIndex == 1) { if (video) { QList<Video*> videos; videos << video->clone(); if (name.isEmpty()) { name = videos.first()->title(); qDebug() << "Emitting name changed" << name; emit nameChanged(name); } emit gotVideos(videos); loadVideos(max - 1, 2); return; } url = YT3::instance().method("videos"); { QUrlQueryHelper urlHelper(url); urlHelper.addQueryItem("part", "snippet"); urlHelper.addQueryItem("id", videoId); } } else { url = YT3::instance().method("search"); { QUrlQueryHelper urlHelper(url); urlHelper.addQueryItem("part", "snippet"); urlHelper.addQueryItem("type", "video"); urlHelper.addQueryItem("relatedToVideoId", videoId); urlHelper.addQueryItem("maxResults", QString::number(max)); if (startIndex > 2) { if (maybeReloadToken(max, startIndex)) return; urlHelper.addQueryItem("pageToken", nextPageToken); } } } lastUrl = url; QObject *reply = The::http()->get(url); connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResults(QByteArray))); connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*))); }
void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) { Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); while (!stream.eos() && !line.contains('}')) { if (line.matchString("criteria {", true)) { parseCriteria(stream, puzzle->criteriaList); } else if (line.matchString("results {", true)) { parseResults(stream, puzzle->resultActions); } else if (line.matchString("flags {", true)) { setStateFlags(puzzle->key, parseFlags(stream)); } line = stream.readLine(); trimCommentsAndWhiteSpace(&line); } }
/* Purpose: calls external static code test tool and display it's results TODO: call only selected part of code (if something is selected) */ void toPLSQLEditor::checkCode(void) { if (currentEditor()->editor()->text().isEmpty()) { // do nothing if code text is empty return; } QTemporaryFile tf; if (tf.open()) { if (!toWriteFile(tf.fileName(), currentEditor()->editor()->text())) { #ifdef DEBUG qDebug() << "Unable to write file (" + tf.fileName() + ")"; #endif return; } else { #ifdef DEBUG qDebug() << "Success!!! Temporary file " + tf.fileName(); #endif } } QString program = toConfigurationSingle::Instance().staticChecker().arg(tf.fileName()); #ifdef DEBUG qDebug() << "program to be executed: " + program; #endif QProcess staticCheck(qApp); staticCheck.setProcessChannelMode(QProcess::MergedChannels); staticCheck.start(program); staticCheck.waitForFinished(); // default timeout - 30000 miliseconds int exit_code = staticCheck.exitStatus(); if (exit_code != 0) { #ifdef DEBUG qDebug() << "Error executing static check. Exit code = " << exit_code; int run_error = staticCheck.error(); // error values taken from Qt4.6 documentation for QProcess switch (run_error) { case 0: qDebug() << "The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program."; break; case 1: qDebug() << "The process crashed some time after starting successfully."; break; case 5: qDebug() << "An unknown error occurred."; break; default: qDebug() << "Error code: " << run_error << "--" << staticCheck.errorString(); } // switch #endif return; } QString qq = staticCheck.readAllStandardOutput(); #ifdef DEBUG qDebug() << "stdout" << qq; #endif QMultiMap<int, QString> Observations; parseResults(qq, Observations); currentEditor()->editor()->setErrors(Observations, false); currentEditor()->applyResult("STATIC", Observations); currentEditor()->resizeResults(); } // checkCode