+ // it seems that only one item can be selected, but I am
+ // removing all selected items anyway.
+ QList<QTreeWidgetItem*> items = shortcutsTW->selectedItems();
+ for (int i = 0; i < items.size(); ++i) {
+ string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
+ string lfun = fromqstr(items[i]->text(0));
+ FuncRequest func = lyxaction.lookupFunc(lfun);
+ item_type tag = static_cast<item_type>(items[i]->data(0, Qt::UserRole).toInt());
+
+ switch (tag) {
+ case System: {
+ // for system bind, we do not touch the item
+ // but add an user unbind item
+ user_unbind_.bind(shortcut, func);
+ setItemType(items[i], UserUnbind);
+ removePB->setText(toqstr("Restore"));
+ break;
+ }
+ case UserBind: {
+ // for user_bind, we remove this bind
+ QTreeWidgetItem * parent = items[i]->parent();
+ int itemIdx = parent->indexOfChild(items[i]);
+ parent->takeChild(itemIdx);
+ if (itemIdx > 0)
+ shortcutsTW->scrollToItem(parent->child(itemIdx - 1));
+ else
+ shortcutsTW->scrollToItem(parent);
+ user_bind_.unbind(shortcut, func);
+ break;
+ }
+ case UserUnbind: {
+ // for user_unbind, we remove the unbind, and the item
+ // become System again.
+ user_unbind_.unbind(shortcut, func);
+ setItemType(items[i], System);
+ removePB->setText(toqstr("Remove"));
+ break;
+ }
+ case UserExtraUnbind: {
+ // for user unbind that is not in system bind file,
+ // remove this unbind file
+ QTreeWidgetItem * parent = items[i]->parent();
+ parent->takeChild(parent->indexOfChild(items[i]));
+ user_unbind_.unbind(shortcut, func);
+ }
+ }
+ }