Example #1
0
ActionDesc *ServiceDesc::actionAt(NPT_Ordinal index) const
{
	if (index < actionCount()) {
		return *m_private->m_actionList.GetItem(index);
	}
	return NULL;
}
Example #2
0
QPopupMenu *KAccelBase::createPopupMenu(QWidget *pParent, const KKeySequence &seq)
{
    KShortcutMenu *pMenu = new KShortcutMenu(pParent, &actions(), seq);

    bool bActionInserted = false;
    bool bInsertSeparator = false;
    for(uint i = 0; i < actionCount(); i++)
    {
        const KAccelAction *pAction = actions().actionPtr(i);

        if(!pAction->isEnabled())
            continue;

        // If an action has already been inserted into the menu
        //  and we have a label instead of an action here,
        //  then indicate that we should insert a separator before the next menu entry.
        if(bActionInserted && !pAction->isConfigurable() && pAction->name().contains(':'))
            bInsertSeparator = true;

        for(uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++)
        {
            const KKeySequence &seqAction = pAction->shortcut().seq(iSeq);
            if(seqAction.startsWith(seq))
            {
                if(bInsertSeparator)
                {
                    pMenu->insertSeparator();
                    bInsertSeparator = false;
                }

                pMenu->insertAction(i, seqAction);

                // kdDebug(125) << "sLabel = " << sLabel << ", seq = " << (QString)seqMenu.qt() << ", i = " << i << endl;
                // kdDebug(125) << "pMenu->accel(" << i << ") = " << (QString)pMenu->accel(i) << endl;
                bActionInserted = true;
                break;
            }
        }
    }
    pMenu->updateShortcuts();
    return pMenu;
}