[Kde-bindings] qyoto - patch - member variable access modifier
David Lechner
david at lechnology.com
Thu Jan 31 19:42:27 UTC 2013
I just started using qyoto and I am really liking it. I have a patch to
submit.
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.
Here is the patch:
From 128e12578f4ee20a9491337464cc3ed9dd6ed93b Mon Sep 17 00:00:00 2001
From: David Lechner <david at lechnology.com>
Date: Thu, 31 Jan 2013 12:50:46 -0600
Subject: [PATCH] add member access modifier option
---
tools/uics/cs/cswritedeclaration.cpp | 28 +++++++++++++++++++++++-----
tools/uics/main.cpp | 10 +++++++++-
tools/uics/option.h | 1 +
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/tools/uics/cs/cswritedeclaration.cpp
b/tools/uics/cs/cswritedeclaration.cpp
index ccfb3ef..efccdf1 100644
--- a/tools/uics/cs/cswritedeclaration.cpp
+++ b/tools/uics/cs/cswritedeclaration.cpp
@@ -163,10 +163,13 @@ void WriteDeclaration::acceptUI(DomUI *node)
void WriteDeclaration::acceptWidget(DomWidget *node)
{
QString className = QLatin1String("QWidget");
+ QString memberAccess = QString("public").trimmed();
if (node->hasAttributeClass())
className = node->attributeClass();
+ if (!option.memberAccess.isEmpty())
+ memberAccess = option.memberAccess;
- output << option.indent << "public " <<
uic->customWidgetsInfo()->realClassName(className) << " " <<
driver->findOrInsertWidget(node) << ";\n";
+ output << option.indent << memberAccess << " " <<
uic->customWidgetsInfo()->realClassName(className) << " " <<
driver->findOrInsertWidget(node) << ";\n";
TreeWalker::acceptWidget(node);
}
@@ -174,31 +177,46 @@ void WriteDeclaration::acceptWidget(DomWidget *node)
void WriteDeclaration::acceptLayout(DomLayout *node)
{
QString className = QLatin1String("QLayout");
+ QString memberAccess = QString("public").trimmed();
if (node->hasAttributeClass())
className = node->attributeClass();
+ if (!option.memberAccess.isEmpty())
+ memberAccess = option.memberAccess;
- output << option.indent << "public " << className << " " <<
driver->findOrInsertLayout(node) << ";\n";
+ output << option.indent << memberAccess << " " << className << " "
<< driver->findOrInsertLayout(node) << ";\n";
TreeWalker::acceptLayout(node);
}
void WriteDeclaration::acceptSpacer(DomSpacer *node)
{
- output << option.indent << "public QSpacerItem " <<
driver->findOrInsertSpacer(node) << ";\n";
+ QString memberAccess = QString("public").trimmed();
+ if (!option.memberAccess.isEmpty())
+ memberAccess = option.memberAccess;
+
+ output << option.indent << memberAccess << " QSpacerItem " <<
driver->findOrInsertSpacer(node) << ";\n";
TreeWalker::acceptSpacer(node);
}
void WriteDeclaration::acceptActionGroup(DomActionGroup *node)
{
- output << option.indent << "public QActionGroup " <<
driver->findOrInsertActionGroup(node) << ";\n";
+ QString memberAccess = QString("public").trimmed();
+ if (!option.memberAccess.isEmpty())
+ memberAccess = option.memberAccess;
+
+ output << option.indent << memberAccess << " QActionGroup " <<
driver->findOrInsertActionGroup(node) << ";\n";
TreeWalker::acceptActionGroup(node);
}
void WriteDeclaration::acceptAction(DomAction *node)
{
- output << option.indent << "public QAction " <<
driver->findOrInsertAction(node) << ";\n";
+ QString memberAccess = QString("public").trimmed();
+ if (!option.memberAccess.isEmpty())
+ memberAccess = option.memberAccess;
+
+ output << option.indent << memberAccess << " QAction " <<
driver->findOrInsertAction(node) << ";\n";
TreeWalker::acceptAction(node);
}
diff --git a/tools/uics/main.cpp b/tools/uics/main.cpp
index 719b227..4dc3153 100644
--- a/tools/uics/main.cpp
+++ b/tools/uics/main.cpp
@@ -45,7 +45,8 @@ void showHelp(const char *appName)
" -x generate extra code to test
the class\n"
" -n, -namespace generate the class in this
namespace\n"
" -c, -class generate the class with this
name\n"
- " -a, -access the access modofier of the
class\n"
+ " -a, -access the access modifier of the
class\n"
+ " -ma, -member-access the access modifier of the
member variables\n"
"\n", appName);
}
@@ -129,6 +130,13 @@ int main(int argc, char *argv[])
return 1;
}
driver.option().access = QLatin1String(argv[arg]);
+ } else if (opt == QLatin1String("-ma") || opt ==
QLatin1String("-member-access")) {
+ ++arg;
+ if (!argv[arg]) {
+ showHelp(argv[0]);
+ return 1;
+ }
+ driver.option().memberAccess = QLatin1String(argv[arg]);
} else if (!fileName) {
fileName = argv[arg];
} else {
diff --git a/tools/uics/option.h b/tools/uics/option.h
index a785452..867ed52 100644
--- a/tools/uics/option.h
+++ b/tools/uics/option.h
@@ -49,6 +49,7 @@ struct Option
QString name_space;
QString klass;
QString access;
+ QString memberAccess;
QString translateFunction;
QString uic3;
#ifdef QT_UIC_JAVA_GENERATOR
--
1.7.10.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20130131/5597aa2f/attachment.html>
More information about the Kde-bindings
mailing list