@@ -218,6 +218,18 @@ static void addListRegistration(AbstractMetaType::shared_pointer type, QSet<QStr
218218 }
219219}
220220
221+ namespace {
222+ QStringList capitalize (QStringList parts)
223+ {
224+ for (QString& p : parts) {
225+ if (p.length () > 0 ) {
226+ p[0 ] = p[0 ].toUpper ();
227+ }
228+ }
229+ return parts;
230+ }
231+ }
232+
221233void SetupGenerator::generate ()
222234{
223235 AbstractMetaClassList classes_with_polymorphic_id;
@@ -245,9 +257,19 @@ void SetupGenerator::generate()
245257
246258 QString packKey = ShellGenerator::toFileNameBase (pack.key ());
247259 QString packName = packKey;
248- QString qtPackageName = " Qt" + pack.key ().split (' .' ).back ().split (' _' ).front ();
249- bool isBuiltin = packKey.endsWith (" _builtin" );
250- QString initName = qtPackageName + (isBuiltin ? " Builtin" : " " );
260+ QString packageName = pack.key ();
261+ QString trolltechPrefix = " com.trolltech." ;
262+ if (packageName.startsWith (trolltechPrefix)) {
263+ // remove this prefix
264+ packageName = packageName.mid (trolltechPrefix.length ());
265+ }
266+ packageName = capitalize (packageName.split (' .' )).join (" " );
267+ bool isBuiltin = packageName.endsWith (" _builtin" );
268+ if (isBuiltin) {
269+ // remove trailing _builtin from packageName:
270+ packageName = packageName.left (packageName.length () - 8 );
271+ }
272+ QString initName = packageName + (isBuiltin ? " Builtin" : " " );
251273
252274 {
253275 QString fileName (packName + " /" + packKey + " _init.cpp" );
@@ -336,12 +358,12 @@ void SetupGenerator::generate()
336358 operatorCodes = " 0" ;
337359 }
338360 if (cls->isQObject ()) {
339- s << " PythonQt::priv()->registerClass(&" << cls->qualifiedCppName () << " ::staticMetaObject, \" " << qtPackageName <<" \" , PythonQtCreateObject<PythonQtWrapper_" << cls->name () << " >" << shellCreator << " , module, " << operatorCodes <<" );" << endl;
361+ s << " PythonQt::priv()->registerClass(&" << cls->qualifiedCppName () << " ::staticMetaObject, \" " << packageName <<" \" , PythonQtCreateObject<PythonQtWrapper_" << cls->name () << " >" << shellCreator << " , module, " << operatorCodes <<" );" << endl;
340362 } else if (cls->isGlobalNamespace ()) {
341- s << " PythonQt::priv()->registerGlobalNamespace(\" " << cls->qualifiedCppName () << " \" , \" " << qtPackageName << " \" , PythonQtCreateObject<PythonQtWrapper_" << cls->name () << " >, PythonQtWrapper_" << cls->name () << " ::staticMetaObject, module); " << endl;
363+ s << " PythonQt::priv()->registerGlobalNamespace(\" " << cls->qualifiedCppName () << " \" , \" " << packageName << " \" , PythonQtCreateObject<PythonQtWrapper_" << cls->name () << " >, PythonQtWrapper_" << cls->name () << " ::staticMetaObject, module); " << endl;
342364 } else {
343365 QString baseName = cls->baseClass ()?cls->baseClass ()->qualifiedCppName ():" " ;
344- s << " PythonQt::priv()->registerCPPClass(\" " << cls->qualifiedCppName () << " \" , \" " << baseName << " \" , \" " << qtPackageName <<" \" , PythonQtCreateObject<PythonQtWrapper_" << cls->name () << " >" << shellCreator << " , module, " << operatorCodes <<" );" << endl;
366+ s << " PythonQt::priv()->registerCPPClass(\" " << cls->qualifiedCppName () << " \" , \" " << baseName << " \" , \" " << packageName <<" \" , PythonQtCreateObject<PythonQtWrapper_" << cls->name () << " >" << shellCreator << " , module, " << operatorCodes <<" );" << endl;
345367 }
346368 for (AbstractMetaClass* interface : cls->interfaces ()) {
347369 // the interface might be our own class... (e.g. QPaintDevice)
0 commit comments