- // We need to access the root model, not the filtered one
- for(int cat = 0; cat < _shortcutsModel->rowCount(); cat++) {
- QModelIndex catIdx = _shortcutsModel->index(cat, 0);
- for(int r = 0; r < _shortcutsModel->rowCount(catIdx); r++) {
- QModelIndex actIdx = _shortcutsModel->index(r, 0, catIdx);
- Q_ASSERT(actIdx.isValid());
- if(actIdx.data(ShortcutsModel::ActiveShortcutRole).value<QKeySequence>() != seq)
- continue;
-
- if(!actIdx.data(ShortcutsModel::IsConfigurableRole).toBool()) {
- QMessageBox::warning(this, tr("Shortcut Conflict"),
- tr("The \"%1\" shortcut is already in use, and cannot be configured.\nPlease choose another one.").arg(seq.toString()),
- QMessageBox::Ok);
- return false;
- }
-
- QMessageBox box(QMessageBox::Warning, tr("Shortcut Conflict"),
- (tr("The \"%1\" shortcut is ambiguous with the shortcut for the following action:")
- + "<br><ul><li>%2</li></ul><br>"
- + tr("Do you want to reassign this shortcut to the selected action?")
- ).arg(seq.toString(), actIdx.data().toString()),
- QMessageBox::Cancel, this);
- box.addButton(tr("Reassign"), QMessageBox::AcceptRole);
- if(box.exec() == QMessageBox::Cancel)
- return false;
-
- _conflictingIndex = actIdx;
- return true;
+bool KeySequenceWidget::isKeySequenceAvailable(const QKeySequence &seq)
+{
+ if (seq.isEmpty())
+ return true;
+
+ // We need to access the root model, not the filtered one
+ for (int cat = 0; cat < _shortcutsModel->rowCount(); cat++) {
+ QModelIndex catIdx = _shortcutsModel->index(cat, 0);
+ for (int r = 0; r < _shortcutsModel->rowCount(catIdx); r++) {
+ QModelIndex actIdx = _shortcutsModel->index(r, 0, catIdx);
+ Q_ASSERT(actIdx.isValid());
+ if (actIdx.data(ShortcutsModel::ActiveShortcutRole).value<QKeySequence>() != seq)
+ continue;
+
+ if (!actIdx.data(ShortcutsModel::IsConfigurableRole).toBool()) {
+ QMessageBox::warning(this, tr("Shortcut Conflict"),
+ tr("The \"%1\" shortcut is already in use, and cannot be configured.\nPlease choose another one.").arg(seq.toString(QKeySequence::NativeText)),
+ QMessageBox::Ok);
+ return false;
+ }
+
+ QMessageBox box(QMessageBox::Warning, tr("Shortcut Conflict"),
+ (tr("The \"%1\" shortcut is ambiguous with the shortcut for the following action:")
+ + "<br><ul><li>%2</li></ul><br>"
+ + tr("Do you want to reassign this shortcut to the selected action?")
+ ).arg(seq.toString(QKeySequence::NativeText), actIdx.data().toString()),
+ QMessageBox::Cancel, this);
+ box.addButton(tr("Reassign"), QMessageBox::AcceptRole);
+ if (box.exec() == QMessageBox::Cancel)
+ return false;
+
+ _conflictingIndex = actIdx;
+ return true;
+ }