QTfrontend/ui/widget/keybinder.cpp
changeset 14906 089f0c10ca95
parent 14905 505c8d101be3
child 15254 441bdf1e6026
equal deleted inserted replaced
14905:505c8d101be3 14906:089f0c10ca95
   312 }
   312 }
   313 
   313 
   314 // check if the given key is bound multiple times
   314 // check if the given key is bound multiple times
   315 bool KeyBinder::checkConflictsWith(int compareTo, bool updateState)
   315 bool KeyBinder::checkConflictsWith(int compareTo, bool updateState)
   316 {
   316 {
   317     // TODO: Make conflict check more efficient
       
   318     for(int i=0; i<BINDS_NUMBER; i++)
   317     for(int i=0; i<BINDS_NUMBER; i++)
   319     {
   318     {
   320         if(i == compareTo)
   319         if(i == compareTo)
   321             continue;
   320             continue;
   322         if(CBBind[i] == NULL || CBBind[compareTo] == NULL)
   321         if(CBBind[i] == NULL || CBBind[compareTo] == NULL)
   329             if(updateState)
   328             if(updateState)
   330             {
   329             {
   331                 p_hasConflicts = true;
   330                 p_hasConflicts = true;
   332                 conflictLabel->setHidden(false);
   331                 conflictLabel->setHidden(false);
   333             }
   332             }
   334             QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]);
   333             QTableWidgetItem* conflictItem = bindComboBoxCellMappings->value(CBBind[i]);
   335             item->setIcon(*conflictIcon);
   334             conflictItem->setIcon(*conflictIcon);
   336             item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
   335             conflictItem->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
   337             item->setForeground(QBrush(Qt::white));
   336             conflictItem->setForeground(QBrush(Qt::white));
   338             item = bindComboBoxCellMappings->value(CBBind[compareTo]);
   337             conflictItems.append(conflictItem);
   339             item->setIcon(*conflictIcon);
   338             conflictItem = bindComboBoxCellMappings->value(CBBind[compareTo]);
   340             item->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
   339             conflictItem->setIcon(*conflictIcon);
   341             item->setForeground(QBrush(Qt::white));
   340             conflictItem->setBackground(QBrush(QColor(0xE3, 0x1A, 0x1A)));
       
   341             conflictItem->setForeground(QBrush(Qt::white));
       
   342             conflictItems.append(conflictItem);
   342             return true;
   343             return true;
   343         }
       
   344         else
       
   345         {
       
   346             QTableWidgetItem* item = bindComboBoxCellMappings->value(CBBind[i]);
       
   347             item->setIcon(*dropDownIcon);
       
   348             item->setBackground(QBrush(Qt::transparent));
       
   349             item->setForeground(QBrush(QColor("#F6CB1C")));
       
   350             item = bindComboBoxCellMappings->value(CBBind[compareTo]);
       
   351             item->setIcon(*dropDownIcon);
       
   352             item->setBackground(QBrush(Qt::transparent));
       
   353             item->setForeground(QBrush(QColor("#F6CB1C")));
       
   354         }
   344         }
   355     }
   345     }
   356     if(updateState)
   346     if(updateState)
   357     {
   347     {
   358         p_hasConflicts = false;
   348         p_hasConflicts = false;
   359         conflictLabel->setHidden(true);
   349         conflictLabel->setHidden(true);
   360     }
   350     }
       
   351     for (int c=0; c < conflictItems.size(); c++)
       
   352     {
       
   353         QTableWidgetItem* conflictItem = conflictItems[c];
       
   354         conflictItem->setIcon(*dropDownIcon);
       
   355         conflictItem->setBackground(QBrush(Qt::transparent));
       
   356         conflictItem->setForeground(QBrush(QColor("#F6CB1C")));
       
   357         conflictItem = NULL;
       
   358     }
       
   359     conflictItems.clear();
   361     return false;
   360     return false;
   362 }
   361 }
   363 
   362 
   364 // check if any key is bound multiple times and causing a conflict
   363 // check if any key is bound multiple times and causing a conflict
   365 bool KeyBinder::checkConflicts()
   364 bool KeyBinder::checkConflicts()