# HG changeset patch # User Wuzzy # Date 1557253431 -7200 # Node ID 089f0c10ca95fdeb72e7a72d7718300696e15b60 # Parent 505c8d101be3727af7b5aabaf96ce51f99a2a315 Frontend: Optimize control conflict handling a bit diff -r 505c8d101be3 -r 089f0c10ca95 QTfrontend/ui/widget/keybinder.cpp --- a/QTfrontend/ui/widget/keybinder.cpp Tue May 07 19:39:08 2019 +0200 +++ b/QTfrontend/ui/widget/keybinder.cpp Tue May 07 20:23:51 2019 +0200 @@ -314,7 +314,6 @@ // check if the given key is bound multiple times bool KeyBinder::checkConflictsWith(int compareTo, bool updateState) { - // TODO: Make conflict check more efficient for(int i=0; isetHidden(false); } - QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]); - item->setIcon(*conflictIcon); - item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A))); - item->setForeground(QBrush(Qt::white)); - item = bindComboBoxCellMappings->value(CBBind[compareTo]); - item->setIcon(*conflictIcon); - item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A))); - item->setForeground(QBrush(Qt::white)); + QTableWidgetItem* conflictItem = bindComboBoxCellMappings->value(CBBind[i]); + conflictItem->setIcon(*conflictIcon); + conflictItem->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A))); + conflictItem->setForeground(QBrush(Qt::white)); + conflictItems.append(conflictItem); + conflictItem = bindComboBoxCellMappings->value(CBBind[compareTo]); + conflictItem->setIcon(*conflictIcon); + conflictItem->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A))); + conflictItem->setForeground(QBrush(Qt::white)); + conflictItems.append(conflictItem); return true; } - else - { - QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]); - item->setIcon(*dropDownIcon); - item->setBackground(QBrush(Qt::transparent)); - item->setForeground(QBrush(QColor("#F6CB1C"))); - item = bindComboBoxCellMappings->value(CBBind[compareTo]); - item->setIcon(*dropDownIcon); - item->setBackground(QBrush(Qt::transparent)); - item->setForeground(QBrush(QColor("#F6CB1C"))); - } } if(updateState) { p_hasConflicts = false; conflictLabel->setHidden(true); } + for (int c=0; c < conflictItems.size(); c++) + { + QTableWidgetItem* conflictItem = conflictItems[c]; + conflictItem->setIcon(*dropDownIcon); + conflictItem->setBackground(QBrush(Qt::transparent)); + conflictItem->setForeground(QBrush(QColor("#F6CB1C"))); + conflictItem = NULL; + } + conflictItems.clear(); return false; } diff -r 505c8d101be3 -r 089f0c10ca95 QTfrontend/ui/widget/keybinder.h --- a/QTfrontend/ui/widget/keybinder.h Tue May 07 19:39:08 2019 +0200 +++ b/QTfrontend/ui/widget/keybinder.h Tue May 07 20:23:51 2019 +0200 @@ -60,6 +60,7 @@ QIcon * conflictIcon; QString defaultText; bool enableSignal; + QList conflictItems; bool p_hasConflicts; signals: