KDECore
kuitformats.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <kuitformats_p.h>
00021
00022 #include <config.h>
00023 #include <kglobal.h>
00024 #include <klocale.h>
00025
00026 #include <QStringList>
00027 #include <QRegExp>
00028
00029 #include <kdebug.h>
00030
00031 QString KuitFormats::toKeyCombo (const QString &shstr, const QString &delim,
00032 const QHash<QString, QString> &keydict)
00033 {
00034 static QRegExp delRx("[+-]");
00035
00036 int p = delRx.indexIn(shstr);
00037
00038 QStringList keys;
00039 if (p < 0) {
00040 keys.append(shstr);
00041 }
00042 else {
00043 QChar oldDelim = shstr[p];
00044 keys = shstr.split(oldDelim, QString::SkipEmptyParts);
00045 }
00046
00047 for (int i = 0; i < keys.size(); ++i) {
00048
00049 QString nkey = keys[i].trimmed().toLower();
00050 bool isFunctionKey = nkey.length() > 1 && nkey[1].isDigit();
00051 if (!isFunctionKey) {
00052 keys[i] = keydict.contains(nkey) ? keydict[nkey] : keys[i].trimmed();
00053 }
00054 else {
00055 keys[i] = keydict["f%1"].arg(nkey.mid(1));
00056 }
00057 }
00058 return keys.join(delim);
00059 }
00060
00061 QString KuitFormats::toInterfacePath (const QString &inpstr,
00062 const QString &delim)
00063 {
00064 static QRegExp delRx("\\||->");
00065
00066 int p = delRx.indexIn(inpstr);
00067 if (p < 0) {
00068 return inpstr;
00069 }
00070 else {
00071 QString oldDelim = delRx.capturedTexts().at(0);
00072 QStringList guiels = inpstr.split(oldDelim, QString::SkipEmptyParts);
00073 return guiels.join(delim);
00074 }
00075 }
00076