X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Futil.cpp;h=a55946c360c811cabfcaed183b0c2411e682a4af;hb=3e54b38220f4fdf0af117f490bb8287ab2121aeb;hp=8b9231e19f8cd4fb22f3416c74c7958639e81e62;hpb=e052c6532456d818b804ce726c8a6e66c81ad8a0;p=quassel.git diff --git a/src/common/util.cpp b/src/common/util.cpp index 8b9231e1..a55946c3 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -60,6 +60,22 @@ QString stripFormatCodes(QString str) { return str; } +QString stripAcceleratorMarkers(const QString &label_) { + QString label = label_; + int p = 0; + forever { + p = label.indexOf('&', p); + if(p < 0 || p + 1 >= label.length()) + break; + + if(label.at(p + 1).isLetterOrNumber() || label.at(p + 1) == '&') + label.remove(p, 1); + + ++p; + } + return label; +} + QString decodeString(const QByteArray &input, QTextCodec *codec) { // First, we check if it's utf8. It is very improbable to encounter a string that looks like // valid utf8, but in fact is not. This means that if the input string passes as valid utf8, it