[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdevelop/3.4/parts/astyle
From: Megan Webb <kdeveloper.megan () gmail ! com>
Date: 2006-12-04 12:21:40
Message-ID: 1165234900.027238.3226.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 610450 by webb:
Bug: 137913
Bug: 105396
Fix applying all the options. Added more sample code to the style
examples. Updated some tool tips.
M +24 -12 astyle_adaptor.cpp
M +2 -1 astyle_part.cpp
M +8 -3 astyle_widget.cpp
M +9 -4 astyleconfig.ui
--- branches/kdevelop/3.4/parts/astyle/astyle_adaptor.cpp #610449:610450
@@ -7,7 +7,7 @@
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qcheckbox.h>
-
+#include <kdebug.h>
#include <kapplication.h>
#include <kconfig.h>
@@ -40,12 +40,20 @@
KDevFormatter::KDevFormatter(const QMap<QString, QVariant>& options)
{
+// for ( QMap<QString, QVariant>::ConstIterator iter = options.begin();iter != \
options.end();iter++ ) +// {
+// kdDebug ( 9009 ) << "format: " << iter.key() << "=" << iter.data() << endl;
+// }
+
+ setCStyle();
+
// style
QString s = options["FStyle"].toString();
if ( predefinedStyle( s ) )
{
return;
}
+
// fill
int wsCount = options["FillCount"].toInt();
if (options["Fill"].toString() == "Tabs")
@@ -57,9 +65,11 @@
setSpaceIndentation(wsCount);
m_indentString = "";
m_indentString.fill(' ', wsCount);
- setTabSpaceConversionMode(options["FillForce"].toBool());
}
+ setTabSpaceConversionMode(options["FillForce"].toBool());
+ setEmptyLineFill(options["Fill_EmptyLines"].toBool());
+
// indent
setSwitchIndent(options["IndentSwitches"].toBool());
setClassIndent(options["IndentClasses"].toBool());
@@ -67,6 +77,8 @@
setBracketIndent(options["IndentBrackets"].toBool());
setNamespaceIndent(options["IndentNamespaces"].toBool());
setLabelIndent(options["IndentLabels"].toBool());
+ setBlockIndent(options["IndentBlocks"].toBool());
+ setPreprocessorIndent(options["IndentPreprocessors"].toBool());
// continuation
setMaxInStatementIndentLength(options["MaxStatement"].toInt());
@@ -84,16 +96,7 @@
else
setBracketFormatMode(astyle::NONE_MODE);
- // padding
- setOperatorPaddingMode(options["PadOperators"].toBool());
- setParensInsidePaddingMode(options["PadParenthesesIn"].toBool());
- setParensOutsidePaddingMode(options["PadParenthesesOut"].toBool());
- setParensUnPaddingMode(options["PadParenthesesUn"].toBool());
-
- // oneliner
- setBreakOneLineBlocksMode(options["KeepBlocks"].toBool());
- setSingleStatementsMode(options["KeepStatements"].toBool());
-
+ setBreakClosingHeaderBracketsMode(options["BracketsCloseHeaders"].toBool());
// blocks
setBreakBlocksMode(options["BlockBreak"].toBool());
if (options["BlockBreakAll"].toBool()){
@@ -102,6 +105,15 @@
}
setBreakElseIfsMode(options["BlockIfElse"].toBool());
+ // padding
+ setOperatorPaddingMode(options["PadOperators"].toBool());
+ setParensInsidePaddingMode(options["PadParenthesesIn"].toBool());
+ setParensOutsidePaddingMode(options["PadParenthesesOut"].toBool());
+ setParensUnPaddingMode(options["PadParenthesesUn"].toBool());
+
+ // oneliner
+ setBreakOneLineBlocksMode(!options["KeepBlocks"].toBool());
+ setSingleStatementsMode(!options["KeepStatements"].toBool());
}
KDevFormatter::KDevFormatter( AStyleWidget * widget )
--- branches/kdevelop/3.4/parts/astyle/astyle_part.cpp #610449:610450
@@ -73,8 +73,9 @@
// kdDebug(9009) << "Load global"<<endl;
KConfig *config = kapp->config();
config->setGroup("AStyle");
- QString options = \
config->readEntry("Options","BlockBreak=0,BlockBreakAll=0,BlockIfElse=0,Brackets=Break \
,BracketsCloseHeaders=0,FStyle=UserDefined,Fill=Tabs,FillCount=4,FillEmptyLines=0,Fill \
Force=0,IndentBlocks=0,IndentBrackets=0,IndentCases=1,IndentClasses=1,IndentLabels=1,I \
ndentNamespaces=1,IndentPreprocessors=0,IndentSwitches=0,KeepBlocks=0,KeepStatements=0 \
,MaxStatement=40,MinConditional=-1,PadOperators=1,PadParenthesesIn=1,PadParenthesesOut=0,PadParenthesesUn=1,");
+ QString options = \
config->readEntry("Options","BlockBreak=0,BlockBreakAll=0,BlockIfElse=0,Brackets=Break \
,BracketsCloseHeaders=0,FStyle=UserDefined,Fill=Tabs,FillCount=4,FillEmptyLines=0,Fill \
Force=0,IndentBlocks=0,IndentBrackets=0,IndentCases=0,IndentClasses=1,IndentLabels=1,I \
ndentNamespaces=1,IndentPreprocessors=0,IndentSwitches=1,KeepBlocks=1,KeepStatements=1 \
,MaxStatement=40,MinConditional=-1,PadOperators=0,PadParenthesesIn=1,PadParenthesesOut=1,PadParenthesesUn=1,");
+
QStringList pairs = QStringList::split( ",", options);
QStringList::Iterator it;
for ( it = pairs.begin(); it != pairs.end(); ++it ) {
--- branches/kdevelop/3.4/parts/astyle/astyle_widget.cpp #610449:610450
@@ -249,6 +249,11 @@
m_part->saveGlobal();
}
+// for ( QMap<QString, QVariant>::ConstIterator iter = m_option->begin();iter != \
m_option->end();iter++ ) +// {
+// kdDebug ( 9009 ) << "widget: " << iter.key() << "=" << iter.data() << endl;
+// }
+
}
@@ -271,11 +276,11 @@
StyleExample->clear();
- QString bracketSample = "if (isFoo){\n\tbar();\n} else {\n\tbar();\n}\n";
+ QString bracketSample = "namespace foospace {\n\tint Foo(){\n\tif \
(isBar)\n{\nbar(); \n\treturn 1; } else \nreturn 0;}}\n\nvoid test(){\n\tif \
(isFoo){\n\tbar();\n} else\n{\n\tbar();\n}\n}\n";
- QString indentSample = "#define foobar(A)\\\n{Foo();Bar();}\n#define \
anotherFoo(B)\\\nreturn Bar()\n\nnamespace Bar\n{\nclass \
Foo\n{public:\nFoo();\nvirtual !Foo();\n};\nswitch (foo)\n{\ncase \
1:\na+=1;\nbreak;\ncase 2:\n{\na += 2;\n break;\n}\n}\nif \
(isFoo)\n{\nbar();\n{\nelse\n{\nanotherBar();\n}\n}\nint \
foo()\n\twhile(isFoo)\n\t\t{\n\t\t\t...\n\t\t\tgoto \
error;\n\t\t....\n\t\terror:\n\t\t\t...\n\t\t}\n\t}\nfooArray[]={ \
red,\n\tgreen,\n\tdarkblue};\nfooFunction(barArg1,\n\tbarArg2,\n\tbarArg3);\n"; \
+ QString indentSample = "#define foobar(A)\\\n{Foo();Bar();}\n#define \
anotherFoo(B)\\\nreturn Bar()\n\nnamespace Bar\n{\nclass \
Foo\n{public:\nFoo();\nvirtual !Foo();\n};\nswitch (foo)\n{\ncase \
1:\na+=1;\nbreak;\ncase 2:\n{\na += 2;\n break;\n}\n}\nif \
(isFoo)\n{\nbar();\n}\nelse\n{\nanotherBar();\n}\nint \
foo()\n\twhile(isFoo)\n\t\t{\n\t\t\t...\n\t\t\tgoto \
error;\n\t\t....\n\t\terror:\n\t\t\t...\n\t\t}\n\t}\nfooArray[]={ \
red,\n\tgreen,\n\tdarkblue};\nfooFunction(barArg1,\n\tbarArg2,\n\tbarArg3);\n";
- QString formattingSample = \
"if(isFoo(a,b))\n\tbar(a,b);\nif(isFoo)\n\ta=bar((b-c)*a,*d--);\nif( isFoo( a,b ) \
)\n\tbar(a, b);\nif (isFoo) {isFoo=false;cat << isFoo <<endl;}\nif(isFoo)DoBar();if \
(isFoo){\n\tbar();\n\telse if(isBar()){\n\tannotherBar();\n}\n"; + QString \
formattingSample = "void \
func(){\n\tif(isFoo(a,b))\n\tbar(a,b);\nif(isFoo)\n\ta=bar((b-c)*a,*d--);\nif( \
isFoo( a,b ) )\n\tbar(a, b);\nif (isFoo) {isFoo=false;cat << isFoo \
<<endl;}\nif(isFoo)DoBar();if (isFoo){\n\tbar();\n}\n\telse \
if(isBar()){\n\tannotherBar();\n}\n}\n";
QString styleSample = "\t//Tabs & Brackets\nnamespace foo{\n" + bracketSample + \
"}\n\t// Indentation\n" + indentSample + "\t// Formatting\n" + formattingSample;
--- branches/kdevelop/3.4/parts/astyle/astyleconfig.ui #610449:610450
@@ -453,7 +453,8 @@
<string>&Attach</string>
</property>
<property name="toolTip" stdset="0">
- <string>Attach brackets to pre-block code (i.e. \
Java/K&R style).</string> + <string>Attach \
brackets to pre-block code (i.e. Java/K&R style). +See also \
Formatting/Blocks/Break if-else</string> </property>
</widget>
<widget class="QCheckBox" row="5" column="0">
@@ -467,7 +468,8 @@
<string>Break &closing headers</string>
</property>
<property name="toolTip" stdset="0">
- <string>Break brackets before closing headers \
(e.g. 'else', 'catch', ...).</string> + \
<string>Break brackets before closing headers (e.g. 'else', 'catch', ...) +from their \
immediately preceding closing brackets.</string> </property>
</widget>
<widget class="QRadioButton" row="3" column="0">
@@ -478,7 +480,8 @@
<string>Linu&x style</string>
</property>
<property name="toolTip" stdset="0">
- <string>Break definition-block brackets and \
attach command-block brackets.</string> + \
<string>Break brackets from class/function declarations, +but attach brackets to \
pre-block command statements.</string> </property>
</widget>
<spacer row="4" column="0">
@@ -857,7 +860,9 @@
<string>&Add spaces around \
operators</string> </property>
<property name="toolTip" stdset="0">
- <string>Insert space paddings around \
operators.</string> + <string>Insert space padding \
around operators. +Once padded, operators stay padded.
+There is no unpad operator option.</string>
</property>
</widget>
</vbox>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic