Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

KHUtil.cpp

Go to the documentation of this file.
00001 #include "KHUtil.h"
00002 #include <qwindowsystem_qws.h>
00003 
00004 int KHUtil::hex2int(const QString& hexstr, bool* ok)
00005 {
00006         int val;
00007         bool success;
00008         if(hexstr.find("0x") == 0){
00009                 val = hexstr.mid(2).toInt(&success, 16);
00010         } else {
00011                 val = hexstr.toInt(&success, 16);
00012         }
00013         if(!success){
00014                 val = 0;
00015         }
00016         if(ok){
00017                 *ok = success;
00018         }
00019         return(val);
00020 }
00021 
00022 const QStringList KHUtil::parseArgs(const QString& arguments)
00023 {
00024         QString str;
00025         QStringList args;
00026         char quote = 0;
00027         char c;
00028         for(unsigned int i=0; i<arguments.length(); i++){
00029                 c = arguments[i];
00030                 switch(c){
00031                 case '\"':
00032                         if(quote == 0){
00033                                 quote = c;
00034                         } else if(quote == '\"'){
00035                                 if(str.length() > 0){
00036                                         args.append(str);
00037                                 }
00038                                 str = "";
00039                                 quote = 0;
00040                         } else {
00041                                 str += c;
00042                         }
00043                         break;
00044                 case '\'':
00045                         if(quote == 0){
00046                                 quote = c;
00047                         } else if(quote == '\''){
00048                                 if(str.length() > 0){
00049                                         args.append(str);
00050                                 }
00051                                 str = "";
00052                                 quote = 0;
00053                         } else {
00054                                 str += c;
00055                         }
00056                         break;
00057                 case ' ':
00058                         if(quote == 0){
00059                                 if(str.length() > 0){
00060                                         args.append(str);
00061                                         str = "";
00062                                 }
00063                         } else {
00064                                 str += c;
00065                         }
00066                         break;
00067                 default:
00068                         str += c;
00069                         break;
00070                 }
00071         }
00072         if(str.length() > 0){
00073                 args.append(str);
00074         }
00075         return(args);
00076 }
00077 
00078 const QString KHUtil::currentApp()
00079 {
00080         QString app;
00081         const QList<QWSWindow>& list = qwsServer->clientWindows();
00082         QWSWindow* w;
00083         for(QListIterator<QWSWindow> it(list); (w=it.current()); ++it){
00084                 if(w->isVisible() && w->client()->identity() != QString::null){
00085                         app = w->client()->identity();
00086                         break;
00087                 }
00088         }
00089         return app;
00090 }

Generated on Sat Nov 5 16:16:43 2005 for OPIE by  doxygen 1.4.2