Пример #1
0
ShortcutsModel::ShortcutsModel(const QHash<QString, ActionCollection *> &actionCollections, QObject *parent)
  : QAbstractItemModel(parent),
  _changedCount(0)
{
  _showIcons=!QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus);
  for(int r = 0; r < actionCollections.values().count(); r++) {
    ActionCollection *coll = actionCollections.values().at(r);
    Item *item = new Item();
    item->row = r;
    item->collection = coll;
    for(int i = 0; i < coll->actions().count(); i++) {
      Action *action = qobject_cast<Action *>(coll->actions().at(i));
      if(!action)
        continue;
      Item *actionItem = new Item();
      actionItem->parentItem = item;
      actionItem->row = i;
      actionItem->collection = coll;
      actionItem->action = action;
      actionItem->shortcut = action->shortcut();
      item->actionItems.append(actionItem);
    }
    _categoryItems.append(item);
  }
}
Пример #2
0
ShortcutsModel::ShortcutsModel(const QHash<QString, ActionCollection*>& actionCollections, QObject* parent)
    : QAbstractItemModel(parent)
    , _changedCount(0)
{
    for (int r = 0; r < actionCollections.values().count(); r++) {
        ActionCollection* coll = actionCollections.values().at(r);
        auto* item = new Item();
        item->row = r;
        item->collection = coll;
        for (int i = 0; i < coll->actions().count(); i++) {
            auto* action = qobject_cast<Action*>(coll->actions().at(i));
            if (!action)
                continue;
            auto* actionItem = new Item();
            actionItem->parentItem = item;
            actionItem->row = i;
            actionItem->collection = coll;
            actionItem->action = action;
            actionItem->shortcut = action->shortcut();
            item->actionItems.append(actionItem);
        }
        _categoryItems.append(item);
    }
}