• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kuitformats.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries
00002     Copyright (C) 2007 Chusslove Illich <caslav.ilic@gmx.net>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
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); // find delimiter
00037 
00038     QStringList keys;
00039     if (p < 0) { // single-key shortcut, no delimiter found
00040         keys.append(shstr);
00041     }
00042     else { // multi-key shortcut
00043         QChar oldDelim = shstr[p];
00044         keys = shstr.split(oldDelim, QString::SkipEmptyParts);
00045     }
00046 
00047     for (int i = 0; i < keys.size(); ++i) {
00048         // Normalize key, trim and all lower-case.
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); // find delimiter
00067     if (p < 0) { // single-element path, no delimiter found
00068         return inpstr;
00069     }
00070     else { // multi-element path
00071         QString oldDelim = delRx.capturedTexts().at(0);
00072         QStringList guiels = inpstr.split(oldDelim, QString::SkipEmptyParts);
00073         return guiels.join(delim);
00074     }
00075 }
00076 

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal