本文整理汇总了C++中actiontools::ActionInstance::definition方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionInstance::definition方法的具体用法?C++ ActionInstance::definition怎么用?C++ ActionInstance::definition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actiontools::ActionInstance
的用法示例。
在下文中一共展示了ActionInstance::definition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeCurrentAction
void Executer::executeCurrentAction()
{
//Skip disabled actions
if(mCurrentActionIndex >= 0)
{
while(mCurrentActionIndex < mScript->actionCount() && canExecuteAction(mCurrentActionIndex) != CanExecute)
++mCurrentActionIndex;
}
if(mCurrentActionIndex < 0 || mCurrentActionIndex >= mScript->actionCount())
{
stopExecution();
return;
}
int nextLine = mCurrentActionIndex + 2;
if(nextLine > mScript->actionCount())
nextLine = -1;
QScriptValue script = mScriptEngine->globalObject().property("Script");
script.setProperty("nextLine", mScriptEngine->newVariant(QVariant(nextLine)));
script.setProperty("line", mCurrentActionIndex + 1, QScriptValue::ReadOnly);
ActionTools::ActionInstance *actionInstance = currentActionInstance();
const ActionTools::ExceptionActionInstancesHash &exceptionActionInstancesHash = actionInstance->exceptionActionInstances();
const ActionTools::ActionException::ExceptionActionInstance &exceptionAction = exceptionActionInstancesHash.value(ActionTools::ActionException::CodeErrorException);
mShowDebuggerOnCodeError = (exceptionAction.action() == ActionTools::ActionException::StopExecutionExceptionAction);
mExecutionWindow->setCurrentActionName(actionInstance->definition()->name());
mExecutionWindow->setCurrentActionColor(actionInstance->color());
connect(actionInstance, SIGNAL(executionEnded()), this, SLOT(actionExecutionEnded()));
connect(actionInstance, SIGNAL(executionException(int,QString)), this, SLOT(executionException(int,QString)));
connect(actionInstance, SIGNAL(disableAction(bool)), this, SLOT(disableAction(bool)));
connect(actionInstance, SIGNAL(showProgressDialog(QString,int)), this, SLOT(showProgressDialog(QString,int)));
connect(actionInstance, SIGNAL(updateProgressDialog(int)), this, SLOT(updateProgressDialog(int)));
connect(actionInstance, SIGNAL(updateProgressDialog(QString)), this, SLOT(updateProgressDialog(QString)));
connect(actionInstance, SIGNAL(hideProgressDialog()), this, SLOT(hideProgressDialog()));
connect(actionInstance, SIGNAL(consolePrint(QString)), this, SLOT(consolePrint(QString)));
connect(actionInstance, SIGNAL(consolePrintWarning(QString)), this, SLOT(consolePrintWarning(QString)));
connect(actionInstance, SIGNAL(consolePrintError(QString)), this, SLOT(consolePrintError(QString)));
mExecutionStatus = PrePause;
mExecutionTimer.start();
mExecutionTime.start();
if(currentActionInstance()->pauseBefore() + mPauseBefore > 0)
{
mExecutionWindow->setProgressEnabled(true);
mExecutionWindow->setProgressMinimum(0);
mExecutionWindow->setProgressMaximum(currentActionInstance()->pauseBefore() + mPauseBefore);
mExecutionWindow->setProgressValue(0);
}
else
mExecutionWindow->setProgressEnabled(false);
mExecutionEnded = true;
}
示例2: mimeData
QMimeData* ScriptModel::mimeData(const QModelIndexList &indexes) const
{
if(indexes.isEmpty())
return 0;
QMimeData *mimeDataPtr = new QMimeData();
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
QList<int> rowIdList;
for(const QModelIndex &index: indexes)
{
if(!index.isValid() || index.column() != ColumnLabel)
continue;
if(!rowIdList.contains(index.row()))
rowIdList << index.row();
}
std::sort(rowIdList.begin(), rowIdList.end(), qGreater<int>());
for(int row: rowIdList)
{
ActionTools::ActionInstance *actionInstance = mScript->actionAt(row);
if(!actionInstance)
continue;
stream << row;
stream << ActionTools::ActionInstanceBuffer(actionInstance->definition()->id(), *actionInstance);
}
mimeDataPtr->setData("application/actiona.action", encodedData);
return mimeDataPtr;
}
示例3: data
QVariant ScriptModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid())
return QVariant();
ActionTools::ActionInstance *actionInstance = mScript->actionAt(index.row());
if(!actionInstance)
return QVariant();
switch(role)
{
case ActionDataRole:
return QVariant::fromValue(*actionInstance);
case ActionIdRole:
return actionInstance->definition()->id();
case Qt::BackgroundRole:
{
const QColor &color = actionInstance->color();
if(color.isValid())
return QBrush(color);
return QBrush();
}
case Qt::FontRole:
{
if(!actionInstance->definition()->worksUnderThisOS())
{
QFont font = QApplication::font();
font.setItalic(true);
return font;
}
return QFont();
}
case Qt::ForegroundRole:
{
const QColor &color = actionInstance->color();
if(color.isValid())
{
if(color.lightness() < 128)
return QBrush(Qt::white);
else
return QBrush(Qt::black);
}
else
{
const QPalette &palette = QApplication::palette();
if(!actionInstance->isEnabled())
return QBrush(palette.color(QPalette::Disabled, QPalette::WindowText));
return QBrush();
}
}
}
switch(index.column())
{
case ColumnLabel:
switch(role)
{
case Qt::CheckStateRole:
return QVariant(actionInstance->isEnabled() ? Qt::Checked : Qt::Unchecked);
case Qt::DisplayRole:
{
QString labelString = actionInstance->label();
if(!labelString.isNull() && !labelString.isEmpty())
return labelString;
return QString("%1").arg(index.row() + 1, 3, 10, QChar('0'));
}
case Qt::EditRole:
return actionInstance->label();
}
break;
case ColumnActionName:
switch(role)
{
case Qt::ToolTipRole:
return tr("Double-clic to edit the action");
case Qt::DisplayRole:
return actionInstance->definition()->name();
case Qt::DecorationRole:
return QIcon(actionInstance->definition()->icon());
case Qt::TextAlignmentRole:
return Qt::AlignCenter;
}
break;
case ColumnComment:
switch(role)
{
case Qt::DisplayRole:
case Qt::EditRole:
return actionInstance->comment();
}
break;
}
//.........这里部分代码省略.........
示例4: executionException
void Executer::executionException(int exception,
const QString &message)
{
ActionTools::ActionInstance *actionInstance = currentActionInstance();
bool standardException = (exception >= 0 && exception < ActionTools::ActionException::ExceptionCount);
bool customException = false;
for(ActionTools::ActionException *actionException: actionInstance->definition()->exceptions())
{
if(actionException->id() == exception)
{
customException = true;
break;
}
}
if(!standardException && !customException)
{
mConsoleWidget->addDesignErrorLine(tr("Action design error: Invalid exception emitted (%1, line %2)")
.arg(actionInstance->definition()->name())
.arg(mCurrentActionIndex+1), ActionTools::ConsoleWidget::Error);
stopExecution();
return;
}
ActionTools::ActionException::ExceptionActionInstance exceptionActionInstance = actionInstance->exceptionActionInstance(static_cast<ActionTools::ActionException::Exception>(exception));
ActionTools::ConsoleWidget::Type exceptionType;
bool shouldStopExecution;
switch(exceptionActionInstance.action())
{
case ActionTools::ActionException::SkipExceptionAction:
exceptionType = ActionTools::ConsoleWidget::Information;
actionExecutionEnded();
shouldStopExecution = false;
break;
case ActionTools::ActionException::GotoLineExceptionAction:
{
exceptionType = ActionTools::ConsoleWidget::Information;
if(canExecuteAction(exceptionActionInstance.line()) != CanExecute)
{
ActionTools::ActionInstance *currentAction = mScript->actionAt(mCurrentActionIndex);
qint64 currentActionRuntimeId = -1;
if(currentAction)
currentActionRuntimeId = currentAction->runtimeId();
mConsoleWidget->addExceptionLine(tr("Invalid exception line: %1").arg(exceptionActionInstance.line()),
currentActionRuntimeId,
exception,
ActionTools::ConsoleWidget::Error);
shouldStopExecution = true;
}
else
{
QScriptValue script = mScriptEngine->globalObject().property("Script");
script.setProperty("nextLine", mScriptEngine->newVariant(QVariant(exceptionActionInstance.line())));
actionExecutionEnded();
shouldStopExecution = false;
}
}
break;
default:
exceptionType = ActionTools::ConsoleWidget::Error;
shouldStopExecution = true;
}
if(shouldStopExecution)
{
QString finalMessage = tr("Script line %1: ").arg(mCurrentActionIndex+1);
ActionTools::ActionInstance *currentAction = mScript->actionAt(mCurrentActionIndex);
qint64 currentActionRuntimeId = -1;
if(currentAction)
currentActionRuntimeId = currentAction->runtimeId();
mConsoleWidget->addActionLine(finalMessage + message,
currentActionRuntimeId,
mScriptEngine->globalObject().property("currentParameter").toString(),
mScriptEngine->globalObject().property("currentSubParameter").toString(),
mScriptAgent->currentLine(),
mScriptAgent->currentColumn(),
exceptionType);
stopExecution();
}
}
示例5: startExecution
//.........这里部分代码省略.........
QImage image;
if(!image.loadFromData(resource.data()))
{
mConsoleWidget->addResourceLine(tr("Invalid image resource"), key, ActionTools::ConsoleWidget::Error);
return false;
}
value = Code::Image::constructor(image, mScriptEngine);
}
break;
}
mScriptEngine->globalObject().setProperty(key, value, QScriptValue::ReadOnly | QScriptValue::Undeletable);
}
for(int actionIndex = 0; actionIndex < mScript->actionCount(); ++actionIndex)
{
ActionTools::ActionInstance *actionInstance = mScript->actionAt(actionIndex);
actionInstance->reset();
actionInstance->clearRuntimeParameters();
actionInstance->setupExecution(mScriptEngine, mScript, actionIndex);
mActionEnabled.append(true);
qint64 currentActionRuntimeId = -1;
if(actionInstance)
currentActionRuntimeId = actionInstance->runtimeId();
if(canExecuteAction(actionIndex) == CanExecute)
{
++mActiveActionsCount;
if(actionInstance->definition()->id() == "ActionBeginProcedure")
{
if(lastBeginProcedure != -1)
{
mConsoleWidget->addActionLine(tr("Invalid Begin procedure action, you have to end the previous procedure before starting another one"), currentActionRuntimeId, QString(), QString(), -1, -1, ActionTools::ConsoleWidget::Error);
return false;
}
lastBeginProcedure = actionIndex;
const ActionTools::SubParameter &nameParameter = actionInstance->subParameter("name", "value");
const QString &procedureName = nameParameter.value().toString();
if(procedureName.isEmpty())
{
mConsoleWidget->addActionLine(tr("A procedure name cannot be empty"), currentActionRuntimeId, QString(), QString(), -1, -1, ActionTools::ConsoleWidget::Error);
return false;
}
if(mScript->findProcedure(procedureName) != -1)
{
mConsoleWidget->addActionLine(tr("A procedure with the name \"%1\" has already been declared").arg(procedureName), currentActionRuntimeId, QString(), QString(), -1, -1, ActionTools::ConsoleWidget::Error);
return false;
}
mScript->addProcedure(procedureName, actionIndex);
}
else if(actionInstance->definition()->id() == "ActionEndProcedure")
{
if(lastBeginProcedure == -1)