本文整理汇总了C++中actiontools::ActionInstance::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionInstance::isEnabled方法的具体用法?C++ ActionInstance::isEnabled怎么用?C++ ActionInstance::isEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actiontools::ActionInstance
的用法示例。
在下文中一共展示了ActionInstance::isEnabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canExecuteAction
Executer::ExecuteActionResult Executer::canExecuteAction(int index) const
{
if(index < 0 || index >= mScript->actionCount())
return IncorrectLine;
ActionTools::ActionInstance *actionInstance = mScript->actionAt(index);
if(!actionInstance)
return InvalidAction;
if(!mActionEnabled[index] || !actionInstance->isEnabled())
return DisabledAction;
if(mExecuteOnlySelection && !actionInstance->isSelected())
return UnselectedAction;
return CanExecute;
}
示例2: QUndoCommand
//ChangeEnabledCommand
ChangeEnabledCommand::ChangeEnabledCommand(const QList<int> &rows, bool enabled, ScriptModel *model, ScriptProxyModel *proxyModel)
: QUndoCommand(),
mModel(model),
mProxyModel(proxyModel),
mRows(rows),
mNew(enabled)
{
for(int row: mRows)
{
ActionTools::ActionInstance *actionInstance = mModel->mScript->actionAt(row);
if(!actionInstance)
continue;
mOld << actionInstance->isEnabled();
}
setText(QObject::tr("Change the enabled status"));
}
示例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;
}
//.........这里部分代码省略.........