void ArticleTagSearch::setTag(const std::string& _tag) { if(_tag.empty() || std::find_if(_tag.begin(), _tag.end(), invalidChar()) != _tag.end()) throw InvalidValue(gettext("invalid tag")); tag = _tag; }
void KRestrictedLine::keyPressEvent( QKeyEvent *e ) { if (e->key() == Key_Enter || e->key() == Key_Return) { emit returnPressed(); return; } // let QLineEdit process "special" keys // so that we still can use the default key binding if (e->ascii() < 32) { QLineEdit::keyPressEvent(e); return; } // do we have a list of valid chars && // is the pressed key in the list of valid chars? if (!qsValidChars.isEmpty() && !qsValidChars.contains((char)e->ascii())) { // invalid char, emit signal and return emit (invalidChar(e->key())); return; } else // valid char: let QLineEdit process this key as usual QLineEdit::keyPressEvent(e); return; }