void ZoomMenu::addActions(QMenu *m) { const ActionList za = m_menuActions->actions(); const ActionList::const_iterator cend = za.constEnd(); for (ActionList::const_iterator it = za.constBegin(); it != cend; ++it) { m->addAction(*it); if (zoomOf(*it) == 100) m->addSeparator(); } }
void ZoomMenu::setZoom(int percent) { const ActionList za = m_menuActions->actions(); const ActionList::const_iterator cend = za.constEnd(); for (ActionList::const_iterator it = za.constBegin(); it != cend; ++it) if (zoomOf(*it) == percent) { (*it)->setChecked(true); return; } }
//Uses A* search to find optimal sequence of actions to go from current location to desired location //Once sequence is found, the actions are executed. //Returns: // ACT_GOING: still executing sequence of actions // ACT_SUCCESS: finished executing sequence of actions // ACT_ERROR: search provided no solution to the problem // other: Flags to indicate something went wrong ActionResult Brain::GoToLocation(byte end_x, byte end_y, int desired_direction /*= -1*/) { static bool is_searching = true; static ActionList action_list; //Perform the search and convert it to a usable list if(is_searching) { byte_action_list byte_actions = SearchAlgorithm::AStarGoAToB(end_x, end_y, robot_state_, board_state_, desired_direction); for(byte_action action : byte_actions) { SearchAlgorithm::PrintByteActionString(action); } action_list = ByteActionListConverter(byte_actions); is_searching = false; //If the action list is empty after search has been completed, no good! //This means our search found no solution; return error if(action_list.IsEmpty()) { Serial.println(end_x); Serial.println(end_y); robot_state_.Print(); board_state_.Print(); is_searching = true; //reset search for next time return ACT_ERROR; } } //If the list is empty, we've completed our execution of the actions if(action_list.IsEmpty()) { is_searching = true; //reset search for next time return ACT_SUCCESS; } //Get current action and execute it Action* curr_action = action_list.GetCurrentAction(); // curr_action->Print(); ActionResult result = curr_action->Run(); //From the result of the action, return things to the calling function switch(result) { case ACT_GOING: //Continue on this action return ACT_GOING; break; case ACT_SUCCESS: //Good! Action completed, Move on to the next step action_list.MoveToNextAction(); return ACT_GOING; break; default: //Error; return error flags and let calling function deal with it. Do not continue with these actions is_searching = true; //reset search for next time return result; break; } }
RobotInterface::ActionList RobotInterface::XMLReader::Private::readActionsTag(TiXmlElement *actionsElem) { const std::string &valueStr = actionsElem->ValueStr(); if (valueStr.compare("actions") != 0) { SYNTAX_ERROR(actionsElem->Row()) << "Expected \"actions\". Found" << valueStr; } std::string filename; if (actionsElem->QueryStringAttribute("file", &filename) == TIXML_SUCCESS) { // yDebug() << "Found actions file [" << filename << "]"; filename=rf.findFileByName(filename); return readActionsFile(filename); } std::string robotName; if (actionsElem->QueryStringAttribute("robot", &robotName) != TIXML_SUCCESS) { SYNTAX_WARNING(actionsElem->Row()) << "\"actions\" element should contain the \"robot\" attribute"; } if (robotName != robot.name()) { SYNTAX_WARNING(actionsElem->Row()) << "Trying to import a file for the wrong robot. Found" << robotName << "instead of" << robot.name(); } unsigned int build; #if TINYXML_UNSIGNED_INT_BUG if (actionsElem->QueryUnsignedAttribute("build", &build()) != TIXML_SUCCESS) { // No build attribute. Assuming build="0" SYNTAX_WARNING(actionsElem->Row()) << "\"actions\" element should contain the \"build\" attribute [unsigned int]. Assuming 0"; } #else int tmp; if (actionsElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) { // No build attribute. Assuming build="0" SYNTAX_WARNING(actionsElem->Row()) << "\"actions\" element should contain the \"build\" attribute [unsigned int]. Assuming 0"; tmp = 0; } build = (unsigned)tmp; #endif if (build != robot.build()) { SYNTAX_WARNING(actionsElem->Row()) << "Import a file for a different robot build. Found" << build << "instead of" << robot.build(); } ActionList actions; for (TiXmlElement* childElem = actionsElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) { ActionList childActions = readActions(childElem); for (ActionList::const_iterator it = childActions.begin(); it != childActions.end(); ++it) { actions.push_back(*it); } } return actions; }
void ActionEditor::deleteActions(QDesignerFormWindowInterface *fw, const ActionList &actions) { // We need a macro even in the case of single action because the commands might cause the // scheduling of other commands (signal slots connections) const QString description = actions.size() == 1 ? tr("Remove action '%1'").arg(actions.front()->objectName()) : tr("Remove actions"); fw->beginCommand(description); foreach(QAction *action, actions) { RemoveActionCommand *cmd = new RemoveActionCommand(fw); cmd->init(action); fw->commandHistory()->push(cmd); }
void SimpleController::flood(Channel *channel, const PacketIn *msg) { log_debug("flood"); ActionList actions; actions.add(AT_OUTPUT{OFPP_FLOOD}); PacketOutBuilder packetOut; packetOut.setBufferId(msg->bufferId()); packetOut.setInPort(msg->inPort()); packetOut.setActions(actions); packetOut.send(channel); }
//ActionCallback World::pushActionCallback(){ void World::pushActionCallback(){ BoundingBox *box = character->getBoundingBox(); EntityList *elist = new EntityList(); int nEntities = currScene->getEntitiesInBox(box, elist); for(EntityList::iterator i=elist->begin(); i!=elist->end(); i++){ ActionList actionList = (*i)->getActionList(); for(ActionList::iterator j = actionList.begin(); j!=actionList.end(); j++){ if((*j)->type == ACTION_PUSH){ (*j)->react(); } } } }
void World::pickupActionCallback(){ EntityList *elist = new EntityList(); BoundingBox *box = character->getFeetBoundingBox(); int nEntities = currScene->getEntitiesInBox(box, elist); for(EntityList::iterator i=elist->begin(); i!=elist->end(); i++){ ActionList actionList = (*i)->getActionList(); for(ActionList::iterator j = actionList.begin(); j!=actionList.end(); j++){ if((*j)->type == ACTION_PICKUP && (*i)->getAttribute(ENTITY_PICKUPABLE)){ (*j)->react(); } } } }
ActionList CorrectPlayer::GetActions(Hand hand, int dealer, Shoe& shoe, int betSize, bool allBusted, int numBusted) { this->allBusted = allBusted; this->numBusted = numBusted; ActionList actions; actions.Add(Action(ActionType::Stand, Stand(hand, dealer, shoe))); actions.Add(Action(ActionType::Hit, Hit(hand, dealer, shoe))); actions.Add(Action(ActionType::Double, Double(hand, dealer, shoe, betSize))); actions.Add(Action(ActionType::Surrender, SurrenderEV())); return actions; }
bool CKeyBindings::RemoveCommandFromList(ActionList& al, const std::string& command) { bool success = false; ActionList::iterator it = al.begin(); while (it != al.end()) { if (it->command == command) { it = al.erase(it); success = true; } else { ++it; } } return success; }
ActionList ActionsWidget::actionList() const { // return a copy of our action list ActionList list; foreach( ClipAction* action, m_actionList ) { if ( !action ) { qCDebug(KLIPPER_LOG) << "action is null"; continue; } list.append( new ClipAction( *action ) ); } return list; }
bool CKeyBindings::RemoveCommandFromList(ActionList& al, const string& command) { bool success = false; for (int i = 0; i < (int)al.size(); ++i) { if (al[i].command == command) { success = true; for (int j = (i + 1); j < (int)al.size(); ++j) { al[j - 1] = al[j]; } al.resize(al.size() - 1); } } return success; }
/** \fn KeyBindings::GetKeyContexts(const QString &) const * \brief Get the context names in which a key is bound. * \return A list of context names in which a key is bound. */ QStringList KeyBindings::GetKeyContexts(const QString &key) const { ActionList actions = m_actionSet.GetActions(key); QStringList contexts; for (int i = 0; i < actions.size(); i++) { QString context = actions[i].GetContext(); if (!contexts.contains(context)) contexts.push_back(context); } return contexts; }
bool ToolBarEventFilter::handleContextMenuEvent(QContextMenuEvent * event ) { event->accept(); const QPoint globalPos = event->globalPos(); const ActionList al = contextMenuActions(event->globalPos()); QMenu menu(0); const ActionList::const_iterator acend = al.constEnd(); for (ActionList::const_iterator it = al.constBegin(); it != acend; ++it) menu.addAction(*it); menu.exec(globalPos); return true; }
void PrintDeviceInfo(Device *dev, int indent) { string indentStr; GetIndentString(indent, indentStr); const char *devName = dev->getFriendlyName(); cout << indentStr << devName << endl; int i, n, j; ServiceList *serviceList = dev->getServiceList(); int serviceCnt = serviceList->size(); for (n=0; n<serviceCnt; n++) { Service *service = serviceList->getService(n); cout << indentStr << " service[" << n << "] = "<< service->getServiceType() << endl; ActionList *actionList = service->getActionList(); int actionCnt = actionList->size(); for (i=0; i<actionCnt; i++) { Action *action = actionList->getAction(i); cout << indentStr << " action[" << i << "] = "<< action->getName() << endl; ArgumentList *argList = action->getArgumentList(); int argCnt = argList->size(); for (j=0; j<argCnt; j++) { Argument *arg = argList->getArgument(j); cout << indentStr << " arg[" << j << "] = " << arg->getName() << "(" << arg->getDirection() << ")"; StateVariable *stateVar = arg->getRelatedStateVariable(); if (stateVar != NULL) cout << " - " << stateVar->getName(); cout << endl; } } ServiceStateTable *stateTable = service->getServiceStateTable(); int varCnt = stateTable->size(); for (i=0; i<varCnt; i++) { StateVariable *stateVar = stateTable->getStateVariable(i); cout << indentStr << " stateVar[" << i << "] = " << stateVar->getName() << endl; AllowedValueList *valueList = stateVar->getAllowedValueList(); int valueListCnt = valueList->size(); if (0 < valueListCnt) { for (j=0; j<valueListCnt; j++) cout << indentStr << " AllowedValueList[" << j << "] = " << valueList->getAllowedValue(j) << endl; } AllowedValueRange *valueRange = stateVar->getAllowedValueRange(); if (valueRange != NULL) { cout << indentStr << " AllowedRange[minimum] = " << valueRange->getMinimum() << endl; cout << indentStr << " AllowedRange[maximum] = " << valueRange->getMaximum() << endl; cout << indentStr << " AllowedRange[step] = " << valueRange->getStep() << endl; } } } }
double NetworkConstantModel::next_occuring_event(double /*now*/) { NetworkConstantAction *action = nullptr; double min = -1.0; ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { action = static_cast<NetworkConstantAction*>(&*it); if (action->latency_ > 0 && (min < 0 || action->latency_ < min)) min = action->latency_; } return min; }
const CKeyBindings::ActionList& CKeyBindings::GetActionList(const CKeyChain& kc) const { static ActionList out; //FIXME switch to thread_local when all buildbots are using >=gcc4.7 out.clear(); if (kc.empty()) return out; const CKeyBindings::ActionList& al = GetActionList(kc.back()); for (const Action& action: al) { if (kc.fit(action.keyChain)) out.push_back(action); } return out; }
const CKeyBindings::ActionList& CKeyBindings::GetActionList(const CKeySet& ks) const { static const ActionList empty; const ActionList* alPtr = ∅ if (ks.AnyMod()) { KeyMap::const_iterator it = bindings.find(ks); if (it != bindings.end()) { alPtr = &(it->second); } } else { // have to check for an AnyMod keyset as well as the normal one CKeySet anyMod = ks; anyMod.SetAnyBit(); KeyMap::const_iterator nit = bindings.find(ks); KeyMap::const_iterator ait = bindings.find(anyMod); const bool haveNormal = (nit != bindings.end()); const bool haveAnyMod = (ait != bindings.end()); if (haveNormal && !haveAnyMod) { alPtr = &(nit->second); } else if (!haveNormal && haveAnyMod) { alPtr = &(ait->second); } else if (haveNormal && haveAnyMod) { // combine the two lists (normal first) static ActionList merged; //FIXME switch to thread_local when all buildbots are using >=gcc4.7 merged = nit->second; merged.insert(merged.end(), ait->second.begin(), ait->second.end()); alPtr = &merged; } } if (debugEnabled) { LOG("GetActions: hex=0x%02X acii=\"%s\":", ks.Key(), ks.GetString(false).c_str()); if (alPtr != &empty) { int i = 1; for (const auto& a: *alPtr) { LOG(" %i. action=\"%s\" rawline=\"%s\" shortcut=\"%s\"", i++, a.command.c_str(), a.rawline.c_str(), a.boundWith.c_str()); } } else { LOG(" EMPTY"); } } return *alPtr; }
bool QDesignerMenuBar::handleContextMenuEvent(QWidget *, QContextMenuEvent *event) { event->accept(); m_currentIndex = actionIndexAt(this, mapFromGlobal(event->globalPos()), Qt::Horizontal); update(); QMenu menu; const ActionList al = contextMenuActions(); const ActionList::const_iterator acend = al.constEnd(); for (ActionList::const_iterator it = al.constBegin(); it != acend; ++it) menu.addAction(*it); menu.exec(event->globalPos()); return true; }
/******************************************************************************************** > BOOL OpNudge::DoesActionListHideNodes(OpNudge * pOp) Author: Simon_Knight (Xara Group Ltd) <*****@*****.**> Created: 27/7/00 Inputs: ptr to the (nudge) operation Outputs: - Returns: TRUE if the action list for the op does a HideNodesAction Purpose: To disallow the merging of nudge operations if a HideNodesAction was added to this nudge op, as this wouldn't then undo correctly. Errors: - SeeAlso: - ********************************************************************************************/ BOOL OpNudge::DoesActionListHideNodes(Operation * pOp) { ActionList * pActions = pOp->GetUndoActionList(); ListItem* CurrentAction = pActions->GetHead(); while (CurrentAction != NULL) // For each action in the list { if (IS_A(CurrentAction, HideNodeAction)) return TRUE; // Get next action CurrentAction = pActions->GetNext(CurrentAction); } return FALSE; }
void PsiToolBar::initialize( QString base, bool createUniqueActions ) { d->base = base; d->uniqueActions.clear(); // PsiOptions::instance()->getOption(base + ".").toString() // setHorizontallyStretchable(PsiOptions::instance()->getOption(base + ".stretchable").toBool()); // setVerticallyStretchable(PsiOptions::instance()->getOption(base + ".stretchable").toBool()); setMovable (!PsiOptions::instance()->getOption(base + ".locked").toBool()); if ( d->psi ) { ActionList actions = d->psi->actionList()->suitableActions( d->type ); QStringList keys = PsiOptions::instance()->getOption(base + ".actions").toStringList(); for (int j = 0; j < keys.size(); j++) { IconAction *action = actions.action( keys[j] ); if ( action && action->isSeparator() ) { addSeparator(); } else if ( action ) { if ( createUniqueActions ) { action = action->copy(); d->uniqueActions.append( action ); } action->addTo( this ); emit registerAction( action ); } else { qWarning("PsiToolBar::initialize(): action %s not found!", keys[j].latin1()); } } } else { qWarning("PsiToolBar::initialize(): psi is NULL!"); } if (PsiOptions::instance()->getOption(base + ".visible").toBool()) { show(); } else { hide(); } }
/********* * Model * *********/ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) { CpuAction *action; while ((xbt_heap_size(getActionHeap()) > 0) && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) { action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap())); XBT_CDEBUG(surf_kernel, "Something happened to action %p", action); if (TRACE_is_enabled()) { Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0))); TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(), lmm_variable_getvalue(action->getVariable()), action->getLastUpdate(), now - action->getLastUpdate()); } action->finish(); XBT_CDEBUG(surf_kernel, "Action %p finished", action); /* set the remains to 0 due to precision problems when updating the remaining amount */ action->setRemains(0); action->setState(SURF_ACTION_DONE); action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped } if (TRACE_is_enabled()) { //defining the last timestamp that we can safely dump to trace file //without losing the event ascending order (considering all CPU's) double smaller = -1; ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { action = static_cast<CpuAction*>(&*it); if (smaller < 0) { smaller = action->getLastUpdate(); continue; } if (action->getLastUpdate() < smaller) { smaller = action->getLastUpdate(); } } if (smaller > 0) { TRACE_last_timestamp_to_dump = smaller; } } return; }
ToolBarManager::ToolBarManager(QMainWindow *configureableMainWindow, QWidget *parent, QMenu *toolBarMenu, const QDesignerActions *actions, const QList<QToolBar *> &toolbars, const QList<QDesignerToolWindow*> &toolWindows) : QObject(parent), m_configureableMainWindow(configureableMainWindow), m_parent(parent), m_toolBarMenu(toolBarMenu), m_manager(new QtToolBarManager(this)), m_configureAction(new QAction(tr("Configure Toolbars..."), this)), m_toolbars(toolbars) { m_configureAction->setMenuRole(QAction::NoRole); m_configureAction->setObjectName(QLatin1String("__qt_configure_tool_bars_action")); connect(m_configureAction, SIGNAL(triggered()), this, SLOT(configureToolBars())); m_manager->setMainWindow(configureableMainWindow); foreach(QToolBar *tb, m_toolbars) { const QString title = tb->windowTitle(); m_manager->addToolBar(tb, title); addActionsToToolBarManager(tb->actions(), title, m_manager); } addActionsToToolBarManager(actions->windowActions()->actions(), tr("Window"), m_manager); addActionsToToolBarManager(actions->helpActions()->actions(), tr("Help"), m_manager); // Filter out the device profile preview actions which have int data(). ActionList previewActions = actions->styleActions()->actions(); ActionList::iterator it = previewActions.begin(); for ( ; (*it)->isSeparator() || (*it)->data().type() == QVariant::Int; ++it) ; previewActions.erase(previewActions.begin(), it); addActionsToToolBarManager(previewActions, tr("Style"), m_manager); const QString dockTitle = tr("Dock views"); foreach (QDesignerToolWindow *tw, toolWindows) { if (QAction *action = tw->action()) m_manager->addAction(action, dockTitle); } m_manager->addAction(m_configureAction, tr("Toolbars")); updateToolBarMenu(); }
RobotInterface::ActionList RobotInterface::XMLReader::Private::readActions(TiXmlElement *actionsElem) { const std::string &valueStr = actionsElem->ValueStr(); if (valueStr.compare("action") != 0 && valueStr.compare("actions") != 0) { SYNTAX_ERROR(actionsElem->Row()) << "Expected \"action\" or \"actions\". Found" << valueStr; } if (valueStr.compare("action") == 0) { ActionList actionList; actionList.push_back(readActionTag(actionsElem)); return actionList; } // "actions" return readActionsTag(actionsElem); }
ActionList DispatcherPrivate::getContainers(const QString &ns) const { ActionList ret; if (ns != QLatin1String("/")) { int pos = ns.size(); // qDebug() << pos << ns.mid(0, pos); while (pos > 0) { // qDebug() << pos << ns.mid(0, pos); ret.append(actionContainer.value(ns.mid(0, pos))); pos = ns.lastIndexOf(QLatin1Char('/'), pos - 1); } } // qDebug() << actionContainer.size() << rootActions; ret.append(rootActions); return ret; }
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; }
PathAction* DebugMenu::CreateOrFindPaths(std::vector<String>& paths, PathAction* action) { if (paths.empty()) return action; String name = paths.front(); paths.erase(paths.begin()); ActionList* actionList = action ? &action->actionList : &m_ActionList; for (IAction* a : *actionList) { if (a->type == IAction::Type::PATH && a->name == name) return CreateOrFindPaths(paths, (PathAction*)a); } PathAction* pathAction = spnew PathAction(name, action); actionList->push_back(pathAction); return CreateOrFindPaths(paths, pathAction); }
char GameFlow::GetUserInput(ActionList actions) { char c; c=toupper(_getch()); while(!actions.IsValidAction(c)) { c=toupper(_getch()); } return(c); }
// Create a MDI subwindow for the form. QMdiSubWindow *DockedMainWindow::createMdiSubWindow(QWidget *fw, Qt::WindowFlags f, const QKeySequence &designerCloseActionShortCut) { QMdiSubWindow *rc = mdiArea()->addSubWindow(fw, f); // Make action shortcuts respond only if focused to avoid conflicts with // designer menu actions if (designerCloseActionShortCut == QKeySequence(QKeySequence::Close)) { const ActionList systemMenuActions = rc->systemMenu()->actions(); if (!systemMenuActions.empty()) { const ActionList::const_iterator cend = systemMenuActions.constEnd(); for (ActionList::const_iterator it = systemMenuActions.constBegin(); it != cend; ++it) { if ( (*it)->shortcut() == designerCloseActionShortCut) { (*it)->setShortcutContext(Qt::WidgetShortcut); break; } } } } return rc; }
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; }