[Kde-bindings] playground/bindings/kimono

Arno Rehn kde at arnorehn.de
Sat Oct 7 20:45:56 UTC 2006


SVN commit 593434 by arnorehn:

* Fixed some problems with enums in uics.

* Fixed problem where SetupUi() and RetranslateUi() weren't accessible
  due to a missing 'public'

CCMAIL: kde-bindings at kde.org



 M  +6 -0      ChangeLog  
 M  +26 -0     qyoto/Qyoto.cs  
 M  +1 -1      uics/cs/cswritedeclaration.cpp  
 M  +25 -6     uics/cs/cswriteinitialization.cpp  


--- trunk/playground/bindings/kimono/ChangeLog #593433:593434
@@ -1,5 +1,11 @@
 2006-10-06  Arno Rehn  <arno at arnorehn.de>
 
+	* Fixed some problems with enums in uics.
+	* Fixed problem where SetupUi() and RetranslateUi() weren't accessible
+	  due to a missing 'public'
+
+2006-10-06  Arno Rehn  <arno at arnorehn.de>
+
 	* Copied over some fixes from QtRuby:
 		* Fixed a bug in slot return values where they were only
 		  working when a signal was emitted in Ruby, and not when
--- trunk/playground/bindings/kimono/qyoto/Qyoto.cs #593433:593434
@@ -34,6 +34,32 @@
 		/// This hashtable has classe names as keys, and QMetaObjects as values
 		static Hashtable metaObjects = new Hashtable();
 		
+		public static int GetCPPEnumValue(string c, string value) {
+			Type t = Type.GetType("Qyoto." + c, false);
+			if (t == null) {
+#if DEBUG
+				Console.WriteLine("NULL");
+#endif
+				return 0;
+			}
+			foreach (Type nt in t.GetNestedTypes()) {
+				if (nt.IsEnum) {
+#if DEBUG
+					Console.WriteLine("ENUM: {0}", nt.ToString());
+#endif
+					foreach (int i in Enum.GetValues(nt)) {
+#if DEBUG
+						Console.WriteLine("MEMBER: {0}", Enum.Format(nt, i, "f"));
+#endif
+						if (Enum.Format(nt, i, "f") == value) {
+							return i;
+						}
+					}
+				}
+			}
+			return 0;
+		}
+		
 		public static bool IsSmokeClass(Type t) {
 			object[] attr = t.GetCustomAttributes(typeof(SmokeClass), false);
 			return attr.Length > 0;
--- trunk/playground/bindings/kimono/uics/cs/cswritedeclaration.cpp #593433:593434
@@ -92,7 +92,7 @@
     if (node->elementImages()) {
         output << "\n"
             // << "protected:\n"
-            << option.indent << "enum IconID\n"
+            << option.indent << "protected enum IconID\n"
             << option.indent << "{\n";
         WriteIconDeclaration(uic).acceptUI(node);
 
--- trunk/playground/bindings/kimono/uics/cs/cswriteinitialization.cpp #593433:593434
@@ -76,7 +76,7 @@
 
     QString widgetClassName = node->elementWidget()->attributeClass();
 
-    output << option.indent << "void " << "SetupUi(" << widgetClassName << " " << varName << ")\n"
+    output << option.indent << "public void " << "SetupUi(" << widgetClassName << " " << varName << ")\n"
            << option.indent << "{\n";
 
     QStringList connections = uic->databaseInfo()->connections();
@@ -132,7 +132,7 @@
         m_refreshInitialization += option.indent + QLatin1String("Q_UNUSED(") + varName + QLatin1String(");\n");
     }*/
 
-    output << option.indent << "void " << "RetranslateUi(" << widgetClassName << " " << varName << ")\n"
+    output << option.indent << "public void " << "RetranslateUi(" << widgetClassName << " " << varName << ")\n"
            << option.indent << "{\n"
            << m_refreshInitialization
            << option.indent << "} // RetranslateUi\n\n";
@@ -345,7 +345,7 @@
             if (properties.contains(QLatin1String("spacing")))
                 spacing = properties.value(QLatin1String("spacing"))->elementNumber();
 
-            output << option.indent << parent << ".SetColumnLayout(0, Qt.Vertical);\n";
+            output << option.indent << parent << ".SetColumnLayout(0, Qt.Orientation.Vertical);\n";
 
             if (spacing != INT_MIN) {
                 QString value = QString::number(spacing);
@@ -438,7 +438,7 @@
     QString orientation = properties.contains(QLatin1String("orientation"))
         ? properties.value(QLatin1String("orientation"))->elementEnum() : QString();
 
-    bool isVspacer = orientation == QLatin1String("Qt.Vertical")
+    bool isVspacer = orientation == QLatin1String("Qt::Vertical")
         || orientation == QLatin1String("Vertical");
 
     output << option.indent << varName << " = new QSpacerItem(";
@@ -646,7 +646,16 @@
             output << option.indent << varName << ".SetFrameShape(" << shape << ");\n";
             output << option.indent << varName << ".SetFrameShadow(QFrame.Shadow.Sunken);\n";
             continue;
-        }
+        } /*else if (propertyName == QLatin1String("orientation")) {
+            // orientation hack for C#
+            QString orientation = QLatin1String("");
+            if (p->elementEnum() == QLatin1String("Qt::Vertical"))
+                orientation = QLatin1String("Qt.Orientation.Vertical");
+            if (p->elementEnum() == QLatin1String("Qt::Horizontal"))
+                orientation = QLatin1String("Qt.Orientation.Horizontal");
+            output << option.indent << varName << ".SetOrientation(" << orientation << ");\n";
+            continue;
+        }*/
 
         bool stdset = m_stdsetdef;
         if (p->hasAttributeStdset())
@@ -693,11 +702,20 @@
             break;
         case DomProperty::Enum:
             propertyValue = p->elementEnum();
-            if (!propertyValue.contains(QLatin1String("::")))
+            if (propertyValue.contains(QLatin1String("::"))) {
+                QStringList parts = propertyValue.split("::");
+                propertyValue = parts[0] + QLatin1String(".") + propertyName.left(1).toUpper() + propertyName.mid(1) + QLatin1String(".") + parts[1];
+            }
+            if (!p->elementEnum().contains(QLatin1String("::")))
                 propertyValue.prepend(className + QLatin1String(QLatin1String(".")));
             break;
         case DomProperty::Set:
+            // this need special treatment because in C++ the enums aren't specified
             propertyValue = p->elementSet();
+            if (propertyValue.contains(QLatin1String("::"))) {
+                QStringList parts = propertyValue.split("::");
+                propertyValue = QLatin1String("Qyoto.Qyoto.GetCPPEnumValue(\"") + parts[0] + "\", \"" + parts[1] + QLatin1String("\")");
+            }
             break;
         case DomProperty::Font: {
             DomFont *f = p->elementFont();
@@ -893,6 +911,7 @@
                     }
                 }
             }
+            propertyValue += QLatin1String("]");
             break;
 
         case DomProperty::Url: {



More information about the Kde-bindings mailing list