<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 14px;" lang="x-western">I just started using qyoto and
I am really liking it. I have a patch to submit.
<br>
<br>
The most recent commit added some options to the uics tool, so
this should be fresh in someones memory. I would like to add one
more option. Namely the ability to specify the access modifier for
member variables.
<br>
<br>
Here is the patch:
<br>
<br>
From 128e12578f4ee20a9491337464cc3ed9dd6ed93b Mon Sep 17 00:00:00
2001
<br>
From: David Lechner <a class="moz-txt-link-rfc2396E"
href="mailto:david@lechnology.com"><david@lechnology.com></a>
<br>
Date: Thu, 31 Jan 2013 12:50:46 -0600
<br>
Subject: [PATCH] add member access modifier option
<br>
<br>
---
<br>
tools/uics/cs/cswritedeclaration.cpp | 28
+++++++++++++++++++++++-----
<br>
tools/uics/main.cpp | 10 +++++++++-
<br>
tools/uics/option.h | 1 +
<br>
3 files changed, 33 insertions(+), 6 deletions(-)
<br>
<br>
diff --git a/tools/uics/cs/cswritedeclaration.cpp
b/tools/uics/cs/cswritedeclaration.cpp
<br>
index ccfb3ef..efccdf1 100644
<br>
--- a/tools/uics/cs/cswritedeclaration.cpp
<br>
+++ b/tools/uics/cs/cswritedeclaration.cpp
<br>
@@ -163,10 +163,13 @@ void WriteDeclaration::acceptUI(DomUI *node)
<br>
void WriteDeclaration::acceptWidget(DomWidget *node)
<br>
{
<br>
QString className = QLatin1String("QWidget");
<br>
+ QString memberAccess = QString("public").trimmed();
<br>
if (node->hasAttributeClass())
<br>
className = node->attributeClass();
<br>
+ if (!option.memberAccess.isEmpty())
<br>
+ memberAccess = option.memberAccess;
<br>
<br>
- output << option.indent << "public " <<
uic->customWidgetsInfo()->realClassName(className) <<
" " << driver->findOrInsertWidget(node) << ";\n";
<br>
+ output << option.indent << memberAccess <<
" " <<
uic->customWidgetsInfo()->realClassName(className) <<
" " << driver->findOrInsertWidget(node) << ";\n";
<br>
<br>
TreeWalker::acceptWidget(node);
<br>
}
<br>
@@ -174,31 +177,46 @@ void
WriteDeclaration::acceptWidget(DomWidget *node)
<br>
void WriteDeclaration::acceptLayout(DomLayout *node)
<br>
{
<br>
QString className = QLatin1String("QLayout");
<br>
+ QString memberAccess = QString("public").trimmed();
<br>
if (node->hasAttributeClass())
<br>
className = node->attributeClass();
<br>
+ if (!option.memberAccess.isEmpty())
<br>
+ memberAccess = option.memberAccess;
<br>
<br>
- output << option.indent << "public " <<
className << " " <<
driver->findOrInsertLayout(node) << ";\n";
<br>
+ output << option.indent << memberAccess <<
" " << className << " " <<
driver->findOrInsertLayout(node) << ";\n";
<br>
<br>
TreeWalker::acceptLayout(node);
<br>
}
<br>
<br>
void WriteDeclaration::acceptSpacer(DomSpacer *node)
<br>
{
<br>
- output << option.indent << "public QSpacerItem "
<< driver->findOrInsertSpacer(node) << ";\n";
<br>
+ QString memberAccess = QString("public").trimmed();
<br>
+ if (!option.memberAccess.isEmpty())
<br>
+ memberAccess = option.memberAccess;
<br>
+
<br>
+ output << option.indent << memberAccess <<
" QSpacerItem " << driver->findOrInsertSpacer(node)
<< ";\n";
<br>
<br>
TreeWalker::acceptSpacer(node);
<br>
}
<br>
<br>
void WriteDeclaration::acceptActionGroup(DomActionGroup *node)
<br>
{
<br>
- output << option.indent << "public QActionGroup "
<< driver->findOrInsertActionGroup(node) << ";\n";
<br>
+ QString memberAccess = QString("public").trimmed();
<br>
+ if (!option.memberAccess.isEmpty())
<br>
+ memberAccess = option.memberAccess;
<br>
+
<br>
+ output << option.indent << memberAccess <<
" QActionGroup " << driver->findOrInsertActionGroup(node)
<< ";\n";
<br>
<br>
TreeWalker::acceptActionGroup(node);
<br>
}
<br>
<br>
void WriteDeclaration::acceptAction(DomAction *node)
<br>
{
<br>
- output << option.indent << "public QAction "
<< driver->findOrInsertAction(node) << ";\n";
<br>
+ QString memberAccess = QString("public").trimmed();
<br>
+ if (!option.memberAccess.isEmpty())
<br>
+ memberAccess = option.memberAccess;
<br>
+
<br>
+ output << option.indent << memberAccess <<
" QAction " << driver->findOrInsertAction(node) <<
";\n";
<br>
<br>
TreeWalker::acceptAction(node);
<br>
}
<br>
diff --git a/tools/uics/main.cpp b/tools/uics/main.cpp
<br>
index 719b227..4dc3153 100644
<br>
--- a/tools/uics/main.cpp
<br>
+++ b/tools/uics/main.cpp
<br>
@@ -45,7 +45,8 @@ void showHelp(const char *appName)
<br>
" -x generate extra code to
test the class\n"
<br>
" -n, -namespace generate the class in
this namespace\n"
<br>
" -c, -class generate the class with
this name\n"
<br>
- " -a, -access the access modofier of
the class\n"
<br>
+ " -a, -access the access modifier of
the class\n"
<br>
+ " -ma, -member-access the access modifier of
the member variables\n"
<br>
"\n", appName);
<br>
}
<br>
<br>
@@ -129,6 +130,13 @@ int main(int argc, char *argv[])
<br>
return 1;
<br>
}
<br>
driver.option().access = QLatin1String(argv[arg]);
<br>
+ } else if (opt == QLatin1String("-ma") || opt ==
QLatin1String("-member-access")) {
<br>
+ ++arg;
<br>
+ if (!argv[arg]) {
<br>
+ showHelp(argv[0]);
<br>
+ return 1;
<br>
+ }
<br>
+ driver.option().memberAccess =
QLatin1String(argv[arg]);
<br>
} else if (!fileName) {
<br>
fileName = argv[arg];
<br>
} else {
<br>
diff --git a/tools/uics/option.h b/tools/uics/option.h
<br>
index a785452..867ed52 100644
<br>
--- a/tools/uics/option.h
<br>
+++ b/tools/uics/option.h
<br>
@@ -49,6 +49,7 @@ struct Option
<br>
QString name_space;
<br>
QString klass;
<br>
QString access;
<br>
+ QString memberAccess;
<br>
QString translateFunction;
<br>
QString uic3;
<br>
#ifdef QT_UIC_JAVA_GENERATOR
<br>
<div class="moz-txt-sig"><span class="moz-txt-tag">-- <br>
</span>1.7.10.4
<br>
<br>
<br>
</div>
</div>
</body>
</html>