Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
void PromotionTaskMenu::addActions(QDesignerFormWindowInterface *fw, unsigned flags,
                                   ActionList &actionList)
{
    Q_ASSERT(m_widget);
    const int previousSize = actionList.size();
    const PromotionState promotionState = createPromotionActions(fw);

    // Promotion candidates/demote
    actionList += m_promotionActions;

    // Edit action depending on context
    switch (promotionState) {
    case  CanPromote:
        actionList += m_EditPromoteToAction;
        break;
    case CanDemote:
        if (!(flags & SuppressGlobalEdit))
            actionList += m_globalEditAction;
        if (!languageExtension(fw->core())) {
            actionList += separatorAction(this);
            actionList += m_EditSignalsSlotsAction;
        }
        break;
    default:
        if (!(flags & SuppressGlobalEdit))
            actionList += m_globalEditAction;
        break;
    }
    // Add separators if required
    if (actionList.size() > previousSize) {
        if (flags &  LeadingSeparator)
            actionList.insert(previousSize, separatorAction(this));
        if (flags & TrailingSeparator)
            actionList += separatorAction(this);
    }
}