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

List:       kde-commits
Subject:    KDE/kdelibs/kdecore/kconfig_compiler
From:       Chusslove Illich <caslav.ilic () gmx ! net>
Date:       2007-07-11 0:11:17
Message-ID: 1184112677.344802.15719.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 686292 by ilic:

Let <label> and <whatsthis> have context attribute.

 M  +51 -13    kconfig_compiler.cpp  


--- trunk/KDE/kdelibs/kdecore/kconfig_compiler/kconfig_compiler.cpp #686291:686292
@@ -123,6 +123,7 @@
     struct Choice
     {
       QString name;
+      QString context;
       QString label;
       QString whatsThis;
     };
@@ -148,13 +149,13 @@
     };
 
     CfgEntry( const QString &group, const QString &type, const QString &key,
-              const QString &name, const QString &label,
+              const QString &name, const QString &context, const QString &label,
               const QString &whatsThis, const QString &code,
               const QString &defaultValue, const Choices &choices, const QList<Signal> signalList,
               bool hidden )
       : mGroup( group ), mType( type ), mKey( key ), mName( name ),
-        mLabel( label ), mWhatsThis( whatsThis ), mCode( code ),
-        mDefaultValue( defaultValue ), mChoices( choices ),
+        mContext( context ), mLabel( label ), mWhatsThis( whatsThis ),
+        mCode( code ), mDefaultValue( defaultValue ), mChoices( choices ),
         mSignalList(signalList), mHidden( hidden )
     {
     }
@@ -171,6 +172,9 @@
     void setName( const QString &name ) { mName = name; }
     QString name() const { return mName; }
 
+    void setContext( const QString &context ) { mContext = context; }
+    QString context() const { return mContext; }
+
     void setLabel( const QString &label ) { mLabel = label; }
     QString label() const { return mLabel; }
 
@@ -222,6 +226,7 @@
       std::cerr << "  type: " << qPrintable(mType) << std::endl;
       std::cerr << "  key: " << qPrintable(mKey) << std::endl;
       std::cerr << "  name: " << qPrintable(mName) << std::endl;
+      std::cerr << "  context: " << qPrintable(mContext) << std::endl;
       std::cerr << "  label: " << qPrintable(mLabel) << std::endl;
 // whatsthis
       std::cerr << "  code: " << qPrintable(mCode) << std::endl;
@@ -245,6 +250,7 @@
     QString mType;
     QString mKey;
     QString mName;
+    QString mContext;
     QString mLabel;
     QString mWhatsThis;
     QString mCode;
@@ -495,6 +501,7 @@
   QString name = element.attribute( "name" );
   QString key = element.attribute( "key" );
   QString hidden = element.attribute( "hidden" );
+  QString context = element.attribute( "context" );
   QString label;
   QString whatsThis;
   QString defaultValue;
@@ -512,8 +519,14 @@
 
   for ( QDomElement e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement() ) {
     QString tag = e.tagName();
-    if ( tag == "label" ) label = e.text();
-    else if ( tag == "whatsthis" ) whatsThis = e.text();
+    if ( tag == "label" ) {
+      label = e.text();
+      context = e.attribute( "context" );
+    }
+    else if ( tag == "whatsthis" ) {
+      whatsThis = e.text();
+      context = e.attribute( "context" );
+    }
     else if ( tag == "min" ) minValue = e.text();
     else if ( tag == "max" ) maxValue = e.text();
     else if ( tag == "code" ) code = e.text();
@@ -590,8 +603,14 @@
             std::cerr << "Tag <choice> requires attribute 'name'." << std::endl;
           }
           for( QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement() ) {
-            if ( e3.tagName() == "label" ) choice.label = e3.text();
-            if ( e3.tagName() == "whatsthis" ) choice.whatsThis = e3.text();
+            if ( e3.tagName() == "label" ) {
+              choice.label = e3.text();
+              choice.context = e3.attribute( "context" );
+            }
+            if ( e3.tagName() == "whatsthis" ) {
+              choice.whatsThis = e3.text();
+              choice.context = e3.attribute( "context" );
+            }
           }
           chlist.append( choice );
         }
@@ -721,7 +740,7 @@
     preProcessDefault(defaultValue, name, type, choices, code);
   }
 
-  CfgEntry *result = new CfgEntry( group, type, key, name, label, whatsThis,
+  CfgEntry *result = new CfgEntry( group, type, key, name, context, label, whatsThis,
                                    code, defaultValue, choices, signalList,
                                    hidden == "true" );
   if (!param.isEmpty())
@@ -959,7 +978,11 @@
   QString txt;
   if (itemVarStr.isNull()) itemVarStr=itemPath(e);
   if ( !e->label().isEmpty() ) {
-    txt += "  " + itemVarStr + "->setLabel( i18n(";
+    txt += "  " + itemVarStr + "->setLabel( ";
+    if ( !e->context().isEmpty() )
+      txt += "i18nc(" + quoteString(e->context()) + ", ";
+    else
+      txt += "i18n(";
     if ( !e->param().isEmpty() )
       txt += quoteString(e->label().replace("$("+e->param()+')', i));
     else
@@ -967,7 +990,11 @@
     txt+= ") );\n";
   }
   if ( !e->whatsThis().isEmpty() ) {
-    txt += "  " + itemVarStr + "->setWhatsThis( i18n(";
+    txt += "  " + itemVarStr + "->setWhatsThis( ";
+    if ( !e->context().isEmpty() )
+      txt += "i18nc(" + quoteString(e->context()) + ", ";
+    else
+      txt += "i18n(";
     if ( !e->param().isEmpty() )
       txt += quoteString(e->whatsThis().replace("$("+e->param()+')', i));
     else
@@ -1821,10 +1848,21 @@
         cpp << "    KConfigSkeleton::ItemEnum::Choice choice;" << endl;
         cpp << "    choice.name = QLatin1String( \"" << (*it).name << "\" );" << endl;
         if ( setUserTexts ) {
-          if ( !(*it).label.isEmpty() )
-            cpp << "    choice.label = i18n(" << quoteString((*it).label) << ");" << endl;
+          if ( !(*it).label.isEmpty() ) {
+            cpp << "    choice.label = ";
+            if ( !(*it).context.isEmpty() )
+              cpp << "i18nc(" + quoteString((*it).context) + ", ";
+            else
+              cpp << "i18n(";
+            cpp << quoteString((*it).label) << ");" << endl;
+          }
           if ( !(*it).whatsThis.isEmpty() )
-            cpp << "    choice.whatsThis = i18n(" << quoteString((*it).whatsThis) << ");" << endl;
+            cpp << "    choice.whatsThis = ";
+            if ( !(*it).context.isEmpty() )
+              cpp << "i18nc(" + quoteString((*it).context) + ", ";
+            else
+              cpp << "i18n(";
+            cpp << quoteString((*it).whatsThis) << ");" << endl;
         }
         cpp << "    values" << (*itEntry)->name() << ".append( choice );" << endl;
         cpp << "  }" << endl;
[prev in list] [next in list] [prev in thread] [next in thread] 

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