本文整理汇总了C++中ActionList::at方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionList::at方法的具体用法?C++ ActionList::at怎么用?C++ ActionList::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionList
的用法示例。
在下文中一共展示了ActionList::at方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDeviceProfiles
void PreviewActionGroup::updateDeviceProfiles()
{
typedef QList<DeviceProfile> DeviceProfileList;
typedef QList<QAction *> ActionList;
const QDesignerSharedSettings settings(m_core);
const DeviceProfileList profiles = settings.deviceProfiles();
const ActionList al = actions();
// Separator?
const bool hasProfiles = !profiles.empty();
al.at(MaxDeviceActions)->setVisible(hasProfiles);
int index = 0;
if (hasProfiles) {
// Make actions visible
const int maxIndex = qMin(static_cast<int>(MaxDeviceActions), profiles.size());
for (; index < maxIndex; index++) {
const QString name = profiles.at(index).name();
al.at(index)->setText(name);
al.at(index)->setVisible(true);
}
}
// Hide rest
for ( ; index < MaxDeviceActions; index++)
al.at(index)->setVisible(false);
}
示例2: clear
void clear()
{
for(unsigned int k=0; k<actions.size();k++)
{
ActionItem *ret=actions.at(k);
delete ret;
}
actions.clear();
}
示例3:
ActionItem *pop()
{
if (actions.empty())
return 0;
ActionItem *ret=actions.at(0);
actions.pop_front();
return ret;
}
示例4: startDrag
void ToolBarEventFilter::startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers)
{
const int index = actionIndexAt(m_toolBar, pos, m_toolBar->orientation());
if (index == - 1)
return;
const ActionList actions = m_toolBar->actions();
QAction *action = actions.at(index);
QDesignerFormWindowInterface *fw = formWindow();
const Qt::DropAction dropAction = (modifiers & Qt::ControlModifier) ? Qt::CopyAction : Qt::MoveAction;
if (dropAction == Qt::MoveAction) {
RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw);
const int nextIndex = index + 1;
QAction *nextAction = nextIndex < actions.size() ? actions.at(nextIndex) : 0;
cmd->init(m_toolBar, action, nextAction);
fw->commandHistory()->push(cmd);
}
QDrag *drag = new QDrag(m_toolBar);
drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap( action));
drag->setMimeData(new ActionRepositoryMimeData(action, dropAction));
if (drag->start(dropAction) == Qt::IgnoreAction) {
hideDragIndicator();
if (dropAction == Qt::MoveAction) {
const ActionList currentActions = m_toolBar->actions();
QAction *previous = 0;
if (index >= 0 && index < currentActions.size())
previous = currentActions.at(index);
InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw);
cmd->init(m_toolBar, action, previous);
fw->commandHistory()->push(cmd);
}
}
}
示例5: handleContextMenuEvent
bool ToolBarEventFilter::handleContextMenuEvent(QContextMenuEvent * event )
{
event->accept();
const QPoint globalPos = event->globalPos();
const int index = actionIndexAt(m_toolBar, m_toolBar->mapFromGlobal(globalPos), m_toolBar->orientation());
const ActionList actions = m_toolBar->actions();
QAction *action = index != -1 ?actions.at(index) : 0;
QVariant itemData;
QMenu menu(0);
// Insert before
if (action && index != 0 && !action->isSeparator()) {
QAction *newSeperatorAct = menu.addAction(tr("Insert Separator before '%1'").arg(action->objectName()));
qVariantSetValue(itemData, action);
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
}
// Append separator
if (actions.empty() || !actions.back()->isSeparator()) {
QAction *newSeperatorAct = menu.addAction(tr("Append Separator"));
qVariantSetValue(itemData, static_cast<QAction*>(0));
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
}
// Remove
if (!menu.actions().empty())
menu.addSeparator();
// Remove
if (action) {
QAction *a = menu.addAction(tr("Remove action '%1'").arg(action->objectName()));
qVariantSetValue(itemData, action);
a->setData(itemData);
connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction()));
}
QAction *remove_toolbar = menu.addAction(tr("Remove Toolbar '%1'").arg(m_toolBar->objectName()));
connect(remove_toolbar, SIGNAL(triggered()), this, SLOT(slotRemoveToolBar()));
menu.exec(globalPos);
return true;
}
示例6: handleDropEvent
bool ToolBarEventFilter::handleDropEvent(QDropEvent *event)
{
const ActionRepositoryMimeData *d = qobject_cast<const ActionRepositoryMimeData*>(event->mimeData());
if (!d)
return false;
if (d->actionList().isEmpty()) {
event->ignore();
hideDragIndicator();
return true;
}
QAction *action = d->actionList().first();
const ActionList actions = m_toolBar->actions();
if (!action || actions.contains(action)) {
event->ignore();
hideDragIndicator();
return true;
}
// Try to find action to 'insert before'. Click on action or in free area, else ignore.
QAction *beforeAction = 0;
const QPoint pos = event->pos();
const int index = actionIndexAt(m_toolBar, pos, m_toolBar->orientation());
if (index != -1) {
beforeAction = actions.at(index);
} else {
if (!freeArea(m_toolBar).contains(pos)) {
event->ignore();
hideDragIndicator();
return true;
}
}
event->acceptProposedAction();
QDesignerFormWindowInterface *fw = formWindow();
InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw);
cmd->init(m_toolBar, action, beforeAction);
fw->commandHistory()->push(cmd);
hideDragIndicator();
return true;
}
示例7: contextMenuActions
ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos)
{
ActionList rc;
const int index = actionIndexAt(m_toolBar, m_toolBar->mapFromGlobal(globalPos), m_toolBar->orientation());
const ActionList actions = m_toolBar->actions();
QAction *action = index != -1 ?actions.at(index) : 0;
QVariant itemData;
// Insert before
if (action && index != 0 && !action->isSeparator()) {
QAction *newSeperatorAct = new QAction(tr("Insert Separator before '%1'").arg(action->objectName()), 0);
itemData.setValue(action);
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
rc.push_back(newSeperatorAct);
}
// Append separator
if (actions.empty() || !actions.back()->isSeparator()) {
QAction *newSeperatorAct = new QAction(tr("Append Separator"), 0);
itemData.setValue(static_cast<QAction*>(0));
newSeperatorAct->setData(itemData);
connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator()));
rc.push_back(newSeperatorAct);
}
// Promotion
if (!m_promotionTaskMenu)
m_promotionTaskMenu = new PromotionTaskMenu(m_toolBar, PromotionTaskMenu::ModeSingleWidget, this);
m_promotionTaskMenu->addActions(formWindow(), PromotionTaskMenu::LeadingSeparator|PromotionTaskMenu::TrailingSeparator, rc);
// Remove
if (action) {
QAction *a = new QAction(tr("Remove action '%1'").arg(action->objectName()), 0);
itemData.setValue(action);
a->setData(itemData);
connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction()));
rc.push_back(a);
}
QAction *remove_toolbar = new QAction(tr("Remove Toolbar '%1'").arg(m_toolBar->objectName()), 0);
connect(remove_toolbar, SIGNAL(triggered()), this, SLOT(slotRemoveToolBar()));
rc.push_back(remove_toolbar);
return rc;
}
示例8: slotRemoveSelectedAction
void ToolBarEventFilter::slotRemoveSelectedAction()
{
QAction *action = qobject_cast<QAction*>(sender());
if (!action)
return;
QAction *a = qvariant_cast<QAction*>(action->data());
Q_ASSERT(a != 0);
QDesignerFormWindowInterface *fw = formWindow();
Q_ASSERT(fw);
const ActionList actions = m_toolBar->actions();
const int pos = actions.indexOf(a);
QAction *action_before = 0;
if (pos != -1 && actions.count() > pos + 1)
action_before = actions.at(pos + 1);
RemoveActionFromCommand *cmd = new RemoveActionFromCommand(fw);
cmd->init(m_toolBar, a, action_before);
fw->commandHistory()->push(cmd);
}