bool DecodeBitstreamCommand::execute( GitlCommandParameter& rcInputArg, GitlCommandParameter& rcOutputArg ) { ModelLocator* pModel = ModelLocator::getInstance(); /// *****STEP 0 : Request***** QVariant vValue; vValue = rcInputArg.getParameter("filename"); QString strFilename = vValue.toString(); vValue = rcInputArg.getParameter("version"); int iVersion = vValue.toInt(); vValue = rcInputArg.getParameter("skip_decode"); bool bSkipDecode = vValue.toBool(); QString strDecoderPath = "./decoders"; QString strDecoderOutputPath = pModel->getPreferences().getCacheFolder(); int iSequenceIndex = pModel->getSequenceManager().getAllSequences().size(); strDecoderOutputPath += QString("/%1").arg(iSequenceIndex); /// show busy dialog GitlUpdateUIEvt evt; evt.setParameter("busy_dialog_visible", true); evt.dispatch(); /// hide busy dialog when scope exit SCOPE_EXIT(GitlUpdateUIEvt evt; evt.setParameter("busy_dialog_visible", false); evt.dispatch(); );
static void xMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &strMsg) { QByteArray localMsg = strMsg.toLocal8Bit(); switch (type) { case QtDebugMsg: fprintf(stdout, "[Debug]: %s\n", localMsg.constData()); break; case QtWarningMsg: fprintf(stderr, "[Warn]: %s\n", localMsg.constData()); break; case QtCriticalMsg: fprintf(stderr, "[Crit]: %s\n", localMsg.constData()); break; case QtFatalMsg: fprintf(stderr, "[Fata]: %s\n", localMsg.constData()); } fflush(stdout); fflush(stderr); GitlUpdateUIEvt cEvt; cEvt.setParameter("msg_detail", strMsg); cEvt.setParameter("msg_level",(int)type); cEvt.dispatch(); if(type == QtFatalMsg) abort(); }
void GitlFrontController::onCommandRequestArrive(GitlIvkCmdEvt &rcEvt) { QMutexLocker cCmdExeMutexLocker(&m_cCmdExeMutex); GitlUpdateUIEvt cRefreshUIEvt; GitlCommandParameter& rcRequest = rcEvt.getParameters(); GitlCommandParameter& rcRespond = cRefreshUIEvt.getParameters(); // find command by name QString strCommandName = rcEvt.getCommandName(); rcRespond.setParameter("command_name", strCommandName); QHash<QString, QMetaObject*>::iterator i = m_cCommandTable.find(strCommandName); if( i != m_cCommandTable.end() ) { //command name matched //create command const QMetaObject* pMetaObj = i.value(); QObject* pObj = pMetaObj->newInstance(); //if fail to create command class if(pObj == NULL) { qCritical() << QString("Unable to create command class '%1'! Please ensure the constructor have Q_INVOKABLE macro.") .arg(pMetaObj->className()); return; } QSharedPointer<GitlAbstractCommand> pCmd(static_cast<GitlAbstractCommand *>(pObj)); //execute command if( pCmd->execute(rcRequest, rcRespond) == false ) { qDebug() << QString("%1 Execution Failed!").arg(pMetaObj->className()); } else { cRefreshUIEvt.dispatch(); qDebug() << QString("%1 Execution Success!").arg(pMetaObj->className()); } return; } qWarning() << QString("No matched command name found. %1").arg(strCommandName); return; }