@@ -68,7 +68,8 @@ namespace Core::Internal {
68
68
actionsFilterLayout->addWidget (findShortcutButton);
69
69
actionsLayout->addLayout (actionsFilterLayout);
70
70
auto actionsTreeWidget = new QTreeWidget;
71
- actionsTreeWidget->setHeaderLabels ({tr (" Name" ), tr (" ID" ), tr (" Shortcut" )});
71
+ actionsTreeWidget->setHeaderLabels ({tr (" Name" ), tr (" Shortcut" )});
72
+ actionsTreeWidget->setContextMenuPolicy (Qt::CustomContextMenu);
72
73
actionsLayout->addWidget (actionsTreeWidget);
73
74
actionsGroupBox->setLayout (actionsLayout);
74
75
mainLayout->addWidget (actionsGroupBox);
@@ -109,7 +110,6 @@ namespace Core::Internal {
109
110
actionsTreeWidget->resizeColumnToContents (0 );
110
111
actionsTreeWidget->resizeColumnToContents (1 );
111
112
actionsTreeWidget->collapseAll ();
112
- actionsTreeWidget->setContextMenuPolicy (Qt::CustomContextMenu);
113
113
114
114
connect (m_presetComboBox, QOverload<int >::of (&QComboBox::currentIndexChanged), this , [=](int index ) {
115
115
m_shortcutInfo.clear ();
@@ -259,6 +259,7 @@ namespace Core::Internal {
259
259
private:
260
260
enum ItemDataRole {
261
261
ShortcutRole = Qt::UserRole,
262
+ IDRole,
262
263
};
263
264
264
265
QComboBox *m_presetComboBox;
@@ -273,7 +274,8 @@ namespace Core::Internal {
273
274
auto domain = ICore::instance ()->actionManager ()->domain ();
274
275
item->setText (0 , ActionObjectInfo::translatedCategory (catalog.name ()));
275
276
item->setIcon (0 , domain->objectIcon (qIDec->theme (), catalog.id ()));
276
- item->setText (1 , catalog.id ());
277
+ item->setData (0 , IDRole, catalog.id ());
278
+ item->setTextAlignment (1 , Qt::AlignRight);
277
279
for (const auto &childCatalog : catalog.children ()) {
278
280
auto childItem = new QTreeWidgetItem;
279
281
traverseCatalog (childItem, childCatalog);
@@ -285,7 +287,7 @@ namespace Core::Internal {
285
287
auto actionMgr = ICore::instance ()->actionManager ();
286
288
auto shortcutsFamily = m_presetComboBox->currentData ().toBool () ? actionMgr->systemShortcutsFamily (m_presetComboBox->currentText ()) : actionMgr->userShortcutsFamily (m_presetComboBox->currentText ());
287
289
auto domain = ICore::instance ()->actionManager ()->domain ();
288
- auto id = item->text ( 1 );
290
+ auto id = item->data ( 0 , IDRole). toString ( );
289
291
for (int i = 0 ; i < item->childCount (); i++) {
290
292
traverseShortcuts (item->child (i));
291
293
}
@@ -297,7 +299,7 @@ namespace Core::Internal {
297
299
shortcuts = modification.value (id);
298
300
} else if (!m_presetComboBox->currentData ().toBool () && m_userShortcutFamilyAddition.contains (m_presetComboBox->currentText ())) {
299
301
shortcuts = m_userShortcutFamilyAddition.value (m_presetComboBox->currentText ()).value (id, domain->objectInfo (id).shortcuts ());
300
- } else if (shortcutsFamily.value (item->text ( 1 ))) {
302
+ } else if (shortcutsFamily.value (item->data ( 0 , IDRole). toString ( ))) {
301
303
shortcuts = shortcutsFamily.value (id).value ();
302
304
} else {
303
305
shortcuts = domain->objectInfo (id).shortcuts ();
@@ -307,7 +309,7 @@ namespace Core::Internal {
307
309
m_shortcutInfo.insert (keySeq.toString (), item);
308
310
}
309
311
310
- item->setText (2 , shortcutTexts.join (' ' ));
312
+ item->setText (1 , shortcutTexts.join (' ' ));
311
313
item->setData (0 , ShortcutRole, QVariant::fromValue (shortcuts));
312
314
}
313
315
@@ -322,7 +324,7 @@ namespace Core::Internal {
322
324
if (!text.isEmpty ())
323
325
item->setExpanded (true );
324
326
return true ;
325
- } else if (item->text (0 ).contains (text, Qt::CaseInsensitive) || item->text ( 1 ).contains (text, Qt::CaseInsensitive)) {
327
+ } else if (item->text (0 ).contains (text, Qt::CaseInsensitive) || item->data ( 0 , IDRole). toString ( ).contains (text, Qt::CaseInsensitive)) {
326
328
item->setHidden (false );
327
329
return true ;
328
330
} else {
@@ -355,11 +357,11 @@ namespace Core::Internal {
355
357
shortcutTexts.append (" [" + shortcut.toString (QKeySequence::NativeText) + " ]" );
356
358
}
357
359
if (m_presetComboBox->currentData ().toBool ()) {
358
- m_systemShortcutFamilyModification[m_presetComboBox->currentText ()].insert (item->text ( 1 ), shortcuts);
360
+ m_systemShortcutFamilyModification[m_presetComboBox->currentText ()].insert (item->data ( 0 , IDRole). toString ( ), shortcuts);
359
361
} else {
360
- m_userShortcutFamilyModification[m_presetComboBox->currentText ()].insert (item->text ( 1 ), shortcuts);
362
+ m_userShortcutFamilyModification[m_presetComboBox->currentText ()].insert (item->data ( 0 , IDRole). toString ( ), shortcuts);
361
363
}
362
- item->setText (2 , shortcutTexts.join (' ' ));
364
+ item->setText (1 , shortcutTexts.join (' ' ));
363
365
}
364
366
365
367
void promptShortcut (QTreeWidgetItem *item) {
0 commit comments