comparison tools/duic/d/dwriteinitialization.cpp @ 56:d5a6b6269f44

duic is working now on the first testcase, if there are any issues with it please report
author eldar
date Mon, 18 May 2009 22:15:59 +0000
parents 2085c2157b50
children 454e4b4beb59
comparison
equal deleted inserted replaced
55:63c31e221118 56:d5a6b6269f44
478 const QString varName = m_driver->findOrInsertWidget(node->elementWidget()); 478 const QString varName = m_driver->findOrInsertWidget(node->elementWidget());
479 m_registeredWidgets.insert(varName, node->elementWidget()); // register the main widget 479 m_registeredWidgets.insert(varName, node->elementWidget()); // register the main widget
480 480
481 const QString widgetClassName = node->elementWidget()->attributeClass(); 481 const QString widgetClassName = node->elementWidget()->attributeClass();
482 482
483 m_output << m_option.indent << "void " << "setupUi(" << widgetClassName << " *" << varName << ")\n" 483 m_output << m_option.indent << "void " << "setupUi(" << widgetClassName << " " << varName << ")\n"
484 << m_option.indent << "{\n"; 484 << m_option.indent << "{\n";
485 485
486 if (m_activateScripts) 486 if (m_activateScripts)
487 writeSetupUIScriptVariableDeclarations( m_option.indent, m_output); 487 writeSetupUIScriptVariableDeclarations( m_option.indent, m_output);
488 488
530 530
531 if (!m_delayedInitialization.isEmpty()) 531 if (!m_delayedInitialization.isEmpty())
532 m_output << "\n" << m_delayedInitialization << "\n"; 532 m_output << "\n" << m_delayedInitialization << "\n";
533 533
534 if (m_option.autoConnection) 534 if (m_option.autoConnection)
535 m_output << "\n" << m_option.indent << "QMetaObject.connectSlotsByName(" << varName << ");\n"; 535 m_output << "\n" << m_option.indent << "// QMetaObject.connectSlotsByName(" << varName << ");\n";
536 536
537 m_output << m_option.indent << "} // setupUi\n\n"; 537 m_output << m_option.indent << "} // setupUi\n\n";
538 538
539 if (m_delayedActionInitialization.isEmpty()) { 539 if (m_delayedActionInitialization.isEmpty()) {
540 m_refreshInitialization += m_option.indent; 540 m_refreshInitialization += m_option.indent;
541 m_refreshInitialization += QLatin1String("Q_UNUSED("); 541 m_refreshInitialization += QLatin1String("Q_UNUSED(");
542 m_refreshInitialization += varName ; 542 m_refreshInitialization += varName ;
543 m_refreshInitialization +=QLatin1String(");\n"); 543 m_refreshInitialization +=QLatin1String(");\n");
544 } 544 }
545 545
546 m_output << m_option.indent << "void " << "retranslateUi(" << widgetClassName << " *" << varName << ")\n" 546 m_output << m_option.indent << "void " << "retranslateUi(" << widgetClassName << " " << varName << ")\n"
547 << m_option.indent << "{\n" 547 << m_option.indent << "{\n"
548 << m_refreshInitialization 548 << m_refreshInitialization
549 << m_option.indent << "} // retranslateUi\n\n"; 549 << m_option.indent << "} // retranslateUi\n\n";
550 550
551 m_layoutChain.pop(); 551 m_layoutChain.pop();
1033 DomWidget *buttonGroupWidget = findWidget(QLatin1String("Q3ButtonGroup")); 1033 DomWidget *buttonGroupWidget = findWidget(QLatin1String("Q3ButtonGroup"));
1034 1034
1035 QString indent; 1035 QString indent;
1036 if (!m_widgetChain.top()) { 1036 if (!m_widgetChain.top()) {
1037 indent = QLatin1String(" "); 1037 indent = QLatin1String(" ");
1038 m_output << m_option.indent << "if (" << varName << ".objectName().isEmpty())\n"; 1038 m_output << m_option.indent << "if (" << varName << ".objectName().length == 0)\n";
1039 } 1039 }
1040 m_output << m_option.indent << indent << varName << ".setObjectName(QString.fromUtf8(" << fixString(varName, m_option.indent) << "));\n"; 1040 m_output << m_option.indent << indent << varName << ".setObjectName(QString.fromUtf8(" << fixString(varName, m_option.indent) << "));\n";
1041 1041
1042 int leftMargin, topMargin, rightMargin, bottomMargin; 1042 int leftMargin, topMargin, rightMargin, bottomMargin;
1043 leftMargin = topMargin = rightMargin = bottomMargin = -1; 1043 leftMargin = topMargin = rightMargin = bottomMargin = -1;
1170 propertyValue = QString::fromLatin1("QCursor(Qt.%1)") 1170 propertyValue = QString::fromLatin1("QCursor(Qt.%1)")
1171 .arg(p->elementCursorShape()); 1171 .arg(p->elementCursorShape());
1172 break; 1172 break;
1173 case DomProperty::Enum: 1173 case DomProperty::Enum:
1174 propertyValue = p->elementEnum(); 1174 propertyValue = p->elementEnum();
1175 if (!propertyValue.contains(QLatin1String("."))) { 1175 if (!propertyValue.contains(QLatin1String("::"))) {
1176 QString scope = className; 1176 QString scope = className;
1177 scope += QLatin1String("."); 1177 scope += QLatin1String("::");
1178 propertyValue.prepend(scope); 1178 propertyValue.prepend(scope);
1179 } 1179 }
1180 propertyValue = propertyValue.replace("::", "."); // qtd
1180 break; 1181 break;
1181 case DomProperty::Set: 1182 case DomProperty::Set:
1182 propertyValue = p->elementSet(); 1183 propertyValue = p->elementSet();
1183 break; 1184 break;
1184 case DomProperty::Font: 1185 case DomProperty::Font:
2269 { 2270 {
2270 if (str.isEmpty()) 2271 if (str.isEmpty())
2271 return QLatin1String("QString()"); 2272 return QLatin1String("QString()");
2272 2273
2273 QString result; 2274 QString result;
2274 const QString comment = commentHint.isEmpty() ? QString(QLatin1Char('0')) : fixString(commentHint, m_option.indent); 2275 const QString comment = commentHint.isEmpty() ? QString("null") : fixString(commentHint, m_option.indent);
2275 2276
2276 if (m_option.translateFunction.isEmpty()) { 2277 if (m_option.translateFunction.isEmpty()) {
2277 result = QLatin1String("QApplication.translate(\""); 2278 result = QLatin1String("QApplication.translate(\"");
2278 result += m_generatedClass; 2279 result += m_generatedClass;
2279 result += QLatin1Char('"'); 2280 result += QLatin1Char('"');
2415 const QString sender = findDeclaration(connection->elementSender()); 2416 const QString sender = findDeclaration(connection->elementSender());
2416 const QString receiver = findDeclaration(connection->elementReceiver()); 2417 const QString receiver = findDeclaration(connection->elementReceiver());
2417 2418
2418 if (sender.isEmpty() || receiver.isEmpty()) 2419 if (sender.isEmpty() || receiver.isEmpty())
2419 return; 2420 return;
2420 2421 // qtd signal
2421 m_output << m_option.indent << "QObject.connect(" 2422 QRegExp excl_brackets("\\((.*)\\)");
2423 QString stripped_signal = connection->elementSignal().remove(excl_brackets);
2424 QString stripped_slot = connection->elementSlot().remove(excl_brackets);
2425 m_output << m_option.indent
2422 << sender 2426 << sender
2423 << ", " 2427 << "." << stripped_signal
2424 << "SIGNAL(" << connection->elementSignal() << ')' 2428 << ".connect"
2425 << ", " 2429 << "(&" << receiver << "."
2426 << receiver 2430 << stripped_slot << ");\n";
2427 << ", "
2428 << "SLOT(" << connection->elementSlot() << ')'
2429 << ");\n";
2430 } 2431 }
2431 2432
2432 DomImage *WriteInitialization::findImage(const QString &name) const 2433 DomImage *WriteInitialization::findImage(const QString &name) const
2433 { 2434 {
2434 return m_registeredImages.value(name); 2435 return m_registeredImages.value(name);