[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kdecore/kconfig_compiler
From:       Waldo Bastian <bastian () kde ! org>
Date:       2004-08-03 11:10:38
Message-ID: 20040803111038.AE0D39A40 () office ! kde ! org
[Download RAW message or body]

CVS commit by waba: 

Add support for multiline label / whatsthis texts. (BR86435)
CCMAIL: 86435-done@bugs.kde.org


  M +20 -10    kconfig_compiler.cpp   1.53


--- kdelibs/kdecore/kconfig_compiler/kconfig_compiler.cpp  #1.52:1.53
@@ -211,4 +211,14 @@ static void addQuotes( QString &s )
 }
 
+static QString quoteString( const QString &s )
+{
+  QString r = s;
+  r.replace( "\\", "\\\\" );
+  r.replace( "\"", "\\\"" );
+  r.replace( "\r", "" );
+  r.replace( "\n", "\\n\"\n\"" );
+  return "\"" + r + "\"";
+}
+
 static QString dumpNode(const QDomNode &node)
 {
@@ -700,18 +710,18 @@ QString userTextsFunctions( CfgEntry *e,
   if (itemVarStr.isNull()) itemVarStr=itemVar(e);
   if ( !e->label().isEmpty() ) {
-    txt += "  " + itemVarStr + "->setLabel( i18n(\"";
+    txt += "  " + itemVarStr + "->setLabel( i18n(";
     if ( !e->param().isEmpty() )
-      txt += e->label().replace("$("+e->param()+")", i);
+      txt += quoteString(e->label().replace("$("+e->param()+")", i));
     else 
-      txt+= e->label();
-    txt+= "\") );\n";
+      txt+= quoteString(e->label());
+    txt+= ") );\n";
   }
   if ( !e->whatsThis().isEmpty() ) {
-    txt += "  " + itemVarStr + "->setWhatsThis( i18n(\"";
+    txt += "  " + itemVarStr + "->setWhatsThis( i18n(";
     if ( !e->param().isEmpty() )
-      txt += e->whatsThis().replace("$("+e->param()+")", i);
+      txt += quoteString(e->whatsThis().replace("$("+e->param()+")", i));
     else 
-      txt+= e->whatsThis();
-    txt+="\") );\n";
+      txt+= quoteString(e->whatsThis());
+    txt+=") );\n";
   }
   return txt;
@@ -1241,7 +1251,7 @@ int main( int argc, char **argv )
         if ( setUserTexts ) {
           if ( !(*it).label.isEmpty() )
-            cpp << "    choice.label = i18n(\"" << (*it).label << "\");" << endl;
+            cpp << "    choice.label = i18n(" << quoteString((*it).label) << ");" << endl;
           if ( !(*it).whatsThis.isEmpty() )
-            cpp << "    choice.whatsThis = i18n(\"" << (*it).whatsThis << "\");" << endl;
+            cpp << "    choice.whatsThis = i18n(" << quoteString((*it).whatsThis) << ");" << endl;
         }
         cpp << "    values" << e->name() << ".append( choice );" << endl;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic