[Kde-bindings] playground/bindings/kimono
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Wed Jan 31 12:14:28 UTC 2007
SVN commit 628785 by rdale:
* Added an '-x' option to the uics tool to generate a Main method
for testing purposes
CCMAIL: kde-bindings at kde.org
M +2 -0 ChangeLog
M +7 -4 uics/cs/cswritedeclaration.cpp
M +5 -0 uics/main.cpp
M +2 -0 uics/option.h
M +18 -0 uics/uic.cpp
--- trunk/playground/bindings/kimono/ChangeLog #628784:628785
@@ -2,6 +2,8 @@
* Changed the uics code generation to use C# properties
* Special case shortcut properties to create a QKeySequence
+ * Added an '-x' option to the uics tool to generate a Main method
+ for testing purposes
2007-30-01 Arno Rehn <arno at arnorehn.de>
--- trunk/playground/bindings/kimono/uics/cs/cswritedeclaration.cpp #628784:628785
@@ -68,11 +68,14 @@
if (nsList.count())
output << "\n";
+ if (option.execCode) {
+ output << "partial class " << exportMacro << option.prefix << className << "\n"
+ << "{\n";
+ } else {
+ output << "class " << exportMacro << option.prefix << className << "\n"
+ << "{\n";
+ }
- output << "class " << exportMacro << option.prefix << className << "\n"
- << "{\n";
- //<< "public:\n";
-
QStringList connections = uic->databaseInfo()->connections();
for (int i=0; i<connections.size(); ++i) {
QString connection = connections.at(i);
--- trunk/playground/bindings/kimono/uics/main.cpp #628784:628785
@@ -42,6 +42,7 @@
" -tr <func> use func() for i18n\n"
" -p, -no-protection disable header protection\n"
" -g <name> change generator\n"
+ " -x generate extra code to test the class\n"
"\n", appName);
}
@@ -69,6 +70,10 @@
return 1;
}
driver.option().outputFile = QFile::decodeName(argv[arg]);
+#ifdef QT_UIC_CS_GENERATOR
+ } else if (opt == QLatin1String("-x")) {
+ driver.option().execCode = 1;
+#endif
} else if (opt == QLatin1String("-p") || opt == QLatin1String("-no-protection")) {
driver.option().headerProtection = false;
} else if (opt == QLatin1String("-postfix")) {
--- trunk/playground/bindings/kimono/uics/option.h #628784:628785
@@ -38,6 +38,7 @@
unsigned int generateNamespace : 1;
unsigned int autoConnection : 1;
unsigned int dependencies : 1;
+ unsigned int execCode : 1;
Generator generator;
QString inputFile;
@@ -59,6 +60,7 @@
generateNamespace(1),
autoConnection(1),
dependencies(0),
+ execCode(0),
generator(CppGenerator),
prefix(QLatin1String("Ui_"))
{ indent.fill(QLatin1Char(' '), 4); }
--- trunk/playground/bindings/kimono/uics/uic.cpp #628784:628785
@@ -203,8 +203,26 @@
WriteIncludes(this).acceptUI(ui);
Validator(this).acceptUI(ui);
+
WriteDeclaration(this).acceptUI(ui);
+ if (option().execCode) {
+ QString qualifiedClassName = ui->elementClass() + option().postfix;
+ QString className = qualifiedClassName;
+ out << "partial class " << option().prefix << className << " {" << endl;
+ out << option().indent << "public static int Main(string[] args) {" << endl;
+ out << option().indent << option().indent << "new QApplication(args);" << endl;
+ out << option().indent << option().indent << option().prefix << className << " u = new " << option().prefix << className << "();" << endl;
+ DomWidget* parentWidget = ui->elementWidget();
+ QString parentClass = parentWidget->attributeClass();
+ out << option().indent << option().indent << parentClass << " w = new " << parentClass << "();" << endl;
+ out << option().indent << option().indent << "u.SetupUi(w);" << endl;
+ out << option().indent << option().indent << "w.Show();" << endl;
+ out << option().indent << option().indent << "return QApplication.Exec();" << endl;
+ out << option().indent << "}" << endl;
+ out << "}" << endl;
+ }
+
if (opt.headerProtection)
writeHeaderProtectionEnd();
More information about the Kde-bindings
mailing list