[PyKDE] 3 bugs (+patches) in pyuic3

Rene Hogendoorn rene.hogendoorn at hccnet.nl
Mon Mar 11 08:05:24 GMT 2002


Pyuic3 has three problems when QDataView, QDataBrowser or QDataTable is present in the .ui file

1. the declaration of 'from qtsql import ...' is not generated correctly (syntax error)
2. QDataView, QDataBrowser and QDataTable are not imported from qtsql
3. the treatment of stringlists is incorrect (declared as 'self.XX_stringlist', used and returned
   as 'XX_stringlist')

The following patch to form.cpp addresses 1 and 2:

Index: pyuic3/form.cpp
===================================================================
RCS file: /home/cvs/public/PyQt/pyuic3/form.cpp,v
retrieving revision 1.8
diff -u -r1.8 form.cpp
--- pyuic3/form.cpp	24 Feb 2002 01:36:06 -0000	1.8
+++ pyuic3/form.cpp	10 Mar 2002 21:49:15 -0000
@@ -173,41 +173,6 @@
 	}
     }
 
-    registerDatabases( e );
-    dbConnections = unique( dbConnections );
-    if ( dbConnections.count() )
-	sqlClasses += "QSqlDatabase";
-    if ( dbCursors.count() )
-	sqlClasses += "QSqlCursor";
-    bool dbForm = FALSE;
-    if ( dbForms[ "(default)" ].count() )
-	dbForm = TRUE;
-    bool subDbForms = FALSE;
-    for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) {
-	if ( !(*it).isEmpty()  && (*it) != "(default)" ) {
-	    if ( dbForms[ (*it) ].count() ) {
-		subDbForms = TRUE;
-		break;
-	    }
-	}
-    }
-    if ( dbForm || subDbForms ) {
-	sqlClasses += "QSqlForm";
-	sqlClasses += "QSqlRecord";
-    }
-
-    if ( !sqlClasses.empty() ) {
-	out << indent << "from qtsql import";
-	char sep = ' ';
-
-	for ( it = sqlClasses.begin(); it != sqlClasses.end(); ++it ) {
-	    out << sep << (*it) << endl;
-	    sep = ',';
-	}
-
-	out << endl;
-    }
-
     // do the local includes afterwards, since global includes have priority on clashes
     for ( i = 0; i < (int) nl.length(); i++ ) {
 	QDomElement n2 = nl.item(i).toElement();
@@ -257,6 +222,52 @@
 	out << indent << "from qttable import QTable" << endl;
 
     out << endl;
+
+    registerDatabases( e );
+    dbConnections = unique( dbConnections );
+    if ( ! dbConnections.empty() )
+	sqlClasses += "QSqlDatabase";
+    if ( ! dbCursors.empty() )
+	sqlClasses += "QSqlCursor";
+    bool dbForm = FALSE;
+    if ( ! dbForms[ "(default)" ].empty() )
+	dbForm = TRUE;
+    bool subDbForms = FALSE;
+    for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) {
+	if ( !(*it).isEmpty()  && (*it) != "(default)" ) {
+	    if ( ! dbForms[ (*it) ].empty() ) {
+		subDbForms = TRUE;
+		break;
+	    }
+	}
+    }
+    if ( dbForm || subDbForms ) {
+	sqlClasses += "QSqlForm";
+	sqlClasses += "QSqlRecord";
+    }
+
+    if (globalIncludes.findIndex("qdatatable.h") >= 0)
+	sqlClasses += "QDataTable";
+       
+    if (globalIncludes.findIndex("qtableview.h") >= 0)
+	sqlClasses += "QTableView";
+       
+    if (globalIncludes.findIndex("qdatabrowser.h") >= 0)
+	sqlClasses += "QDataBrowser";
+       
+
+    if ( ! sqlClasses.empty() ) {
+	it = sqlClasses.begin();
+
+	// sqlClasses is not empty, so
+	out << indent << "from qtsql import " << (*it);
+
+	for ( ++it; it != sqlClasses.end(); ++it ) {
+	   out << ', \\' << endl << "     " << (*it);
+	}
+
+	out << endl;
+    }
 
     // find out what images are required
     QStringList requiredImages;

The following patch to object.cpp addresses 3:

Index: pyuic3/object.cpp
===================================================================
RCS file: /home/cvs/public/PyQt/pyuic3/object.cpp,v
retrieving revision 1.6
diff -u -r1.6 object.cpp
--- pyuic3/object.cpp	24 Feb 2002 01:36:06 -0000	1.6
+++ pyuic3/object.cpp	10 Mar 2002 22:05:26 -0000
@@ -574,11 +574,10 @@
 	QString listname = "l";
 	if ( !obj.isEmpty() ) {
 	    listname = obj + "_stringlist";
-	    listname = registerObject( listname );
-	    out << indent << "self." << listname << " = QStringList()" << endl;
-	} else {
-	    out << indent << listname << " = QStringList()" << endl;
+	    listname = "self." + registerObject( listname );
 	}
+	out << indent << listname << " = QStringList()" << endl;
+
 	while ( !n3.isNull() ) {
 	    if ( n3.tagName() == "string" )
 		out << indent << listname << ".append(\"" << n3.firstChild().toText().data().simplifyWhiteSpace() << "\")" << endl;





More information about the PyQt mailing list