本文整理汇总了C++中actiontools::ActionInstance::copyActionDataFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionInstance::copyActionDataFrom方法的具体用法?C++ ActionInstance::copyActionDataFrom怎么用?C++ ActionInstance::copyActionDataFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actiontools::ActionInstance
的用法示例。
在下文中一共展示了ActionInstance::copyActionDataFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setData
bool ScriptModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if(!index.isValid())
return false;
if(role == ActionIdRole)
{
mScript->setAction(index.row(), mActionFactory->newActionInstance(value.toString()));
emit dataChanged(index, index);
emit scriptEdited();
return true;
}
ActionTools::ActionInstance *actionInstance = mScript->actionAt(index.row());
if(!actionInstance)
return false;
if(role == ActionDataRole)
{
actionInstance->copyActionDataFrom(value.value<ActionTools::ActionInstance>());
emit dataChanged(index, index);
emit scriptEdited();
return true;
}
if(index.column() == ColumnLabel)
{
switch(role)
{
case Qt::CheckStateRole:
mUndoStack->push(new ChangeEnabledCommand(QList<int>() << index.row(), value.toBool(), this));
emit scriptEdited();
return true;
case Qt::EditRole:
QString lineNumber(QString("%1").arg(index.row() + 1, 3, 10, QChar('0')));
QString labelString(value.toString());
QString finalValue;
if(!labelString.isEmpty() && lineNumber != labelString)
{
int labelLine = mScript->labelLine(labelString);
if(labelLine == -1 || labelLine == index.row())
finalValue = labelString;
}
if(labelString == actionInstance->label() || labelString == lineNumber)
return true;
mUndoStack->push(new ChangeLabelCommand(finalValue, index.row(), this));
emit scriptEdited();
return true;
}
}
else if(index.column() == ColumnComment)
{
if(value.toString() == actionInstance->comment())
return true;
mUndoStack->push(new ChangeCommentCommand(value.toString(), index.row(), this));
emit scriptEdited();
return true;
}
return false;
}